gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/ActionExec.cpp server/Ac...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/ActionExec.cpp server/Ac...
Date: Fri, 04 Aug 2006 17:23:49 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/08/04 17:23:49

Modified files:
        .              : ChangeLog 
        server         : ActionExec.cpp ActionExec.h execute_tag.h 
                         movie_definition.h sprite_instance.cpp 
                         sprite_instance.h 
        server/swf     : ASHandlers.cpp 

Log message:
                * server/swf/ASHandlers.cpp: implemented ActionWaitForFrame
                  and ActionWaitForFrameExpression()
                * server/sprite_instance.cpp, server/sprite_instance.h:
                  added get_frame_number(as_value& frame_spec) for common
                  use in swf tags.
                * server/movie_definition.h: added doxygen comment
                * server/ActionExec.cpp, server/ActionExec.h: added
                  skip_actions() for use with WaitForFrame
                * server/execute_tag.h: removed unused parameter warning.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.589&r2=1.590
http://cvs.savannah.gnu.org/viewcvs/gnash/server/ActionExec.cpp?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/server/ActionExec.h?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/execute_tag.h?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_definition.h?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/ASHandlers.cpp?cvsroot=gnash&r1=1.42&r2=1.43

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.589
retrieving revision 1.590
diff -u -b -r1.589 -r1.590
--- ChangeLog   4 Aug 2006 16:11:01 -0000       1.589
+++ ChangeLog   4 Aug 2006 17:23:49 -0000       1.590
@@ -1,5 +1,14 @@
 2006-08-04 Sandro Santilli <address@hidden>
 
+       * server/swf/ASHandlers.cpp: implemented ActionWaitForFrame
+         and ActionWaitForFrameExpression()
+       * server/sprite_instance.cpp, server/sprite_instance.h:
+         added get_frame_number(as_value& frame_spec) for common
+         use in swf tags.
+       * server/movie_definition.h: added doxygen comment 
+       * server/ActionExec.cpp, server/ActionExec.h: added
+         skip_actions() for use with WaitForFrame
+       * server/execute_tag.h: removed unused parameter warning.
        * gui/NullGui.h: removed unused parameters warnings.
        * server/character.h, server/movie_def_impl.cpp,
          server/movie_def_impl.h, server/movie_definition.h,

Index: server/ActionExec.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/ActionExec.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- server/ActionExec.cpp       27 Jul 2006 01:47:11 -0000      1.18
+++ server/ActionExec.cpp       4 Aug 2006 17:23:49 -0000       1.19
@@ -198,10 +198,47 @@
     env.set_target(original_target);
 }
 
+void
+ActionExec::skip_actions(size_t offset)
+{
+       pc = next_pc;
 
+       for(size_t i=0; i<offset; ++i)
+       {
+               // we need to check at every iteration because
+               // an action can be longer then a single byte
+               if ( pc == stop_pc )
+               {
+                       log_error("End of DoAction block hit while skipping "
+                               " %u action tags - "
+                               "Malformed SWF ? (WaitForFrame, probably)",
+                               offset);
+                       return;
+               }
+
+               // Get the opcode.
+               uint8_t action_id = code[pc];
+
+               // Set default next_pc offset, control flow action handlers
+               // will be able to reset it. 
+               if ((action_id & 0x80) == 0) {
+                       // action with no extra data
+                       next_pc = pc+1;
+               } else {
+                       // action with extra data
+                       int16_t length = code.read_int16(pc+1);
+                       assert( length >= 0 );
+                       next_pc = pc + length + 3;
+               }
+
+               pc = next_pc;
+       }
 }
 
 
+} // end of namespace gnash
+
+
 // Local Variables:
 // mode: C++
 // indent-tabs-mode: t

Index: server/ActionExec.h
===================================================================
RCS file: /sources/gnash/gnash/server/ActionExec.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- server/ActionExec.h 29 Jun 2006 19:22:49 -0000      1.2
+++ server/ActionExec.h 4 Aug 2006 17:23:49 -0000       1.3
@@ -96,6 +96,12 @@
 
        bool isFunction2() { return _function2_var; }
 
+       /// Skip the specified number of action tags 
+       //
+       /// The offset is relative to next_pc
+       ///
+       void skip_actions(size_t offset);
+
        void operator() ();
                
 };

