CVSROOT: /sources/gnash Module name: gnash Changes by: Zou Lunkai <zoulunkai> 07/04/16 01:02:17
Modified files: . : ChangeLog server : sprite_instance.cpp server/vm : ASHandlers.cpp Added files: testsuite/misc-ming.all: frame_label_test.c Log message: new tests for frame label and fixs CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2878&r2=1.2879 http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.242&r2=1.243 http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.90&r2=1.91 http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/frame_label_test.c?cvsroot=gnash&rev=1.1 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.2878 retrieving revision 1.2879 diff -u -b -r1.2878 -r1.2879 --- ChangeLog 15 Apr 2007 15:27:03 -0000 1.2878 +++ ChangeLog 16 Apr 2007 01:02:17 -0000 1.2879 @@ -1,3 +1,13 @@ +2007-04-16 Zou Lunkai <[EMAIL PROTECTED]> + + * testsuite/misc-ming.all/frame_label_test.c: + a new testcase + * server/sprite_instance.cpp: + update call_frame_actions(); + * server/vm/ASHandlers.cpp: + properly process frame label in ActionCallFrame() and ActionGotoExpression(). + + 2007-04-15 Sandro Santilli <[EMAIL PROTECTED]> * server/edit_text_character.cpp (display): move text glyphs Index: server/sprite_instance.cpp =================================================================== RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v retrieving revision 1.242 retrieving revision 1.243 diff -u -b -r1.242 -r1.243 --- server/sprite_instance.cpp 15 Apr 2007 14:31:19 -0000 1.242 +++ server/sprite_instance.cpp 16 Apr 2007 01:02:17 -0000 1.243 @@ -1722,13 +1722,7 @@ return; } - // Take not of iterator to last element - ActionList::iterator top_iterator = m_action_list.end(); - --top_iterator; // now points to last element in *current* list - -#ifndef NDEBUG size_t original_size = m_action_list.size(); -#endif // Set the current sound_stream_id to -1, meaning that no stream are // active. If there are an active stream it will be updated while @@ -1749,15 +1743,18 @@ // Execute any new actions triggered by the tag, // leaving existing actions to be executed. - - ++top_iterator; // now points to one past last of *previous* list - ActionList::const_iterator it = top_iterator; + ActionList::iterator it = m_action_list.begin(); + for(size_t i =0; i<original_size; i++) + { + it++; + } + ActionList::iterator previous_end = it; while (it != m_action_list.end()) { execute_action(*(*it)); ++it; } - m_action_list.erase(top_iterator, m_action_list.end()); + m_action_list.erase(previous_end, m_action_list.end()); assert(m_action_list.size() == original_size); } Index: server/vm/ASHandlers.cpp =================================================================== RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v retrieving revision 1.90 retrieving revision 1.91 diff -u -b -r1.90 -r1.91 --- server/vm/ASHandlers.cpp 15 Apr 2007 14:31:19 -0000 1.90 +++ server/vm/ASHandlers.cpp 16 Apr 2007 01:02:17 -0000 1.91 @@ -14,7 +14,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -/* $Id: ASHandlers.cpp,v 1.90 2007/04/15 14:31:19 strk Exp $ */ +/* $Id: ASHandlers.cpp,v 1.91 2007/04/16 01:02:17 zoulunkai Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -576,9 +576,7 @@ sprite_instance* tgt = env.get_target()->to_movie(); assert(tgt); - // 0-based already? - //// Convert from 1-based to 0-based - //frame--; + // frame number within this tag is hard-coded and 0-based tgt->goto_frame(frame); } @@ -1989,10 +1987,34 @@ thread.ensureStack(1); // frame spec - // Note: no extra data in this instruction! - sprite_instance* tgt = env.get_target()->to_movie(); - assert(tgt); - tgt->call_frame_actions(env.top(0)); + string target_frame = env.top(0).to_std_string(); + string target_path; + string frame_var; + + character * target; + if( env.parse_path(target_frame, target_path, frame_var) ) + { + target = env.find_target(target_path); + } + else + { + frame_var = target_frame; + target = env.get_target(); + } + + sprite_instance *target_sprite = target->to_movie(); + if(target_sprite) + { + target_sprite->call_frame_actions(frame_var); + } + else + { + log_aserror( + "Couldn't find target_sprite \"%s\" in ActionCallFrame!" + " target frame actions will not be called...", + target_path.c_str()); + } + env.drop(1); } @@ -2008,7 +2030,6 @@ const action_buffer& code = thread.code; size_t pc = thread.pc; - //dbglogfile << __PRETTY_FUNCTION__ << ": unimplemented!" << endl; // From Alexi's SWF ref: // @@ -2025,31 +2046,45 @@ unsigned char play_flag = code[pc + 3]; sprite_instance::play_state state = play_flag ? sprite_instance::PLAY : sprite_instance::STOP; - sprite_instance* target = env.get_target()->to_movie(); - if ( ! target ) + string target_frame = env.pop().to_std_string(); + string target_path; + string frame_var; + + character * target; + if( env.parse_path(target_frame, target_path, frame_var) ) { - log_error("environment target is not a sprite_instance while executing ActionGotoExpression"); - env.drop(1); - return; + target = env.find_target(target_path); + } + else + { + target = env.get_target(); + frame_var = target_frame; } - as_value expression = env.pop(); - + sprite_instance *target_sprite = target->to_movie(); + if(target_sprite) + { size_t frame_number; - if ( ! target->get_frame_number(expression, frame_number) ) + if ( ! target_sprite->get_frame_number(frame_var, frame_number) ) { IF_VERBOSE_ASCODING_ERRORS( log_aserror("Frame spec found on stack " "at ActionGotoExpression doesn't evaluate " "to a valid frame: %s", - expression.to_debug_string().c_str()); + target_frame.c_str()); ); return; } - - target->goto_frame(frame_number); - target->set_play_state(state); - + target_sprite->goto_frame(frame_number); + target_sprite->set_play_state(state); + } + else + { + log_aserror( + "Couldn't find target_sprite \"%s\" in ActionGotoExpression!" + " will not goto taget_frame...", + target_frame.c_str()); + } } Index: testsuite/misc-ming.all/frame_label_test.c =================================================================== RCS file: testsuite/misc-ming.all/frame_label_test.c diff -N testsuite/misc-ming.all/frame_label_test.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ testsuite/misc-ming.all/frame_label_test.c 16 Apr 2007 01:02:17 -0000 1.1 @@ -0,0 +1,143 @@ +/* + * 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 + * + */ + +/* + _root + |------mc1 + |------mc11 +*/ + +#include <stdlib.h> +#include <stdio.h> +#include <ming.h> + +#include "ming_utils.h" + +#define OUTPUT_VERSION 5 +#define OUTPUT_FILENAME "frame_label_test.swf" + + +int +main(int argc, char** argv) +{ + SWFMovie mo; + SWFMovieClip mc1, mc11, dejagnuclip; + SWFDisplayItem it1, it11; + SWFShape sh_red; + + 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); + add_actions(mo, "x1=0; x2=0; x3=0; x4=0; x5=0; x6=0;"); + SWFMovie_nextFrame(mo); /* 1st frame of _root */ + + + mc11 = newSWFMovieClip(); + sh_red = make_fill_square (100, 300, 60, 60, 255, 0, 0, 255, 0, 0); + SWFMovieClip_add(mc11, (SWFBlock)sh_red); + add_clip_actions(mc11, "stop();"); + SWFMovieClip_nextFrame(mc11); + SWFMovieClip_nextFrame(mc11); + SWFMovieClip_nextFrame(mc11); + + add_clip_actions(mc11, "_root.x1 = 'mc11_frame4'; stop(); "); + SWFMovieClip_labelFrame(mc11, "frame4"); + SWFMovieClip_nextFrame(mc11); + add_clip_actions(mc11, "_root.x2 = 'mc11_frame5'; stop(); "); + SWFMovieClip_labelFrame(mc11, "frame5"); + SWFMovieClip_nextFrame(mc11); + add_clip_actions(mc11, "_root.x3 = 'mc11_frame6'; stop(); "); + SWFMovieClip_labelFrame(mc11, "frame6"); + SWFMovieClip_nextFrame(mc11); + + + mc1 = newSWFMovieClip(); + sh_red = make_fill_square (200, 300, 60, 60, 255, 0, 0, 255, 0, 0); + SWFMovieClip_add(mc1, (SWFBlock)sh_red); + add_clip_actions(mc1, "stop();"); + it11 = SWFMovieClip_add(mc1, (SWFBlock)mc11); + SWFDisplayItem_setDepth(it11, 10); + SWFDisplayItem_setName(it11, "mc11"); + SWFMovieClip_nextFrame(mc1); + SWFMovieClip_nextFrame(mc1); + SWFMovieClip_nextFrame(mc1); + + add_clip_actions(mc1, "_root.x4 = 'mc1_frame4'; stop(); "); + SWFMovieClip_labelFrame(mc1, "frame4"); + SWFMovieClip_nextFrame(mc1); + add_clip_actions(mc1, "_root.x5 = 'mc1_frame5'; stop(); "); + SWFMovieClip_labelFrame(mc1, "frame5"); + SWFMovieClip_nextFrame(mc1); + add_clip_actions(mc1, "_root.x6 = 'mc1_frame6'; stop(); "); + SWFMovieClip_labelFrame(mc1, "frame6"); + SWFMovieClip_nextFrame(mc1); + + + /* place _root.mc1 */ + it1 = SWFMovie_add(mo, (SWFBlock)mc1); + SWFDisplayItem_setDepth(it1, 20); + SWFDisplayItem_setName(it1, "mc1"); + SWFMovie_nextFrame(mo); /* 2nd frame of _root */ + + + add_actions(mo, " gotoAndPlay('/mc1:frame4'); " //GotoLabel + " gotoAndPlay('mc1:frame5'); " //GotoLabel + " gotoAndPlay('/mc1/:6'); " //GotoLabel + " lable = '/mc1/mc11/:frame4'; " + " gotoAndPlay(lable); " //GotoExpression + " lable = '/mc1/mc11/:5'; " + " gotoAndPlay(lable); " + " callFrame('/mc1/mc11/:frame6'); " ); + SWFMovie_nextFrame(mo); /* 3rd frame of _root */ + + + /* checks */ + /* GotoExpression and callFrame support target_path */ + check_equals(mo, "_root.x1", "'mc11_frame4'"); + check_equals(mo, "_root.x2", "'mc11_frame5'"); + check_equals(mo, "_root.x3", "'mc11_frame6'"); + /* seems that GotoLabel does not support target_path */ + check_equals(mo, "_root.x4", "0"); + check_equals(mo, "_root.x5", "0"); + check_equals(mo, "_root.x6", "0"); + add_actions(mo, " _root.totals(); stop(); "); + SWFMovie_nextFrame(mo); /* 4th frame of _root */ + + + //Output movie + puts("Saving " OUTPUT_FILENAME ); + SWFMovie_save(mo, OUTPUT_FILENAME); + + return 0; +} + + + _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit