[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r12101: Reduce usage of VM::get(), i
From: |
Bastiaan Jacques |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r12101: Reduce usage of VM::get(), in particular: |
Date: |
Tue, 23 Mar 2010 00:46:33 +0100 |
User-agent: |
Bazaar (2.0.3) |
------------------------------------------------------------
revno: 12101
committer: Bastiaan Jacques <address@hidden>
branch nick: trunk
timestamp: Tue 2010-03-23 00:46:33 +0100
message:
Reduce usage of VM::get(), in particular:
as_object.{h,cpp}: Remove the default constructor and add a protected one
for subclasses.
Globals.{h,cpp}: Remove _vm, as one is inherited from as_object.
modified:
libcore/as_function.cpp
libcore/as_object.cpp
libcore/as_object.h
libcore/asobj/Global_as.h
libcore/asobj/Globals.cpp
libcore/asobj/Globals.h
libcore/asobj/MovieClipLoader.cpp
libcore/asobj/Object.cpp
libcore/asobj/flash/display/MovieClip_as.cpp
libcore/asobj/flash/text/TextSnapshot_as.cpp
libcore/asobj/flash/xml/XMLNode_as.cpp
testsuite/libcore.all/PropertyListTest.cpp
=== modified file 'libcore/as_function.cpp'
--- a/libcore/as_function.cpp 2010-01-11 06:41:38 +0000
+++ b/libcore/as_function.cpp 2010-03-22 23:46:33 +0000
@@ -261,17 +261,17 @@
if (!fn.nargs)
{
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror (_("Function.apply() called with no args"));
- );
- new_fn_call.this_ptr = new as_object;
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror (_("Function.apply() called with no args"));
+ );
+ new_fn_call.this_ptr = new as_object(getGlobal(fn));
}
else
{
// Get the object to use as 'this' reference
as_object* obj = fn.arg(0).to_object(getGlobal(fn));
- if (!obj) obj = new as_object;
+ if (!obj) obj = new as_object(getGlobal(fn));
new_fn_call.this_ptr = obj;
=== modified file 'libcore/as_object.cpp'
--- a/libcore/as_object.cpp 2010-03-11 01:47:08 +0000
+++ b/libcore/as_object.cpp 2010-03-22 23:46:33 +0000
@@ -296,13 +296,13 @@
{
}
-as_object::as_object()
+as_object::as_object(VM& vm)
:
_displayObject(0),
_array(false),
_relay(0),
- _vm(VM::get()),
- _members(*this)
+ _vm(vm),
+ _members(*this)
{
}
=== modified file 'libcore/as_object.h'
--- a/libcore/as_object.h 2010-03-13 18:00:33 +0000
+++ b/libcore/as_object.h 2010-03-22 23:46:33 +0000
@@ -197,11 +197,6 @@
/// uses the resources of the Global object.
explicit as_object(Global_as& global);
- /// Construct an ActionScript object with no prototype associated.
- //
- /// This constructor is deprecated!
- as_object();
-
/// Function dispatch
//
/// Various objects can be called, including functions and super objects.
@@ -801,6 +796,19 @@
protected:
+ /// Construct an as_object associated with a VM.
+ //
+ /// This constructor is intended for subclasses. Although they could call
+ /// the public constructor that accepts a Global_as, this could imply
+ /// that that constructor can access members of the passed Global_as
+ /// other than getVM(), which might not be available because the Global_as
+ /// will not be fully constructed yet. While that is currently not the
+ /// case, using this constructor eliminates this potential initialization
+ /// order problem.
+ /// @param vm The VM to associate the newly created as_object with.
+ explicit as_object(VM& vm);
+
+
/// Mark all reachable resources, override from GcResource.
//
/// The default implementation marks all properties
@@ -816,8 +824,10 @@
/// Mark properties and triggers list as reachable (for the GC)
void markAsObjectReachable() const;
+ /// The VM containing this object.
+ VM& _vm;
private:
-
+
/// Find an existing property for update
//
/// Scans the inheritance chain only for getter/setters or statics.
@@ -858,9 +868,6 @@
/// destructor is called.
boost::scoped_ptr<Relay> _relay;
- /// The VM containing this object.
- VM& _vm;
-
/// Properties of this as_object
PropertyList _members;
=== modified file 'libcore/asobj/Global_as.h'
--- a/libcore/asobj/Global_as.h 2010-03-11 17:03:04 +0000
+++ b/libcore/asobj/Global_as.h 2010-03-22 23:46:33 +0000
@@ -59,6 +59,10 @@
virtual const ClassHierarchy& classHierarchy() const = 0;
virtual ClassHierarchy& classHierarchy() = 0;
+ explicit Global_as(VM& vm)
+ : as_object(vm)
+ {}
+
/// Create an ActionScript function
virtual builtin_function* createFunction(ASFunction function) = 0;
=== modified file 'libcore/asobj/Globals.cpp'
--- a/libcore/asobj/Globals.cpp 2010-03-10 16:13:07 +0000
+++ b/libcore/asobj/Globals.cpp 2010-03-22 23:46:33 +0000
@@ -266,8 +266,8 @@
AVM1Global::AVM1Global(VM& vm)
:
+ Global_as(vm),
_classes(this, &_et),
- _vm(vm),
_objectProto(new as_object(*this))
{
}
@@ -388,8 +388,8 @@
AVM2Global::AVM2Global(abc::Machine& /*machine*/, VM& vm)
:
+ Global_as(vm),
_classes(this, 0),
- _vm(vm),
_objectProto(new as_object(*this))
{
}
=== modified file 'libcore/asobj/Globals.h'
--- a/libcore/asobj/Globals.h 2010-03-11 01:47:08 +0000
+++ b/libcore/asobj/Globals.h 2010-03-22 23:46:33 +0000
@@ -112,7 +112,6 @@
Extension _et;
ClassHierarchy _classes;
- VM& _vm;
as_object* _objectProto;
@@ -175,7 +174,6 @@
private:
ClassHierarchy _classes;
- VM& _vm;
as_object* _objectProto;
};
=== modified file 'libcore/asobj/MovieClipLoader.cpp'
--- a/libcore/asobj/MovieClipLoader.cpp 2010-01-25 18:52:20 +0000
+++ b/libcore/asobj/MovieClipLoader.cpp 2010-03-22 23:46:33 +0000
@@ -192,7 +192,7 @@
}
- as_object* mcl_obj = new as_object;
+ as_object* mcl_obj = new as_object(getGlobal(fn));
size_t bytesLoaded = sp->get_bytes_loaded();
size_t bytesTotal = sp->get_bytes_total();
=== modified file 'libcore/asobj/Object.cpp'
--- a/libcore/asobj/Object.cpp 2010-01-11 06:41:38 +0000
+++ b/libcore/asobj/Object.cpp 2010-03-22 23:46:33 +0000
@@ -153,7 +153,7 @@
}
if (!fn.isInstantiation()) {
- return new as_object();
+ return new as_object(gl);
}
return gl.createObject();
=== modified file 'libcore/asobj/flash/display/MovieClip_as.cpp'
--- a/libcore/asobj/flash/display/MovieClip_as.cpp 2010-03-11 01:47:08
+0000
+++ b/libcore/asobj/flash/display/MovieClip_as.cpp 2010-03-22 23:46:33
+0000
@@ -124,7 +124,7 @@
as_object* proto = gl.createObject();
if (isAS3(getVM(where))) {
- as_object* cl = new as_object();
+ as_object* cl = new as_object(gl);
cl->set_prototype(proto);
attachMovieClipAS3Interface(*proto);
@@ -1284,7 +1284,7 @@
}
// This is a bare object.
- as_object* bounds_obj = new as_object();
+ as_object* bounds_obj = new as_object(getGlobal(fn));
bounds_obj->init_member("xMin", xMin);
bounds_obj->init_member("yMin", yMin);
bounds_obj->init_member("xMax", xMax);
=== modified file 'libcore/asobj/flash/text/TextSnapshot_as.cpp'
--- a/libcore/asobj/flash/text/TextSnapshot_as.cpp 2010-03-11 01:47:08
+0000
+++ b/libcore/asobj/flash/text/TextSnapshot_as.cpp 2010-03-22 23:46:33
+0000
@@ -272,7 +272,7 @@
continue;
}
- as_object* el = new as_object;
+ as_object* el = new as_object(getGlobal(ri));
el->init_member("indexInRun", pos);
el->init_member("selected",
@@ -503,7 +503,7 @@
size_t end = std::max<boost::int32_t>(start + 1, toInt(fn.arg(1)));
Global_as& gl = getGlobal(fn);
- as_object* ri = gl.createArray();;
+ as_object* ri = gl.createArray();
ts->getTextRunInfo(start, end, *ri);
=== modified file 'libcore/asobj/flash/xml/XMLNode_as.cpp'
--- a/libcore/asobj/flash/xml/XMLNode_as.cpp 2010-03-11 01:47:08 +0000
+++ b/libcore/asobj/flash/xml/XMLNode_as.cpp 2010-03-22 23:46:33 +0000
@@ -83,7 +83,7 @@
_global(gl),
_object(0),
_parent(0),
- _attributes(new as_object),
+ _attributes(new as_object(gl)),
_childNodes(0),
_type(Element)
{
@@ -94,7 +94,7 @@
_global(tpl._global),
_object(0),
_parent(0),
- _attributes(new as_object),
+ _attributes(new as_object(_global)),
_childNodes(0),
_name(tpl._name),
_value(tpl._value),
=== modified file 'testsuite/libcore.all/PropertyListTest.cpp'
--- a/testsuite/libcore.all/PropertyListTest.cpp 2010-01-11 06:41:38
+0000
+++ b/testsuite/libcore.all/PropertyListTest.cpp 2010-03-22 23:46:33
+0000
@@ -87,7 +87,7 @@
log_debug("VM version %d", vm.getSWFVersion());
- as_object obj;
+ as_object obj(getGlobal(vm));
PropertyList props(obj);
as_value val("value");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r12101: Reduce usage of VM::get(), in particular:,
Bastiaan Jacques <=