Gnash
0.8.10
|
The base class for all ActionScript objects. More...
#include <as_object.h>
Public Member Functions | |
as_object (const Global_as &global) | |
Construct an ActionScript object with no prototype associated. | |
virtual | ~as_object () |
The as_object dtor does nothing special. | |
virtual as_value | call (const fn_call &fn) |
Function dispatch. | |
virtual std::string | stringValue () const |
Return the string representation for this object. | |
Property * | findProperty (const ObjectURI &uri, as_object **owner=0) |
Find a property, scanning the inheritance chain. | |
VM & | vm () const |
Return a reference to this as_object's global object. | |
void | dump_members () |
Dump all properties using log_debug. | |
virtual bool | set_member (const ObjectURI &uri, const as_value &val, bool ifFound=false) |
Set a member value. | |
void | init_member (const std::string &name, const as_value &val, int flags=DefaultFlags) |
Initialize a member value by string. | |
void | init_member (const ObjectURI &uri, const as_value &val, int flags=DefaultFlags) |
Initialize a member value by key. | |
void | init_property (const std::string &key, as_function &getter, as_function &setter, int flags=DefaultFlags) |
Initialize a getter/setter property by name. | |
void | init_property (const std::string &key, as_c_function_ptr getter, as_c_function_ptr setter, int flags=DefaultFlags) |
Initialize a getter/setter property by name. | |
void | init_property (const ObjectURI &uri, as_function &getter, as_function &setter, int flags=DefaultFlags) |
Initialize a getter/setter property by key. | |
void | init_property (const ObjectURI &uri, as_c_function_ptr getter, as_c_function_ptr setter, int flags=DefaultFlags) |
Initialize a getter/setter property by key. | |
bool | init_destructive_property (const ObjectURI &uri, as_function &getter, int flags=PropFlags::dontEnum) |
Initialize a destructive getter property. | |
bool | init_destructive_property (const ObjectURI &uri, as_c_function_ptr getter, int flags=PropFlags::dontEnum) |
Initialize a destructive getter property. | |
void | init_readonly_property (const std::string &key, as_function &getter, int flags=DefaultFlags) |
Use this method for read-only properties. | |
void | init_readonly_property (const std::string &key, as_c_function_ptr getter, int flags=DefaultFlags) |
Use this method for read-only properties. | |
bool | watch (const ObjectURI &uri, as_function &trig, const as_value &cust) |
Add a watch trigger, overriding any other defined for same name. | |
bool | unwatch (const ObjectURI &uri) |
Remove a watch trigger. | |
virtual bool | get_member (const ObjectURI &uri, as_value *val) |
Get a property by name if it exists. | |
virtual as_object * | get_super (const ObjectURI &fname) |
as_object * | get_super () |
std::pair< bool, bool > | delProperty (const ObjectURI &uri) |
Delete a property of this object, unless protected from deletion. | |
Property * | getOwnProperty (const ObjectURI &uri) |
Get this object's own named property, if existing. | |
void | set_member_flags (const ObjectURI &uri, int setTrue, int setFalse=0) |
Set member flags (probably used by ASSetPropFlags) | |
virtual as_function * | to_function () |
Cast to a as_function, or return NULL. | |
virtual bool | isSuper () const |
Return true if this is a 'super' object. | |
void | addInterface (as_object *ctor) |
Add an interface to the list of interfaces. | |
bool | instanceOf (as_object *ctor) |
Check whether this object is an instance of the given constructor. | |
bool | prototypeOf (as_object &instance) |
Check whether this object is in another object's inheritance chain. | |
void | setPropFlags (const as_value &props, int set_false, int set_true) |
Set property flags. | |
void | copyProperties (const as_object &o) |
Copy properties from the given object. | |
void | clearProperties () |
Drop all properties from this object. | |
template<typename T > | |
void | visitProperties (PropertyVisitor &visitor) const |
Visit the properties of this object by key/as_value pairs. | |
void | visitKeys (KeyVisitor &visitor) const |
Visit all visible property identifiers. | |
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. | |
as_object * | get_prototype () const |
Return this object's __proto__ member. | |
void | set_prototype (const as_value &proto) |
Set this object's __proto__ member. | |
void | setRelay (Relay *p) |
Set the as_object's Relay object. | |
Relay * | relay () const |
Access the as_object's Relay object. | |
bool | array () const |
Return true if this object should be treated as an array. | |
void | setArray (bool array=true) |
Set whether this object should be treated as an array. | |
DisplayObject * | displayObject () const |
Return the DisplayObject associated with this object. | |
void | setDisplayObject (DisplayObject *d) |
Set the DisplayObject associated with this as_object. | |
Static Public Attributes | |
static const int | DefaultFlags |
The most common flags for built-in properties. | |
Protected Member Functions | |
as_object (VM &vm) | |
Construct an as_object associated with a VM. | |
virtual void | markReachableResources () const |
Mark all reachable resources, override from GcResource. |
The base class for all ActionScript objects.
Everything in ActionScript is an object or convertible to an object. This class is the base class for all object types and the implementation of the ActionScript Object type itself. See asobj/Object.cpp for the ActionScript Object interface. An AS2 object has 3 principle tasks: 1. to store a set of ActionScript properties and to control dynamic access to them. 2. to store native type information. 3. to store 'watches' that report on changes to any member property. A fourth but relatively minor task is to store a list of implemented interfaces (see as_object::instanceOf()). ActionScript has two different levels of Object typing: Dynamic Typing 1a. Native type information, stored in a Relay and inaccessible to ActionScript. 1b. Array type information. This is very similar (and possibly identical to) Relays. 2. Link to a DisplayObject. Both these dynamic types can be changed independently at runtime using native functions (often, but not always, constructor functions). Static Typing Functions (as_function), Super objects (as_super) and AS3 Class types (as_class) have a static type, that is, they are not convertible to each other once created.
gnash::as_object::as_object | ( | const Global_as & | global | ) | [explicit] |
Construct an ActionScript object with no prototype associated.
global | A reference to the Global object the new object ultimately belongs to. The created object uses the resources of the Global object. |
Referenced by gnash::Global_as::createArray().
virtual gnash::as_object::~as_object | ( | ) | [inline, virtual] |
The as_object dtor does nothing special.
gnash::as_object::as_object | ( | VM & | vm | ) | [explicit, protected] |
Construct an as_object associated with a VM.
This constructor is intended for subclasses. Although they could call the public constructor that accepts a Global_as, this could imply that that constructor can access members of the passed Global_as other than getVM(), which might not be available because the Global_as will not be fully constructed yet. While that is currently not the case, using this constructor eliminates this potential initialization order problem.
void gnash::as_object::add_property | ( | const std::string & | key, |
as_function & | getter, | ||
as_function * | setter | ||
) |
Add a getter/setter property if no member already has that name.
key | Property identifier. |
getter | A function to invoke when this property value is requested. |
setter | A function to invoke when setting this property's value. By passing null, the property will have no setter. This is valid. |
References gnash::getURI(), vm(), gnash::PropertyList::getProperty(), gnash::Property::getCache(), gnash::PropertyList::addGetterSetter(), test::v, gnash::Trigger::call(), and gnash::Property::setCache().
void gnash::as_object::addInterface | ( | as_object * | ctor | ) |
Add an interface to the list of interfaces.
This is used by the action "implements". This opcode is a compile-time promise that a class will implement all the methods of an otherwise unrelated interface class. The only use in AVM1 is to allow instanceOf to return true when a class implements another class.
ctor | An as_object to specify as an interface implemented by this object. |
References assert.
bool gnash::as_object::array | ( | ) | const [inline] |
Return true if this object should be treated as an array.
Referenced by gnash::amf::Writer::writeObject(), set_member(), setArray(), gnash::operator<<(), and gnash::Global_as::createArray().
Function dispatch.
Various objects can be called, including functions and super objects. A normal object has no call functionality, so the default implementation throws an ActionTypeError.
Reimplemented in gnash::Function, gnash::Function2, gnash::as_function, gnash::builtin_function, gnash::NativeFunction, and gnash::abc::abc_function.
void gnash::as_object::clearProperties | ( | ) | [inline] |
Drop all properties from this object.
References gnash::PropertyList::clear().
Referenced by gnash::DisplayObject::destroy().
void gnash::as_object::copyProperties | ( | const as_object & | o | ) |
Copy properties from the given object.
NOTE: the __proto__ member will NOT be copied.
o | The object to copy properties from. |
References visitProperties().
Referenced by gnash::MovieClip::construct().
std::pair< bool, bool > gnash::as_object::delProperty | ( | const ObjectURI & | uri | ) |
Delete a property of this object, unless protected from deletion.
This function does *not* recurse in this object's prototype.
uri | Property identifier. |
References gnash::PropertyList::delProperty().
Referenced by gnash::delVariable(), and gnash::abc::Machine::execute().
DisplayObject* gnash::as_object::displayObject | ( | ) | const [inline] |
Return the DisplayObject associated with this object.
Referenced by gnash::getVariable(), get_member(), set_member(), visitKeys(), gnash::as_value::set_as_object(), gnash::IsDisplayObject::operator()(), and gnash::movie_root::findCharacterByTarget().
void gnash::as_object::dump_members | ( | ) |
Dump all properties using log_debug.
Note that it is very likely that this will result in changes to the object, as accessing getter/setters or destructive properties can modify properties. Only use this function for temporary debugging!
References gnash::PropertyList::size(), and gnash::PropertyList::dump().
Find a property, scanning the inheritance chain.
uri | Property identifier. |
owner | If not null, this is set to the object which contained an inherited property. |
References gnash::getSWFVersion().
Referenced by get_super(), gnash::sendEvent(), gnash::DisplayObject::hasEventHandler(), and gnash::abc::Machine::execute().
Get a property by name if it exists.
Order of property lookup:
NOTE: accessing a getter/setter property may modify the object. See getMember() for a property accessor that corresponds to ActionScript behaviour.
uri | Property identifier. |
val | Variable to assign an existing value to. Will be untouched if no property with the given name was found. |
1. Visible own properties. 2. If DisplayObject, magic properties 3. Visible own properties of all __proto__ objects (a DisplayObject ends the chain). 4. __resolve property of this object and all __proto__ objects (a Display Object ends the chain). This should ignore visibility but doesn't.
References assert, gnash::getSWFVersion(), displayObject(), gnash::key::d, gnash::getDisplayObjectProperty(), gnash::NSV::PROP_uuRESOLVE, gnash::Property::isGetterSetter(), gnash::Property::getCache(), gnash::Property::getValue(), gnash::as_value::is_object(), gnash::getStringTable(), gnash::string_table::value(), gnash::getName(), gnash::invoke(), gnash::getVM(), IF_VERBOSE_ASCODING_ERRORS, and _.
Referenced by gnash::getVariable(), instanceOf(), gnash::getPathElement(), gnash::Button::trackAsMenu(), gnash::Button::isEnabled(), gnash::DisplayObject::allowHandCursor(), gnash::DumpGui::run(), gnash::Global_as::createArray(), gnash::movie_root::processInvoke(), gnash::MovieClip::handleFocus(), and gnash::MovieClip::trackAsMenu().
as_object * gnash::as_object::get_prototype | ( | ) | const |
Return this object's __proto__ member.
The __proto__ member is the exported interface (prototype) of the class this object is an instance of.
NOTE: can return NULL (and it is expected to do for Object.prototype)
References gnash::getSWFVersion(), gnash::PropertyList::getProperty(), gnash::NSV::PROP_uuPROTOuu, gnash::visible(), gnash::Property::getValue(), gnash::toObject(), and gnash::getVM().
Referenced by get_super(), instanceOf(), prototypeOf(), visitKeys(), gnash::abc::Machine::execute(), and gnash::createVideoObject().
Get the super object of this object.
The super should be __proto__ if this is a prototype object itself, or __proto__.__proto__ if this is not a prototype object. This is only conceptual however, and may be more convoluted to obtain the actual super.
References get_prototype(), gnash::ObjectURI::empty(), gnash::getSWFVersion(), findProperty(), and gnash::getGlobal().
Referenced by gnash::Function::call(), and gnash::Function2::call().
as_object * gnash::as_object::get_super | ( | ) |
References get_prototype(), and gnash::getGlobal().
Get this object's own named property, if existing.
This function does *not* recurse in this object's prototype.
uri | Property identifier. |
References gnash::PropertyList::getProperty().
Referenced by gnash::constructInstance(), gnash::setLocal(), gnash::abc::Class::addGetter(), gnash::abc::Class::addSetter(), gnash::Global_as::createFunction(), gnash::Global_as::createClass(), gnash::abc::Method::addGetter(), and gnash::abc::Method::addSetter().
bool gnash::as_object::init_destructive_property | ( | const ObjectURI & | uri, |
as_function & | getter, | ||
int | flags = PropFlags::dontEnum |
||
) |
Initialize a destructive getter property.
A destructive getter can be used as a place holder for the real value of a property. As soon as getValue is invoked on the getter, it destroys itself after setting its property to the return value of getValue.
uri | Property identifier. |
getter | A function to invoke when this property value is requested. |
flags | Flags for the new member. By default dontEnum. |
References gnash::PropertyList::addDestructiveGetter().
Referenced by gnash::bitmapdata_class_init(), gnash::bitmapfilter_class_init(), gnash::ClassHierarchy::declareClass(), gnash::colortransform_class_init(), gnash::flash_display_package_init(), gnash::flash_external_package_init(), gnash::externalinterface_class_init(), gnash::flash_filters_package_init(), gnash::flash_package_init(), gnash::flash_geom_package_init(), gnash::matrix_class_init(), gnash::flash_net_package_init(), gnash::point_class_init(), gnash::rectangle_class_init(), gnash::flash_text_package_init(), and gnash::transform_class_init().
bool gnash::as_object::init_destructive_property | ( | const ObjectURI & | uri, |
as_c_function_ptr | getter, | ||
int | flags = PropFlags::dontEnum |
||
) |
Initialize a destructive getter property.
A destructive getter can be used as a place holder for the real value of a property. As soon as getValue is invoked on the getter, it destroys itself after setting its property to the return value of getValue.
uri | Property identifier. |
getter | A function to invoke when this property value is requested. |
flags | Flags for the new member. By default dontEnum. |
References gnash::PropertyList::addDestructiveGetter().
void gnash::as_object::init_member | ( | const std::string & | name, |
const as_value & | val, | ||
int | flags = DefaultFlags |
||
) |
Initialize a member value by string.
This is just a wrapper around the other init_member method used as a trampoline to avoid changing all classes to use string_table::key directly.
name | Name of the member. |
val | Value to assign to the member. |
flags | Flags for the new member. By default dontDelete and dontEnum. |
References gnash::getURI(), and vm().
Referenced by gnash::accessibility_class_init(), gnash::array_class_init(), gnash::attachAsBroadcasterStaticInterface(), gnash::registerBitmapClass(), gnash::boolean_class_init(), gnash::button_class_init(), gnash::abc::Class::addValue(), gnash::abc::Class::addSlot(), gnash::abc::Class::addMethod(), gnash::date_class_init(), gnash::dbus_class_init(), gnash::dejagnu_class_init(), gnash::fileio_class_init(), gnash::filereference_class_init(), gnash::getArguments(), gnash::function_class_init(), gnash::Global_as::createFunction(), gnash::Global_as::createClass(), gnash::Global_as::createArray(), gnash::Global_as::registerClasses(), gnash::registerBuiltinObject(), gnash::registerBuiltinClass(), gnash::gtkext_class_init(), gnash::attachKeyInterface(), gnash::lirc_class_init(), gnash::attachLoadableInterface(), gnash::abc::Machine::execute(), gnash::abc::Method::addValue(), gnash::abc::Method::addSlot(), gnash::MovieClip::constructAsScriptObject(), gnash::movieclip_class_init(), gnash::moviecliploader_class_init(), gnash::mysql_class_init(), gnash::NetConnection_as::notifyStatus(), gnash::number_class_init(), gnash::initObjectClass(), gnash::sharedobject_class_init(), gnash::sound_class_init(), gnash::string_class_init(), gnash::textfield_class_init(), gnash::textformat_class_init(), gnash::video_class_init(), gnash::VM::getNative(), gnash::xml_class_init(), gnash::XMLNode_as::object(), and gnash::xmlnode_class_init().
void gnash::as_object::init_member | ( | const ObjectURI & | uri, |
const as_value & | val, | ||
int | flags = DefaultFlags |
||
) |
Initialize a member value by key.
This method has to be used by built-in classes initialization (VM initialization in general) as will avoid to scan the inheritance chain.
By default, members initialized by calling this function will be protected from deletion and not shown in enumeration. These flags can be explicitly set using the third argument.
uri | Property identifier. |
val | Value to assign to the member. |
flags | Flags for the new member. By default dontDelete and dontEnum. |
References gnash::PropertyList::setValue(), gnash::key::l, gnash::getStringTable(), and _.
void gnash::as_object::init_property | ( | const std::string & | key, |
as_function & | getter, | ||
as_function & | setter, | ||
int | flags = DefaultFlags |
||
) |
Initialize a getter/setter property by name.
This is just a wrapper around the other init_property method used as a trampoline to avoid changing all classes to use string_table::key directly.
key | Name of the property. Will be converted to lowercase if VM is initialized for SWF6 or lower. |
getter | A function to invoke when this property value is requested. add_ref will be called on the function. |
setter | A function to invoke when setting this property's value. add_ref will be called on the function. |
flags | Flags for the new member. By default dontDelete and dontEnum. See PropFlags::Flags. |
References gnash::getURI(), and vm().
Referenced by init_property(), init_readonly_property(), gnash::abc::Class::addGetter(), gnash::abc::Class::addSetter(), gnash::abc::Method::addGetter(), and gnash::abc::Method::addSetter().
void gnash::as_object::init_property | ( | const std::string & | key, |
as_c_function_ptr | getter, | ||
as_c_function_ptr | setter, | ||
int | flags = DefaultFlags |
||
) |
Initialize a getter/setter property by name.
This is just a wrapper around the other init_property method used as a trampoline to avoid changing all classes to use string_table::key directly.
key | Name of the property. Will be converted to lowercase if VM is initialized for SWF6 or lower. |
getter | A function to invoke when this property value is requested. |
setter | A function to invoke when setting this property's value. |
flags | Flags for the new member. By default dontDelete and dontEnum. See PropFlags::Flags. |
References gnash::getURI(), vm(), and init_property().
void gnash::as_object::init_property | ( | const ObjectURI & | uri, |
as_function & | getter, | ||
as_function & | setter, | ||
int | flags = DefaultFlags |
||
) |
Initialize a getter/setter property by key.
This method has to be used by built-in classes initialization (VM initialization in general) as will avoid to scan the inheritance chain.
uri | Property identifier. |
getter | A function to invoke when this property value is requested. |
setter | A function to invoke when this property value is set. |
flags | Flags for the new member. By default dontEnum and dontDelete. |
References gnash::PropertyList::addGetterSetter().
void gnash::as_object::init_property | ( | const ObjectURI & | uri, |
as_c_function_ptr | getter, | ||
as_c_function_ptr | setter, | ||
int | flags = DefaultFlags |
||
) |
Initialize a getter/setter property by key.
This method has to be used by built-in classes initialization (VM initialization in general) as will avoid to scan the inheritance chain.
uri | Property identifier. |
getter | A function to invoke when this property value is requested. |
setter | A function to invoke when this property value is set. |
flags | Flags for the new member. By default dontEnum and dontDelete. |
References gnash::PropertyList::addGetterSetter().
void gnash::as_object::init_readonly_property | ( | const std::string & | key, |
as_function & | getter, | ||
int | flags = DefaultFlags |
||
) |
Use this method for read-only properties.
This method achieves the same as the above init_property method. Additionally, it sets the property as read-only so that a default handler will be triggered when ActionScript attempts to set the property. The arguments are the same as the above init_property arguments, although the setter argument is omitted.
References gnash::getURI(), vm(), init_property(), gnash::PropFlags::readOnly, assert, and gnash::PropertyList::getProperty().
Referenced by gnash::NetConnection_as::setURI().
void gnash::as_object::init_readonly_property | ( | const std::string & | key, |
as_c_function_ptr | getter, | ||
int | flags = DefaultFlags |
||
) |
Use this method for read-only properties.
This method achieves the same as the above init_property method. Additionally, it sets the property as read-only so that a default handler will be triggered when ActionScript attempts to set the property.
The arguments are the same as the above init_property arguments, although the setter argument is omitted.
References gnash::getURI(), vm(), init_property(), gnash::PropFlags::readOnly, assert, and gnash::PropertyList::getProperty().
bool gnash::as_object::instanceOf | ( | as_object * | ctor | ) |
Check whether this object is an instance of the given constructor.
An object is an instance of a constructor if constructor.prototype is found anywhere in the object's prototype chain (e.g. if object.__proto__ == constructor.prototype). It is also an instance of a constructor if the constructor is listed in the object's interfaces (this is a compile-time promise and has no runtime effects other than for instanceOf).
ctor | The as_object to compare this object to. For more ActionScript-like syntax it can be any object or null. |
An object is never an instance of a null prototype.
References get_member(), gnash::NSV::PROP_PROTOTYPE, gnash::toObject(), gnash::getVM(), and get_prototype().
Referenced by gnash::abc::Machine::execute().
virtual bool gnash::as_object::isSuper | ( | ) | const [inline, virtual] |
Return true if this is a 'super' object.
void gnash::as_object::markReachableResources | ( | ) | const [protected, virtual] |
Mark all reachable resources, override from GcResource.
The default implementation marks all properties
If a derived class provides access to more GC-managed resources, it should override this function and call this function directly as the last step.
Reimplemented from gnash::GcResource.
Reimplemented in gnash::Function, and gnash::Global_as.
References gnash::PropertyList::setReachable(), gnash::renderer::opengl::for_each(), and gnash::GcResource::setReachable().
bool gnash::as_object::prototypeOf | ( | as_object & | instance | ) |
Check whether this object is in another object's inheritance chain.
This is roughly the inverse of instanceOf().
instance | The instance object to check for inheritance from this object. |
References get_prototype(), IF_VERBOSE_ASCODING_ERRORS, and _.
Relay* gnash::as_object::relay | ( | ) | const [inline] |
Access the as_object's Relay object.
The Relay object is a polymorphic object containing native type characteristics. It is rarely useful to use this function directly. Instead use the convenience functions ensure<>() and isNativeType() to access the Relay object. Relay objects are not available to ActionScript, so this object should not be used in built-in functions (that is, functions implemented in ActionScript).
Referenced by gnash::amf::Writer::writeObject(), gnash::operator<<(), and gnash::ThisIsNative::operator()().
bool gnash::as_object::set_member | ( | const ObjectURI & | uri, |
const as_value & | val, | ||
bool | ifFound = false |
||
) | [virtual] |
Set a member value.
Order of property lookup:
uri | Property identifier. |
val | Value to assign to the named property. |
ifFound | If true, don't create a new member, but rather only update an existing one. |
0. MovieClip textfield variables. TODO: this is a hack and should be eradicated. 1. Own properties even if invisible or not getter-setters. 2. If DisplayObject, magic properties 3. Visible own getter-setter properties of all __proto__ objects (a DisplayObject ends the chain).
References displayObject(), gnash::MovieClip::setTextFieldVariables(), array(), gnash::checkArrayLength(), gnash::key::d, gnash::setDisplayObjectProperty(), gnash::getSWFVersion(), gnash::Property::isGetterSetter(), gnash::visible(), gnash::readOnly(), IF_VERBOSE_ASCODING_ERRORS, gnash::key::l, gnash::getStringTable(), _, gnash::string_table::value(), gnash::getName(), and gnash::PropertyList::setValue().
Referenced by gnash::setVariable(), gnash::AsBroadcaster::initialize(), gnash::registerBitmapClass(), gnash::declareLocal(), gnash::setLocal(), gnash::abc::Class::addValue(), gnash::fileio_scandir(), gnash::abc::Method::setOwner(), gnash::abc::Method::addValue(), gnash::movie_root::processInvoke(), gnash::movie_root::LoadCallback::processLoad(), gnash::MovieClip::setVariables(), gnash::TextField::setTextValue(), and gnash::XMLNode_as::setAttribute().
void gnash::as_object::set_member_flags | ( | const ObjectURI & | uri, |
int | setTrue, | ||
int | setFalse = 0 |
||
) |
Set member flags (probably used by ASSetPropFlags)
name | Name of the property. Must be all lowercase if the current VM is initialized for a target up to SWF6. |
setTrue | The set of flags to set |
setFalse | The set of flags to clear |
References gnash::PropertyList::setFlags().
Referenced by gnash::accessibility_class_init(), setPropFlags(), gnash::AsBroadcaster::initialize(), gnash::color_class_init(), gnash::date_class_init(), gnash::initObjectClass(), and gnash::sound_class_init().
void gnash::as_object::set_prototype | ( | const as_value & | proto | ) |
Set this object's __proto__ member.
This does more or less what set_member("__proto__") does, but without the lookup process.
References gnash::PropertyList::setValue(), gnash::NSV::PROP_uuPROTOuu, and DefaultFlags.
Referenced by gnash::constructInstance(), gnash::getObjectWithPrototype(), gnash::Global_as::createArray(), gnash::Global_as::makeObject(), gnash::abc::Machine::execute(), gnash::MovieClip::constructAsScriptObject(), and gnash::XMLNode_as::object().
void gnash::as_object::setArray | ( | bool | array = true | ) | [inline] |
Set whether this object should be treated as an array.
References array().
Referenced by gnash::Global_as::createArray().
void gnash::as_object::setDisplayObject | ( | DisplayObject * | d | ) | [inline] |
Set the DisplayObject associated with this as_object.
References gnash::key::d.
Referenced by gnash::DisplayObject::DisplayObject().
void gnash::as_object::setPropFlags | ( | const as_value & | props, |
int | set_false, | ||
int | set_true | ||
) |
Set property flags.
props | A comma-delimited list of property names as a string, a NULL value. This is in fact a string, which should be split on the ',' to an array then processed. TODO: this would be much better as a free function. |
set_false | A mask of flags to set to false. |
set_true | A mask of flags to set to true. |
References gnash::as_value::is_null(), gnash::PropertyList::setFlagsAll(), gnash::as_value::to_string(), set_member_flags(), gnash::getURI(), and vm().
void gnash::as_object::setRelay | ( | Relay * | p | ) | [inline] |
Set the as_object's Relay object.
This is a pointer to a native object that contains special type characteristics. Setting the Relay object allows native functions to get or set non-ActionScript properties. This function should only be used in native functions such as constructors and special creation functions like MovieClip.createTextField(). As Relay objects are not available to ActionScript, this should never appear in built-in functions. This function also removes Array typing from an object when a Relay is assigned. There are tests verifying this behaviour in actionscript.all and the swfdec testsuite.
Referenced by gnash::XMLNode_as::object().
std::string gnash::as_object::stringValue | ( | ) | const [virtual] |
Return the string representation for this object.
This is dependent on the VM version and the type of object, function, or class.
Reimplemented in gnash::as_function, and gnash::abc::as_class.
virtual as_function* gnash::as_object::to_function | ( | ) | [inline, virtual] |
Cast to a as_function, or return NULL.
Reimplemented in gnash::as_function.
Referenced by gnash::amf::Writer::writeObject(), gnash::as_value::to_function(), and gnash::as_value::is_function().
bool gnash::as_object::unwatch | ( | const ObjectURI & | uri | ) |
Remove a watch trigger.
uri | Property identifier. |
References gnash::getStringTable(), gnash::string_table::value(), gnash::getName(), gnash::PropertyList::getProperty(), and gnash::Property::isGetterSetter().
void gnash::as_object::visitKeys | ( | KeyVisitor & | visitor | ) | const |
Visit all visible property identifiers.
NB: this function does not access the property values, so callers can be certain no values will be changed. The enumeration recurses through the prototype chain. This implementation will keep track of visited object to avoid infinite loops in the prototype chain. NOTE: the MM player just chokes in this case.
visitor | The visitor function. Will be invoked for each property of this object with an ObjectURI as the only argument. |
References displayObject(), gnash::DisplayObject::visitNonProperties(), gnash::PropertyList::visitKeys(), and get_prototype().
void gnash::as_object::visitProperties | ( | PropertyVisitor & | visitor | ) | const [inline] |
Visit the properties of this object by key/as_value pairs.
The method will invoke the given visitor method with the identifier and value of the property. Note that this access values, which may change the object.
visitor | The visitor function. Will be invoked for each property of this object with an ObjectURI as first argument and a const as_value as second argument. |
References gnash::PropertyList::visitValues(), and gnash::key::T.
Referenced by gnash::amf::Writer::writeObject(), copyProperties(), and gnash::enumerateProperties().
VM& gnash::as_object::vm | ( | ) | const [inline] |
Return a reference to this as_object's global object.
Referenced by add_property(), init_member(), init_property(), init_readonly_property(), setPropFlags(), gnash::getVM(), gnash::getRoot(), gnash::getStringTable(), gnash::getRunResources(), gnash::getSWFVersion(), gnash::getGlobal(), gnash::Function::call(), gnash::Function2::call(), gnash::Global_as::registerClasses(), and gnash::Global_as::getVM().
bool gnash::as_object::watch | ( | const ObjectURI & | uri, |
as_function & | trig, | ||
const as_value & | cust | ||
) |
Add a watch trigger, overriding any other defined for same name.
uri | property identifier |
trig | A function to invoke when this property value is assigned to. The function will be called with old val, new val and the custom value below. Its return code will be used to set actual value |
cust | Custom value to always pass to the trigger as third arg |
References gnash::getStringTable(), gnash::string_table::value(), and gnash::getName().
const int gnash::as_object::DefaultFlags [static] |
PropFlags::dontDelete | PropFlags::dontEnum
The most common flags for built-in properties.
Most API properties, including classes and objects, have these flags.
Referenced by gnash::accessibility_class_init(), set_prototype(), gnash::registerBitmapClass(), gnash::boolean_class_init(), gnash::button_class_init(), gnash::date_class_init(), gnash::filereference_class_init(), gnash::Global_as::createFunction(), gnash::Global_as::createClass(), gnash::registerBuiltinObject(), gnash::registerBuiltinClass(), gnash::movieclip_class_init(), gnash::moviecliploader_class_init(), gnash::number_class_init(), gnash::sharedobject_class_init(), gnash::textfield_class_init(), gnash::textformat_class_init(), gnash::video_class_init(), gnash::xml_class_init(), and gnash::xmlnode_class_init().