gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog extensions/dejagnu/dejagnu.cpp ...


From: Bastiaan Jacques
Subject: [Gnash-commit] gnash ChangeLog extensions/dejagnu/dejagnu.cpp ...
Date: Thu, 22 Mar 2007 22:37:46 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Bastiaan Jacques <bjacques>     07/03/22 22:37:46

Modified files:
        .              : ChangeLog 
        extensions/dejagnu: dejagnu.cpp 
        extensions/fileio: fileio.cpp 
        extensions/mysql: mysql_db.cpp 
        server         : as_function.cpp sprite_instance.cpp 
                         swf_function.cpp textformat.cpp timers.cpp 
        server/asobj   : Global.cpp LoadVars.cpp LocalConnection.cpp 
                         MovieClipLoader.cpp Object.cpp Sound.cpp 
                         xml.cpp xmlsocket.cpp 
        server/vm      : fn_call.h 

Log message:
                * server/vm/fn_call.h: Make fn_call more robust: rename
                first_arg_bottom_index to _stack_offset, which I think is more
                descriptive. Make _stack_offset and _env private properties; add
                accessors for them. Make nargs a const property. Add doxygen
                comments for all members.
                * all over the place: Adjust all users of fn_call members.
                Make sure all callers use the new accessors and that no caller
                tries to set now-const properties.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2676&r2=1.2677
http://cvs.savannah.gnu.org/viewcvs/gnash/extensions/dejagnu/dejagnu.cpp?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/extensions/fileio/fileio.cpp?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/extensions/mysql/mysql_db.cpp?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_function.cpp?cvsroot=gnash&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/gnash/server/sprite_instance.cpp?cvsroot=gnash&r1=1.200&r2=1.201
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf_function.cpp?cvsroot=gnash&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/gnash/server/textformat.cpp?cvsroot=gnash&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gnash/server/timers.cpp?cvsroot=gnash&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Global.cpp?cvsroot=gnash&r1=1.54&r2=1.55
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/LoadVars.cpp?cvsroot=gnash&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/LocalConnection.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/MovieClipLoader.cpp?cvsroot=gnash&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Object.cpp?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Sound.cpp?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xml.cpp?cvsroot=gnash&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/xmlsocket.cpp?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/fn_call.h?cvsroot=gnash&r1=1.4&r2=1.5

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2676
retrieving revision 1.2677
diff -u -b -r1.2676 -r1.2677
--- ChangeLog   22 Mar 2007 17:46:02 -0000      1.2676
+++ ChangeLog   22 Mar 2007 22:37:45 -0000      1.2677
@@ -16,6 +16,14 @@
        server/character{.cpp, .h}, server/character_instance.cpp:
        Use the new init_property() for read-only properties. Don't
        check if read-only properties are being set in getters.
+       * server/vm/fn_call.h: Make fn_call more robust: rename
+       first_arg_bottom_index to _stack_offset, which I think is more
+       descriptive. Make _stack_offset and _env private properties; add
+       accessors for them. Make nargs a const property. Add doxygen
+       comments for all members.
+       * all over the place: Adjust all users of fn_call members.
+       Make sure all callers use the new accessors and that no caller
+       tries to set now-const properties.
 
 2007-03-22 Sandro Santilli <address@hidden>
 

Index: extensions/dejagnu/dejagnu.cpp
===================================================================
RCS file: /sources/gnash/gnash/extensions/dejagnu/dejagnu.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- extensions/dejagnu/dejagnu.cpp      19 Mar 2007 17:11:14 -0000      1.6
+++ extensions/dejagnu/dejagnu.cpp      22 Mar 2007 22:37:45 -0000      1.7
@@ -116,7 +116,7 @@
     assert(ptr);
     
     if (fn.nargs > 0) {
-       const char *text = 
fn.env->bottom(fn.first_arg_bottom_index).to_string();
+       const char *text = fn.arg(0).to_string();
        return as_value(ptr->obj.pass(text));
     }
 }
@@ -129,7 +129,7 @@
     assert(ptr);
     
     if (fn.nargs > 0) {
-       const char *text = 
fn.env->bottom(fn.first_arg_bottom_index).to_string();
+       const char *text = fn.arg(0).to_string();
        return as_value(ptr->obj.fail(text));
     }
 }

