gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/as_function.cpp server/a...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/as_function.cpp server/a...
Date: Fri, 28 Sep 2007 10:10:37 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/09/28 10:10:36

Modified files:
        .              : ChangeLog 
        server         : as_function.cpp as_function.h 
                         builtin_function.h edit_text_character.cpp 

Log message:
                * server/as_function.{cpp,h}: Add a constructor
                  taking no args to use when a default prototype (iface)
                  is wanted. The other constructor, taking an interface
                  will be used when willing to control wheter or not a
                  prototype should be used (TextField don't have one in SWF5
                  and lower).
                * server/builtin_function.h: Same as with as_function, have
                  a constructor taking on interface for a default one, use
                  a NULL interface as meaning we don't want to expose a
                  prototype.
                * server/edit_text_character.cpp: don't set a prototype for 
TextField
                  class in SWF5, make TextField instances of object when 
TextField
                  has no prototype.
                * testsuite/actionscript.all/toString_valueOf.as: one more 
success.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4461&r2=1.4462
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_function.cpp?cvsroot=gnash&r1=1.42&r2=1.43
http://cvs.savannah.gnu.org/viewcvs/gnash/server/as_function.h?cvsroot=gnash&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/gnash/server/builtin_function.h?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.122&r2=1.123

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4461
retrieving revision 1.4462
diff -u -b -r1.4461 -r1.4462
--- ChangeLog   28 Sep 2007 09:31:52 -0000      1.4461
+++ ChangeLog   28 Sep 2007 10:10:36 -0000      1.4462
@@ -1,3 +1,21 @@
+2007-09-28 Sandro Santilli <address@hidden>
+
+       * server/as_function.{cpp,h}: Add a constructor
+         taking no args to use when a default prototype (iface)
+         is wanted. The other constructor, taking an interface
+         will be used when willing to control wheter or not a
+         prototype should be used (TextField don't have one in SWF5
+         and lower).
+       * server/builtin_function.h: Same as with as_function, have
+         a constructor taking on interface for a default one, use
+         a NULL interface as meaning we don't want to expose a
+         prototype.
+       * server/edit_text_character.cpp: don't set a prototype for TextField
+         class in SWF5, make TextField instances of object when TextField
+         has no prototype.
+       * testsuite/actionscript.all/toString_valueOf.as: one more success.
+
+
 2007-09-28 Benjamin Wolsey <address@hidden>
 
        * configure.ac, testsuite/libbase/TCXXRc.cpp, gnashrc-local.in: add

Index: server/as_function.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/as_function.cpp,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -b -r1.42 -r1.43
--- server/as_function.cpp      23 Sep 2007 08:48:17 -0000      1.42
+++ server/as_function.cpp      28 Sep 2007 10:10:36 -0000      1.43
@@ -96,6 +96,15 @@
        return as_value(func.get());
 }
 
+as_function::as_function()
+       :
+       // all functions inherit from global Function class
+       as_object(getFunctionPrototype())
+{
+       as_object* iface = new as_object(getObjectInterface());
+       iface->init_member("constructor", this); 
+       init_member("prototype", as_value(iface));
+}
 
 
 // What if we want a function to inherit from Object instead ?
@@ -104,13 +113,11 @@
        // all functions inherit from global Function class
        as_object(getFunctionPrototype())
 {
-       /// TODO: create properties lazily, on getPrototype() call
-       if ( ! iface )
+       if ( iface )
        {
-               iface = new as_object(getObjectInterface());
-       }
        iface->init_member("constructor", this); 
        init_member("prototype", as_value(iface));
+       }
 }
 
 void

Index: server/as_function.h
===================================================================
RCS file: /sources/gnash/gnash/server/as_function.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- server/as_function.h        12 Sep 2007 15:21:43 -0000      1.18
+++ server/as_function.h        28 Sep 2007 10:10:36 -0000      1.19
@@ -155,17 +155,21 @@
        }
 #endif // GNASH_USE_GC
 
-       /// Construct a function with given interface
+       /// Construct a function with a default interface
        //
-       /// If the given interface is NULL a default one
-       /// will be provided, with constructor set as 'this'.
+       /// The default interface will have derive from Object and 
+       /// have 'this' set as it's 'constructor' member. 
        ///
+       as_function();
+
+       /// Construct a function with given interface (possibly none)
+       //
        /// @param iface
