[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11261: Pass Global_as to some as_ob
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11261: Pass Global_as to some as_object ctors. |
Date: |
Wed, 15 Jul 2009 17:24:35 +0200 |
User-agent: |
Bazaar (1.13.1) |
------------------------------------------------------------
revno: 11261
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Wed 2009-07-15 17:24:35 +0200
message:
Pass Global_as to some as_object ctors.
modified:
libcore/ClassHierarchy.cpp
libcore/abc_function.cpp
libcore/as_function.cpp
libcore/as_function.h
libcore/as_object.cpp
libcore/as_object.h
libcore/asobj/Globals.cpp
libcore/builtin_function.h
libcore/swf_function.cpp
------------------------------------------------------------
revno: 11260.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Wed 2009-07-15 13:09:16 +0200
message:
Take Global_as ref in builtin_function's ctor.
modified:
libcore/as_function.cpp
libcore/asobj/Globals.cpp
libcore/builtin_function.h
------------------------------------------------------------
revno: 11260.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Wed 2009-07-15 13:21:47 +0200
message:
Make as_function take a Global_as reference in its constructor. Pass this
from all subclasses.
modified:
libcore/ClassHierarchy.cpp
libcore/abc_function.cpp
libcore/as_function.cpp
libcore/as_function.h
libcore/as_object.cpp
libcore/builtin_function.h
libcore/swf_function.cpp
------------------------------------------------------------
revno: 11260.1.3
committer: Benjamin Wolsey <address@hidden>
branch nick: temp
timestamp: Wed 2009-07-15 15:48:07 +0200
message:
Create an as_object ctor taking a Global_as reference and pass this from
as_function.
modified:
libcore/as_function.cpp
libcore/as_object.cpp
libcore/as_object.h
=== modified file 'libcore/ClassHierarchy.cpp'
--- a/libcore/ClassHierarchy.cpp 2009-07-15 09:10:56 +0000
+++ b/libcore/ClassHierarchy.cpp 2009-07-15 11:21:47 +0000
@@ -66,9 +66,10 @@
public:
bool isBuiltin() { return true; }
- declare_extension_function(ClassHierarchy::ExtensionClass &c,
- as_object *g, Extension* e)
+ declare_extension_function(ClassHierarchy::ExtensionClass &c, as_object *g,
+ Extension* e)
:
+ as_function(*getGlobal(*g)),
mDeclaration(c),
mTarget(g),
mExtension(e)
@@ -128,9 +129,6 @@
class declare_native_function : public as_function
{
-private:
- ClassHierarchy::NativeClass mDeclaration;
- as_object *mTarget;
public:
bool isBuiltin() { return true; }
@@ -138,6 +136,7 @@
declare_native_function(const ClassHierarchy::NativeClass &c,
as_object *g)
:
+ as_function(*getGlobal(*g)),
mDeclaration(c),
mTarget(g)
{
@@ -200,6 +199,11 @@
}
return us;
}
+
+private:
+ ClassHierarchy::NativeClass mDeclaration;
+ as_object *mTarget;
+
};
} // end anonymous namespace
=== modified file 'libcore/abc_function.cpp'
--- a/libcore/abc_function.cpp 2009-07-02 07:39:11 +0000
+++ b/libcore/abc_function.cpp 2009-07-15 11:21:47 +0000
@@ -25,6 +25,7 @@
abc_function::abc_function(asMethod* methodInfo, Machine* machine)
:
+ as_function(*machine->global()),
_methodInfo(methodInfo),
_machine(machine)
{
=== modified file 'libcore/as_function.cpp'
--- a/libcore/as_function.cpp 2009-07-14 15:33:46 +0000
+++ b/libcore/as_function.cpp 2009-07-15 13:48:07 +0000
@@ -60,9 +60,9 @@
// the Function class itself, which would be a member
// of the _global object for each movie instance.
-as_function::as_function(as_object* iface)
+as_function::as_function(Global_as& gl, as_object* iface)
:
- as_object()
+ as_object(gl)
{
int flags = as_prop_flags::dontDelete |
as_prop_flags::dontEnum |
@@ -76,9 +76,9 @@
}
}
-as_function::as_function()
+as_function::as_function(Global_as& gl)
:
- as_object()
+ as_object(gl)
{
int flags = as_prop_flags::dontDelete |
as_prop_flags::dontEnum |
@@ -125,7 +125,8 @@
static boost::intrusive_ptr<builtin_function> func = NULL;
if ( ! func )
{
- func = new builtin_function(function_ctor,
getFunctionPrototype(),
+ Global_as* gl = VM::get().getGlobal();
+ func = new builtin_function(*gl, function_ctor,
getFunctionPrototype(),
true);
VM::get().addStatic(func.get());
}
=== modified file 'libcore/as_function.h'
--- a/libcore/as_function.h 2009-04-23 12:49:08 +0000
+++ b/libcore/as_function.h 2009-07-15 11:21:47 +0000
@@ -25,6 +25,7 @@
namespace gnash {
class fn_call;
class builtin_function;
+ class Global_as;
}
namespace gnash {
@@ -125,27 +126,12 @@
#endif // GNASH_USE_GC
protected:
-
-#ifdef GNASH_USE_GC
- /// Mark prototype (properties) as being reachable and invoke
- /// the as_object class marker.
- //
- /// Call this function from an override of markReachableResources
- /// in a derived class
- ///
- void markAsFunctionReachable() const
- {
- //_properties->setReachable();
-
- markAsObjectReachable();
- }
-#endif // GNASH_USE_GC
-
- /// Construct a function with no interface
+
+ /// Construct a function with no interface
//
/// For SWF>5 the function object will have derive from Function.
///
- as_function();
+ as_function(Global_as& gl);
/// Construct a function with given interface (possibly none)
//
@@ -156,15 +142,23 @@
/// If not NULL, a 'constructor' member will be added to the
/// prototype, pointing to 'this'.
///
- as_function(as_object* iface);
+ as_function(Global_as& gl, as_object* iface);
- /// The "prototype" member.
+#ifdef GNASH_USE_GC
+ /// Mark prototype (properties) as being reachable and invoke
+ /// the as_object class marker.
//
- /// Used for class constructor and members
- /// to be inherited by instances of this
- /// "Function" (class)
+ /// Call this function from an override of markReachableResources
+ /// in a derived class
///
- //boost::intrusive_ptr<as_object> _properties;
+ void markAsFunctionReachable() const
+ {
+ //_properties->setReachable();
+
+ markAsObjectReachable();
+ }
+#endif // GNASH_USE_GC
+
private:
=== modified file 'libcore/as_object.cpp'
--- a/libcore/as_object.cpp 2009-07-15 09:10:56 +0000
+++ b/libcore/as_object.cpp 2009-07-15 13:48:07 +0000
@@ -65,13 +65,13 @@
{
public:
- as_super(as_function* ctor, as_object* proto)
+ as_super(Global_as& gl, as_function* ctor, as_object* proto)
:
+ as_function(gl),
_ctor(ctor),
_proto(proto)
{
set_prototype(proto);
- //log_debug("as_super %p constructed with ctor %p and proto
%p", this, ctor, proto);
}
virtual bool isSuper() const { return true; }
@@ -138,8 +138,7 @@
as_object* proto = get_prototype().get();
if ( ! proto )
{
- //log_debug("We (a super) have no associated prototype,
returning a null-referencing as_super from get_super()");
- return new as_super(0, 0);
+ return new as_super(*getGlobal(*this), 0, 0);
}
// proto's __proto__ is superProto
@@ -211,7 +210,7 @@
}
}
- as_object* super = new as_super(superCtor, superProto);
+ as_object* super = new as_super(*getGlobal(*this), superCtor,
superProto);
return super;
}
@@ -389,7 +388,7 @@
// proto's __constructor__ is superCtor
as_function* superCtor = proto ? proto->get_constructor() : 0;
- as_object* super = new as_super(superCtor, superProto);
+ as_object* super = new as_super(*getGlobal(*this), superCtor,
superProto);
return super;
}
@@ -1076,6 +1075,12 @@
}
+as_object::as_object(Global_as& gl)
+ :
+ _vm(getVM(gl)),
+ _members(_vm)
+{
+}
as_object::as_object()
:
=== modified file 'libcore/as_object.h'
--- a/libcore/as_object.h 2009-07-14 08:11:29 +0000
+++ b/libcore/as_object.h 2009-07-15 13:48:07 +0000
@@ -122,8 +122,7 @@
/// Base-class for ActionScript script-defined objects.
/// This would likely be ActionScript's 'Object' class.
///
-class as_object
- :
+class as_object :
#ifdef GNASH_USE_GC
public GcResource
#else
@@ -139,6 +138,32 @@
typedef PropertyList::SortedPropertyList SortedPropertyList;
public:
+
+ /// Construct an ActionScript object with no prototype associated.
+ //
+ /// @param global A reference to the Global object. The created object
+ /// will hold a reference to this object, using it to
+ /// access other AS resources where necessary. The new
+ /// object belongs in the scope of the passed Global
+ /// object.
+ explicit as_object(Global_as& global);
+
+ /// Construct an ActionScript object with no prototype associated.
+ as_object();
+
+ /// \brief
+ /// Construct an ActionScript object based on the given prototype.
+ /// Adds a reference to the prototype, if any.
+ explicit as_object(as_object* proto);
+
+ /// Construct an ActionScript object based on the given prototype.
+ explicit as_object(boost::intrusive_ptr<as_object> proto);
+
+ /// Copy an as_object.
+ //
+ /// This is used by Array_as, but almost certainly shouldn't be. Please
+ /// don't use this function.
+ explicit as_object(const as_object& other);
/// A function to be called on movie_root::advance()
//
@@ -168,11 +193,7 @@
Property* findProperty(string_table::key name, string_table::key nsname,
as_object **owner = NULL);
-// Property* findProperty(
-
- /// \brief
- /// Return a reference to the Virtual Machine that created
- /// this object.
+ /// Return a reference to this as_object's global object.
VM& vm() const {
return _vm;
}
@@ -195,23 +216,6 @@
///
void dump_members(std::map<std::string, as_value>& to);
- /// Construct an ActionScript object with no prototype associated.
- as_object();
-
- /// \brief
- /// Construct an ActionScript object based on the given prototype.
- /// Adds a reference to the prototype, if any.
- explicit as_object(as_object* proto);
-
- /// Construct an ActionScript object based on the given prototype.
- explicit as_object(boost::intrusive_ptr<as_object> proto);
-
- /// Copy an as_object
- //
- /// TODO: write more about this, is it allowed ? is it safe ?
- ///
- as_object(const as_object& other);
-
/// Return a text representation for this object
virtual std::string get_text_value() const { return "[object Object]"; }
@@ -1104,9 +1108,9 @@
#endif // GNASH_USE_GC
private:
-
- /// The Virtual Machine used to create this object
- VM& _vm;
+
+ /// The global object whose scope contains this object.
+ VM& _vm;
/// Properties of this objects
PropertyList _members;
=== modified file 'libcore/asobj/Globals.cpp'
--- a/libcore/asobj/Globals.cpp 2009-07-15 10:51:10 +0000
+++ b/libcore/asobj/Globals.cpp 2009-07-15 11:09:16 +0000
@@ -181,13 +181,13 @@
builtin_function*
AVM1Global::createFunction(Global_as::ASFunction function)
{
- return new builtin_function(function);
+ return new builtin_function(*this, function);
}
as_object*
AVM1Global::createClass(Global_as::ASFunction ctor, as_object* prototype)
{
- return new builtin_function(ctor, prototype);
+ return new builtin_function(*this, ctor, prototype);
}
@@ -212,7 +212,7 @@
builtin_function*
AVM2Global::createFunction(Global_as::ASFunction function)
{
- return new builtin_function(function);
+ return new builtin_function(*this, function);
}
as_object*
@@ -220,7 +220,7 @@
{
// TODO: this should attach the function to the prototype as its
// constructor member.
- return new builtin_function(ctor, prototype);
+ return new builtin_function(*this, ctor, prototype);
}
as_object*
=== modified file 'libcore/builtin_function.h'
--- a/libcore/builtin_function.h 2009-03-04 19:06:14 +0000
+++ b/libcore/builtin_function.h 2009-07-15 11:21:47 +0000
@@ -27,12 +27,12 @@
namespace gnash {
-typedef as_value (*as_c_function_ptr)(const fn_call& fn);
/// Any built-in function/class should be of this type
class builtin_function : public as_function
{
+ typedef as_value (*ASFunction)(const fn_call& fn);
public:
@@ -44,15 +44,16 @@
/// The C function to call when this as_function is invoked.
/// For classes, the function pointer is the constructor.
///
- builtin_function(as_c_function_ptr func)
+ builtin_function(Global_as& gl, ASFunction func)
:
- as_function(),
+ as_function(gl),
_func(func)
{
- init_member(NSV::PROP_CONSTRUCTOR,
as_function::getFunctionConstructor().get());
+ init_member(NSV::PROP_CONSTRUCTOR,
+ as_function::getFunctionConstructor().get());
}
- /// Construct a builtin function/class with the given interface
(possibly none)
+ /// Construct a builtin function with the given interface (possibly
none)
//
/// @param func
/// The C function to call when this as_function is invoked.
@@ -63,20 +64,19 @@
/// instances of this class)
/// If the given interface is NULL no interface will be
/// provided. Use the constructor taking a single argument
- /// to get a default interface instead.
- ///
- builtin_function(as_c_function_ptr func, as_object* iface, bool
useThisAsCtor=false)
+ /// to get a default interface instead.
+ /// @param useThisAsCtor
+ /// Used only by getFunctionConstructor().
+ builtin_function(Global_as& gl, ASFunction func, as_object* iface,
+ bool useThisAsCtor = false)
:
- as_function(iface),
+ as_function(gl, iface),
_func(func)
{
- if ( useThisAsCtor )
- {
- init_member(NSV::PROP_CONSTRUCTOR, this);
- }
- else
- {
- init_member(NSV::PROP_CONSTRUCTOR,
as_function::getFunctionConstructor().get());
+ if (useThisAsCtor) init_member(NSV::PROP_CONSTRUCTOR, this);
+ else {
+ init_member(NSV::PROP_CONSTRUCTOR,
+ as_function::getFunctionConstructor().get());
}
}
@@ -106,11 +106,10 @@
private:
- as_c_function_ptr _func;
+ ASFunction _func;
};
} // end of gnash namespace
-// __GNASH_BUILTIN_FUNCTION_H__
#endif
=== modified file 'libcore/swf_function.cpp'
--- a/libcore/swf_function.cpp 2009-07-15 07:37:56 +0000
+++ b/libcore/swf_function.cpp 2009-07-15 11:21:47 +0000
@@ -44,7 +44,7 @@
swf_function::swf_function(const action_buffer& ab, as_environment& env,
size_t start, const ScopeStack& scopeStack)
:
- as_function(new as_object(getObjectInterface())),
+ as_function(*getGlobal(env), new as_object(getObjectInterface())),
m_action_buffer(ab),
m_env(env),
_scopeStack(scopeStack),
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11261: Pass Global_as to some as_object ctors.,
Benjamin Wolsey <=