gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/timers.cpp server/timers...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/timers.cpp server/timers...
Date: Mon, 10 Dec 2007 09:23:48 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/12/10 09:23:48

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

Log message:
        Evaluate interval object property on execution, not initialization.
        Fixes setinterval2.swf from swfdec testsuite.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5114&r2=1.5115
http://cvs.savannah.gnu.org/viewcvs/gnash/server/timers.cpp?cvsroot=gnash&r1=1.42&r2=1.43
http://cvs.savannah.gnu.org/viewcvs/gnash/server/timers.h?cvsroot=gnash&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/swfdec/PASSING?cvsroot=gnash&r1=1.73&r2=1.74

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5114
retrieving revision 1.5115
diff -u -b -r1.5114 -r1.5115
--- ChangeLog   10 Dec 2007 04:59:23 -0000      1.5114
+++ ChangeLog   10 Dec 2007 09:23:47 -0000      1.5115
@@ -1,5 +1,11 @@
 2007-12-10 Sandro Santilli <address@hidden>
 
+       * server/timers.{cpp,h}: evaluate object property name
+         at execution, not initialization.
+       * testsuite/swfdec/PASSING: setinterval2.swf passes.
+
+2007-12-10 Sandro Santilli <address@hidden>
+
        * server/timers.cpp (expired): add interval to start time
          when expired (rather then using current time); expire
          also when start+interval == now.

Index: server/timers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/timers.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- server/timers.cpp   10 Dec 2007 04:59:24 -0000      1.42
+++ server/timers.cpp   10 Dec 2007 09:23:48 -0000      1.43
@@ -19,7 +19,7 @@
 //
 //
 
-/* $Id: timers.cpp,v 1.42 2007/12/10 04:59:24 strk Exp $ */
+/* $Id: timers.cpp,v 1.43 2007/12/10 09:23:48 strk Exp $ */
 
 #include "timers.h"
 #include "as_function.h" // for class as_function
@@ -49,25 +49,36 @@
     //log_msg("%s: \n", __FUNCTION__);
   }
   
+  void
+  Timer::setInterval(as_function& method, unsigned long ms, 
boost::intrusive_ptr<as_object> this_ptr, 
+                 std::vector<as_value>& args)
+  {
+    _function = &method;
+    _interval = ms; // keep as milliseconds
+    //log_msg("_interval milliseconds: %llu", _interval);
+    _object = this_ptr;
+    _args = args;
+    start();
+  }
 
   void
   Timer::setInterval(as_function& method, unsigned long ms, 
boost::intrusive_ptr<as_object> this_ptr)
   {
     _function = &method;
-    _interval = ms; // keep milliseconds
-    //log_msg("_interval milliseconds: %lu", _interval);
+    _interval = ms; // keep as milliseconds
+    //log_msg("_interval milliseconds: %llu", _interval);
     _object = this_ptr;
     start();
   }
 
   void
-  Timer::setInterval(as_function& method, unsigned long ms, 
boost::intrusive_ptr<as_object> this_ptr, 
+  Timer::setInterval(boost::intrusive_ptr<as_object> this_ptr, const 
std::string& methodName, unsigned long ms, 
                  std::vector<as_value>& args)
   {
-    _function = &method;
+    _object = this_ptr;
+    _methodName = methodName;
     _interval = ms; // keep as milliseconds
     //log_msg("_interval milliseconds: %llu", _interval);
-    _object = this_ptr;
     _args = args;
     start();
   }
@@ -119,7 +130,29 @@
     //printf("FIXME: %s:\n", __FUNCTION__);
     //log_msg("INTERVAL ID is %d\n", getIntervalID());
 
-    as_value timer_method(_function.get());
+    as_value timer_method;
+
+    if ( _function.get() )
+    {
+        timer_method.set_as_function(_function.get());
+    }
+    else
+    {
+        as_value tmp;
+        if (!_object->get_member(VM::get().getStringTable().find(_methodName), 
&tmp) )
+        {
+            //log_debug("Can't find interval method %s on object %p (%s)", 
_methodName.c_str(), (void*)_object.get(), _object->get_text_value().c_str());
+            return;
+        }
+        as_function* f = tmp.to_as_function();
+        if ( ! f )
+        {
+            //log_debug("member %s of object %p (interval method) is not a 
function (%s)",
+            //   _methodName.c_str(), (void*)_object.get(), 
tmp.to_debug_string().c_str());
+            return;
+        }
+        timer_method.set_as_function(f);
+    }
 
     as_environment env;
 