Index: extensions/fileio/fileio.cpp
===================================================================
RCS file: /sources/gnash/gnash/extensions/fileio/fileio.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- extensions/fileio/fileio.cpp        19 Mar 2007 17:11:14 -0000      1.9
+++ extensions/fileio/fileio.cpp        22 Mar 2007 22:37:45 -0000      1.10
@@ -321,8 +321,8 @@
     assert(ptr);
     
     if (fn.nargs > 0) {
-       string filespec = fn.env->bottom(fn.first_arg_bottom_index).to_string();
-       string mode = fn.env->bottom(fn.first_arg_bottom_index-1).to_string();
+       string filespec = fn.arg(0).to_string();
+       string mode = fn.arg(1).to_string();
        return as_value(ptr->fopen(filespec, mode));
     }
 }
@@ -405,7 +405,7 @@
 //    GNASH_REPORT_FUNCTION;
     Fileio *ptr = (Fileio*)fn.this_ptr;
     assert(ptr);
-    string str = fn.env->bottom(fn.first_arg_bottom_index).to_string();
+    string str = fn.arg(0).to_string();
     return as_value(ptr->fputs(str));
 }
 
@@ -415,7 +415,7 @@
 //    GNASH_REPORT_FUNCTION;
     Fileio *ptr = (Fileio*)fn.this_ptr;
     assert(ptr);    
-    int c = (int) fn.env->bottom(fn.first_arg_bottom_index).to_number();
+    int c = (int) fn.arg(0).to_number();
     return as_value(ptr->fputc(c));
 }
 
@@ -425,7 +425,7 @@
     //   GNASH_REPORT_FUNCTION;
     Fileio *ptr = (Fileio*)fn.this_ptr;
     assert(ptr);    
-    string str = fn.env->bottom(fn.first_arg_bottom_index).to_string();
+    string str = fn.arg(0).to_string();
     return as_value(ptr->fputs(str));
 }
 
@@ -434,7 +434,7 @@
 fileio_puts(const fn_call& fn)
 {
 //    GNASH_REPORT_FUNCTION;
-    string str = fn.env->bottom(fn.first_arg_bottom_index).to_string();
+    string str = fn.arg(0).to_string();
     return as_value(::puts(str.c_str()));
 }
 
@@ -444,7 +444,7 @@
 //    GNASH_REPORT_FUNCTION;
     Fileio *ptr = (Fileio*)fn.this_ptr;
     assert(ptr);    
-    string x = fn.env->bottom(fn.first_arg_bottom_index).to_string();
+    string x = fn.arg(0).to_string();
     return as_value(::putchar(x[0]));
 }
 
@@ -463,7 +463,7 @@
 //    GNASH_REPORT_FUNCTION;
     Fileio *ptr = (Fileio*)fn.this_ptr;
     assert(ptr);    
-    long c = (long) fn.env->bottom(fn.first_arg_bottom_index).to_number();
+    long c = (long) fn.arg(0).to_number();
     return as_value(ptr->fseek(c));
 }
 
@@ -483,7 +483,7 @@
 //    GNASH_REPORT_FUNCTION;
     Fileio *ptr = (Fileio*)fn.this_ptr;
     assert(ptr);
-    string str = fn.env->bottom(fn.first_arg_bottom_index).to_string();
+    string str = fn.arg(0).to_string();
     return as_value(ptr->unlink(str));
 }
 
@@ -497,7 +497,7 @@
 
     Fileio *ptr = (Fileio*)fn.this_ptr;
     assert(ptr);    
-    string str = fn.env->bottom(fn.first_arg_bottom_index).to_string();
+    string str = fn.arg(0).to_string();
     ptr->scandir(str, fn.result);
 }
 

