gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/array.cpp server/as_func...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/array.cpp server/as_func...
Date: Wed, 08 Nov 2006 08:25:28 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/11/08 08:25:28

Modified files:
        .              : ChangeLog 
        server         : array.cpp as_function.cpp 
        server/asobj   : MovieClip.cpp MovieClipLoader.cpp Number.cpp 
                         Object.cpp System.cpp string.cpp 

Log message:
                * server/: array.cpp, as_function.cpp, asobj/: MovieClip.cpp,
                  MovieClipLoader.cpp, Number.cpp, Object.cpp, System.cpp,
                  string.cpp: change static pointers to static *smart* pointers
                  so we're sure they don't get deleted due to assignment to
                  some other short-lived smart_ptr and that they are released
                  at exit.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1552&r2=1.1553
http://cvs.savannah.gnu.org/viewcvs/gnash/server/array.cpp?cvsroot=gnash&r1=1.39&r2=1.40
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_function.cpp?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/MovieClip.cpp?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/MovieClipLoader.cpp?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Number.cpp?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Object.cpp?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/System.cpp?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/string.cpp?cvsroot=gnash&r1=1.4&r2=1.5

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1552
retrieving revision 1.1553
diff -u -b -r1.1552 -r1.1553
--- ChangeLog   8 Nov 2006 07:28:20 -0000       1.1552
+++ ChangeLog   8 Nov 2006 08:25:28 -0000       1.1553
@@ -1,5 +1,14 @@
 2006-11-08 Sandro Santilli <address@hidden>
 
+       * server/: array.cpp, as_function.cpp, asobj/: MovieClip.cpp,
+         MovieClipLoader.cpp, Number.cpp, Object.cpp, System.cpp,
+         string.cpp: change static pointers to static *smart* pointers
+         so we're sure they don't get deleted due to assignment to
+         some other short-lived smart_ptr and that they are released
+         at exit.
+
+2006-11-08 Sandro Santilli <address@hidden>
+
        * server/text.cpp, server/parser/text_character_def.cpp:
          resolve style fonts at parse time (not use time) - reduce
          number of warnings given.

Index: server/array.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/array.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -b -r1.39 -r1.40
--- server/array.cpp    29 Oct 2006 18:34:11 -0000      1.39
+++ server/array.cpp    8 Nov 2006 08:25:28 -0000       1.40
@@ -771,42 +771,42 @@
 }
 
 static void
-attachArrayInterface(as_object* proto)
+attachArrayInterface(as_object& proto)
 {
        // we don't need an explicit member here,
        // we will be handling 'length' requests
        // within overridden get_member()
        //proto->set_member("length", &array_length);
 
-       proto->set_member("join", &array_join);
-       proto->set_member("concat", &array_concat);
-       proto->set_member("slice", &array_slice);
-       proto->set_member("push", &array_push);
-       proto->set_member("unshift", &array_unshift);
-       proto->set_member("pop", &array_pop);
-       proto->set_member("shift", &array_shift);
-       proto->set_member("splice", &array_splice);
-       proto->set_member("sort", &array_sort);
-       proto->set_member("sortOn", &array_sortOn);
-       proto->set_member("reverse", &array_reverse);
-       proto->set_member("toString", &array_to_string);
-       proto->set_member("CASEINSENSITIVE", as_array_object::fCaseInsensitive);
-       proto->set_member("DESCENDING", as_array_object::fDescending);
-       proto->set_member("UNIQUESORT", as_array_object::fUniqueSort);
-       proto->set_member("RETURNINDEXEDARRAY", 
as_array_object::fReturnIndexedArray);
-       proto->set_member("NUMERIC", as_array_object::fNumeric);
+       proto.set_member("join", &array_join);
+       proto.set_member("concat", &array_concat);
+       proto.set_member("slice", &array_slice);
+       proto.set_member("push", &array_push);
+       proto.set_member("unshift", &array_unshift);
+       proto.set_member("pop", &array_pop);
+       proto.set_member("shift", &array_shift);
+       proto.set_member("splice", &array_splice);
+       proto.set_member("sort", &array_sort);
+       proto.set_member("sortOn", &array_sortOn);
+       proto.set_member("reverse", &array_reverse);
+       proto.set_member("toString", &array_to_string);
+       proto.set_member("CASEINSENSITIVE", as_array_object::fCaseInsensitive);
+       proto.set_member("DESCENDING", as_array_object::fDescending);
+       proto.set_member("UNIQUESORT", as_array_object::fUniqueSort);
+       proto.set_member("RETURNINDEXEDARRAY", 
as_array_object::fReturnIndexedArray);
+       proto.set_member("NUMERIC", as_array_object::fNumeric);
 }
 
 static as_object*
 getArrayInterface()
 {
-       static as_object* proto = NULL;
+       static smart_ptr<as_object> proto = NULL;
        if ( proto == NULL )
        {
                proto = new as_object();
-               attachArrayInterface(proto);
+               attachArrayInterface(*proto);
        }
-       return proto;
+       return proto.get_ptr();
 }
 
 // this registers the "Array" member on a "Global"
