gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/asobj/Boolean.cpp server...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/asobj/Boolean.cpp server...
Date: Sun, 02 Dec 2007 09:15:55 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/12/02 09:15:55

Modified files:
        .              : ChangeLog 
        server/asobj   : Boolean.cpp Number.cpp string.cpp 
        server/vm      : fn_call.h 
        testsuite/actionscript.all: Boolean.as Number.as String.as 
                                    ops.as 
        testsuite/swfdec: PASSING 

Log message:
        Add the concept of an 'instantiating' call to fn_call. Use this concept
        to switch behaviour of builtin constructors Number, String and Boolean.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5054&r2=1.5055
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Boolean.cpp?cvsroot=gnash&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Number.cpp?cvsroot=gnash&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/string.cpp?cvsroot=gnash&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/gnash/server/vm/fn_call.h?cvsroot=gnash&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Boolean.as?cvsroot=gnash&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Number.as?cvsroot=gnash&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/String.as?cvsroot=gnash&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/ops.as?cvsroot=gnash&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/swfdec/PASSING?cvsroot=gnash&r1=1.69&r2=1.70

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5054
retrieving revision 1.5055
diff -u -b -r1.5054 -r1.5055
--- ChangeLog   2 Dec 2007 05:58:41 -0000       1.5054
+++ ChangeLog   2 Dec 2007 09:15:54 -0000       1.5055
@@ -1,3 +1,17 @@
+2007-12-01 Sandro Santilli <address@hidden>
+
+       * server/vm/fn_call.h: add isInstantiation() method to distinguish
+         between normal call and instantiating call to builtin constructors.
+       * server/asobj/Boolean.cpp (boolean_ctor): return a boolean (or
+         undefined) type if not instantiating.
+       * server/asobj/Number.cpp (number_ctor): return a number type if not
+         instantiating.
+       * server/asobj/string.cpp (string_ctor): return a string type if not
+         instantiating.
+       * testsuite/actionscript.all/: Boolean.as, Number.as, String.as,
+         ops.as: successes.
+       * testsuite/swfdec/PASSING: string-construct tests pass.
+
 2007-12-01 Bastiaan Jacques <address@hidden>
 
        * server/vm/Machine.cpp: Remove an "empty" if-statement that, if it

Index: server/asobj/Boolean.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Boolean.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- server/asobj/Boolean.cpp    31 Aug 2007 21:53:31 -0000      1.17
+++ server/asobj/Boolean.cpp    2 Dec 2007 09:15:54 -0000       1.18
@@ -107,14 +107,28 @@
 as_value
 boolean_ctor(const fn_call& fn)
 {
-       bool val = false;
        if (fn.nargs > 0)
        {
-               val = fn.arg(0).to_bool();
+               bool val = fn.arg(0).to_bool();
+               if ( ! fn.isInstantiation() )
+               {
+                       return as_value(val);
+               }
+               else
+               {
+                       return as_value(new boolean_as_object(val));
+               }
+       }
+
+       if ( ! fn.isInstantiation() )
+       {
+               return as_value();
+       }
+       else
+       {
+               return as_value(new boolean_as_object(false));
        }
-       boost::intrusive_ptr<as_object> obj = new boolean_as_object(val);
 
-       return as_value(obj.get()); // will keep alive
 }
 
 static boost::intrusive_ptr<builtin_function>

Index: server/asobj/Number.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Number.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- server/asobj/Number.cpp     31 Aug 2007 21:53:32 -0000      1.33
+++ server/asobj/Number.cpp     2 Dec 2007 09:15:54 -0000       1.34
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: Number.cpp,v 1.33 2007/08/31 21:53:32 strk Exp $ */
+/* $Id: Number.cpp,v 1.34 2007/12/02 09:15:54 strk Exp $ */
 
 #include "log.h"
 #include "tu_config.h"
@@ -136,6 +136,11 @@
                val = fn.arg(0).to_number();
        }
 
+       if ( ! fn.isInstantiation() )
+       {
+               return as_value(val);
+       }
+
        number_as_object* obj = new number_as_object(val);
        
        return as_value(obj); // will keep alive

