Gnash  0.8.10
Classes | Public Types | Public Member Functions
gnash::PropertyList Class Reference

Set of properties associated with an ActionScript object. More...

#include <PropertyList.h>

List of all members.

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.
PropertygetProperty (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.

Detailed Description

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.


Member Typedef Documentation

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 boost::multi_index::sequenced< boost::multi_index::tag<CreationOrder> > gnash::PropertyList::SequencedIndex

The sequenced index in creation order.


Constructor & Destructor Documentation

gnash::PropertyList::PropertyList ( as_object obj)

Construct the PropertyList.

Parameters:
objThe as_object to which this PropertyList belongs.

Member Function Documentation

bool gnash::PropertyList::addDestructiveGetter ( const ObjectURI uri,
as_function getter,
const PropFlags flagsIfMissing = 0 
)

Add a destructive getter property, if not already existant.

Parameters:
uriName of the property.
getterA function to invoke when this property value is requested.
flagsIfMissingFlags to associate to the property if a new one is created.
Returns:
true if the property was successfully added.

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.

Parameters:
uriName of the property.
getterA function to invoke when this property value is requested.
flagsIfMissingFlags to associate to the property if a new
Returns:
true if the property was successfully added, false otherwise.

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.

Parameters:
uriName of the property.
getterA function to invoke when this property value is requested.
setterA function to invoke when setting this property's value.
cacheValThe value to use as a cache. If null uses any cache from pre-existing property with same name.
flagsIfMissingFlags to associate to the property if a new one is created.
Returns:
true if the property was successfully added, false otherwise.

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.

Parameters:
uriName of the property.
getterA function to invoke when this property value is requested.
setterA function to invoke when setting this property's value.
Returns:
true if the property was successfully added, false otherwise.

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.

Parameters:
uriName of the property.
Returns:
a pair of boolean values expressing whether the property was found (first) and whether it was deleted (second). Of course a pair(false, true) would be invalid (deleted a non-found property!?). Valid returns are:
  • (false, false) : property not found
  • (true, false) : property protected from deletion
  • (true, true) : property successfully deleted

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().

Property * gnash::PropertyList::getProperty ( const ObjectURI uri) const

Get a property if it exists.

Parameters:
uriName of the property.
Returns:
A Property or 0, if no such property exists. All Property objects are owned by this PropertyList. Do not delete them.

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.

Parameters:
uriName of the property.
setTrueThe set of flags to set
setFalseThe 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.

Parameters:
setTrueThe set of flags to set
setFalseThe 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.

Parameters:
uriName of the property.
valuea const reference to the as_value to use for setting or creating the property.
flagsIfMissingFlags to associate to the property if a new one is created.
Returns:
true if the value was successfully set, false otherwise (found a read-only property, most likely).

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.

Parameters:
donelistDon't enumerate properties in donelist. Enumerated properties are added to donelist.

References gnash::key::i.

Referenced by gnash::as_object::visitKeys().

template<class U , class V >
void gnash::PropertyList::visitValues ( V &  visitor,
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.

Template Parameters:
VThe type of the visitor.
UAn object that may check property values. The object's operator() should return false if the property is not acceptable.
Parameters:
visitorThe 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().


The documentation for this class was generated from the following files: