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/asobj/G...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/array.cpp server/asobj/G...
Date: Mon, 03 Dec 2007 18:05:07 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/12/03 18:05:07

Modified files:
        .              : ChangeLog 
        server         : array.cpp 
        server/asobj   : Global.cpp 
        testsuite/actionscript.all: array.as 

Log message:
                * server/array.cpp: register native functions, fix interface
                  initialization and logging.
                * server/asobj/Global.cpp: ASNative => ASnative
                * testsuite/actionscript.all/array.as: test for calling Array()
                  as a normal function, ctor use trough ASnative, flag position.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.5070&r2=1.5071
http://cvs.savannah.gnu.org/viewcvs/gnash/server/array.cpp?cvsroot=gnash&r1=1.84&r2=1.85
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Global.cpp?cvsroot=gnash&r1=1.78&r2=1.79
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/array.as?cvsroot=gnash&r1=1.35&r2=1.36

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.5070
retrieving revision 1.5071
diff -u -b -r1.5070 -r1.5071
--- ChangeLog   3 Dec 2007 16:50:25 -0000       1.5070
+++ ChangeLog   3 Dec 2007 18:05:06 -0000       1.5071
@@ -1,3 +1,11 @@
+2007-12-03 Sandro Santilli <address@hidden>
+
+       * server/array.cpp: register native functions, fix interface
+         initialization and logging.
+       * server/asobj/Global.cpp: ASNative => ASnative
+       * testsuite/actionscript.all/array.as: test for calling Array()
+         as a normal function, ctor use trough ASnative, flag position.
+
 2007-12-03 Benjamin Wolsey <address@hidden>
 
        * libmedia/sdl/MediaDecoderSdl.cpp: make gotAudio() and gotVideo()

Index: server/array.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/array.cpp,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -b -r1.84 -r1.85
--- server/array.cpp    20 Nov 2007 12:04:55 -0000      1.84
+++ server/array.cpp    3 Dec 2007 18:05:07 -0000       1.85
@@ -29,7 +29,7 @@
 #include "fn_call.h"
 #include "GnashException.h"
 #include "action.h" // for call_method
-#include "VM.h" // for PROPNAME macro to work
+#include "VM.h" // for PROPNAME, registerNative
 #include "Object.h" // for getObjectInterface()
 
 #include <string>
@@ -47,6 +47,7 @@
 static as_object* getArrayInterface();
 static void attachArrayProperties(as_object& proto);
 static void attachArrayInterface(as_object& proto);