@@ -818,22 +818,19 @@
 array_class_init(as_object& glob)
 {
        // This is going to be the global Array "class"/"function"
-       static as_function* ar=NULL;
+       static smart_ptr<as_function> ar=NULL;
 
        if ( ar == NULL )
        {
-               ar = new builtin_function(
-                       &array_new,
-                       getArrayInterface()
-               );
+               ar = new builtin_function(&array_new, getArrayInterface());
 
                // We replicate interface to the Array class itself
-               attachArrayInterface(ar);
+               attachArrayInterface(*ar);
 
        }
 
        // Register _global.Array
-       glob.set_member("Array", ar);
+       glob.set_member("Array", ar.get_ptr());
 }
 
 

Index: server/as_function.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_function.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- server/as_function.cpp      6 Nov 2006 15:11:04 -0000       1.6
+++ server/as_function.cpp      8 Nov 2006 08:25:28 -0000       1.7
@@ -66,16 +66,18 @@
  */
 static as_object* getFunctionPrototype()
 {
-       static as_object* proto = NULL;
+       // Make sure the prototype is always
+       // alive (static smart_ptr<> should ensure this)
+       static smart_ptr<as_object> proto;
 
-       if ( proto == NULL ) {
+       if ( proto.get_ptr() == NULL ) {
                // Initialize Function prototype
                proto = new as_object();
                proto->set_member("apply", &function_apply);
                proto->set_member("call", &function_call);
        }
 
-       return proto;
+       return proto.get_ptr();
 
 }
 
@@ -128,23 +130,16 @@
 {
        // This is going to be the global Function "class"/"function"
        // TODO: use Function() instead (where Function derives from 
as_function, being a class)
-       static as_function *func=new builtin_function(
+
+       // Make sure the prototype is always alive
+       // (static smart_ptr<> should ensure this)
+       static smart_ptr<as_function> func=new builtin_function(
                do_nothing, // function constructor doesn't do anything
                getFunctionPrototype() // exported interface
        );
 
-       // We make the 'prototype' element be a reference to
-       // the __proto__ element
-       //as_object* proto = func->m_prototype;
-       //proto->add_ref();
-
-       //proto->set_member("constructor", func); //as_value(func));
-       //proto->set_member_flags("constructor", 1);
-
-       //func->set_member("prototype", as_value(proto));
-
        // Register _global.Function
-       global->set_member("Function", func);
+       global->set_member("Function", func.get_ptr());
 
 }
 

Index: server/asobj/MovieClip.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/MovieClip.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/asobj/MovieClip.cpp  29 Oct 2006 18:34:12 -0000      1.4
+++ server/asobj/MovieClip.cpp  8 Nov 2006 08:25:28 -0000       1.5
@@ -13,9 +13,9 @@
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
 // 
 //
+
 #ifdef HAVE_PTHREADS
 #include <pthread.h>
 #endif
@@ -24,16 +24,6 @@
 #include <string>
 
 #include "MovieClip.h"
-#include "tu_file.h"
-#include "zlib_adapter.h"
-//#include "stream.h"
-//#include "jpeg.h"
-//#include "fontlib.h"
-//#include "font.h"
-//#include "log.h"
-//#include "Sprite.h"
-//#include "sprite_instance.h"
-//#include "render.h"
 
 using namespace std;
 
@@ -48,23 +38,6 @@
 void
 movieclip_init(as_object* /* global */)
 {
-#if 0
-    // This is going to be the global MovieClip "class"/"function"
-    static as_function *func=new function_as_object();
-
-    // We make the 'prototype' element be a reference to
-    // the __proto__ element
-    as_object* proto = func->m_prototype;
-    proto->add_ref();
-
-    proto->set_member("constructor", func); //as_value(func));
-    proto->set_member_flags("constructor", 1);
-
-    func->set_member("prototype", as_value(proto));
-
-    // Register _global.Function
-    global->set_member("Function", func);
-#endif
 }
 
 } // namespace gnash

