[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11385: Separate Object prototype an
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11385: Separate Object prototype and class entirely for each VM. This still uses |
Date: |
Fri, 07 Aug 2009 16:40:38 +0200 |
User-agent: |
Bazaar (1.16.1) |
------------------------------------------------------------
revno: 11385 [merge]
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Fri 2009-08-07 16:40:38 +0200
message:
Separate Object prototype and class entirely for each VM. This still uses
the VM singleton and the prototypes are still static until the prototype
is stored properly, and until getObjectInterface() takes an argument. This
temporary hack shows there are no ill effects as all tests still pass.
Make more objects non-static, so that they are not shared between the
two VMs. There are still many to go.
Make some changes to VM and Machine construction to address problems created
by VM's ownership of Machine. This is not nearly robust enough, but serves
as a temporary measure until the AS resources are properly separated.
modified:
libcore/asobj/Color_as.cpp
libcore/asobj/Error_as.cpp
libcore/asobj/Globals.cpp
libcore/asobj/Globals.h
libcore/asobj/NetStream_as.cpp
libcore/asobj/Object.cpp
libcore/asobj/Selection_as.cpp
libcore/vm/Machine.cpp
libcore/vm/Machine.h
libcore/vm/VM.cpp
=== modified file 'libcore/asobj/Color_as.cpp'
--- a/libcore/asobj/Color_as.cpp 2009-07-29 05:40:20 +0000
+++ b/libcore/asobj/Color_as.cpp 2009-08-07 14:00:50 +0000
@@ -58,12 +58,6 @@
public:
- Color_as()
- :
- as_object(getColorInterface()),
- _sprite(0)
- {}
-
Color_as(MovieClip* sp)
:
as_object(getColorInterface()),
@@ -136,20 +130,15 @@
}
// extern (used by Global.cpp)
-void color_class_init(as_object& global, const ObjectURI& uri)
+void
+color_class_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 = getColorInterface();
- cl = gl->createClass(&color_ctor, proto);
- }
+ Global_as* gl = getGlobal(global);
+ as_object* proto = getColorInterface();
+ as_object* cl = gl->createClass(&color_ctor, proto);
// Register _global.Color
- global.init_member(getName(uri), cl.get(), as_object::DefaultFlags,
+ global.init_member(getName(uri), cl, as_object::DefaultFlags,
getNamespace(uri));
}
=== modified file 'libcore/asobj/Error_as.cpp'
--- a/libcore/asobj/Error_as.cpp 2009-07-29 10:57:41 +0000
+++ b/libcore/asobj/Error_as.cpp 2009-08-07 14:01:37 +0000
@@ -46,7 +46,8 @@
// extern
-void Error_class_init(as_object& where, const ObjectURI& uri)
+void
+Error_class_init(as_object& where, const ObjectURI& uri)
{
Global_as* gl = getGlobal(where);
=== modified file 'libcore/asobj/Globals.cpp'
--- a/libcore/asobj/Globals.cpp 2009-08-06 11:02:25 +0000
+++ b/libcore/asobj/Globals.cpp 2009-08-07 08:43:01 +0000
@@ -154,6 +154,11 @@
_classes(this, 0),
_vm(vm)
{
+}
+
+void
+AVM2Global::registerClasses()
+{
init_member("trace", createFunction(global_trace));
init_member("escape", createFunction(global_escape));
@@ -165,7 +170,7 @@
array_class_init(*this, ObjectURI(NSV::CLASS_ARRAY, NS_GLOBAL));
function_class_init(*this, ObjectURI(NSV::CLASS_FUNCTION, NS_GLOBAL));
- _classes.declareAll(avm2Classes(vm.getStringTable()));
+ _classes.declareAll(avm2Classes(_vm.getStringTable()));
_classes.getGlobalNs()->stubPrototype(_classes, NSV::CLASS_FUNCTION);
@@ -177,6 +182,7 @@
_classes.getGlobalNs()->getClass(NSV::CLASS_ARRAY)->setDeclared();
_classes.getGlobalNs()->stubPrototype(_classes, NSV::CLASS_STRING);
_classes.getGlobalNs()->getClass(NSV::CLASS_STRING)->setDeclared();
+
}
as_object*
=== modified file 'libcore/asobj/Globals.h'
--- a/libcore/asobj/Globals.h 2009-07-16 12:46:26 +0000
+++ b/libcore/asobj/Globals.h 2009-08-07 08:43:01 +0000
@@ -123,6 +123,8 @@
AVM2Global(Machine& m, VM& vm);
~AVM2Global() {}
+ void registerClasses();
+
/// Create an ActionScript function
virtual builtin_function* createFunction(Global_as::ASFunction function);
=== modified file 'libcore/asobj/NetStream_as.cpp'
--- a/libcore/asobj/NetStream_as.cpp 2009-08-04 17:39:22 +0000
+++ b/libcore/asobj/NetStream_as.cpp 2009-08-07 14:01:58 +0000
@@ -109,22 +109,12 @@
NetStream_as::init(as_object& global, const ObjectURI& uri)
{
- // This is going to be the global NetStream "class"/"function"
- static boost::intrusive_ptr<as_object> cl;
-
- if ( cl == NULL )
- {
- Global_as* gl = getGlobal(global);
- as_object* proto = getNetStreamInterface();
- cl = gl->createClass(&netstream_new, proto);
- // replicate all interface to class, to be able to access
- // all methods as static functions
- attachNetStreamInterface(*cl);
-
- }
+ Global_as* gl = getGlobal(global);
+ as_object* proto = getNetStreamInterface();
+ as_object* cl = gl->createClass(&netstream_new, proto);
// Register _global.String
- global.init_member(getName(uri), cl.get(), as_object::DefaultFlags,
+ global.init_member(getName(uri), cl, as_object::DefaultFlags,
getNamespace(uri));
}
=== modified file 'libcore/asobj/Object.cpp'
--- a/libcore/asobj/Object.cpp 2009-07-30 13:11:28 +0000
+++ b/libcore/asobj/Object.cpp 2009-08-07 09:53:58 +0000
@@ -81,28 +81,22 @@
void
object_class_init(as_object& where, const ObjectURI& uri)
{
- // This is going to be the global Object "class"/"function"
- static boost::intrusive_ptr<as_object> cl=NULL;
-
- if ( cl == NULL )
- {
- Global_as* gl = getGlobal(where);
- as_object* proto = getObjectInterface();
- cl = gl->createClass(object_ctor, proto);
-
- // The as_function ctor takes care of initializing these, but they
- // are different for the Object class.
- const int readOnly = PropFlags::readOnly;
- cl->set_member_flags(NSV::PROP_uuPROTOuu, readOnly);
- cl->set_member_flags(NSV::PROP_CONSTRUCTOR, readOnly);
- cl->set_member_flags(NSV::PROP_PROTOTYPE, readOnly);
-
- VM& vm = getVM(where);
- const int flags = as_object::DefaultFlags | PropFlags::readOnly;
- cl->init_member("registerClass", vm.getNative(101, 8), flags);
+
+ Global_as* gl = getGlobal(where);
+ as_object* proto = getObjectInterface();
+ boost::intrusive_ptr<as_object> cl = gl->createClass(object_ctor, proto);
+
+ // The as_function ctor takes care of initializing these, but they
+ // are different for the Object class.
+ const int readOnly = PropFlags::readOnly;
+ cl->set_member_flags(NSV::PROP_uuPROTOuu, readOnly);
+ cl->set_member_flags(NSV::PROP_CONSTRUCTOR, readOnly);
+ cl->set_member_flags(NSV::PROP_PROTOTYPE, readOnly);
+
+ VM& vm = getVM(where);
+ const int readOnlyFlags = as_object::DefaultFlags | PropFlags::readOnly;
+ cl->init_member("registerClass", vm.getNative(101, 8), readOnlyFlags);
- }
-
// Register _global.Object (should only be visible in SWF5 up)
int flags = PropFlags::dontEnum;
where.init_member(getName(uri), cl.get(), flags, getNamespace(uri));
@@ -113,13 +107,26 @@
as_object*
getObjectInterface()
{
- static boost::intrusive_ptr<as_object> o;
- if ( o == NULL )
- {
- o = new as_object(); // end of the inheritance chain
- attachObjectInterface(*o);
- }
- return o.get();
+ VM& vm = VM::get();
+
+ if (isAS3(vm)) {
+ static boost::intrusive_ptr<as_object> o;
+ if ( o == NULL )
+ {
+ o = new as_object(); // end of the inheritance chain
+ attachObjectInterface(*o);
+ }
+ return o.get();
+ }
+
+ static boost::intrusive_ptr<as_object> o;
+ if ( o == NULL )
+ {
+ o = new as_object(); // end of the inheritance chain
+ attachObjectInterface(*o);
+ }
+ return o.get();
+
}
=== modified file 'libcore/asobj/Selection_as.cpp'
--- a/libcore/asobj/Selection_as.cpp 2009-07-16 10:07:08 +0000
+++ b/libcore/asobj/Selection_as.cpp 2009-08-07 14:01:23 +0000
@@ -57,10 +57,9 @@
{
// Selection is NOT a class, but a simple object, see Selection.as
- static boost::intrusive_ptr<as_object> obj =
- new as_object(getObjectInterface());
+ as_object* obj = new as_object(getObjectInterface());
attachSelectionInterface(*obj);
- global.init_member(getName(uri), obj.get(), as_object::DefaultFlags,
+ global.init_member(getName(uri), obj, as_object::DefaultFlags,
getNamespace(uri));
}
=== modified file 'libcore/vm/Machine.cpp'
--- a/libcore/vm/Machine.cpp 2009-07-29 14:33:56 +0000
+++ b/libcore/vm/Machine.cpp 2009-08-07 08:43:01 +0000
@@ -332,10 +332,21 @@
mCurrentFunction(0),
_vm(vm)
{
+
+}
+
+void
+Machine::init()
+{
+
// TODO: The Global constructor needs the Machine and VM to be more or less
// fully constructed, so we might think how to do this better.
- _global = new AVM2Global(*this, _vm);
-
+ AVM2Global* g = new AVM2Global(*this, _vm);
+ _global = g;
+
+ AVM2Switcher switcher(_vm);
+ g->registerClasses();
+
}
Global_as*
=== modified file 'libcore/vm/Machine.h'
--- a/libcore/vm/Machine.h 2009-07-14 15:33:46 +0000
+++ b/libcore/vm/Machine.h 2009-08-07 08:43:01 +0000
@@ -62,6 +62,23 @@
class Machine
{
public:
+
+ /// Create an AS3 interpreter.
+ Machine(VM& vm);
+
+ /// Initialize the AS resources
+ //
+ /// This extra step is necessary because the Machine is initialized
+ /// and owned by the AVM1 machine(VM). All access to Machine currently
+ /// occurs through VM, but since the VM's Machine pointer is null until
+ /// the Machine ctor has completed, we cannot construct AS resources
+ /// until after the ctor is complete, because AS resource creation
+ /// accesses the Machine through the VM's pointer...
+ //
+ /// TODO: fix the mess.
+ void init();
+
+
// Flash specific members.
/// The DisplayObject which initiated these actions.
DisplayObject *getTarget();
@@ -216,9 +233,6 @@
as_value executeFunction(asMethod* function, const fn_call& fn);
void instantiateClass(std::string className, as_object* global);
-
- Machine(VM& vm);
-
/// Return the Global object for this Machine.
//
/// This should be different from the AVM1 global object because the VMs
=== modified file 'libcore/vm/VM.cpp'
--- a/libcore/vm/VM.cpp 2009-07-14 09:48:53 +0000
+++ b/libcore/vm/VM.cpp 2009-08-07 08:43:01 +0000
@@ -73,7 +73,7 @@
#ifdef ENABLE_AVM2
_singleton->_machine = new Machine(*_singleton);
- assert(_singleton->getGlobal());
+ _singleton->_machine->init();
#endif
return *_singleton;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11385: Separate Object prototype and class entirely for each VM. This still uses,
Benjamin Wolsey <=