gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/sprite_instance.cpp serv...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/sprite_instance.cpp serv...
Date: Mon, 27 Nov 2006 11:22:43 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/11/27 11:22:43

Modified files:
        .              : ChangeLog 
        server         : sprite_instance.cpp sprite_instance.h 
        server/parser  : movie_def_impl.cpp 
        testsuite/actionscript.all: MovieClip.as 

Log message:
                * server/parser/movie_def_impl.cpp (create_instance):
                  don't force the instance name to be _root !
                * server/sprite_instance.{h,cpp}: added support
                  for the _target property.
                * testsuite/actionscript.all/MovieClip.as: added
                  tests for the _target property.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1785&r2=1.1786
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.89&r2=1.90
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/movie_def_impl.cpp?cvsroot=gnash&r1=1.45&r2=1.46
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/MovieClip.as?cvsroot=gnash&r1=1.16&r2=1.17

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1785
retrieving revision 1.1786
diff -u -b -r1.1785 -r1.1786
--- ChangeLog   27 Nov 2006 10:00:44 -0000      1.1785
+++ ChangeLog   27 Nov 2006 11:22:42 -0000      1.1786
@@ -1,5 +1,12 @@
 2006-11-27 Sandro Santilli <address@hidden>
 
+       * server/parser/movie_def_impl.cpp (create_instance):
+         don't force the instance name to be _root !
+       * server/sprite_instance.{h,cpp}: added support
+         for the _target property; report execution of
+         frame tags when in verbose action mode.
+       * testsuite/actionscript.all/MovieClip.as: added
+         tests for the _target property.
        * server/asobj/Video.cpp: attachvideo => attachVideo.
        * server/asobj/string.cpp: lastindexof => lastIndexOf.
        * testsuite/actionscript.all/: XMLNode.as, MovieClip.as:

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -b -r1.89 -r1.90
--- server/sprite_instance.cpp  27 Nov 2006 02:12:59 -0000      1.89
+++ server/sprite_instance.cpp  27 Nov 2006 11:22:43 -0000      1.90
@@ -1051,7 +1051,7 @@
            //else if (name == "_target")
        {
            // Full path to this object; e.g. 
"/_level0/sprite1/sprite2/ourSprite"
-           val->set_string("/_root");
+           val->set_string(getTargetPath().c_str());
            return true;
        }
        case M_FRAMESLOADED:
@@ -1876,11 +1876,20 @@
        // Execute this frame's init actions, if necessary.
        if (m_init_actions_executed[frame] == false)
        {
+
                const PlayList* init_actions = m_def->get_init_actions(frame);
 
                if ( init_actions && ! init_actions->empty() )
                {
 
+                       IF_VERBOSE_ACTION(
+                               log_action("Executing " SIZET_FMT 
+                                       " *init* actions in frame " SIZET_FMT
+                                       " of sprite %s", init_actions->size(),
+                                       frame, getTargetPath().c_str());
+                       );
+
+
                        // Need to execute these actions.
                        std::for_each(init_actions->begin(), 
init_actions->end(),
                                
std::bind2nd(std::mem_fun(&execute_tag::execute), this));
@@ -1892,6 +1901,14 @@
        }
 
        const PlayList& playlist = m_def->get_playlist(frame);
+
+       IF_VERBOSE_ACTION(
+               log_action("Executing " SIZET_FMT " actions in frame "
+                       SIZET_FMT " of sprite %s %s",
+                       playlist.size(), frame, getTargetPath().c_str(),
+                       state_only ? "(state only)" : "" );
+       );
+
        if (state_only)
        {
                std::for_each(playlist.begin(), playlist.end(),
@@ -2585,4 +2602,64 @@
                method_name, method_arg_fmt, args);
 }
 
+const std::string&
+sprite_instance::getTargetPath() const
+{
+       if ( _target.empty() ) _target = computeTargetPath();
+       else
+       {
+               // What if set_name() is called *after*
+               // we computed the _target string ?
+               // let's check this... the design doesn't
+               // take the problem into account..
+               assert (_target == computeTargetPath() );
+       }
+
+       return _target;
+}
+
+/*private*/
+std::string
+sprite_instance::computeTargetPath() const
+{
+
+       // TODO: check what happens when this character
+       //       is a movie_instance loaded into another
+       //       running movie.
+
+       typedef std::vector<std::string> Path;
+       Path path;
+
+       // Build parents stack
+       const character* ch = this;
+       for (;;)
+       {
+               const character* parent = ch->get_parent();
+
+               // Don't push the _root name on the stack
+               if ( ! parent )
+               {
+                       assert(ch->get_name().empty());
+                       break;
+               }
+
+               path.push_back(ch->get_name());
+               ch = parent;
+       } 
+
+       if ( path.empty() ) return "/";
+
+       // Build the target string from the parents stack
+       std::string target;
+       for ( Path::reverse_iterator
+                       it=path.rbegin(), itEnd=path.rend();
+                       it != itEnd;
+                       ++it )
+       {
+               target += "/" + *it; 
+       }
+
+       return target;
+}
+
 } // namespace gnash

Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- server/sprite_instance.h    24 Nov 2006 13:33:21 -0000      1.43
+++ server/sprite_instance.h    27 Nov 2006 11:22:43 -0000      1.44
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: sprite_instance.h,v 1.43 2006/11/24 13:33:21 strk Exp $ */
+/* $Id: sprite_instance.h,v 1.44 2006/11/27 11:22:43 strk Exp $ */
 
 // Stateful live Sprite instance
 