+static void attachArrayStatics(as_object& proto);
 
 inline static bool int_lt_or_eq (int a)
 {
@@ -609,7 +610,9 @@
        // If the array is empty, report an error and return undefined!
        if ( elements.empty() ) 
        {
-           log_error(_("tried to pop element from back of empty array, 
returning undef"));
+               IF_VERBOSE_ASCODING_ERRORS(
+               log_aserror(_("tried to pop element from back of empty array, 
returning undef"));
+               );
                return as_value(); // undefined
        }
 
@@ -625,7 +628,9 @@
        // If the array is empty, report an error and return undefined!
        if ( elements.empty() ) 
        {
-               log_error(_("tried to shift element from front of empty array, 
returning undef"));
+               IF_VERBOSE_ASCODING_ERRORS(
+               log_aserror(_("tried to shift element from front of empty 
array, returning undef"));
+               );
                return as_value(); // undefined
        }
 
@@ -1435,26 +1440,13 @@
 
        gettersetter = new builtin_function(&array_length, NULL);
        proto.init_property("length", *gettersetter, *gettersetter);
+
+       proto.init_member("size", new builtin_function(array_size));
 }
 
 static void
-attachArrayInterface(as_object& proto)
+attachArrayStatics(as_object& proto)
 {
-
-       proto.init_member("join", new builtin_function(array_join));
-       proto.init_member("concat", new builtin_function(array_concat));
-       proto.init_member("slice", new builtin_function(array_slice));
-       proto.init_member("push", new builtin_function(array_push));
-       proto.init_member("unshift", new builtin_function(array_unshift));
-       proto.init_member("pop", new builtin_function(array_pop));
-       proto.init_member("shift", new builtin_function(array_shift));
-       proto.init_member("splice", new builtin_function(array_splice));
-       proto.init_member("sort", new builtin_function(array_sort));
-       proto.init_member("size", new builtin_function(array_size));
-       proto.init_member("sortOn", new builtin_function(array_sortOn));
-       proto.init_member("reverse", new builtin_function(array_reverse));
-       proto.init_member("toString", new builtin_function(array_to_string));
-
        proto.init_member("CASEINSENSITIVE", as_array_object::fCaseInsensitive);
        proto.init_member("DESCENDING", as_array_object::fDescending);
        proto.init_member("UNIQUESORT", as_array_object::fUniqueSort);
@@ -1462,6 +1454,61 @@
        proto.init_member("NUMERIC", as_array_object::fNumeric);
 }
 
+static void
+attachArrayInterface(as_object& proto)
+{
+       VM& vm = proto.getVM();
+
+       // Array.push
+       vm.registerNative(array_push, 252, 1);
+       proto.init_member("push", vm.getNative(252, 1));
+
+       // Array.pop
+       vm.registerNative(array_pop, 252, 2);
+       proto.init_member("pop", vm.getNative(252, 2));
+
+       // Array.concat
+       vm.registerNative(array_concat, 252, 3);
+       proto.init_member("concat", vm.getNative(252, 3));
+
+       // Array.shift
+       vm.registerNative(array_shift, 252, 4);
+       proto.init_member("shift", vm.getNative(252, 4));
+
+       // Array.unshift
+       vm.registerNative(array_unshift, 252, 5);
+       proto.init_member("unshift", vm.getNative(252, 5));
+
+       // Array.slice
+       vm.registerNative(array_slice, 252, 6);
+       proto.init_member("slice", vm.getNative(252, 6));
+
+       // Array.join
+       vm.registerNative(array_join, 252, 7);
+       proto.init_member("join", vm.getNative(252, 7));
+
+       // Array.splice
+       vm.registerNative(array_splice, 252, 8);
+       proto.init_member("splice", vm.getNative(252, 8));
+
+       // Array.toString
+       vm.registerNative(array_to_string, 252, 9);
+       proto.init_member("toString", vm.getNative(252, 9));
+
+       // Array.sort
+       vm.registerNative(array_sort, 252, 10);
+       proto.init_member("sort", vm.getNative(252, 10));
+
+       // Array.reverse
+       vm.registerNative(array_reverse, 252, 11);
+       proto.init_member("reverse", vm.getNative(252, 11));
+
+       // Array.sortOn
+       vm.registerNative(array_sortOn, 252, 12);
+       proto.init_member("sortOn", vm.getNative(252, 12));
+
+}
+
 static as_object*
 getArrayInterface()
 {
@@ -1489,11 +1536,13 @@
 
        if ( ar == NULL )
        {
+               VM& vm = glob.getVM();
+               vm.registerNative(array_new, 252, 0);
                ar = new builtin_function(&array_new, getArrayInterface());
-               VM::get().addStatic(ar.get());
+               vm.addStatic(ar.get());
 
-               // We replicate interface to the Array class itself
-               attachArrayInterface(*ar);
+               // Attach static members
+               attachArrayStatics(*ar);
        }
 
        // Register _global.Array

Index: server/asobj/Global.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Global.cpp,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -b -r1.78 -r1.79
--- server/asobj/Global.cpp     2 Dec 2007 14:54:33 -0000       1.78
+++ server/asobj/Global.cpp     3 Dec 2007 18:05:07 -0000       1.79
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: Global.cpp,v 1.78 2007/12/02 14:54:33 strk Exp $ */
+/* $Id: Global.cpp,v 1.79 2007/12/03 18:05:07 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -426,7 +426,7 @@
 
        // ASSetPropFlags
        init_member("ASSetPropFlags", new 
builtin_function(as_global_assetpropflags));
-       init_member("ASNative", new builtin_function(as_global_asnative));
+       init_member("ASnative", new builtin_function(as_global_asnative));
 
        // Defined in timers.h
        init_member("setInterval", new builtin_function(timer_setinterval));

Index: testsuite/actionscript.all/array.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/array.as,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- testsuite/actionscript.all/array.as 29 Sep 2007 16:22:58 -0000      1.35
+++ testsuite/actionscript.all/array.as 3 Dec 2007 18:05:07 -0000       1.36
@@ -18,18 +18,22 @@
 
 // Initial test written by Mike Carlson
 
-rcsid="$Id: array.as,v 1.35 2007/09/29 16:22:58 strk Exp $";
+rcsid="$Id: array.as,v 1.36 2007/12/03 18:05:07 strk Exp $";
 
 #include "check.as"
 
 check_equals(typeof(Array), 'function');
+check_equals ( Array.CASEINSENSITIVE , 1 );
+check_equals ( Array.DESCENDING , 2 );
+check_equals ( Array.UNIQUESORT , 4 );
+check_equals ( Array.RETURNINDEXEDARRAY , 8 );
+check_equals ( Array.NUMERIC , 16 );
 check_equals(typeof(Array.prototype), 'object');
 check_equals(typeof(Array.prototype.__proto__), 'object');
 check_equals(Array.prototype.__proto__, Object.prototype);
 check_equals(typeof(Array.prototype.concat), 'function');
 check_equals(typeof(Array.prototype.join), 'function');
 check_equals(typeof(Array.prototype.pop), 'function');
-
 check_equals(typeof(Array.prototype.push), 'function');
 check_equals(typeof(Array.prototype.reverse), 'function');
 check_equals(typeof(Array.prototype.shift), 'function');
@@ -40,7 +44,18 @@
 check_equals(typeof(Array.prototype.unshift), 'function');
 check_equals(typeof(Array.prototype.toString), 'function');
 check_equals(typeof(Array.prototype.length), 'undefined');
+check_equals(typeof(Array.prototype.size), 'undefined');
+check_equals ( typeof(Array.prototype.CASEINSENSITIVE), 'undefined' );
+check_equals ( typeof(Array.prototype.DESCENDING), 'undefined' );
+check_equals ( typeof(Array.prototype.UNIQUESORT), 'undefined' );
+check_equals ( typeof(Array.prototype.RETURNINDEXEDARRAY), 'undefined' );
+check_equals ( typeof(Array.prototype.NUMERIC), 'undefined' );
 #if OUTPUT_VERSION >= 6
+check ( Array.hasOwnProperty('CASEINSENSITIVE') );
+check ( Array.hasOwnProperty('DESCENDING') );
+check ( Array.hasOwnProperty('UNIQUESORT') );
+check ( Array.hasOwnProperty('RETURNINDEXEDARRAY') );
+check ( Array.hasOwnProperty('NUMERIC') );
 check(Array.prototype.hasOwnProperty('concat'));
 check(Array.prototype.hasOwnProperty('join'));
 check(Array.prototype.hasOwnProperty('pop'));
@@ -55,8 +70,17 @@
 check(Array.prototype.hasOwnProperty('toString'));
 check(!Array.prototype.hasOwnProperty('length'));
 check(!Array.prototype.hasOwnProperty('valueOf'));
+check(!Array.prototype.hasOwnProperty('size'));
 #endif // OUTPUT_VERSION >= 6
 
+check_equals(typeof(Array()), 'object');
+check_equals(typeof(new Array()), 'object');
+f = ASnative(252, 0);
+check_equals(typeof(f), 'function');
+a = f();
+check_equals(typeof(a), 'object');
+check_equals(typeof(a.pop), 'function');
+
 neg = new Object();
 neg.valueOf = function () { return -1; };
 zero = new Object();
@@ -137,12 +161,6 @@
 check_equals ( a.join("test") , "9test8test7test551test200" );
 
 // Test one of our sorting type members
-check_equals ( Array.CASEINSENSITIVE , 1 );
-check_equals ( Array.DESCENDING , 2 );
-check_equals ( Array.UNIQUESORT , 4 );
-check_equals ( Array.RETURNINDEXEDARRAY , 8 );
-check_equals ( Array.NUMERIC , 16 );
-
 check_equals( typeof(Array.UNIQUE), 'undefined' );
 
 // the following tests do not belong here, but
@@ -163,13 +181,6 @@
 a.sort();
 check_equals ( a.toString(), "200,551,7,8,9" );
 
-// test flags
-check_equals ( Array.CASEINSENSITIVE, 1 );
-check_equals ( Array.DESCENDING, 2 );
-check_equals ( Array.UNIQUESORT, 4 );
-check_equals ( Array.RETURNINDEXEDARRAY, 8 );
-check_equals ( Array.NUMERIC, 16 );
-
 a.push(200,7,200,7,200,8,8,551,7,7);
 a.sort( Array.NUMERIC );
 check_equals ( a.toString() , "7,7,7,7,7,8,8,8,9,200,200,200,200,551,551" );
@@ -952,4 +963,31 @@
 xcheck_equals(out['len'], 2);
 check_equals(out[1], 1);
 check_equals(out[0], 1);
-totals();
+
+
+// TODO: test ASnative-returned functions:
+//
+// ASnative(252, 1) - [Array.prototype] push
+// ASnative(252, 2) - [Array.prototype] pop
+// ASnative(252, 3) - [Array.prototype] concat
+// ASnative(252, 4) - [Array.prototype] shift
+// ASnative(252, 5) - [Array.prototype] unshift
+// ASnative(252, 6) - [Array.prototype] slice
+// ASnative(252, 7) - [Array.prototype] join
+// ASnative(252, 8) - [Array.prototype] splice
+// ASnative(252, 9) - [Array.prototype] toString
+// ASnative(252, 10) - [Array.prototype] sort
+// ASnative(252, 11) - [Array.prototype] reverse
+// ASnative(252, 12) - [Array.prototype] sortOn 
+//
+
+
+#if OUTPUT_VERSION < 6
+ check_totals(363);
+#else
+# if OUTPUT_VERSION < 7
+  check_totals(391);
+# else
+  check_totals(398);
+# endif
+#endif




reply via email to

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