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/aso...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/as_object.cpp server/aso...
Date: Tue, 02 Oct 2007 12:17:47 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/10/02 12:17:47

Modified files:
        .              : ChangeLog 
        server         : as_object.cpp 
        server/asobj   : MovieClipLoader.cpp 
        testsuite/actionscript.all: MovieClipLoader.as 

Log message:
                * server/as_object.cpp (callMethod): fix order in which
                  args are pushed on the stack [the version taking 2 args].
                * server/asobj/MovieClipLoader.cpp: initialize MovieClipLoader
                  instances as AsBroadcasters, call broadcastMessage for 
broadcasting,
                  use the environment used in the loadClip call.
                * testsuite/actionscript.all/MovieClipLoader.as: add test for
                  existence of the broadcastMessage function.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4497&r2=1.4498
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_object.cpp?cvsroot=gnash&r1=1.66&r2=1.67
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/MovieClipLoader.cpp?cvsroot=gnash&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/MovieClipLoader.as?cvsroot=gnash&r1=1.4&r2=1.5

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4497
retrieving revision 1.4498
diff -u -b -r1.4497 -r1.4498
--- ChangeLog   2 Oct 2007 06:26:42 -0000       1.4497
+++ ChangeLog   2 Oct 2007 12:17:46 -0000       1.4498
@@ -1,5 +1,15 @@
 2007-10-02 Sandro Santilli <address@hidden>
 
+       * server/as_object.cpp (callMethod): fix order in which
+         args are pushed on the stack [the version taking 2 args].
+       * server/asobj/MovieClipLoader.cpp: initialize MovieClipLoader
+         instances as AsBroadcasters, call broadcastMessage for broadcasting,
+         use the environment used in the loadClip call.
+       * testsuite/actionscript.all/MovieClipLoader.as: add test for
+         existence of the broadcastMessage function.
+
+2007-10-02 Sandro Santilli <address@hidden>
+
        * server/movie_root.cpp (testInvariant): non-emptiness of _movies
          container is NOT an invariant...
 

Index: server/as_object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_object.cpp,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- server/as_object.cpp        27 Sep 2007 17:23:17 -0000      1.66
+++ server/as_object.cpp        2 Oct 2007 12:17:46 -0000       1.67
@@ -735,13 +735,21 @@
                return ret;
        }
 
-       env.push(arg0);
+#ifndef NDEBUG
+       size_t origStackSize = env.stack_size();
+#endif
+
        env.push(arg1);
+       env.push(arg0);
 
-       ret = call_method(method, &env, this, 2, env.stack_size()-2);
+       ret = call_method(method, &env, this, 2, env.stack_size()-1);
 
        env.drop(2);
 
+#ifndef NDEBUG
+       assert(origStackSize == env.stack_size());
+#endif
+
        return ret;
 }
 

Index: server/asobj/MovieClipLoader.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/MovieClipLoader.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- server/asobj/MovieClipLoader.cpp    19 Sep 2007 14:20:50 -0000      1.31
+++ server/asobj/MovieClipLoader.cpp    2 Oct 2007 12:17:46 -0000       1.32
@@ -36,6 +36,7 @@
 #include "VM.h" // for the string table.
 #include "builtin_function.h"
 #include "Object.h" // for getObjectInterface
+#include "AsBroadcaster.h" // for initializing self as a broadcaster
 
 #include <typeinfo> 
 #include <string>
@@ -58,8 +59,10 @@
        o.init_member("unloadClip", new 
builtin_function(moviecliploader_unloadclip));
        o.init_member("getProgress", new 
builtin_function(moviecliploader_getprogress));
 
+#if 0 // done by AsBroadcaster
        o.init_member("addListener", new 
builtin_function(moviecliploader_addlistener));
        o.init_member("removeListener", new 
builtin_function(moviecliploader_removelistener));
+#endif
 
 #if 0
        // Load the default event handlers. These should really never
@@ -112,7 +115,7 @@
        struct mcl *getProgress(as_object *ao);
 
        /// MovieClip
-       bool loadClip(const std::string& url, sprite_instance& target);
+       bool loadClip(const std::string& url, sprite_instance& target, 
as_environment& env);
 
        void unloadClip(void *);
 
@@ -120,6 +123,7 @@
        /// @ {
        ///
 
