20 #ifndef GNASH_PROPERTY_H 21 #define GNASH_PROPERTY_H 23 #include <boost/variant.hpp> 46 class NativeGetterSetter;
57 template<
typename Arg,
typename S>
58 struct GetSetVisitor : boost::static_visitor<typename S::result_type>
60 GetSetVisitor(
const Arg& arg) : _arg(arg) {}
61 template<
typename T>
typename S::result_type operator()(
T&
t)
const {
71 typedef void result_type;
72 template<
typename T,
typename Arg>
73 result_type operator()(
T&
t, Arg&
a)
const {
82 template<
typename T,
typename Arg>
83 result_type operator()(
T&
t, Arg&
a)
const {
91 struct SetUnderlying : boost::static_visitor<>
94 result_type operator()(
T& gs,
const as_value& val)
const {
95 gs.setUnderlying(val);
97 result_type operator()(NativeGetterSetter&,
const as_value&)
const {}
103 struct GetUnderlying : boost::static_visitor<as_value>
106 result_type operator()(
const T& gs)
const {
107 return gs.getUnderlying();
109 result_type operator()(
const NativeGetterSetter&)
const {
110 return result_type();
115 struct MarkReachable : boost::static_visitor<>
118 result_type operator()(
const T& gs)
const {
119 gs.markReachableResources();
128 _getset(UserDefinedGetterSetter(getter, setter))
134 _getset(NativeGetterSetter(getter, setter))
139 GetSetVisitor<const fn_call, Get>
s(fn);
140 return boost::apply_visitor(s, _getset);
145 GetSetVisitor<fn_call, Set>
s(fn);
146 boost::apply_visitor(s, _getset);
151 boost::apply_visitor(
157 return boost::apply_visitor(GetUnderlying(), _getset);
161 boost::apply_visitor(MarkReachable(), _getset);
167 class UserDefinedGetterSetter
176 _beingAccessed(
false)
186 const as_value& getUnderlying()
const {
return _underlyingValue; }
189 void setUnderlying(
const as_value&
v) { _underlyingValue =
v; }
201 class ScopedLock : boost::noncopyable
205 explicit ScopedLock(
const UserDefinedGetterSetter& na)
208 _obtainedLock(_a._beingAccessed ?
false :
true)
212 if (_obtainedLock) _a._beingAccessed =
true;
215 ~ScopedLock() {
if ( _obtainedLock) _a._beingAccessed =
false; }
223 bool obtainedLock()
const {
return _obtainedLock; }
227 const UserDefinedGetterSetter& _a;
235 mutable bool _beingAccessed;
239 class NativeGetterSetter
245 _getter(
get), _setter(
set) {}
265 boost::variant<UserDefinedGetterSetter, NativeGetterSetter> _getset;
280 struct SetReachable : boost::static_visitor<>
282 result_type operator()(
const as_value& val)
const {
296 _uri(
std::move(uri)),
297 _flags(
std::move(flags)),
306 _uri(
std::move(uri)),
307 _flags(
std::move(flags)),
308 _destructive(destroy)
313 bool destroy =
false)
316 _uri(
std::move(uri)),
317 _flags(
std::move(flags)),
318 _destructive(destroy)
382 void clearVisible(
int swfVersion) { _flags.clear_visible(swfVersion); }
391 return boost::apply_visitor(SetReachable(), _bound);
397 typedef boost::variant<as_value, GetterSetter> BoundType;
400 mutable BoundType _bound;
411 mutable bool _destructive;
429 #endif // GNASH_PROPERTY_H Definition: GnashKey.h:147
bool test() const
Definition: PropFlags.h:94
Holder for getter/setter functions.
Definition: Property.h:44
ActionScript value type.
Definition: as_value.h:94
Property(ObjectURI uri, const as_value &value, PropFlags flags)
Definition: Property.h:292
An abstract property.
Definition: Property.h:276
Definition: GnashKey.h:131
uri
Definition: test.py:12
GetterSetter(as_c_function_ptr getter, as_c_function_ptr setter)
Construct a native getter-setter.
Definition: Property.h:132
Flags defining the level of protection of a member.
Definition: PropFlags.h:28
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
void setReachable() const
Mark this property as being reachable (for the GC)
Definition: Property.h:390
as_value(* as_c_function_ptr)(const fn_call &fn)
Definition: Property.h:34
bool get_visible(int swfVersion) const
Get version-based visibility.
Definition: PropFlags.h:99
The base class for all ActionScript objects.
Definition: as_object.h:161
void setCache(const as_value &v)
Set the cache value (for user-defined getter-setters)
Definition: Property.h:150
as_value getCache() const
Get the cache value (for user-defined getter-setters)
Definition: Property.h:156
A URI for describing as_objects.
Definition: ObjectURI.h:44
bool isGetterSetter() const
Is this a getter/setter property?
Definition: Property.h:377
Definition: GnashKey.h:166
bool visible(const Property &prop, int version)
Is this member supposed to be visible by a VM of given version ?
Definition: Property.h:423
void markReachableResources() const
Definition: Property.h:160
Property(ObjectURI uri, as_c_function_ptr getter, as_c_function_ptr setter, PropFlags flags, bool destroy=false)
Definition: Property.h:311
bool readOnly(const Property &prop)
is this a read-only member ?
Definition: Property.h:417
Definition: GnashKey.h:132
#define DSOTEXPORT
Definition: dsodefs.h:63
const ObjectURI & uri() const
The name-namespace pair (ObjectURI) of this Property.
Definition: Property.h:385
const PropFlags & getFlags() const
accessor to the properties flags
Definition: Property.h:322
void setFlags(const PropFlags &flags) const
Set the flags of the property.
Definition: Property.h:325
Property(ObjectURI uri, as_function *getter, as_function *setter, PropFlags flags, bool destroy=false)
Definition: Property.h:301
void clearVisible(int swfVersion)
Clear visibility flags.
Definition: Property.h:382
Definition: GnashKey.h:165
Definition: GnashKey.h:95
Parameters/environment for builtin or user-defined functions callable from ActionScript.
Definition: fn_call.h:117
Protect from assigning a value.
Definition: PropFlags.h:42
void setReachable() const
Set any object value as reachable (for the GC)
Definition: as_value.cpp:691
ActionScript Function, either builtin or SWF-defined.
Definition: as_function.h:62
GetterSetter(as_function *getter, as_function *setter)
Construct a user-defined getter-setter.
Definition: Property.h:126