gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/button_character_instanc...


From: Udo Giacomozzi
Subject: [Gnash-commit] gnash ChangeLog server/button_character_instanc...
Date: Thu, 19 Apr 2007 17:41:36 +0000

CVSROOT:        /cvsroot/gnash
Module name:    gnash
Changes by:     Udo Giacomozzi <udog>   07/04/19 17:41:36

Modified files:
        .              : ChangeLog 
        server         : button_character_instance.cpp character.cpp 
                         character.h sprite_instance.cpp 
                         sprite_instance.h 

Log message:
        move getTarget() and friends to character

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2938&r2=1.2939
http://cvs.savannah.gnu.org/viewcvs/gnash/server/button_character_instance.cpp?cvsroot=gnash&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.cpp?cvsroot=gnash&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.h?cvsroot=gnash&r1=1.69&r2=1.70
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.247&r2=1.248
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.99&r2=1.100

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/gnash/gnash/ChangeLog,v
retrieving revision 1.2938
retrieving revision 1.2939
diff -u -b -r1.2938 -r1.2939
--- ChangeLog   19 Apr 2007 17:06:46 -0000      1.2938
+++ ChangeLog   19 Apr 2007 17:41:35 -0000      1.2939
@@ -1,3 +1,12 @@
+2007-04-19 Udo Giacomozzi <address@hidden>
+
+       * server/character.{h,cpp}, server/sprite_instance.{h,cpp}: 
+         moved getTarget(), getTargetPath(),
+         get_text_value() to character class so that button instances
+         can deal with "targets" too.
+       * server/character.{h,cpp}: implemented "_target" getter-setter   
+       * server/button_character_instance.cpp: added _target getter-setter 
+       
 2007-04-19 Sandro Santilli <address@hidden>
 
        * testsuite/actionscript.all/Number.as:

Index: server/button_character_instance.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/server/button_character_instance.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- server/button_character_instance.cpp        18 Apr 2007 09:35:42 -0000      
1.43
+++ server/button_character_instance.cpp        19 Apr 2007 17:41:35 -0000      
1.44
@@ -217,6 +217,10 @@
        gettersetter = new builtin_function(&character::parent_getset, NULL);
        o.init_property("_parent", *gettersetter, *gettersetter);
 
+       gettersetter = new builtin_function(&character::target_getset, NULL);
+       o.init_property("_target", *gettersetter, *gettersetter);
+       
+
 #if 0
        gettersetter = new builtin_function(&character::onrollover_getset, 
NULL);
        o.init_property("onRollOver", *gettersetter, *gettersetter);

Index: server/character.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/server/character.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- server/character.cpp        18 Apr 2007 09:35:42 -0000      1.36
+++ server/character.cpp        19 Apr 2007 17:41:35 -0000      1.37
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 // 
 
-/* $Id: character.cpp,v 1.36 2007/04/18 09:35:42 jgilmore Exp $ */
+/* $Id: character.cpp,v 1.37 2007/04/19 17:41:35 udog Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -580,10 +580,17 @@
        {
                rv = as_value(p);
        }
-
        return rv;
 }
 
+as_value
+character::target_getset(const fn_call& fn)
+{
+       boost::intrusive_ptr<character> ptr = 
ensureType<character>(fn.this_ptr);
+
+       return as_value(ptr->getTargetPath());
+}
+
 void
 character::set_event_handlers(const Events& copyfrom)
 {
@@ -732,6 +739,96 @@
        transformedByScript(); // m_accept_anim_moves = false; 
 }
 
+
+/*private*/
+std::string
+character::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 )
+               {
+                       // it is completely legal to set root's _name
+                       //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;
+}
+
+/*public*/
+const std::string
+character::getTargetPath() const
+{
+
+  // TODO: maybe cache computed target?
+
+       return computeTargetPath();
+}
+
+
+/*public*/
+const std::string
+character::getTarget() const
+{
+
+  // TODO: maybe cache computed target?
+
+       std::string target_dot;
+
+       std::string levelString = "_level0"; // TODO: support real levels!
+
+       const std::string& targetPath = getTargetPath();
+       if ( targetPath == "/" ) target_dot = levelString;
+       else
+       {
+               target_dot = levelString + targetPath;
+               for (std::string::size_type i=0; i<target_dot.length(); ++i)
+               {
+                       if ( target_dot[i] == '/' ) target_dot[i] = '.';
+               }
+       }
+
+       return target_dot;
+}
+
+/*public*/
+const char*
+character::get_text_value() const
+{
+       return getTarget().c_str();
+}
+
+
 } // namespace gnash
 
 // local variables:

Index: server/character.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/character.h,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -b -r1.69 -r1.70
--- server/character.h  18 Apr 2007 13:57:25 -0000      1.69
+++ server/character.h  19 Apr 2007 17:41:35 -0000      1.70
@@ -18,7 +18,7 @@
 //
 //
 