-       ///     The interface exported by this class (ie.
-       ///     it's 'prototype' member). If NULL a default
-       ///     prototype will be used, using 'this' as
-       ///     it's 'constructor' member. 
-       ///     Refcount on the interface will be incremented.
+       ///     The interface exported by this class (its 'prototype' member).
+       ///     If NULL, no prototype will be set (this is used for some
+       ///     corner cases like TextField in SWF5 or below).
+       ///     If not NULL, a 'constructor' member will be added to the
+       ///     prototype, pointing to 'this'.
        ///
        as_function(as_object* iface);
 

Index: server/builtin_function.h
===================================================================
RCS file: /sources/gnash/gnash/server/builtin_function.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/builtin_function.h   1 Jul 2007 10:54:20 -0000       1.11
+++ server/builtin_function.h   28 Sep 2007 10:10:36 -0000      1.12
@@ -37,20 +37,36 @@
 
 public:
 
-       /// Construct a builtin function/class
+       /// Construct a builtin function/class with a default interface
        //
+       /// The default interface will have a constructor member set as 'this'
        ///
        /// @param func
        ///     The C function to call when this as_function is invoked.
        ///     For classes, the function pointer is the constructor.
        ///
+       builtin_function(as_c_function_ptr func)
+               :
+               as_function(),
+               _func(func)
+       {
+               init_member("constructor", this);
+       }
+
+       /// Construct a builtin function/class with the given interface 
(possibly none)
+       //
+       /// @param func
+       ///     The C function to call when this as_function is invoked.
+       ///     For classes, the function pointer is the constructor.
+       ///
        /// @param iface
        ///     The interface of this class (will be inherited by
        ///     instances of this class)
-       ///     If the given interface is NULL a default one
-       ///     will be provided, with constructor set as 'this'.
+       ///     If the given interface is NULL no interface will be
+       ///     provided. Use the constructor taking a single argument
+       ///     to get a default interface instead.
        ///
-       builtin_function(as_c_function_ptr func, as_object* iface=NULL)
+       builtin_function(as_c_function_ptr func, as_object* iface)
                :
                as_function(iface),
                _func(func)

Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -b -r1.122 -r1.123
--- server/edit_text_character.cpp      25 Sep 2007 11:10:00 -0000      1.122
+++ server/edit_text_character.cpp      28 Sep 2007 10:10:36 -0000      1.123
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: edit_text_character.cpp,v 1.122 2007/09/25 11:10:00 strk Exp $ */
+/* $Id: edit_text_character.cpp,v 1.123 2007/09/28 10:10:36 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -283,7 +283,9 @@
 static as_value
 textfield_ctor(const fn_call& /* fn */)
 {
-       boost::intrusive_ptr<as_object> obj = new 
as_object(getTextFieldInterface());
+       as_object* proto = getTextFieldInterface();
+       if ( ! proto ) proto = getObjectInterface(); // for SWF5 and below I 
guess...
+       boost::intrusive_ptr<as_object> obj = new as_object(proto);
        return as_value(obj);
 }
 
@@ -376,6 +378,9 @@
 getTextFieldInterface()
 {
        static boost::intrusive_ptr<as_object> proto;
+
+       if ( VM::get().getSWFVersion() < 6 ) return NULL;
+
        if ( proto == NULL )
        {
                proto = new as_object(getObjectInterface());
@@ -1634,8 +1639,25 @@
 
        if ( cl == NULL )
        {
-               cl=new builtin_function(&textfield_ctor, 
getTextFieldInterface());
-               VM::get().addStatic(cl.get());
+               VM& vm = VM::get();
+
+               as_object* iface = getTextFieldInterface();
+               cl=new builtin_function(&textfield_ctor, iface);
+#ifndef NDEBUG
+               int swfVer = vm.getSWFVersion();
+               if ( swfVer > 5 )
+               {
+                       assert(iface);
+                       
assert(cl->getOwnProperty(vm.getStringTable().find("prototype")));
+               }
+               else
+               {
+                       assert(!iface);
+                       
assert(!cl->getOwnProperty(vm.getStringTable().find("prototype")));
+               }
+#endif
+
+               vm.addStatic(cl.get());
 
                // replicate all interface to class, to be able to access
                // all methods as static functions




reply via email to

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