+#if 0
        /// Add an object to the list of event listeners
        //
        /// This function will call add_ref() on the
@@ -128,14 +132,16 @@
        void addListener(boost::intrusive_ptr<as_object> listener);
 
        void removeListener(boost::intrusive_ptr<as_object> listener);
+#endif
 
        /// Invoke any listener for the specified event
-       void dispatchEvent(const std::string& eventName, fn_call& fn);
+       void dispatchEvent(const std::string& eventName, as_environment& env, 
const as_value& arg);
 
        /// @ }
 
 protected:
 
+#if 0
 #ifdef GNASH_USE_GC
        /// Mark MovieClipLoader-specific reachable resources and invoke
        /// the parent's class version (markAsObjectReachable)
@@ -145,12 +151,13 @@
        ///
        virtual void markReachableResources() const;
 #endif // GNASH_USE_GC
+#endif
 
 private:
 
-       typedef std::set< boost::intrusive_ptr<as_object> > Listeners;
+       //typedef std::set< boost::intrusive_ptr<as_object> > Listeners;
+       //Listeners _listeners;
 
-       Listeners _listeners;
        bool          _started;
        bool          _completed;
        std::string     _filespec;
@@ -165,6 +172,8 @@
 {
        _mcl.bytes_loaded = 0;
        _mcl.bytes_total = 0;  
+
+       AsBroadcaster::initialize(*this);
 }
 
 MovieClipLoader::~MovieClipLoader()
@@ -183,12 +192,11 @@
 
 
 bool
-MovieClipLoader::loadClip(const std::string& url_str, sprite_instance& target)
+MovieClipLoader::loadClip(const std::string& url_str, sprite_instance& target, 
as_environment& env)
 {
        // Prepare function call for events...
-       as_environment env;
-       env.push(as_value(&target));
-       fn_call events_call(this, &env, 1, 0);
+       //env.push(as_value(&target));
+       //fn_call events_call(this, &env, 1, 0);
 
        URL url(url_str.c_str(), get_base_url());
        
@@ -199,7 +207,7 @@
        // Call the callback since we've started loading the file
        // TODO: probably we should move this below, after 
        //       the loading thread actually started
-       dispatchEvent("onLoadStart", events_call);
+       dispatchEvent("onLoadStart", env, as_value(&target));
 
        bool ret = target.loadMovie(url);
        if ( ! ret ) 
@@ -219,7 +227,8 @@
        /// TODO: check if we need to place it before calling
        ///       this function though...
        ///
-       dispatchEvent("onLoadInit", events_call);
+       //dispatchEvent("onLoadInit", events_call);
+       dispatchEvent("onLoadInit", env, as_value(&target));
 
        struct mcl *mcl_data = getProgress(&target);
 
@@ -233,7 +242,8 @@
        // TODO: dispatchEvent("onLoadProgress", ...)
 
        log_unimpl (_("FIXME: MovieClipLoader calling onLoadComplete *before* 
movie has actually been fully loaded (cheating)"));
-       dispatchEvent("onLoadComplete", events_call);
+       //dispatchEvent("onLoadComplete", events_call);
+       dispatchEvent("onLoadComplete", env, as_value(&target));
 
        return true;
 }
@@ -244,80 +254,17 @@
   GNASH_REPORT_FUNCTION;
 }
 
-
-void
-MovieClipLoader::addListener(boost::intrusive_ptr<as_object> listener)
-{
-       assert(listener); // caller should check
-       _listeners.insert(listener);
-}
-
-
-void
-MovieClipLoader::removeListener(boost::intrusive_ptr<as_object> listener)
-{
-       assert(listener); // caller should check
-       Listeners::iterator it = _listeners.find(listener);
-       if ( it != _listeners.end() )
-       {
-               _listeners.erase(it);
-       }
-}
-
-  
 // Callbacks
 void
-MovieClipLoader::dispatchEvent(const std::string& event, fn_call& fn)
+MovieClipLoader::dispatchEvent(const std::string& event, as_environment& env, 
const as_value& arg)
 {
-       typedef Listeners::iterator iterator;
-
-#if GNASH_DEBUG
-       log_msg(_("Dispatching %s event to " SIZET_FMT " listeners"),
-               event.c_str(), _listeners.size());
-#endif
-
-       string_table& st = VM::get().getStringTable();
-       for (iterator it=_listeners.begin(), itEnd=_listeners.end();
-                       it != itEnd;
-                       ++it)
-       {
-               boost::intrusive_ptr<as_object> listener = *it;
-               as_value method;
-               if (!listener->get_member(st.find(event), &method) )
-               {
-#if GNASH_DEBUG
-log_msg(_("Listener %p doesn't have an %s event to listen for, skipped"),
-       (void*)listener, event.c_str());
-#endif
-                       // this listener doesn't care about this event
-                       // event
-                       continue;
-               }
-
-#if GNASH_DEBUG
-               log_msg(_("Testing call to listener's "
-                       " %s function"), event.c_str());
-#endif
+       string_table& st = _vm.getStringTable();
 
-               call_method(method, &fn.env(), fn.this_ptr.get(), fn.nargs, 
fn.offset());
-       }
-
-}
-
-#ifdef GNASH_USE_GC
-void
-MovieClipLoader::markReachableResources() const
-{
-       assert(isReachable());
+       as_value ev(event);
 
-       // mark listeners
-       for(Listeners::const_iterator i=_listeners.begin(), e=_listeners.end(); 
i!=e; ++i)
-       {
-               (*i)->setReachable();
-       }
-       markAsObjectReachable();
+       log_debug("dispatchEvent calling broadcastMessage with args %s and %s", 
ev.to_debug_string().c_str(), arg.to_debug_string().c_str());
+       callMethod(st.find("broadcastMessage"), env, ev, arg);
 }
-#endif // GNASH_USE_GC
 
 static as_value
 moviecliploader_loadclip(const fn_call& fn)
@@ -361,7 +308,7 @@
                str_url.c_str(), (void*)sprite);
 #endif
 
