gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/movie_root.cpp server/ti...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/movie_root.cpp server/ti...
Date: Tue, 11 Dec 2007 00:14:24 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/12/11 00:14:23

Modified files:
        .              : ChangeLog 
        server         : movie_root.cpp timers.cpp timers.h 
        server/asobj   : Global.cpp 
        testsuite/actionscript.all: Global.as 
        testsuite/swfdec: PASSING 
        utilities      : processor.cpp 

Log message:
        Implement setTimeout/clearTimeout, better support for fscommand:quit in
        gprocessor

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5123&r2=1.5124
http://cvs.savannah.gnu.org/viewcvs/gnash/server/movie_root.cpp?cvsroot=gnash&r1=1.134&r2=1.135
http://cvs.savannah.gnu.org/viewcvs/gnash/server/timers.cpp?cvsroot=gnash&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/gnash/server/timers.h?cvsroot=gnash&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Global.cpp?cvsroot=gnash&r1=1.79&r2=1.80
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Global.as?cvsroot=gnash&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/swfdec/PASSING?cvsroot=gnash&r1=1.75&r2=1.76
http://cvs.savannah.gnu.org/viewcvs/gnash/utilities/processor.cpp?cvsroot=gnash&r1=1.76&r2=1.77

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5123
retrieving revision 1.5124
diff -u -b -r1.5123 -r1.5124
--- ChangeLog   10 Dec 2007 23:17:18 -0000      1.5123
+++ ChangeLog   11 Dec 2007 00:14:22 -0000      1.5124
@@ -1,5 +1,16 @@
 2007-12-10 Sandro Santilli <address@hidden>
 
+       * utilities/processor.cpp: check for quit request right
+         after calling movie_root::setRootMovie, as that would
+         execute actions in first frame.
+       * server/timers.{cpp,h}, server/asobj/Global.cpp: implement
+         setTimeout/clearTimeout.
+       * testsuite/actionscript.all/Global.as: test existance of
+         setTiemout/clearTimeout.
+       * testsuite/swfdec/PASSING: setTimeout-related successes.
+
+2007-12-10 Sandro Santilli <address@hidden>
+
        * testsuite/actionscript.all/Makefile.am: fix abs_mediadir to contain
          quotes. Prior version failed building XML-*.swf files, dunno if this
          patch breaks POSIX compatibility.

Index: server/movie_root.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/movie_root.cpp,v
retrieving revision 1.134
retrieving revision 1.135
diff -u -b -r1.134 -r1.135
--- server/movie_root.cpp       10 Dec 2007 20:17:17 -0000      1.134
+++ server/movie_root.cpp       11 Dec 2007 00:14:23 -0000      1.135
@@ -1355,11 +1355,7 @@
                }
                else
                {
-                       if ( timer->expired() )
-                       {
-                               //cout << " EXPIRED, start time is now " << 
timer.getStart() << endl;
-                               (*timer)();
-                       }
+                       timer->executeIfExpired();
                }
 
                it = nextIterator;

Index: server/timers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/timers.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- server/timers.cpp   10 Dec 2007 09:23:48 -0000      1.43
+++ server/timers.cpp   11 Dec 2007 00:14:23 -0000      1.44
@@ -19,7 +19,7 @@
 //
 //
 
-/* $Id: timers.cpp,v 1.43 2007/12/10 09:23:48 strk Exp $ */
+/* $Id: timers.cpp,v 1.44 2007/12/11 00:14:23 strk Exp $ */
 
 #include "timers.h"
 #include "as_function.h" // for class as_function
@@ -40,7 +40,8 @@
   Timer::Timer() :
       _interval(0),
       _start(std::numeric_limits<unsigned long>::max()),
-      _object(0)
+      _object(0),
+      _runOnce(false)
   {
   }
   
