gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ./ChangeLog server/Function.cpp server/Fu...


From: strk
Subject: [Gnash-commit] gnash ./ChangeLog server/Function.cpp server/Fu...
Date: Fri, 10 Feb 2006 16:10:13 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Branch:         
Changes by:     strk <address@hidden>   06/02/10 16:10:13

Modified files:
        .              : ChangeLog 
        server         : Function.cpp Function.h Object.cpp action.cpp 
                         action.h 

Log message:
        DONE

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/ChangeLog.diff?tr1=1.118&tr2=1.119&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Function.cpp.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Function.h.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Object.cpp.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/action.cpp.diff?tr1=1.39&tr2=1.40&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/action.h.diff?tr1=1.14&tr2=1.15&r1=text&r2=text

Patches:
Index: gnash/ChangeLog
diff -u gnash/ChangeLog:1.118 gnash/ChangeLog:1.119
--- gnash/ChangeLog:1.118       Fri Feb 10 13:20:03 2006
+++ gnash/ChangeLog     Fri Feb 10 16:10:13 2006
@@ -1,8 +1,14 @@
 2006-02-10 Sandro Santilli <address@hidden>
 
-       * server/action.{cpp,h}: added doActionCallMethod and
-       doActionCallFunction private methods to action_buffer.
+       * server/action.{cpp,h}: added doActionCallMethod,
+       doActionCallFunction, doActionDefineFunction and
+       doActionDefineFunction2 private methods to action_buffer.
        * testsuite/actionscript.all/Function.as: more tests.
+       * server/Object.cpp: reworked get_member/set_member to map
+       "__proto__" to m_prototype.
+       * server/Function.{h,cpp}: mapped m_properties to
+       "prototype". Set prototype.constructor at properties
+       initialization time.
 
 2006-02-09  Rob Savoye  <address@hidden>
 
Index: gnash/server/Function.cpp
diff -u gnash/server/Function.cpp:1.3 gnash/server/Function.cpp:1.4
--- gnash/server/Function.cpp:1.3       Tue Feb  7 03:49:43 2006
+++ gnash/server/Function.cpp   Fri Feb 10 16:10:13 2006
@@ -244,6 +244,9 @@
                proto_obj->set_member("apply", &function_apply);
                proto_obj->set_member("call", &function_call);
 
+               proto_obj->set_member("constructor", this);
+               proto_obj->set_member_flags("constructor", 1);
+
                as_value        proto(proto_obj);
                m_properties->set_member("prototype", proto);
        }
