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: Thu, 15 Nov 2007 22:23:35 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/11/15 22:23:35

Modified files:
        .              : ChangeLog 
        server         : sprite_instance.cpp sprite_instance.h 
        testsuite/swfdec: PASSING 

Log message:
        Call constructAsScriptObject directly rather then on_event(CONSTRUCT)
        when needed.
        Doing so we can invoke the event handler *after* __proto__ is set
        but *before* the class constructor is invoked, as reported to be needed 
by
        swfdec tests.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4872&r2=1.4873
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.386&r2=1.387
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.h?cvsroot=gnash&r1=1.149&r2=1.150
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/swfdec/PASSING?cvsroot=gnash&r1=1.61&r2=1.62

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4872
retrieving revision 1.4873
diff -u -b -r1.4872 -r1.4873
--- ChangeLog   15 Nov 2007 20:46:39 -0000      1.4872
+++ ChangeLog   15 Nov 2007 22:23:34 -0000      1.4873
@@ -1,5 +1,15 @@
 2007-11-15 Sandro Santilli <address@hidden>
 
+       * server/sprite_instance.{cpp,h}: call constructAsScriptObject
+         directly rather then on_event(CONSTRUCT) when needed. Doing
+         so we can invoke the event handler *after* __proto__ is set
+         but *before* the class constructor is invoked, as reported to
+         be needed by swfdec tests.
+       * testsuite/swfdec/PASSING: movieclip-set-prototype-{5,6,7,8}.swf
+         succeed.
+
+2007-11-15 Sandro Santilli <address@hidden>
+
        * server/vm/ASHandlers.cpp (ActionCastOp): swap order of arguments,
          return null on supposedly invalid call.
        * testsuite/swfdec/PASSING: cast-{5,6,7,8}.swf succeed.

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.386
retrieving revision 1.387
diff -u -b -r1.386 -r1.387
--- server/sprite_instance.cpp  15 Nov 2007 16:57:23 -0000      1.386
+++ server/sprite_instance.cpp  15 Nov 2007 22:23:34 -0000      1.387
@@ -48,7 +48,7 @@
 #include "StreamProvider.h"
 #include "URLAccessManager.h" // for loadVariables
 #include "LoadVariablesThread.h" 
-#include "ExecutableCode.h"
+#include "ExecutableCode.h" // for inheritance of ConstructEvent
 #include "gnash.h" // for point class !
 #include "Timeline.h" // for restoreDisplayList
 #include "Object.h" // for getObjectInterface
@@ -87,6 +87,56 @@
 static void attachMovieClipInterface(as_object& o);
 static void attachMovieClipProperties(as_object& o);
 
+/// Anonymous namespace for module-private definitions
+namespace
+{
+
+       /// ConstructEvent, used for queuing construction
+       //
+       /// It's execution will call constructAsScriptObject() 
+       /// on the target sprite
+       ///
+       class ConstructEvent: public ExecutableCode {
+
+       public:
+
+               ConstructEvent(sprite_instance* nTarget)
+                       :
+                       _target(nTarget)
+               {}
+
+
+               ExecutableCode* clone() const
+               {
+                       return new ConstructEvent(*this);
+               }
+
+               virtual void execute()
+               {
+                       _target->constructAsScriptObject();
+               }
+
+       #ifdef GNASH_USE_GC
+               /// Mark reachable resources (for the GC)
+               //
+               /// Reachable resources are:
+               ///      - the action target (_target)
+               ///
+               virtual void markReachableResources() const
+               {
+                       _target->setReachable();
+               }
+       #endif // GNASH_USE_GC
+
+       private:
+
+               sprite_instance* _target;
+
+       };
+
+} // anonymous namespace
+
+
 //------------------------------------------------
 // Utility funx
 //------------------------------------------------
@@ -1789,8 +1839,6 @@
 bool sprite_instance::get_member(string_table::key name_key, as_value* val,
        string_table::key nsname)
 {
-       //constructAsScriptObject();
-
        const std::string& name = VM::get().getStringTable().value(name_key);
 
        // FIXME: use addProperty interface for these !!
@@ -2149,15 +2197,6 @@
                return false;
        }
 