Index: server/execute_tag.h
===================================================================
RCS file: /sources/gnash/gnash/server/execute_tag.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- server/execute_tag.h        24 Jun 2006 17:56:36 -0000      1.2
+++ server/execute_tag.h        4 Aug 2006 17:23:49 -0000       1.3
@@ -70,7 +70,7 @@
        }
 
        // Is the 'frame' arg is really needed ?
-       virtual void execute_state_reverse(movie* m, int frame)
+       virtual void execute_state_reverse(movie* m, int /*frame*/)
        {
                execute_state(m);
        }

Index: server/movie_definition.h
===================================================================
RCS file: /sources/gnash/gnash/server/movie_definition.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- server/movie_definition.h   4 Aug 2006 15:30:36 -0000       1.8
+++ server/movie_definition.h   4 Aug 2006 17:23:49 -0000       1.9
@@ -196,6 +196,7 @@
        // For use during creation.
        //
 
+       /// Returns 1 based index. Ex: if 1 then 1st frame as been fully loaded
        virtual size_t  get_loading_frame() const = 0;
 
        virtual void    add_character(int id, character_def* ch) = 0;

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- server/sprite_instance.cpp  4 Aug 2006 15:30:36 -0000       1.26
+++ server/sprite_instance.cpp  4 Aug 2006 17:23:49 -0000       1.27
@@ -723,11 +723,8 @@
     m_action_list.resize(0);
 }
 
-/// Execute the actions for the specified frame. 
-//
-/// The frame_spec could be an integer or a string.
-///
-void sprite_instance::call_frame_actions(const as_value& frame_spec)
+size_t
+sprite_instance::get_frame_number(const as_value& frame_spec) const
 {
        size_t  frame_number;
 
@@ -746,6 +743,18 @@
                frame_number = (size_t) frame_spec.to_number() - 1;
        }
 
