gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/character.cpp server/cha...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/character.cpp server/cha...
Date: Tue, 04 Sep 2007 21:50:22 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/09/04 21:50:21

Modified files:
        .              : ChangeLog 
        server         : character.cpp character.h 
        server/vm      : ExecutableCode.h 

Log message:
                * server/character.{cpp,h}: add hasEventHandler() and 
queueEvent()
                  methods. Implement ::unload by queuing the UNLOAD event (not 
its
                  handlers
                * server/vm/ExecutableCode.h: Add QueuedEvent "executable 
code", for
                  queuing events rather then handlers.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4219&r2=1.4220
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.cpp?cvsroot=gnash&r1=1.52&r2=1.53
http://cvs.savannah.gnu.org/viewcvs/gnash/server/character.h?cvsroot=gnash&r1=1.93&r2=1.94
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ExecutableCode.h?cvsroot=gnash&r1=1.9&r2=1.10

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4219
retrieving revision 1.4220
diff -u -b -r1.4219 -r1.4220
--- ChangeLog   4 Sep 2007 20:50:00 -0000       1.4219
+++ ChangeLog   4 Sep 2007 21:50:21 -0000       1.4220
@@ -1,5 +1,13 @@
 2007-09-04 Sandro Santilli <address@hidden>
 
+       * server/character.{cpp,h}: add hasEventHandler() and queueEvent()
+         methods. Implement ::unload by queuing the UNLOAD event (not its
+         handlers
+       * server/vm/ExecutableCode.h: Add QueuedEvent "executable code", for
+         queuing events rather then handlers.
+
+2007-09-04 Sandro Santilli <address@hidden>
+
        * server/sprite_instance.h: make execute_action() public, for use
          by DoActionTag (for init actions).
        * server/swf/DoActionTag.h: execute init actions by directly

Index: server/character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/character.cpp,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -b -r1.52 -r1.53
--- server/character.cpp        3 Sep 2007 17:37:37 -0000       1.52
+++ server/character.cpp        4 Sep 2007 21:50:21 -0000       1.53
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 // 
 
-/* $Id: character.cpp,v 1.52 2007/09/03 17:37:37 strk Exp $ */
+/* $Id: character.cpp,v 1.53 2007/09/04 21:50:21 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -679,45 +679,35 @@
        assert(!_unloaded); // don't unload characters twice !
 
        //log_msg(_("Queuing unload event for character %p"), this);
-       bool hasEvent =  queueEventHandler(event_id::UNLOAD);
        //on_event(event_id::UNLOAD);
+       //bool hasEvent = queueEventHandler(event_id::UNLOAD);
+       queueEvent(event_id::UNLOAD);
+       bool hasEvent = hasEventHandler(event_id::UNLOAD);
 
        _unloaded = true;
 
        return hasEvent;
 }
 
-bool
-character::queueEventHandler(const event_id& id)
+void
+character::queueEvent(const event_id& id)
 {
-       bool called=false;
 
-       movie_root& root = VM::get().getRoot();
-
-       std::auto_ptr<ExecutableCode> code ( get_event_handler(id) );
-       if ( code.get() )
-       {
-               root.pushAction(code);
-               called=true;
-       }
+       movie_root& root = _vm.getRoot();
+       std::auto_ptr<ExecutableCode> event(new 
QueuedEvent(boost::intrusive_ptr<character>(this), id));
+       root.pushAction(event);
+}
 
-       // This is likely wrong, we use it as a workaround
-       // to the fact that we don't distinguish between
-       // ActionScript and SWF defined events
-       // (for example: onClipLoad vs. onLoad)
-       //
-       //if (called) return;
+bool
+character::hasEventHandler(const event_id& id) const
+{
+       Events::const_iterator it = _event_handlers.find(id);
+       if ( it != _event_handlers.end() ) return true;
 
-       // Check for member function.
        boost::intrusive_ptr<as_function> method = 
getUserDefinedEventHandler(id.get_function_name());
-       if ( method )
-       {
-               root.pushAction(method, boost::intrusive_ptr<character>(this));
-               called = true;
-       }
-
-       return called;
+       if (method) return true;
 
+       return false;
 }
 
 boost::intrusive_ptr<as_function>

Index: server/character.h
===================================================================
RCS file: /sources/gnash/gnash/server/character.h,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -b -r1.93 -r1.94
--- server/character.h  3 Sep 2007 07:42:59 -0000       1.93
+++ server/character.h  4 Sep 2007 21:50:21 -0000       1.94
@@ -19,7 +19,7 @@
 //
 //
 
-/* $Id: character.h,v 1.93 2007/09/03 07:42:59 strk Exp $ */
+/* $Id: character.h,v 1.94 2007/09/04 21:50:21 strk Exp $ */
 
 #ifndef GNASH_CHARACTER_H
 #define GNASH_CHARACTER_H
@@ -866,11 +866,22 @@
                return false;
        }
 
-       /// Queue event handler(s), if any.
+       /// Queue event in the global action queue.
        //
-       /// @return true if any event handler was queued, false otherwise.
+       /// on_event(id) will be called by execution of the queued
+       /// action
        ///
-       bool queueEventHandler(const event_id& id);
+       void queueEvent(const event_id& id);
+
+       /// Return true if an handler for the given event is defined
+       //
+       /// NOTE that we look for both clip-defined and user-defined
+       /// handlers, which is likely error prone since we're doing
+       /// this in a non-virtual function. Main use for this method
+       /// is for being called by ::unload() to verify an Unload handler
+       /// is available.
+       ///
+       bool hasEventHandler(const event_id& id) const;
 
        virtual void on_button_event(const event_id& id)
        {

Index: server/vm/ExecutableCode.h
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ExecutableCode.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- server/vm/ExecutableCode.h  4 Sep 2007 10:19:01 -0000       1.9
+++ server/vm/ExecutableCode.h  4 Sep 2007 21:50:21 -0000       1.10
@@ -15,7 +15,7 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-/* $Id: ExecutableCode.h,v 1.9 2007/09/04 10:19:01 strk Exp $ */
+/* $Id: ExecutableCode.h,v 1.10 2007/09/04 21:50:21 strk Exp $ */
 
 #ifndef GNASH_EXECUTABLECODE_H
 #define GNASH_EXECUTABLECODE_H
@@ -173,6 +173,48 @@
 
 };
 
+/// Generic event  (constructed by id, invoked using on_event
+class QueuedEvent: public ExecutableCode {
+
+public:
+
+       QueuedEvent(boost::intrusive_ptr<character> nTarget, const event_id& id)
+               :
+               _target(nTarget),
+               _eventId(id)
+       {}
+
+
+       ExecutableCode* clone() const
+       {
+               return new QueuedEvent(*this);
+       }
+
+       virtual void execute()
+       {
+               _target->on_event(_eventId);
+       }
+
+#ifdef GNASH_USE_GC
+       /// Mark reachable resources (for the GC)
+       //
+       /// Reachable resources are:
+       ///      - the action target (_target)
+       ///
+       virtual void markReachableResources() const
+       {
+               if ( _target ) _target->setReachable();
+       }
+#endif // GNASU_USE_GC
+
+private:
+
+       boost::intrusive_ptr<character> _target;
+
+       const event_id _eventId;
+
+};
+
 /// Function code
 class FunctionCode: public ExecutableCode {
 




reply via email to

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