[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11415: Various fixes, tests and tes
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11415: Various fixes, tests and test passes. |
Date: |
Thu, 13 Aug 2009 12:38:14 +0200 |
User-agent: |
Bazaar (1.16.1) |
------------------------------------------------------------
revno: 11415 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Thu 2009-08-13 12:38:14 +0200
message:
Various fixes, tests and test passes.
modified:
libcore/asobj/Date_as.cpp
libcore/asobj/Globals.cpp
libcore/asobj/TextFormat_as.cpp
libcore/asobj/flash/accessibility/Accessibility_as.cpp
libcore/asobj/flash/display/BitmapData_as.cpp
testsuite/actionscript.all/BitmapData.as
testsuite/actionscript.all/Global.as
testsuite/actionscript.all/Instance.as
testsuite/swfdec/PASSING
=== modified file 'libcore/asobj/Date_as.cpp'
--- a/libcore/asobj/Date_as.cpp 2009-07-29 05:40:20 +0000
+++ b/libcore/asobj/Date_as.cpp 2009-08-13 09:20:28 +0000
@@ -145,7 +145,6 @@
template<bool utc> as_value date_setSeconds(const fn_call& fn);
as_value date_setYear(const fn_call& fn);
as_value date_tostring(const fn_call& fn);
- as_value date_valueof(const fn_call& fn);
as_value date_UTC(const fn_call& fn);
void fillGnashTime(double time, GnashTime& gt);
@@ -210,20 +209,21 @@
void
Date_as::init(as_object& global, const ObjectURI& uri)
{
- // This is going to be the global Date "class"/"function"
- static boost::intrusive_ptr<as_object> cl;
-
- if ( cl == NULL ) {
- Global_as* gl = getGlobal(global);
- as_object* proto = getDateInterface();
- cl = gl->createClass(&date_new, proto);
-
- // replicate static interface to class (Date.UTC)
- attachDateStaticInterface(*cl);
- }
+
+ Global_as* gl = getGlobal(global);
+ as_object* proto = getDateInterface();
+ as_object* cl = gl->createClass(&date_new, proto);
+
+ const int flags = PropFlags::readOnly;
+ cl->set_member_flags(NSV::PROP_uuPROTOuu, flags);
+ cl->set_member_flags(NSV::PROP_CONSTRUCTOR, flags);
+ cl->set_member_flags(NSV::PROP_PROTOTYPE, flags);
+
+ // Attach static interface to class (Date.UTC)
+ attachDateStaticInterface(*cl);
// Register _global.Date
- global.init_member(getName(uri), cl.get(), as_object::DefaultFlags,
+ global.init_member(getName(uri), cl, as_object::DefaultFlags,
getNamespace(uri));
}
@@ -340,7 +340,6 @@
void
attachDateInterface(as_object& o)
{
- Global_as* gl = getGlobal(o);
VM& vm = getVM(o);
o.init_member("getFullYear", vm.getNative(103, 0));
@@ -380,7 +379,9 @@
o.init_member("setUTCMinutes", vm.getNative(103, 141));
o.init_member("setUTCSeconds", vm.getNative(103, 142));
o.init_member("setUTCMilliseconds", vm.getNative(103, 143));
- o.init_member("valueOf", gl->createFunction(date_valueof));
+
+ string_table& st = getStringTable(o);
+ o.init_member("valueOf", o.getMember(st.find("getTime")));
}
@@ -388,7 +389,8 @@
attachDateStaticInterface(as_object& o)
{
VM& vm = getVM(o);
- o.init_member("UTC", vm.getNative(103, 257));
+ const int flags = as_object::DefaultFlags | PropFlags::readOnly;
+ o.init_member("UTC", vm.getNative(103, 257), flags);
}
as_object*
@@ -1342,17 +1344,9 @@
return(0.0);
}
-/// \brief Date.valueOf() returns the number of milliseconds since midnight
+/// \brief Date.getTime() returns the number of milliseconds since midnight
/// January 1, 1970 00:00 UTC, for a Date. The return value can be a fractional
/// number of milliseconds.
-as_value
-date_valueof(const fn_call& fn)
-{
- boost::intrusive_ptr<Date_as> date = ensureType<Date_as>(fn.this_ptr);
- return as_value(date->getTimeValue());
-}
-
-
as_value date_getTime(const fn_call& fn)
{
boost::intrusive_ptr<Date_as> date = ensureType<Date_as>(fn.this_ptr);
=== modified file 'libcore/asobj/Globals.cpp'
--- a/libcore/asobj/Globals.cpp 2009-08-11 09:15:29 +0000
+++ b/libcore/asobj/Globals.cpp 2009-08-13 08:52:05 +0000
@@ -954,12 +954,79 @@
return as_value();
}
-// ASSetNative function
-// TODO: find dox
+
+/// ASSetNative(targetObject, major, properties, minor)
+//
+/// Sets a series of properties on targetObject using the native table.
+/// The third argument is generally documented to be an array, but in fact
+/// it is always converted to a string and parsed.
as_value
-global_assetnative(const fn_call& /*fn*/)
+global_assetnative(const fn_call& fn)
{
- LOG_ONCE(log_unimpl("ASSetNative"));
+
+ if (fn.nargs < 3) {
+ return as_value();
+ }
+
+ Global_as* gl = getGlobal(fn);
+
+ as_object* targetObject = fn.arg(0).to_object(*gl).get();
+ if (!targetObject) {
+ return as_value();
+ }
+
+ const int major = fn.arg(1).to_int();
+ if (major < 0) return as_value();
+
+ const std::string& props = fn.arg(2).to_string();
+ const int minor = fn.nargs > 3 ? std::max(fn.arg(3).to_int(), 0) : 0;
+
+ std::string::const_iterator pos = props.begin();
+
+ VM& vm = getVM(fn);
+
+ size_t i = 0;
+
+ // pos is always the position after the last located property.
+ while (pos != props.end()) {
+
+ // If there are no further commas, find the end of the string.
+ std::string::const_iterator comma = std::find(pos, props.end(), ',');
+
+ const char num = *pos;
+
+ int flag;
+
+ switch (num) {
+ case '6':
+ flag = PropFlags::onlySWF6Up;
+ ++pos;
+ break;
+ case '7':
+ flag = PropFlags::onlySWF7Up;
+ ++pos;
+ break;
+ case '8':
+ flag = PropFlags::onlySWF8Up;
+ ++pos;
+ break;
+ case '9':
+ flag = PropFlags::onlySWF9Up;
+ ++pos;
+ break;
+ default:
+ flag = 0;
+
+ }
+ const std::string& property = std::string(pos, comma);
+ if (!property.empty()) {
+ targetObject->init_member(property,
+ vm.getNative(major, minor + i), flag);
+ }
+ if (comma == props.end()) break;
+ pos = comma + 1;
+ ++i;
+ }
return as_value();
}
=== modified file 'libcore/asobj/TextFormat_as.cpp'
--- a/libcore/asobj/TextFormat_as.cpp 2009-08-12 17:03:54 +0000
+++ b/libcore/asobj/TextFormat_as.cpp 2009-08-13 07:22:56 +0000
@@ -124,13 +124,12 @@
TextFormat_as::TextFormat_as()
:
as_object(getTextFormatInterface()),
-
_flags(0),
_underline(false),
_bold(false),
- _display(),
_italic(false),
_bullet(false),
+ _display(),
_align(TextField::ALIGN_LEFT),
_blockIndent(-1),
_color(),
@@ -153,18 +152,12 @@
void
TextFormat_as::init(as_object& global, const ObjectURI& uri)
{
- // This is going to be the global Color "class"/"function"
- static boost::intrusive_ptr<as_object> cl;
-
- if ( cl == NULL )
- {
- Global_as* gl = getGlobal(global);
- as_object* proto = getTextFormatInterface();
- cl = gl->createClass(&textformat_new, proto);
- }
-
- // Register _global.Color
- global.init_member(getName(uri), cl.get(), as_object::DefaultFlags,
+
+ Global_as* gl = getGlobal(global);
+ as_object* proto = getTextFormatInterface();
+ as_object* cl = gl->createClass(&textformat_new, proto);
+
+ global.init_member(getName(uri), cl, as_object::DefaultFlags,
getNamespace(uri));
}
=== modified file 'libcore/asobj/flash/accessibility/Accessibility_as.cpp'
--- a/libcore/asobj/flash/accessibility/Accessibility_as.cpp 2009-07-28
11:58:27 +0000
+++ b/libcore/asobj/flash/accessibility/Accessibility_as.cpp 2009-08-13
07:04:21 +0000
@@ -35,8 +35,8 @@
// Forward declarations
namespace {
as_value accessibility_ctor(const fn_call& fn);
- void attachAccessibilityInterface(as_object& o);
void attachAccessibilityStaticInterface(as_object& o);
+ void attachAccessibilityAS3StaticInterface(as_object& o);
as_object* getAccessibilityInterface();
as_value Accessibility_isActive(const fn_call& fn);
@@ -45,82 +45,57 @@
as_value Accessibility_sendEvent(const fn_call& fn);
}
-class Accessibility_as : public as_object
-{
-
-public:
-
- Accessibility_as()
- :
- as_object(getAccessibilityInterface())
- {}
-};
-
// extern (used by Global.cpp)
-void accessibility_class_init(as_object& where, const ObjectURI& uri)
+void
+accessibility_class_init(as_object& where, const ObjectURI& uri)
{
- boost::intrusive_ptr<as_object> obj = new as_object(getObjectInterface());
- attachAccessibilityInterface(*obj);
+ Global_as* gl = getGlobal(where);
+ as_object* proto = getObjectInterface();
+
+ const int flags = as_object::DefaultFlags | PropFlags::readOnly;
+
+ // This object has unusual properties.
+ as_object* obj = gl->createObject(proto);
+ obj->set_member_flags(NSV::PROP_uuPROTOuu, flags);
+ obj->init_member(NSV::PROP_CONSTRUCTOR, gl->getMember(NSV::CLASS_OBJECT),
+ flags);
+
+ attachAccessibilityStaticInterface(*obj);
+
// Register _global.Accessibility
- where.init_member(getName(uri), obj.get(), as_object::DefaultFlags,
+ where.init_member(getName(uri), obj, as_object::DefaultFlags,
getNamespace(uri));
}
namespace {
void
-attachAccessibilityInterface(as_object& o)
+attachAccessibilityAS3StaticInterface(as_object& o)
{
Global_as* gl = getGlobal(o);
- const int flags = PropFlags::dontDelete
- | PropFlags::readOnly;
+ o.init_member("active", gl->createFunction(Accessibility_active));
+}
- const VM& vm = getVM(o);
- // For swf v9 or greater, the isActive() method has been changed to a
- // the property "active".
- if ( vm.getSWFVersion() >= 9 ) {
- o.init_member("active", gl->createFunction(Accessibility_active), flags);
- } else {
- o.init_member("isActive", gl->createFunction(Accessibility_isActive),
flags);
- o.init_member("sendEvent", gl->createFunction(Accessibility_sendEvent),
flags);
- }
+void
+attachAccessibilityStaticInterface(as_object& o)
+{
+ Global_as* gl = getGlobal(o);
+ const int flags = PropFlags::dontDelete |
+ PropFlags::readOnly;
+
+ o.init_member("isActive",
+ gl->createFunction(Accessibility_isActive), flags);
+ o.init_member("sendEvent",
+ gl->createFunction(Accessibility_sendEvent), flags);
o.init_member("updateProperties",
gl->createFunction(Accessibility_updateProperties), flags);
-
-}
-
-void
-attachAccessibilityStaticInterface(as_object& /*o*/)
-{
-}
-
-as_object*
-getAccessibilityInterface()
-{
- static boost::intrusive_ptr<as_object> o;
- if ( ! o ) {
- o = new as_object();
- attachAccessibilityInterface(*o);
- }
- return o.get();
-}
-
-as_value
-accessibility_ctor(const fn_call& /*fn*/)
-{
- boost::intrusive_ptr<as_object> obj = new Accessibility_as;
-
- return as_value(obj.get()); // will keep alive
-}
-
-
-as_value
-Accessibility_isActive(const fn_call& fn)
-{
- boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
- UNUSED(ptr);
+}
+
+as_value
+Accessibility_isActive(const fn_call& /*fn*/)
+{
LOG_ONCE( log_unimpl (__FUNCTION__) );
return as_value();
}
@@ -128,30 +103,20 @@
as_value
Accessibility_active(const fn_call& /*fn*/)
{
- GNASH_REPORT_FUNCTION;
-
-// boost::intrusive_ptr<as_object> ptr =
ensureType<as_object>(fn.this_ptr);
-// UNUSED(ptr);
LOG_ONCE( log_unimpl (__FUNCTION__) );
return as_value(false);
}
as_value
-Accessibility_updateProperties(const fn_call& fn)
+Accessibility_updateProperties(const fn_call& /*fn*/)
{
- GNASH_REPORT_FUNCTION;
- boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
- UNUSED(ptr);
LOG_ONCE( log_unimpl (__FUNCTION__) );
return as_value();
}
as_value
-Accessibility_sendEvent(const fn_call& fn)
+Accessibility_sendEvent(const fn_call& /*fn*/)
{
- GNASH_REPORT_FUNCTION;
- boost::intrusive_ptr<as_object> ptr = ensureType<as_object>(fn.this_ptr);
- UNUSED(ptr);
LOG_ONCE( log_unimpl (__FUNCTION__) );
return as_value();
}
=== modified file 'libcore/asobj/flash/display/BitmapData_as.cpp'
--- a/libcore/asobj/flash/display/BitmapData_as.cpp 2009-07-29 05:40:20
+0000
+++ b/libcore/asobj/flash/display/BitmapData_as.cpp 2009-08-13 07:55:40
+0000
@@ -685,8 +685,11 @@
{
if (fn.nargs < 2) {
- // TODO: should fail if not enough arguments are passed.
- return as_value();
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("BitmapData constructor requires at least two "
+ "arguments. Will not construct a BitmapData");
+ );
+ throw ActionTypeError();
}
size_t width, height;
@@ -709,8 +712,13 @@
}
// FIXME: Should fail to construct the object.
- if (width > 2880 || height > 2880) return as_value();
- if (width < 1 || height < 1) return as_value();
+ if (width > 2880 || height > 2880 || width < 1 || height < 1) {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("BitmapData width and height must be between "
+ "1 and 2880. Will not construct a BitmapData");
+ );
+ throw ActionTypeError();
+ }
boost::intrusive_ptr<BitmapData_as> obj =
new BitmapData_as(width, height, transparent, fillColor);
=== modified file 'testsuite/actionscript.all/BitmapData.as'
--- a/testsuite/actionscript.all/BitmapData.as 2009-05-25 13:46:33 +0000
+++ b/testsuite/actionscript.all/BitmapData.as 2009-08-13 09:05:48 +0000
@@ -72,7 +72,7 @@
//-------------------------------------------------------------
bmp = new Bitmap();
-xcheck_equals(typeof(bmp), "undefined");
+check_equals(typeof(bmp), "undefined");
bmp = new Bitmap(10, 10);
check_equals(typeof(bmp), 'object');
@@ -117,11 +117,11 @@
// 2880 is the maximum, 1 the minimum. Returns
// undefined if the dimensions are invalid.
bmp = new Bitmap(10000, 3);
-xcheck_equals(typeof(bmp), "undefined");
+check_equals(typeof(bmp), "undefined");
check_equals(bmp.height, undefined);
bmp = new Bitmap(0, 10000);
-xcheck_equals(bmp, undefined);
+check_equals(bmp, undefined);
check_equals(bmp.height, undefined);
bmp = new Bitmap(2880, 2880);
@@ -129,11 +129,11 @@
check_equals(bmp.height, 2880);
bmp = new Bitmap(2880, 2881);
-xcheck_equals(typeof(bmp), "undefined");
+check_equals(typeof(bmp), "undefined");
check_equals(bmp.height, undefined);
bmp = new Bitmap(0, 2880);
-xcheck_equals(bmp, undefined);
+check_equals(bmp, undefined);
check_equals(bmp.height, undefined);
bmp = new Bitmap(2879, 2879);
@@ -141,11 +141,11 @@
check_equals(bmp.height, 2879);
bmp = new Bitmap(0, 2879);
-xcheck_equals(bmp, undefined);
+check_equals(bmp, undefined);
check_equals(bmp.height, undefined);
bmp = new Bitmap(-1, 10, false, 0xff);
-xcheck_equals(bmp, undefined);
+check_equals(bmp, undefined);
check_equals(bmp.height, undefined);
// --------------------
=== modified file 'testsuite/actionscript.all/Global.as'
--- a/testsuite/actionscript.all/Global.as 2009-06-16 10:07:54 +0000
+++ b/testsuite/actionscript.all/Global.as 2009-08-13 09:03:10 +0000
@@ -471,16 +471,46 @@
// END OF TEST
//------------------------------------------------------------
+// Test _global.ASSetNative
+
+o = new Object();
+ASSetNative(o, 103, "q, w, e,6z,6u,7u, 7i, t,z,u");
+r = "";
+for (i in o) { r+=i + ","; };
+check_equals(r, " t, 7i,u,z, e, w,q,");
+
+// Check that toString() is called.
+var o = new Object ();
+var a = ["i", "u"];
+a.toString = function() { trace ("toString called"); return "o, j"; };
+ASSetNative (o, 200, a, 10);
+
+r = "";
+for (i in o) { r += i + ","; };
+// It's not what's in the array (i, u), but what's returned by its toString
+// method ("o,j");
+check_equals(r, " j,o,");
+
+// The function is not dependent on the present of the ASnative function.
+ASnative = 56;
+o = new Object();
+ASSetNative (o, 200, "k,j,l", 10);
+
+r = "";
+for (i in o) { r += i + ","; };
+check_equals(r, "l,j,k,");
+
+
#if OUTPUT_VERSION == 5
- check_totals(155); // SWF5
+ check_totals(158); // SWF5
#else
# if OUTPUT_VERSION == 6
- check_totals(189); // SWF6
+ check_totals(192); // SWF6
# else
# if OUTPUT_VERSION == 7
- check_totals(171); // SWF7
+ check_totals(174); // SWF7
# else
- check_totals(158); // SWF8+
+ check_totals(161); // SWF8+
# endif
# endif
#endif
=== modified file 'testsuite/actionscript.all/Instance.as'
--- a/testsuite/actionscript.all/Instance.as 2009-02-25 22:33:03 +0000
+++ b/testsuite/actionscript.all/Instance.as 2009-08-13 09:04:55 +0000
@@ -118,12 +118,7 @@
// It should be undefined in SWF8 because the object isn't constructed when the
// given values are incorrect.
o = new flash.display.BitmapData();
-#if OUTPUT_VERSION < 8
check_equals(typeof(o), "undefined");
check_equals(o, undefined);
-#else
-xcheck_equals(typeof(o), "undefined");
-xcheck_equals(o, undefined);
-#endif
check_totals(34);
=== modified file 'testsuite/swfdec/PASSING'
--- a/testsuite/swfdec/PASSING 2009-08-12 15:02:36 +0000
+++ b/testsuite/swfdec/PASSING 2009-08-13 09:21:40 +0000
@@ -2,6 +2,10 @@
abort-really-aborts-6.swf:b932b86a10e5668e2e85d5cca0662b4f
abort-really-aborts-7.swf:2f7ae8e5595e0dec523ea46107683025
abort-really-aborts-8.swf:cfd60440f939844201b7bc405a75d662
+accessibility-properties-5.swf:8276a40c5861667971ee252aaf7acde7
+accessibility-properties-6.swf:e82d89d21d3d59b66e3caf987fe55423
+accessibility-properties-7.swf:8a8533bd2bc9269d502b020561321312
+accessibility-properties-8.swf:5bc64728f025d67638d46d3570f87dbf
add2-5.swf:c286fa19d9adbc133e211f836625c298
add2-6.swf:a569da2f9c30f43b020ceaa1d5eb96a6
add2-7.swf:60923badd220f89cb2d6a6e3380654b6
@@ -72,6 +76,11 @@
asnative-create-6.swf:79aa26f566218edbdecdb46e88be7a1a
asnative-create-7.swf:b3f18c999ed081ac39132ec6a9df2cb0
asnative-create-8.swf:8f98f662b43c0794fc7b85bd91f07d39
+assetnative-5.swf:9bb10e1455b4e163f06369746405cdf6
+assetnative-6.swf:49de8b9ad29d26be4cf10dcc9cf3074b
+assetnative-7.swf:a1159ab53a5fa5475b2c69d226cbdfd6
+assetnative-8.swf:3d286484e3062f2b4783d1050a7c7a21
+assetnative-9.swf:df22e729bf4cbea130119dd775e6c6bf
ASSetPropFlags-ignore-5.swf:c4e6df938c3b197cf816e2eb5be64756
ASSetPropFlags-ignore-5.swf:e94bd74cf8c9e8d063b74b8cbcf1ae95
ASSetPropFlags-ignore-6.swf:304d494ef49c6692685327c3db5fb3b0
@@ -328,6 +337,10 @@
dangling-print-6.swf:9c079b270d7ce76fbb1f0209a01de3c6
dangling-print-7.swf:5338574e04b055fe168b443a5ca1da98
dangling-print-8.swf:3a8af45c5348dd5da7417b75d7aef8c6
+date-properties-5.swf:779e491ed8ce37be2b4306f72575a13e
+date-properties-6.swf:e246c85257128201c3d3ea0cada21e2b
+date-properties-7.swf:82a3f3308c84be06475a1a8e6677715e
+date-properties-8.swf:9275619eac3031bf14ff656d3f96a67f
date-set-multiple-5.swf:42e397f0380fd6e0ba4331e1cfe5cede
date-set-multiple-6.swf:19e0539c29244563f8ac7ceadf2f561d
date-set-multiple-7.swf:55ab4407ed40093961215c1e9d321a8f
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11415: Various fixes, tests and test passes.,
Benjamin Wolsey <=