gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/as_environment.cpp serve...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/as_environment.cpp serve...
Date: Mon, 16 Apr 2007 16:47:30 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/04/16 16:47:30

Modified files:
        .              : ChangeLog 
        server         : as_environment.cpp as_environment.h 
        server/vm      : ASHandlers.cpp 
        testsuite/actionscript.all: getvariable.as 

Log message:
                * server/as_environment.{cpp,h}: add a parse_path method to
                  return an actual object when the given parameter is actually
                  a path.
                * server/vm/ASHandlers.cpp (ActionCallFunction): set 'this'
                  pointer to the object containing the function if the function
                  name is a path. Fixes bug #18698.
                * testsuite/actionscript.all/getvariable.as: success in
                  callFunction(path.to_function), a few more tests of that kind.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2889&r2=1.2890
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.cpp?cvsroot=gnash&r1=1.67&r2=1.68
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_environment.h?cvsroot=gnash&r1=1.44&r2=1.45
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/ASHandlers.cpp?cvsroot=gnash&r1=1.94&r2=1.95
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/getvariable.as?cvsroot=gnash&r1=1.11&r2=1.12

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2889
retrieving revision 1.2890
diff -u -b -r1.2889 -r1.2890
--- ChangeLog   16 Apr 2007 13:02:49 -0000      1.2889
+++ ChangeLog   16 Apr 2007 16:47:29 -0000      1.2890
@@ -1,5 +1,16 @@
 2007-04-16 Sandro Santilli <address@hidden>
 
+       * server/as_environment.{cpp,h}: add a parse_path method to
+         return an actual object when the given parameter is actually
+         a path.
+       * server/vm/ASHandlers.cpp (ActionCallFunction): set 'this'
+         pointer to the object containing the function if the function
+         name is a path. Fixes bug #18698.
+       * testsuite/actionscript.all/getvariable.as: success in
+         callFunction(path.to_function), a few more tests of that kind.
+
+2007-04-16 Sandro Santilli <address@hidden>
+
        * testsuite/actionscript.all/getvariable.as: check 'this' pointer when
          calling a function trough a path.
        * testsuite/server/Makefile.am: add libgnashamf.la to GNASH libs.

Index: server/as_environment.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.cpp,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- server/as_environment.cpp   11 Apr 2007 05:04:14 -0000      1.67
+++ server/as_environment.cpp   16 Apr 2007 16:47:29 -0000      1.68
@@ -16,7 +16,7 @@
 
 //
 
-/* $Id: as_environment.cpp,v 1.67 2007/04/11 05:04:14 zoulunkai Exp $ */
+/* $Id: as_environment.cpp,v 1.68 2007/04/16 16:47:29 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -408,6 +408,22 @@
     return true;
 }
 
+bool
+as_environment::parse_path(const std::string& var_path,
+               as_object** target, as_value& val)
+{
+       string path;
+       string var;
+       bool is_slash_based;
+       if( ! parse_path(var_path, path, var, &is_slash_based) ) return false;
+        as_object* target_ptr = is_slash_based ? find_object_slashsyntax(path) 
: find_object_dotsyntax(path); 
+       if ( ! target_ptr ) return false;
+
+       target_ptr->get_member(var, &val);
+       *target = target_ptr;
+       return true;
+}
+
 character*
 as_environment::find_target(const as_value& val) const
 {

Index: server/as_environment.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_environment.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- server/as_environment.h     10 Apr 2007 17:41:42 -0000      1.44
+++ server/as_environment.h     16 Apr 2007 16:47:29 -0000      1.45
@@ -14,7 +14,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: as_environment.h,v 1.44 2007/04/10 17:41:42 strk Exp $ */
+/* $Id: as_environment.h,v 1.45 2007/04/16 16:47:29 strk Exp $ */
 
 #ifndef GNASH_AS_ENVIRONMENT_H
 #define GNASH_AS_ENVIRONMENT_H
@@ -415,6 +415,28 @@
        static bool parse_path(const std::string& var_path, std::string& path,
                std::string& var, bool* is_slash_based=NULL);
 