Index: extensions/mysql/mysql_db.cpp
===================================================================
RCS file: /sources/gnash/gnash/extensions/mysql/mysql_db.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- extensions/mysql/mysql_db.cpp       19 Mar 2007 17:11:14 -0000      1.6
+++ extensions/mysql/mysql_db.cpp       22 Mar 2007 22:37:45 -0000      1.7
@@ -302,10 +302,10 @@
     assert(ptr);
 
     if (fn.nargs == 4) {
-       const char *host = 
fn.env->bottom(fn.first_arg_bottom_index).to_string();
-       const char *db = 
fn.env->bottom(fn.first_arg_bottom_index-1).to_string();
-       const char *user = 
fn.env->bottom(fn.first_arg_bottom_index-2).to_string();
-       const char *passwd = 
fn.env->bottom(fn.first_arg_bottom_index-3).to_string();   
+       const char *host = fn.arg(0).to_string();
+       const char *db = fn.arg(1).to_string();
+       const char *user = fn.arg(2).to_string();
+       const char *passwd = fn.arg(3).to_string();     
        return as_value(ptr->obj.connect(host, db, user, passwd));
     } else {
        return as_value(false);
@@ -321,8 +321,8 @@
     assert(ptr);
 
     if (fn.nargs > 0) {
-       const char *sql = fn.env->bottom(fn.first_arg_bottom_index).to_string();
-       as_array_object *arr = (as_array_object 
*)fn.env->bottom(fn.first_arg_bottom_index-1).to_object();
+       const char *sql = fn.arg(0).to_string();
+       as_array_object *arr = (as_array_object *)fn.arg(1).to_object();
 //     std::vector< std::vector<const char *> >
        MySQL::query_t qresult;
 #if 0
@@ -393,7 +393,7 @@
 //    GNASH_REPORT_FUNCTION;
     mysql_as_object *ptr = (mysql_as_object*)fn.this_ptr;
     if (fn.nargs > 0) {
-       const char *sql = fn.env->bottom(fn.first_arg_bottom_index).to_string();
+       const char *sql = fn.arg(0).to_string();
        assert(ptr);
        return as_value(ptr->obj.guery(sql));
     }

Index: server/as_function.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_function.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- server/as_function.cpp      21 Mar 2007 14:37:20 -0000      1.26
+++ server/as_function.cpp      22 Mar 2007 22:37:45 -0000      1.27
@@ -187,10 +187,9 @@
        // Get function body 
        boost::intrusive_ptr<as_function> function_obj = 
ensureType<as_function>(fn.this_ptr);
 
-       // Copy new function call from old one, we'll modify 
-       // the copy only if needed
-       fn_call new_fn_call(fn);
-       new_fn_call.nargs=0;
+       unsigned int nargs = fn.nargs;
+       boost::intrusive_ptr<as_object> this_ptr = fn.this_ptr;
+       int offset = fn.offset();
 
        if ( ! fn.nargs )
        {
@@ -201,11 +200,13 @@
        else
        {
                // Get the object to use as 'this' reference
-               boost::intrusive_ptr<as_object> this_ptr = 
fn.arg(0).to_object();
-               if ( this_ptr ) new_fn_call.this_ptr = this_ptr;
+               this_ptr = fn.arg(0).to_object();
+               if (!this_ptr )
+               {
                // ... or recycle this function's call 'this' pointer
                // (most likely the Function instance)
-               else new_fn_call.this_ptr = fn.this_ptr;
+                       this_ptr = fn.this_ptr;
+               }
 
                if ( fn.nargs > 1 )
                // we have an 'arguments' array
@@ -256,22 +257,24 @@
                        for (unsigned int i=nelems; i; i--)
                        {
                                value=arg_array->at(i-1);
-                               fn.env->push_val(value);
+                               fn.env().push_val(value);
                                pushed++;
                        }
 
-                       
new_fn_call.first_arg_bottom_index=fn.env->get_top_index();
-                       new_fn_call.nargs=nelems;
+                       offset = fn.env().get_top_index();
+                       nargs=nelems;
                }
        }
 
        call_it:
 
+       fn_call new_fn_call(this_ptr, &fn.env(), nargs, offset);
+
        // Call the function 
        as_value rv = function_obj->call(new_fn_call);
 
        // Drop additional values we pushed on the stack 
-       fn.env->drop(pushed);
+       fn.env().drop(pushed);
 
         return rv;
 }
@@ -285,26 +288,29 @@
 
        // Copy new function call from old one, we'll modify 
        // the copy only if needed
-       fn_call new_fn_call(fn);
+
+       boost::intrusive_ptr<as_object> this_ptr = fn.this_ptr;
+       unsigned int nargs = fn.nargs;
+       int index = fn.offset();
 
        if ( ! fn.nargs )
        {
                 dbglogfile << "Function.call() with no args" << endl;
-               new_fn_call.nargs=0;
        }
        else
        {
                // Get the object to use as 'this' reference
-               boost::intrusive_ptr<as_object> this_ptr = 
fn.arg(0).to_object();
-               new_fn_call.this_ptr = this_ptr;
-               new_fn_call.nargs--;
-               new_fn_call.first_arg_bottom_index--;
+               this_ptr = fn.arg(0).to_object();
+               nargs--;
+               index--;
        }
 
+       fn_call new_fn_call(this_ptr, &fn.env(), nargs, index);
+
        // Call the function 
        return (*function_obj)(new_fn_call);
 
-       //log_msg("at function_call exit, stack: \n"); fn.env->dump_stack();
+       //log_msg("at function_call exit, stack: \n"); fn.env().dump_stack();
 
        //log_msg("%s: tocheck \n", __FUNCTION__);
 }

