Go to the documentation of this file.
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)
180 as_value
get(
const fn_call& fn)
const;
183 void set(
const fn_call& fn);
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;
232 as_function* _getter;
233 as_function* _setter;
234 as_value _underlyingValue;
235 mutable bool _beingAccessed;
239 class NativeGetterSetter
245 _getter(
get), _setter(
set) {}
248 as_value
get(
const fn_call& fn)
const {
253 void set(
const fn_call& fn) {
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)
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
static LogFile & getDefaultInstance()
Definition: log.cpp:77
void setFlags(const PropFlags &flags) const
Set the flags of the property.
Definition: Property.h:325
Abstract base class for FS handlers.
Definition: HostInterface.h:200
as_value getCache() const
Get the cache value (for user-defined getter-setters)
Definition: Property.h:156
VGPath path
Definition: testr_gtk.cpp:84
boost::variant< HostMessage, CustomMessage > Message
Definition: HostInterface.h:213
DSOEXPORT Renderer_agg_base * create_Renderer_agg(const char *pixelformat)
Create a render handler.
Definition: Renderer_agg.cpp:2048
static DSOEXPORT boost::intrusive_ptr< movie_definition > makeMovie(const URL &url, const RunResources &runResources, const char *real_url=nullptr, bool startLoaderThread=true, const std::string *postdata=nullptr)
Create a gnash::movie_definition from the given URL.
Definition: MovieFactory.cpp:109
std::string name
Definition: LocalConnection_as.cpp:149
void setCache(const as_value &v)
Set internal cached value of this property.
Definition: Property.cpp:172
bool visible(const Property &prop, int version)
Is this member supposed to be visible by a VM of given version ?
Definition: Property.h:423
bool removeLog()
Remove the log file.
Definition: log.cpp:365
void setTagLoaders(std::shared_ptr< const SWF::TagLoadersTable > loaders)
Set the loader functions for SWF parsing.
Definition: RunResources.h:121
The base class for all ActionScript objects.
Definition: as_object.h:162
Top-level gnash exception.
Definition: GnashException.h:31
@ T
Definition: GnashKey.h:132
void setStreamProvider(std::shared_ptr< StreamProvider > sp)
Set the StreamProvider.
Definition: RunResources.h:66
virtual void fetchSamples(std::int16_t *to, unsigned int nSamples)
Fetch mixed samples.
Definition: sound_handler.cpp:646
void set(const fn_call &fn)
Invoke the setter.
Definition: Property.h:144
void log_debug(StringType msg, Args... args)
Definition: log.h:301
void setSoundHandler(std::shared_ptr< sound::sound_handler > s)
Set the sound::sound_handler.
Definition: RunResources.h:88
#define _(String)
Definition: log.h:44
void setLogFilename(const std::string &fname)
Set log filename.
Definition: log.cpp:274
A manually advanced clock.
Definition: ManualClock.h:31
void resetLastAdvanceTimer()
Definition: processor.cpp:130
Provides information about timeline context.
Definition: as_environment.h:51
Holder for getter/setter functions.
Definition: Property.h:45
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
void clear_visible(int swfVersion)
Definition: PropFlags.h:108
Abstract base class for hosting app handler.
Definition: HostInterface.h:208
int getopt(int, char *const *, const char *)
#define PACKAGE
Definition: gnashconfig.h:556
@ m
Definition: GnashKey.h:159
FsCommandExecutor execFsCommand
Definition: processor.cpp:220
@ s
Definition: GnashKey.h:165
@ n
Definition: GnashKey.h:160
Property(ObjectURI uri, const as_value &value, PropFlags flags)
Definition: Property.h:292
@ SCREEN_COLOR
Definition: HostInterface.h:160
VM & getVM(const as_environment &env)
Definition: as_environment.h:222
@ SET_CLIPBOARD
Definition: HostInterface.h:130
double secondsSinceLastAdvance()
Definition: processor.cpp:137
void log_error(StringType msg, Args... args)
Definition: log.h:283
GetterSetter(as_function *getter, as_function *setter)
Construct a user-defined getter-setter.
Definition: Property.h:126
void setRenderer(std::shared_ptr< Renderer > r)
Definition: RunResources.h:108
static DSOEXPORT void clear()
Clear the MovieFactory resources.
Definition: MovieFactory.cpp:157
#define bindtextdomain(Domainname, Dirname)
Definition: gettext.h:66
Parameters/environment for builtin or user-defined functions callable from ActionScript.
Definition: fn_call.h:118
@ t
Definition: GnashKey.h:166
DSOEXPORT std::uint64_t getTicks()
Wall clock timer, returns current POSIX time in milliseconds.
Definition: ClockTime.cpp:61
@ r
Definition: GnashKey.h:164
bool isGetterSetter() const
Is this a getter/setter property?
Definition: Property.h:377
#define VERBOSE_ACTION
Definition: log.h:359
bool get_visible(int swfVersion) const
Get version-based visibility.
Definition: PropFlags.h:99
#define textdomain(Domainname)
Definition: gettext.h:65
@ a
Definition: GnashKey.h:147
const boost::any & arg() const
Definition: HostInterface.h:191
KnownEvent event() const
Definition: HostInterface.h:190
double lastAdvanceTimer
Definition: processor.cpp:127
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:29
void setActionDump(int x)
Definition: log.h:135
void setReachable() const
Mark this property as being reachable (for the GC)
Definition: Property.h:390
A class to contain transferable arguments for a fn_call.
Definition: fn_call.h:57
T * get(as_object *o)
Extract the DisplayObject attached to an object.
Definition: as_object.h:842
int main(int argc, char *argv[])
Definition: processor.cpp:223
A case-insensitive string equality operator.
Definition: StringPredicates.h:42
An abstract property.
Definition: Property.h:277
Null sound_handler, for testing or manual fetching of samples.
Definition: NullSoundHandler.h:37
std::vector< std::string > infiles
Definition: gnash.cpp:58
DSOTEXPORT as_value getValue(const as_object &this_ptr) const
Get value of this property.
Definition: Property.cpp:98
void advance(unsigned long amount)
Advance the clock by the given amount of milliseconds.
Definition: ManualClock.h:53
@ PLAYER_TYPE
Definition: HostInterface.h:154
@ _1
Definition: GnashKey.h:95
void setCache(const as_value &v)
Set the cache value (for user-defined getter-setters)
Definition: Property.h:150
void markReachableResources() const
Definition: Property.h:160
Class to group together per-run and external resources for Gnash.
Definition: RunResources.h:54
ActionScript value type.
Definition: as_value.h:95
as_value(* as_c_function_ptr)(const fn_call &fn)
Definition: Property.h:34
virtual void reset()
Discard all sound inputs (slots and aux streamers) and clear scheduling.
Definition: sound_handler.cpp:812
@ PIXEL_ASPECT_RATIO
Definition: HostInterface.h:148
@ S
Definition: GnashKey.h:131
const ObjectURI & uri() const
The name-namespace pair (ObjectURI) of this Property.
Definition: Property.h:385
void setReachable() const
Set any object value as reachable (for the GC)
Definition: as_value.cpp:691
void gnashSleep(time_t useconds)
Sleep compatibly for the specified number of microseconds.
Definition: GnashSleep.h:35
Property(ObjectURI uri, as_function *getter, as_function *setter, PropFlags flags, bool destroy=false)
Definition: Property.h:301
@ PLAYSTATE_PLAY
Definition: MovieClip.h:99
Property(ObjectURI uri, as_c_function_ptr getter, as_c_function_ptr setter, PropFlags flags, bool destroy=false)
Definition: Property.h:311
void clearVisible(int swfVersion)
Clear visibility flags.
Definition: Property.h:382
as_value get(fn_call &fn) const
Invoke the getter.
Definition: Property.h:138
Sound mixer.
Definition: sound_handler.h:88
std::string url
Definition: gnash.cpp:59
LogFile & dbglogfile
Definition: fileio.cpp:76
@ SCREEN_RESOLUTION
Definition: HostInterface.h:136
static RcInitFile & getDefaultInstance()
Return the default instance of RC file.
Definition: rc.cpp:61
This class represents the 'Stage' and top-level movie.
Definition: movie_root.h:151
#define DSOTEXPORT
Definition: dsodefs.h:63
Built-in forms of communication with the host application.
Definition: HostInterface.h:86
static GnashFactory & instance()
Get the GnashFactory singleton.
Definition: GnashFactory.h:78
@ c
Definition: GnashKey.h:149
as_value getCache() const
Get internal cached value of this property.
Definition: Property.cpp:127
EventCallback eventCallback
Definition: processor.cpp:219
@ SHOW_MOUSE
Definition: HostInterface.h:98
const PropFlags & getFlags() const
accessor to the properties flags
Definition: Property.h:322
#define VERSION
Definition: gnashconfig.h:731
const char * GPROC_VERSION
Definition: processor.cpp:108
sound::sound_handler * soundHandler() const
Get a pointer to a sound::sound_handler set by a hosting application.
Definition: RunResources.h:96
void setNetwork(int x)
Definition: log.h:139
Uniform Resource Locator.
Definition: URL.h:35
IOChannel * make_stream(int fd, const char *cachefilename)
Returns a read-only IOChannel that fetches data from an file descriptor open for read.
Definition: noseek_fd_adapter.cpp:364
@ readOnly
Protect from assigning a value.
Definition: PropFlags.h:42
@ u
Definition: GnashKey.h:167
A URI for describing as_objects.
Definition: ObjectURI.h:45
void setMediaHandler(std::shared_ptr< media::MediaHandler > s)
Definition: RunResources.h:100
unsigned long elapsed() const
Return number of milliseconds elapsed since start.
Definition: ManualClock.h:41
#define VERBOSE_PARSE
Definition: log.h:354
bool test() const
Definition: PropFlags.h:94
void setVerbosity()
Definition: log.h:123
void setWriteDisk(bool b)
Set whether to write logs to file.
Definition: log.cpp:281
std::map< std::string, std::string > MovieVariables
Definition: MovieClip.h:93
void addDefaultLoaders(TagLoadersTable &table)
Add the default parsing functions for SWF files to a TagLoadersTable.
Definition: DefaultTagLoaders.cpp:107
@ SCREEN_DPI
Definition: HostInterface.h:142
@ e
Definition: GnashKey.h:151
@ QUERY
Definition: HostInterface.h:172
void setParserDump(int x)
Definition: log.h:151
bool readOnly(const Property &prop)
is this a read-only member ?
Definition: Property.h:417
bool setValue(as_object &this_ptr, const as_value &value) const
Set value of this property.
Definition: Property.cpp:133
KnownEvent
The messages that a hosting application should handle.
Definition: HostInterface.h:92
ActionScript Function, either builtin or SWF-defined.
Definition: as_function.h:63