@@ -51,35 +52,38 @@
 
   void
   Timer::setInterval(as_function& method, unsigned long ms, 
boost::intrusive_ptr<as_object> this_ptr, 
-                 std::vector<as_value>& args)
+                 std::vector<as_value>& args, bool runOnce)
   {
     _function = &method;
     _interval = ms; // keep as milliseconds
     //log_msg("_interval milliseconds: %llu", _interval);
     _object = this_ptr;
     _args = args;
+    _runOnce = runOnce;
     start();
   }
 
   void
-  Timer::setInterval(as_function& method, unsigned long ms, 
boost::intrusive_ptr<as_object> this_ptr)
+  Timer::setInterval(as_function& method, unsigned long ms, 
boost::intrusive_ptr<as_object> this_ptr, bool runOnce)
   {
     _function = &method;
     _interval = ms; // keep as milliseconds
     //log_msg("_interval milliseconds: %llu", _interval);
     _object = this_ptr;
+    _runOnce = runOnce;
     start();
   }
 
   void
   Timer::setInterval(boost::intrusive_ptr<as_object> this_ptr, const 
std::string& methodName, unsigned long ms, 
-                 std::vector<as_value>& args)
+                 std::vector<as_value>& args, bool runOnce)
   {
     _object = this_ptr;
     _methodName = methodName;
     _interval = ms; // keep as milliseconds
     //log_msg("_interval milliseconds: %llu", _interval);
     _args = args;
+    _runOnce = runOnce;
     start();
   }
 
@@ -98,8 +102,8 @@
   }
   
 
-bool
-Timer::expired()
+void
+Timer::executeIfExpired()
 {
        if ( _start != std::numeric_limits<unsigned long>::max() )
        {
@@ -109,11 +113,19 @@
                //cout << "Start is " << _start << " interval is " << _interval 
<< " now is " << now << endl;
                if (now >= _start + _interval)
                {
+                       execute();
+                       if ( _runOnce )
+                       {
+                               clearInterval();
+                       }
+                       else
+                       {
                        // TODO: set _start to save lost time in calling 
expired ?
                        _start += _interval; // reset the timer
                        //cout << " Expired, reset start to " << _start << endl;
                        //log_msg("Timer expired! \n");
-                       return true;
+                               //return true;
+                       }
                }
        }
        else
@@ -121,11 +133,11 @@
                log_msg("Timer not enabled!");
        }
 
-       return false;
+       //return false;
 }
 
 void