-       bool ret = ptr->loadClip(str_url, *sprite);
+       bool ret = ptr->loadClip(str_url, *sprite, fn.env());
 
        return as_value(ret);
 
@@ -406,43 +353,6 @@
   return as_value(mcl_obj.get()); // will store in a boost::intrusive_ptr
 }
 
-static as_value
-moviecliploader_addlistener(const fn_call& fn)
-{
-       boost::intrusive_ptr<MovieClipLoader> mcl = 
ensureType<MovieClipLoader>(fn.this_ptr);
-  
-       boost::intrusive_ptr<as_object> listener = fn.arg(0).to_object();
-       if ( ! listener )
-       {
-               IF_VERBOSE_ASCODING_ERRORS (
-               log_aserror(_("Listener given to MovieClipLoader.addListener() 
is not an object"));
-               )
-               return as_value();
-       }
-
-       mcl->addListener(listener);
-       return as_value();
-}
-
-static as_value
-moviecliploader_removelistener(const fn_call& fn)
-{
-       boost::intrusive_ptr<MovieClipLoader> mcl = 
ensureType<MovieClipLoader>(fn.this_ptr);
-  
-       boost::intrusive_ptr<as_object> listener = fn.arg(0).to_object();
-       if ( ! listener )
-       {
-               IF_VERBOSE_ASCODING_ERRORS (
-               log_aserror(_("Listener given to 
MovieClipLoader.removeListener() is not an object"));
-               )
-               return as_value();
-       }
-
-       mcl->removeListener(listener);
-       return as_value();
-}
-
-
 void
 moviecliploader_class_init(as_object& global)
 {

Index: testsuite/actionscript.all/MovieClipLoader.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/MovieClipLoader.as,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- testsuite/actionscript.all/MovieClipLoader.as       29 Sep 2007 16:22:58 
-0000      1.4
+++ testsuite/actionscript.all/MovieClipLoader.as       2 Oct 2007 12:17:47 
-0000       1.5
@@ -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: MovieClipLoader.as,v 1.4 2007/09/29 16:22:58 strk Exp $";
+rcsid="$Id: MovieClipLoader.as,v 1.5 2007/10/02 12:17:47 strk Exp $";
 
 #include "check.as"
 
@@ -36,6 +36,7 @@
 check_equals(typeOf(mcl.getProgress), 'function');
 check_equals(typeOf(mcl.loadClip), 'function');
 check_equals(typeOf(mcl.removeListener), 'function');
+check_equals(typeOf(mcl.broadcastMessage), 'function');
 check_equals(typeOf(mcl.unloadClip), 'function');
 check(mcl instanceOf MovieClipLoader);
 




reply via email to

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