Gnash  0.8.11dev
Classes | Public Types | Public Member Functions | List of all members
gnash::PropertyList Class Reference

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

#include <PropertyList.h>

Inheritance diagram for gnash::PropertyList:

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::LessThanPropertyTracker
 
typedef Property value_type
 
typedef boost::multi_index::sequenced< boost::multi_index::tag< CreationOrder > > SequencedIndex
 The sequenced index in creation order. More...
 
typedef boost::multi_index::ordered_unique< boost::multi_index::tag< Case >, KeyExtractor, ObjectURI::LessThanCaseIndex
 The case-sensitive index. More...
 
typedef boost::multi_index::ordered_non_unique< boost::multi_index::tag< NoCase >, KeyExtractor, ObjectURI::CaseLessThanNoCaseIndex
 The case-insensitive index. More...
 
typedef boost::multi_index_container< value_type, boost::multi_index::indexed_by< SequencedIndex, CaseIndex, NoCaseIndex > > container
 The container of the Properties. More...
 
typedef container::iterator iterator
 
typedef container::const_iterator const_iterator
 

Public Member Functions

DSOTEXPORT PropertyList (as_object &obj)
 Construct the PropertyList. More...
 
template<class U , class V >
void visitValues (V &visitor, U cmp=U()) const
 Visit properties. More...
 
void visitKeys (KeyVisitor &v, PropertyTracker &donelist) const
 Enumerate all non-hidden properties to the given container. More...
 
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. More...
 
DSOTEXPORT PropertygetProperty (const ObjectURI &uri) const
 Get a property if it exists. More...
 
DSOTEXPORT std::pair< bool, bool > delProperty (const ObjectURI &uri)
 Delete a Property, if existing and not protected from deletion. More...
 
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. More...
 
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. More...
 
bool addDestructiveGetter (const ObjectURI &uri, as_function &getter, const PropFlags &flagsIfMissing=0)
 Add a destructive getter property, if not already existant. More...
 
bool addDestructiveGetter (const ObjectURI &uri, as_c_function_ptr getter, const PropFlags &flagsIfMissing=0)
 
DSOTEXPORT void setFlags (const ObjectURI &uri, int setTrue, int setFalse)
 Set the flags of a property. More...
 
void setFlagsAll (int setTrue, int setFalse)
 Set the flags of all properties. More...
 
void clear ()
 Remove all entries in the container. More...
 
size_t size () const
 Return number of properties in this list. More...
 
void dump ()
 Dump all members (using log_debug) More...
 
void setReachable () const
 Mark all properties reachable. More...
 

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

§ CaseIndex

typedef boost::multi_index::ordered_unique< boost::multi_index::tag<Case>, KeyExtractor, ObjectURI::LessThan> gnash::PropertyList::CaseIndex

The case-sensitive index.

§ const_iterator

typedef container::const_iterator gnash::PropertyList::const_iterator

§ container

typedef boost::multi_index_container< value_type, boost::multi_index::indexed_by<SequencedIndex, CaseIndex, NoCaseIndex> > gnash::PropertyList::container

The container of the Properties.

§ iterator

typedef container::iterator gnash::PropertyList::iterator

§ NoCaseIndex

typedef boost::multi_index::ordered_non_unique< boost::multi_index::tag<NoCase>, KeyExtractor, ObjectURI::CaseLessThan> gnash::PropertyList::NoCaseIndex

The case-insensitive index.

§ PropertyTracker

§ SequencedIndex

typedef boost::multi_index::sequenced< boost::multi_index::tag<CreationOrder> > gnash::PropertyList::SequencedIndex

The sequenced index in creation order.

§ value_type

Constructor & Destructor Documentation

§ PropertyList()

gnash::PropertyList::PropertyList ( as_object obj)

Construct the PropertyList.

Parameters
objThe as_object to which this PropertyList belongs.

Member Function Documentation

§ addDestructiveGetter() [1/2]

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::key::a, gnash::Property::getFlags(), gnash::getStringTable(), gnash::getVM(), gnash::key::l, gnash::log_debug(), and gnash::log_error().

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

§ addDestructiveGetter() [2/2]

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::key::a, gnash::Property::getFlags(), gnash::getStringTable(), gnash::getVM(), gnash::key::l, and gnash::log_debug().

§ addGetterSetter() [1/2]

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::Property::getFlags(), gnash::getStringTable(), gnash::getVM(), gnash::key::l, gnash::log_debug(), gnash::Property::setCache(), and gnash::Property::setFlags().

Referenced by gnash::as_object::add_property(), and gnash::as_object::init_property().

§ addGetterSetter() [2/2]

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::Property::getFlags(), gnash::getStringTable(), gnash::getVM(), gnash::key::l, gnash::log_debug(), gnash::Property::setFlags(), and gnash::string_table::value().

§ clear()

void gnash::PropertyList::clear ( )

Remove all entries in the container.

§ delProperty()

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::PropFlags::dontDelete, and gnash::getVM().

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

§ dump()

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::getStringTable(), gnash::key::l, and gnash::log_debug().

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

§ getProperty()

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::stats::KeyLookup::check(), gnash::getStringTable(), gnash::getVM(), gnash::ObjectURI::name, and gnash::NSV::PROP_uuPROTOuu.

Referenced by gnash::as_object::add_property(), gnash::as_object::get_prototype(), gnash::as_object::getOwnProperty(), gnash::as_object::init_readonly_property(), and gnash::as_object::unwatch().

§ setFlags()

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::key::f, gnash::getVM(), and gnash::PropFlags::set_flags().

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

§ setFlagsAll()

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

§ setReachable()

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

§ setValue()

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::key::a, gnash::Property::getFlags(), gnash::getStringTable(), gnash::getVM(), gnash::key::l, gnash::log_debug(), and gnash::Property::setValue().

Referenced by gnash::as_object::init_member(), gnash::as_object::set_member(), and gnash::as_object::set_prototype().

§ size()

size_t gnash::PropertyList::size ( ) const
inline

Return number of properties in this list.

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

§ visitKeys()

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::PropFlags::dontEnum.

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

§ visitValues()

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.

References gnash::fontlib::clear(), DSOTEXPORT, test::uri, and test::v.


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