@@ -157,8 +190,10 @@
 as_value
 timer_setinterval(const fn_call& fn)
 {
+       //std::stringstream ss; fn.dump_args(ss);
+       //log_debug("setInterval(%s)", ss.str().c_str());
+
        //log_msg("%s: args=%d", __FUNCTION__, fn.nargs);
-       // TODO: support setInterval(object, propertyname, intervaltime, 
arguments...) too
     
        if ( fn.nargs < 2 )
        {
@@ -185,37 +220,13 @@
                return as_value();
        }
 
+    std::string methodName;
+
        // Get interval function
        boost::intrusive_ptr<as_function> as_func = obj->to_function(); 
        if ( ! as_func )
        {
-               as_value method;
-               const std::string& method_name = fn.arg(1).to_string();
-               if 
(!obj->get_member(VM::get().getStringTable().find(method_name), &method) )
-               {
-                       IF_VERBOSE_ASCODING_ERRORS(
-                               std::stringstream ss; fn.dump_args(ss);
-                               log_aserror("Invalid call to setInterval(%s) "
-                                       "- can't find member %s of object %s",
-                                       ss.str().c_str(), method_name.c_str(),
-                                       fn.arg(0).to_debug_string().c_str());
-                       );
-                       return as_value();
-               }
-               as_func = method.to_as_function();
-               if ( ! as_func )
-               {
-                       IF_VERBOSE_ASCODING_ERRORS(
-                               std::stringstream ss; fn.dump_args(ss);
-                               log_aserror("Invalid call to setInterval(%s) "
-                                       "- %s.%s is not a function",
-                                       ss.str().c_str(),
-                                       fn.arg(0).to_debug_string().c_str(),
-                                       method_name.c_str());
-                       );
-                       return as_value();
-               }
-
+               methodName = fn.arg(1).to_string();
                timer_arg = 2;
        }
 
@@ -233,6 +244,7 @@
 
        // 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;
@@ -242,7 +254,16 @@
        }
 
        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);
+       }
+       else
+       {
+               timer->setInterval(obj, methodName, ms, args);
+       }
+    
     
        movie_root& root = VM::get().getRoot();
        int id = root.add_interval_timer(timer);

Index: server/timers.h
===================================================================
RCS file: /sources/gnash/gnash/server/timers.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- server/timers.h     9 Dec 2007 20:40:49 -0000       1.30
+++ server/timers.h     10 Dec 2007 09:23:48 -0000      1.31
@@ -110,6 +110,26 @@
       void setInterval(as_function& method, unsigned long ms, 
boost::intrusive_ptr<as_object> this_ptr, 
                      std::vector<as_value>& args);
 
+      /// Setup the Timer to call a late-evaluated object method, enabling it.
+      //
+      /// @param this_ptr
+      ///      The object to be used as 'this' pointer when calling the
+      ///      associated function. Will be stored in an intrusive_ptr.
+      ///      It is allowed to be NULL as long as fn_call is allowed
+      ///      a NULL as 'this_ptr' (we might want to change this).
+      ///
+      /// @param methodName
+      ///      The method name to call from execution operator.
+      ///
+      /// @param ms
+      ///      The number of milliseconds between expires.
+      ///
+      /// @param args
+      ///      The list of arguments to pass to the function being invoked.
+      ///
+      void setInterval(boost::intrusive_ptr<as_object> obj, const std::string& 
methodName, unsigned long ms, 
+                     std::vector<as_value>& args);
+
       /// Clear the timer, ready for reuse
       //
       /// When a Timer is cleared, the expired() function
@@ -177,9 +197,12 @@
       ///
       unsigned int _start;
 
-      /// The associated function, stored in an intrusive pointer
+      /// The associated function (if statically-bound) stored in an intrusive 
pointer
       boost::intrusive_ptr<as_function> _function;
 
+      /// The associated method name, stored in an intrusive pointer
+      std::string _methodName;
+
       /// Context for the function call. Will be used as 'this' pointer.
       boost::intrusive_ptr<as_object> _object;
 

Index: testsuite/swfdec/PASSING
===================================================================
RCS file: /sources/gnash/gnash/testsuite/swfdec/PASSING,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -b -r1.73 -r1.74
--- testsuite/swfdec/PASSING    10 Dec 2007 04:59:24 -0000      1.73
+++ testsuite/swfdec/PASSING    10 Dec 2007 09:23:48 -0000      1.74
@@ -496,6 +496,7 @@
 setinterval-arguments.swf:bf5653c905e58846b5a9ee8841c3bcb3
 setinterval-clear.swf:7897b1f201377d65dbffe1ae8182479a
 setinterval.swf:dbbfeaa905278739001776269e287887
+setinterval2.swf:f2a17dbddcd0a72a672fbb9a63e0ea5b
 settarget-5.swf:2fdaa96ec67a1041d36d552f91a41cd4
 settarget-6.swf:78786db5ba63f78996f63001501d46fe
 settarget-7.swf:9f0f1e71281e0adee53742a283654c11




reply via email to

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