[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10637: Minor fixes and code cleanup
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10637: Minor fixes and code cleanup for flash package classes. |
Date: |
Fri, 27 Feb 2009 12:55:27 +0100 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10637
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Fri 2009-02-27 12:55:27 +0100
message:
Minor fixes and code cleanup for flash package classes.
Use as_environment::find_object() to make code more readable and reduce
duplication.
Correct return values when objects are overwritten. Use versioned strings.
Passes in actionscript.all and swfdec.
modified:
libcore/MovieClip.cpp
libcore/asobj/flash/display/BitmapData_as.cpp
libcore/asobj/flash/geom/ColorTransform_as.cpp
libcore/asobj/flash/geom/Matrix_as.cpp
libcore/asobj/flash/geom/Rectangle_as.cpp
libcore/asobj/flash/geom/Transform_as.cpp
testsuite/actionscript.all/BitmapData.as
testsuite/actionscript.all/Matrix.as
testsuite/swfdec/PASSING
=== modified file 'libcore/MovieClip.cpp'
--- a/libcore/MovieClip.cpp 2009-02-10 15:38:43 +0000
+++ b/libcore/MovieClip.cpp 2009-02-27 11:55:27 +0000
@@ -5238,64 +5238,26 @@
as_value
movieclip_transform(const fn_call& fn)
{
- boost::intrusive_ptr<MovieClip> ptr =
- ensureType<MovieClip>(fn.this_ptr);
-
- VM& vm = ptr->getVM();
- string_table& st = ptr->getVM().getStringTable();
-
- as_value flash;
- if (!vm.getGlobal()->get_member(st.find("flash"), &flash))
- {
- log_error("No flash object found!");
- return as_value();
- }
- boost::intrusive_ptr<as_object> flashObj = flash.to_object();
-
- if (!flashObj)
- {
- log_error("flash isn't an object!");
- return as_value();
- }
-
- as_value geom;
- if (!flashObj->get_member(st.find("geom"), &geom))
- {
- log_error("No flash.geom object found!");
- return as_value();
- }
- boost::intrusive_ptr<as_object> geomObj = geom.to_object();
-
- if (!geomObj)
- {
- log_error("flash.geom isn't an object!");
- return as_value();
- }
-
- as_value transform;
- if (!geomObj->get_member(st.find("Transform"), &transform))
- {
- log_error("No flash.geom.Transform object found!");
- return as_value();
- }
-
- boost::intrusive_ptr<as_function> transformCtor =
- transform.to_as_function();
-
- if (!transformCtor)
- {
- log_error("flash.geom.Transform isn't a function!");
+ boost::intrusive_ptr<MovieClip> ptr = ensureType<MovieClip>(fn.this_ptr);
+
+ // If not found, construction fails.
+ as_value transform(fn.env().find_object("flash.geom.Transform"));
+
+ boost::intrusive_ptr<as_function> transCtor = transform.to_as_function();
+
+ if (!transCtor) {
+ log_error("Failed to construct flash.geom.Transform!");
return as_value();
}
// Construct a flash.geom.Transform object with "this" as argument.
- std::auto_ptr< std::vector<as_value> > args (new std::vector<as_value>);
+ std::auto_ptr<std::vector<as_value> > args(new std::vector<as_value>);
args->push_back(ptr.get());
- boost::intrusive_ptr<as_object> transformObj =
- transformCtor->constructInstance(fn.env(), args);
+ boost::intrusive_ptr<as_object> newTrans =
+ transCtor->constructInstance(fn.env(), args);
- return as_value(transformObj.get());
+ return as_value(newTrans.get());
}
/// Properties (and/or methods) attached to every *instance* of a MovieClip
=== modified file 'libcore/asobj/flash/display/BitmapData_as.cpp'
--- a/libcore/asobj/flash/display/BitmapData_as.cpp 2009-02-25 22:33:03
+0000
+++ b/libcore/asobj/flash/display/BitmapData_as.cpp 2009-02-27 11:55:27
+0000
@@ -564,20 +564,34 @@
as_value
BitmapData_rectangle(const fn_call& fn)
{
- boost::intrusive_ptr<BitmapData_as> ptr =
ensureType<BitmapData_as>(fn.this_ptr);
+ boost::intrusive_ptr<BitmapData_as> ptr =
+ ensureType<BitmapData_as>(fn.this_ptr);
// Returns the immutable rectangle of the bitmap or -1 if dispose()
// has been called.
if (ptr->getBitmapData().empty()) return -1;
- boost::intrusive_ptr<as_object> obj = init_Rectangle_instance();
-
- obj->set_member(NSV::PROP_X, 0.0);
- obj->set_member(NSV::PROP_Y, 0.0);
- obj->set_member(NSV::PROP_WIDTH, ptr->getWidth());
- obj->set_member(NSV::PROP_HEIGHT, ptr->getHeight());
-
- return as_value(obj.get()); // will keep alive
+ // If it's not found construction will fail.
+ as_value rectangle(fn.env().find_object("flash.geom.Rectangle"));
+ boost::intrusive_ptr<as_function> rectCtor = rectangle.to_as_function();
+
+ if (!rectCtor) {
+ log_error("Failed to construct flash.geom.Rectangle!");
+ return -1;
+ }
+
+ // Construct a Rectangle from the data.
+ std::auto_ptr<std::vector<as_value> > args(new std::vector<as_value>);
+
+ args->push_back(0.0);
+ args->push_back(0.0);
+ args->push_back(ptr->getWidth());
+ args->push_back(ptr->getHeight());
+
+ boost::intrusive_ptr<as_object> newRect =
+ rectCtor->constructInstance(fn.env(), args);
+
+ return as_value(newRect.get());
}
as_value
=== modified file 'libcore/asobj/flash/geom/ColorTransform_as.cpp'
--- a/libcore/asobj/flash/geom/ColorTransform_as.cpp 2009-02-25 22:33:03
+0000
+++ b/libcore/asobj/flash/geom/ColorTransform_as.cpp 2009-02-27 11:55:27
+0000
@@ -240,7 +240,8 @@
{
// Must be a ColorTransform
- boost::intrusive_ptr<ColorTransform_as> ptr =
ensureType<ColorTransform_as>(fn.this_ptr);
+ boost::intrusive_ptr<ColorTransform_as> ptr =
+ ensureType<ColorTransform_as>(fn.this_ptr);
// We need the as_value to_string method, but using ptr->get_member
// is unnecessary when we can read directly from the object.
=== modified file 'libcore/asobj/flash/geom/Matrix_as.cpp'
--- a/libcore/asobj/flash/geom/Matrix_as.cpp 2009-02-25 22:33:03 +0000
+++ b/libcore/asobj/flash/geom/Matrix_as.cpp 2009-02-27 11:55:27 +0000
@@ -94,14 +94,17 @@
o.init_member("clone", new builtin_function(Matrix_clone), fl);
o.init_member("concat", new builtin_function(Matrix_concat), fl);
o.init_member("createBox", new builtin_function(Matrix_createBox), fl);
- o.init_member("createGradientBox", new
builtin_function(Matrix_createGradientBox), fl);
- o.init_member("deltaTransformPoint", new
builtin_function(Matrix_deltaTransformPoint), fl);
+ o.init_member("createGradientBox",
+ new builtin_function(Matrix_createGradientBox), fl);
+ o.init_member("deltaTransformPoint",
+ new builtin_function(Matrix_deltaTransformPoint), fl);
o.init_member("identity", new builtin_function(Matrix_identity), fl);
o.init_member("invert", new builtin_function(Matrix_invert), fl);
o.init_member("rotate", new builtin_function(Matrix_rotate), fl);
o.init_member("scale", new builtin_function(Matrix_scale), fl);
o.init_member("toString", new builtin_function(Matrix_toString), fl);
- o.init_member("transformPoint", new
builtin_function(Matrix_transformPoint), fl);
+ o.init_member("transformPoint",
+ new builtin_function(Matrix_transformPoint), fl);
o.init_member("translate", new builtin_function(Matrix_translate), fl);
}
@@ -389,7 +392,8 @@
IF_VERBOSE_ASCODING_ERRORS(
std::ostringstream ss;
fn.dump_args(ss);
- log_aserror("Matrix.deltaTransformPoint(%s): needs one argument",
ss.str());
+ log_aserror("Matrix.deltaTransformPoint(%s): needs one argument",
+ ss.str());
);
return as_value();
}
@@ -402,7 +406,8 @@
IF_VERBOSE_ASCODING_ERRORS(
std::ostringstream ss;
fn.dump_args(ss);
- log_aserror("Matrix.deltaTransformPoint(%s): needs an object",
ss.str());
+ log_aserror("Matrix.deltaTransformPoint(%s): needs an object",
+ ss.str());
);
return as_value();
}
@@ -658,12 +663,14 @@
std::ostringstream ss;
- ss << "(a=" << a.to_string() << ", "
- "b="<< b.to_string() << ", "
- "c="<< c.to_string() << ", "
- "d="<< d.to_string() << ", "
- "tx="<< tx.to_string() << ", "
- "ty="<< ty.to_string() << ")";
+ const int version = fn.getVM().getSWFVersion();
+
+ ss << "(a=" << a.to_string_versioned(version) << ", "
+ "b="<< b.to_string_versioned(version) << ", "
+ "c="<< c.to_string_versioned(version) << ", "
+ "d="<< d.to_string_versioned(version) << ", "
+ "tx="<< tx.to_string_versioned(version) << ", "
+ "ty="<< ty.to_string_versioned(version) << ")";
return as_value(ss.str());
}
=== modified file 'libcore/asobj/flash/geom/Rectangle_as.cpp'
--- a/libcore/asobj/flash/geom/Rectangle_as.cpp 2009-02-25 22:33:03 +0000
+++ b/libcore/asobj/flash/geom/Rectangle_as.cpp 2009-02-27 11:55:27 +0000
@@ -177,7 +177,8 @@
IF_VERBOSE_ASCODING_ERRORS(
std::stringstream ss;
fn.dump_args(ss);
- log_aserror("flash.geom.Rectangle(%s): %s", ss.str(),
_("missing arguments"));
+ log_aserror("flash.geom.Rectangle(%s): %s", ss.str(),
+ _("missing arguments"));
);
return as_value();
}
@@ -415,7 +416,8 @@
static as_value
Rectangle_bottomRight_getset(const fn_call& fn)
{
- boost::intrusive_ptr<Rectangle_as> ptr =
ensureType<Rectangle_as>(fn.this_ptr);
+ boost::intrusive_ptr<Rectangle_as> ptr =
+ ensureType<Rectangle_as>(fn.this_ptr);
as_value ret;
@@ -434,7 +436,7 @@
as_environment& env = fn.env();
- std::auto_ptr< std::vector<as_value> > args ( new
std::vector<as_value> );
+ std::auto_ptr<std::vector<as_value> > args(new
std::vector<as_value>);
args->push_back(right);
args->push_back(bottom);
@@ -443,7 +445,8 @@
else // setter
{
IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("Attempt to set read-only property %s"),
"Rectangle.bottomRight");
+ log_aserror(_("Attempt to set read-only property %s"),
+ "Rectangle.bottomRight");
);
}
@@ -523,7 +526,7 @@
as_environment& env = fn.env();
- std::auto_ptr< std::vector<as_value> > args ( new
std::vector<as_value> );
+ std::auto_ptr<std::vector<as_value> > args(new
std::vector<as_value>);
args->push_back(w);
args->push_back(h);
=== modified file 'libcore/asobj/flash/geom/Transform_as.cpp'
--- a/libcore/asobj/flash/geom/Transform_as.cpp 2009-02-25 22:33:03 +0000
+++ b/libcore/asobj/flash/geom/Transform_as.cpp 2009-02-27 11:55:27 +0000
@@ -148,55 +148,16 @@
boost::intrusive_ptr<Transform_as> ptr =
ensureType<Transform_as>(fn.this_ptr);
- VM& vm = ptr->getVM();
- string_table& st = vm.getStringTable();
-
- if (!fn.nargs)
- {
-
- // This is silly. Should be easier to do, even if it's necessary
- // somewhere in the chain to go through all the objects.
-
- // Getter
- as_value flash;
- if (!vm.getGlobal()->get_member(st.find("flash"), &flash))
- {
- log_error("No flash object found!");
- return as_value();
- }
- boost::intrusive_ptr<as_object> flashObj = flash.to_object();
-
- if (!flashObj)
- {
- log_error("flash isn't an object!");
- return as_value();
- }
-
- as_value geom;
- if (!flashObj->get_member(st.find("geom"), &geom))
- {
- log_error("No flash.geom object found!");
- return as_value();
- }
- boost::intrusive_ptr<as_object> geomObj = geom.to_object();
-
- if (!geomObj)
- {
- log_error("flash.geom isn't an object!");
- return as_value();
- }
-
- as_value colorTransform;
- if (!geomObj->get_member(st.find("ColorTransform"), &colorTransform))
- {
- log_error("No flash.geom.ColorTransform object found!");
- return as_value();
- }
-
- boost::intrusive_ptr<as_function> colorTransformCtor =
colorTransform.to_as_function();
- if (!colorTransformCtor)
- {
- log_error("flash.geom.ColorTransform isn't a function!");
+ if (!fn.nargs) {
+
+ // If it's not found, construction will fail.
+ as_value colorTrans(fn.env().find_object("flash.geom.ColorTransform"));
+
+ boost::intrusive_ptr<as_function> colorTransformCtor =
+ colorTrans.to_as_function();
+
+ if (!colorTransformCtor) {
+ log_error("Failed to construct flash.geom.ColorTransform!");
return as_value();
}
@@ -306,55 +267,16 @@
boost::intrusive_ptr<Transform_as> ptr =
ensureType<Transform_as>(fn.this_ptr);
- VM& vm = ptr->getVM();
- string_table& st = vm.getStringTable();
-
if (!fn.nargs)
{
- // This is silly. Should be easier to do, even if it's necessary
- // somewhere in the chain to go through all the objects.
-
- // Getter
- as_value flash;
- if (!vm.getGlobal()->get_member(st.find("flash"), &flash))
- {
- log_error("No flash object found!");
- return as_value();
- }
- boost::intrusive_ptr<as_object> flashObj = flash.to_object();
-
- if (!flashObj)
- {
- log_error("flash isn't an object!");
- return as_value();
- }
-
- as_value geom;
- if (!flashObj->get_member(st.find("geom"), &geom))
- {
- log_error("No flash.geom object found!");
- return as_value();
- }
- boost::intrusive_ptr<as_object> geomObj = geom.to_object();
-
- if (!geomObj)
- {
- log_error("flash.geom isn't an object!");
- return as_value();
- }
-
- as_value matrixVal;
- if (!geomObj->get_member(st.find("Matrix"), &matrixVal))
- {
- log_error("No flash.geom.Matrix object found!");
- return as_value();
- }
-
- boost::intrusive_ptr<as_function> matrixCtor =
matrixVal.to_as_function();
- if (!matrixCtor)
- {
- log_error("flash.geom.Matrix isn't a function!");
+ // If it's not found, construction will fail.
+ as_value matrix(fn.env().find_object("flash.geom.Matrix"));
+
+ boost::intrusive_ptr<as_function> matrixCtor = matrix.to_as_function();
+
+ if (!matrixCtor) {
+ log_error("Failed to construct flash.geom.Matrix!");
return as_value();
}
@@ -381,7 +303,8 @@
IF_VERBOSE_ASCODING_ERRORS(
std::ostringstream ss;
fn.dump_args(ss);
- log_aserror("Transform.matrix(%s): extra arguments discarded",
ss.str());
+ log_aserror("Transform.matrix(%s): extra arguments discarded",
+ ss.str());
);
}
@@ -392,7 +315,8 @@
IF_VERBOSE_ASCODING_ERRORS(
std::ostringstream ss;
fn.dump_args(ss);
- log_aserror("Transform.matrix(%s): argument is not an object",
ss.str());
+ log_aserror("Transform.matrix(%s): argument is not an object",
+ ss.str());
);
return as_value();
}
@@ -424,8 +348,10 @@
static as_value
Transform_pixelBounds_getset(const fn_call& fn)
{
- boost::intrusive_ptr<Transform_as> ptr =
ensureType<Transform_as>(fn.this_ptr);
- UNUSED(ptr);
+ boost::intrusive_ptr<Transform_as> ptr =
+ ensureType<Transform_as>(fn.this_ptr);
+
+ UNUSED(ptr);
LOG_ONCE( log_unimpl (__FUNCTION__) );
return as_value();
}
=== modified file 'testsuite/actionscript.all/BitmapData.as'
--- a/testsuite/actionscript.all/BitmapData.as 2009-02-25 22:33:03 +0000
+++ b/testsuite/actionscript.all/BitmapData.as 2009-02-27 11:55:27 +0000
@@ -223,7 +223,7 @@
bmp = new Bitmap(20, 10, true);
backup = flash.geom.Rectangle;
flash.geom.Rectangle = 2;
-xcheck_equals(bmp.rectangle, -1);
+check_equals(bmp.rectangle, -1);
flash.geom.Rectangle = function (x, y, w, h)
{
@@ -232,17 +232,17 @@
this.width = h;
this.height = w;
};
-xcheck_equals(bmp.rectangle.toString(), "[object Object]");
+check_equals(bmp.rectangle.toString(), "[object Object]");
flash.geom.Rectangle = function (x, y, w, h)
{
};
-xcheck_equals(bmp.rectangle.toString(), "[object Object]");
+check_equals(bmp.rectangle.toString(), "[object Object]");
flash.geom.Rectangle = function ()
{
};
-xcheck_equals(bmp.rectangle.toString(), "[object Object]");
+check_equals(bmp.rectangle.toString(), "[object Object]");
flash.geom.Rectangle = backup;
check_equals(bmp.rectangle.toString(), "(x=0, y=0, w=20, h=10)");
=== modified file 'testsuite/actionscript.all/Matrix.as'
--- a/testsuite/actionscript.all/Matrix.as 2009-02-25 22:33:03 +0000
+++ b/testsuite/actionscript.all/Matrix.as 2009-02-27 11:55:27 +0000
@@ -156,7 +156,7 @@
#if OUTPUT_VERSION > 6
check_equals(m1.toString(), "(a=8, b=undefined, c=undefined, d=undefined,
tx=undefined, ty=undefined)");
#else
-xcheck_equals(m1.toString(), "(a=8, b=, c=, d=, tx=, ty=)");
+check_equals(m1.toString(), "(a=8, b=, c=, d=, tx=, ty=)");
#endif
m1 = new Matrix(1, 2, 3, 4, 5, 6);
@@ -336,7 +336,7 @@
#if OUTPUT_VERSION > 6
check_equals("" + m7, "(a=A string, b=undefined, c=[object Object], d=true,
tx=NaN, ty=(x=0, y=0))");
#else
-xcheck_equals("" + m7, "(a=A string, b=, c=[object Object], d=true, tx=NaN,
ty=(x=0, y=0))");
+check_equals("" + m7, "(a=A string, b=, c=[object Object], d=true, tx=NaN,
ty=(x=0, y=0))");
#endif
m7.rotate(2);
=== modified file 'testsuite/swfdec/PASSING'
--- a/testsuite/swfdec/PASSING 2009-01-29 15:08:14 +0000
+++ b/testsuite/swfdec/PASSING 2009-02-27 11:55:27 +0000
@@ -104,6 +104,7 @@
bitmapdata-getters-5.swf:b32dce961f672c8c7ae32d5cee3d8f45
bitmapdata-getters-6.swf:305acbd129fc45f26837dec9f24720ca
bitmapdata-getters-7.swf:93e7771bb9f3ad11318b18c136555649
+bitmapdata-getters-8.swf:2fd651b565796622a06accb8d958cf71
bitmap-filter-properties-5.swf:62973bfcdf9f1fd383440fabcbfebca9
bitmap-filter-properties-5.swf:d69ea38322111b3626c6b9577838674f
bitwise-5.swf:98475055aae4796a066e7728d5a7a944
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10637: Minor fixes and code cleanup for flash package classes.,
Benjamin Wolsey <=