Go to the documentation of this file.
19 #ifndef GNASH_AS_OBJECT_H
20 #define GNASH_AS_OBJECT_H
31 #include <boost/noncopyable.hpp>
66 _propname(std::move(propname)),
68 _customArg(std::move(customArg)),
88 bool dead()
const {
return _dead; }
105 std::string _propname;
187 virtual std::string stringValue()
const;
229 bool ifFound =
false);
241 void init_member(
const std::string&
name,
const as_value& val,
242 int flags = DefaultFlags);
260 int flags = DefaultFlags);
283 void init_property(
const std::string& key,
as_function& getter,
377 void init_readonly_property(
const std::string& key,
as_function& getter,
378 int flags = DefaultFlags);
393 void init_readonly_property(
const std::string& key,
468 void set_member_flags(
const ObjectURI&
uri,
int setTrue,
int setFalse = 0);
474 virtual bool isSuper()
const {
return false; }
523 void setPropFlags(
const as_value& props,
int set_false,
int set_true);
548 _members.visitValues<
T>(visitor);
573 void add_property(
const std::string& key,
as_function& getter,
588 void set_prototype(
const as_value& proto);
605 if (
p) _array =
false;
606 if (_relay) _relay->clean();
639 return _displayObject;
668 virtual void markReachableResources()
const;
689 template<
typename T>
class PrototypeRecursor;
710 std::unique_ptr<Relay> _relay;
722 std::vector<as_object*> _interfaces;
724 typedef std::map<ObjectURI, Trigger, ObjectURI::LessThan> TriggerContainer;
725 std::unique_ptr<TriggerContainer> _trigs;
740 void sendEvent(as_object&
o,
const as_environment& env,
const ObjectURI&
name);
759 o.get_member(
uri, &ret);
789 return visible(prop, _version);
844 if (!
o)
return nullptr;
845 return dynamic_cast<T*
>(
o->displayObject());
856 return (
o.getOwnProperty(
uri));
877 if (!obj)
return false;
878 relay =
dynamic_cast<T*
>(obj->
relay());
930 #endif // GNASH_AS_OBJECT_H
bool isNativeType(const as_object *obj, T *&relay)
Check whether the object is an instance of a known type.
Definition: as_object.h:875
DSOTEXPORT Property * getProperty(const ObjectURI &uri) const
Get a property if it exists.
Definition: PropertyList.cpp:139
@ l
Definition: GnashKey.h:158
Collectable resource.
Definition: GC.h:75
as_value call(const as_value &oldval, const as_value &newval, as_object &this_obj)
Call the trigger.
Definition: as_object.cpp:1039
void visitKeys(KeyVisitor &visitor) const
Visit all visible property identifiers.
Definition: as_object.cpp:904
@ PROP_uuRESOLVE
Definition: namedStrings.h:119
void set_member_flags(const ObjectURI &uri, int setTrue, int setFalse=0)
Set member flags (probably used by ASSetPropFlags)
Definition: as_object.cpp:753
std::string name
Definition: LocalConnection_as.cpp:149
void setCache(const as_value &v)
Set internal cached value of this property.
Definition: Property.cpp:172
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:423
@ d
Definition: GnashKey.h:150
An abstract property visitor.
Definition: PropertyList.h:49
as_object * _object
Definition: Array_as.cpp:680
The base class for all ActionScript objects.
Definition: as_object.h:162
void visitKeys(KeyVisitor &v, PropertyTracker &donelist) const
Enumerate all non-hidden properties to the given container.
Definition: PropertyList.cpp:172
Top-level gnash exception.
Definition: GnashException.h:31
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
as_value getOwnProperty(as_object &o, const ObjectURI &uri)
Get an own member of an object.
Definition: as_object.h:777
as_object * toObject(const as_value &v, VM &vm)
Convert an as_value to an object.
Definition: VM.cpp:457
@ T
Definition: GnashKey.h:132
string_table::key getName(const ObjectURI &o)
Get the name element of an ObjectURI.
Definition: ObjectURI.h:116
void setFlagsAll(int setTrue, int setFalse)
Set the flags of all properties.
Definition: PropertyList.cpp:129
A general use string table.
Definition: string_table.h:42
bool is_null() const
Definition: as_value.h:340
const std::string & value(key to_find) const
Find a string by its key.
Definition: string_table.h:102
virtual bool isSuper() const
Return true if this is a 'super' object.
Definition: as_object.h:474
void dump_members()
Dump all properties using log_debug.
Definition: as_object.cpp:852
void log_debug(StringType msg, Args... args)
Definition: log.h:301
@ i
Definition: GnashKey.h:155
as_object * getPathElement(as_object &o, const ObjectURI &uri)
Resolve the given relative path component.
Definition: as_object.cpp:1089
void set_prototype(const as_value &proto)
Set this object's proto member.
Definition: as_object.cpp:518
Exists()
Definition: as_object.h:798
#define _(String)
Definition: log.h:44
Provides information about timeline context.
Definition: as_environment.h:51
bool instanceOf(as_object *ctor)
Check whether this object is an instance of the given constructor.
Definition: as_object.cpp:769
void init_member(const std::string &name, const as_value &val, int flags=DefaultFlags)
Initialize a member value by string.
Definition: as_object.cpp:669
The AVM1 virtual machine.
Definition: VM.h:72
bool prototypeOf(as_object &instance)
Check whether this object is in another object's inheritance chain.
Definition: as_object.cpp:831
virtual as_function * to_function()
Cast to a as_function, or return NULL.
Definition: as_object.h:471
virtual as_value call(const fn_call &fn)
Function dispatch.
Definition: as_object.cpp:301
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
bool operator()(const Property &) const
Definition: as_object.h:799
bool unwatch(const ObjectURI &uri)
Remove a watch trigger.
Definition: as_object.cpp:990
@ dontEnum
Protect from enumeration.
Definition: PropFlags.h:36
@ dontDelete
Protect from deletion.
Definition: PropFlags.h:39
IsEnumerable()
Definition: as_object.h:807
std::int32_t second
Definition: Date_as.cpp:93
void clearProperties()
Drop all properties from this object.
Definition: as_object.h:533
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:690
A trigger that can be associated with a property name.
Definition: as_object.h:60
Global_as & getGlobal(const as_environment &env)
Definition: as_environment.cpp:651
A MovieClip is a container for DisplayObjects.
Definition: MovieClip.h:84
VM & getVM(const as_environment &env)
Definition: as_environment.h:222
void log_error(StringType msg, Args... args)
Definition: log.h:283
as_value getMember(as_object &o, const ObjectURI &uri)
Get a member of an object using AS lookup rules.
Definition: as_object.h:756
bool array() const
Return true if this object should be treated as an array.
Definition: as_object.h:625
bool init_destructive_property(const ObjectURI &uri, as_function &getter, int flags=PropFlags::dontEnum)
Initialize a destructive getter property.
Definition: as_object.cpp:720
as_object * createObject(const Global_as &gl)
Definition: Global_as.cpp:303
SortedPropertyList enumerateProperties(as_object &obj)
Enumerate all non-hidden properties to the passed container.
Definition: as_object.cpp:1069
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
Parameters/environment for builtin or user-defined functions callable from ActionScript.
Definition: fn_call.h:118
An abstract key visitor.
Definition: PropertyList.h:58
static const int DefaultFlags
The most common flags for built-in properties.
Definition: as_object.h:192
Trigger(std::string propname, as_function &trig, as_value customArg)
Definition: as_object.h:63
bool isGetterSetter() const
Is this a getter/setter property?
Definition: Property.h:377
virtual void visitNonProperties(KeyVisitor &) const
Enumerate any non-proper properties.
Definition: DisplayObject.h:247
bool operator()(const Property &p) const
Definition: as_object.h:808
bool setDisplayObjectProperty(DisplayObject &obj, const ObjectURI &uri, const as_value &val)
Set special properties.
Definition: DisplayObject.cpp:961
@ PROP_uuCONSTRUCTORuu
Definition: namedStrings.h:117
FunctionArgs< as_value > Args
Definition: fn_call.h:121
void for_each(C &container, R(T::*pmf)(const A &), const A &arg)
Definition: Renderer_ogl.cpp:690
This is the base class for type-specific object data.
Definition: Relay.h:50
static void encode(std::string &str)
Encode a string to URL-encoded format converting all dodgy characters to AB hex sequences.
Definition: URL.cpp:391
const RunResources & getRunResources(const as_object &o)
Get the RunResources from an as_object.
Definition: as_object.cpp:1142
bool setTextFieldVariables(const ObjectURI &uri, const as_value &val)
TODO: this is also unlikely to be the best way to do it.
Definition: MovieClip.cpp:834
DSOEXPORT as_value invoke(const as_value &method, const as_environment &env, as_object *this_ptr, fn_call::Args &args, as_object *super=nullptr, const movie_definition *callerDef=nullptr)
Call an as_value on an as_object.
Definition: Global_as.h:166
An ActionScript type error.
Definition: GnashException.h:161
DSOTEXPORT std::string to_string(int version=7) const
Get a std::string representation for this value.
Definition: as_value.cpp:205
A class to contain transferable arguments for a fn_call.
Definition: fn_call.h:57
#define IF_VERBOSE_ASCODING_ERRORS(x)
Definition: log.h:397
void kill()
Definition: as_object.h:90
T * get(as_object *o)
Extract the DisplayObject attached to an object.
Definition: as_object.h:842
virtual ~as_object()
The as_object dtor does nothing special.
Definition: as_object.h:174
virtual std::string stringValue() const
Return the string representation for this object.
Definition: as_object.cpp:307
bool empty() const
Definition: ObjectURI.h:76
An abstract property.
Definition: Property.h:277
virtual bool get_member(const ObjectURI &uri, as_value *val)
Get a property by name if it exists.
Definition: as_object.cpp:378
bool operator()(const Property &prop) const
Definition: as_object.h:788
bool dead() const
True if this Trigger has been disposed of.
Definition: as_object.h:88
void setPropFlags(const as_value &props, int set_false, int set_true)
Set property flags.
Definition: as_object.cpp:860
DisplayObject * displayObject() const
Return the DisplayObject associated with this object.
Definition: as_object.h:638
DSOTEXPORT as_value getValue(const as_object &this_ptr) const
Get value of this property.
Definition: Property.cpp:98
void copyProperties(const as_object &o)
Copy properties from the given object.
Definition: as_object.cpp:895
Definition: as_object.h:805
@ p
Definition: GnashKey.h:162
void dump()
Dump all members (using log_debug)
Definition: PropertyList.cpp:189
DSOTEXPORT std::pair< bool, bool > delProperty(const ObjectURI &uri)
Delete a Property, if existing and not protected from deletion.
Definition: PropertyList.cpp:154
@ _1
Definition: GnashKey.h:95
void setReachable() const
Mark all properties reachable.
Definition: PropertyList.h:295
Class to group together per-run and external resources for Gnash.
Definition: RunResources.h:54
ActionScript value type.
Definition: as_value.h:95
as_value(* as_c_function_ptr)(const fn_call &fn)
Definition: Property.h:34
as_object * get_super()
Definition: as_object.cpp:467
Property * findProperty(const ObjectURI &uri, as_object **owner=nullptr)
Find a property, scanning the inheritance chain.
Definition: as_object.cpp:477
bool getDisplayObjectProperty(DisplayObject &obj, const ObjectURI &uri, as_value &val)
DisplayObject property lookup.
Definition: DisplayObject.cpp:897
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:734
virtual as_value call(const fn_call &fn)=0
Function dispatch.
Definition: ObjectURI.h:164
VM & vm() const
Return a reference to this as_object's global object.
Definition: as_object.h:205
void log_aserror(StringType msg, Args... args)
Definition: log.h:331
movie_root & getRoot(const as_environment &env)
Definition: as_environment.cpp:645
void setReachable() const
Set any object value as reachable (for the GC)
Definition: as_value.cpp:691
Relay * relay() const
Access the as_object's Relay object.
Definition: as_object.h:620
DSOTEXPORT std::pair< bool, bool > delProperty(const ObjectURI &uri)
Delete a property of this object, unless protected from deletion.
Definition: as_object.cpp:313
as_object * get_prototype() const
Return this object's proto member.
Definition: as_object.cpp:932
void clearVisible(int swfVersion)
Clear visibility flags.
Definition: Property.h:382
DSOTEXPORT void setFlags(const ObjectURI &uri, int setTrue, int setFalse)
Set the flags of a property.
Definition: PropertyList.cpp:118
void EraseIf(Container &c, Predicate p)
Erase elements from an associative container based on a predicate.
Definition: GnashAlgorithm.h:45
void checkArrayLength(as_object &array, const ObjectURI &uri, const as_value &val)
Genuine arrays handle the length property in a special way.
Definition: Array_as.cpp:920
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:972
This class represents the 'Stage' and top-level movie.
Definition: movie_root.h:151
DSOTEXPORT bool setValue(const ObjectURI &uri, const as_value &value, const PropFlags &flagsIfMissing=0)
Set the value of a property, creating a new one if it doesn't exist.
Definition: PropertyList.cpp:94
#define DSOTEXPORT
Definition: dsodefs.h:63
The Global object ultimately contains all objects in an ActionScript run.
Definition: Global_as.h:50
virtual bool set_member(const ObjectURI &uri, const as_value &val, bool ifFound=false)
Set a member value.
Definition: as_object.cpp:583
int getSWFVersion(const as_environment &env)
Definition: as_environment.cpp:657
uri
Definition: test.py:12
@ c
Definition: GnashKey.h:149
as_value getCache() const
Get internal cached value of this property.
Definition: Property.cpp:127
string_table & getStringTable(const as_environment &env)
Definition: as_environment.cpp:639
as_object * getObjectWithPrototype(Global_as &gl, const ObjectURI &c)
Definition: as_object.cpp:1109
virtual void markReachableResources() const
Mark all reachable resources, override from GcResource.
Definition: as_object.cpp:1011
#define DSOEXPORT
Definition: dsodefs.h:55
@ PROP_uuPROTOuu
Definition: namedStrings.h:118
ObjectURI getURI(const VM &vm, const std::string &str, bool lowerCaseHint=false)
Definition: VM.h:290
bool addDestructiveGetter(const ObjectURI &uri, as_function &getter, const PropFlags &flagsIfMissing=0)
Add a destructive getter property, if not already existant.
Definition: PropertyList.cpp:265
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:169
IsVisible(int version)
Definition: as_object.h:787
bool hasOwnProperty(as_object &o, const ObjectURI &uri)
Return true if this object has the named property.
Definition: as_object.h:854
bool addGetterSetter(const ObjectURI &uri, as_function &getter, as_function *setter, const as_value &cacheVal, const PropFlags &flagsIfMissing=0)
Add a getter/setter property, if not already existing.
Definition: PropertyList.cpp:198
void addInterface(as_object *ctor)
Add an interface to the list of interfaces.
Definition: as_object.cpp:759
std::vector< T > container_type
Definition: fn_call.h:61
void setDisplayObject(DisplayObject *d)
Set the DisplayObject associated with this as_object.
Definition: as_object.h:643
Function objects for visiting properties.
Definition: as_object.h:785
bool caseless(const as_object &o)
Return whether property matching is caseless.
Definition: as_object.h:924
void sendEvent(as_object &o, const as_environment &env, const ObjectURI &name)
Send a system event.
Definition: as_object.cpp:1099
void setArray(bool array=true)
Set whether this object should be treated as an array.
Definition: as_object.h:630
void setReachable() const
Definition: as_object.cpp:1032
@ o
Definition: GnashKey.h:161
@ readOnly
Protect from assigning a value.
Definition: PropFlags.h:42
std::set< ObjectURI, ObjectURI::LessThan > PropertyTracker
Definition: PropertyList.h:85
@ PROP_PROTOTYPE
Definition: namedStrings.h:87
bool is_object() const
Return true if this value is an object.
Definition: as_value.h:219
A URI for describing as_objects.
Definition: ObjectURI.h:45
Set of properties associated with an ActionScript object.
Definition: PropertyList.h:82
size_t size() const
Return number of properties in this list.
Definition: PropertyList.h:281
SimpleBuffer data
Definition: LocalConnection_as.cpp:151
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:320
@ e
Definition: GnashKey.h:151
bool readOnly(const Property &prop)
is this a read-only member ?
Definition: Property.h:417
std::string getURLEncodedVars(as_object &o)
Get url-encoded variables.
Definition: as_object.cpp:946
bool setValue(as_object &this_ptr, const as_value &value) const
Set value of this property.
Definition: Property.cpp:133
ActionScript Function, either builtin or SWF-defined.
Definition: as_function.h:63
void setReachable() const
Mark this resource as being reachable.
Definition: GC.h:92
Definition: as_object.h:796
Property * getOwnProperty(const ObjectURI &uri)
Get this object's own named property, if existing.
Definition: as_object.cpp:926