-Timer::operator() ()
+Timer::execute()
 {
     //printf("FIXME: %s:\n", __FUNCTION__);
     //log_msg("INTERVAL ID is %d\n", getIntervalID());
@@ -272,6 +284,91 @@
   
 // TODO: move to Global.cpp
 as_value
+timer_settimeout(const fn_call& fn)
+{
+       //std::stringstream ss; fn.dump_args(ss);
+       //log_debug("setTimeout(%s)", ss.str().c_str());
+
+       //log_msg("%s: args=%d", __FUNCTION__, fn.nargs);
+    
+       if ( fn.nargs < 2 )
+       {
+               IF_VERBOSE_ASCODING_ERRORS(
+                       std::stringstream ss; fn.dump_args(ss);
+                       log_aserror("Invalid call to setTimeout(%s) "
+                               "- need at least 2 arguments",
+                               ss.str().c_str());
+               );
+               return as_value();
+       }
+
+       unsigned timer_arg = 1;
+
+       boost::intrusive_ptr<as_object> obj = fn.arg(0).to_object();
+       if ( ! obj )
+       {
+               IF_VERBOSE_ASCODING_ERRORS(
+                       std::stringstream ss; fn.dump_args(ss);
+                       log_aserror("Invalid call to setInterval(%s) "
+                               "- first argument is not an object or function",
+                               ss.str().c_str());
+               );
+               return as_value();
+       }
+
+       std::string methodName;
+
+       // Get interval function
+       boost::intrusive_ptr<as_function> as_func = obj->to_function(); 
+       if ( ! as_func )
+       {
+               methodName = fn.arg(1).to_string();
+               timer_arg = 2;
+       }
+
+
+       if ( fn.nargs < timer_arg+1 )
+       {
+               IF_VERBOSE_ASCODING_ERRORS(
+                       std::stringstream ss; fn.dump_args(ss);
+                       log_aserror("Invalid call to setTimeout(%s) "
+                               "- missing timeout argument",
+                               ss.str().c_str());
+               );
+               return as_value();
+       }
+
+       // Get interval time
+       unsigned long ms = static_cast<unsigned 
long>(fn.arg(timer_arg).to_number());
+       // TODO: check validity of interval time number ?
+
+       // Parse arguments 
+       Timer::ArgsContainer args;
+       for (unsigned i=timer_arg+1; i<fn.nargs; ++i)
+       {
+               args.push_back(fn.arg(i));
+       }
+
+       std::auto_ptr<Timer> timer(new Timer);
+       if ( as_func )
+       {
+               // TODO: 'this_ptr' should be NULL/undefined in this case
+               timer->setInterval(*as_func, ms, fn.this_ptr, args, true);
+       }
+       else
+       {
+               timer->setInterval(obj, methodName, ms, args, true);
+       }
+    
+    
+       movie_root& root = VM::get().getRoot();
+
+       int id = root.add_interval_timer(timer);
+       return as_value(id);
+}
+  
+// TODO: move to Global.cpp
+as_value
 timer_clearinterval(const fn_call& fn)
 {
        //log_msg("%s: nargs = %d", __FUNCTION__, fn.nargs);

Index: server/timers.h
===================================================================
RCS file: /sources/gnash/gnash/server/timers.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- server/timers.h     10 Dec 2007 16:18:24 -0000      1.32
+++ server/timers.h     11 Dec 2007 00:14:23 -0000      1.33
@@ -87,7 +87,10 @@
       ///      It is allowed to be NULL as long as fn_call is allowed
       ///      a NULL as 'this_ptr' (we might want to change this).
       ///
-      void setInterval(as_function& method, unsigned long ms, 
boost::intrusive_ptr<as_object> this_ptr);
+      /// @param runOnce
+      ///      If true the interval will run only once. False if omitted.
+      ///
+      void setInterval(as_function& method, unsigned long ms, 
boost::intrusive_ptr<as_object> this_ptr, bool runOnce=false);
 
       /// Setup the Timer, enabling it.
       //
@@ -107,8 +110,11 @@
       /// @param args
       ///      The list of arguments to pass to the function being invoked.
       ///
+      /// @param runOnce
+      ///      If true the interval will run only once. False if omitted.
+      ///
       void setInterval(as_function& method, unsigned long ms, 
boost::intrusive_ptr<as_object> this_ptr, 
-                     std::vector<as_value>& args);
+                     std::vector<as_value>& args, bool runOnce=false);
 
       /// Setup the Timer to call a late-evaluated object method, enabling it.
       //
@@ -127,8 +133,11 @@
       /// @param args
       ///      The list of arguments to pass to the function being invoked.
       ///
+      /// @param runOnce
+      ///      If true the interval will run only once. False if omitted.
+      ///
       void setInterval(boost::intrusive_ptr<as_object> obj, const std::string& 
methodName, unsigned long ms, 
-                     std::vector<as_value>& args);
+                     std::vector<as_value>& args, bool runOnce=false);
 
       /// Clear the timer, ready for reuse
       //
@@ -139,11 +148,12 @@
       ///
       void clearInterval();
 
-      /// Return true if interval ticks are passed since last call to start()
+      /// Execute the associated callback if timer expired.
       //
-      /// Always returns false if the timer is cleared.
-      //
-      bool expired();
+      /// If single run is requested the timer is cleared after execution,
+      /// otherwise the timer is reset after that.
+      ///
+      void executeIfExpired();
 
       /// Return true if interval has been cleared.
       //
@@ -155,7 +165,11 @@
       }
 
       /// Execute associated function properly setting up context
