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: Thu, 24 Apr 2008 20:16:20 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/04/24 20:16:19

Modified files:
        .              : ChangeLog 
        server         : as_object.cpp as_object.h 
        server/vm      : ASHandlers.cpp 
        testsuite/actionscript.all: Inheritance.as 
        testsuite/misc-mtasc.all: implementsOpTest.as 
        testsuite/swfdec: PASSING 

Log message:
        * server/as_object.{cpp,h} (instanceOf): don't consider
          ourself as a prototype, use our __proto__ to check
          for inheritance and interfaces instead. Accept generic
          as_object, not just functions.
        * server/vm/ASHandlers.cpp (ActionImplementsOp):
          Interfaces must be registered to 'prototype', not '__proto__'
          of the target. (ActionInstanceOf): don't insist for the constructor
          argument to be a function, logaserror for aserrors...
        * testsuite/misc-mtasc.all/implementsOpTest.as: no more failures here.
        * testsuite/actionscript.all/Inheritance.as: no more failures about
          IMPLEMENTSOP / instanceof.
        * testsuite/swfdec/PASSING: implements.as succeeds in all versions,
          instance-of-propflags succeeds in versions 5,8,9 (fails in 6,7)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6388&r2=1.6389
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.cpp?cvsroot=gnash&r1=1.116&r2=1.117
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.h?cvsroot=gnash&r1=1.105&r2=1.106
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.228&r2=1.229
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Inheritance.as?cvsroot=gnash&r1=1.60&r2=1.61
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-mtasc.all/implementsOpTest.as?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/swfdec/PASSING?cvsroot=gnash&r1=1.132&r2=1.133

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6388
retrieving revision 1.6389
diff -u -b -r1.6388 -r1.6389
--- ChangeLog   24 Apr 2008 20:13:31 -0000      1.6388
+++ ChangeLog   24 Apr 2008 20:16:16 -0000      1.6389
@@ -1,5 +1,21 @@
 2008-04-24 Sandro Santilli <address@hidden>
 
+       * server/as_object.{cpp,h} (instanceOf): don't consider
+         ourself as a prototype, use our __proto__ to check
+         for inheritance and interfaces instead. Accept generic
+         as_object, not just functions.
+       * server/vm/ASHandlers.cpp (ActionImplementsOp):
+         Interfaces must be registered to 'prototype', not '__proto__'
+         of the target. (ActionInstanceOf): don't insist for the constructor
+         argument to be a function, logaserror for aserrors...
+       * testsuite/misc-mtasc.all/implementsOpTest.as: no more failures here.
+       * testsuite/actionscript.all/Inheritance.as: no more failures about
+         IMPLEMENTSOP / instanceof.
+       * testsuite/swfdec/PASSING: implements.as succeeds in all versions,
+         instance-of-propflags succeeds in versions 5,8,9 (fails in 6,7)
+
+2008-04-24 Sandro Santilli <address@hidden>
+
        * testsuite/actionscript.all/Inheritance.as:
          Don't run 'implementsop' tests if Ming doesn't
          support it. Add a test to ensure we don't

Index: server/as_object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.cpp,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -b -r1.116 -r1.117
--- server/as_object.cpp        21 Apr 2008 11:27:42 -0000      1.116
+++ server/as_object.cpp        24 Apr 2008 20:16:17 -0000      1.117
@@ -873,24 +873,65 @@
 }
 
 bool