+       /// \brief
+       /// Try to parse a string as a variable path
+       //
+       /// Variable paths come in the form:
+       ///
+       ///     /path/to/some/sprite/:varname
+       ///
+       /// (or same thing, without the last '/')
+       ///
+       /// or
+       ///     path.to.some.var
+       ///
+       /// If there's no dot nor comma, or if the 'path' part
+       /// does not resolve to an object, this function returns false.
+       /// Otherwise, true is returned and 'target' and 'val'
+       /// parameters are appropriaterly set.
+       ///
+       /// Note that if the parser variable name doesn't exist in the found
+       /// target, the 'val' will be undefined, but no other way to tell 
whether
+       /// the variable existed or not from the caller...
+       ///
+       bool parse_path(const std::string& var_path, as_object** target, 
as_value& val);
 
        /// The variables container (case-insensitive)
        typedef std::map<std::string, as_value, StringNoCaseLessThen> Variables;

Index: server/vm/ASHandlers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/vm/ASHandlers.cpp,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -b -r1.94 -r1.95
--- server/vm/ASHandlers.cpp    16 Apr 2007 11:19:48 -0000      1.94
+++ server/vm/ASHandlers.cpp    16 Apr 2007 16:47:30 -0000      1.95
@@ -14,7 +14,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: ASHandlers.cpp,v 1.94 2007/04/16 11:19:48 strk Exp $ */
+/* $Id: ASHandlers.cpp,v 1.95 2007/04/16 16:47:30 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -2166,7 +2166,16 @@
        //env.dump_stack();
 
        // Let's consider it a as a string and lookup the function.
-       as_value function = thread.getVariable(env.top(0).to_string(&env));
+        const std::string& funcname = env.top(0).to_string(&env);
+
+        as_value function;
+
+        as_object* this_ptr = thread.getThisPointer();
+        if ( ! env.parse_path(funcname, &this_ptr, function) )
+        {
+                function = thread.getVariable(funcname);
+        }
+
        if ( ! function.is_object() ) 
        {
                log_aserror("ActionCallFunction: %s is not an object", 
env.top(0).to_string(&env).c_str());
@@ -2200,7 +2209,7 @@
         debugger.callStackPush(function_name);
        debugger.matchBreakPoint(function_name, true);
 #endif
-       as_value result = call_method(function, &env, thread.getThisPointer(),
+       as_value result = call_method(function, &env, this_ptr,
                                  nargs, env.get_top_index() - 2);
 
        //log_msg("Function's result: %s", result.to_string(&env));

Index: testsuite/actionscript.all/getvariable.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/getvariable.as,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- testsuite/actionscript.all/getvariable.as   16 Apr 2007 13:02:49 -0000      
1.11
+++ testsuite/actionscript.all/getvariable.as   16 Apr 2007 16:47:30 -0000      
1.12
@@ -19,7 +19,7 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: getvariable.as,v 1.11 2007/04/16 13:02:49 strk Exp $";
+rcsid="$Id: getvariable.as,v 1.12 2007/04/16 16:47:30 strk Exp $";
 
 #include "check.as"
 
@@ -333,6 +333,8 @@
 
 //---------------------------------------------------------------------
 // Check scope of function called trough a path
+// nothing to do with GetVariable, but I didnt' feel like adding another
+// file for testing this.. it's still related to tags and variable names
 //---------------------------------------------------------------------
 
 num = 7;
@@ -347,8 +349,44 @@
        callfunction
         setvariable
 };
-xcheck_equals(checkpoint, 5);
+check_equals(checkpoint, 5);
 
+o2 = new Object;
+o2.m = new Object;
+o2.m.func = func;
+o2.num = 3;
+o2.m.num = 4;
+with (o2.m) {
+asm {
+        push 'checkpoint'
+       push 0
+       push 'func'
+       callfunction
+        setvariable
+};
+};
+check_equals(checkpoint, 4);
+
+_global.func = func;
+_global.num = 9;
+asm {
+        push 'checkpoint'
+       push 0
+       push 'func'
+       callfunction
+        setvariable
+};
+check_equals(checkpoint, 7);
+
+this["o2.m.func"] = function() { return 19; };
+asm {
+        push 'checkpoint'
+       push 0
+       push 'o2.m.func'
+       callfunction
+        setvariable
+};
+check_equals(checkpoint, 4);
 
 //-----------------------------------------------------------------------
 // TODO: try use of 'with' stack




reply via email to

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