-      void operator() ();
+      void execute();
+
+      /// Execute associated function properly setting up context
+      void operator() () { execute(); }
+
       
       /// Arguments list type
       typedef std::vector<as_value> ArgsContainer;
@@ -208,11 +222,14 @@
 
       /// List of arguments
       ArgsContainer _args;
+
+      /// True if the timer should execute only once (for setTimeout)
+      bool _runOnce;
 };
   
   as_value timer_setinterval(const fn_call& fn);
+  as_value timer_settimeout(const fn_call& fn);
   as_value timer_clearinterval(const fn_call& fn);
-  as_value timer_expire(const fn_call& fn);
   
 } // end of namespace gnash
 

Index: server/asobj/Global.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Global.cpp,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -b -r1.79 -r1.80
--- server/asobj/Global.cpp     3 Dec 2007 18:05:07 -0000       1.79
+++ server/asobj/Global.cpp     11 Dec 2007 00:14:23 -0000      1.80
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: Global.cpp,v 1.79 2007/12/03 18:05:07 strk Exp $ */
+/* $Id: Global.cpp,v 1.80 2007/12/11 00:14:23 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -431,6 +431,8 @@
        // Defined in timers.h
        init_member("setInterval", new builtin_function(timer_setinterval));
        init_member("clearInterval", new builtin_function(timer_clearinterval));
+       init_member("setTimeout", new builtin_function(timer_settimeout));
+       init_member("clearTimeout", new builtin_function(timer_clearinterval));
 
        ch->setGlobal(this);
 

Index: testsuite/actionscript.all/Global.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Global.as,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- testsuite/actionscript.all/Global.as        8 Nov 2007 23:59:41 -0000       
1.36
+++ testsuite/actionscript.all/Global.as        11 Dec 2007 00:14:23 -0000      
1.37
@@ -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: Global.as,v 1.36 2007/11/08 23:59:41 strk Exp $";
+rcsid="$Id: Global.as,v 1.37 2007/12/11 00:14:23 strk Exp $";
 
 #include "check.as"
 
@@ -124,6 +124,9 @@
 check_equals(typeof(setInterval), 'function');
 check_equals(typeof(clearInterval), 'function');
 
+check_equals(typeof(setTimeout), 'function');
+check_equals(typeof(clearTimeout), 'function');
+
 
 //------------------------------------------------------------
 // Test ASSetPropFlags
@@ -260,15 +263,15 @@
 //------------------------------------------------------------
 
 #if OUTPUT_VERSION == 5
-       check_totals(44); // SWF5
+       check_totals(46); // SWF5
 #else
 # if OUTPUT_VERSION == 6
-       check_totals(77); // SWF6
+       check_totals(79); // SWF6
 # else
 #  if OUTPUT_VERSION == 7
-       check_totals(59); // SWF7
+       check_totals(61); // SWF7
 #  else
-       check_totals(46); // SWF8+
+       check_totals(48); // SWF8+
 #  endif
 # endif
 #endif

Index: testsuite/swfdec/PASSING
===================================================================
RCS file: /sources/gnash/gnash/testsuite/swfdec/PASSING,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -b -r1.75 -r1.76
--- testsuite/swfdec/PASSING    10 Dec 2007 21:53:23 -0000      1.75
+++ testsuite/swfdec/PASSING    11 Dec 2007 00:14:23 -0000      1.76
@@ -261,6 +261,7 @@
 load-5.swf:e2efd27e8813c647072fe7bbe5fecff3
 loadmovie-case-5.swf:a7d492cb23eef08a115d7a667c9b5089
 loadmovie-case-6.swf:e5bc78b62bb2688bd99a57bfec7e4eb1
+loadmovie-case-7.swf:0ce485bdd81c872df4b7327c1d048936
 loadvars-5.swf:378a93e3fc7821a72f61332dcfa6cbf7
 local.swf:12135ef5103f1b0dcc428308511b9c07
 math-constants-5.swf:ca9d0fc66667d7c7863e699367176573
@@ -279,6 +280,7 @@
 movieclip-get-swf-version-8.swf:5228a59ad74ce8ba27e0fb8a593a2c8d
 movieclip-get-swf-version-8.swf:c79a3ef15927fe63fa9bc66cd6959e55
 movieclip-get-swf-version-load-5.swf:3d7dcf17068a176d72b14ca18b166c21
+movieclip-get-swf-version-load-5.swf:9dce6c61d27b304a590ac0206daee064
 movieclip-set-prototype-5.swf:99235a738d69d9c78fa2bc5d355c6dae
 movieclip-set-prototype-6.swf:bae79ccbb89bb7c11cd1961d2c473022
 movieclip-set-prototype-7.swf:f147fff166cc46cdcda77d5012faddb0
@@ -291,6 +293,8 @@
 moviecliploader-constructor-6.swf:e50f068ebde835d503c43ae1fcaf4371
 moviecliploader-getprogress-5.swf:0d58d1e3762e678c27f38309c34906ec
 moviecliploader-getprogress-6.swf:80231ce07d7197f269532a7d9f920c06
+moviecliploader-unknown-format-5.swf:b28db9ff343a9487fbb90adfc46725b9
+moviecliploader-unknown-format-6.swf:08cab100a05f91617b55f30492ff814d
 name.swf:88260c60778020b3c5610a8fa804b979
 name2.swf:6a0c27c17dd51d4f52276ab675324eff
 names.swf:04f10e23865b40240e7d295967f18ba9
@@ -517,6 +521,10 @@
 settarget2-tostring-5.swf:66b7402854ca261fc8102c916a3efe6d
 settarget2-tostring-7.swf:cfa9318ea413cc8ebf950902c952a3fd
 settarget2-tostring-8.swf:ca6f5fe29c73ef074a6ad39c0ecfa1d8
+settimeout-clear-self-5.swf:4b87d29d2b95ef3e19b0bd166a663824
+settimeout-clear-self-6.swf:c3af4774a839a83d71900e49ffbd472f
+settimeout-clear-self-7.swf:be3a0acb447f02e06fe2599c020c3aba
+settimeout-clear-self-8.swf:c27de1bb237678e6f9f06c3edb94f243
 setvariable-callback-6.swf:bc09506d6000aaf6f989f9d493272350
 setvariable-callback-7.swf:c9a0c81393da6900bf5281353db99b70
 setvariable-function-5.swf:d2f9d5e1a83833c452d2d752cd2bbf1c
@@ -606,6 +614,7 @@
 undefinedtrace-v6.swf:
 undefinedtrace-v7.swf:
 undefinedtrace-v8.swf:
+unloadmovie-simple-5.swf:3b897f539cb7eb764692def6fcc62853
 with-delete-5.swf:e4db8598315a7f70785e7e96af7f3c3f
 with-delete-6.swf:49de7093280168a4013377eaf7753fa0
 with-delete-7.swf:f7668d30827a77f415ec325f052125c6

Index: utilities/processor.cpp
===================================================================
RCS file: /sources/gnash/gnash/utilities/processor.cpp,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -b -r1.76 -r1.77
--- utilities/processor.cpp     9 Dec 2007 21:47:16 -0000       1.76
+++ utilities/processor.cpp     11 Dec 2007 00:14:23 -0000      1.77
@@ -16,7 +16,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: processor.cpp,v 1.76 2007/12/09 21:47:16 strk Exp $ */
+/* $Id: processor.cpp,v 1.77 2007/12/11 00:14:23 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -345,6 +345,11 @@
     std::auto_ptr<movie_instance> mi ( md->create_movie_instance() );
 
     m.setRootMovie( mi.release() );
+    if ( quitrequested )  // setRootMovie would execute actions in first frame
+    {
+        quitrequested = false;
+        return md;
+    }
     
     resetLastAdvanceTimer();
     int        kick_count = 0;




reply via email to

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