Index: server/sprite_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/sprite_instance.cpp,v
retrieving revision 1.200
retrieving revision 1.201
diff -u -b -r1.200 -r1.201
--- server/sprite_instance.cpp  22 Mar 2007 16:56:36 -0000      1.200
+++ server/sprite_instance.cpp  22 Mar 2007 22:37:45 -0000      1.201
@@ -638,7 +638,7 @@
                case 1: // target
                {
                        as_value& tgt_val = fn.arg(0);
-                       character* target = fn.env->find_target(tgt_val);
+                       character* target = fn.env().find_target(tgt_val);
                        if ( ! target )
                        {
                                IF_VERBOSE_ASCODING_ERRORS(
@@ -1117,7 +1117,7 @@
        }
        else // setter
        {
-               ptr->set_name(fn.arg(0).to_string(fn.env));
+               ptr->set_name(fn.arg(0).to_string(&fn.env()));
                //IF_VERBOSE_ASCODING_ERRORS(
                //log_aserror("Attempt to set read-only property '_name'");
                //);

Index: server/swf_function.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf_function.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- server/swf_function.cpp     21 Mar 2007 14:37:20 -0000      1.27
+++ server/swf_function.cpp     22 Mar 2007 22:37:45 -0000      1.28
@@ -171,12 +171,12 @@
        as_environment* our_env = m_env;
        if (our_env == NULL)
        {
-               our_env = fn.env;
+               our_env = &fn.env();
        }
        assert(our_env);
 
 #if 0
-       log_msg("swf_function() stack:\n"); fn.env->dump_stack();
+       log_msg("swf_function() stack:\n"); fn.env().dump_stack();
        log_msg("  first_arg_bottom_index: %d\n", fn.first_arg_bottom_index);
 #endif
 

Index: server/textformat.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/textformat.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- server/textformat.cpp       20 Mar 2007 15:01:20 -0000      1.19
+++ server/textformat.cpp       22 Mar 2007 22:37:45 -0000      1.20
@@ -127,7 +127,7 @@
   //
   // TODO we should handle setTextFormat as a method on TextField,
   // instead of doing this.
-  fn.env->set_variable("setTextFormat", new 
builtin_function(textformat_setformat));
+  fn.env().set_variable("setTextFormat", new 
builtin_function(textformat_setformat));
   
   return as_value(text_obj);
 }

Index: server/timers.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/timers.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- server/timers.cpp   20 Mar 2007 15:01:20 -0000      1.25
+++ server/timers.cpp   22 Mar 2007 22:37:45 -0000      1.26
@@ -18,7 +18,7 @@
 //
 //
 
-/* $Id: timers.cpp,v 1.25 2007/03/20 15:01:20 strk Exp $ */
+/* $Id: timers.cpp,v 1.26 2007/03/22 22:37:45 bjacques Exp $ */
 
 #include "timers.h"
 #include "as_function.h" // for class as_function
@@ -199,7 +199,7 @@
        }
 
        Timer timer;
-       timer.setInterval(*as_func, ms, fn.this_ptr, fn.env);
+       timer.setInterval(*as_func, ms, fn.this_ptr, &fn.env());
     
        movie_root& root = VM::get().getRoot();
        int id = root.add_interval_timer(timer);

Index: server/asobj/Global.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Global.cpp,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -b -r1.54 -r1.55
--- server/asobj/Global.cpp     22 Mar 2007 08:45:52 -0000      1.54
+++ server/asobj/Global.cpp     22 Mar 2007 22:37:45 -0000      1.55
@@ -18,7 +18,7 @@
 
 // Implementation of the Global ActionScript Object
 
-/* $Id: Global.cpp,v 1.54 2007/03/22 08:45:52 strk Exp $ */
+/* $Id: Global.cpp,v 1.55 2007/03/22 22:37:45 bjacques Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -114,7 +114,7 @@
 {
     ASSERT_FN_ARGS_IS_1
 
-    return as_value( static_cast<bool>(isnan(fn.arg(0).to_number(fn.env)) ));
+    return as_value( static_cast<bool>(isnan(fn.arg(0).to_number(&fn.env())) 
));
 }
 
 static as_value
@@ -122,7 +122,7 @@
 {
     ASSERT_FN_ARGS_IS_1
 
-    return as_value( isfinite(fn.arg(0).to_number(fn.env)) );
+    return as_value( isfinite(fn.arg(0).to_number(&fn.env())) );
 }
 
 /// \brief Encode a string to URL-encoded format
@@ -186,8 +186,7 @@
 static as_value
 as_global_parseint(const fn_call& fn)
 {
-       as_environment* env = fn.env;
-
+    as_environment* env = &fn.env();
     // assert(fn.nargs == 2 || fn.nargs == 1);
     if (fn.nargs < 1) {
        IF_VERBOSE_ASCODING_ERRORS(
@@ -297,8 +296,9 @@
 static as_value
 as_global_assetpropflags(const fn_call& fn)
 {
-    int version = fn.env->get_version();
-    as_environment* env = fn.env;
+    as_environment* env = &fn.env();
+    int version = env->get_version();
+    
 
     //log_msg("ASSetPropFlags called with %d args", fn.nargs);
 

Index: server/asobj/LoadVars.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/LoadVars.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- server/asobj/LoadVars.cpp   20 Mar 2007 15:01:20 -0000      1.17
+++ server/asobj/LoadVars.cpp   22 Mar 2007 22:37:45 -0000      1.18
@@ -616,7 +616,7 @@
 static as_value
 loadvars_ctor(const fn_call& fn)
 {
-       boost::intrusive_ptr<as_object> obj = new LoadVars(fn.env);
+       boost::intrusive_ptr<as_object> obj = new LoadVars(&fn.env());
        
        return as_value(obj.get()); // will keep alive
 }

Index: server/asobj/LocalConnection.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/LocalConnection.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/asobj/LocalConnection.cpp    20 Mar 2007 17:58:39 -0000      1.11
+++ server/asobj/LocalConnection.cpp    22 Mar 2007 22:37:45 -0000      1.12
@@ -139,7 +139,7 @@
     boost::intrusive_ptr<localconnection_as_object> ptr = 
ensureType<localconnection_as_object>(fn.this_ptr);
     
     if (fn.nargs != 0) {
-        ret = 
ptr->obj.connect(fn.env->bottom(fn.first_arg_bottom_index).to_string());
+        ret = ptr->obj.connect(fn.arg(0).to_string());
     } else {
         log_msg("ERROR: No connection name specified to 
LocalConnection.connect()!\n");
         ret = ptr->obj.connect("localhost"); // FIXME: This should probably

Index: server/asobj/MovieClipLoader.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/MovieClipLoader.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- server/asobj/MovieClipLoader.cpp    20 Mar 2007 15:01:20 -0000      1.22
+++ server/asobj/MovieClipLoader.cpp    22 Mar 2007 22:37:45 -0000      1.23
@@ -287,7 +287,7 @@
                        " %s function", event.c_str());
 #endif
 
-               call_method(method, fn.env, fn.this_ptr.get(), fn.nargs, 
fn.first_arg_bottom_index);
+               call_method(method, &fn.env(), fn.this_ptr.get(), fn.nargs, 
fn.offset());
        }
 
 }
@@ -315,7 +315,7 @@
 #endif
        std::string str_url = url_arg.to_string(); 
 
-       character* target = fn.env->find_target(fn.arg(1));
+       character* target = fn.env().find_target(fn.arg(1));
        if ( ! target )
        {
                log_error("Could not find target %s", fn.arg(1).to_string());

Index: server/asobj/Object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Object.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- server/asobj/Object.cpp     20 Mar 2007 15:01:20 -0000      1.20
+++ server/asobj/Object.cpp     22 Mar 2007 22:37:46 -0000      1.21
@@ -18,7 +18,7 @@
 //
 //
 
-/* $Id: Object.cpp,v 1.20 2007/03/20 15:01:20 strk Exp $ */
+/* $Id: Object.cpp,v 1.21 2007/03/22 22:37:46 bjacques Exp $ */
 
 // Implementation of ActionScript Object class.
 
@@ -270,7 +270,7 @@
 
        // TODO: check to *which* definition should we ask the export
        //       this code uses the *relative* root of current environment's 
target
-       movie_definition* def = 
fn.env->get_target()->get_root_movie()->get_movie_definition();
+       movie_definition* def = 
fn.env().get_target()->get_root_movie()->get_movie_definition();
        boost::intrusive_ptr<resource> exp_res = 
def->get_exported_resource(symbolid.c_str());
        if ( ! exp_res )
        {

Index: server/asobj/Sound.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Sound.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/asobj/Sound.cpp      20 Mar 2007 15:01:20 -0000      1.10
+++ server/asobj/Sound.cpp      22 Mar 2007 22:37:46 -0000      1.11
@@ -284,7 +284,7 @@
                const char* name = fn.arg(0).to_string();
 
                // check the import.
-               movie_definition* def = 
fn.env->get_target()->get_root_movie()->get_movie_definition();
+               movie_definition* def = 
fn.env().get_target()->get_root_movie()->get_movie_definition();
                assert(def);
                boost::intrusive_ptr<resource> res = 
def->get_exported_resource(name);
                if (res == NULL)
@@ -336,7 +336,7 @@
        }
 
        // check the import.
-       movie_definition* def = 
fn.env->get_target()->get_root_movie()->get_movie_definition();
+       movie_definition* def = 
fn.env().get_target()->get_root_movie()->get_movie_definition();
        assert(def);
        boost::intrusive_ptr<resource> res = def->get_exported_resource(name);
        if (res == NULL)

Index: server/asobj/xml.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xml.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- server/asobj/xml.cpp        22 Mar 2007 08:45:52 -0000      1.23
+++ server/asobj/xml.cpp        22 Mar 2007 22:37:46 -0000      1.24
@@ -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: xml.cpp,v 1.23 2007/03/22 08:45:52 strk Exp $ */
+/* $Id: xml.cpp,v 1.24 2007/03/22 22:37:46 bjacques Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -800,21 +800,21 @@
 #if 1
     if (fn.this_ptr->get_member("onLoad", &method)) {
         //    log_msg("FIXME: Found onLoad!\n");
-        fn.env->set_variable("success", true);
+        fn.env().set_variable("success", true);
         fn.arg(0) = true;
 #if 0
         as_c_function_ptr      func = method.to_c_function();
         if (func) {
            // It's a C function.  Call it.
            log_msg("Calling C function for onLoad\n");
-           (*func)(fn_call(&val, xml_obj, fn.env, fn.nargs, 
fn.first_arg_bottom_index)); // was this_ptr instead of node
+           (*func)(fn_call(&val, xml_obj, fn.env(), fn.nargs, 
fn.first_arg_bottom_index)); // was this_ptr instead of node
        } else
 #endif
        if (as_function* as_func = method.to_as_function()) {
            // It's an ActionScript function.  Call it.
            log_msg("Calling ActionScript function for onLoad\n");
            // XXX other than being assigned into, val appears to be unused.
-           val = (*as_func)(fn_call(xml_obj, fn.env, fn.nargs, 
fn.first_arg_bottom_index)); // was this_ptr instead of node
+           val = (*as_func)(fn_call(xml_obj, &fn.env(), fn.nargs, 
fn.offset())); // was this_ptr instead of node
        } else {
            log_error("error in call_method(): method is not a function\n");
        }
@@ -856,7 +856,7 @@
     
         if (fn.this_ptr->get_member("onLoad", &method)) {
             // log_msg("FIXME: Found onLoad!\n");
-           val = call_method(method, fn.env, fn.this_ptr.get(), 0, 0);
+           val = call_method(method, &fn.env(), fn.this_ptr.get(), 0, 0);
         } else {
             log_msg("FIXME: Couldn't find onLoad!\n");
         }
@@ -882,8 +882,8 @@
         if (fn.this_ptr->get_member("onData", &method)) {
             log_msg("FIXME: Found onData!\n");
            // TODO: this is suspicious (set_variable for what??)
-            fn.env->set_variable("success", true);
-           val = call_method(method, fn.env, fn.this_ptr, 0, 0);
+            fn.env().set_variable("success", true);
+           val = call_method(method, fn.env(), fn.this_ptr, 0, 0);
         } else {
             log_msg("FIXME: Couldn't find onData!\n");
         }
@@ -954,12 +954,12 @@
     // log_msg("%s: nargs=%d\n", __FUNCTION__, fn.nargs);
   
     if (fn.nargs > 0) {
-           boost::intrusive_ptr<as_object> obj = fn.env->top(0).to_object();
+           boost::intrusive_ptr<as_object> obj = fn.env().top(0).to_object();
 
         if (! obj ) {
             xml_obj = new XML;
             //log_msg("\tCreated New XML object at %p\n", xml_obj);
-            tu_string datain = fn.env->top(0).to_tu_string();
+            tu_string datain = fn.env().top(0).to_tu_string();
             xml_obj->parseXML(datain);
             //log_msg("*** Start setting up the stack frames ***\n");
             xml_obj->setupFrame(xml_obj.get(), xml_obj->firstChild(), true);
@@ -1175,9 +1175,9 @@
 #if 1
     if (fn.this_ptr->get_member("onLoad", &method)) {
         log_msg("FIXME: Found onLoad!\n");
-        fn.env->set_variable("success", true); // what is this for ?
+        fn.env().set_variable("success", true); // what is this for ?
        fn.arg(0) = true; // what is this for ?
-       val = call_method(method, fn.env, fn.this_ptr.get(), 0, 0);
+       val = call_method(method, &fn.env(), fn.this_ptr.get(), 0, 0);
     } else {
         log_msg("Couldn't find onLoad event handler, setting up callback\n");
         // ptr->set_event_handler(event_id::XML_LOAD, 
(as_c_function_ptr)&xml_onload);

Index: server/asobj/xmlsocket.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/xmlsocket.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- server/asobj/xmlsocket.cpp  20 Mar 2007 15:01:20 -0000      1.12
+++ server/asobj/xmlsocket.cpp  22 Mar 2007 22:37:46 -0000      1.13
@@ -379,8 +379,8 @@
     
     log_msg("%s: nargs=%d\n", __FUNCTION__, fn.nargs);
     boost::intrusive_ptr<xmlsocket_as_object> ptr = 
ensureType<xmlsocket_as_object>(fn.this_ptr);
-    const std::string host = 
fn.env->bottom(fn.first_arg_bottom_index).to_string();
-    std::string port_str = 
fn.env->bottom(fn.first_arg_bottom_index-1).to_string();
+    const std::string host = fn.arg(0).to_string();
+    std::string port_str = fn.arg(1).to_string();
     double port = atof(port_str.c_str());
     
     ptr->obj.connect(host.c_str(), static_cast<int>(port));
@@ -388,17 +388,17 @@
 #if 0 // use connect return as result
     // Push result onto stack for onConnect
     if (ret) {
-        fn.env->push(as_value(true));
+        fn.env().push(as_value(true));
     }
     else {
-        fn.env->push(as_value(false));
+        fn.env().push(as_value(false));
     }
 #endif
-    fn.env->push(as_value(true));
+    fn.env().push(as_value(true));
     if (fn.this_ptr->get_member("onConnect", &method)) {
         //    log_msg("FIXME: Found onConnect!\n");
         first = false; // what is this for ?
-        val = call_method0(method, fn.env, fn.this_ptr.get());
+        val = call_method0(method, &fn.env(), fn.this_ptr.get());
     } else {
         //ptr->set_event_handler(event_id::SOCK_CONNECT, 
(as_c_function_ptr)&xmlsocket_event_connect);
     }
@@ -408,11 +408,11 @@
     Timer *timer = new Timer;
     boost::intrusive_ptr<builtin_function> ondata_handler = new 
builtin_function(
         &xmlsocket_event_ondata, NULL);
-    timer->setInterval(*ondata_handler, 50, 
boost::dynamic_pointer_cast<as_object>(ptr), fn.env);
+    timer->setInterval(*ondata_handler, 50, 
boost::dynamic_pointer_cast<as_object>(ptr), &fn.env());
     VM::get().getRoot().add_interval_timer(*timer);
 #endif
     
-    fn.env->pop();
+    fn.env().pop();
     
     return as_value(true);
 }
@@ -426,7 +426,7 @@
     as_value   val;
     
     boost::intrusive_ptr<xmlsocket_as_object> ptr = 
ensureType<xmlsocket_as_object>(fn.this_ptr);
-    const std::string object = fn.env->bottom( 
fn.first_arg_bottom_index).to_string();
+    const std::string object = fn.arg(0).to_string();
     //  log_msg("%s: host=%s, port=%g\n", __FUNCTION__, host, port);
     return as_value(ptr->obj.send(object));
 }
@@ -488,11 +488,11 @@
     //
     //as_c_function_ptr int_handler = (as_c_function_ptr)&timer_setinterval;
     //env->set_member("setInterval", int_handler);
-    fn.env->set_member("setInterval", timer_setinterval);
+    fn.env().set_member("setInterval", timer_setinterval);
     
     //as_c_function_ptr clr_handler = timer_clearinterval;
     // TODO:  check this, sounds suspicious
-    fn.env->set_member("clearInterval", timer_clearinterval);
+    fn.env().set_member("clearInterval", timer_clearinterval);
     
     //env->set_variable("setInterval", int_handler, 0);
     //xmlsock_obj->set_event_handler(event_id::TIMER,
@@ -549,7 +549,7 @@
 //          log_msg("Got message #%d, %d bytes long at %p: %s: \n", i,
 //                  strlen(messages[i]), messages[i], messages[i]);
                 datain = messages[i];
-                //fn.env->push(datain);
+                //fn.env().push(datain);
 #ifndef USE_DMALLOC
                 //dump_memory_stats(__FUNCTION__, __LINE__, "start");
 #endif
@@ -563,7 +563,7 @@
 #endif  
         //log_msg("Deleting message #%d at %p\n", i, messages[i]);
         //delete messages[i];
-        //fn.env->pop();
+        //fn.env().pop();
         datain.set_undefined();
       }
       ptr->obj.processing(false);
@@ -618,7 +618,7 @@
         //env->bottom(0) = true;
         
         if (fn.this_ptr->get_member("onConnect", &method)) {
-           val = call_method0(method, fn.env, fn.this_ptr.get());
+           val = call_method0(method, &fn.env(), fn.this_ptr.get());
         } else {
             log_msg("FIXME: Couldn't find onConnect!");
         }

Index: server/vm/fn_call.h
===================================================================
RCS file: /sources/gnash/gnash/server/vm/fn_call.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/vm/fn_call.h 20 Mar 2007 15:01:20 -0000      1.4
+++ server/vm/fn_call.h 22 Mar 2007 22:37:46 -0000      1.5
@@ -43,19 +43,22 @@
 class fn_call
 {
 public:
+       /// The as_object (or a pointer derived thereof) on which this call
+       /// is taking place.
        boost::intrusive_ptr<as_object> this_ptr;
-       as_environment* env;
-       unsigned int nargs;
-       int first_arg_bottom_index;
 
+       /// Number of arguments to this ActionScript function call.
+       const unsigned int nargs;
+
+public:
        fn_call(as_object* this_in,
                        as_environment* env_in,
                        int nargs_in, int first_in)
                :
                this_ptr(this_in),
-               env(env_in),
                nargs(nargs_in),
-               first_arg_bottom_index(first_in)
+               _env(env_in),
+               _stack_offset(first_in)
        {
        }
 
@@ -64,9 +67,9 @@
                        int nargs_in, int first_in)
                :
                this_ptr(this_in),
-               env(env_in),
                nargs(nargs_in),
-               first_arg_bottom_index(first_in)
+               _env(env_in),
+               _stack_offset(first_in)
        {
        }
 
@@ -74,7 +77,17 @@
        as_value& arg(unsigned int n) const
        {
                assert(n < nargs);
-               return env->bottom(first_arg_bottom_index - n);
+               return _env->bottom(_stack_offset - n);
+       }
+
+       int offset() const
+       {
+               return _stack_offset;
+       }
+
+       as_environment& env() const
+       {
+               return *_env;
        }
 
        /// Dump arguments to given output stream
@@ -87,6 +100,14 @@
                }
        }
 
+private:
+       /// The ActionScript environment in which the function call is taking
+       /// place. This contains, among other things, the function arguments.
+       as_environment* _env;
+
+       /// The offset from the bottom of the env callstack to the first
+       /// argument to our fn_call.
+       unsigned int _stack_offset;
 };
 
 /// Signature of a builtin function callable from ActionScript




reply via email to

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