[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r12262: Minor fixes to and implement
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r12262: Minor fixes to and implementation of flash.geom class functions. Some new |
Date: |
Sat, 19 Jun 2010 11:25:11 +0200 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 12262 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Sat 2010-06-19 11:25:11 +0200
message:
Minor fixes to and implementation of flash.geom class functions. Some new
passes in the swfdec testsuite.
modified:
libcore/asobj/flash/geom/Matrix_as.cpp
libcore/asobj/flash/geom/Rectangle_as.cpp
testsuite/actionscript.all/Rectangle.as
testsuite/swfdec/PASSING
=== modified file 'libcore/asobj/flash/geom/Matrix_as.cpp'
--- a/libcore/asobj/flash/geom/Matrix_as.cpp 2010-03-11 01:47:08 +0000
+++ b/libcore/asobj/flash/geom/Matrix_as.cpp 2010-06-19 08:40:55 +0000
@@ -664,6 +664,24 @@
ptr->get_member(NSV::PROP_TX, &tx);
ptr->get_member(NSV::PROP_TY, &ty);
+ VM& vm = getVM(fn);
+
+ as_value ret("(a=");
+ newAdd(ret, a, vm);
+ newAdd(ret, ", b=", vm);
+ newAdd(ret, b, vm);
+ newAdd(ret, ", c=", vm);
+ newAdd(ret, c, vm);
+ newAdd(ret, ", d=", vm);
+ newAdd(ret, d, vm);
+ newAdd(ret, ", tx=", vm);
+ newAdd(ret, tx, vm);
+ newAdd(ret, ", ty=", vm);
+ newAdd(ret, ty, vm);
+ newAdd(ret, ")", vm);
+
+ return ret;
+
std::ostringstream ss;
const int version = getSWFVersion(fn);
@@ -867,50 +885,18 @@
{
as_object* obj = ensure<ValidThis>(fn);
- as_value a, b, c, d, tx, ty;
-
- if (fn.nargs == 0)
- {
- a.set_double(1);
- b.set_double(0);
- c.set_double(0);
- d.set_double(1);
- tx.set_double(0);
- ty.set_double(0);
+ if (!fn.nargs) {
+ const string_table::key identity = getStringTable(fn).find("identity");
+ callMethod(obj, identity);
+ return as_value();
}
- else
- {
- switch (fn.nargs)
- {
- default:
- IF_VERBOSE_ASCODING_ERRORS(
- std::ostringstream ss;
- fn.dump_args(ss);
- log_aserror("Matrix(%s): discarding extra arguments",
ss.str());
- );
- case 6:
- ty = fn.arg(5);
- case 5:
- tx = fn.arg(4);
- case 4:
- d = fn.arg(3);
- case 3:
- c = fn.arg(2);
- case 2:
- b = fn.arg(1);
- case 1:
- a = fn.arg(0);
- break;
- }
- }
-
- obj->set_member(NSV::PROP_TY, ty);
- obj->set_member(NSV::PROP_TX, tx);
- obj->set_member(NSV::PROP_D, d);
- obj->set_member(NSV::PROP_C, c);
- obj->set_member(NSV::PROP_B, b);
- obj->set_member(NSV::PROP_A, a);
+ obj->set_member(NSV::PROP_A, fn.arg(0));
+ obj->set_member(NSV::PROP_B, fn.nargs > 1 ? fn.arg(1) : as_value());
+ obj->set_member(NSV::PROP_C, fn.nargs > 2 ? fn.arg(2) : as_value());
+ obj->set_member(NSV::PROP_D, fn.nargs > 3 ? fn.arg(3) : as_value());
+ obj->set_member(NSV::PROP_TX, fn.nargs > 4 ? fn.arg(4) : as_value());
+ obj->set_member(NSV::PROP_TY, fn.nargs > 5 ? fn.arg(5) : as_value());
return as_value();
}
=== modified file 'libcore/asobj/flash/geom/Rectangle_as.cpp'
--- a/libcore/asobj/flash/geom/Rectangle_as.cpp 2010-01-25 18:52:20 +0000
+++ b/libcore/asobj/flash/geom/Rectangle_as.cpp 2010-06-19 09:01:47 +0000
@@ -225,13 +225,56 @@
}
+
+// This is horrible ActionScript implemented in C++.
as_value
Rectangle_containsPoint(const fn_call& fn)
{
as_object* ptr = ensure<ValidThis>(fn);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
- return as_value();
+
+ as_object* arg = (fn.nargs > 0) ? fn.arg(0).to_object(getGlobal(fn)) : 0;
+
+ VM& vm = getVM(fn);
+
+ as_value thisx;
+ ptr->get_member(NSV::PROP_X, &thisx);
+ as_value argx;
+ if (arg) arg->get_member(NSV::PROP_X, &argx);
+
+ // argx >= thisx
+ as_value ret = newLessThan(argx, thisx, vm);
+ if (ret.is_undefined()) return as_value();
+ if (ret.to_bool()) return as_value(false);
+
+ as_value thisw;
+ ptr->get_member(NSV::PROP_WIDTH, &thisw);
+
+ newAdd(thisx, thisw, vm);
+ ret = newLessThan(argx, thisx, vm);
+ if (ret.is_undefined()) return as_value();
+ if (!ret.to_bool()) return as_value(false);
+
+ as_value thisy;
+ ptr->get_member(NSV::PROP_Y, &thisy);
+ as_value argy;
+ if (arg) arg->get_member(NSV::PROP_Y, &argy);
+
+ // argy >= thisy
+ ret = newLessThan(argy, thisy, vm);
+ if (ret.is_undefined()) return as_value();
+ if (ret.to_bool()) return as_value(false);
+
+ as_value thish;
+ ptr->get_member(NSV::PROP_HEIGHT, &thish);
+
+ newAdd(thisy, thish, vm);
+ ret = newLessThan(argy, thisy, vm);
+ if (ret.is_undefined()) return as_value();
+ if (!ret.to_bool()) return as_value(false);
+
+ return as_value(true);
+
+
}
as_value
@@ -334,8 +377,10 @@
Rectangle_setEmpty(const fn_call& fn)
{
as_object* ptr = ensure<ValidThis>(fn);
- UNUSED(ptr);
- LOG_ONCE( log_unimpl (__FUNCTION__) );
+ ptr->set_member(NSV::PROP_X, 0.0);
+ ptr->set_member(NSV::PROP_Y, 0.0);
+ ptr->set_member(NSV::PROP_WIDTH, 0.0);
+ ptr->set_member(NSV::PROP_HEIGHT, 0.0);
return as_value();
}
@@ -351,16 +396,19 @@
ptr->get_member(NSV::PROP_WIDTH, &w);
ptr->get_member(NSV::PROP_HEIGHT, &h);
- std::stringstream ss;
- const int version = getSWFVersion(fn);
-
- ss << "(x=" << x.to_string(version)
- << ", y=" << y.to_string(version)
- << ", w=" << w.to_string(version)
- << ", h=" << h.to_string(version)
- << ")";
-
- return as_value(ss.str());
+ VM& vm = getVM(fn);
+
+ as_value ret("(x=");
+ newAdd(ret, x, vm);
+ newAdd(ret, ", y=", vm);
+ newAdd(ret, y, vm);
+ newAdd(ret, ", w=", vm);
+ newAdd(ret, w, vm);
+ newAdd(ret, ", h=", vm);
+ newAdd(ret, h, vm);
+ newAdd(ret, ")", vm);
+
+ return ret;
}
as_value
@@ -609,41 +657,17 @@
as_object* obj = ensure<ValidThis>(fn);
- as_value x;
- as_value y;
- as_value w;
- as_value h;
-
- if ( ! fn.nargs )
- {
- x.set_double(0);
- y.set_double(0);
- w.set_double(0);
- h.set_double(0);
- }
- else
- {
- do {
- x = fn.arg(0);
- if ( fn.nargs < 2 ) break;
- y = fn.arg(1);
- if ( fn.nargs < 3 ) break;
- w = fn.arg(2);
- if ( fn.nargs < 4 ) break;
- h = fn.arg(3);
- if ( fn.nargs < 5 ) break;
- IF_VERBOSE_ASCODING_ERRORS(
- std::stringstream ss;
- fn.dump_args(ss);
- log_aserror("flash.geom.Rectangle(%s): %s", ss.str(),
_("arguments after the first four discarded"));
- );
- } while(0);
- }
-
- obj->set_member(NSV::PROP_X, x);
- obj->set_member(NSV::PROP_Y, y);
- obj->set_member(NSV::PROP_WIDTH, w);
- obj->set_member(NSV::PROP_HEIGHT, h);
+ if (!fn.nargs) {
+ const string_table::key setEmpty = getStringTable(fn).find("setEmpty");
+ callMethod(obj, setEmpty);
+ return as_value();
+ }
+
+ // At least one arg
+ obj->set_member(NSV::PROP_X, fn.arg(0));
+ obj->set_member(NSV::PROP_Y, fn.nargs > 1 ? fn.arg(1) : as_value());
+ obj->set_member(NSV::PROP_WIDTH, fn.nargs > 2 ? fn.arg(2) : as_value());
+ obj->set_member(NSV::PROP_HEIGHT, fn.nargs > 3 ? fn.arg(3) : as_value());
return as_value();
}
=== modified file 'testsuite/actionscript.all/Rectangle.as'
--- a/testsuite/actionscript.all/Rectangle.as 2010-01-01 17:48:26 +0000
+++ b/testsuite/actionscript.all/Rectangle.as 2010-06-19 09:00:01 +0000
@@ -358,6 +358,20 @@
// Test containsPoint
//-------------------------------------------------------------
+r0 = new Rectangle(10, 10, 15, 16);
+check_equals(r0.containsPoint({x:4, y:6}), false);
+check_equals(r0.containsPoint({x:11, y:11}), true);
+check_equals(r0.containsPoint({x:10, y:10}), true);
+check_equals(r0.containsPoint({x:10, y:26}), false);
+check_equals(r0.containsPoint({x:10, y:25.9}), true);
+check_equals(r0.containsPoint({x:24.9, y:25.9}), true);
+check_equals(r0.containsPoint({x:25, y:10}), false);
+check_equals(r0.containsPoint({x:-25, y:-10}), false);
+
+check_equals(r0.containsPoint({x:13, y:undefined}), undefined);
+check_equals(r0.containsPoint({x:undefined, y:14}), undefined);
+check_equals(r0.containsPoint({x:"12", y:"12"}), true);
+
// TODO
//-------------------------------------------------------------
@@ -424,6 +438,6 @@
// END OF TEST
//-------------------------------------------------------------
-check_totals(149);
+check_totals(160);
#endif // OUTPUT_VERSION >= 8
=== modified file 'testsuite/swfdec/PASSING'
--- a/testsuite/swfdec/PASSING 2010-06-17 11:36:16 +0000
+++ b/testsuite/swfdec/PASSING 2010-06-19 08:43:49 +0000
@@ -735,6 +735,9 @@
math-function-valueOf-7.swf:f8229fa4a2409b13dfba252d00773a74
math-function-valueOf-8.swf:a460031e38bf76f310846f670677eaff
matrix-construct-5.swf:bfc2176f4495b5f7465afd1a6f489ead
+matrix-construct-6.swf:0b412fd064bece38e9a6f117f4c4fb7a
+matrix-construct-7.swf:afb3b2cffcea0c30e794e7e1d134c406
+matrix-construct-8.swf:7d6b71c0562113b037ff83e1aa838123
matrix-properties-5.swf:a80d726dfde5b460add76a7532e7ee01
matrix-properties-6.swf:a7934cc5476219b199a40c4feb627dfe
matrix-properties-7.swf:144e6c666febf556bec9864ee234a54a
@@ -1068,6 +1071,9 @@
random-negative-7.swf:c37d945ee37e2c79771fc24048c2cb05
random-negative-8.swf:aa9dea7841d517b54711660bf666da0e
rectangle-construct-5.swf:346164542dbfc9715da30ee9ea011373
+rectangle-construct-6.swf:4a5a2a553b5dcb00f7fabd4a9bc33311
+rectangle-construct-7.swf:2baee75083f2c286afce030a5294e81e
+rectangle-construct-8.swf:a8956560274b9557dab1380d802b2b9f
rectangle-equals-5.swf:a32beb36b2e690320c9d88e3130cb600
rectangle-properties-5.swf:b9926dc51714320ff06eddb544ae9260
rectangle-properties-7.swf:48616a870f18a7f29553a3579db8a19f
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r12262: Minor fixes to and implementation of flash.geom class functions. Some new,
Benjamin Wolsey <=