[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/asobj/Object.cpp testsui...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/asobj/Object.cpp testsui... |
Date: |
Thu, 01 Feb 2007 11:57:20 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/02/01 11:57:20
Modified files:
. : ChangeLog
server/asobj : Object.cpp
testsuite/actionscript.all: Number.as Object.as
Log message:
* testsuite/actionscript.all/Object.as: add tests for toString
and valueOf. The latter doesn't work yet.
* server/asobj/Object.cpp: add valueOf and toString methods,
make addProperty availability version-dependent (only if SWF
> 5)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2213&r2=1.2214
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Object.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Number.as?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Object.as?cvsroot=gnash&r1=1.18&r2=1.19
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2213
retrieving revision 1.2214
diff -u -b -r1.2213 -r1.2214
--- ChangeLog 1 Feb 2007 11:23:56 -0000 1.2213
+++ ChangeLog 1 Feb 2007 11:57:19 -0000 1.2214
@@ -1,5 +1,9 @@
2007-02-01 Sandro Santilli <address@hidden>
+ * testsuite/actionscript.all/Object.as: add tests for toString
+ and valueOf. The latter doesn't work yet.
+ * server/asobj/Object.cpp: add valueOf and toString methods,
+ make addProperty availability version-dependent (only if SWF > 5)
* server/as_object.{cpp,h}: add generic and reusable
actionscript method handlers for toString() and
valueOf().
Index: server/asobj/Object.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Object.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- server/asobj/Object.cpp 18 Jan 2007 22:53:21 -0000 1.11
+++ server/asobj/Object.cpp 1 Feb 2007 11:57:19 -0000 1.12
@@ -18,7 +18,7 @@
//
//
-/* $Id: Object.cpp,v 1.11 2007/01/18 22:53:21 strk Exp $ */
+/* $Id: Object.cpp,v 1.12 2007/02/01 11:57:19 strk Exp $ */
// Implementation of ActionScript Object class.
@@ -32,6 +32,7 @@
#include "character.h" // for Object.registerClass (get_root_movie)
#include "sprite_instance.h" // for Object.registerClass
(get_movie_definition)
#include "sprite_definition.h" // for Object.registerClass
(get_movie_definition)
+#include "VM.h" // for SWF version (attachObjectInterface)
#include "log.h"
@@ -48,11 +49,21 @@
static void
attachObjectInterface(as_object& o)
{
+ int target_version = o.getVM().getSWFVersion();
+
// FIXME: add Object interface here:
- o.init_member("addProperty", &object_addproperty);
- o.set_member_flags("addProperty", 1); // hidden
o.init_member("registerClass", &object_registerClass);
o.set_member_flags("registerClass", 1); // hidden
+
+ // Object.valueOf()
+ o.init_member("valueOf", &as_object::valueof_method);
+
+ // Object.toString()
+ o.init_member("toString", &as_object::tostring_method);
+
+ if ( target_version < 6 ) return;
+ o.init_member("addProperty", &object_addproperty);
+ o.set_member_flags("addProperty", 1); // hidden
}
static as_object*
Index: testsuite/actionscript.all/Number.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Number.as,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- testsuite/actionscript.all/Number.as 1 Feb 2007 11:23:56 -0000
1.9
+++ testsuite/actionscript.all/Number.as 1 Feb 2007 11:57:20 -0000
1.10
@@ -26,7 +26,7 @@
// TODO: test with SWF target != 6 (the only one tested so far)
//
-rcsid="$Id: Number.as,v 1.9 2007/02/01 11:23:56 strk Exp $";
+rcsid="$Id: Number.as,v 1.10 2007/02/01 11:57:20 strk Exp $";
#include "check.as"
@@ -47,21 +47,16 @@
check_equals(typeof(n1.toString), "function");
check_equals(typeof(n1.toString()), "string");
check_equals(n1.toString(), "268");
-#if OUTPUT_VERSION > 5
-check(Number.prototype.toString != Object.prototype.toString);
-#else
-// equality of function for SW5 makes no sense, it seems
-xcheck_equals(Number.prototype.toString, Object.prototype.toString);
-#endif
+var backup = Object.prototype.toString;
+Object.prototype.toString = function() { return "fake_string"; };
+check_equals(n1.toString(), "268"); // doesn't inherit from Object
+Object.prototype.toString = backup;
// Test Number.valueOf
check_equals(typeof(n1.valueOf), "function");
check_equals(typeof(n1.valueOf()), "number");
-check_equals(n1.toString(), 268);
-#if OUTPUT_VERSION > 5
-check(Number.prototype.valueOf != Object.prototype.valueOf);
-#else
-// equality of function for SW5 makes no sense, it seems
-xcheck_equals(Number.prototype.valueOf, Object.prototype.valueOf);
-#endif
-
+check_equals(n1.valueOf(), 268);
+var backup = Object.prototype.valueOf;
+Object.prototype.valueOf = function() { return "fake_value"; };
+check_equals(n1.valueOf(), 268); // doesn't inherit from Object
+Object.prototype.valueOf = backup;
Index: testsuite/actionscript.all/Object.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Object.as,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- testsuite/actionscript.all/Object.as 27 Nov 2006 00:53:46 -0000
1.18
+++ testsuite/actionscript.all/Object.as 1 Feb 2007 11:57:20 -0000
1.19
@@ -20,19 +20,43 @@
// compile this test case with Ming makeswf, and then
// execute it like this gnash -1 -r 0 -v out.swf
-rcsid="$Id: Object.as,v 1.18 2006/11/27 00:53:46 strk Exp $";
+rcsid="$Id: Object.as,v 1.19 2007/02/01 11:57:20 strk Exp $";
#include "check.as"
+// Test existance of methods
+check_equals(typeof(Object), 'function');
+check_equals(typeof(Object.prototype), 'object');
+check_equals(typeof(Object.prototype.toString), 'function');
+check_equals(typeof(Object.prototype.valueOf), 'function');
+#if OUTPUT_VERSION > 5
+check_equals(typeof(Object.prototype.addProperty), 'function');
+#else
+check_equals(typeof(Object.prototype.addProperty), 'undefined');
+#endif
+
// Test Object creation using 'new'
var obj = new Object; // uses SWFACTION_NEWOBJECT
check (obj != undefined);
check (typeof(obj) == "object");
check (obj.__proto__.constructor == Object);
+// Test instantiated Object methods
+check_equals(typeof(obj.toString), 'function');
+check_equals(typeof(obj.valueOf), 'function');
+#if OUTPUT_VERSION > 5
+check_equals(typeof(obj.addProperty), 'function');
+#else
+check_equals(typeof(obj.addProperty), 'undefined');
+#endif
+
// Test instantiated Object members
obj.member = 1;
check (obj.member == 1)
+check_equals(typeof(obj.toString()), 'string');
+check_equals(obj.toString(), '[object Object]');
+xcheck_equals(typeof(obj.valueOf()), 'object');
+check_equals(obj.valueOf(), obj);
// Test Object creation using literal initialization
var obj2 = { member:1 }; // uses SWFACTION_INITOBJECT
@@ -74,6 +98,9 @@
// Test addProperty
//----------------------
+// Object.addProperty wasn't in SWF5
+#if OUTPUT_VERSION > 5
+
// the 'getter' function
function getLen() {
return this._len;
@@ -118,6 +145,8 @@
check_equals (inh2.len, 7);
check_equals (proto.len, undefined);
+// Object.addProperty wasn't in SWF5
+#endif // OUTPUT_VERSION > 5
//----------------------
// Test enumeration
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog server/asobj/Object.cpp testsui...,
Sandro Santilli <=