19 #ifndef GNASH_AS_OBJECT_H
20 #define GNASH_AS_OBJECT_H
30 #include <boost/scoped_ptr.hpp>
31 #include <boost/noncopyable.hpp>
68 _customArg(customArg),
88 bool dead()
const {
return _dead; }
105 std::string _propname;
229 bool ifFound =
false);
474 virtual bool isSuper()
const {
return false; }
605 if (p) _array =
false;
606 if (_relay) _relay->clean();
639 return _displayObject;
689 template<
typename T>
class PrototypeRecursor;
710 boost::scoped_ptr<Relay> _relay;
722 std::vector<as_object*> _interfaces;
724 typedef std::map<ObjectURI, Trigger, ObjectURI::LessThan> TriggerContainer;
725 boost::scoped_ptr<TriggerContainer> _trigs;
740 void sendEvent(as_object&
o,
const as_environment& env,
const ObjectURI&
name);
789 return visible(prop, _version);
845 return dynamic_cast<T*
>(
o->displayObject());
877 if (!obj)
return false;
878 relay =
dynamic_cast<T*
>(obj->
relay());
930 #endif // GNASH_AS_OBJECT_H
Trigger(const std::string &propname, as_function &trig, const as_value &customArg)
Definition: as_object.h:63
virtual bool set_member(const ObjectURI &uri, const as_value &val, bool ifFound=false)
Set a member value.
Definition: as_object.cpp:584
virtual void markReachableResources() const
Mark all reachable resources, override from GcResource.
Definition: as_object.cpp:1012
as_object * get_prototype() const
Return this object's proto member.
Definition: as_object.cpp:933
bool init_destructive_property(const ObjectURI &uri, as_function &getter, int flags=PropFlags::dontEnum)
Initialize a destructive getter property.
Definition: as_object.cpp:721
Definition: GnashKey.h:150
Property * getOwnProperty(const ObjectURI &uri)
Get this object's own named property, if existing.
Definition: as_object.cpp:927
virtual std::string stringValue() const
Return the string representation for this object.
Definition: as_object.cpp:309
Protect from deletion.
Definition: PropFlags.h:39
SortedPropertyList enumerateProperties(as_object &obj)
Enumerate all non-hidden properties to the passed container.
Definition: as_object.cpp:1070
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:168
virtual as_value call(const fn_call &fn)
Function dispatch.
Definition: as_object.cpp:303
void clearProperties()
Drop all properties from this object.
Definition: as_object.h:533
DisplayObject * displayObject() const
Return the DisplayObject associated with this object.
Definition: as_object.h:638
virtual bool isSuper() const
Return true if this is a 'super' object.
Definition: as_object.h:474
ActionScript value type.
Definition: as_value.h:95
as_value(* as_c_function_ptr)(const fn_call &fn)
Definition: Property.h:34
void sendEvent(as_object &o, const as_environment &env, const ObjectURI &name)
Send a system event.
Definition: as_object.cpp:1100
An abstract property.
Definition: Property.h:275
void init_property(const std::string &key, as_function &getter, as_function &setter, int flags=DefaultFlags)
Initialize a getter/setter property by name.
Definition: as_object.cpp:691
DSOTEXPORT as_value getValue(const as_object &this_ptr) const
Get value of this property.
Definition: Property.cpp:98
bool watch(const ObjectURI &uri, as_function &trig, const as_value &cust)
Add a watch trigger, overriding any other defined for same name.
Definition: as_object.cpp:973
void setPropFlags(const as_value &props, int set_false, int set_true)
Set property flags.
Definition: as_object.cpp:861
Property * findProperty(const ObjectURI &uri, as_object **owner=0)
Find a property, scanning the inheritance chain.
Definition: as_object.cpp:479
VM & _vm
Definition: Array_as.cpp:857
Global_as & getGlobal(const as_environment &env)
Definition: as_environment.cpp:651
virtual ~as_object()
The as_object dtor does nothing special.
Definition: as_object.h:174
DSOTEXPORT std::pair< bool, bool > delProperty(const ObjectURI &uri)
Delete a property of this object, unless protected from deletion.
Definition: as_object.cpp:315
void setReachable() const
Definition: as_object.cpp:1033
bool dead() const
True if this Trigger has been disposed of.
Definition: as_object.h:88
Exists()
Definition: as_object.h:798
void set_prototype(const as_value &proto)
Set this object's proto member.
Definition: as_object.cpp:520
bool instanceOf(as_object *ctor)
Check whether this object is an instance of the given constructor.
Definition: as_object.cpp:770
std::string getURLEncodedVars(as_object &o)
Get url-encoded variables.
Definition: as_object.cpp:947
Definition: GnashKey.h:149
bool isNativeType(const as_object *obj, T *&relay)
Check whether the object is an instance of a known type.
Definition: as_object.h:875
The base class for all ActionScript objects.
Definition: as_object.h:161
IsVisible(int version)
Definition: as_object.h:787
Definition: GnashKey.h:161
as_value call(const as_value &oldval, const as_value &newval, as_object &this_obj)
Call the trigger.
Definition: as_object.cpp:1040
as_value getOwnProperty(as_object &o, const ObjectURI &uri)
Get an own member of an object.
Definition: as_object.h:777
A general use string table.
Definition: string_table.h:41
A URI for describing as_objects.
Definition: ObjectURI.h:44
as_value getMember(as_object &o, const ObjectURI &uri)
Get a member of an object using AS lookup rules.
Definition: as_object.h:756
void dump_members()
Dump all properties using log_debug.
Definition: as_object.cpp:853
as_object * getObjectWithPrototype(Global_as &gl, const ObjectURI &c)
Definition: as_object.cpp:1110
bool operator()(const Property &) const
Definition: as_object.h:799
VM & getVM(const as_environment &env)
Definition: as_environment.h:222
static const int DefaultFlags
The most common flags for built-in properties.
Definition: as_object.h:192
An abstract property visitor.
Definition: PropertyList.h:49
virtual as_function * to_function()
Cast to a as_function, or return NULL.
Definition: as_object.h:471
void visitProperties(PropertyVisitor &visitor) const
Visit the properties of this object by key/as_value pairs.
Definition: as_object.h:547
bool visible(const Property &prop, int version)
Is this member supposed to be visible by a VM of given version ?
Definition: Property.h:431
Class to group together per-run and external resources for Gnash.
Definition: RunResources.h:43
void setDisplayObject(DisplayObject *d)
Set the DisplayObject associated with this as_object.
Definition: as_object.h:643
as_object * get_super()
Definition: as_object.cpp:469
A trigger that can be associated with a property name.
Definition: as_object.h:59
void setArray(bool array=true)
Set whether this object should be treated as an array.
Definition: as_object.h:630
bool operator()(const Property &prop) const
Definition: as_object.h:788
Definition: as_object.h:804
std::vector< std::pair< ObjectURI, as_value > > SortedPropertyList
This is used to hold an intermediate copy of an as_object's properties.
Definition: as_object.h:887
void set_member_flags(const ObjectURI &uri, int setTrue, int setFalse=0)
Set member flags (probably used by ASSetPropFlags)
Definition: as_object.cpp:754
void setRelay(Relay *p)
Set the as_object's Relay object.
Definition: as_object.h:604
DSOTEXPORT as_object(const Global_as &global)
Construct an ActionScript object with no prototype associated.
Definition: as_object.cpp:280
void add_property(const std::string &key, as_function &getter, as_function *setter)
Add a getter/setter property if no member already has that name.
Definition: as_object.cpp:322
void copyProperties(const as_object &o)
Copy properties from the given object.
Definition: as_object.cpp:896
VM & vm() const
Return a reference to this as_object's global object.
Definition: as_object.h:205
void kill()
Definition: as_object.h:90
int getSWFVersion(const as_environment &env)
Definition: as_environment.cpp:657
The Global object ultimately contains all objects in an ActionScript run.
Definition: Global_as.h:55
string_table & getStringTable(const as_environment &env)
Definition: as_environment.cpp:639
const PropFlags & getFlags() const
accessor to the properties flags
Definition: Property.h:330
The AVM1 virtual machine.
Definition: VM.h:71
void init_member(const std::string &name, const as_value &val, int flags=DefaultFlags)
Initialize a member value by string.
Definition: as_object.cpp:670
Definition: GnashKey.h:132
bool test() const
Definition: PropFlags.h:94
void clear()
Remove all entries in the container.
Definition: PropertyList.cpp:313
void init_readonly_property(const std::string &key, as_function &getter, int flags=DefaultFlags)
Use this method for read-only properties.
Definition: as_object.cpp:735
void addInterface(as_object *ctor)
Add an interface to the list of interfaces.
Definition: as_object.cpp:760
bool unwatch(const ObjectURI &uri)
Remove a watch trigger.
Definition: as_object.cpp:991
bool caseless(const as_object &o)
Return whether property matching is caseless.
Definition: as_object.h:924
Definition: GnashKey.h:162
Set of properties associated with an ActionScript object.
Definition: PropertyList.h:81
const RunResources & getRunResources(const as_object &o)
Get the RunResources from an as_object.
Definition: as_object.cpp:1143
This is the base class for type-specific object data.
Definition: Relay.h:49
#define DSOTEXPORT
Definition: dsodefs.h:63
Function objects for visiting properties.
Definition: as_object.h:784
virtual bool get_member(const ObjectURI &uri, as_value *val)
Get a property by name if it exists.
Definition: as_object.cpp:380
Definition: as_object.h:795
bool hasOwnProperty(as_object &o, const ObjectURI &uri)
Return true if this object has the named property.
Definition: as_object.h:854
Relay * relay() const
Access the as_object's Relay object.
Definition: as_object.h:620
Collectable resource.
Definition: GC.h:74
Parameters/environment for builtin or user-defined functions callable from ActionScript.
Definition: fn_call.h:107
bool prototypeOf(as_object &instance)
Check whether this object is in another object's inheritance chain.
Definition: as_object.cpp:832
as_object * getPathElement(as_object &o, const ObjectURI &uri)
Resolve the given relative path component.
Definition: as_object.cpp:1090
bool operator()(const Property &p) const
Definition: as_object.h:808
IsEnumerable()
Definition: as_object.h:807
An abstract key visitor.
Definition: PropertyList.h:58
void visitValues(V &visitor, U cmp=U()) const
Visit properties.
Definition: PropertyList.h:151
std::string name
Definition: LocalConnection_as.cpp:151
ActionScript Function, either builtin or SWF-defined.
Definition: as_function.h:62
bool array() const
Return true if this object should be treated as an array.
Definition: as_object.h:625
movie_root & getRoot(const as_environment &env)
Definition: as_environment.cpp:645
void visitKeys(KeyVisitor &visitor) const
Visit all visible property identifiers.
Definition: as_object.cpp:905
Protect from enumeration.
Definition: PropFlags.h:36
This class represents the 'Stage' and top-level movie.
Definition: movie_root.h:150