gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/as_object.h server/as_va...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/as_object.h server/as_va...
Date: Tue, 12 Dec 2006 16:58:31 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/12/12 16:58:31

Modified files:
        .              : ChangeLog 
        server         : as_object.h as_value.cpp as_value.h character.h 
                         sprite_instance.cpp sprite_instance.h 
        server/asobj   : string.cpp 
        testsuite/actionscript.all: MovieClip.as 

Log message:
                * server/as_object.h: added get_primitive_value() virtual
                  functions.
                * server/as_value.{cpp,h}: added to_primitive().
                * server/character.h: made set_name virtual to allow handling
                  from subclasses. For the same reason _name is now protected
                  (from private).
                * server/sprite_instance.{h,cpp}: override get_text_name()
                  and set_name().
                * server/asobj/string.cpp: override get_primitive_value().
                * testsuite/actionscript.all/MovieClip.as: add test for
                  cast to primitive.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1917&r2=1.1918
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.h?cvsroot=gnash&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_value.h?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.h?cvsroot=gnash&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.99&r2=1.100
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.47&r2=1.48
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/string.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/MovieClip.as?cvsroot=gnash&r1=1.18&r2=1.19

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1917
retrieving revision 1.1918
diff -u -b -r1.1917 -r1.1918
--- ChangeLog   12 Dec 2006 16:27:43 -0000      1.1917
+++ ChangeLog   12 Dec 2006 16:58:31 -0000      1.1918
@@ -1,5 +1,19 @@
 2006-12-12 Sandro Santilli <address@hidden>
 
+       * server/as_object.h: added get_primitive_value() virtual
+         functions.
+       * server/as_value.{cpp,h}: added to_primitive().
+       * server/character.h: made set_name virtual to allow handling
+         from subclasses. For the same reason _name is now protected
+         (from private).
+       * server/sprite_instance.{h,cpp}: override get_text_name()
+         and set_name().
+       * server/asobj/string.cpp: override get_primitive_value().
+       * testsuite/actionscript.all/MovieClip.as: add test for
+         cast to primitive.
+
+2006-12-12 Sandro Santilli <address@hidden>
+
        * server/asobj/string.cpp: added get_text_value 
          override.
 

Index: server/as_object.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- server/as_object.h  10 Dec 2006 18:39:22 -0000      1.26
+++ server/as_object.h  12 Dec 2006 16:58:31 -0000      1.27
@@ -26,18 +26,18 @@
 
 #include "tu_config.h"
 
-#include <cmath>
 #include "container.h"
 #include "ref_counted.h" // for inheritance 
 #include "PropertyList.h"
+#include "as_value.h" // for return of get_primitive_value
 
+#include <cmath>
 #include <utility> // for std::pair
 
 // Forward declarations
 namespace gnash {
        class as_function;
        class sprite_instance;
-       class as_value;
        class as_environment;
        class VM;
 }
@@ -129,6 +129,19 @@
                return atof(get_text_value());
        }
 
+       /// Return the "primitive" value of this object
+       //
+       /// The default implementation returns the numeric value
+       /// of this object, other objects can override this function
+       /// to provide another "preferred" primitive. Primitive
+       /// values are: undefined, null, boolean, string, number.
+       ///
+       /// See ECMA-2.6.2 (section 4.3.2).
+       ///
+       virtual as_value get_primitive_value() const {
+               return as_value(get_numeric_value());
+       }
+
        /// Set a member value
        //
        /// The default behaviour is to call set_member_default,

Index: server/as_value.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_value.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/as_value.cpp 3 Nov 2006 13:57:29 -0000       1.11
+++ server/as_value.cpp 12 Dec 2006 16:58:31 -0000      1.12
@@ -213,6 +213,28 @@
     return to_tu_string();
 }
 
+// Conversion to primitive value.
+as_value
+as_value::to_primitive() const
+{
+       switch (m_type)
+       {
+               case OBJECT:
+                       return m_object_value->get_primitive_value();
+               case AS_FUNCTION:
+                       return m_as_function_value->get_primitive_value();
+               case UNDEFINED:
+               case NULLTYPE:
+               case BOOLEAN:
+               case STRING:
+               case NUMBER:
+               case C_FUNCTION:
+               default:
+                       return *this;
+       }
+
+}
+
 // Conversion to double.
 double
 as_value::to_number() const