-/* $Id: character.h,v 1.69 2007/04/18 13:57:25 udog Exp $ */
+/* $Id: character.h,v 1.70 2007/04/19 17:41:35 udog Exp $ */
 
 #ifndef GNASH_CHARACTER_H
 #define GNASH_CHARACTER_H
@@ -88,6 +88,8 @@
        /// Set to yes when this instance has been unloaded
        bool _unloaded;
 
+       /// Build the _target member recursive on parent
+       std::string computeTargetPath() const;
 
 protected:
 
@@ -228,6 +230,9 @@
        /// Getter-setter for _parent 
        static as_value parent_getset(const fn_call& fn);
 
+       /// Getter-setter for _target 
+       static as_value target_getset(const fn_call& fn);
+
        /// @} Common ActionScript getter-setters for characters
 
 public:
@@ -829,6 +834,24 @@
        virtual void unload();
 
        bool isUnloaded() { return _unloaded; }
+       
+public:
+
+       /// Return full path to this object, in slash notation
+       //
+       /// e.g. "/sprite1/sprite2/ourSprite"
+       ///
+       const std::string getTargetPath() const;
+
+       /// Return full path to this object, in dot notation
+       //
+       /// e.g. "_level0.sprite1.sprite2.ourSprite"
+       ///
+       const std::string getTarget() const;
+       
+  // override from as_object
+       virtual const char* get_text_value() const;     
+       
 };
 
 

Index: server/sprite_instance.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.247
retrieving revision 1.248
diff -u -b -r1.247 -r1.248
--- server/sprite_instance.cpp  18 Apr 2007 13:24:44 -0000      1.247
+++ server/sprite_instance.cpp  19 Apr 2007 17:41:36 -0000      1.248
@@ -1533,7 +1533,6 @@
        m_has_mouse_event(false),
        _text_variables(),
        m_sound_stream_id(-1),
-       _target(), // don't initialize now, as parent can be assigned later
        m_def(def),
        m_on_event_load_called(false)
 {
@@ -3002,6 +3001,9 @@
     // Construct the sprite again
     construct();
 
+    // re-assign standard properties
+    attachMovieClipProperties(*this);
+
 }
 
 character*
@@ -3142,93 +3144,6 @@
                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;
-}
-
-const std::string&
-sprite_instance::getTarget() const
-{
-       if ( ! _target_dot.empty() ) return _target_dot;
-
-       std::string levelString = "_level0"; // TODO: support real levels!
-
-       const std::string& targetPath = getTargetPath();
-       if ( targetPath == "/" ) _target_dot = levelString;
-       else
-       {
-               _target_dot = levelString + targetPath;
-               for (std::string::size_type i=0; i<_target_dot.length(); ++i)
-               {
-                       if ( _target_dot[i] == '/' ) _target_dot[i] = '.';
-               }
-       }
-
-       return _target_dot;
-}
-
-/*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 )
-               {
-                       // it is completely legal to set root's _name
-                       //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;
-}
-
-const char*
-sprite_instance::get_text_value() const
-{
-       return getTarget().c_str();
-}
 
 // WARNING: THIS SNIPPET NEEDS THE CHARACTER TO BE "INSTANTIATED", which is
 //          it's target path needs to exist, or any as_value for it will be
@@ -3301,10 +3216,6 @@
 {
        _name = name;
 
-       // Reset these so they get computed next
-       // time someone request them.
-       _target.clear();
-       _target_dot.clear();
 }
 
 bool

Index: server/sprite_instance.h
===================================================================
RCS file: /cvsroot/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -b -r1.99 -r1.100
--- server/sprite_instance.h    18 Apr 2007 13:24:44 -0000      1.99
+++ server/sprite_instance.h    19 Apr 2007 17:41:36 -0000      1.100
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: sprite_instance.h,v 1.99 2007/04/18 13:24:44 strk Exp $ */
+/* $Id: sprite_instance.h,v 1.100 2007/04/19 17:41:36 udog Exp $ */
 
 // Stateful live Sprite instance
 
@@ -126,9 +126,6 @@
        ///
        virtual sprite_instance* get_root_movie();
 
-       // override from as_object
-       virtual const char* get_text_value() const;
-
        /// \brief
        /// Return the sprite_definition (or movie_definition)
        /// from which this sprite_instance has been created
@@ -664,18 +661,6 @@
        /// 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. "/sprite1/sprite2/ourSprite"
-       ///
-       const std::string& getTargetPath() const;
-
-       /// Return full path to this object, in dot notation
-       //
-       /// e.g. "_level0.sprite1.sprite2.ourSprite"
-       ///
-       const std::string& getTarget() const;
-
        /// Override for character::set_name to proprely update
        /// _target and _target_dot.
        virtual void set_name(const char* name);
@@ -880,19 +865,6 @@
        /// 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;
-
-       /// The full path to this object, in dot notation
-       mutable std::string _target_dot;
-
-       /// Build the _target member recursive on parent
-       std::string computeTargetPath() const;
 
        /// The DisplayList resulting by execution of tags in first frame.
        //




reply via email to

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