Index: server/asobj/string.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/string.cpp,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- server/asobj/string.cpp     20 Nov 2007 12:04:55 -0000      1.43
+++ server/asobj/string.cpp     2 Dec 2007 09:15:54 -0000       1.44
@@ -16,7 +16,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: string.cpp,v 1.43 2007/11/20 12:04:55 cmusick Exp $ */
+/* $Id: string.cpp,v 1.44 2007/12/02 09:15:54 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -562,16 +562,21 @@
 static as_value
 string_ctor(const fn_call& fn)
 {
-    boost::intrusive_ptr<string_as_object> obj = new string_as_object;
-
-    std::string& str = obj->str();
+       std::string str;
 
-    if (fn.nargs > 0) {
+       if (fn.nargs )
+       {
         str = fn.arg(0).to_string();
     }
 
-    // this shouldn't be needed
-    //attachStringInterface(*str);
+       if ( ! fn.isInstantiation() )
+       {
+               return as_value(str);
+       }
+       
+       boost::intrusive_ptr<string_as_object> obj = new string_as_object;
+
+       obj->str() = str;
 
     return as_value(obj.get());
 }

Index: server/vm/fn_call.h
===================================================================
RCS file: /sources/gnash/gnash/server/vm/fn_call.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- server/vm/fn_call.h 20 Nov 2007 10:31:40 -0000      1.13
+++ server/vm/fn_call.h 2 Dec 2007 09:15:55 -0000       1.14
@@ -85,6 +85,18 @@
        {
        }
 
+       /// Return true if this call is an object instantiation
+       bool isInstantiation() const
+       {
+               // Currently the as_function::constructInstance
+               // will set 'this_ptr' to NULL when calling a builtin
+               // function, so we use this info to find out.
+               // For the future, we might use an explicit flag instead
+               // as I belive there are some cases in which 'this' is
+               // undefined even in a normal function call.
+               return (this_ptr == 0);
+       }
+
        /// Access a particular argument.
        as_value& arg(unsigned int n) const
        {

Index: testsuite/actionscript.all/Boolean.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Boolean.as,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- testsuite/actionscript.all/Boolean.as       2 Dec 2007 00:46:59 -0000       
1.17
+++ testsuite/actionscript.all/Boolean.as       2 Dec 2007 09:15:55 -0000       
1.18
@@ -20,13 +20,13 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: Boolean.as,v 1.17 2007/12/02 00:46:59 strk Exp $";
+rcsid="$Id: Boolean.as,v 1.18 2007/12/02 09:15:55 strk Exp $";
 
 #include "check.as"
 
 check_equals(typeof(Boolean), 'function');
-xcheck_equals(typeof(Boolean()), 'undefined');
-xcheck_equals(typeof(Boolean(true)), 'boolean');
+check_equals(typeof(Boolean()), 'undefined');
+check_equals(typeof(Boolean(true)), 'boolean');
 check_equals(typeof(new Boolean()), 'object');
 
 var boolObj = new Boolean;

Index: testsuite/actionscript.all/Number.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Number.as,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- testsuite/actionscript.all/Number.as        30 Nov 2007 19:12:50 -0000      
1.36
+++ testsuite/actionscript.all/Number.as        2 Dec 2007 09:15:55 -0000       
1.37
@@ -27,17 +27,17 @@
 // TODO: test with SWF target != 6 (the only one tested so far)
 //     
 
-rcsid="$Id: Number.as,v 1.36 2007/11/30 19:12:50 strk Exp $";
+rcsid="$Id: Number.as,v 1.37 2007/12/02 09:15:55 strk Exp $";
 
 #include "check.as"
 
 var n1=new Number(268);
 check_equals(typeof(n1), 'object');
 var n1prim = Number(268);
-xcheck_equals(typeof(n1prim), 'number');
-// gnash fails below because it compares 2 objects
+check_equals(typeof(n1prim), 'number');
+// gnash used to fail below because it compares 2 objects
 // rather then an object and a primitive
-xcheck_equals(n1, n1prim);
+check_equals(n1, n1prim);
 
 // strict-equality operator was introduced in SWF6
 #if OUTPUT_VERSION > 5

Index: testsuite/actionscript.all/String.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/String.as,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- testsuite/actionscript.all/String.as        2 Dec 2007 00:24:48 -0000       
1.27
+++ testsuite/actionscript.all/String.as        2 Dec 2007 09:15:55 -0000       
1.28
@@ -16,13 +16,13 @@
 
 // Original author: Mike Carlson - June 19th, 2006
 
-rcsid="$Id: String.as,v 1.27 2007/12/02 00:24:48 strk Exp $";
+rcsid="$Id: String.as,v 1.28 2007/12/02 09:15:55 strk Exp $";
 
 #include "check.as"
 
 // Gnash fails this always returning an object when String 
 // constructor is invoked.
-xcheck_equals(typeof(String()), 'string');
+check_equals(typeof(String()), 'string');
 
 var a;
 a = new String("wallawallawashinGTON");

Index: testsuite/actionscript.all/ops.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/ops.as,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- testsuite/actionscript.all/ops.as   21 Nov 2007 22:35:37 -0000      1.29
+++ testsuite/actionscript.all/ops.as   2 Dec 2007 09:15:55 -0000       1.30
@@ -20,7 +20,7 @@
  *  Test binary predicates (equal, less_then, greater_then, logical and 
bitwise ops)
  */
 
