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.cpp server/as_...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/as_object.cpp server/as_...
Date: Sun, 02 Sep 2007 00:12:49 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/09/02 00:12:48

Modified files:
        .              : ChangeLog 
        server         : as_object.cpp as_object.h dlist.cpp 
                         sprite_instance.cpp 
        testsuite/actionscript.all: Object.as toString_valueOf.as 

Log message:
                * server/as_object.{h,cpp}: handle __proto__ has a normal 
property.
                * server/sprite_instance.cpp (replace_display_object): log an 
error
                  if the character to be replaced is not found.
                * server/dlist.cpp (replace_character): don't restart the 
character
                  being added (fixes a problem with the ::restart function 
itself, in
                  that it also cleans up all properties, which now include the
                  __proto__ member).
                * testsuite/actionscript.all/toString_valueOf.as: more 
successes.
                * testsuite/actionscript.all/Object.as: more successes.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4185&r2=1.4186
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.cpp?cvsroot=gnash&r1=1.58&r2=1.59
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.h?cvsroot=gnash&r1=1.65&r2=1.66
http://cvs.savannah.gnu.org/viewcvs/gnash/server/dlist.cpp?cvsroot=gnash&r1=1.81&r2=1.82
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.320&r2=1.321
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Object.as?cvsroot=gnash&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/toString_valueOf.as?cvsroot=gnash&r1=1.11&r2=1.12

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4185
retrieving revision 1.4186
diff -u -b -r1.4185 -r1.4186
--- ChangeLog   1 Sep 2007 23:44:22 -0000       1.4185
+++ ChangeLog   2 Sep 2007 00:12:47 -0000       1.4186
@@ -1,3 +1,15 @@
+2007-09-01 Sandro Santilli <address@hidden>
+
+       * server/as_object.{h,cpp}: handle __proto__ has a normal property.
+       * server/sprite_instance.cpp (replace_display_object): log an error
+         if the character to be replaced is not found.
+       * server/dlist.cpp (replace_character): don't restart the character
+         being added (fixes a problem with the ::restart function itself, in
+         that it also cleans up all properties, which now include the
+         __proto__ member).
+       * testsuite/actionscript.all/toString_valueOf.as: more successes.
+       * testsuite/actionscript.all/Object.as: more successes.
+
 2007-09-01 Markus Gothe <address@hidden> 
 
        * macros/boost.m4: push/pop CXXFLAGS/CPPFLAGS.

Index: server/as_object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.cpp,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -b -r1.58 -r1.59
--- server/as_object.cpp        1 Sep 2007 10:03:57 -0000       1.58
+++ server/as_object.cpp        2 Sep 2007 00:12:48 -0000       1.59
@@ -98,22 +98,6 @@
 {
        assert(val);
 
-       //log_msg(_("Getting member %s (SWF version:%d)"), name.c_str(), 
vm.getSWFVersion());
-
-       // TODO: inspect wheter it is possible to make __proto__ a
-       //       getter/setter property instead, to take this into account
-       //
-       if (name == "__proto__")
-       {
-               as_object* p = get_prototype();
-               if ( p ) {
-                       val->set_as_object(p);
-                       return true;
-               } else {
-                       return false;
-               }
-       }
-
        Property* prop = findProperty(name);
        if ( ! prop ) return false;
 
