Gnash
0.8.10
|
Set of properties associated with an ActionScript object. More...
#include <PropertyList.h>
Classes | |
struct | Case |
Identifier for the case-sensitive index. More... | |
struct | CreationOrder |
Identifier for the sequenced index. More... | |
struct | KeyExtractor |
struct | NoCase |
Identifier for the case-insensitive index. More... | |
Public Types | |
typedef std::set< ObjectURI, ObjectURI::LessThan > | PropertyTracker |
typedef Property | value_type |
typedef boost::multi_index::sequenced < boost::multi_index::tag < CreationOrder > > | SequencedIndex |
The sequenced index in creation order. | |
typedef boost::multi_index::ordered_unique < boost::multi_index::tag < Case >, KeyExtractor, ObjectURI::LessThan > | CaseIndex |
The case-sensitive index. | |
typedef boost::multi_index::ordered_non_unique < boost::multi_index::tag < NoCase >, KeyExtractor, ObjectURI::CaseLessThan > | NoCaseIndex |
The case-insensitive index. | |
typedef boost::multi_index_container < value_type, boost::multi_index::indexed_by < SequencedIndex, CaseIndex, NoCaseIndex > > | container |
The container of the Properties. | |
typedef container::iterator | iterator |
typedef container::const_iterator | const_iterator |
Public Member Functions | |
PropertyList (as_object &obj) | |
Construct the PropertyList. | |
template<class U , class V > | |
void | visitValues (V &visitor, U cmp=U()) const |
Visit properties. | |
void | visitKeys (KeyVisitor &v, PropertyTracker &donelist) const |
Enumerate all non-hidden properties to the given container. | |
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. | |
Property * | getProperty (const ObjectURI &uri) const |
Get a property if it exists. | |
std::pair< bool, bool > | delProperty (const ObjectURI &uri) |
Delete a Property, if existing and not protected from deletion. | |
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. | |
bool | addGetterSetter (const ObjectURI &uri, as_c_function_ptr getter, as_c_function_ptr setter, const PropFlags &flagsIfMissing) |
Add a getter/setter property, if not already existing. | |
bool | addDestructiveGetter (const ObjectURI &uri, as_function &getter, const PropFlags &flagsIfMissing=0) |
Add a destructive getter property, if not already existant. | |
bool | addDestructiveGetter (const ObjectURI &uri, as_c_function_ptr getter, const PropFlags &flagsIfMissing=0) |
void | setFlags (const ObjectURI &uri, int setTrue, int setFalse) |
Set the flags of a property. | |
void | setFlagsAll (int setTrue, int setFalse) |
Set the flags of all properties. | |
void | clear () |
Remove all entries in the container. | |
size_t | size () const |
Return number of properties in this list. | |
void | dump () |
Dump all members (using log_debug) | |
void | setReachable () const |
Mark all properties reachable. |
Set of properties associated with an ActionScript object.
The PropertyList container is the sole owner of the Property elements in it contained and has full responsibility of their construction and destruction. A PropertyList holds a reference to the as_object whose properties it contains. This reference will always be valid if the PropertyList is a member of as_object. It is theoretically possible for a PropertyList to be used with any as_object, not just original as_object it was use with. Currently (as there is no use for this scenario) it is not possible to change the owner.
typedef boost::multi_index::ordered_unique< boost::multi_index::tag<Case>, KeyExtractor, ObjectURI::LessThan> gnash::PropertyList::CaseIndex |
The case-sensitive index.
typedef container::const_iterator gnash::PropertyList::const_iterator |
typedef boost::multi_index_container< value_type, boost::multi_index::indexed_by<SequencedIndex, CaseIndex, NoCaseIndex> > gnash::PropertyList::container |
The container of the Properties.
typedef container::iterator gnash::PropertyList::iterator |
typedef boost::multi_index::ordered_non_unique< boost::multi_index::tag<NoCase>, KeyExtractor, ObjectURI::CaseLessThan> gnash::PropertyList::NoCaseIndex |
The case-insensitive index.
typedef std::set<ObjectURI, ObjectURI::LessThan> gnash::PropertyList::PropertyTracker |
typedef boost::multi_index::sequenced< boost::multi_index::tag<CreationOrder> > gnash::PropertyList::SequencedIndex |
The sequenced index in creation order.
gnash::PropertyList::PropertyList | ( | as_object & | obj | ) |
Construct the PropertyList.
obj | The as_object to which this PropertyList belongs. |
bool gnash::PropertyList::addDestructiveGetter | ( | const ObjectURI & | uri, |
as_function & | getter, | ||
const PropFlags & | flagsIfMissing = 0 |
||
) |
Add a destructive getter property, if not already existant.
uri | Name of the property. |
getter | A function to invoke when this property value is requested. |
flagsIfMissing | Flags to associate to the property if a new one is created. |
References gnash::getVM(), gnash::key::l, gnash::getStringTable(), _, gnash::key::a, and gnash::Property::getFlags().
Referenced by gnash::as_object::init_destructive_property().
bool gnash::PropertyList::addDestructiveGetter | ( | const ObjectURI & | uri, |
as_c_function_ptr | getter, | ||
const PropFlags & | flagsIfMissing = 0 |
||
) |
Add a destructive getter property, if not already existant.
uri | Name of the property. |
getter | A function to invoke when this property value is requested. |
flagsIfMissing | Flags to associate to the property if a new |
References gnash::getVM(), gnash::key::a, gnash::key::l, gnash::getStringTable(), and gnash::Property::getFlags().
bool gnash::PropertyList::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.
TODO: this function has far too many arguments.
uri | Name of the property. |
getter | A function to invoke when this property value is requested. |
setter | A function to invoke when setting this property's value. |
cacheVal | The value to use as a cache. If null uses any cache from pre-existing property with same name. |
flagsIfMissing | Flags to associate to the property if a new one is created. |
References gnash::key::a, gnash::getVM(), gnash::Property::setFlags(), gnash::Property::setCache(), gnash::key::l, gnash::getStringTable(), and gnash::Property::getFlags().
Referenced by gnash::as_object::add_property(), and gnash::as_object::init_property().
bool gnash::PropertyList::addGetterSetter | ( | const ObjectURI & | uri, |
as_c_function_ptr | getter, | ||
as_c_function_ptr | setter, | ||
const PropFlags & | flagsIfMissing | ||
) |
Add a getter/setter property, if not already existing.
uri | Name of the property. |
getter | A function to invoke when this property value is requested. |
setter | A function to invoke when setting this property's value. |
References gnash::key::a, gnash::getVM(), gnash::Property::setFlags(), gnash::key::l, gnash::getStringTable(), gnash::Property::getFlags(), and gnash::string_table::value().
void gnash::PropertyList::clear | ( | ) |
Remove all entries in the container.
Referenced by gnash::as_object::clearProperties().
std::pair< bool, bool > gnash::PropertyList::delProperty | ( | const ObjectURI & | uri | ) |
Delete a Property, if existing and not protected from deletion.
uri | Name of the property. |
References gnash::getVM().
Referenced by gnash::as_object::delProperty().
void gnash::PropertyList::dump | ( | ) |
Dump all members (using log_debug)
This does not reflect the normal enumeration order. It is sorted lexicographically by property.
References gnash::key::l, and gnash::getStringTable().
Referenced by gnash::as_object::dump_members().
Get a property if it exists.
uri | Name of the property. |
References gnash::getStringTable(), gnash::NSV::PROP_uuPROTOuu, gnash::stats::KeyLookup::check(), gnash::ObjectURI::name, and gnash::getVM().
Referenced by gnash::as_object::add_property(), gnash::as_object::init_readonly_property(), gnash::as_object::getOwnProperty(), gnash::as_object::get_prototype(), and gnash::as_object::unwatch().
void gnash::PropertyList::setFlags | ( | const ObjectURI & | uri, |
int | setTrue, | ||
int | setFalse | ||
) |
Set the flags of a property.
uri | Name of the property. |
setTrue | The set of flags to set |
setFalse | The set of flags to clear |
References gnash::getVM(), gnash::key::f, and gnash::PropFlags::set_flags().
Referenced by gnash::as_object::set_member_flags().
void gnash::PropertyList::setFlagsAll | ( | int | setTrue, |
int | setFalse | ||
) |
Set the flags of all properties.
setTrue | The set of flags to set |
setFalse | The set of flags to clear |
References gnash::key::f, and gnash::PropFlags::set_flags().
Referenced by gnash::as_object::setPropFlags().
void gnash::PropertyList::setReachable | ( | ) | const [inline] |
Mark all properties reachable.
This can be called very frequently, so is inlined to allow the compiler to optimize it.
References gnash::renderer::opengl::for_each(), and gnash::Property::setReachable().
Referenced by gnash::as_object::markReachableResources().
bool gnash::PropertyList::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.
If the named property is a getter/setter one it's setter will be invoked using the given as_object as 'this' pointer. If the property is not found a SimpleProperty will be created.
uri | Name of the property. |
value | a const reference to the as_value to use for setting or creating the property. |
flagsIfMissing | Flags to associate to the property if a new one is created. |
References gnash::getVM(), gnash::key::a, gnash::key::l, gnash::getStringTable(), gnash::Property::getFlags(), and gnash::Property::setValue().
Referenced by gnash::as_object::set_prototype(), gnash::as_object::set_member(), and gnash::as_object::init_member().
size_t gnash::PropertyList::size | ( | ) | const [inline] |
Return number of properties in this list.
Referenced by gnash::as_object::dump_members().
void gnash::PropertyList::visitKeys | ( | KeyVisitor & | v, |
PropertyTracker & | donelist | ||
) | const |
Enumerate all non-hidden properties to the given container.
Follows enumeration order. Note that this enumeration does not access the values. Accessing the values can result in changes to the object if the value is a getter-setter, and key enumeration must avoid this.
donelist | Don't enumerate properties in donelist. Enumerated properties are added to donelist. |
References gnash::key::i.
Referenced by gnash::as_object::visitKeys().
void gnash::PropertyList::visitValues | ( | V & | visitor, |
U | cmp = U() |
||
) | const [inline] |
Visit properties.
The method will invoke the given visitor method passing it two arguments: name of the property and value of it.
V | The type of the visitor. |
U | An object that may check property values. The object's operator() should return false if the property is not acceptable. |
visitor | The visitor function. It must implement the function: bool accept(const ObjectURI&, const as_value&); Scan is by enumeration order and stops when accept() returns false. |
Referenced by gnash::as_object::visitProperties().