gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] [SCM] Gnash branch, master, updated. 6a45df09b0a401e332ae


From: Benjamin Wolsey
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. 6a45df09b0a401e332ae87861282a267d381d76d
Date: Sun, 10 Oct 2010 10:08:55 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  6a45df09b0a401e332ae87861282a267d381d76d (commit)
       via  dab4c60dedd8b838cd7f363fac5757c97a507b4f (commit)
       via  b3f67e4517f3b1df235236202a907cd2812d94b7 (commit)
       via  49b3be6b3ae754cdae63259b1456168567ffa5fb (commit)
       via  1ccc57a06173668a903b1f177889f50cf5b97fb8 (commit)
       via  3b6bfc5cb1928ab6f8801f48f46981926b7c3c73 (commit)
       via  1ff2df07c59157b84e56d2c13c4ed65c8083673b (commit)
       via  83bd299caa019f782d067e3ea47376ae9ee40609 (commit)
      from  a944729fa80d4907e18eea7f0217da2d53dd3a19 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=6a45df09b0a401e332ae87861282a267d381d76d


commit 6a45df09b0a401e332ae87861282a267d381d76d
Merge: dab4c60 a944729
Author: Benjamin Wolsey <address@hidden>
Date:   Sun Oct 10 12:08:44 2010 +0200

    Merge branch 'master' of git.sv.gnu.org:/srv/git/gnash


http://git.savannah.gnu.org/cgit//commit/?id=dab4c60dedd8b838cd7f363fac5757c97a507b4f


commit dab4c60dedd8b838cd7f363fac5757c97a507b4f
Author: Benjamin Wolsey <address@hidden>
Date:   Sat Oct 9 11:15:04 2010 +0200

    Change local function arguments and document.

diff --git a/libcore/vm/ASHandlers.cpp b/libcore/vm/ASHandlers.cpp
index e0e811b..b582922 100644
--- a/libcore/vm/ASHandlers.cpp
+++ b/libcore/vm/ASHandlers.cpp
@@ -84,7 +84,11 @@ namespace {
 
     as_object* construct_object(as_function* ctor_as_func, as_environment& env,
             unsigned int nargs);
-    as_object* safeToObject(Global_as& gl, const as_value& val);
+
+    /// Convert to object without an exception being thrown.
+    //
+    /// @return     null if the value cannot be converted to an object.
+    as_object* safeToObject(VM& vm, const as_value& val);
 
     /// Common code for ActionGetUrl and ActionGetUrl2
     //
@@ -1334,10 +1338,10 @@ ActionCastOp(ActionExec& thread)
     as_environment& env = thread.env;
 
     // Get the "instance"
-    as_object* instance = safeToObject(getGlobal(thread.env), env.top(0));
+    as_object* instance = safeToObject(getVM(thread.env), env.top(0));
 
     // Get the "super" function
-    as_object* super = safeToObject(getGlobal(thread.env), env.top(1));
+    as_object* super = safeToObject(getVM(thread.env), env.top(1));
 
     // Invalid args!
     if (!super || ! instance)
@@ -1385,7 +1389,7 @@ ActionImplementsOp(ActionExec& thread)
     as_environment& env = thread.env;
 
     as_value objval = env.pop();
-    as_object* obj = safeToObject(getGlobal(thread.env), objval);
+    as_object* obj = safeToObject(getVM(thread.env), objval);
     int count = toNumber(env.pop(), getVM(env));
 
     if (!obj) {
@@ -1403,7 +1407,7 @@ ActionImplementsOp(ActionExec& thread)
         );
         return;
     }