Index: server/asobj/MovieClipLoader.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/MovieClipLoader.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- server/asobj/MovieClipLoader.cpp    31 Oct 2006 15:58:58 -0000      1.8
+++ server/asobj/MovieClipLoader.cpp    8 Nov 2006 08:25:28 -0000       1.9
@@ -81,13 +81,13 @@
 static as_object*
 getMovieClipLoaderInterface()
 {
-       static as_object* o=NULL;
+       static smart_ptr<as_object> o;
        if ( o == NULL )
        {
                o = new as_object();
                attachMovieClipLoaderInterface(*o);
        }
-       return o;
+       return o.get_ptr();
 }
 
 
@@ -401,7 +401,7 @@
 
   as_object*   mov_obj = new MovieClipLoader;
 
-  fn.result->set_as_object(mov_obj);
+  fn.result->set_as_object(mov_obj); // will store in a smart_ptr
 }
 
 // Invoked every time the loading content is written to disk during
@@ -423,7 +423,7 @@
   mcl_obj->set_member("bytesLoaded", mcl_data->bytes_loaded);
   mcl_obj->set_member("bytesTotal",  mcl_data->bytes_total);
   
-  fn.result->set_as_object(mcl_obj);
+  fn.result->set_as_object(mcl_obj); // will store in a smart_ptr
 }
 
 static void

Index: server/asobj/Number.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Number.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/asobj/Number.cpp     5 Nov 2006 20:10:12 -0000       1.4
+++ server/asobj/Number.cpp     8 Nov 2006 08:25:28 -0000       1.5
@@ -18,7 +18,7 @@
 //
 //
 
-/* $Id: Number.cpp,v 1.4 2006/11/05 20:10:12 strk Exp $ */
+/* $Id: Number.cpp,v 1.5 2006/11/08 08:25:28 strk Exp $ */
 
 // Implementation of ActionScript Number class.
 
@@ -52,13 +52,13 @@
 static as_object*
 getNumberInterface()
 {
-       static as_object* o=NULL;
+       static smart_ptr<as_object> o=NULL;
        if ( o == NULL )
        {
                o = new as_object();
                attachNumberInterface(*o);
        }
-       return o;
+       return o.get_ptr();
 }
 
 // FIXME: add some useful methods :)
@@ -106,14 +106,14 @@
 
        number_as_object* obj = new number_as_object(val);
        
-       fn.result->set_as_object(obj);
+       fn.result->set_as_object(obj); // will keep alive
 }
 
 // extern (used by Global.cpp)
 void number_class_init(as_object& global)
 {
        // This is going to be the global Number "class"/"function"
-       static builtin_function* cl=NULL;
+       static smart_ptr<builtin_function> cl=NULL;
 
        if ( cl == NULL )
        {
@@ -125,7 +125,7 @@
        }
 
        // Register _global.Number
-       global.set_member("Number", cl);
+       global.set_member("Number", cl.get_ptr());
 
 }
 

Index: server/asobj/Object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Object.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- server/asobj/Object.cpp     29 Oct 2006 18:34:12 -0000      1.6
+++ server/asobj/Object.cpp     8 Nov 2006 08:25:28 -0000       1.7
@@ -18,7 +18,7 @@
 //
 //
 
-/* $Id: Object.cpp,v 1.6 2006/10/29 18:34:12 rsavoye Exp $ */
+/* $Id: Object.cpp,v 1.7 2006/11/08 08:25:28 strk Exp $ */
 
 // Implementation of ActionScript Object class.
 
@@ -51,13 +51,13 @@
 static as_object*
 getObjectInterface()
 {
-       static as_object* o=NULL;
+       static smart_ptr<as_object> o;
        if ( o == NULL )
        {
                o = new as_object();
                attachObjectInterface(*o);
        }
-       return o;
+       return o.get_ptr();
 }
 
 // FIXME: add some useful methods :)
@@ -89,7 +89,7 @@
                return;
        }
 
-       as_object* new_obj;
+       smart_ptr<as_object> new_obj;
        if ( fn.nargs == 0 )
        {
                new_obj = new object_as_object();
@@ -100,7 +100,7 @@
                new_obj = new object_as_object();
        }
 
-       fn.result->set_as_object(new_obj);
+       fn.result->set_as_object(new_obj.get_ptr()); // will keep alive
 }
 
 std::auto_ptr<as_object>
@@ -114,7 +114,7 @@
 void object_class_init(as_object& global)
 {
        // This is going to be the global Object "class"/"function"
-       static builtin_function* cl=NULL;
+       static smart_ptr<builtin_function> cl=NULL;
 
        if ( cl == NULL )
        {
@@ -126,7 +126,7 @@
        }
 
        // Register _global.Object
-       global.set_member("Object", cl);
+       global.set_member("Object", cl.get_ptr());
 
 }
 

