[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/array.cpp testsuite/acti...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/array.cpp testsuite/acti... |
Date: |
Wed, 28 Feb 2007 13:00:05 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/02/28 13:00:05
Modified files:
. : ChangeLog
server : array.cpp
testsuite/actionscript.all: array.as
Log message:
* server/array.cpp: use builtin_method for builtin
methods :) ensure the 'this' pointer passed
to builtin methods is valid.
* testsuite/actionscript.all/array.as:
Add test for calling Array builtin functions
using FUnction.call.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2495&r2=1.2496
http://cvs.savannah.gnu.org/viewcvs/gnash/server/array.cpp?cvsroot=gnash&r1=1.49&r2=1.50
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/array.as?cvsroot=gnash&r1=1.12&r2=1.13
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2495
retrieving revision 1.2496
diff -u -b -r1.2495 -r1.2496
--- ChangeLog 28 Feb 2007 11:02:04 -0000 1.2495
+++ ChangeLog 28 Feb 2007 13:00:04 -0000 1.2496
@@ -1,5 +1,14 @@
2007-02-28 Sandro Santilli <address@hidden>
+ * server/array.cpp: use builtin_method for builtin
+ methods :) ensure the 'this' pointer passed
+ to builtin methods is valid.
+ * testsuite/actionscript.all/array.as:
+ Add test for calling Array builtin functions
+ using FUnction.call.
+
+2007-02-28 Sandro Santilli <address@hidden>
+
* server/asobj/gen-asclass.sh: updated to
use new, more robust and more correct layout.
* server/asobj/string.cpp: robustness and
Index: server/array.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/array.cpp,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -b -r1.49 -r1.50
--- server/array.cpp 28 Feb 2007 07:41:27 -0000 1.49
+++ server/array.cpp 28 Feb 2007 13:00:05 -0000 1.50
@@ -29,17 +29,17 @@
#include <pthread.h>
#endif
-#include <string>
-#include <algorithm>
-#include <memory> // for auto_ptr
-
#include "as_value.h"
#include "array.h"
-//#include "action.h"
#include "log.h"
#include "builtin_function.h" // for Array class
#include "as_function.h" // for sort user-defined comparator
#include "fn_call.h"
+#include "GnashException.h"
+
+#include <string>
+#include <algorithm>
+#include <memory> // for auto_ptr
namespace gnash {
@@ -457,21 +457,31 @@
}
+static as_array_object *
+ensureArray(as_object* obj)
+{
+ as_array_object* ret = dynamic_cast<as_array_object*>(obj);
+ if ( ! ret )
+ {
+ throw ActionException("builtin method or gettersetter for Array
objects called against non-Array instance");
+ }
+ return ret;
+}
+
static void
array_splice(const fn_call& fn)
{
- assert(dynamic_cast<as_array_object*>(fn.this_ptr));
- //as_array_object* array = static_cast<as_array_object*>(fn.this_ptr);
+ as_array_object* array = ensureArray(fn.this_ptr);
+ UNUSED(array);
- log_error("Array.splice() method not implemented yet!\n");
+ log_error("FIXME: Array.splice() method not implemented yet!\n");
fn.result->set_undefined();
}
static void
array_sort(const fn_call& fn)
{
- assert(dynamic_cast<as_array_object*>(fn.this_ptr));
- as_array_object* array = static_cast<as_array_object*>(fn.this_ptr);
+ as_array_object* array = ensureArray(fn.this_ptr);
uint8_t flags;
@@ -499,10 +509,10 @@
static void
array_sortOn(const fn_call& fn)
{
- assert(dynamic_cast<as_array_object*>(fn.this_ptr));
- //as_array_object* array = static_cast<as_array_object*>(fn.this_ptr);
+ as_array_object* array = ensureArray(fn.this_ptr);
+ UNUSED(array);
- log_error("Array.sortOn() method not implemented yet!\n");
+ log_error("FIXME: Array.sortOn() method not implemented yet!");
fn.result->set_undefined();
}
@@ -510,12 +520,10 @@
static void
array_push(const fn_call& fn)
{
- assert(dynamic_cast<as_array_object*>(fn.this_ptr));
- as_array_object* array = \
- static_cast<as_array_object*>(fn.this_ptr);
+ as_array_object* array = ensureArray(fn.this_ptr);
IF_VERBOSE_ACTION (
- log_action("calling array push, pushing %d values onto back of
array\n",fn.nargs);
+ log_action("calling array push, pushing %d values onto back of
array",fn.nargs);
);
for (int i=0;i<fn.nargs;i++)
@@ -528,12 +536,10 @@
static void
array_unshift(const fn_call& fn)
{
- assert(dynamic_cast<as_array_object*>(fn.this_ptr));
- as_array_object* array = \
- static_cast<as_array_object*>(fn.this_ptr);
+ as_array_object* array = ensureArray(fn.this_ptr);
IF_VERBOSE_ACTION (
- log_action("calling array unshift, pushing %d values onto front of
array\n",fn.nargs);
+ log_action("calling array unshift, pushing %d values onto front of
array",fn.nargs);
);
for (int i=fn.nargs-1;i>=0;i--)
@@ -546,15 +552,14 @@
static void
array_pop(const fn_call& fn)
{
- assert(dynamic_cast<as_array_object*>(fn.this_ptr));
- as_array_object* array = \
- static_cast<as_array_object*>(fn.this_ptr);
+ as_array_object* array = ensureArray(fn.this_ptr);
// Get our index, log, then return result
(*fn.result) = array->pop();
IF_VERBOSE_ACTION (
- log_action("calling array pop, result:%s, new array
size:%d\n",fn.result->to_string(),array->size());
+ log_action("calling array pop, result:%s, new array size:%d",
+ fn.result->to_string(), array->size());
);
}
@@ -562,15 +567,14 @@
static void
array_shift(const fn_call& fn)
{
- assert(dynamic_cast<as_array_object*>(fn.this_ptr));
- as_array_object* array = \
- static_cast<as_array_object*>(fn.this_ptr);
+ as_array_object* array = ensureArray(fn.this_ptr);
// Get our index, log, then return result
(*fn.result) = array->shift();
IF_VERBOSE_ACTION (
- log_action("calling array shift, result:%s, new array
size:%d\n",fn.result->to_string(),array->size());
+ log_action("calling array shift, result:%s, new array size:%d",
+ fn.result->to_string(), array->size());
);
}
@@ -578,16 +582,15 @@
static void
array_reverse(const fn_call& fn)
{
- assert(dynamic_cast<as_array_object*>(fn.this_ptr));
- as_array_object* array = \
- static_cast<as_array_object*>(fn.this_ptr);
+ as_array_object* array = ensureArray(fn.this_ptr);
array->reverse();
fn.result->set_as_object(array);
IF_VERBOSE_ACTION (
- log_action("called array reverse, result:%s, new array
size:%d\n",fn.result->to_string(),array->size());
+ log_action("called array reverse, result:%s, new array size:%d",
+ fn.result->to_string(), array->size());
);
}
@@ -596,9 +599,7 @@
static void
array_join(const fn_call& fn)
{
- assert(dynamic_cast<as_array_object*>(fn.this_ptr));
- as_array_object* array = \
- static_cast<as_array_object*>(fn.this_ptr);
+ as_array_object* array = ensureArray(fn.this_ptr);
std::string separator = ",";
@@ -613,21 +614,17 @@
static void
array_size(const fn_call& fn)
{
- assert(dynamic_cast<as_array_object*>(fn.this_ptr));
- as_array_object* array = \
- static_cast<as_array_object*>(fn.this_ptr);
+ as_array_object* array = ensureArray(fn.this_ptr);
fn.result->set_int(array->size());
}
// Callback to convert array to a string
+// TODO CHECKME: rely on Object.toString ? (
static void
array_to_string(const fn_call& fn)
{
-
- assert(dynamic_cast<as_array_object*>(fn.this_ptr));
- as_array_object* array = \
- static_cast<as_array_object*>(fn.this_ptr);
+ as_array_object* array = ensureArray(fn.this_ptr);
std::string ret = array->toString();
@@ -650,9 +647,7 @@
static void
array_concat(const fn_call& fn)
{
- assert(dynamic_cast<as_array_object*>(fn.this_ptr));
- as_array_object* array = \
- static_cast<as_array_object*>(fn.this_ptr);
+ as_array_object* array = ensureArray(fn.this_ptr);
// use copy ctor
as_array_object* newarray = new as_array_object(*array);
@@ -679,9 +674,7 @@
static void
array_slice(const fn_call& fn)
{
- assert(dynamic_cast<as_array_object*>(fn.this_ptr));
- as_array_object* array = \
- static_cast<as_array_object*>(fn.this_ptr);
+ as_array_object* array = ensureArray(fn.this_ptr);
// start and end index of the part we're slicing
int startindex, endindex;
@@ -793,19 +786,20 @@
// within overridden get_member()
//proto->init_member("length", &array_length);
- proto.init_member("join", &array_join);
- proto.init_member("concat", &array_concat);
- proto.init_member("slice", &array_slice);
- proto.init_member("push", &array_push);
- proto.init_member("unshift", &array_unshift);
- proto.init_member("pop", &array_pop);
- proto.init_member("shift", &array_shift);
- proto.init_member("splice", &array_splice);
- proto.init_member("sort", &array_sort);
- proto.init_member("size", &array_size);
- proto.init_member("sortOn", &array_sortOn);
- proto.init_member("reverse", &array_reverse);
- proto.init_member("toString", &array_to_string);
+ 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);
Index: testsuite/actionscript.all/array.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/array.as,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- testsuite/actionscript.all/array.as 28 Feb 2007 07:41:27 -0000 1.12
+++ testsuite/actionscript.all/array.as 28 Feb 2007 13:00:05 -0000 1.13
@@ -5,7 +5,7 @@
// Updated with sort functions, and to use check() macro
// by Mike Carlson Feb. 14th, 2006
-rcsid="$Id: array.as,v 1.12 2007/02/28 07:41:27 strk Exp $";
+rcsid="$Id: array.as,v 1.13 2007/02/28 13:00:05 strk Exp $";
#include "check.as"
@@ -43,6 +43,14 @@
check_equals ( a.join() , "200,551,7,8,9" );
a.reverse();
check_equals ( a.join() , "9,8,7,551,200" );
+#if OUTPUT_VERSION > 5
+check_equals ( Array.prototype.join.apply(a), "9,8,7,551,200" );
+check_equals ( a.join.apply(a), "9,8,7,551,200" );
+#else
+// It seems that up to SWF5 we couldn't do this ...
+xcheck_equals ( Array.prototype.join.apply(a), undefined );
+xcheck_equals ( a.join.apply(a), undefined );
+#endif
check_equals ( a.join("test") , "9test8test7test551test200" );
// Test one of our sorting type members
@@ -151,6 +159,14 @@
check_equals(c[8], undefined);
// $Log: array.as,v $
+// Revision 1.13 2007/02/28 13:00:05 strk
+// * server/array.cpp: use builtin_method for builtin
+// methods :) ensure the 'this' pointer passed
+// to builtin methods is valid.
+// * testsuite/actionscript.all/array.as:
+// Add test for calling Array builtin functions
+// using FUnction.call.
+//
// Revision 1.12 2007/02/28 07:41:27 strk
// * server/array.{cpp,h}: allow resize trough
// setting the 'length' property.
@@ -163,57 +179,3 @@
// * testsuite/actionscript.all/array.as: added some tests for
// invalid calls to Array.slice()
//
-// Revision 1.10 2006/10/15 02:30:55 rsavoye
-// * testsuite/actionscript.all/swf_exists.exp: Use local_exec()
-// instead of spawn/expect. This works better with batch tests.
-// * testsuite/actionscript.all/check.as: Add xcheck and
-// xcheck_equals to handle expected failures.
-// * testsuite/actionscript.all/dejagnu.as: Add xpass and xfail to
-// handle expect failures.
-// * testsuite/actionscript.all/Boolean.as, Date.as, Global.as,
-// Inheritance.as, MovieClip.as, NetConnection.as, Number.as,
-// Object.as, Selection.as, array.as, delete.as, inheritance.as: Use
-// xcheck and xcheck_equals for tests expected to not work yet.
-// * testsuite/actionscript.all/XML.as, XMLNode.as: Use xpass and
-// xfail for tests expected to not work yet.
-//
-// Revision 1.9 2006/07/06 08:16:31 strk
-// Added instanceOf test for both new Array() and [...] constructors.
-//
-// Revision 1.8 2006/07/06 07:55:24 strk
-// "tostring" => "toString" (SWF 7 and up are case-sensitive in this); added
tests for Array constants.
-//
-// Revision 1.7 2006/06/20 20:45:27 strk
-// * testsuite/actionscript.all/: added rcsid variable
-// to all testfiles, had check.as print testfile info at
-// the beginning rather then at each check.
-//
-// Revision 1.6 2006/04/27 16:31:56 strk
-// * server/: (array.cpp, array.h): big cleanup, provided
-// overrides for get_member() and set_member() to add support
-// for the special 'length' element, turned array_as_object into
-// a real class.
-// * server/: (Object.cpp, Object.h): moved get_member
-// and set_member to get_member_default and set_member_default
-// with protected access level, provided public virtuals
-// invoking the protected non-virtuals. This is to allow cleaner
-// hooking for ActionScript classes.
-//
-// Revision 1.5 2006/04/27 09:37:00 strk
-// completed switch to check_equals() macro
-//
-// Revision 1.4 2006/04/27 07:27:25 strk
-// * testsuite/actionscript.all/array.as: turned length()
-// method calls to length data member accesses.
-//
-// Revision 1.3 2006/04/26 20:02:41 strk
-// More uses of the check_equals macro
-//
-// Revision 1.2 2006/02/14 08:17:51 corfe
-// Change all tests to use new check macro. Add tests for all implemented
array functions, as well as several tests for the unimplemented sort function.
-//
-// Revision 1.1 2006/02/01 11:43:16 strk
-// Added generic rule to build .swf from .as using makeswf (Ming).
-// Changed array.as source to avoid ActionScript2 constructs (class).
-// Added initial version of a movieclip AS class tester.
-//
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog server/array.cpp testsuite/acti...,
Sandro Santilli <=