+       return frame_number;
+}
+
+/// Execute the actions for the specified frame. 
+//
+/// The frame_spec could be an integer or a string.
+///
+void sprite_instance::call_frame_actions(const as_value& frame_spec)
+{
+       size_t  frame_number = get_frame_number(frame_spec);
+
+
        if (frame_number >= m_def->get_frame_count())
        {
                    // No dice.

Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/sprite_instance.h    4 Aug 2006 15:30:36 -0000       1.13
+++ server/sprite_instance.h    4 Aug 2006 17:23:49 -0000       1.14
@@ -235,6 +235,12 @@
        ///
        void    goto_frame(size_t target_frame_number);
 
+       /// \brief
+       /// Parse frame spec and return frame number.
+       /// Frame spec can either be a number of a string (label)
+       ///
+       size_t get_frame_number(const as_value& frame_spec) const;
+
 
        /// Look up the labeled frame, and jump to it.
        bool goto_labeled_frame(const char* label);

Index: server/swf/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/ASHandlers.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- server/swf/ASHandlers.cpp   3 Aug 2006 22:19:59 -0000       1.42
+++ server/swf/ASHandlers.cpp   4 Aug 2006 17:23:49 -0000       1.43
@@ -586,7 +586,7 @@
 
        assert( code[thread.pc] == SWF::ACTION_GOTOFRAME );
 
-       int frame = code.read_int16(thread.pc+3);
+       size_t frame = code.read_int16(thread.pc+3);
 
        // If the frame we goto isn't the next in line, all sounds are stopped.
        if (env.get_target()->get_current_frame()+1 != frame) {
@@ -637,7 +637,7 @@
 {
 //     GNASH_REPORT_FUNCTION;
 
-       //as_environment& env = thread.env;
+       as_environment& env = thread.env;
        const action_buffer& code = thread.code;
 
        assert( code[thread.pc] == SWF::ACTION_WAITFORFRAME );
@@ -646,31 +646,33 @@
        size_t tag_len = code.read_int16(thread.pc+1);
        if ( tag_len != 3 )
        {
-               log_warning("Malformed SWF: ActionWaitForFrame (0x%X) tag 
length == %ld (expected 3)", SWF::ACTION_WAITFORFRAME, tag_len);
+               log_warning("Malformed SWF: ActionWaitForFrame (0x%X) tag 
length == %lu (expected 3)", SWF::ACTION_WAITFORFRAME, tag_len);
        }
 
-       // we don't use the stack!
-       //ensure_stack(env, 1);
-
-       // If we haven't loaded a specified frame yet, then we're supposed
-       // to skip some specified number of actions.
+       // If we haven't loaded a specified frame yet, then 
+       // skip the specified number of actions.
        //
-       // Since we don't load incrementally, just ignore this opcode.
+       unsigned int framenum = code.read_int16(thread.pc+3);
+       uint8 skip = code[thread.pc+4];
 
-       //unsigned int framenum = code.read_int16(thread.pc+3);
-       //int skip = code[thread.pc+4];
+       character* target = env.get_target();
+       sprite_instance* target_sprite = dynamic_cast<sprite_instance*>(target);
+       if ( ! target_sprite )
+       {
+               log_error("environment target is not a sprite_instance while 
executing ActionWaitForFrame");
+               return;
+       }
 
-#if 0 // pseudo-code, to be implemented
+       movie_definition* sd = target_sprite->get_movie_definition();
 
-       if ( target.loaded_frames() < framenum )
+       if ( sd->get_loading_frame() < framenum )
        {
                // better delegate this to ActionExec
                thread.skip_actions(skip);
        }
-#endif
 
        dbglogfile << __PRETTY_FUNCTION__
-               << ": unimplemented (we need to implement!!)"
+               << ": testing"
                << endl;
 }
 
@@ -1289,29 +1291,41 @@
 {
 //     GNASH_REPORT_FUNCTION;
        as_environment& env = thread.env;
-       //const action_buffer& code = thread.code;
+       const action_buffer& code = thread.code;
 
        ensure_stack(env, 1); // expression
 
        // how many actions to skip if frame has not been loaded
-       //short unsigned int skip = code[thread.pc+3];
+       uint8 skip = code[thread.pc+3];
 
        // env.top(0) contains frame specification,
        // evaluated as for ActionGotoExpression
-
-#if 0 // pseudo-code, to be implemented
        as_value& framespec = env.top(0);
-       if ( ! target.find_frame(framespec) )
+       
+       character* target = env.get_target();
+       sprite_instance* target_sprite = dynamic_cast<sprite_instance*>(target);
+       if ( ! target_sprite )
+       {
+               log_error("environment target is not a sprite_instance "
+                       "while executing ActionWaitForFrameExpression");
+               env.drop(1);
+               return;
+       }
+
+       movie_definition* sd = target_sprite->get_movie_definition();
+
+       size_t framenum = target_sprite->get_frame_number(framespec);
+
+       if ( sd->get_loading_frame() < framenum )
        {
                // better delegate this to ActionExec
                thread.skip_actions(skip);
        }
-#endif
 
        env.drop(1);
        
        dbglogfile << __PRETTY_FUNCTION__ 
-                  << ": unimplemented (we need to implement!!)"
+                  << ": testing"
                   << endl;
 }
 
@@ -1540,8 +1554,8 @@
                      
                if (next_pc > stop_pc)
                {
-                       log_error("branch to offset %ld -- "
-                               " this section only runs to %ld. "
+                       log_error("branch to offset %lu -- "
+                               " this section only runs to %lu. "
                                " Malformed SWF !.",
                                next_pc,
                                stop_pc);
@@ -2635,7 +2649,7 @@
        size_t pc = thread.pc;
        size_t next_pc = thread.next_pc;
 
-       log_action("-------------- with block start: stack size is %ld",
+       log_action("-------------- with block start: stack size is %lu",
                with_stack.size());
 
        if (with_stack.size() < 8)
@@ -2770,7 +2784,7 @@
 {
        if ( static_cast<size_t>(x) > _handlers.size() )
        {
-               log_error("at SWFHandlers::action_name(%d) call time, _handlers 
size is %ld", x, _handlers.size());
+               log_error("at SWFHandlers::action_name(%d) call time, _handlers 
size is %lu", x, _handlers.size());
                return NULL;
        }
        else
@@ -2787,8 +2801,8 @@
 
     size_t missing = required-env.stack_size();
 
-    log_error("Stack underrun: %ld elements required, %ld available. "
-        "Fixing by pushing %ld undefined values on the missing slots.",
+    log_error("Stack underrun: %lu elements required, %lu available. "
+        "Fixing by pushing %lu undefined values on the missing slots.",
         required, env.stack_size(), missing);
 
     for (size_t i=0; i<missing; ++i)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]