gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash/server action.h action.cpp


From: strk
Subject: [Gnash-commit] gnash/server action.h action.cpp
Date: Sun, 05 Feb 2006 16:12:17 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Branch:         
Changes by:     strk <address@hidden>   06/02/05 16:12:17

Modified files:
        server         : action.h action.cpp 

Log message:
        Fixed Object constructor to accept a prototype argument (copy-ctor)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/action.h.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/action.cpp.diff?tr1=1.22&tr2=1.23&r1=text&r2=text

Patches:
Index: gnash/server/action.cpp
diff -u gnash/server/action.cpp:1.22 gnash/server/action.cpp:1.23
--- gnash/server/action.cpp:1.22        Sun Feb  5 10:10:00 2006
+++ gnash/server/action.cpp     Sun Feb  5 16:12:17 2006
@@ -1179,7 +1179,24 @@
        void    as_global_object_ctor(const fn_call& fn)
        // Constructor for ActionScript class Object.
        {
-               fn.result->set_as_object_interface(new as_object);
+               as_object *new_obj;
+
+               if ( fn.nargs == 0 )
+               {
+                       new_obj = new as_object();
+               }
+               else if ( fn.nargs == 1 ) // copy constructor
+               {
+                       as_object_interface *src_obj = fn.arg(0).to_object();
+                       new_obj = new as_object(src_obj);
+               }
+               else
+               {
+                       IF_VERBOSE_DEBUG(log_msg("Too many args to Object 
constructor"));
+                       new_obj = new as_object();
+               }
+
+               fn.result->set_as_object_interface(new_obj);
        }
 
        void    as_global_assetpropflags(const fn_call& fn)
@@ -2251,7 +2268,7 @@
 
                                        int nmembers = (int) 
env->pop().to_number();
 
-                                       smart_ptr<as_object> new_obj_ptr(new 
as_object); // won't this be leaking ?
+                                       smart_ptr<as_object> new_obj_ptr(new 
as_object); 
 
                                        // Set provided members
                                        for (int i=0; i<nmembers; ++i) {
Index: gnash/server/action.h
diff -u gnash/server/action.h:1.8 gnash/server/action.h:1.9
--- gnash/server/action.h:1.8   Sat Feb  4 15:32:07 2006
+++ gnash/server/action.h       Sun Feb  5 16:12:17 2006
@@ -429,7 +429,11 @@
                void    set_double(double val) { drop_refs(); m_type = NUMBER; 
m_number_value = val; }
                void    set_bool(bool val) { drop_refs(); m_type = BOOLEAN; 
m_boolean_value = val; }
                void    set_int(int val) { set_double(val); }
+
+               /// Make this value an as_object_interface.
+               /// Internally adds a reference to the ref-counted 
as_object_interface.
                void    set_as_object_interface(as_object_interface* obj);
+
                void    set_as_c_function_ptr(as_c_function_ptr func)
                {
                        drop_refs(); m_type = C_FUNCTION; m_c_function_value = 
func;
@@ -618,7 +622,12 @@
                stringi_hash<as_member> m_members;
                as_object_interface*    m_prototype;
 
+               /// Construct an ActionScript object with no prototype 
associated.
                as_object() : m_prototype(NULL) { }
+
+               /// \brief
+               /// Construct an ActionScript object based on the given 
prototype.
+               /// Adds a reference to the prototype, if any.
                as_object(as_object_interface* proto) : m_prototype(proto)
                {
                        if (m_prototype)
@@ -627,6 +636,9 @@
                        }
                }
 
+               /// \brief
+               /// Default destructor for ActionScript objects.
+               /// Drops reference on prototype member, if any.
                virtual ~as_object()
                {
                        if (m_prototype)




reply via email to

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