[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/sprite_instance.h server...
From: |
Zou Lunkai |
Subject: |
[Gnash-commit] gnash ChangeLog server/sprite_instance.h server... |
Date: |
Sun, 08 Apr 2007 08:37:07 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Zou Lunkai <zoulunkai> 07/04/08 08:37:07
Modified files:
. : ChangeLog
server : sprite_instance.h sprite_instance.cpp
Added files:
testsuite/misc-ming.all: get_frame_number_test.c
Log message:
new testcase for get_frame_number() and fixs
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2810&r2=1.2811
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.90&r2=1.91
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.227&r2=1.228
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/get_frame_number_test.c?cvsroot=gnash&rev=1.1
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2810
retrieving revision 1.2811
diff -u -b -r1.2810 -r1.2811
--- ChangeLog 8 Apr 2007 08:06:58 -0000 1.2810
+++ ChangeLog 8 Apr 2007 08:37:07 -0000 1.2811
@@ -1,3 +1,11 @@
+2007-04-08 Zou Lunkai <address@hidden>
+
+ * testsuite/misc-ming.all:get_frame_number_test.c
+ new testcase for get_frame_number() and goto_frame().
+ *server/sprite_instance.h, sprite_instance.cpp
+ update implementation of get_frame_number() and goto_frame(),
+ fix the above the testcase.
+
2007-04-08 Sandro Santilli <address@hidden>
* testsuite/actionscript.all/XML.as: add tests for XML.attributes
Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -b -r1.90 -r1.91
--- server/sprite_instance.h 6 Apr 2007 15:36:05 -0000 1.90
+++ server/sprite_instance.h 8 Apr 2007 08:37:07 -0000 1.91
@@ -17,7 +17,7 @@
//
//
-/* $Id: sprite_instance.h,v 1.90 2007/04/06 15:36:05 strk Exp $ */
+/* $Id: sprite_instance.h,v 1.91 2007/04/08 08:37:07 zoulunkai Exp $ */
// Stateful live Sprite instance
@@ -279,14 +279,11 @@
/// Parse frame spec and return a 0-based frame number.
//
- /// If frame spec cannot be converted to !NAN number
+ /// If frame spec cannot be converted to !NAN and !Infinity number
/// it will be converted to a string and considered a
/// frame label (returns false if referring to an
/// unknwown label).
///
- /// If frame spec can be converted to a non-zero positive
- /// integer it will be "clamped" to the valid range.
- ///
/// @param frame_spec
/// The frame specification.
///
Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.227
retrieving revision 1.228
diff -u -b -r1.227 -r1.228
--- server/sprite_instance.cpp 6 Apr 2007 16:23:43 -0000 1.227
+++ server/sprite_instance.cpp 8 Apr 2007 08:37:07 -0000 1.228
@@ -1725,11 +1725,11 @@
as_environment* env = const_cast<as_environment*>(&m_as_environment);
- double num = frame_spec.to_number(env);
+ as_value str(frame_spec.to_std_string(env));
- // TODO: check if a frame labeled "0" or "-3" or "Infinite"
- // takes precedence over the numerical value.
- if ( isnan(num) )
+ double num = str.to_number(env);
+
+ if ( isnan(num) || isinf(num))
{
return m_def->get_labeled_frame(frame_spec.to_string(env),
&frameno);
}
@@ -1737,7 +1737,10 @@
// TODO: are we sure we shouldn't check for frames labeled with
negative numbers ?
if ( num < 1 ) return false;
- frameno = iclamp(int(num), 1, m_def->get_frame_count())-1;
+ // all frame numbers >= 0 are valid, but a valid frame number may still
+ // reference a non-exist frame(eg. frameno > total_frames).
+ frameno = num - 1;
+
return true;
}
@@ -2424,15 +2427,20 @@
assert(! isUnloaded() );
- // target_frame_number = iclamp(target_frame_number, 0,
m_def->get_frame_count() - 1);
- // Macromedia Flash ignores goto_frame(bad_frame)
- if (target_frame_number > m_def->get_frame_count() - 1 ||
- target_frame_number == m_current_frame) // to prevent
infinitive recursion
- {
- //FIXME: Don't set play state to STOP, just return will be more
correct.
- // m_current_frame will be incremented in next advance_sprite,
so I think
- // there will be no 'infinitive recursion' (Zou)
+ // goto_frame stops by default.
+ // ActionGotoFrame tells the movieClip to go to the target frame
+ // and stop at that frame.
set_play_state(STOP);
+
+ if(target_frame_number == m_current_frame)
+ {
+ // don't push actions
+ return;
+ }
+ if(target_frame_number > m_def->get_frame_count() - 1)
+ {
+ m_current_frame = m_def->get_frame_count() - 1;
+ // don't push actions
return;
}
@@ -2513,10 +2521,6 @@
// current frame should also be executed(Zou)
m_current_frame = target_frame_number;
- // goto_frame stops by default.
- // Zou: ActionGotoFrame tells the movieClip to go to the target frame
- // and stop at that frame.
- set_play_state(STOP);
// After entering to advance_sprite() m_current_frame points to frame
// that already is executed.
Index: testsuite/misc-ming.all/get_frame_number_test.c
===================================================================
RCS file: testsuite/misc-ming.all/get_frame_number_test.c
diff -N testsuite/misc-ming.all/get_frame_number_test.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/misc-ming.all/get_frame_number_test.c 8 Apr 2007 08:37:07
-0000 1.1
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+/*
+ * Zou Lunkai, address@hidden
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ming.h>
+
+#include "ming_utils.h"
+
+#define OUTPUT_VERSION 6
+#define OUTPUT_FILENAME "get_frame_number_test.swf"
+
+
+int
+main(int argc, char** argv)
+{
+ SWFMovie mo;
+ SWFMovieClip dejagnuclip;
+
+ const char *srcdir=".";
+ if ( argc>1 )
+ srcdir=argv[1];
+ else
+ {
+ fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
+ return 1;
+ }
+
+ Ming_init();
+ mo = newSWFMovieWithVersion(OUTPUT_VERSION);
+ SWFMovie_setDimension(mo, 800, 600);
+ SWFMovie_setRate (mo, 12.0);
+
+ dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0,
800, 600);
+ SWFMovie_add(mo, (SWFBlock)dejagnuclip);
+ SWFMovie_nextFrame(mo); /* 1st frame */
+
+
+ SWFMovie_labelFrame(mo, "8");
+ SWFMovie_nextFrame(mo); /* 2nd frame */
+
+ SWFMovie_labelFrame(mo, "8a");
+ SWFMovie_nextFrame(mo); /* 3rd frame */
+
+ SWFMovie_labelFrame(mo, "aa");
+ SWFMovie_nextFrame(mo); /* 4th frame*/
+
+ check_equals(mo, "_currentframe", "5");
+ add_actions(mo, " gotoAndStop('8'); "); // ActionGotoLabel
+ check_equals(mo, "_currentframe", "2");
+ add_actions(mo, " gotoAndStop('xxxxxxxx'); "); // ActionGotoLabel
+ check_equals(mo, "_currentframe", "2");
+ add_actions(mo, " gotoAndStop('Infinity'); "); // ActionGotoLabel
+ check_equals(mo, "_currentframe", "2");
+ add_actions(mo, " gotoAndStop(Infinity); "); // ActionGotoExpression
+ check_equals(mo, "_currentframe", "2");
+ add_actions(mo, " x = 0; "
+ " gotoAndStop(x); "); // ActionGotoExpression
+ check_equals(mo, "_currentframe", "2");
+ add_actions(mo, " x = -1; "
+ " gotoAndStop(x); "); // ActionGotoExpression
+ check_equals(mo, "_currentframe", "2");
+ add_actions(mo, " gotoAndStop(6); "); // ActionGotoFrame
+ SWFMovie_nextFrame(mo); /* 5th frame */
+
+ add_actions(mo, "function func1() {}"
+ "func1.prototype.toString = function() { return '8'; };"
+ "x1 = new func1();"
+
+ "function func2() {}"
+ "func2.prototype.valueOf = function() { return 8;}; "
+ "x2 = new func2();"
+
+ "function func3() {}"
+ "func3.prototype.toString = function() { return '8'; }; "
+ "func3.prototype.valueOf = function() { return 8;};"
+ "x3 = new func3();" );
+
+
+ add_actions(mo, " x = '8'; gotoAndStop(x); "); // ActionGotoExpression
+ check_equals(mo, "_currentframe", "6");
+
+ add_actions(mo, " x = '8a'; gotoAndStop(x); "); // ActionGotoExpression
+ check_equals(mo, "_currentframe", "3");
+
+ add_actions(mo, " x = 'aa'; gotoAndStop(x); "); // ActionGotoExpression
+ check_equals(mo, "_currentframe", "4");
+
+ add_actions(mo, " gotoAndStop(x1); "); // ActionGotoExpression
+ /* reach the last frame */
+ check_equals(mo, "_currentframe", "6");
+
+ /* reset _currentframe to 1 */
+ add_actions(mo, " gotoAndStop(1); ");
+ add_actions(mo, " gotoAndStop(x2); "); // ActionGotoExpression
+ check_equals(mo, "_currentframe", "1");
+
+ add_actions(mo, " gotoAndStop(x3); "); // ActionGotoExpression
+ /* reach the last frame */
+ check_equals(mo, "_currentframe", "6");
+
+ add_actions(mo, " _root.totals(); stop(); ");
+ SWFMovie_nextFrame(mo); /* 6th frame */
+
+ //Output movie
+ puts("Saving " OUTPUT_FILENAME );
+ SWFMovie_save(mo, OUTPUT_FILENAME);
+
+ return 0;
+}
+
+
+
+
+
+
- [Gnash-commit] gnash ChangeLog server/sprite_instance.h server...,
Zou Lunkai <=