Index: gnash/server/Function.h
diff -u gnash/server/Function.h:1.2 gnash/server/Function.h:1.3
--- gnash/server/Function.h:1.2 Mon Feb  6 04:11:04 2006
+++ gnash/server/Function.h     Fri Feb 10 16:10:13 2006
@@ -40,7 +40,6 @@
 /// ActionScript Function.
 class function_as_object : public as_object
 {
-
 public:
        action_buffer*  m_action_buffer;
 
@@ -65,10 +64,12 @@
        /// arg register assignments
        uint16  m_function2_flags;
 
-       /// ActionScript functions have a property namespace!
-       /// Typically used for class constructors,
-       /// for "prototype", "constructor",
-       /// and class properties.
+       /// The "prototype" member.
+       //
+       /// Used for class constructor and members
+       /// to be inherited by instances of this
+       /// "Function" (class)
+       ///
        as_object*      m_properties;
 
        /// Constructor for 'new Function' constructor
Index: gnash/server/Object.cpp
diff -u gnash/server/Object.cpp:1.1 gnash/server/Object.cpp:1.2
--- gnash/server/Object.cpp:1.1 Mon Feb  6 04:11:04 2006
+++ gnash/server/Object.cpp     Fri Feb 10 16:10:13 2006
@@ -30,8 +30,8 @@
 bool
 as_object::get_member(const tu_stringi& name, as_value* val)
 {
-       //printf("GET MEMBER: %s at %p for object %p\n", name.c_str(), val, 
this);
-       if (name == "prototype")
+       //log_msg("GET MEMBER: %s at %p for object %p\n", name.c_str(), val, 
this);
+       if (name == "__proto__")
        {
                val->set_as_object_interface(m_prototype);
                return true;
@@ -41,12 +41,19 @@
 
                if (m_members.get(name, &m) == false)
                {
-                       if (m_prototype != NULL)
+                       //log_msg("  not found on first level\n");
+                       if (m_prototype == NULL)
                        {
+                               //log_msg("  no __proto__ (m_prototype) 
defined\n");
+                               return false;
+                       }
+                       else
+                       {
+                               //log_msg("  checkin in __proto__ (m_prototype) 
%p\n",m_prototype);
                                return m_prototype->get_member(name, val);
                        }
-                       return false;
                } else {
+                       //log_msg("  found on first level");
                        *val=m.get_member_value();
                        return true;
                }
@@ -66,7 +73,7 @@
 as_object::set_member(const tu_stringi& name, const as_value& val )
 {
        //printf("SET MEMBER: %s at %p for object %p\n", name.c_str(), 
val.to_object(), this);
-       if (name == "prototype")
+       if (name == "__proto__") // isn't this readonly?
        {
                if (m_prototype) m_prototype->drop_ref();
                m_prototype = val.to_object();
Index: gnash/server/action.cpp
diff -u gnash/server/action.cpp:1.39 gnash/server/action.cpp:1.40
--- gnash/server/action.cpp:1.39        Fri Feb 10 13:50:04 2006
+++ gnash/server/action.cpp     Fri Feb 10 16:10:13 2006
@@ -1059,9 +1059,9 @@
                std::string insertst;
                int hexcode;
 
-               for (int i=0;i<input.length();)
+               for (unsigned int i=0;i<input.length();)
                {
-                       if ((int(input.length()) > i + 2) && input[i] == '%' &&
+                       if ((input.length() > i + 2) && input[i] == '%' &&
                                isxdigit(input[i+1]) && isxdigit(input[i+2]))
                        {
                                input[i+1] = toupper(input[i+1]);
@@ -1774,10 +1774,6 @@
 
                        // Create an empty object, with a ref to the 
constructor's prototype.
                        smart_ptr<as_object>    new_obj_ptr(new 
as_object(proto.to_object()));
-
-                       // Set up the constructor member.
-                       new_obj_ptr->set_member("constructor", constructor);
-                       new_obj_ptr->set_member_flags("constructor", 1);
                        
                        new_obj.set_as_object_interface(new_obj_ptr.get_ptr());
 
@@ -1860,7 +1856,7 @@
        action_buffer::doActionCallMethod(as_environment* env)
        {
                // Some corner case behaviors depend on the SWF file version.
-               int version = 
env->get_target()->get_movie_definition()->get_version();
+               //int version = 
env->get_target()->get_movie_definition()->get_version();
 
                // Get name of the method
                const tu_string&        method_name = 
env->top(0).to_tu_string();
@@ -1946,6 +1942,120 @@
                env->top(0) = result;
        }
 
+       /*private*/
+       void
+       action_buffer::doActionDefineFunction(as_environment* env,
+                       array<with_stack_entry>& with_stack, int pc, int* 
next_pc)
+       {
+               function_as_object* func = new function_as_object(this, env, 
*next_pc, with_stack);
+
+               int     i = pc;
+               i += 3;
+
+               // Extract name.
+               // @@ security: watch out for possible missing terminator here!
+               tu_string       name = (const char*) &m_buffer[i];
+               i += name.length() + 1;
+
+               // Get number of arguments.
+               int     nargs = m_buffer[i] | (m_buffer[i + 1] << 8);
+               i += 2;
+
+               // Get the names of the arguments.
+               for (int n = 0; n < nargs; n++)
+               {
+                       // @@ security: watch out for possible missing 
terminator here!
+                       func->add_arg(0, (const char*) &m_buffer[i]);
+                       i += func->m_args.back().m_name.length() + 1;
+               }
+
+               // Get the length of the actual function code.
+               int     length = m_buffer[i] | (m_buffer[i + 1] << 8);
+               i += 2;
+               func->set_length(length);
+
+               // Skip the function body (don't interpret it now).
+               *next_pc += length;
+
+               // If we have a name, then save the function in this
+               // environment under that name.
+               as_value        function_value(func);
+               if (name.length() > 0)
+               {
+                       // @@ NOTE: should this be m_target->set_variable()???
+                       env->set_member(name, function_value);
+               }
+
+               // Also leave it on the stack.
+               env->push_val(function_value);
+
+       }
+
+       /*private*/
+       void
+       action_buffer::doActionDefineFunction2(as_environment* env,
+                       array<with_stack_entry>& with_stack, int pc, int* 
next_pc)
+       {
+               function_as_object*     func = new function_as_object(this, 
env, *next_pc, with_stack);
+               func->set_is_function2();
+
+               int     i = pc;
+               i += 3;
+
+               // Extract name.
+               // @@ security: watch out for possible missing terminator here!
+               tu_string       name = (const char*) &m_buffer[i];
+               i += name.length() + 1;
+
+               // Get number of arguments.
+               int     nargs = m_buffer[i] | (m_buffer[i + 1] << 8);
+               i += 2;
+
+               // Get the count of local registers used by this function.
+               uint8   register_count = m_buffer[i];
+               i += 1;
+               func->set_local_register_count(register_count);
+
+               // Flags, for controlling register assignment of implicit args.
+               uint16  flags = m_buffer[i] | (m_buffer[i + 1] << 8);
+               i += 2;
+               func->set_function2_flags(flags);
+
+               // Get the register assignments and names of the arguments.
+               for (int n = 0; n < nargs; n++)
+               {
+                       int     arg_register = m_buffer[i];
+                       i++;
+
+                       // @@ security: watch out for possible missing 
terminator here!
+                       func->add_arg(arg_register, (const char*) &m_buffer[i]);
+                       i += func->m_args.back().m_name.length() + 1;
+               }
+
+               // Get the length of the actual function code.
+               int     length = m_buffer[i] | (m_buffer[i + 1] << 8);
+               i += 2;
+               func->set_length(length);
+
+               // Skip the function body (don't interpret it now).
+               *next_pc += length;
+
+               // If we have a name, then save the function in this
+               // environment under that name.
+               as_value        function_value(func);
+               if (name.length() > 0)
+               {
+                       // @@ NOTE: should this be m_target->set_variable()???
+                       env->set_member(name, function_value);
+               }
+
+               // Also leave it on the stack.
+               env->push_val(function_value);
+
+       }
+
+
+
        void    action_buffer::execute(
                as_environment* env,
                int start_pc,
@@ -2947,65 +3057,8 @@
                                }
 
                                case SWF::ACTION_DEFINEFUNCTION2: // 0x8E
-                               {
-                                       function_as_object*     func = new 
function_as_object(this, env, next_pc, with_stack);
-                                       func->set_is_function2();
-
-                                       int     i = pc;
-                                       i += 3;
-
-                                       // Extract name.
-                                       // @@ security: watch out for possible 
missing terminator here!
-                                       tu_string       name = (const char*) 
&m_buffer[i];
-                                       i += name.length() + 1;
-
-                                       // Get number of arguments.
-                                       int     nargs = m_buffer[i] | 
(m_buffer[i + 1] << 8);
-                                       i += 2;
-
-                                       // Get the count of local registers 
used by this function.
-                                       uint8   register_count = m_buffer[i];
-                                       i += 1;
-                                       
func->set_local_register_count(register_count);
-
-                                       // Flags, for controlling register 
assignment of implicit args.
-                                       uint16  flags = m_buffer[i] | 
(m_buffer[i + 1] << 8);
-                                       i += 2;
-                                       func->set_function2_flags(flags);
-
-                                       // Get the register assignments and 
names of the arguments.
-                                       for (int n = 0; n < nargs; n++)
-                                       {
-                                               int     arg_register = 
m_buffer[i];
-                                               i++;
-
-                                               // @@ security: watch out for 
possible missing terminator here!
-                                               func->add_arg(arg_register, 
(const char*) &m_buffer[i]);
-                                               i += 
func->m_args.back().m_name.length() + 1;
-                                       }
-
-                                       // Get the length of the actual 
function code.
-                                       int     length = m_buffer[i] | 
(m_buffer[i + 1] << 8);
-                                       i += 2;
-                                       func->set_length(length);
-
-                                       // Skip the function body (don't 
interpret it now).
-                                       next_pc += length;
-
-                                       // If we have a name, then save the 
function in this
-                                       // environment under that name.
-                                       as_value        function_value(func);
-                                       if (name.length() > 0)
-                                       {
-                                               // @@ NOTE: should this be 
m_target->set_variable()???
-                                               env->set_member(name, 
function_value);
-                                       }
-
-                                       // Also leave it on the stack.
-                                       env->push_val(function_value);
-
+                                       doActionDefineFunction2(env, 
with_stack, pc, &next_pc);
                                        break;
-                               }
 
                                case SWF::ACTION_WITH:  // with
                                {
@@ -3227,52 +3280,9 @@
                                        break;
                                }
 
-                               case SWF::ACTION_DEFINEFUNCTION:        // 
declare function
-                               {
-                                       function_as_object* func = new 
function_as_object(this, env, next_pc, with_stack);
-
-                                       int     i = pc;
-                                       i += 3;
-
-                                       // Extract name.
-                                       // @@ security: watch out for possible 
missing terminator here!
-                                       tu_string       name = (const char*) 
&m_buffer[i];
-                                       i += name.length() + 1;
-
-                                       // Get number of arguments.
-                                       int     nargs = m_buffer[i] | 
(m_buffer[i + 1] << 8);
-                                       i += 2;
-
-                                       // Get the names of the arguments.
-                                       for (int n = 0; n < nargs; n++)
-                                       {
-                                               // @@ security: watch out for 
possible missing terminator here!
-                                               func->add_arg(0, (const char*) 
&m_buffer[i]);
-                                               i += 
func->m_args.back().m_name.length() + 1;
-                                       }
-
-                                       // Get the length of the actual 
function code.
-                                       int     length = m_buffer[i] | 
(m_buffer[i + 1] << 8);
-                                       i += 2;
-                                       func->set_length(length);
-
-                                       // Skip the function body (don't 
interpret it now).
-                                       next_pc += length;
-
-                                       // If we have a name, then save the 
function in this
-                                       // environment under that name.
-                                       as_value        function_value(func);
-                                       if (name.length() > 0)
-                                       {
-                                               // @@ NOTE: should this be 
m_target->set_variable()???
-                                               env->set_member(name, 
function_value);
-                                       }
-
-                                       // Also leave it on the stack.
-                                       env->push_val(function_value);
-
+                               case SWF::ACTION_DEFINEFUNCTION: // declare 
function
+                                       doActionDefineFunction(env, with_stack, 
pc, &next_pc);
                                        break;
-                               }
 
                                case SWF::ACTION_BRANCHIFTRUE:  // branch if 
true
                                {
Index: gnash/server/action.h
diff -u gnash/server/action.h:1.14 gnash/server/action.h:1.15
--- gnash/server/action.h:1.14  Fri Feb 10 12:27:43 2006
+++ gnash/server/action.h       Fri Feb 10 16:10:13 2006
@@ -214,6 +214,12 @@
 
                void doActionCallFunction(as_environment* env,
                        array<with_stack_entry>& with_stack);
+
+               void doActionDefineFunction(as_environment* env,
+                       array<with_stack_entry>& with_stack, int pc, int* 
next_pc);
+
+               void doActionDefineFunction2(as_environment* env,
+                       array<with_stack_entry>& with_stack, int pc, int* 
next_pc);
        };
 
 
@@ -640,7 +646,7 @@
                /// Members of this objects in an hash
                stringi_hash<as_member> m_members;
 
-               /// This object's 'prototype'
+               /// Reference to this object's '__proto__'
                as_object_interface*    m_prototype;
 
                /// Construct an ActionScript object with no prototype 
associated.




reply via email to

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