-       //if ( id.m_id == event_id::INITIALIZE )
-       if ( id.m_id == event_id::CONSTRUCT )
-       {
-               // Construct as ActionScript object.
-               // TODO: it could be we need to do this on-demand instead
-               // (on __proto__ query)
-               constructAsScriptObject();
-       }
-
        if ( id.is_button_event() && ! isEnabled() )
        {
 #ifdef GNASH_DEBUG
@@ -3398,7 +3437,7 @@
                log_debug("Sprite %s is dynamic, sending INITIALIZE and 
CONSTRUCT events immediately", getTarget().c_str());
 #endif
                on_event(event_id::INITIALIZE);
-               on_event(event_id::CONSTRUCT);
+               constructAsScriptObject(); 
        }
        else
        {
@@ -3410,7 +3449,8 @@
 #ifdef GNASH_DEBUG
                log_debug("Queuing CONSTRUCT event for sprite %s", 
getTarget().c_str());
 #endif
-               queueEvent(event_id::CONSTRUCT, movie_root::apCONSTRUCT);
+               std::auto_ptr<ExecutableCode> code ( new ConstructEvent(this) );
+               _vm.getRoot().pushAction(code, movie_root::apCONSTRUCT);
        }
 
        // Now execute frame tags and take care of queuing the LOAD event.
@@ -3458,6 +3498,9 @@
 #ifdef GNASH_DEBUG
        log_debug("constructAsScriptObject called for sprite %s", 
getTarget().c_str());
 #endif
+
+       bool eventHandlersInvoked = false;
+
        do {
                if ( _name.empty() )
                {
@@ -3472,10 +3515,7 @@
                sprite_definition* def = 
dynamic_cast<sprite_definition*>(m_def.get());
 
                // We won't "construct" top-level movies
-               if ( ! def )
-               {
-                       break;
-               }
+               if ( ! def ) break;
 
                as_function* ctor = def->getRegisteredClass();
 #ifdef GNASH_DEBUG
@@ -3490,21 +3530,29 @@
                        boost::intrusive_ptr<as_object> proto = 
ctor->getPrototype();
                        set_prototype(proto);
 
-                       //log_msg(_("Calling the user-defined constructor 
against this sprite_instance"));
-                       fn_call call(this, &(get_environment()), 0, 0);
-
-                       // we don't use the constructor return (should we?)
-                       (*ctor)(call);
+                       // Call event handlers *after* setting up the __proto__
+                       // but *before* calling the registered class constructor
+                       on_event(event_id::CONSTRUCT);
+                       eventHandlersInvoked = true;
 
                        int swfversion = _vm.getSWFVersion();
 
-                       // Set the '__constructor__' and 'constructor' members
+                       // Set the '__constructor__' and 'constructor' members, 
as well as call
+                       // the actual constructor.
+                       //
                        // TODO: this would be best done by an 
as_function::constructInstance()
                        //       method. We have one but it returns a new 
object rather then
                        //       initializing a given object, we just need to 
add another one...
                        //
                        if ( swfversion > 5 )
                        {
+                               //log_debug(_("Calling the user-defined 
constructor against this sprite_instance"));
+                               fn_call call(this, &(get_environment()), 0, 0);
+
+                               // we don't use the constructor return (should 
we?)
+                               (*ctor)(call);
+
+
                                set_member(NSV::PROP_uuCONSTRUCTORuu, ctor);
                                if ( swfversion == 6 )
                                {
@@ -3512,8 +3560,14 @@
                                }
                        }
                }
+
        } while (0);
 
+       /// Invoke event handlers if not done yet
+       if ( ! eventHandlersInvoked )
+       {
+               on_event(event_id::CONSTRUCT);
+       }
 }
 
 bool

Index: server/sprite_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.h,v
retrieving revision 1.149
retrieving revision 1.150
diff -u -b -r1.149 -r1.150
--- server/sprite_instance.h    14 Nov 2007 13:23:47 -0000      1.149
+++ server/sprite_instance.h    15 Nov 2007 22:23:35 -0000      1.150
@@ -815,8 +815,6 @@
         ///
         void queueAction(const action_buffer& buf);
 
-private:
-
        /// Construct this instance as an ActionScript object
        //
        /// This method invokes the constructor associated with our
@@ -826,6 +824,8 @@
        ///
        void constructAsScriptObject();
 
+private:
+
        /// Register this sprite as a listener of core broadcasters
        //
        /// This is currently only used for key events broadcaster

Index: testsuite/swfdec/PASSING
===================================================================
RCS file: /sources/gnash/gnash/testsuite/swfdec/PASSING,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- testsuite/swfdec/PASSING    15 Nov 2007 20:46:40 -0000      1.61
+++ testsuite/swfdec/PASSING    15 Nov 2007 22:23:35 -0000      1.62
@@ -221,6 +221,10 @@
 math-constants-6.swf:cc4a6b92d473f57cb5479c97ba77c2e0
 math-constants-7.swf:53df046dd67c331c79c0c939215ac770
 mouse-scaled-5.swf:9138b10aab35c2d4e969057b9c253b42
+movieclip-set-prototype-5.swf:99235a738d69d9c78fa2bc5d355c6dae
+movieclip-set-prototype-6.swf:bae79ccbb89bb7c11cd1961d2c473022
+movieclip-set-prototype-7.swf:f147fff166cc46cdcda77d5012faddb0
+movieclip-set-prototype-8.swf:9fbacb2c3107d434b585978d18ec25bb
 movieclip-swap-depths-5.swf:4c337a1aaa285b1e7d000acc06b6a5d7
 moviecliploader-constructor-5.swf:fd0fb9a785017456810f06b61c109d35
 moviecliploader-constructor-6.swf:e50f068ebde835d503c43ae1fcaf4371




reply via email to

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