@@ -432,7 +454,7 @@
        {
                // convert this value to a primitive and recurse
                // TODO: implement ``as_value as_value::to_primitive() const''
-               //return to_primitive() == v;
+               return to_primitive() == v;
 
                // to_primitive is not implemented yet, so
                // we force conversion to a number

Index: server/as_value.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_value.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- server/as_value.h   3 Nov 2006 15:43:09 -0000       1.18
+++ server/as_value.h   12 Dec 2006 16:58:31 -0000      1.19
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: as_value.h,v 1.18 2006/11/03 15:43:09 nihilus Exp $ */
+/* $Id: as_value.h,v 1.19 2006/12/12 16:58:31 strk Exp $ */
 
 #ifndef GNASH_AS_VALUE_H
 #define GNASH_AS_VALUE_H
@@ -283,6 +283,12 @@
        /// Conversion to boolean.
        bool    to_bool() const;
 
+       /// Return value as a primitive type
+       //
+       /// Primitive types are: undefined, null, boolean, string, number.
+       /// See ECMA-2.6.2 (section 4.3.2).
+       as_value to_primitive() const;
+
        /// \brief
        /// Return value as an object
        /// or NULL if this is not possible.

Index: server/character.h
===================================================================
RCS file: /sources/gnash/gnash/server/character.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- server/character.h  6 Dec 2006 12:48:51 -0000       1.34
+++ server/character.h  12 Dec 2006 16:58:31 -0000      1.35
@@ -18,7 +18,7 @@
 //
 //
 
-/* $Id: character.h,v 1.34 2006/12/06 12:48:51 strk Exp $ */
+/* $Id: character.h,v 1.35 2006/12/12 16:58:31 strk Exp $ */
 
 #ifndef GNASH_CHARACTER_H
 #define GNASH_CHARACTER_H
@@ -67,9 +67,6 @@
 
        int             m_id;
 
-       /// Name of this character (if any)
-       std::string     _name;
-
        int             m_depth;
        cxform  m_color_transform;
        matrix  m_matrix;
@@ -83,6 +80,9 @@
 
 protected:
 
+       /// Name of this character (if any)
+       std::string     _name;
+
        bool m_visible;
 
        boost::intrusive_ptr<character> m_parent;
@@ -189,7 +189,7 @@
     uint16_t   get_clip_depth() const { return m_clip_depth; }
     void       set_clip_depth(uint16_t d) { m_clip_depth = d; }
 
-    void set_name(const char* name) { _name = name; }
+    virtual void set_name(const char* name) { _name = name; }
 
     const std::string& get_name() const { return _name; }
 

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -b -r1.99 -r1.100
--- server/sprite_instance.cpp  8 Dec 2006 14:11:48 -0000       1.99
+++ server/sprite_instance.cpp  12 Dec 2006 16:58:31 -0000      1.100
@@ -2735,4 +2735,32 @@
        return target;
 }
 
+const char*
+sprite_instance::get_text_value() const
+{
+       if ( ! _target_dot.empty() ) return _target_dot.c_str();
+
+       _target_dot = "_level0" + getTargetPath();
+
+       std::string::size_type current=0;
+       for (int i=0; i<_target_dot.length(); ++i)
+       {
+               if ( _target_dot[i] == '/' ) _target_dot[i] = '.';
+       }
+       //if ( _target_dot.back() == '.' ) _target_dot.pop_back();
+       return _target_dot.c_str();
+}
+
+void
+sprite_instance::set_name(const char* name)
+{
+       log_msg("set_name called");
+       _name = name;
+
+       // Reset these so they get computed next
+       // time someone request them.
+       _target.clear();
+       _target_dot.clear();
+}
+
 } // namespace gnash

Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- server/sprite_instance.h    6 Dec 2006 10:58:34 -0000       1.47
+++ server/sprite_instance.h    12 Dec 2006 16:58:31 -0000      1.48
@@ -17,7 +17,7 @@
 // 
 //
 
-/* $Id: sprite_instance.h,v 1.47 2006/12/06 10:58:34 strk Exp $ */
+/* $Id: sprite_instance.h,v 1.48 2006/12/12 16:58:31 strk Exp $ */
 
 // Stateful live Sprite instance
 
@@ -108,6 +108,9 @@
        ///
        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
@@ -543,6 +546,10 @@
        ///
        const std::string& getTargetPath() const;
 
+       /// Override for character::set_name to proprely update
+       /// _target and _target_dot.
+       virtual void set_name(const char* name);
+
 private:
 
        /// Execute a single action buffer (DOACTION block)
@@ -621,6 +628,9 @@
        /// 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;
 

Index: server/asobj/string.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/string.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/asobj/string.cpp     12 Dec 2006 16:27:43 -0000      1.11
+++ server/asobj/string.cpp     12 Dec 2006 16:58:31 -0000      1.12
@@ -18,10 +18,14 @@
 //
 //
 
-/* $Id: string.cpp,v 1.11 2006/12/12 16:27:43 strk Exp $ */
+/* $Id: string.cpp,v 1.12 2006/12/12 16:58:31 strk Exp $ */
 
 // Implementation of ActionScript String class.
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "tu_config.h"
 #include "gstring.h"
 #include "smart_ptr.h"
@@ -30,6 +34,7 @@
 #include "builtin_function.h" // need builtin_function
 #include "log.h"
 #include "array.h"
+#include "as_value.h"
 
 namespace gnash {
 
@@ -104,6 +109,11 @@
                return m_string.c_str();
        }
 
+       as_value get_primitive_value() const
+       {
+               return as_value(m_string.c_str());
+       }
+
 };
 
 

Index: testsuite/actionscript.all/MovieClip.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/MovieClip.as,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- testsuite/actionscript.all/MovieClip.as     27 Nov 2006 13:46:24 -0000      
1.18
+++ testsuite/actionscript.all/MovieClip.as     12 Dec 2006 16:58:31 -0000      
1.19
@@ -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.18 2006/11/27 13:46:24 strk Exp $";
+rcsid="$Id: MovieClip.as,v 1.19 2006/12/12 16:58:31 strk Exp $";
 
 #include "check.as"
 
@@ -204,6 +204,8 @@
 check_equals(mc3_mc.getBytesTotal(), 0);
 check_equals(mc3.getBytesLoaded(), 0);
 check_equals(mc3.getBytesTotal(), 0);
+check_equals(mc3_mc, _level0.mc3_mc);
+check_equals(String(mc3_mc), "_level0.mc3_mc");
 #endif
 
 




reply via email to

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