Index: server/asobj/System.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/System.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- server/asobj/System.cpp     29 Oct 2006 18:34:12 -0000      1.3
+++ server/asobj/System.cpp     8 Nov 2006 08:25:28 -0000       1.4
@@ -69,7 +69,7 @@
 static as_object*
 getSystemSecurityInterface()
 {
-       static as_object* proto = NULL;
+       static smart_ptr<as_object> proto;
        if ( proto == NULL )
        {
                proto = new as_object();
@@ -77,43 +77,43 @@
                proto->set_member("allowinsecuredomain", 
&system_security_allowinsecuredomain);
                proto->set_member("loadpolicyfile", 
&system_security_loadpolicyfile);
        }
-       return proto;
+       return proto.get_ptr();
 }
 
 static as_object*
 getSystemCapabilitiesInterface()
 {
-       static as_object* proto = NULL;
+       static smart_ptr<as_object> proto;
        if ( proto == NULL )
        {
                proto = new as_object();
                proto->set_member("version", "Gnash-" VERSION);
        }
-       return proto;
+       return proto.get_ptr();
 }
 
 static void
-attachSystemInterface(as_object* proto)
+attachSystemInterface(as_object& proto)
 {
        // Initialize Function prototype
-       proto->set_member("security", getSystemSecurityInterface());
-       proto->set_member("capabilities", getSystemCapabilitiesInterface());
-       proto->set_member("setclipboard", &system_setclipboard);
-       proto->set_member("showsettings", &system_showsettings);
+       proto.set_member("security", getSystemSecurityInterface());
+       proto.set_member("capabilities", getSystemCapabilitiesInterface());
+       proto.set_member("setclipboard", &system_setclipboard);
+       proto.set_member("showsettings", &system_showsettings);
 }
 
 static as_object*
 getSystemInterface()
 {
-       static as_object* proto = NULL;
+       static smart_ptr<as_object> proto;
        if ( proto == NULL )
        {
                proto = new as_object();
-               attachSystemInterface(proto);
+               attachSystemInterface(*proto);
                proto->set_member("constructor", &system_new); 
                proto->set_member_flags("constructor", 1);
        }
-       return proto;
+       return proto.get_ptr();
 }
 
 system_as_object::system_as_object()
@@ -164,18 +164,18 @@
 system_init(as_object* glob)
 {
        // This is going to be the global System "class"/"function"
-       static as_function* sys=NULL;
+       static smart_ptr<as_function> sys;
 
        if ( sys == NULL )
        {
                sys = new builtin_function(do_nothing, getSystemInterface());
 
                // We replicate interface to the System class itself
-               attachSystemInterface(sys);
+               attachSystemInterface(*sys);
        }
 
        // Register _global.System
-       glob->set_member("System", sys);
+       glob->set_member("System", sys.get_ptr());
 
 }
 

Index: server/asobj/string.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/string.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/asobj/string.cpp     5 Nov 2006 20:10:12 -0000       1.4
+++ server/asobj/string.cpp     8 Nov 2006 08:25:28 -0000       1.5
@@ -18,7 +18,7 @@
 //
 //
 
-/* $Id: string.cpp,v 1.4 2006/11/05 20:10:12 strk Exp $ */
+/* $Id: string.cpp,v 1.5 2006/11/08 08:25:28 strk Exp $ */
 
 // Implementation of ActionScript String class.
 
@@ -66,13 +66,13 @@
 static as_object*
 getStringInterface()
 {
-       static as_object* o=NULL;
+       static smart_ptr<as_object> o;
        if ( o == NULL )
        {
                o = new as_object();
                attachStringInterface(*o);
        }
-       return o;
+       return o.get_ptr();
 }
 
 class tu_string_as_object : public as_object
@@ -281,7 +281,7 @@
 void string_class_init(as_object& global)
 {
        // This is going to be the global String "class"/"function"
-       static builtin_function* cl=NULL;
+       static smart_ptr<builtin_function> cl;
 
        if ( cl == NULL )
        {
@@ -293,7 +293,7 @@
        }
 
        // Register _global.String
-       global.set_member("String", cl);
+       global.set_member("String", cl.get_ptr());
 
 }
 
@@ -303,9 +303,6 @@
        tu_string_as_object* obj = new tu_string_as_object();
        if ( val ) obj->m_string = val;
        return std::auto_ptr<as_object>(obj);
-       //return ret;
-       //std::auto_ptr<as_object> ret(obj);
-       //return ret;
 }
   
 } // namespace gnash




reply via email to

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