-    obj = safeToObject(getGlobal(thread.env), protoval);
+    obj = safeToObject(getVM(thread.env), protoval);
     if (!obj) {
         IF_VERBOSE_ASCODING_ERRORS(
             log_aserror(_("IMPLEMENTSOP target object's prototype is not "
@@ -1422,7 +1426,7 @@ ActionImplementsOp(ActionExec& thread)
 
     while (count--) {
         as_value ctorval = env.pop();
-        as_object* ctor = safeToObject(getGlobal(thread.env), ctorval);
+        as_object* ctor = safeToObject(getVM(thread.env), ctorval);
         if (!ctor) {
             IF_VERBOSE_ASCODING_ERRORS(
                 log_aserror(_("class found on stack on IMPLEMENTSOP is "
@@ -1437,7 +1441,7 @@ ActionImplementsOp(ActionExec& thread)
             );
             continue;
         }
-        as_object *inter = safeToObject(getGlobal(thread.env), protoval);
+        as_object *inter = safeToObject(getVM(thread.env), protoval);
         if (!inter) {
             IF_VERBOSE_ASCODING_ERRORS(
                 log_aserror(_("Prototype of interface object for "
@@ -2208,7 +2212,7 @@ ActionDelete(ActionExec& thread)
             // Don't create an object! Only get the value if it is an object
             // already.
             if (target.is_object()) {
-                obj = safeToObject(getGlobal(thread.env), target);
+                obj = safeToObject(getVM(thread.env), target);
                 propertyname = var;
             }
         }
@@ -2217,7 +2221,7 @@ ActionDelete(ActionExec& thread)
         // Don't create an object! Only get the value if it is an object
         // already.
         if (env.top(1).is_object()) {
-            obj = safeToObject(getGlobal(thread.env), env.top(1));
+            obj = safeToObject(getVM(thread.env), env.top(1));
         }
     }
 
@@ -2273,7 +2277,7 @@ ActionDelete2(ActionExec& thread)
         return;
     }
 
-    as_object* obj = safeToObject(getGlobal(thread.env), target);
+    as_object* obj = safeToObject(getVM(thread.env), target);
     env.top(1).set_bool(thread.delObjectMember(*obj, var));
 }
 
@@ -2587,7 +2591,7 @@ ActionEnumerate(ActionExec& thread)
 
     env.top(0).set_undefined();
 
-    const as_object* obj = safeToObject(getGlobal(thread.env), variable);
+    const as_object* obj = safeToObject(getVM(thread.env), variable);
     if ( !obj || !variable.is_object() )
     {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -2696,7 +2700,7 @@ ActionGetMember(ActionExec& thread)
     as_value member_name = env.top(0);
     as_value target = env.top(1);
 
-    as_object* obj = safeToObject(getGlobal(thread.env), target);
+    as_object* obj = safeToObject(getVM(thread.env), target);
     if (!obj)
     {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -2744,7 +2748,7 @@ ActionSetMember(ActionExec& thread)
     
     as_environment& env = thread.env;
 
-    as_object* obj = safeToObject(getGlobal(thread.env), env.top(2));
+    as_object* obj = safeToObject(getVM(thread.env), env.top(2));
     const std::string& member_name = env.top(1).to_string();
     const as_value& member_value = env.top(0);
 
@@ -2848,7 +2852,7 @@ ActionCallMethod(ActionExec& thread)
         log_action(_(" method nargs: %d"), nargs);
     );
 
-    as_object* obj = safeToObject(getGlobal(thread.env), obj_value);
+    as_object* obj = safeToObject(getVM(thread.env), obj_value);
     if (!obj) {
         // If this value is not an object, it can neither have any members
         // nor be called as a function, so neither opcode usage is possible.
@@ -2898,7 +2902,7 @@ ActionCallMethod(ActionExec& thread)
             return;
         }
 
-        method_obj = safeToObject(getGlobal(thread.env), method_value);
+        method_obj = safeToObject(getVM(thread.env), method_value);
         if ( ! method_obj ) {
             IF_VERBOSE_ASCODING_ERRORS(
             log_aserror(_("ActionCallMethod: "
@@ -2994,7 +2998,7 @@ ActionNewMethod(ActionExec& thread)
         nargs = available_args;
     }
 
-    as_object* obj = safeToObject(getGlobal(thread.env), obj_val);
+    as_object* obj = safeToObject(getVM(thread.env), obj_val);
     if (!obj) {
         // SWF integrity check
         // FIXME, should this be log_swferror?  Or log_aserror?
@@ -3059,11 +3063,11 @@ ActionInstanceOf(ActionExec& thread)
     as_environment& env = thread.env;
 
     // Get the "super" function
-    as_object* super = safeToObject(getGlobal(thread.env), env.top(0));
+    as_object* super = safeToObject(getVM(thread.env), env.top(0));
 
     // Get the "instance" (but avoid implicit conversion of primitive values!)
     as_object* instance = env.top(1).is_object() ?
-        safeToObject(getGlobal(thread.env), env.top(1)) : 0;
+        safeToObject(getVM(thread.env), env.top(1)) : 0;
 
     // Invalid args!
     if (!super || ! instance) {
@@ -3095,7 +3099,7 @@ ActionEnum2(ActionExec& thread)
     // as we copied that as_value.
     env.top(0).set_undefined();
 
-    as_object* obj = safeToObject(getGlobal(thread.env), obj_val);
+    as_object* obj = safeToObject(getVM(thread.env), obj_val);
     if (!obj || !obj_val.is_object()) {
         IF_VERBOSE_ASCODING_ERRORS(
         log_aserror(_("Top of stack not an object %s at ActionEnum2 "
@@ -3606,11 +3610,11 @@ ActionUnsupported(ActionExec& thread)
 }
 
 as_object*
-safeToObject(Global_as& gl, const as_value& val)
+safeToObject(VM& vm, const as_value& val)
 {
 
     try {
-        return toObject(val, getVM(gl));
+        return toObject(val, vm);
     }
     catch (const GnashException&) {
         return 0;

http://git.savannah.gnu.org/cgit//commit/?id=b3f67e4517f3b1df235236202a907cd2812d94b7


commit b3f67e4517f3b1df235236202a907cd2812d94b7
Author: Benjamin Wolsey <address@hidden>
Date:   Sat Oct 9 11:04:07 2010 +0200

    Move unnecessary functions out of Global_as interface.

diff --git a/libcore/as_value.cpp b/libcore/as_value.cpp
index a5bc26d..4714544 100644
--- a/libcore/as_value.cpp
+++ b/libcore/as_value.cpp
@@ -70,6 +70,8 @@ namespace {
     bool compareBoolean(const as_value& boolean, const as_value& other,
             int version);
     inline bool findMethod(as_object& obj, string_table::key m, as_value& ret);
+    template<typename T> as_object* constructObject(VM& vm, const T& arg,
+            string_table::key className);
 }
 
 namespace {
@@ -451,9 +453,8 @@ as_value::to_bool(const int version) const
 
 // Return value as an object.
 as_object*
-as_value::to_object(const VM& vm) const
+as_value::to_object(VM& vm) const
 {
-    Global_as& global = *vm.getGlobal();
 
     switch (_type)
     {
@@ -464,13 +465,13 @@ as_value::to_object(const VM& vm) const
             return getObject(toDisplayObject());
 
         case STRING:
-            return global.createString(getStr());
+            return constructObject(vm, getStr(), NSV::CLASS_STRING);
 
         case NUMBER:
-            return global.createNumber(getNum());
+            return constructObject(vm, getNum(), NSV::CLASS_NUMBER);
 
         case BOOLEAN:
-            return global.createBoolean(getBool());
+            return constructObject(vm, getBool(), NSV::CLASS_BOOLEAN);
 
         default:
             // Invalid to convert exceptions.
@@ -481,17 +482,17 @@ as_value::to_object(const VM& vm) const
 MovieClip*
 as_value::toMovieClip(bool allowUnloaded) const
 {
-    if ( _type != DISPLAYOBJECT ) return 0;
+    if (_type != DISPLAYOBJECT) return 0;
 
     DisplayObject *ch = getCharacter(allowUnloaded);
-    if ( ! ch ) return 0;
+    if (!ch) return 0;
     return ch->to_movie();
 }
 
 DisplayObject*
 as_value::toDisplayObject(bool allowUnloaded) const
 {
-    if (_type != DISPLAYOBJECT) return NULL;
+    if (_type != DISPLAYOBJECT) return 0;
     return getCharacter(allowUnloaded);
 }
 
@@ -977,6 +978,49 @@ findMethod(as_object& obj, string_table::key m, as_value& 
ret)
     return obj.get_member(m, &ret) && ret.is_object();
 }
 
+/// Construct an instance of the specified global class.
+//
+/// If the class is not present or is not a constructor function, this
+/// function throws an ActionTypeError.
+//
+/// TODO: consider whether ActionTypeError is an appropriate exception.
+/// TODO: test the other failure cases.
+template<typename T>
+as_object*
+constructObject(VM& vm, const T& arg, string_table::key className)
+{
+
+    as_object& gl = *vm.getGlobal();
+
+    as_value clval;
+
+    // This is tested in actionscript.all/Object.as to return an 
+    // undefined value. We throw the exception back to the VM, which pushes
+    // an undefined value onto the stack.
+    if (!gl.get_member(className, &clval) ) {
+        throw ActionTypeError();
+    }
+    
+    // This is not properly tested.
+    if (!clval.is_function()) {
+        throw ActionTypeError();
+    }
+    
+    as_function* ctor = clval.to_function();
+
+    // This is also not properly tested.
+    if (!ctor) throw ActionTypeError();
+
+    fn_call::Args args;
+    args += arg;
+
+    as_environment env(vm);
+    as_object* ret = constructInstance(*ctor, env, args);
+
+    return ret;
+
+}
+
 } // unnamed namespace
 
 std::ostream&
diff --git a/libcore/as_value.h b/libcore/as_value.h
index 748f417..9f6658b 100644
--- a/libcore/as_value.h
+++ b/libcore/as_value.h
@@ -256,7 +256,7 @@ public:
     /// @param global   The global object object for the conversion. This
     ///                 contains the prototypes or constructors necessary for
     ///                 conversion.
-    as_object* to_object(const VM& vm) const;
+    as_object* to_object(VM& vm) const;
     
     /// Returns value as a MovieClip if it is a MovieClip.
     //
diff --git a/libcore/asobj/Global_as.cpp b/libcore/asobj/Global_as.cpp
index 5ff8720..1164d99 100644
--- a/libcore/asobj/Global_as.cpp
+++ b/libcore/asobj/Global_as.cpp
@@ -138,8 +138,6 @@ namespace {
     as_value local_errorConstructor(const fn_call& fn);
     
     void registerNatives(as_object& global);
-    template<typename T> as_object* constructObject(Global_as& gl, const T& 
arg,
-            string_table::key className);
 }
 
 Global_as::Global_as(VM& vm)
@@ -197,24 +195,6 @@ Global_as::createClass(Global_as::ASFunction ctor, 
as_object* prototype)
     return cl;
 }
 
-as_object*
-Global_as::createString(const std::string& s)
-{
-    // This is not really correct. If there is no String class, toObject()
-    // returns an undefined value, not a null object. The behaviour is the
-    // same for versions 5 to 8.
-    return constructObject(*this, s, NSV::CLASS_STRING);
-}
-
-as_object*
-Global_as::createNumber(double d)
-{
-    // This is not really correct. If there is no String class, toObject()
-    // returns an undefined value, not a null object. The behaviour is the
-    // same for versions 5 to 8.
-    return constructObject(*this, d, NSV::CLASS_NUMBER);
-
-}
 
 /// Construct an Array.
 //
@@ -241,12 +221,6 @@ Global_as::createArray()
     return array;
 }
 
-as_object*
-Global_as::createBoolean(bool b)
-{
-    return constructObject(*this, b, NSV::CLASS_BOOLEAN);
-}
-
 void 
 Global_as::markReachableResources() const
 {
@@ -1171,45 +1145,6 @@ global_enableDebugConsole(const fn_call& /*fn*/)
     LOG_ONCE(log_unimpl("_global.enableDebugConsole"));
     return as_value();
 }
-/// Construct an instance of the specified global class.
-//
-/// If the class is not present or is not a constructor function, this
-/// function throws an ActionTypeError.
-//
-/// TODO: consider whether ActionTypeError is an appropriate exception.
-/// TODO: test the other failure cases.
-template<typename T>
-as_object*
-constructObject(Global_as& gl, const T& arg, string_table::key className)
-{
-    as_value clval;
-
-    // This is tested in actionscript.all/Object.as to return an 
-    // undefined value. We throw the exception back to the VM, which pushes
-    // an undefined value onto the stack.
-    if (!gl.get_member(className, &clval) ) {
-        throw ActionTypeError();
-    }
-    
-    // This is not properly tested.
-    if (!clval.is_function()) {
-        throw ActionTypeError();
-    }
-    
-    as_function* ctor = clval.to_function();
-
-    // This is also not properly tested.
-    if (!ctor) throw ActionTypeError();
-
-    fn_call::Args args;
-    args += arg;
-
-    as_environment env(getVM(gl));
-    as_object* ret = constructInstance(*ctor, env, args);
-
-    return ret;
-
-}
 
 void
 registerNatives(as_object& global)
diff --git a/libcore/asobj/Global_as.h b/libcore/asobj/Global_as.h
index ef00ddc..c070e59 100644
--- a/libcore/asobj/Global_as.h
+++ b/libcore/asobj/Global_as.h
@@ -63,12 +63,6 @@ public:
     
     void registerClasses();
 
-    as_object* createString(const std::string& s);
-
-    as_object* createNumber(double d);
-
-    as_object* createBoolean(bool b);
-    
     as_object* createArray();
 
     VM& getVM() const {
diff --git a/libcore/vm/VM.cpp b/libcore/vm/VM.cpp
index d630596..c7c9f9f 100644
--- a/libcore/vm/VM.cpp
+++ b/libcore/vm/VM.cpp
@@ -458,7 +458,7 @@ toNumber(const as_value& v, const VM& vm)
 }
 
 as_object*
-toObject(const as_value& v, const VM& vm)
+toObject(const as_value& v, VM& vm)
 {
     return v.to_object(vm);
 }
diff --git a/libcore/vm/VM.h b/libcore/vm/VM.h
index eb4cb7f..c902a44 100644
--- a/libcore/vm/VM.h
+++ b/libcore/vm/VM.h
@@ -401,7 +401,7 @@ double toNumber(const as_value& v, const VM& vm);
 /// @param val  The value to return as an object
 /// @param vm   The VM to use for the conversion.
 /// @return     The Object representation value of the passed as_value.
-as_object* toObject(const as_value& v, const VM& vm);
+as_object* toObject(const as_value& v, VM& vm);
 
 /// AS2-compatible conversion to 32bit integer
 //

http://git.savannah.gnu.org/cgit//commit/?id=49b3be6b3ae754cdae63259b1456168567ffa5fb


commit 49b3be6b3ae754cdae63259b1456168567ffa5fb
Author: Benjamin Wolsey <address@hidden>
Date:   Sat Oct 9 10:50:13 2010 +0200

    Use toObject()

diff --git a/extensions/mysql/mysql_db.cpp b/extensions/mysql/mysql_db.cpp
index ef47da9..4b242b3 100644
--- a/extensions/mysql/mysql_db.cpp
+++ b/extensions/mysql/mysql_db.cpp
@@ -319,7 +319,7 @@ mysql_qetData(const fn_call& fn)
 
     if (fn.nargs > 0) {
         std::string sql = fn.arg(0).to_string();
-           as_object* arr = fn.arg(1).to_object(getGlobal(fn));
+           as_object* arr = toObject(fn.arg(1), getVM(fn));
 
         MySQL::query_t qresult;
 
diff --git a/libcore/ClassHierarchy.cpp b/libcore/ClassHierarchy.cpp
index 58f9661..2b2e7db 100644
--- a/libcore/ClassHierarchy.cpp
+++ b/libcore/ClassHierarchy.cpp
@@ -119,8 +119,7 @@ public:
         // Successfully loaded it, now find it, set its proto, and return.
         as_value us;
         if (mTarget->get_member(_decl.uri, &us)) {
-            Global_as& gl = getGlobal(fn);
-            if (!us.to_object(gl)) {
+            if (!toObject(us, getVM(fn))) {
                 log_error("Native class %s is not an object after "
                         "initialization (%s)",
                         st.value(getName(_decl.uri)), us);
diff --git a/libcore/MovieClip.cpp b/libcore/MovieClip.cpp
index 309f174..1210caf 100644
--- a/libcore/MovieClip.cpp
+++ b/libcore/MovieClip.cpp
@@ -711,7 +711,7 @@ MovieClip::pathElement(const ObjectURI& uri)
         return getObject(tmp.toDisplayObject(true));
     }
 
-    return tmp.to_object(getGlobal(*getObject(this)));
+    return toObject(tmp, getVM(*getObject(this)));
 }
 
 bool
diff --git a/libcore/Video.cpp b/libcore/Video.cpp
index 2e9cca1..7118269 100644
--- a/libcore/Video.cpp
+++ b/libcore/Video.cpp
@@ -349,7 +349,7 @@ video_attach(const fn_call& fn)
                return as_value();
        }
 
-    as_object* obj = fn.arg(0).to_object(getGlobal(fn));
+    as_object* obj = toObject(fn.arg(0), getVM(fn));
        NetStream_as* ns;
 
     if (isNativeType(obj, ns)) {
diff --git a/libcore/as_function.cpp b/libcore/as_function.cpp
index 199dc53..2d311d0 100644
--- a/libcore/as_function.cpp
+++ b/libcore/as_function.cpp
@@ -116,7 +116,7 @@ as_function::construct(as_object& newobj, const 
as_environment& env,
     // 'this' pointer. Others return a new object. This is to handle those
     // cases.
     if (isBuiltin() && ret.is_object()) {
-        as_object* fakeobj = ret.to_object(getGlobal(env));
+        as_object* fakeobj = toObject(ret, getVM(env));
 
         fakeobj->init_member(NSV::PROP_uuCONSTRUCTORuu, as_value(this),
                 flags);
@@ -207,7 +207,7 @@ function_apply(const fn_call& fn)
        else
        {
                // Get the object to use as 'this' reference
-               as_object* obj = fn.arg(0).to_object(getGlobal(fn));
+               as_object* obj = toObject(fn.arg(0), getVM(fn));
 
         if (!obj) obj = new as_object(getGlobal(fn)); 
 
@@ -234,7 +234,7 @@ function_apply(const fn_call& fn)
                        );
 
                        boost::intrusive_ptr<as_object> arg1 = 
-                fn.arg(1).to_object(getGlobal(fn));
+                toObject(fn.arg(1), getVM(fn));
 
             if (arg1) {
                 PushFunctionArgs pa(new_fn_call);
@@ -264,7 +264,7 @@ function_call(const fn_call& fn)
     if (!fn.nargs || fn.arg(0).is_undefined() || fn.arg(0).is_null()) {
         tp = new as_object(getGlobal(fn));
     }
-    else tp = fn.arg(0).to_object(getGlobal(fn));
+    else tp = toObject(fn.arg(0), getVM(fn));
 
     new_fn_call.this_ptr = tp;
     new_fn_call.super = 0;
diff --git a/libcore/as_object.cpp b/libcore/as_object.cpp
index 6aaeeba..55f8835 100644
--- a/libcore/as_object.cpp
+++ b/libcore/as_object.cpp
@@ -787,7 +787,7 @@ as_object::instanceOf(as_object* ctor)
         return false;
     }
 
-    as_object* ctorProto = protoVal.to_object(getGlobal(*this));
+    as_object* ctorProto = toObject(protoVal, getVM(*this));
     if (!ctorProto) {
 #ifdef GNASH_DEBUG_INSTANCE_OF
         log_debug("Object %p can't be an instance of an object (%p) "
@@ -974,7 +974,7 @@ as_object::get_prototype() const
     
     const as_value& proto = prop->getValue(*this);
     
-    return proto.to_object(getGlobal(*this));
+    return toObject(proto, getVM(*this));
 }
 
 as_object*
@@ -1002,7 +1002,7 @@ as_object::get_path_element(const ObjectURI& uri)
         return NULL;
     }
     
-    return tmp.to_object(getGlobal(*this));
+    return toObject(tmp, getVM(*this));
 }
 
 void
@@ -1139,9 +1139,9 @@ sendEvent(as_object& o, const as_environment& env, const 
ObjectURI& name)
 as_object*
 getObjectWithPrototype(Global_as& gl, string_table::key c)
 {
-    as_object* ctor = getMember(gl, c).to_object(gl);
-    as_object* proto = ctor ?
-        getMember(*ctor, NSV::PROP_PROTOTYPE).to_object(gl) : 0;
+    as_object* ctor = toObject(getMember(gl, c), getVM(gl));
+    as_object* proto = ctor ? 
+        toObject(getMember(*ctor, NSV::PROP_PROTOTYPE), getVM(gl)) : 0;
 
     as_object* o = createObject(gl);
     o->set_prototype(proto ? proto : as_value());
diff --git a/libcore/as_value.cpp b/libcore/as_value.cpp
index b4e5bbe..a5bc26d 100644
--- a/libcore/as_value.cpp
+++ b/libcore/as_value.cpp
@@ -451,8 +451,10 @@ as_value::to_bool(const int version) const
 
 // Return value as an object.
 as_object*
-as_value::to_object(Global_as& global) const
+as_value::to_object(const VM& vm) const
 {
+    Global_as& global = *vm.getGlobal();
+
     switch (_type)
     {
         case OBJECT:
diff --git a/libcore/as_value.h b/libcore/as_value.h
index 8d41b4c..748f417 100644
--- a/libcore/as_value.h
+++ b/libcore/as_value.h
@@ -256,7 +256,7 @@ public:
     /// @param global   The global object object for the conversion. This
     ///                 contains the prototypes or constructors necessary for
     ///                 conversion.
-    as_object* to_object(Global_as& global) const;
+    as_object* to_object(const VM& vm) const;
     
     /// Returns value as a MovieClip if it is a MovieClip.
     //
diff --git a/libcore/asobj/Array_as.cpp b/libcore/asobj/Array_as.cpp
index 5a982e4..4ce58c1 100644
--- a/libcore/asobj/Array_as.cpp
+++ b/libcore/asobj/Array_as.cpp
@@ -621,8 +621,8 @@ public:
     bool operator()(const as_value& a, const as_value& b) const {
 
         // why do we cast ao/bo to objects here ?
-        as_object* ao = a.to_object(getGlobal(_obj));
-        as_object* bo = b.to_object(getGlobal(_obj));
+        as_object* ao = toObject(a, getVM(_obj));
+        as_object* bo = toObject(b, getVM(_obj));
 
         assert(ao);
         assert(bo);
@@ -667,8 +667,8 @@ public:
         std::vector<as_cmp_fn>::iterator cmp = _cmps.begin();
 
         // why do we cast ao/bo to objects here ?
-        as_object* ao = a.to_object(getGlobal(_obj));
-        as_object* bo = b.to_object(getGlobal(_obj));
+        as_object* ao = toObject(a, getVM(_obj));
+        as_object* bo = toObject(b, getVM(_obj));
 
         // TODO: this may not be correct, but it is better than accessing
         // null pointers.
@@ -708,8 +708,8 @@ public:
         Comps::const_iterator cmp = _cmps.begin();
 
         // why do we cast ao/bo to objects here ?
-        as_object* ao = a.to_object(getGlobal(_obj));
-        as_object* bo = b.to_object(getGlobal(_obj));
+        as_object* ao = toObject(a, getVM(_obj));
+        as_object* bo = toObject(b, getVM(_obj));
 
         for (Props::iterator pit = _prps.begin(), pend = _prps.end();
                 pit != pend; ++pit, ++cmp)
@@ -1113,7 +1113,7 @@ array_sortOn(const fn_call& fn)
     // case: sortOn(["prop1", "prop2"] ...)
     if (fn.arg(0).is_object()) 
     {
-        as_object* props = fn.arg(0).to_object(getGlobal(fn));
+        as_object* props = toObject(fn.arg(0), getVM(fn));
         assert(props);
 
         std::vector<string_table::key> prp;
@@ -1135,7 +1135,7 @@ array_sortOn(const fn_call& fn)
         // case: sortOn(["prop1", "prop2"], [Array.FLAG1, Array.FLAG2])
         else if (fn.arg(1).is_object()) {
 
-            as_object* farray = fn.arg(1).to_object(getGlobal(fn));
+            as_object* farray = toObject(fn.arg(1), getVM(fn));
 
             // Only an array will do for this case.
             if (farray->array() && arrayLength(*farray) == optnum) {
@@ -1355,8 +1355,7 @@ array_concat(const fn_call& fn)
         // The type is checked using instanceOf.
         const as_value& arg = fn.arg(i);
 
-        Global_as& gl = getGlobal(fn);
-        as_object* other = arg.to_object(gl);
+        as_object* other = toObject(arg, getVM(fn));
 
         if (other) {
             // If it's not an array, we want to carry on and add it as an
diff --git a/libcore/asobj/AsBroadcaster.cpp b/libcore/asobj/AsBroadcaster.cpp
index 89bfc91..6d8e705 100644
--- a/libcore/asobj/AsBroadcaster.cpp
+++ b/libcore/asobj/AsBroadcaster.cpp
@@ -100,7 +100,7 @@ public:
     void operator()(const as_value& v)
     {
 
-        boost::intrusive_ptr<as_object> o = v.to_object(getGlobal(_fn));
+        as_object* o = toObject(v, getVM(_fn));
         if (!o) return;
 
 #ifdef GNASH_DEBUG_BROADCASTER
@@ -113,7 +113,7 @@ public:
 
         if (method.is_function()) {
             _fn.super = o->get_super(_eventURI);
-            _fn.this_ptr = o.get();
+            _fn.this_ptr = o;
             method.to_function()->call(_fn);
         }
 
@@ -148,8 +148,8 @@ AsBroadcaster::initialize(as_object& o)
     Global_as& gl = getGlobal(o);
 
     // Find _global.AsBroadcaster.
-    as_object* asb =
-        getMember(gl, NSV::CLASS_AS_BROADCASTER).to_object(gl);
+    as_object* asb = toObject(
+            getMember(gl, NSV::CLASS_AS_BROADCASTER), getVM(o));
 
     // If it's not an object, these are left undefined, but they are
     // always attached to the initialized object.
@@ -248,7 +248,7 @@ asbroadcaster_initialize(const fn_call& fn)
         return as_value();
     }
 
-    boost::intrusive_ptr<as_object> tgt = tgtval.to_object(getGlobal(fn));
+    boost::intrusive_ptr<as_object> tgt = toObject(tgtval, getVM(fn));
     if ( ! tgt )
     {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -301,7 +301,7 @@ asbroadcaster_addListener(const fn_call& fn)
         return as_value(false); 
     }
 
-    as_object* listeners = listenersValue.to_object(getGlobal(fn));
+    as_object* listeners = toObject(listenersValue, getVM(fn));
 
     // We checked is_object() above.
     assert(listeners); 
@@ -346,7 +346,7 @@ asbroadcaster_removeListener(const fn_call& fn)
         return as_value(false); // TODO: check this
     }
 
-    as_object* listeners = listenersValue.to_object(getGlobal(fn));
+    as_object* listeners = toObject(listenersValue, getVM(fn));
     assert(listeners);
 
     as_value listenerToRemove; 
@@ -410,7 +410,7 @@ asbroadcaster_broadcastMessage(const fn_call& fn)
         return as_value(); // TODO: check this
     }
 
-    as_object* listeners = listenersValue.to_object(getGlobal(fn));
+    as_object* listeners = toObject(listenersValue, getVM(fn));
 
     if (!fn.nargs) {
         IF_VERBOSE_ASCODING_ERRORS(
diff --git a/libcore/asobj/Camera_as.cpp b/libcore/asobj/Camera_as.cpp
index 37dc9d5..c4d1341 100644
--- a/libcore/asobj/Camera_as.cpp
+++ b/libcore/asobj/Camera_as.cpp
@@ -246,8 +246,8 @@ camera_get(const fn_call& fn)
 
     // Properties are attached to the prototype (not __proto__) when get() is
     // called. 
-    as_object* proto =
-        getMember(*ptr, NSV::PROP_PROTOTYPE).to_object(getGlobal(fn));
+    as_object* proto = toObject(
+        getMember(*ptr, NSV::PROP_PROTOTYPE), getVM(fn));
 
     attachCameraProperties(*proto);
 
diff --git a/libcore/asobj/Color_as.cpp b/libcore/asobj/Color_as.cpp
index 6599615..e6d833d 100644
--- a/libcore/asobj/Color_as.cpp
+++ b/libcore/asobj/Color_as.cpp
@@ -68,8 +68,8 @@ color_class_init(as_object& where, const ObjectURI& uri)
     as_object* cl = registerBuiltinClass(where, color_ctor,
             attachColorInterface, 0, uri);
 
-    as_object* proto =
-        getMember(*cl, NSV::PROP_PROTOTYPE).to_object(getGlobal(where));
+    as_object* proto = toObject(
+        getMember(*cl, NSV::PROP_PROTOTYPE), getVM(where));
 
     if (!proto) return;
 
@@ -190,7 +190,7 @@ color_settransform(const fn_call& fn)
                return as_value();
        }
 
-       as_object* trans = fn.arg(0).to_object(getGlobal(fn));
+       as_object* trans = toObject(fn.arg(0), getVM(fn));
 
     if (!trans) {
                IF_VERBOSE_ASCODING_ERRORS(
diff --git a/libcore/asobj/ContextMenu_as.cpp b/libcore/asobj/ContextMenu_as.cpp
index c0331c7..c649426 100644
--- a/libcore/asobj/ContextMenu_as.cpp
+++ b/libcore/asobj/ContextMenu_as.cpp
@@ -62,8 +62,7 @@ public:
     CopyMenuItems(string_table::key c, as_object& nc) : _c(c), _target(nc) {}
 
     void operator()(const as_value& val) {
-        Global_as& gl = getGlobal(_target);
-        as_object* obj = val.to_object(gl);
+        as_object* obj = toObject(val, getVM(_target));
         as_value cp = callMethod(obj, _c);
         callMethod(&_target, NSV::PROP_PUSH, cp);
     }
@@ -159,7 +158,7 @@ contextmenu_copy(const fn_call& fn)
         if (arr) {
             as_object* customs;
             if (customItems.is_object() &&
-                    (customs = customItems.to_object(getGlobal(fn)))) {
+                    (customs = toObject(customItems, getVM(fn)))) {
                 string_table::key copykey = getStringTable(fn).find("copy");
                 CopyMenuItems c(copykey, *arr);
                 foreachArray(*customs, c);
diff --git a/libcore/asobj/Global_as.cpp b/libcore/asobj/Global_as.cpp
index 4e58535..5ff8720 100644
--- a/libcore/asobj/Global_as.cpp
+++ b/libcore/asobj/Global_as.cpp
@@ -200,7 +200,7 @@ Global_as::createClass(Global_as::ASFunction ctor, 
as_object* prototype)
 as_object*
 Global_as::createString(const std::string& s)
 {
-    // This is not really correct. If there is no String class, to_object()
+    // This is not really correct. If there is no String class, toObject()
     // returns an undefined value, not a null object. The behaviour is the
     // same for versions 5 to 8.
     return constructObject(*this, s, NSV::CLASS_STRING);
@@ -209,7 +209,7 @@ Global_as::createString(const std::string& s)
 as_object*
 Global_as::createNumber(double d)
 {
-    // This is not really correct. If there is no String class, to_object()
+    // This is not really correct. If there is no String class, toObject()
     // returns an undefined value, not a null object. The behaviour is the
     // same for versions 5 to 8.
     return constructObject(*this, d, NSV::CLASS_NUMBER);
@@ -227,7 +227,7 @@ Global_as::createArray()
     as_object* array = new as_object(*this);
 
     as_value ctor = getMember(*this, NSV::CLASS_ARRAY);
-    as_object* obj = ctor.to_object(*this);
+    as_object* obj = toObject(ctor, gnash::getVM(*this));
     if (obj) {
         as_value proto;
         if (obj->get_member(NSV::PROP_PROTOTYPE, &proto)) {
@@ -656,7 +656,7 @@ global_assetpropflags(const fn_call& fn)
     );
     
     // object
-    boost::intrusive_ptr<as_object> obj = fn.arg(0).to_object(getGlobal(fn));
+    boost::intrusive_ptr<as_object> obj = toObject(fn.arg(0), getVM(fn));
     if ( ! obj ) {
         IF_VERBOSE_ASCODING_ERRORS(
         log_aserror(_("Invalid call to ASSetPropFlags: "
@@ -806,9 +806,7 @@ global_assetnative(const fn_call& fn)
         return as_value();
     }
 
-    Global_as& gl = getGlobal(fn);
-
-    as_object* targetObject = fn.arg(0).to_object(gl);
+    as_object* targetObject = toObject(fn.arg(0), getVM(fn));
     if (!targetObject) {
         return as_value();
     }
@@ -877,9 +875,7 @@ global_assetnativeaccessor(const fn_call& fn)
         return as_value();
     }
 
-    Global_as& gl = getGlobal(fn);
-
-    as_object* targetObject = fn.arg(0).to_object(gl);
+    as_object* targetObject = toObject(fn.arg(0), getVM(fn));
     if (!targetObject) {
         return as_value();
     }
@@ -1019,7 +1015,7 @@ global_setInterval(const fn_call& fn)
 
        unsigned timer_arg = 1;
 
-       as_object* obj = fn.arg(0).to_object(getGlobal(fn));
+       as_object* obj = toObject(fn.arg(0), getVM(fn));
        if (!obj) {
 
                IF_VERBOSE_ASCODING_ERRORS(
@@ -1091,7 +1087,7 @@ global_setTimeout(const fn_call& fn)
 
        unsigned timer_arg = 1;
 
-       as_object* obj = fn.arg(0).to_object(getGlobal(fn));
+       as_object* obj = toObject(fn.arg(0), getVM(fn));
        if (!obj) {
                IF_VERBOSE_ASCODING_ERRORS(
                        std::stringstream ss; fn.dump_args(ss);
diff --git a/libcore/asobj/Global_as.h b/libcore/asobj/Global_as.h
index 1b6fc16..ef00ddc 100644
--- a/libcore/asobj/Global_as.h
+++ b/libcore/asobj/Global_as.h
@@ -187,7 +187,7 @@ invoke(const as_value& method, const as_environment& env, 
as_object* this_ptr,
     call.callerDef = callerDef;
 
        try {
-               if (as_object* func = method.to_object(getGlobal(env))) {
+               if (as_object* func = toObject(method, getVM(env))) {
             // Call function.
                    val = func->call(call);
                }
diff --git a/libcore/asobj/LoadableObject.cpp b/libcore/asobj/LoadableObject.cpp
index 60fb7ea..4a66341 100644
--- a/libcore/asobj/LoadableObject.cpp
+++ b/libcore/asobj/LoadableObject.cpp
@@ -168,11 +168,9 @@ loadableobject_addRequestHeader(const fn_call& fn)
     as_value customHeaders;
     as_object* array;
 
-    Global_as& gl = getGlobal(fn);
-
     if (fn.this_ptr->get_member(NSV::PROP_uCUSTOM_HEADERS, &customHeaders))
     {
-        array = customHeaders.to_object(gl);
+        array = toObject(customHeaders, getVM(fn));
         if (!array)
         {
             IF_VERBOSE_ASCODING_ERRORS(
@@ -183,7 +181,7 @@ loadableobject_addRequestHeader(const fn_call& fn)
         }
     }
     else {
-        array = gl.createArray();
+        array = getGlobal(fn).createArray();
         // This property is always initialized on the first call to
         // addRequestHeaders. It has default properties.
         fn.this_ptr->init_member(NSV::PROP_uCUSTOM_HEADERS, array);
@@ -199,11 +197,10 @@ loadableobject_addRequestHeader(const fn_call& fn)
         return as_value();
     }
     
-    if (fn.nargs == 1)
-    {
+    if (fn.nargs == 1) {
         // This must be an array (or something like it). Keys / values are
         // pushed in valid pairs to the _customHeaders array.    
-        as_object* headerArray = fn.arg(0).to_object(gl);
+        as_object* headerArray = toObject(fn.arg(0), getVM(fn));
 
         if (!headerArray) {
             IF_VERBOSE_ASCODING_ERRORS(
@@ -328,7 +325,7 @@ loadableobject_sendAndLoad(const fn_call& fn)
 
     // TODO: if this isn't an XML or LoadVars, it won't work, but we should
     // check how far things get before it fails.
-    as_object* target = fn.arg(1).to_object(getGlobal(fn));
+    as_object* target = toObject(fn.arg(1), getVM(fn));
 
     // According to the Flash 8 Cookbook (Joey Lott, Jeffrey Bardzell), p 427,
     // this method sends by GET unless overridden, and always by GET in the
@@ -357,7 +354,7 @@ loadableobject_sendAndLoad(const fn_call& fn)
 
             /// Read in our custom headers if they exist and are an
             /// array.
-            as_object* array = customHeaders.to_object(getGlobal(fn));
+            as_object* array = toObject(customHeaders, getVM(fn));
             if (array) {
                 WriteHeaders wh(headers);
                 foreachArray(*array, wh);
diff --git a/libcore/asobj/Microphone_as.cpp b/libcore/asobj/Microphone_as.cpp
index af5c3b0..4daf648 100644
--- a/libcore/asobj/Microphone_as.cpp
+++ b/libcore/asobj/Microphone_as.cpp
@@ -247,7 +247,7 @@ microphone_get(const fn_call& fn)
 
     // Properties are attached to the prototype (not __proto__) when get() is
     // called. 
-    as_object* proto = getMember(*ptr, 
NSV::PROP_PROTOTYPE).to_object(getGlobal(fn));
+    as_object* proto = toObject(getMember(*ptr, NSV::PROP_PROTOTYPE), 
getVM(fn));
     attachMicrophoneProperties(*proto);
  
     // TODO: this should return the same object when the same device is
diff --git a/libcore/asobj/MovieClipLoader.cpp 
b/libcore/asobj/MovieClipLoader.cpp
index 886b786..93f0f3d 100644
--- a/libcore/asobj/MovieClipLoader.cpp
+++ b/libcore/asobj/MovieClipLoader.cpp
@@ -181,7 +181,7 @@ moviecliploader_getProgress(const fn_call& fn)
                return as_value();
        }
 
-       as_object* target = fn.arg(0).to_object(getGlobal(fn));
+       as_object* target = toObject(fn.arg(0), getVM(fn));
   
        if (!target) {
                IF_VERBOSE_ASCODING_ERRORS(
diff --git a/libcore/asobj/MovieClip_as.cpp b/libcore/asobj/MovieClip_as.cpp
index c430465..bf6d5f7 100644
--- a/libcore/asobj/MovieClip_as.cpp
+++ b/libcore/asobj/MovieClip_as.cpp
@@ -487,7 +487,7 @@ movieclip_attachMovie(const fn_call& fn)
     boost::intrusive_ptr<as_object> initObj;
 
     if (fn.nargs > 3 ) {
-        initObj = fn.arg(3).to_object(getGlobal(fn));
+        initObj = toObject(fn.arg(3), getVM(fn));
         if (!initObj) {
             // This is actually a valid thing to do,
             // the documented behaviour is to just NOT
@@ -527,7 +527,7 @@ movieclip_attachAudio(const fn_call& fn)
     }
 
     NetStream_as* ns;
-    if (!isNativeType(fn.arg(0).to_object(getGlobal(fn)), ns))
+    if (!isNativeType(toObject(fn.arg(0), getVM(fn)), ns))
     { 
         std::stringstream ss; fn.dump_args(ss);
         // TODO: find out what to do here
@@ -742,7 +742,7 @@ movieclip_duplicateMovieClip(const fn_call& fn)
     // Copy members from initObject
     if (fn.nargs == 3)
     {
-        as_object* initObject = fn.arg(2).to_object(getGlobal(fn));
+        as_object* initObject = toObject(fn.arg(2), getVM(fn));
         ch = movieclip->duplicateMovieClip(newname, depthValue, initObject);
     }
     else
@@ -1162,10 +1162,8 @@ movieclip_meth(const fn_call& fn)
 
     if (!fn.nargs) return as_value(MovieClip::METHOD_NONE); 
 
-    const as_value& v = fn.arg(0);
-    as_object* o = v.to_object(getGlobal(fn));
+    as_object* o = toObject(fn.arg(0), getVM(fn));
     if (!o) {
-        log_debug(_("meth(%s): first argument doesn't cast to object"), v);
         return as_value(MovieClip::METHOD_NONE);
     }
 
@@ -1276,7 +1274,7 @@ movieclip_globalToLocal(const fn_call& fn)
         return ret;
     }
 
-    boost::intrusive_ptr<as_object> obj = fn.arg(0).to_object(getGlobal(fn));
+    boost::intrusive_ptr<as_object> obj = toObject(fn.arg(0), getVM(fn));
     if ( ! obj )
     {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -1338,7 +1336,7 @@ movieclip_localToGlobal(const fn_call& fn)
         return ret;
     }
 
-    boost::intrusive_ptr<as_object> obj = fn.arg(0).to_object(getGlobal(fn));
+    boost::intrusive_ptr<as_object> obj = toObject(fn.arg(0), getVM(fn));
     if ( ! obj )
     {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -1410,7 +1408,7 @@ movieclip_setMask(const fn_call& fn)
     else
     {
 
-        as_object* obj = arg.to_object(getGlobal(fn));
+        as_object* obj = toObject(arg, getVM(fn));
         DisplayObject* mask = get<DisplayObject>(obj);
         if (!mask)
         {
@@ -1755,11 +1753,10 @@ movieclip_beginGradientFill(const fn_call& fn)
     }
 
     typedef boost::intrusive_ptr<as_object> ObjPtr;
-    Global_as& gl = getGlobal(fn);
-    ObjPtr colors = fn.arg(1).to_object(gl);
-    ObjPtr alphas = fn.arg(2).to_object(gl);
-    ObjPtr ratios = fn.arg(3).to_object(gl);
-    ObjPtr matrix = fn.arg(4).to_object(gl);
+    ObjPtr colors = toObject(fn.arg(1), getVM(fn));
+    ObjPtr alphas = toObject(fn.arg(2), getVM(fn));
+    ObjPtr ratios = toObject(fn.arg(3), getVM(fn));
+    ObjPtr matrix = toObject(fn.arg(4), getVM(fn));
 
     if (!colors || !alphas || !ratios || !matrix) {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -1969,7 +1966,7 @@ movieclip_beginBitmapFill(const fn_call& fn)
         return as_value();
     }
 
-    as_object* obj = fn.arg(0).to_object(getGlobal(fn));
+    as_object* obj = toObject(fn.arg(0), getVM(fn));
     BitmapData_as* bd;
 
     if (!isNativeType(obj, bd) || bd->disposed()) {
@@ -1983,7 +1980,7 @@ movieclip_beginBitmapFill(const fn_call& fn)
     SWFMatrix mat;
 
     if (fn.nargs > 1) {
-        as_object* matrix = fn.arg(1).to_object(getGlobal(fn));
+        as_object* matrix = toObject(fn.arg(1), getVM(fn));
         if (matrix) {
             mat = toSWFMatrix(*matrix);
         }
@@ -2049,7 +2046,7 @@ movieclip_attachBitmap(const fn_call& fn)
         return as_value();
     }
 
-    as_object* obj = fn.arg(0).to_object(getGlobal(fn));
+    as_object* obj = toObject(fn.arg(0), getVM(fn));
     BitmapData_as* bd;
 
     if (!isNativeType(obj, bd) || bd->disposed()) {
diff --git a/libcore/asobj/NetConnection_as.cpp 
b/libcore/asobj/NetConnection_as.cpp
index 0820fcf..bce2dfd 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -1042,7 +1042,7 @@ netconnection_call(const fn_call& fn)
     if (fn.nargs > 1) {
 
         if (fn.arg(1).is_object()) {
-            asCallback = (fn.arg(1).to_object(getGlobal(fn)));
+            asCallback = (toObject(fn.arg(1), getVM(fn)));
         }
         else {
             IF_VERBOSE_ASCODING_ERRORS(
diff --git a/libcore/asobj/NetStream_as.cpp b/libcore/asobj/NetStream_as.cpp
index b8dcacc..54dc37d 100644
--- a/libcore/asobj/NetStream_as.cpp
+++ b/libcore/asobj/NetStream_as.cpp
@@ -1618,7 +1618,7 @@ netstream_new(const fn_call& fn)
     if (fn.nargs) {
 
         NetConnection_as* nc;
-        if (isNativeType(fn.arg(0).to_object(getGlobal(fn)), nc)) {
+        if (isNativeType(toObject(fn.arg(0), getVM(fn)), nc)) {
             ns->setNetCon(nc);
         }
         else {
diff --git a/libcore/asobj/Object.cpp b/libcore/asobj/Object.cpp
index d360e9b..629717d 100644
--- a/libcore/asobj/Object.cpp
+++ b/libcore/asobj/Object.cpp
@@ -138,10 +138,8 @@ attachObjectInterface(as_object& o)
 as_value
 object_ctor(const fn_call& fn)
 {
-    Global_as& gl = getGlobal(fn);
-
     if (fn.nargs == 1) {
-        as_object* obj = fn.arg(0).to_object(gl);
+        as_object* obj = toObject(fn.arg(0), getVM(fn));
         if (obj) return as_value(obj);
     }
 
@@ -151,6 +149,8 @@ object_ctor(const fn_call& fn)
         );
     }
 
+    Global_as& gl = getGlobal(fn);
+
     if (!fn.isInstantiation()) {
         return new as_object(gl);
     }
@@ -410,7 +410,7 @@ object_isPrototypeOf(const fn_call& fn)
         return as_value(false); 
     }
 
-    as_object* arg = fn.arg(0).to_object(getGlobal(fn));
+    as_object* arg = toObject(fn.arg(0), getVM(fn));
     if (!arg) {
         IF_VERBOSE_ASCODING_ERRORS(
             log_aserror(_("First arg to Object.isPrototypeOf(%s) is "
diff --git a/libcore/asobj/Selection_as.cpp b/libcore/asobj/Selection_as.cpp
index e541ddd..556714f 100644
--- a/libcore/asobj/Selection_as.cpp
+++ b/libcore/asobj/Selection_as.cpp
@@ -212,7 +212,7 @@ selection_setFocus(const fn_call& fn)
     }
     else {
         /// Try converting directly to DisplayObject.
-        as_object* obj = focus.to_object(getGlobal(fn));
+        as_object* obj = toObject(focus, getVM(fn));
         ch = get<DisplayObject>(obj);
     }
 
diff --git a/libcore/asobj/Sound_as.cpp b/libcore/asobj/Sound_as.cpp
index e437cb9..f125c59 100644
--- a/libcore/asobj/Sound_as.cpp
+++ b/libcore/asobj/Sound_as.cpp
@@ -916,7 +916,7 @@ sound_new(const fn_call& fn)
 
         if (!arg0.is_null() && !arg0.is_undefined()) {
 
-            as_object* obj = arg0.to_object(getGlobal(fn));
+            as_object* obj = toObject(arg0, getVM(fn));
             DisplayObject* ch = get<DisplayObject>(obj);
             IF_VERBOSE_ASCODING_ERRORS(
                 if (!ch) {
diff --git a/libcore/asobj/TextField_as.cpp b/libcore/asobj/TextField_as.cpp
index 4e1b685..7e48dbd 100644
--- a/libcore/asobj/TextField_as.cpp
+++ b/libcore/asobj/TextField_as.cpp
@@ -687,7 +687,7 @@ textfield_setTextFormat(const fn_call& fn)
     }
 
     TextFormat_as* tf;
-    if (!isNativeType(fn.arg(0).to_object(getGlobal(fn)), tf)) {
+    if (!isNativeType(toObject(fn.arg(0), getVM(fn)), tf)) {
 
         IF_VERBOSE_ASCODING_ERRORS(
             std::stringstream ss; fn.dump_args(ss);
diff --git a/libcore/asobj/TextFormat_as.cpp b/libcore/asobj/TextFormat_as.cpp
index cc99c5f..7a3bf81 100644
--- a/libcore/asobj/TextFormat_as.cpp
+++ b/libcore/asobj/TextFormat_as.cpp
@@ -488,7 +488,7 @@ textformat_tabStops(const fn_call& fn)
         return null;
        }
        
-    as_object* arg = fn.arg(0).to_object(getGlobal(fn));
+    as_object* arg = toObject(fn.arg(0), getVM(fn));
     if (!arg) return as_value();
 
        std::vector<int> tabStops;
diff --git a/libcore/asobj/XMLNode_as.cpp b/libcore/asobj/XMLNode_as.cpp
index 2ef8c8f..9596ba6 100644
--- a/libcore/asobj/XMLNode_as.cpp
+++ b/libcore/asobj/XMLNode_as.cpp
@@ -124,7 +124,7 @@ XMLNode_as::object()
     if (!_object) {
         as_object* o = createObject(_global);
         as_object* xn =
-            getMember(_global, NSV::CLASS_XMLNODE).to_object(_global);
+            toObject(getMember(_global, NSV::CLASS_XMLNODE), getVM(_global));
         if (xn) {
             o->set_prototype(getMember(*xn, NSV::PROP_PROTOTYPE));
             o->init_member(NSV::PROP_CONSTRUCTOR, xn);
@@ -603,7 +603,7 @@ xmlnode_appendChild(const fn_call& fn)
        }
 
        XMLNode_as* node;
-    if (!isNativeType(fn.arg(0).to_object(getGlobal(fn)), node)) {
+    if (!isNativeType(toObject(fn.arg(0), getVM(fn)), node)) {
                IF_VERBOSE_ASCODING_ERRORS(
             log_aserror(_("First argument to XMLNode::appendChild() is not "
                     "an XMLNode"));
@@ -651,7 +651,7 @@ xmlnode_insertBefore(const fn_call& fn)
 
        XMLNode_as* newnode;
 
-    if (!isNativeType(fn.arg(0).to_object(getGlobal(fn)), newnode)) {
+    if (!isNativeType(toObject(fn.arg(0), getVM(fn)), newnode)) {
                IF_VERBOSE_ASCODING_ERRORS(
                std::stringstream ss; fn.dump_args(ss);
                log_aserror(_("First argument to XMLNode.insertBefore(%s) is 
not "
@@ -662,7 +662,7 @@ xmlnode_insertBefore(const fn_call& fn)
 
        XMLNode_as* pos;
 
-    if (!isNativeType(fn.arg(1).to_object(getGlobal(fn)), pos)) {
+    if (!isNativeType(toObject(fn.arg(1), getVM(fn)), pos)) {
                IF_VERBOSE_ASCODING_ERRORS(
         std::stringstream ss; fn.dump_args(ss);
                log_aserror(_("Second argument to XMLNode.insertBefore(%s) is 
not "
diff --git a/libcore/asobj/XML_as.cpp b/libcore/asobj/XML_as.cpp
index fac45a4..4e8b769 100644
--- a/libcore/asobj/XML_as.cpp
+++ b/libcore/asobj/XML_as.cpp
@@ -622,7 +622,7 @@ xml_new(const fn_call& fn)
 
         // Copy constructor clones nodes.
         if (fn.arg(0).is_object()) {
-            as_object* other = fn.arg(0).to_object(getGlobal(fn));
+            as_object* other = toObject(fn.arg(0), getVM(fn));
             XML_as* xml;
             if (isNativeType(other, xml)) {
                 as_object* clone = xml->cloneNode(true)->object();
diff --git a/libcore/asobj/flash/display/BitmapData_as.cpp 
b/libcore/asobj/flash/display/BitmapData_as.cpp
index 8585e89..e592a9c 100644
--- a/libcore/asobj/flash/display/BitmapData_as.cpp
+++ b/libcore/asobj/flash/display/BitmapData_as.cpp
@@ -446,7 +446,7 @@ bitmapdata_draw(const fn_call& fn)
         return as_value();
     }
 
-    as_object* o = fn.arg(0).to_object(getGlobal(fn));
+    as_object* o = toObject(fn.arg(0), getVM(fn));
     MovieClip* mc = get<MovieClip>(o);
     if (!mc) {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -460,11 +460,11 @@ bitmapdata_draw(const fn_call& fn)
 
     Transform t;
     if (fn.nargs > 1) {
-        as_object* o = fn.arg(1).to_object(getGlobal(fn));
+        as_object* o = toObject(fn.arg(1), getVM(fn));
         if (o) t.matrix = toSWFMatrix(*o);
     }
     if (fn.nargs > 2) {
-        as_object* o = fn.arg(2).to_object(getGlobal(fn));
+        as_object* o = toObject(fn.arg(2), getVM(fn));
         ColorTransform_as* tr;
         if (isNativeType(o, tr)) {
             t.colorTransform = toCxForm(*tr);
@@ -495,7 +495,7 @@ bitmapdata_fillRect(const fn_call& fn)
     }
 
     // This can be any object with the right properties.   
-    as_object* obj = arg.to_object(getGlobal(fn));
+    as_object* obj = toObject(arg, getVM(fn));
     assert(obj);
     
     as_value x, y, w, h;
diff --git a/libcore/asobj/flash/external/ExternalInterface_as.cpp 
b/libcore/asobj/flash/external/ExternalInterface_as.cpp
index f3a693c..98d95be 100644
--- a/libcore/asobj/flash/external/ExternalInterface_as.cpp
+++ b/libcore/asobj/flash/external/ExternalInterface_as.cpp
@@ -253,7 +253,7 @@ externalinterface_addCallback(const fn_call& fn)
         boost::intrusive_ptr<as_object> asCallback;
         if (fn.arg(2).is_object()) {
             log_debug("adding callback %s", name);
-            asCallback = (fn.arg(2).to_object(getGlobal(fn)));
+            asCallback = (toObject(fn.arg(2), getVM(fn)));
             mr.addExternalCallback(fn.this_ptr, name, asCallback.get());
         }
      }
@@ -418,7 +418,7 @@ externalinterface_uArgumentsToXML(const fn_call& fn)
     if (fn.nargs == 2) {
         std::vector<as_value> args;
         if (fn.arg(0).is_object()) {
-            as_object *obj = fn.arg(0).to_object(getGlobal(fn));
+            as_object *obj = toObject(fn.arg(0), getVM(fn));
             VM& vm = getVM(*obj);    
             PropsSerializer props(vm);
             obj->visitProperties<IsEnumerable>(props);
@@ -487,7 +487,7 @@ externalinterface_uArrayToXML(const fn_call& fn)
 //    GNASH_REPORT_FUNCTION;
     
     if (fn.nargs == 1) {
-        as_object *obj = fn.arg(0).to_object(getGlobal(fn));
+        as_object *obj = toObject(fn.arg(0), getVM(fn));
         std::string str = ExternalInterface::arrayToXML(obj);
         return as_value(str);
     }
@@ -568,7 +568,7 @@ externalinterface_uObjectToXML(const fn_call& fn)
     
     if (fn.nargs == 1) {
         if (!fn.arg(0).is_null() && !fn.arg(0).is_undefined()) {
-            as_object *obj = fn.arg(0).to_object(getGlobal(fn));
+            as_object *obj = toObject(fn.arg(0), getVM(fn));
             std::string str = ExternalInterface::objectToXML(obj);
             return as_value(str);
         } else {
diff --git a/libcore/asobj/flash/geom/ColorTransform_as.cpp 
b/libcore/asobj/flash/geom/ColorTransform_as.cpp
index d71872f..9235a96 100644
--- a/libcore/asobj/flash/geom/ColorTransform_as.cpp
+++ b/libcore/asobj/flash/geom/ColorTransform_as.cpp
@@ -261,7 +261,7 @@ colortransform_concat(const fn_call& fn)
         // Log error
         return as_value();
     }
-    as_object* o = fn.arg(0).to_object(getGlobal(fn));
+    as_object* o = toObject(fn.arg(0), getVM(fn));
     ColorTransform_as* tr;
     if (!isNativeType(o, tr)) {
         return as_value();
diff --git a/libcore/asobj/flash/geom/Matrix_as.cpp 
b/libcore/asobj/flash/geom/Matrix_as.cpp
index 92da3f3..a6fe271 100644
--- a/libcore/asobj/flash/geom/Matrix_as.cpp
+++ b/libcore/asobj/flash/geom/Matrix_as.cpp
@@ -201,7 +201,7 @@ matrix_concat(const fn_call& fn)
     }
 
     // The object to concatenate doesn't have to be a matrix.    
-    as_object* obj = arg.to_object(getGlobal(fn));
+    as_object* obj = toObject(arg, getVM(fn));
     assert(obj);
 
     MatrixType concatMatrix;
@@ -404,7 +404,7 @@ matrix_deltaTransformPoint(const fn_call& fn)
 
     // It doesn't have to be a point. If it has x and y
     // properties, they will be used.    
-    as_object* obj = arg.to_object(getGlobal(fn));
+    as_object* obj = toObject(arg, getVM(fn));
     assert(obj);
 
     const PointType& point = transformPoint(*obj, *ptr);
@@ -712,7 +712,7 @@ matrix_transformPoint(const fn_call& fn)
         return as_value();
     }
     
-    as_object* obj = arg.to_object(getGlobal(fn));
+    as_object* obj = toObject(arg, getVM(fn));
     assert(obj);
     if (!obj->instanceOf(getClassConstructor(fn, "flash.geom.Point"))) {
         /// Isn't a point.
diff --git a/libcore/asobj/flash/geom/Point_as.cpp 
b/libcore/asobj/flash/geom/Point_as.cpp
index 9173c0d..2e3939c 100644
--- a/libcore/asobj/flash/geom/Point_as.cpp
+++ b/libcore/asobj/flash/geom/Point_as.cpp
@@ -129,7 +129,7 @@ point_add(const fn_call& fn)
         }
         );
         const as_value& arg1 = fn.arg(0);
-        as_object* o = arg1.to_object(getGlobal(fn));
+        as_object* o = toObject(arg1, getVM(fn));
         if ( ! o )
         {
             IF_VERBOSE_ASCODING_ERRORS(
@@ -200,7 +200,7 @@ point_equals(const fn_call& fn)
         );
         return as_value(false);
     }
-    as_object* o = arg1.to_object(getGlobal(fn));
+    as_object* o = toObject(arg1, getVM(fn));
     assert(o);
     if (!o->instanceOf(getClassConstructor(fn, "flash.geom.Point")))
     {
@@ -330,7 +330,7 @@ point_subtract(const fn_call& fn)
         }
         );
         const as_value& arg1 = fn.arg(0);
-        as_object* o = arg1.to_object(getGlobal(fn));
+        as_object* o = toObject(arg1, getVM(fn));
         if ( ! o )
         {
             IF_VERBOSE_ASCODING_ERRORS(
@@ -440,7 +440,7 @@ point_distance(const fn_call& fn)
         );
         return as_value();
     }
-    as_object* o1 = arg1.to_object(getGlobal(fn));
+    as_object* o1 = toObject(arg1, getVM(fn));
     assert(o1);
     if (!o1->instanceOf(getClassConstructor(fn, "flash.geom.Point")))
     {
@@ -452,7 +452,7 @@ point_distance(const fn_call& fn)
     }
 
     const as_value& arg2 = fn.arg(1);
-    as_object* o2 = arg2.to_object(getGlobal(fn));
+    as_object* o2 = toObject(arg2, getVM(fn));
     assert(o2);
     // it seems there's no need to check arg2 (see actionscript.all/Point.as)
 
@@ -512,7 +512,7 @@ point_interpolate(const fn_call& fn)
         );
 
         const as_value& p0val = fn.arg(0);
-        as_object* p0 = p0val.to_object(getGlobal(fn));
+        as_object* p0 = toObject(p0val, getVM(fn));
         if ( ! p0 )
         {
             IF_VERBOSE_ASCODING_ERRORS(
@@ -527,7 +527,7 @@ point_interpolate(const fn_call& fn)
         }
 
         const as_value& p1val = fn.arg(1);
-        as_object* p1 = p1val.to_object(getGlobal(fn));
+        as_object* p1 = toObject(p1val, getVM(fn));
         if ( ! p1 )
         {
             IF_VERBOSE_ASCODING_ERRORS(
diff --git a/libcore/asobj/flash/geom/Rectangle_as.cpp 
b/libcore/asobj/flash/geom/Rectangle_as.cpp
index 3cf1587..26b7063 100644
--- a/libcore/asobj/flash/geom/Rectangle_as.cpp
+++ b/libcore/asobj/flash/geom/Rectangle_as.cpp
@@ -232,7 +232,7 @@ Rectangle_containsPoint(const fn_call& fn)
 {
     as_object* ptr = ensure<ValidThis>(fn);
 
-    as_object* arg = (fn.nargs > 0) ? fn.arg(0).to_object(getGlobal(fn)) : 0;
+    as_object* arg = (fn.nargs > 0) ? toObject(fn.arg(0), getVM(fn)) : 0;
     
     VM& vm = getVM(fn);
 
diff --git a/libcore/asobj/flash/geom/Transform_as.cpp 
b/libcore/asobj/flash/geom/Transform_as.cpp
index 0b688dd..507847a 100644
--- a/libcore/asobj/flash/geom/Transform_as.cpp
+++ b/libcore/asobj/flash/geom/Transform_as.cpp
@@ -153,7 +153,7 @@ transform_colorTransform(const fn_call& fn)
         );
     }
 
-    as_object* obj = fn.arg(0).to_object(getGlobal(fn));
+    as_object* obj = toObject(fn.arg(0), getVM(fn));
     if (!obj) {
         IF_VERBOSE_ASCODING_ERRORS(
             std::ostringstream ss;
@@ -313,7 +313,7 @@ transform_matrix(const fn_call& fn)
     }
 
 
-    as_object* obj = fn.arg(0).to_object(getGlobal(fn));
+    as_object* obj = toObject(fn.arg(0), getVM(fn));
     if (!obj)
     {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -369,7 +369,7 @@ transform_ctor(const fn_call& fn)
     }
 
     // TODO: does this have to be a MovieClip or can it be any DisplayObject?
-    as_object* o = fn.arg(0).to_object(getGlobal(fn));
+    as_object* o = toObject(fn.arg(0), getVM(fn));
     MovieClip* mc = get<MovieClip>(o);
 
     if (!mc) return as_value();
diff --git a/libcore/debugger.cpp b/libcore/debugger.cpp
index f316bf8..f1591a0 100644
--- a/libcore/debugger.cpp
+++ b/libcore/debugger.cpp
@@ -567,7 +567,7 @@ Debugger::dumpStackFrame(as_environment &env)
 // FIXME: we want to print the name of the function
 //         if (val.is_function()) {
 // //          cerr << val.get_symbol_handle() << endl;
-//             string name = this->lookupSymbol(val.to_object(getGlobal(fn)));
+//             string name = this->lookupSymbol(toObject(val, getVM(fn)));
 //             if (name.size()) {
 //                 cerr << name << " ";
 //             }
@@ -575,8 +575,8 @@ Debugger::dumpStackFrame(as_environment &env)
         cerr << env.bottom(i);
 
            if (val.is_object()) {
-               boost::intrusive_ptr<as_object> o = 
val.to_object(getGlobal(env));
-               string name = lookupSymbol(o.get());
+                   as_object* o = toObject(val, getVM(env));
+            string name = lookupSymbol(o);
                if (name.size()) {
                    cerr << " \"" << name << "\"";
                }
diff --git a/libcore/movie_root.cpp b/libcore/movie_root.cpp
index d0deb45..d64c525 100644
--- a/libcore/movie_root.cpp
+++ b/libcore/movie_root.cpp
@@ -2580,7 +2580,7 @@ getBuiltinObject(movie_root& mr, string_table::key cl)
 
     as_value val;
     if (!gl.get_member(cl, &val)) return 0;
-    return val.to_object(gl);
+    return toObject(val, mr.getVM());
 }
 
 void
diff --git a/libcore/parser/sprite_definition.cpp 
b/libcore/parser/sprite_definition.cpp
index 824632d..589e359 100644
--- a/libcore/parser/sprite_definition.cpp
+++ b/libcore/parser/sprite_definition.cpp
@@ -139,9 +139,9 @@ sprite_definition::registerClass(as_function* the_class)
 
        log_debug(_("Registered class %p for sprite_def %p"),
             (void*)registeredClass.get(), (void*)this);
-       as_object* proto =
-        getMember(*registeredClass, NSV::PROP_PROTOTYPE).to_object(
-                getGlobal(*registeredClass));
+       as_object* proto = toObject(
+            getMember(*registeredClass, NSV::PROP_PROTOTYPE),
+                getVM(*registeredClass));
 
        log_debug(_(" Exported interface: "));
        proto->dump_members();
diff --git a/libcore/vm/ASHandlers.cpp b/libcore/vm/ASHandlers.cpp
index 8934081..e0e811b 100644
--- a/libcore/vm/ASHandlers.cpp
+++ b/libcore/vm/ASHandlers.cpp
@@ -84,7 +84,7 @@ namespace {
 
     as_object* construct_object(as_function* ctor_as_func, as_environment& env,
             unsigned int nargs);
-    as_object* toObject(Global_as& gl, const as_value& val);
+    as_object* safeToObject(Global_as& gl, const as_value& val);
 
     /// Common code for ActionGetUrl and ActionGetUrl2
     //
@@ -1334,10 +1334,10 @@ ActionCastOp(ActionExec& thread)
     as_environment& env = thread.env;
 
     // Get the "instance"
-    as_object* instance = toObject(getGlobal(thread.env), env.top(0));
+    as_object* instance = safeToObject(getGlobal(thread.env), env.top(0));
 
     // Get the "super" function
-    as_object* super = toObject(getGlobal(thread.env), env.top(1));
+    as_object* super = safeToObject(getGlobal(thread.env), env.top(1));
 
     // Invalid args!
     if (!super || ! instance)
@@ -1385,7 +1385,7 @@ ActionImplementsOp(ActionExec& thread)
     as_environment& env = thread.env;
 
     as_value objval = env.pop();
-    as_object* obj = toObject(getGlobal(thread.env), objval);
+    as_object* obj = safeToObject(getGlobal(thread.env), objval);
     int count = toNumber(env.pop(), getVM(env));
 
     if (!obj) {
@@ -1403,7 +1403,7 @@ ActionImplementsOp(ActionExec& thread)
         );
         return;
     }
-    obj = toObject(getGlobal(thread.env), protoval);
+    obj = safeToObject(getGlobal(thread.env), protoval);
     if (!obj) {
         IF_VERBOSE_ASCODING_ERRORS(
             log_aserror(_("IMPLEMENTSOP target object's prototype is not "
@@ -1422,7 +1422,7 @@ ActionImplementsOp(ActionExec& thread)
 
     while (count--) {
         as_value ctorval = env.pop();
-        as_object* ctor = toObject(getGlobal(thread.env), ctorval);
+        as_object* ctor = safeToObject(getGlobal(thread.env), ctorval);
         if (!ctor) {
             IF_VERBOSE_ASCODING_ERRORS(
                 log_aserror(_("class found on stack on IMPLEMENTSOP is "
@@ -1437,7 +1437,7 @@ ActionImplementsOp(ActionExec& thread)
             );
             continue;
         }
-        as_object *inter = toObject(getGlobal(thread.env), protoval);
+        as_object *inter = safeToObject(getGlobal(thread.env), protoval);
         if (!inter) {
             IF_VERBOSE_ASCODING_ERRORS(
                 log_aserror(_("Prototype of interface object for "
@@ -2208,7 +2208,7 @@ ActionDelete(ActionExec& thread)
             // Don't create an object! Only get the value if it is an object
             // already.
             if (target.is_object()) {
-                obj = toObject(getGlobal(thread.env), target);
+                obj = safeToObject(getGlobal(thread.env), target);
                 propertyname = var;
             }
         }
@@ -2217,7 +2217,7 @@ ActionDelete(ActionExec& thread)
         // Don't create an object! Only get the value if it is an object
         // already.
         if (env.top(1).is_object()) {
-            obj = toObject(getGlobal(thread.env), env.top(1));
+            obj = safeToObject(getGlobal(thread.env), env.top(1));
         }
     }
 
@@ -2273,7 +2273,7 @@ ActionDelete2(ActionExec& thread)
         return;
     }
 
-    as_object* obj = toObject(getGlobal(thread.env), target);
+    as_object* obj = safeToObject(getGlobal(thread.env), target);
     env.top(1).set_bool(thread.delObjectMember(*obj, var));
 }
 
@@ -2327,7 +2327,7 @@ ActionCallFunction(ActionExec& thread)
         )
     }
     else if (!function.is_function()) {
-        as_object* obj = function.to_object(getGlobal(thread.env));
+        as_object* obj = toObject(function, getVM(thread.env));
         super = obj->get_super();
         this_ptr = thread.getThisPointer();
     }
@@ -2587,7 +2587,7 @@ ActionEnumerate(ActionExec& thread)
 
     env.top(0).set_undefined();
 
-    const boost::intrusive_ptr<as_object> obj = 
toObject(getGlobal(thread.env), variable);
+    const as_object* obj = safeToObject(getGlobal(thread.env), variable);
     if ( !obj || !variable.is_object() )
     {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -2696,8 +2696,7 @@ ActionGetMember(ActionExec& thread)
     as_value member_name = env.top(0);
     as_value target = env.top(1);
 
-    boost::intrusive_ptr<as_object> obj =
-        toObject(getGlobal(thread.env), target);
+    as_object* obj = safeToObject(getGlobal(thread.env), target);
     if (!obj)
     {
         IF_VERBOSE_ASCODING_ERRORS(
@@ -2710,9 +2709,9 @@ ActionGetMember(ActionExec& thread)
         return;
     }
 
-    IF_VERBOSE_ACTION (
-    log_action(_(" ActionGetMember: target: %s (object %p)"),
-               target, static_cast<void *>(obj.get()));
+    IF_VERBOSE_ACTION(
+        log_action(_(" ActionGetMember: target: %s (object %p)"),
+                   target, static_cast<void*>(obj));
     );
 
     string_table& st = getStringTable(env);
@@ -2745,7 +2744,7 @@ ActionSetMember(ActionExec& thread)
     
     as_environment& env = thread.env;
 
-    boost::intrusive_ptr<as_object> obj = toObject(getGlobal(thread.env), 
env.top(2));
+    as_object* obj = safeToObject(getGlobal(thread.env), env.top(2));
     const std::string& member_name = env.top(1).to_string();
     const as_value& member_value = env.top(0);
 
@@ -2849,7 +2848,7 @@ ActionCallMethod(ActionExec& thread)
         log_action(_(" method nargs: %d"), nargs);
     );
 
-    as_object* obj = toObject(getGlobal(thread.env), obj_value);
+    as_object* obj = safeToObject(getGlobal(thread.env), obj_value);
     if (!obj) {
         // If this value is not an object, it can neither have any members
         // nor be called as a function, so neither opcode usage is possible.
@@ -2899,7 +2898,7 @@ ActionCallMethod(ActionExec& thread)
             return;
         }
 
-        method_obj = toObject(getGlobal(thread.env), method_value);
+        method_obj = safeToObject(getGlobal(thread.env), method_value);
         if ( ! method_obj ) {
             IF_VERBOSE_ASCODING_ERRORS(
             log_aserror(_("ActionCallMethod: "
@@ -2995,7 +2994,7 @@ ActionNewMethod(ActionExec& thread)
         nargs = available_args;
     }
 
-    boost::intrusive_ptr<as_object> obj = toObject(getGlobal(thread.env), 
obj_val);
+    as_object* obj = safeToObject(getGlobal(thread.env), obj_val);
     if (!obj) {
         // SWF integrity check
         // FIXME, should this be log_swferror?  Or log_aserror?
@@ -3060,11 +3059,11 @@ ActionInstanceOf(ActionExec& thread)
     as_environment& env = thread.env;
 
     // Get the "super" function
-    as_object* super = toObject(getGlobal(thread.env), env.top(0));
+    as_object* super = safeToObject(getGlobal(thread.env), env.top(0));
 
     // Get the "instance" (but avoid implicit conversion of primitive values!)
     as_object* instance = env.top(1).is_object() ?
-        toObject(getGlobal(thread.env), env.top(1)) : NULL;
+        safeToObject(getGlobal(thread.env), env.top(1)) : 0;
 
     // Invalid args!
     if (!super || ! instance) {
@@ -3096,7 +3095,7 @@ ActionEnum2(ActionExec& thread)
     // as we copied that as_value.
     env.top(0).set_undefined();
 
-    as_object* obj = toObject(getGlobal(thread.env), obj_val);
+    as_object* obj = safeToObject(getGlobal(thread.env), obj_val);
     if (!obj || !obj_val.is_object()) {
         IF_VERBOSE_ASCODING_ERRORS(
         log_aserror(_("Top of stack not an object %s at ActionEnum2 "
@@ -3229,9 +3228,7 @@ ActionExtends(ActionExec& thread)
 
     as_environment& env = thread.env;
 
-    Global_as& gl = getGlobal(thread.env);
-
-    as_object* super = env.top(0).to_object(gl);
+    as_object* super = toObject(env.top(0), getVM(thread.env));
     as_function* sub = env.top(1).to_function();
 
     if (!super ||!sub) {
@@ -3250,8 +3247,9 @@ ActionExtends(ActionExec& thread)
     }
     env.drop(2);
 
-    as_object* newproto = new as_object(gl);
-    as_object* p = getMember(*super, NSV::PROP_PROTOTYPE).to_object(gl);
+    as_object* newproto = new as_object(getGlobal(thread.env));
+    as_object* p =
+        toObject(getMember(*super, NSV::PROP_PROTOTYPE), getVM(thread.env));
     newproto->set_prototype(p);
 
     if (getSWFVersion(*super) > 5) {
@@ -3448,7 +3446,7 @@ ActionWith(ActionExec& thread)
 #endif
 
     const as_value& val = env.pop();
-    as_object* with_obj = val.to_object(getGlobal(thread.env));
+    as_object* with_obj = toObject(val, getVM(thread.env));
 
     ++pc; // skip tag code
 
@@ -3572,18 +3570,6 @@ ActionDefineFunction(ActionExec& thread)
         );
 
         thread.setVariable(name, function_value);
-#ifdef USE_DEBUGGER
-        // WARNING: toObject(getGlobal(thread.env), new_obj) can return a 
newly allocated
-        //          thing into the intrusive_ptr, so the debugger
-        //          will be left with a deleted object !!
-        //          Rob: we don't want to use void pointers here..
-        boost::intrusive_ptr<as_object> o = toObject(getGlobal(thread.env), 
function_value);
-#ifndef GNASH_USE_GC
-        o->add_ref(); // this will leak, but at least debugger won't end up
-                  // with a dandling reference...
-#endif //ndef GNASH_USE_GC
-                debugger.addSymbol(o.get(), name);
-#endif
     }
 
     // Otherwise push the function literal on the stack
@@ -3620,13 +3606,13 @@ ActionUnsupported(ActionExec& thread)
 }
 
 as_object*
-toObject(Global_as& gl, const as_value& val)
+safeToObject(Global_as& gl, const as_value& val)
 {
 
     try {
-        return val.to_object(gl);
+        return toObject(val, getVM(gl));
     }
-    catch (const GnashException& gl) {
+    catch (const GnashException&) {
         return 0;
     }
 
diff --git a/libcore/vm/VM.cpp b/libcore/vm/VM.cpp
index 7025f1c..d630596 100644
--- a/libcore/vm/VM.cpp
+++ b/libcore/vm/VM.cpp
@@ -460,7 +460,7 @@ toNumber(const as_value& v, const VM& vm)
 as_object*
 toObject(const as_value& v, const VM& vm)
 {
-    return v.to_object(*vm.getGlobal());
+    return v.to_object(vm);
 }
 
 boost::int32_t

http://git.savannah.gnu.org/cgit//commit/?id=1ccc57a06173668a903b1f177889f50cf5b97fb8


commit 1ccc57a06173668a903b1f177889f50cf5b97fb8
Author: Benjamin Wolsey <address@hidden>
Date:   Sat Oct 9 09:47:53 2010 +0200

    Add toObject() function

diff --git a/libcore/vm/VM.cpp b/libcore/vm/VM.cpp
index 6e1b581..7025f1c 100644
--- a/libcore/vm/VM.cpp
+++ b/libcore/vm/VM.cpp
@@ -457,6 +457,12 @@ toNumber(const as_value& v, const VM& vm)
     return v.to_number(vm.getSWFVersion());
 }
 
+as_object*
+toObject(const as_value& v, const VM& vm)
+{
+    return v.to_object(*vm.getGlobal());
+}
+
 boost::int32_t
 toInt(const as_value& v, const VM& vm)
 {
diff --git a/libcore/vm/VM.h b/libcore/vm/VM.h
index 8e9f8e6..eb4cb7f 100644
--- a/libcore/vm/VM.h
+++ b/libcore/vm/VM.h
@@ -396,6 +396,13 @@ bool toBool(const as_value& v, const VM& vm);
 /// @return     The double value of the passed as_value.
 double toNumber(const as_value& v, const VM& vm);
 
+/// Convert an as_value to an object
+//
+/// @param val  The value to return as an object
+/// @param vm   The VM to use for the conversion.
+/// @return     The Object representation value of the passed as_value.
+as_object* toObject(const as_value& v, const VM& vm);
+
 /// AS2-compatible conversion to 32bit integer
 //
 /// This truncates large numbers to fit in the 32-bit space. It is not a 

http://git.savannah.gnu.org/cgit//commit/?id=3b6bfc5cb1928ab6f8801f48f46981926b7c3c73


commit 3b6bfc5cb1928ab6f8801f48f46981926b7c3c73
Author: Benjamin Wolsey <address@hidden>
Date:   Sat Oct 9 09:42:26 2010 +0200

    Header cleanup, consolidate movie_root::reset.

diff --git a/libcore/DisplayObject.h b/libcore/DisplayObject.h
index 2e939f2..254d850 100644
--- a/libcore/DisplayObject.h
+++ b/libcore/DisplayObject.h
@@ -31,7 +31,8 @@
 #include <boost/cstdint.hpp> // For C99 int types
 #include <boost/noncopyable.hpp>
 
-#include "ObjectURI.h" // for composition
+#include "ObjectURI.h" 
+#include "GC.h"
 #include "Transform.h"
 #include "event_id.h" 
 #include "SWFRect.h"
@@ -39,7 +40,6 @@
 #include "SWFCxForm.h"
 #include "dsodefs.h" 
 #include "snappingrange.h"
-#include "VM.h"
 #ifdef USE_SWFTREE
 # include "tree.hh"
 #endif
@@ -50,6 +50,8 @@
 // Forward declarations
 namespace gnash {
     class MovieClip;
+    class movie_root;
+    class fn_call;
     class Movie;
     class ExecutableCode;
     class action_buffer;
@@ -60,6 +62,7 @@ namespace gnash {
     class as_object;
     class as_value;
     class as_environment;
+    class DisplayObject;
     namespace SWF {
         class TextRecord;
     }
diff --git a/libcore/MorphShape.cpp b/libcore/MorphShape.cpp
index c0a0113..0cc0db3 100644
--- a/libcore/MorphShape.cpp
+++ b/libcore/MorphShape.cpp
@@ -19,7 +19,7 @@
 //
 
 #include "MorphShape.h"
-#include "VM.h"
+
 #include "swf/ShapeRecord.h"
 #include "Geometry.h"
 #include "SWFMatrix.h"
diff --git a/libcore/RunResources.h b/libcore/RunResources.h
index 206827f..4dcbde7 100644
--- a/libcore/RunResources.h
+++ b/libcore/RunResources.h
@@ -70,7 +70,7 @@ public:
     /// This isn't optional. It must always be available, or nothing
     /// can be loaded.
     //
-    /// @return     A StreamProvider (presently a global singleton).
+    /// @return     A StreamProvider 
     const StreamProvider& streamProvider() const {
         assert (_streamProvider.get());
         return *_streamProvider;
diff --git a/libcore/Timers.h b/libcore/Timers.h
index 8e6de31..5a1b946 100644
--- a/libcore/Timers.h
+++ b/libcore/Timers.h
@@ -37,7 +37,6 @@ namespace gnash {
 /// An interval timer.
 //
 /// This is constructed when _global.setInterval() is called.
-/// Instances of this class will be stored in the movie_root singleton.
 ///
 /// A timer has a function to call, a context in which to call it, a
 /// list of arguments and an interval specifying how often the function must be
diff --git a/libcore/as_function.cpp b/libcore/as_function.cpp
index a7cd208..199dc53 100644
--- a/libcore/as_function.cpp
+++ b/libcore/as_function.cpp
@@ -43,24 +43,6 @@ namespace {
     as_value function_ctor(const fn_call& fn);
 }
 
-// This function returns the singleton
-// instance of the ActionScript Function object
-// prototype, which is what the AS Function class
-// exports, thus what each AS function instance inherit.
-// 
-// The returned object can be accessed by ActionScript
-// code through Function.__proto__.prototype.
-// User AS code can add or modify members of this object
-// to modify behaviour of all Function AS instances.
-// 
-// FIXME: do not use a static specifier for the proto
-// object, as multiple runs of a single movie should
-// each use a 'clean', unmodified, version of the
-// prototype. What should really happen is that this
-// prototype gets initializated by initialization of
-// the Function class itself, which would be a member
-// of the _global object for each movie instance.
-
 as_function::as_function(Global_as& gl)
        :
        as_object(gl)
diff --git a/libcore/movie_root.cpp b/libcore/movie_root.cpp
index b9d4628..d0deb45 100644
--- a/libcore/movie_root.cpp
+++ b/libcore/movie_root.cpp
@@ -503,16 +503,10 @@ movie_root::reset()
 {
     sound::sound_handler* sh = _runResources.soundHandler();
     if (sh) sh->reset();
-    clear();
-    _disableScripts = false;
-}
 
-void
-movie_root::clear()
-{
     // reset background color, to allow 
     // next load to set it again.
-    m_background_color.set(255,255,255,255);
+    m_background_color.set(255, 255, 255, 255);
     m_background_color_set = false;
 
     // wipe out live chars
@@ -542,6 +536,8 @@ movie_root::clear()
 #endif
 
     setInvalidated();
+
+    _disableScripts = false;
 }
 
 void
diff --git a/libcore/movie_root.h b/libcore/movie_root.h
index b70b9e3..d7d4041 100644
--- a/libcore/movie_root.h
+++ b/libcore/movie_root.h
@@ -68,6 +68,16 @@
 #include "gnashconfig.h" //USE_SWFTREE
 #endif
 
+#include <map>
+#include <string>
+#include <vector>
+#include <deque>
+#include <list>
+#include <set>
+#include <bitset>
+#include <boost/noncopyable.hpp>
+#include <boost/thread/thread.hpp>
+
 #include "smart_ptr.h" // GNASH_USE_GC
 #include "dsodefs.h" // DSOEXPORT
 #include "MouseButtonState.h" // for composition
@@ -80,6 +90,7 @@
 #include "MovieLoader.h"
 #include "ExternalInterface.h"
 #include "GC.h"
+#include "VM.h"
 
 #ifdef USE_SWFTREE
 # include "tree.hh"
@@ -94,16 +105,6 @@
 # define GNASH_PARANOIA_LEVEL 1
 #endif
 
-#include <map>
-#include <string>
-#include <vector>
-#include <deque>
-#include <list>
-#include <set>
-#include <bitset>
-#include <boost/noncopyable.hpp>
-#include <boost/thread/thread.hpp>
-
 // Forward declarations
 namespace gnash {
     class ExecutableCode; // for ActionQueue
@@ -114,16 +115,16 @@ namespace gnash {
     class IOChannel;
     class RunResources;
     class Button;
+    class VM;
 }
 
-namespace gnash
-{
+namespace gnash {
 
 struct DepthComparator
 {
     typedef MovieClip* LevelMovie;
 
-    bool operator() (const LevelMovie& d1, const LevelMovie& d2)
+    bool operator()(const LevelMovie& d1, const LevelMovie& d2) const
     {
         return d1->get_depth() < d2->get_depth();
     }
@@ -635,13 +636,6 @@ public:
         _liveChars.push_front(ch);
     }
 
-    /// Cleanup all resources and run the GC collector
-    //
-    /// This method should be invoked before calling setRootMovie again
-    /// for a clean restart.
-    ///
-    void clear();
-
     /// Reset stage to its initial state
     void reset();
 
diff --git a/libcore/vm/VM.h b/libcore/vm/VM.h
index 3af3697..8e9f8e6 100644
--- a/libcore/vm/VM.h
+++ b/libcore/vm/VM.h
@@ -70,12 +70,8 @@ namespace gnash {
 //
 /// This header also contains a few utility functions for ActionScript
 /// operations.
-//
-/// Currently the VM is a singleton, but this usage is deprecated. In future
-/// is should be fully re-entrant.
 class DSOEXPORT VM : boost::noncopyable
 {
-
 public:
 
        typedef as_value (*as_c_function_ptr)(const fn_call& fn);
diff --git a/testsuite/MovieTester.cpp b/testsuite/MovieTester.cpp
index 92ce425..1c1921b 100644
--- a/testsuite/MovieTester.cpp
+++ b/testsuite/MovieTester.cpp
@@ -582,7 +582,7 @@ MovieTester::initTestingMediaHandlers()
 void
 MovieTester::restart() 
 {
-    _movie_root->clear(); // restart();
+    _movie_root->reset(); 
     MovieClip::MovieVariables v;
     // We pass 'v' twice, as the second one is for scriptable
     // Variables, which isn't fully implemented yet.
diff --git a/utilities/processor.cpp b/utilities/processor.cpp
index 019b0d7..0d59d6c 100644
--- a/utilities/processor.cpp
+++ b/utilities/processor.cpp
@@ -584,21 +584,14 @@ play_movie(const std::string& filename, const 
RunResources& runResources)
     // destruction when core gnash doesn't need it anymore
     md = 0;
 
-    log_debug("-- Clearning movie_root");
-
-    // clear movie_root (shouldn't have bad consequences on itself)
-    m.clear();
-
-    log_debug("-- Clearning gnash");
+    log_debug("-- Cleaning gnash");
  
     // Clear resources.
     // Forces run of GC, which in turn may invoke
     // destuctors of (say) MovieClip which would try
     // to access the movie_root to unregister self
     //
-    // This means that movie_root must be available
-    // while gnash::clear() runs
-    // 
+    // This means that movie_root must be available.
     MovieFactory::clear();
 
     return true;

http://git.savannah.gnu.org/cgit//commit/?id=1ff2df07c59157b84e56d2c13c4ed65c8083673b


commit 1ff2df07c59157b84e56d2c13c4ed65c8083673b
Author: Benjamin Wolsey <address@hidden>
Date:   Sat Oct 9 08:32:51 2010 +0200

    Clean up includes.

diff --git a/libcore/MovieClip.cpp b/libcore/MovieClip.cpp
index a2beec8..309f174 100644
--- a/libcore/MovieClip.cpp
+++ b/libcore/MovieClip.cpp
@@ -22,9 +22,15 @@
 #include "gnashconfig.h" // USE_SWFTREE 
 #endif
 
-#include "MovieFactory.h"
-#include "log.h" 
 #include "MovieClip.h"
+
+#include <vector>
+#include <string>
+#include <algorithm> // for std::swap
+#include <boost/algorithm/string/case_conv.hpp>
+#include <boost/bind.hpp>
+
+#include "log.h" 
 #include "movie_definition.h"
 #include "as_value.h"
 #include "as_function.h"
@@ -59,12 +65,6 @@
 #include "RunResources.h"
 #include "Transform.h"
 
-#include <vector>
-#include <string>
-#include <algorithm> // for std::swap
-#include <boost/algorithm/string/case_conv.hpp>
-#include <boost/bind.hpp>
-
 namespace gnash {
 
 //#define GNASH_DEBUG 1
diff --git a/libcore/swf/ExportAssetsTag.h b/libcore/swf/ExportAssetsTag.h
index 6f78f48..ec4a40d 100644
--- a/libcore/swf/ExportAssetsTag.h
+++ b/libcore/swf/ExportAssetsTag.h
@@ -28,7 +28,6 @@
 #include "Movie.h"
 #include "MovieClip.h"
 #include "SWFStream.h"
-#include "MovieFactory.h"
 #include "log.h"
 
 namespace gnash {
diff --git a/libcore/swf/tag_loaders.cpp b/libcore/swf/tag_loaders.cpp
index ad0e6a3..84c3397 100644
--- a/libcore/swf/tag_loaders.cpp
+++ b/libcore/swf/tag_loaders.cpp
@@ -50,7 +50,6 @@
 #include "MediaHandler.h"
 #include "SimpleBuffer.h"
 #include "sound_handler.h"
-#include "MovieFactory.h"
 #include "RunResources.h"
 #include "Renderer.h"
 #include "Movie.h"

http://git.savannah.gnu.org/cgit//commit/?id=83bd299caa019f782d067e3ea47376ae9ee40609


commit 83bd299caa019f782d067e3ea47376ae9ee40609
Author: Benjamin Wolsey <address@hidden>
Date:   Sat Oct 9 08:26:11 2010 +0200

    Drop global clear() function.

diff --git a/cygnal/cvm.cpp b/cygnal/cvm.cpp
index 31690f7..d03114d 100644
--- a/cygnal/cvm.cpp
+++ b/cygnal/cvm.cpp
@@ -551,7 +551,7 @@ play_movie(const std::string& filename, const RunResources& 
runResources)
     }
  
     // Clear resources.
-    gnash::clear();
+    MovieFactory::clear();
     
     return md;
 }
diff --git a/gui/Player.cpp b/gui/Player.cpp
index ac635b4..e55ef38 100644
--- a/gui/Player.cpp
+++ b/gui/Player.cpp
@@ -541,7 +541,7 @@ Player::run(int argc, char* argv[], const std::string& 
infile,
     log_debug("Main loop ended, cleaning up");
 
     // Clean up as much as possible, so valgrind will help find actual leaks.
-    gnash::clear();
+    MovieFactory::clear();
 
 }
 
diff --git a/libcore/Makefile.am b/libcore/Makefile.am
index d3407b9..ec5311e 100644
--- a/libcore/Makefile.am
+++ b/libcore/Makefile.am
@@ -119,7 +119,6 @@ libgnashcore_la_SOURCES = \
        FillStyle.cpp \
        Font.cpp \
        fontlib.cpp \
-       impl.cpp \
        LoadVariablesThread.cpp \
        SWFStream.cpp \
        LineStyle.cpp \
diff --git a/libcore/MovieFactory.cpp b/libcore/MovieFactory.cpp
index 3231ce1..90fb6c3 100644
--- a/libcore/MovieFactory.cpp
+++ b/libcore/MovieFactory.cpp
@@ -31,6 +31,7 @@
 #include "URL.h"
 #include "StreamProvider.h"
 #include "MovieLibrary.h"
+#include "fontlib.h"
 
 #include <string>
 #include <map>
@@ -326,6 +327,12 @@ MovieFactory::makeMovie(const URL& url, const 
RunResources& runResources,
     return mov;
 }
 
+void
+MovieFactory::clear()
+{
+    movieLibrary.clear();
+    fontlib::clear();
+}
 
 } // namespace gnash
 
diff --git a/libcore/MovieFactory.h b/libcore/MovieFactory.h
index 7fa1e46..de9278f 100644
--- a/libcore/MovieFactory.h
+++ b/libcore/MovieFactory.h
@@ -115,6 +115,11 @@ public:
             const std::string& url, const RunResources& runResources,
             bool startLoaderThread);
 
+    /// Clear the MovieFactory resources
+    //
+    /// This should be in the dtor.
+    static void clear();
+
     static MovieLibrary movieLibrary;
 };
 
diff --git a/libcore/gnash.h b/libcore/gnash.h
index de90fd8..a32e72d 100644
--- a/libcore/gnash.h
+++ b/libcore/gnash.h
@@ -24,8 +24,6 @@
 #ifndef GNASH_H
 #define GNASH_H
 
-#include "dsodefs.h"
-
 /// Freedom bites
 namespace gnash {
 
@@ -40,18 +38,6 @@ enum Quality
     QUALITY_BEST
 };
 
-/// Maximum release of resources. 
-//
-/// Calls clear_library() and
-/// fontlib::clear(), and also clears some extra internal stuff
-/// that may have been allocated (e.g. global ActionScript
-/// objects).  This should get all gnash structures off the
-/// heap, with the exception of any objects that are still
-/// referenced by the host program and haven't had drop_ref()
-/// called on them.
-///
-DSOEXPORT void clear();
-
 }   // namespace gnash
 
 #endif // GNASH_H
diff --git a/libcore/impl.cpp b/libcore/impl.cpp
deleted file mode 100644
index 9f472d7..0000000
--- a/libcore/impl.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-// impl.cpp:  Implement ActionScript tags, movie loading, library, for Gnash.
-// 
-//   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-//   Foundation, Inc
-// 
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 3 of the License, or
-// (at your option) any later version.
-// 
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-//
-
-#include "MovieFactory.h"
-#include "smart_ptr.h" // GNASH_USE_GC
-#include "IOChannel.h"
-#include "utility.h"
-#include "fontlib.h"
-#include "log.h"
-#include "GnashImage.h"
-#include "sprite_definition.h"
-#include "SWFMovieDefinition.h"
-#include "BitmapMovieDefinition.h"
-#include "RunResources.h"
-#include "URL.h"
-#include "StreamProvider.h"
-#include "MovieClip.h"
-#include "VM.h"
-#include "MovieLibrary.h"
-#include "gnash.h" // DSOEXPORTS
-#include "movie_root.h"
-
-#ifdef GNASH_USE_GC
-#include "GC.h"
-#endif
-
-#include <string>
-#include <map>
-#include <memory> // for auto_ptr
-#include <algorithm>
-
-namespace gnash
-{
-
-//
-// global gnash management
-//
-
-// Maximum release of resources.
-void  clear()
-{
-    // Ideally, we should make sure that function properly signals all threads
-    // about exiting and giving them a chance to cleanly exit.
-    //
-    // If we clear shared memory here we're going to leave threads possibly
-    // accessing deleted memory, which would trigger a segfault.
-    //
-    // My experience is that calling exit(), altought it has the same problem,
-    // reduces the chances of segfaulting ...
-    //
-    // We want this fixed anyway as exit()
-    // itselt can also trigger segfaults.
-    //
-    // See task task #6959 and depending items
-    //
-    log_debug("Any segfault past this message is likely due to improper "
-            "threads cleanup.");
-
-    MovieFactory::movieLibrary.clear();
-    fontlib::clear();
-
-}
-
-} // namespace gnash
-
-// Local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:
diff --git a/utilities/processor.cpp b/utilities/processor.cpp
index 5d78b8e..019b0d7 100644
--- a/utilities/processor.cpp
+++ b/utilities/processor.cpp
@@ -599,7 +599,7 @@ play_movie(const std::string& filename, const RunResources& 
runResources)
     // This means that movie_root must be available
     // while gnash::clear() runs
     // 
-    gnash::clear();
+    MovieFactory::clear();
 
     return true;
 }

-----------------------------------------------------------------------

Summary of changes:
 cygnal/cvm.cpp                                     |    2 +-
 extensions/mysql/mysql_db.cpp                      |    2 +-
 gui/Player.cpp                                     |    2 +-
 libcore/ClassHierarchy.cpp                         |    3 +-
 libcore/DisplayObject.h                            |    7 +-
 libcore/Makefile.am                                |    1 -
 libcore/MorphShape.cpp                             |    2 +-
 libcore/MovieClip.cpp                              |   18 ++--
 libcore/MovieFactory.cpp                           |    7 ++
 libcore/MovieFactory.h                             |    5 +
 libcore/RunResources.h                             |    2 +-
 libcore/Timers.h                                   |    1 -
 libcore/Video.cpp                                  |    2 +-
 libcore/as_function.cpp                            |   26 +-----
 libcore/as_object.cpp                              |   12 ++--
 libcore/as_value.cpp                               |   60 ++++++++++++--
 libcore/as_value.h                                 |    2 +-
 libcore/asobj/Array_as.cpp                         |   19 ++---
 libcore/asobj/AsBroadcaster.cpp                    |   16 ++--
 libcore/asobj/Camera_as.cpp                        |    4 +-
 libcore/asobj/Color_as.cpp                         |    6 +-
 libcore/asobj/ContextMenu_as.cpp                   |    5 +-
 libcore/asobj/Global_as.cpp                        |   81 ++-----------------
 libcore/asobj/Global_as.h                          |    8 +--
 libcore/asobj/LoadableObject.cpp                   |   15 ++--
 libcore/asobj/Microphone_as.cpp                    |    2 +-
 libcore/asobj/MovieClipLoader.cpp                  |    2 +-
 libcore/asobj/MovieClip_as.cpp                     |   31 +++----
 libcore/asobj/NetConnection_as.cpp                 |    2 +-
 libcore/asobj/NetStream_as.cpp                     |    2 +-
 libcore/asobj/Object.cpp                           |    8 +-
 libcore/asobj/Selection_as.cpp                     |    2 +-
 libcore/asobj/Sound_as.cpp                         |    2 +-
 libcore/asobj/TextField_as.cpp                     |    2 +-
 libcore/asobj/TextFormat_as.cpp                    |    2 +-
 libcore/asobj/XMLNode_as.cpp                       |    8 +-
 libcore/asobj/XML_as.cpp                           |    2 +-
 libcore/asobj/flash/display/BitmapData_as.cpp      |    8 +-
 .../asobj/flash/external/ExternalInterface_as.cpp  |    8 +-
 libcore/asobj/flash/geom/ColorTransform_as.cpp     |    2 +-
 libcore/asobj/flash/geom/Matrix_as.cpp             |    6 +-
 libcore/asobj/flash/geom/Point_as.cpp              |   14 ++--
 libcore/asobj/flash/geom/Rectangle_as.cpp          |    2 +-
 libcore/asobj/flash/geom/Transform_as.cpp          |    6 +-
 libcore/debugger.cpp                               |    6 +-
 libcore/gnash.h                                    |   14 ---
 libcore/impl.cpp                                   |   86 --------------------
 libcore/movie_root.cpp                             |   12 +--
 libcore/movie_root.h                               |   34 +++-----
 libcore/parser/sprite_definition.cpp               |    6 +-
 libcore/swf/ExportAssetsTag.h                      |    1 -
 libcore/swf/tag_loaders.cpp                        |    1 -
 libcore/vm/ASHandlers.cpp                          |   80 ++++++++----------
 libcore/vm/VM.cpp                                  |    6 ++
 libcore/vm/VM.h                                    |   11 ++-
 testsuite/MovieTester.cpp                          |    2 +-
 utilities/processor.cpp                            |   13 +---
 57 files changed, 264 insertions(+), 427 deletions(-)
 delete mode 100644 libcore/impl.cpp


hooks/post-receive
-- 
Gnash



reply via email to

[Prev in Thread] Current Thread [Next in Thread]