@@ -135,12 +119,18 @@
 Property*
 as_object::findProperty(const std::string& key)
 {
+       // don't enter an infinite loop looking for __proto__ ...
+       if ( key == "__proto__" )
+       {
+               return _members.getProperty(key);
+       }
+
        // this set will keep track of visited objects,
        // to avoid infinite loops
-       std::set<const as_object*> visited;
+       std::set< as_object* > visited;
 
-       as_object* obj = this;
-       while ( obj && visited.insert(obj).second )
+       boost::intrusive_ptr<as_object> obj = this;
+       while ( obj && visited.insert(obj.get()).second )
        {
                Property* prop = obj->_members.getProperty(key);
                if ( prop ) return prop;
@@ -156,12 +146,21 @@
 Property*
 as_object::findGetterSetter(const std::string& key)
 {
+       // don't enter an infinite loop looking for __proto__ ...
+       if ( key == "__proto__" )
+       {
+               Property* prop = _members.getProperty(key);
+               if ( ! prop ) return NULL;
+               if ( ! prop->isGetterSetter() ) return NULL;
+               return prop;
+       }
+
        // this set will keep track of visited objects,
        // to avoid infinite loops
-       std::set<const as_object*> visited;
+       std::set< as_object* > visited;
 
-       as_object* obj = this;
-       while ( obj && visited.insert(obj).second )
+       boost::intrusive_ptr<as_object> obj = this;
+       while ( obj && visited.insert(obj.get()).second )
        {
                Property* prop = obj->_members.getProperty(key);
                if ( prop && prop->isGetterSetter() )
@@ -180,24 +179,23 @@
 
 /*protected*/
 void
-as_object::set_prototype(boost::intrusive_ptr<as_object> proto)
+as_object::set_prototype(boost::intrusive_ptr<as_object> proto, int flags)
 {
-       m_prototype = proto;
+       static std::string key ( "__proto__" );
+
+       // TODO: check what happens if __proto__ is set as a user-defined 
getter/setter
+       if ( _members.setValue(key, as_value(proto.get()), *this) )
+       {
+               // TODO: optimize this, don't scan again !
+               _members.setFlags(key, flags, 0);
+       }
 }
 
 void
 as_object::set_member_default(const std::string& key, const as_value& val )
 {
-
        //log_msg(_("set_member_default(%s)"), key.c_str());
 
-       // TODO: make __proto__ a getter/setter?
-       if (key == "__proto__") 
-       {
-               set_prototype(val.to_object());
-               return;
-       }
-
        // found a getter/setter property in the inheritance chain
        // so set that and return
        Property* prop = findGetterSetter(key);
@@ -349,11 +347,11 @@
 bool
 as_object::instanceOf(as_function* ctor)
 {
-       const as_object* obj = this;
+       boost::intrusive_ptr<as_object> obj = this;
 
-       std::set<const as_object*> visited;
+       std::set< as_object* > visited;
 
-       while (obj && visited.insert(obj).second )
+       while (obj && visited.insert(obj.get()).second )
        {
                if ( obj->get_prototype() == ctor->getPrototype() ) return true;
                obj = obj->get_prototype(); 
@@ -370,11 +368,11 @@
 bool
 as_object::prototypeOf(as_object& instance)
 {
-       const as_object* obj = &instance;
+       boost::intrusive_ptr<as_object> obj = &instance;
 
-       std::set<const as_object*> visited;
+       std::set< as_object* > visited;
 
-       while (obj && visited.insert(obj).second )
+       while (obj && visited.insert(obj.get()).second )
        {
                if ( obj->get_prototype() == this ) return true;
                obj = obj->get_prototype(); 
@@ -458,11 +456,12 @@
 
                // Are we sure we need to descend to __proto__ ?
                // should we recurse then ?
-
+#if 0
                if (m_prototype)
                {
                        m_prototype->_members.setFlagsAll(set_true, set_false);
                }
+#endif
        }
        else
        {
@@ -490,10 +489,10 @@
 
        // this set will keep track of visited objects,
        // to avoid infinite loops
-       std::set<const as_object*> visited;
+       std::set< as_object* > visited;
 
-       const as_object* obj = this;
-       while ( obj && visited.insert(obj).second )
+       boost::intrusive_ptr<as_object> obj = const_cast<as_object*>(this);
+       while ( obj && visited.insert(obj.get()).second )
        {
                obj->_members.enumerateKeys(env);
                obj = obj->get_prototype();
@@ -510,10 +509,10 @@
 
        // this set will keep track of visited objects,
        // to avoid infinite loops
-       std::set<const as_object*> visited;
+       std::set< as_object* > visited;
 
-       as_object* obj = this;
-       while ( obj && visited.insert(obj).second )
+       boost::intrusive_ptr<as_object> obj = this;
+       while ( obj && visited.insert(obj.get()).second )
        {
                obj->_members.enumerateKeyValue(*this, to);
                obj = obj->get_prototype();
@@ -524,25 +523,28 @@
 as_object::as_object()
        :
        _members(),
-       _vm(VM::get()),
-       m_prototype(NULL)
+       _vm(VM::get())
+       //, m_prototype(NULL)
 {
 }
 
 as_object::as_object(as_object* proto)
        :
        _members(),
-       _vm(VM::get()),
-       m_prototype(proto)
+       _vm(VM::get())
+       //, m_prototype(proto)
 {
+       init_member("__proto__", as_value(proto));
 }
 
 as_object::as_object(boost::intrusive_ptr<as_object> proto)
        :
        _members(),
-       _vm(VM::get()),
-       m_prototype(proto)
+       _vm(VM::get())
+       //, m_prototype(proto)
 {
+       //set_prototype(proto);
+       init_member("__proto__", as_value(proto));
 }
 
 as_object::as_object(const as_object& other)
@@ -553,8 +555,8 @@
        GcResource(), 
 #endif
        _members(other._members),
-       _vm(VM::get()),
-       m_prototype(other.m_prototype)
+       _vm(VM::get())
+       //, m_prototype(other.m_prototype) // done by _members copy
 {
 }
 
@@ -612,21 +614,28 @@
        return obj->get_primitive_value();
 }
 
-as_object*
+boost::intrusive_ptr<as_object>
 as_object::get_prototype()
 {
+       static std::string key ( "__proto__" );
+       as_value tmp;
+       // I don't think any subclass should override getting __proto__ 
anyway...
+       //if ( ! get_member(key, &tmp) ) return NULL;
+       if ( ! _members.getValue(key, tmp, *this) ) return NULL;
+       return tmp.to_object();
+
+#if 0 // the inheritance chain MUST end somewhere, handle the SWF4 thing in 
some other way
        if ( m_prototype ) return m_prototype.get();
        //log_msg(_("as_object::get_prototype(): Hit top of inheritance 
chain"));
 
-#if 0 // the inheritance chain MUST end somewhere, handle the SWF4 thing in 
some other way
        // if SWF version < 5 the Object interface won't keep alive !
        if ( _vm.getSWFVersion() > 4 )
        {
                return getObjectInterface();
        }
-#endif
 
        return NULL;
+#endif
 }
 
 #ifdef NEW_KEY_LISTENER_LIST_DESIGN

Index: server/as_object.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.h,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -b -r1.65 -r1.66
--- server/as_object.h  1 Sep 2007 10:03:57 -0000       1.65
+++ server/as_object.h  2 Sep 2007 00:12:48 -0000       1.66
@@ -440,9 +440,9 @@
        ///
        /// NOTE: can return NULL (and it is expected to do for 
Object.prototype)
        ///
-       as_object* get_prototype();
+       boost::intrusive_ptr<as_object> get_prototype();
 
-       const as_object* get_prototype() const {
+       const boost::intrusive_ptr<as_object> get_prototype() const {
                // cast away constness
                return const_cast<as_object*>(this)->get_prototype();
        }
@@ -454,7 +454,7 @@
        /// public: set_member("__proto__", <anyting>)
        /// will do just the same
        ///
-       void set_prototype(boost::intrusive_ptr<as_object> proto);
+       void set_prototype(boost::intrusive_ptr<as_object> proto, int 
flags=as_prop_flags::dontDelete|as_prop_flags::dontEnum);
 
        std::string asPropName(std::string name);
        
@@ -529,7 +529,7 @@
        void markAsObjectReachable() const
        {
                _members.setReachable();
-               if ( m_prototype.get() ) m_prototype->setReachable();
+               //if ( m_prototype.get() ) m_prototype->setReachable();
        }
 #endif // GNASH_USE_GC
 
@@ -539,7 +539,7 @@
 private:
 
        /// Reference to this object's '__proto__'
-       boost::intrusive_ptr<as_object> m_prototype;
+       //boost::intrusive_ptr<as_object> m_prototype;
 
 };
 

Index: server/dlist.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/dlist.cpp,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -b -r1.81 -r1.82
--- server/dlist.cpp    1 Sep 2007 01:20:46 -0000       1.81
+++ server/dlist.cpp    2 Sep 2007 00:12:48 -0000       1.82
@@ -296,7 +296,11 @@
                ch->set_ratio(ratio);
        }
        ch->set_clip_depth(clip_depth);
-       ch->restart();
+
+       // NOTE: currently, ::restart also cleans up all property, which 
include __proto__ !!
+       //       For this reason I commented it out. Since no tests in the 
testsuite are failing
+       //       I'm not sure what does this break. Udo: do you remember ? 
--strk;
+       // ch->restart();
 
        container_type::iterator it = find_if(
                        _characters.begin(), _characters.end(),

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.320
retrieving revision 1.321
diff -u -b -r1.320 -r1.321
--- server/sprite_instance.cpp  1 Sep 2007 01:20:46 -0000       1.320
+++ server/sprite_instance.cpp  2 Sep 2007 00:12:48 -0000       1.321
@@ -2882,7 +2882,11 @@
                 mat,
                 ratio, clip_depth);
         }
-    } // end of if(existing_char)
+    }
+    else // non-existing character
+    {
+       log_error("sprite_instance::replace_display_object: could not find any 
character at depth %d", depth);
+    } 
 }
 
 void sprite_instance::replace_display_object(

Index: testsuite/actionscript.all/Object.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Object.as,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- testsuite/actionscript.all/Object.as        1 Sep 2007 09:40:06 -0000       
1.32
+++ testsuite/actionscript.all/Object.as        2 Sep 2007 00:12:48 -0000       
1.33
@@ -20,7 +20,7 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: Object.as,v 1.32 2007/09/01 09:40:06 strk Exp $";
+rcsid="$Id: Object.as,v 1.33 2007/09/02 00:12:48 strk Exp $";
 
 #include "check.as"
 
@@ -31,6 +31,9 @@
 // registerClass is a public static function of Object
 check_equals(typeof(Object.registerClass), 'function');
 check_equals(typeof(Object.prototype.toString), 'function');
+#if OUTPUT_VERSION > 5
+ check(Object.prototype.hasOwnProperty('toString'));
+#endif
 check_equals(typeof(Object.prototype.valueOf), 'function');
 check_equals(typeof(Object.prototype.constructor), 'function'); 
 #if OUTPUT_VERSION > 5
@@ -54,19 +57,19 @@
 
 // Through test of existance of methods!
 
-xcheck(Object.hasOwnProperty('__proto__'));
+check(Object.hasOwnProperty('__proto__'));
 
 O = Object;
 check_equals(O, Object);
 
 // found 4 methods in Object
-xcheck(O.hasOwnProperty('__proto__'));
+check(O.hasOwnProperty('__proto__'));
 check(O.hasOwnProperty('registerClass'));
 check(O.hasOwnProperty('constructor'));
 check(O.hasOwnProperty('prototype'));
 
 // fount 4 methods in Object.__proto__
-xcheck(O.__proto__.hasOwnProperty('__proto__'));
+check(O.__proto__.hasOwnProperty('__proto__'));
 check(O.__proto__.hasOwnProperty('apply'));
 check(O.__proto__.hasOwnProperty('call'));
 check(O.__proto__.hasOwnProperty('constructor'));
@@ -75,7 +78,7 @@
 check(O.__proto__.__proto__ == Object.prototype);
 
 // found 3 methods in Object.constructor
-xcheck(O.constructor.hasOwnProperty('__proto__'));
+check(O.constructor.hasOwnProperty('__proto__'));
 check(O.constructor.hasOwnProperty('constructor'));
 check(O.constructor.hasOwnProperty('prototype'));
 
@@ -91,7 +94,7 @@
 check(O.prototype.hasOwnProperty('watch'));
 
 // found 3 methods in Object.prototype.constructor
-xcheck(O.prototype.constructor.hasOwnProperty('__proto__'));
+check(O.prototype.constructor.hasOwnProperty('__proto__'));
 check(O.prototype.constructor.hasOwnProperty('constructor'));
 check(O.prototype.constructor.hasOwnProperty('prototype'));
 

Index: testsuite/actionscript.all/toString_valueOf.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/toString_valueOf.as,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- testsuite/actionscript.all/toString_valueOf.as      1 Sep 2007 09:40:06 
-0000       1.11
+++ testsuite/actionscript.all/toString_valueOf.as      2 Sep 2007 00:12:48 
-0000       1.12
@@ -31,7 +31,7 @@
   
   check(Function.prototype.hasOwnProperty('apply'));
   check(Function.prototype.hasOwnProperty('call'));
-  xcheck(Function.prototype.hasOwnProperty('__proto__'));
+  check(Function.prototype.hasOwnProperty('__proto__'));
   check(Function.prototype.hasOwnProperty('constructor'));
   
   check(!Function.prototype.hasOwnProperty('toString'));




reply via email to

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