-rcsid="$Id: ops.as,v 1.29 2007/11/21 22:35:37 strk Exp $";
+rcsid="$Id: ops.as,v 1.30 2007/12/02 09:15:55 strk Exp $";
 
 #include "check.as"
 
@@ -94,7 +94,7 @@
 x = Number(new Number(NaN));
 y = NaN;
 z = 0/0;
-xcheck_equals(typeof(x), 'number')
+check_equals(typeof(x), 'number')
 check_equals(typeof(y), 'number');
 check_equals(typeof(z), 'number');
 check(isNaN(x));
@@ -233,7 +233,7 @@
 y=true;
 z=x && y;
 #if OUTPUT_VERSION < 7
-       xcheck_equals(z, false);
+       check_equals(z, false);
 #else
        check_equals(z, true);
 #endif 
@@ -242,7 +242,7 @@
 y=String("adcd");
 z=x && y;
 #if OUTPUT_VERSION < 7
-       xcheck_equals(z, false);
+       check_equals(z, false);
 #else
        check_equals(z, true);
 #endif
@@ -306,7 +306,7 @@
 y = String("abcd");
 z = x || y;
 #if OUTPUT_VERSION < 7
-       xcheck_equals(z, false); 
+       check_equals(z, false); 
 #else
        check_equals(z, true);
 #endif
@@ -339,7 +339,7 @@
 y = String("0");
 z = x || y;
 #if OUTPUT_VERSION < 7
-       xcheck_equals(z, false);
+       check_equals(z, false);
 #else
        check_equals(z, true);
 #endif

Index: testsuite/swfdec/PASSING
===================================================================
RCS file: /sources/gnash/gnash/testsuite/swfdec/PASSING,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -b -r1.69 -r1.70
--- testsuite/swfdec/PASSING    1 Dec 2007 22:11:25 -0000       1.69
+++ testsuite/swfdec/PASSING    2 Dec 2007 09:15:55 -0000       1.70
@@ -535,6 +535,9 @@
 stage-size-6.swf:8a83971dbf1f6beb6ba3ed0c94d3559c
 stage-size-7.swf:7090e81184777b7adb4527fbab83780b
 stage-size-8.swf:4f6c615f5c25c2653ec68b42bbc4089f
+string-construct-5.swf:b90373977a72afa66f1f4962a7e67d7a
+string-construct-6.swf:3466a3de80b49a570bddb27a77f19795
+string-construct-7.swf:60ac0591f3d53c9ed8f611a76a32da9e
 string-convert-5.swf:15de6c587a3c3e7c685b8f98ea862790
 string-convert-6.swf:841b7cc8e58c33c38efbfe1768ef82cf
 string-convert-7.swf:b822683afd33802bdd0e7ba31df63d68




reply via email to

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