-as_object::instanceOf(as_function* ctor)
+as_object::instanceOf(as_object* ctor)
 {
-       if (this == ctor->getPrototype())
-               return true;
+//#define GNASH_DEBUG_INSTANCE_OF 1
+
+       as_value protoVal;
+       if ( ! ctor->get_member(NSV::PROP_PROTOTYPE, &protoVal) )
+       {
+#ifdef GNASH_DEBUG_INSTANCE_OF
+               log_debug("Object %p can't be an instance of an object (%p) 
w/out 'prototype'",
+                       (void*)this, (void*)ctor);
+#endif
+               return false;
+       }
+       as_object* ctorProto = protoVal.to_object().get();
+       if ( ! ctorProto )
+       {
+#ifdef GNASH_DEBUG_INSTANCE_OF
+               log_debug("Object %p can't be an instance of an object (%p) 
with non-object 'prototype' (%s)",
+                       (void*)this, (void*)ctor, protoVal.to_debug_string());
+#endif
+               return false;
+       }
+
+       // TODO: cleanup the iteration, make it more readable ...
+
+       std::set< as_object* > visited;
 
-       if (!mInterfaces.empty())
+       as_object* obj = this;
+       while (obj && visited.insert(obj).second )
        {
-               // TODO: Make this work.
-               if (std::find(mInterfaces.begin(), mInterfaces.end(), 
ctor->getPrototype()) != mInterfaces.end())
+               as_object* thisProto = obj->get_prototype().get();
+               if ( ! thisProto )
                {
+                       break;
+               }
+
+               // Check our proto
+               if ( thisProto == ctorProto )
+               {
+#ifdef GNASH_DEBUG_INSTANCE_OF
+                       log_debug("Object %p is an instance of constructor %p 
as the constructor exposes our __proto__ %p",
+                               (void*)obj, (void*)ctor, (void*)thisProto);
+#endif
+                       return true;
+               }
+
+               // Check our proto interfaces
+               if (std::find(thisProto->mInterfaces.begin(), 
thisProto->mInterfaces.end(), ctorProto) != thisProto->mInterfaces.end())
+               {
+#ifdef GNASH_DEBUG_INSTANCE_OF
+                       log_debug("Object %p __proto__ %p had one interface 
matching with the constructor prototype %p",
+                               (void*)obj, (void*)thisProto, (void*)ctorProto);
+#endif
                        return true;
                }
+
+               obj = thisProto;
        }
 
-       as_object *proto = this->get_prototype().get();
-       if (proto)
-               return proto->instanceOf(ctor);
-       else
                return false;
 }
 

Index: server/as_object.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.h,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -b -r1.105 -r1.106
--- server/as_object.h  21 Apr 2008 11:27:42 -0000      1.105
+++ server/as_object.h  24 Apr 2008 20:16:17 -0000      1.106
@@ -839,12 +839,12 @@
 
        /// \brief
        /// Check whether this object is an instance of the given
-       /// as_function constructor
+       /// constructor
        //
        /// NOTE: built-in classes should NOT be C_FUNCTIONS for this to
        /// work
        ///
-       bool instanceOf(as_function* ctor);
+       bool instanceOf(as_object* ctor);
 
        /// \brief
        /// Check whether this object is a 'prototype' in the given

Index: server/vm/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v
retrieving revision 1.228
retrieving revision 1.229
diff -u -b -r1.228 -r1.229
--- server/vm/ASHandlers.cpp    21 Apr 2008 11:54:33 -0000      1.228
+++ server/vm/ASHandlers.cpp    24 Apr 2008 20:16:18 -0000      1.229
@@ -1439,14 +1439,24 @@
                );
                return;
        }
