Classes | Public Types | Public Member Functions

gnash::PropertyList Class Reference

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

#include <PropertyList.h>

Collaboration diagram for gnash::PropertyList:
Collaboration graph
[legend]

List of all members.

Classes

struct  NameExtractor

Public Types

typedef std::set< ObjectURIPropertyTracker
typedef std::pair< Property,
string_table::key
value_type
typedef
boost::multi_index::member
< value_type,
value_type::second_type,&value_type::second
KeyExtractor
typedef
boost::multi_index_container
< value_type,
boost::multi_index::indexed_by
< boost::multi_index::sequenced
<>, boost::multi_index::ordered_unique
< NameExtractor >
, boost::multi_index::ordered_non_unique
< KeyExtractor > > > 
container
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 enumerateKeys (as_environment &env, PropertyTracker &donelist) const
 Enumerate all non-hidden properties to the given as_environment.
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 dump (std::map< std::string, as_value > &to)
 Dump all members into the given map.
void setReachable () const

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 container::const_iterator gnash::PropertyList::const_iterator
typedef boost::multi_index_container< value_type, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::ordered_unique<NameExtractor>, boost::multi_index::ordered_non_unique<KeyExtractor> > > gnash::PropertyList::container
typedef container::iterator gnash::PropertyList::iterator
typedef boost::multi_index::member<value_type, value_type::second_type, &value_type::second> gnash::PropertyList::KeyExtractor

Constructor & Destructor Documentation

gnash::PropertyList::PropertyList ( as_object obj  )  [inline]

Construct the PropertyList.

Parameters:
obj The as_object to which this PropertyList belongs. This object is not fully constructed at this stage, so this constructor should not do anything with it!

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:
key 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.
Returns:
true if the property was successfully added.

References gnash::key::a, gnash::Property::getFlags(), gnash::getStringTable(), gnash::getVM(), gnash::key::l, gnash::ObjectURI::name, and gnash::string_table::noCase().

Referenced by gnash::as_object::init_readonly_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:
key Name of the property. Case-sensitive search.
getter A function to invoke when this property value is requested.
flagsIfMissing Flags 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, gnash::ObjectURI::name, and gnash::string_table::noCase().

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:
key Name of the property. Search is case-*sensitive*
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.
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::ObjectURI::name, gnash::string_table::noCase(), gnash::Property::setCache(), and gnash::Property::setFlags().

Referenced by gnash::as_object::init_readonly_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:
key 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.
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::ObjectURI::name, gnash::string_table::noCase(), gnash::Property::setFlags(), 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:
key Name of the property.
nsId Name of the namespace
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 main().

void gnash::PropertyList::dump ( std::map< std::string, as_value > &  to  ) 

Dump all members into the given map.

This does not reflect the normal enumeration order. It is sorted lexicographically by property.

References gnash::getStringTable(), gnash::key::i, and gnash::key::l.

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

void gnash::PropertyList::enumerateKeys ( as_environment env,
PropertyTracker donelist 
) const

Enumerate all non-hidden properties to the given as_environment.

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:
donelist Don't enumerate properties in donelist. Enumerated properties are added to donelist.

References gnash::getName(), gnash::getStringTable(), gnash::key::i, gnash::as_environment::push(), and gnash::string_table::value().

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

Get a property if it exists.

Parameters:
key Name of the property. Search is case-*sensitive*
nsId The id of the namespace to search
Returns:
A Property or 0, if no such property exists. All Property objects are owned by this PropertyList. Do not delete them.

References gnash::getVM().

Referenced by gnash::as_object::addInterface(), gnash::as_object::getMember(), getVal(), gnash::as_object::instanceOf(), main(), and gnash::as_object::set_member_flags().

void gnash::PropertyList::setFlags ( const ObjectURI uri,
int  setTrue,
int  setFalse 
)

Set the flags of a property.

Parameters:
key Name of the property. Search is case-*sensitive*
setTrue The set of flags to set
setFalse The set of flags to clear

References s2x::f, gnash::getVM(), and gnash::PropFlags::set_flags().

Referenced by main().

void gnash::PropertyList::setFlagsAll ( int  setTrue,
int  setFalse 
)

Set the flags of all properties.

Parameters:
setTrue The set of flags to set
setFalse The set of flags to clear

References s2x::f, and gnash::PropFlags::set_flags().

void gnash::PropertyList::setReachable (  )  const

Mark all simple properties, getters and setters as being reachable (for the GC)

References gnash::foreachFirst(), and gnash::Property::setReachable().

Referenced by gnash::Trigger::setReachable().

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:
key Name of the property. Search is case-*sensitive*
value a const reference to the as_value to use for setting or creating the property.
namespaceId The namespace in which this should be entered. If 0 is given, this will use the first value found, if it exists.
flagsIfMissing Flags 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::Property::isDestructive(), gnash::key::l, gnash::ObjectURI::name, gnash::string_table::noCase(), gnash::readOnly(), and gnash::Property::setValue().

Referenced by main().

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

Return number of properties in this list.

Referenced by main().

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


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