gnash-commit
[Top][All Lists]
Advanced

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

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


From: Sandro Santilli
Subject: [Gnash-commit] gnash server/timers.cpp ChangeLog
Date: Mon, 19 Mar 2007 14:41:28 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/03/19 14:41:28

Modified files:
        server         : timers.cpp 
        .              : ChangeLog 

Log message:
                * server/timers.cpp (timer_setinterval):
                  Accept call in the form setInterval(obj, methodname, timer);
                  warn about unsupported args (right-most arguments).

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/server/timers.cpp?cvsroot=gnash&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2625&r2=1.2626

Patches:
Index: server/timers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/timers.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- server/timers.cpp   9 Feb 2007 13:38:50 -0000       1.22
+++ server/timers.cpp   19 Mar 2007 14:41:27 -0000      1.23
@@ -18,7 +18,7 @@
 //
 //
 
-/* $Id: timers.cpp,v 1.22 2007/02/09 13:38:50 strk Exp $ */
+/* $Id: timers.cpp,v 1.23 2007/03/19 14:41:27 strk Exp $ */
 
 #include "timers.h"
 #include "as_function.h" // for class as_function
@@ -114,23 +114,89 @@
 timer_setinterval(const fn_call& fn)
 {
        //log_msg("%s: args=%d", __FUNCTION__, fn.nargs);
+       // TODO: support setInterval(object, propertyname, intervaltime, 
arguments...) too
+    
+       if ( fn.nargs < 2 )
+       {
+               IF_VERBOSE_ASCODING_ERRORS(
+                       std::stringstream ss; fn.dump_args(ss);
+                       log_aserror("Invalid call to setInterval(%s) "
+                               "- need at least 2 arguments",
+                               ss.str().c_str());
+               );
+               return;
+       }
+
+       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;
+       }
     
        // Get interval function
-       boost::intrusive_ptr<as_function> as_func = fn.arg(0).to_as_function();
+       boost::intrusive_ptr<as_function> as_func = obj->to_function(); 
        if ( ! as_func )
        {
+               as_value method;
+               std::string method_name = fn.arg(1).to_std_string();
+               if ( ! obj->get_member(method_name, &method) )
+               {
                IF_VERBOSE_ASCODING_ERRORS(
                        std::stringstream ss; fn.dump_args(ss);
                        log_aserror("Invalid call to setInterval(%s) "
-                               "- first argument is not a function",
-                               ss.str().c_str());
+                                       "- 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_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;
        }
 
+               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 setInterval(%s) "
+                               "- missing timeout argument",
+                               ss.str().c_str());
+               );
+               return;
+       }
 
        // Get interval time
-       int ms = int(fn.arg(1).to_number());
+       int ms = int(fn.arg(timer_arg).to_number());
+
+       // TODO: parse arguments !!
+       if ( fn.nargs > timer_arg+1 )
+       {
+               std::stringstream ss; fn.dump_args(ss);
+               log_error("FIXME: discarding arguments "
+                               "in setInterval(%s) call", ss.str().c_str());
+       }
 
        Timer timer;
        timer.setInterval(*as_func, ms, fn.this_ptr, fn.env);

Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2625
retrieving revision 1.2626
diff -u -b -r1.2625 -r1.2626
--- ChangeLog   19 Mar 2007 14:40:12 -0000      1.2625
+++ ChangeLog   19 Mar 2007 14:41:27 -0000      1.2626
@@ -1,3 +1,9 @@
+2007-03-19 Sandro Santilli <address@hidden>
+
+       * server/timers.cpp (timer_setinterval):
+         Accept call in the form setInterval(obj, methodname, timer);
+         warn about unsupported args (right-most arguments).
+
 2007-03-19 Ann Barcomb <address@hidden>
 
        * ActionScript has been removed from the Gnash manual.




reply via email to

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