-       obj = obj->get_prototype().get();
-       if (!obj)
+
+       as_value protoval;
+       if ( ! obj->get_member(NSV::PROP_PROTOTYPE, &protoval) )
        {
                IF_VERBOSE_ASCODING_ERRORS(
                log_aserror(_("Target object for IMPLEMENTSOP has no 
prototype."));
                );
                return;
        }
+       obj = protoval.to_object().get();
+       if (!obj)
+       {
+               IF_VERBOSE_ASCODING_ERRORS(
+               log_aserror(_("IMPLEMENTSOP target object's prototype is not an 
object (%s)"),
+                       protoval.to_debug_string());
+               );
+               return;
+       }
 
        if ( count <= 0 )
        {
@@ -1459,16 +1469,38 @@
        thread.ensureStack(count);
        while (count--)
        {
-               as_value funval = env.pop();
-               as_function* fun = funval.to_as_function();
-               if ( ! fun )
+               as_value ctorval = env.pop();
+
+               as_object* ctor = ctorval.to_object().get();
+               if ( ! ctor )
                {
                        IF_VERBOSE_ASCODING_ERRORS(
-                       log_aserror(_("class found on stack on IMPLEMENTSOP is 
not a function: %s"), funval.to_debug_string().c_str());
+                       log_aserror(_("class found on stack on IMPLEMENTSOP is 
not an object: %s"), ctorval.to_debug_string());
                        );
                        continue;
                }
-               as_object *inter = fun->getPrototype().get();
+               if ( ! ctor->get_member(NSV::PROP_PROTOTYPE, &protoval) )
+               {
+                       IF_VERBOSE_ASCODING_ERRORS(
+                       log_aserror(_("Interface object for IMPLEMENTSOP has no 
prototype."));
+                       );
+                       continue;
+               }
+               as_object *inter = protoval.to_object().get();
+               if ( ! inter )
+               {
+                       IF_VERBOSE_ASCODING_ERRORS(
+                       log_aserror(_("Prototype of interface object for 
IMPLEMENTSOP is not an object (%s)."),
+                               protoval.to_debug_string());
+                       );
+                       continue;
+               }
+
+               IF_VERBOSE_ACTION(
+               log_action("%s (with .prototype %p) implements %s (with 
.prototype %p)",
+                       objval.to_debug_string(), (void*)obj, 
ctorval.to_debug_string(),
+                       (void*)inter);
+               );
                obj->add_interface(inter);
        }
 }
@@ -3736,15 +3768,15 @@
     thread.ensureStack(2); // super, instance
 
     // Get the "super" function
-    as_function* super = env.top(0).to_as_function();
+    as_object* super = env.top(0).to_object().get();
 
     // Get the "instance" (but avoid implicit conversion of primitive values!)
-    boost::intrusive_ptr<as_object> instance = env.top(1).is_object() ? 
env.top(1).to_object() : NULL;
+    as_object* instance = env.top(1).is_object() ? 
env.top(1).to_object().get() : NULL;
 
     // Invalid args!
     if (!super || ! instance) {
-        IF_VERBOSE_ACTION(
-        log_action(_("-- %s instanceof %s (invalid args?)"),
+        IF_VERBOSE_ASCODING_ERRORS(
+        log_aserror(_("-- %s instanceof %s (invalid args?)"),
                 env.top(1).to_debug_string().c_str(),
                 env.top(0).to_debug_string().c_str());
         );

Index: testsuite/actionscript.all/Inheritance.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Inheritance.as,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -b -r1.60 -r1.61
--- testsuite/actionscript.all/Inheritance.as   24 Apr 2008 20:13:33 -0000      
1.60
+++ testsuite/actionscript.all/Inheritance.as   24 Apr 2008 20:16:18 -0000      
1.61
@@ -21,7 +21,7 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: Inheritance.as,v 1.60 2008/04/24 20:13:33 strk Exp $";
+rcsid="$Id: Inheritance.as,v 1.61 2008/04/24 20:16:18 strk Exp $";
 #include "check.as"
 
 check_equals(typeof(Object.prototype.constructor), 'function');
@@ -127,7 +127,7 @@
 check_equals(TypeChanger.__proto__, Function.prototype);
 #endif
 
-xcheck(! TypeChanger.prototype instanceof TypeChanger);
+check(! TypeChanger.prototype instanceof TypeChanger);
 
 o1 = new TypeChanger(false);
 check_equals(o1.__proto__, TypeChanger.prototype);
@@ -547,7 +547,7 @@
 ob = {};
 check (! ob instanceof A ); 
 ob.__proto__ = B.prototype;
-xcheck (  ob instanceof A ); 
+check (  ob instanceof A ); 
 
 // Set A.prototype as a prototype of another object
 // and see if now ob results an instance of that other
@@ -555,7 +555,7 @@
 C = {};
 check (! ob instanceof C ); 
 C.prototype = A.prototype;
-xcheck (  ob instanceof C ); 
+check (  ob instanceof C ); 
 
 a = {}; b = {};
 a.__proto__ = b;

Index: testsuite/misc-mtasc.all/implementsOpTest.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-mtasc.all/implementsOpTest.as,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- testsuite/misc-mtasc.all/implementsOpTest.as        24 Apr 2008 16:53:05 
-0000      1.4
+++ testsuite/misc-mtasc.all/implementsOpTest.as        24 Apr 2008 20:16:18 
-0000      1.5
@@ -36,27 +36,27 @@
        
        function test_all():Void {
 
-               xcheck(!ImplementationA instanceof SimpleInterface);
+               check(!ImplementationA instanceof SimpleInterface);
                check(!ImplementationA.prototype instanceof SimpleInterface);
-               xcheck(!ImplementationB instanceof SimpleInterface);
+               check(!ImplementationB instanceof SimpleInterface);
                check(!ImplementationA.prototype instanceof SimpleInterface);
                check(!BExtendingImplementation instanceof ImplementationB);
                check(BExtendingImplementation.prototype instanceof 
ImplementationB);
-               xcheck(BExtendingImplementation.prototype instanceof 
SimpleInterface);
+               check(BExtendingImplementation.prototype instanceof 
SimpleInterface);
 
                objectA = new ImplementationA();
                objectB = new ImplementationB();
                objectC = new BExtendingImplementation();
 
                check(objectA instanceof ImplementationA);
-               xcheck(objectA instanceof SimpleInterface);
+               check(objectA instanceof SimpleInterface);
 
                check(objectB instanceof ImplementationB);
-               xcheck(objectB instanceof SimpleInterface);
+               check(objectB instanceof SimpleInterface);
 
                check(objectC instanceof BExtendingImplementation);
                check(objectC instanceof ImplementationB);
-               xcheck(objectC instanceof SimpleInterface);
+               check(objectC instanceof SimpleInterface);
        
 
                // TODO: review the tests below

Index: testsuite/swfdec/PASSING
===================================================================
RCS file: /sources/gnash/gnash/testsuite/swfdec/PASSING,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -b -r1.132 -r1.133
--- testsuite/swfdec/PASSING    23 Apr 2008 06:02:00 -0000      1.132
+++ testsuite/swfdec/PASSING    24 Apr 2008 20:16:19 -0000      1.133
@@ -339,6 +339,10 @@
 height1.swf:245da260d32dbc48a5f38566ee70171b
 height3.swf:2b7547493377ae1c0163c8273a4073f7
 height4.swf:8d36c180d196b49608f996db21a421bc
+implements-5.swf:92a657f3a89add44b1dd4f0e30632bc8
+implements-6.swf:280cde1bf92ae5c9358f30ae96e72016
+implements-7.swf:e74d546b9e6600313fb681da1303911f
+implements-8.swf:fc6e3b9fd5f9576a76da9c1714086352
 initaction-queue-5.swf:484859f4ef160149fa9c9d12983c9407
 initaction-queue-6.swf:f385d9c91f03feddc78878a240cefce1
 initaction-queue-7.swf:9a9c506965a854a348db7be3701ee4b3
@@ -348,6 +352,9 @@
 instance-name-loaded-5.swf:507414bb411ba30305034cf3078e5fa2
 instance-name-loaded-6.swf:d5fbbda201d50d6bf121b7c1a78ad3c8
 instance-name-loaded-7.swf:f4b4cf3a25a0010b7ff13a56a42d1aad
+instance-of-propflags-5.swf:1cab145faaa9544b3b1488c09f6639e5
+instance-of-propflags-8.swf:af7c2eee7fa1e572ff330d03d936d959
+instance-of-propflags-9.swf:b125071d54db67ae00035fc87ba37a9b
 isnan-5.swf:b296bdcf5e062c7263bdeac1df3b08b3
 isnan-6.swf:115656233daa53cadfba0c85584567e7
 isnan-7.swf:68650298c0f014793884b2d7adea1356




reply via email to

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