@@ -511,6 +511,12 @@
        /// Get the current m_sound_stream_id
        virtual int get_sound_stream_id() { return m_sound_stream_id;}
 
+       /// Return full path to this object, in slash notation
+       //
+       /// e.g. "/_level0/sprite1/sprite2/ourSprite"
+       ///
+       const std::string& getTargetPath() const;
+
 private:
 
        /// Execute a single action buffer (DOACTION block)
@@ -582,6 +588,17 @@
        /// soundid for current playing stream. If no stream set to -1
        int m_sound_stream_id;
 
+       /// The full path to this object, in slash notation
+       //
+       /// It is computed on-demand by the getTargetPath()
+       /// method. Can not compute it at construction time
+       /// becase the set_name() method can be used to
+       /// change an instance name (should we forbid that, btw?)
+       mutable std::string _target;
+
+       /// Build the _target member recursive on parent
+       std::string computeTargetPath() const;
+
 protected:
 
        /// \brief

Index: server/parser/movie_def_impl.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/parser/movie_def_impl.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -b -r1.45 -r1.46
--- server/parser/movie_def_impl.cpp    23 Nov 2006 16:48:38 -0000      1.45
+++ server/parser/movie_def_impl.cpp    27 Nov 2006 11:22:43 -0000      1.46
@@ -833,7 +833,7 @@
 
     movie_instance* root_movie = new movie_instance(this, m, NULL);
 
-    root_movie->set_name("_root");
+    //root_movie->set_name("_root");
     m->set_root_movie(root_movie);
 
     m->add_ref();

Index: testsuite/actionscript.all/MovieClip.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/MovieClip.as,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- testsuite/actionscript.all/MovieClip.as     27 Nov 2006 09:40:42 -0000      
1.16
+++ testsuite/actionscript.all/MovieClip.as     27 Nov 2006 11:22:43 -0000      
1.17
@@ -22,7 +22,7 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: MovieClip.as,v 1.16 2006/11/27 09:40:42 strk Exp $";
+rcsid="$Id: MovieClip.as,v 1.17 2006/11/27 11:22:43 strk Exp $";
 
 #include "check.as"
 
@@ -191,3 +191,16 @@
 check_equals(mc3.getBytesLoaded(), 0);
 check_equals(mc3.getBytesTotal(), 0);
 #endif
+
+
+// Test the _target property
+check_equals(_root._target, "/");
+
+#if OUTPUT_VERSION >= 6
+// unfortunately we can't use createEmptyMovieClip with
+// lower SWF targets...
+var mc4 = _root.createEmptyMovieClip("mc4_mc", 60);
+check_equals(mc4._target, "/mc4_mc");
+var mc5 = mc4.createEmptyMovieClip("mc5_mc", 60);
+check_equals(mc5._target, "/mc4_mc/mc5_mc");
+#endif




reply via email to

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