Swfdec Reference Manual | ||||
---|---|---|---|---|
#include <swfdec/swfdec.h> SwfdecAsContext; void swfdec_as_context_startup (SwfdecAsContext *context); void swfdec_as_context_abort (SwfdecAsContext *context, const char *reason); gboolean swfdec_as_context_is_aborted (SwfdecAsContext *context); const char* swfdec_as_context_get_string (SwfdecAsContext *context, const char *string); const char* swfdec_as_context_give_string (SwfdecAsContext *context, char *string); void swfdec_as_context_use_mem (SwfdecAsContext *context, gsize bytes); gboolean swfdec_as_context_try_use_mem (SwfdecAsContext *context, gsize bytes); void swfdec_as_context_unuse_mem (SwfdecAsContext *context, gsize bytes); void swfdec_as_context_gc (SwfdecAsContext *context); void swfdec_as_context_maybe_gc (SwfdecAsContext *context); void swfdec_as_context_throw (SwfdecAsContext *context, const SwfdecAsValue *value); gboolean swfdec_as_context_catch (SwfdecAsContext *context, SwfdecAsValue *value); void swfdec_as_context_get_time (SwfdecAsContext *context, GTimeVal *tv); SwfdecAsFrame* swfdec_as_context_get_frame (SwfdecAsContext *context); gboolean swfdec_as_context_is_constructing (SwfdecAsContext *context);
"aborted" gboolean : Read "debugger" SwfdecAsDebugger* : Read / Write / Construct Only "memory-until-gc" gulong : Read / Write / Construct "random-seed" guint : Write
A SwfdecAsContext provides the main execution environment for Actionscript execution. It provides the objects typically available in ECMAScript and manages script execution, garbage collection etc. SwfdecPlayer is a subclass of the context that implements Flash specific objects on top of it. However, it is possible to use the context for completely different functions where a sandboxed scripting environment is needed. An example is the Swfdec debugger.
typedef struct _SwfdecAsContext SwfdecAsContext;
This is the main object ued to hold the state of a script engine. All members are private and should not be accessed.
Subclassing this structure to get scripting support in your own appliation is encouraged.
void swfdec_as_context_startup (SwfdecAsContext *context);
Starts up the context. This function must be called before any Actionscript
is called on context
.
|
a SwfdecAsContext |
void swfdec_as_context_abort (SwfdecAsContext *context, const char *reason);
Aborts script execution in context
. Call this functon if the script engine
encountered a fatal error and cannot continue. A possible reason for this is
an out-of-memory condition.
|
a SwfdecAsContext |
|
a string describing why execution was aborted |
gboolean swfdec_as_context_is_aborted (SwfdecAsContext *context);
Determines if the given context is aborted. An aborted context is not able to execute any scripts. Aborting can happen if the script engine detects bad scripts that cause excessive memory usage, infinite loops or other problems. In that case the script engine aborts for safety reasons.
|
a SwfdecAsContext |
Returns : |
TRUE if the player is aborted, FALSE if it runs normally.
|
const char* swfdec_as_context_get_string (SwfdecAsContext *context, const char *string);
Gets the garbage-collected version of string
. You need to call this function
for every not garbage-collected string that you want to use in Swfdecs script
interpreter.
|
a SwfdecAsContext |
|
a sting that is not garbage-collected |
Returns : |
the garbage-collected version of string
|
const char* swfdec_as_context_give_string (SwfdecAsContext *context, char *string);
Takes ownership of string
and returns a refcounted version of the same
string. This function is the same as swfdec_as_context_get_string()
, but
takes ownership of string
.
|
a SwfdecAsContext |
|
string to make refcounted |
Returns : |
A refcounted string |
void swfdec_as_context_use_mem (SwfdecAsContext *context, gsize bytes);
Registers bytes
additional bytes as in use by the context
. This function
keeps track of the memory that script code consumes. If too much memory is
in use, this function may decide to stop the script engine with an out of
memory error.
|
a SwfdecAsContext |
|
number of bytes to use |
gboolean swfdec_as_context_try_use_mem (SwfdecAsContext *context, gsize bytes);
Tries to register bytes
additional bytes as in use by the context
. This
function keeps track of the memory that script code consumes. The scripting
engine won't be stopped, even if there wasn't enough memory left.
|
a SwfdecAsContext |
|
number of bytes to use |
Returns : |
TRUE if the memory could be allocated. FALSE on OOM.
|
void swfdec_as_context_unuse_mem (SwfdecAsContext *context, gsize bytes);
Releases a number of bytes previously allocated using
swfdec_as_context_use_mem()
. See that function for details.
|
a SwfdecAsContext |
|
number of bytes to release |
void swfdec_as_context_gc (SwfdecAsContext *context);
Calls the Swfdec Gargbage collector and reclaims any unused memory. You
should call this function or swfdec_as_context_maybe_gc()
regularly.
|
a SwfdecAsContext |
void swfdec_as_context_maybe_gc (SwfdecAsContext *context);
Calls the garbage collector if necessary. It's a good idea to call this
function regularly instead of swfdec_as_context_gc()
as it only does collect
garage as needed. For example, SwfdecPlayer calls this function after every
frame advancement.
|
a SwfdecAsContext |
void swfdec_as_context_throw (SwfdecAsContext *context, const SwfdecAsValue *value);
Throws a new exception in the context
using the given value
. This function
can only be called if the context
is not already throwing an exception.
|
a SwfdecAsContext |
|
a SwfdecAsValue to be thrown |
gboolean swfdec_as_context_catch (SwfdecAsContext *context, SwfdecAsValue *value);
Removes the currently thrown exception from context
and sets value
to the
thrown value
|
a SwfdecAsContext |
|
a SwfdecAsValue to be thrown |
Returns : |
TRUE if an exception was catched, FALSE otherwise
|
void swfdec_as_context_get_time (SwfdecAsContext *context, GTimeVal *tv);
This function queries the time to be used inside this context. By default,
this is the same as g_get_current_time()
, but it may be overwriten to allow
things such as slower or faster playback.
|
a SwfdecAsContext |
|
a GTimeVal to be set to the context's time |
SwfdecAsFrame* swfdec_as_context_get_frame (SwfdecAsContext *context);
This is a debugging function. It gets the topmost stack frame that is
currently executing. If no function is executing, NULL
is returned. You can
easily get a backtrace with code like this:
for (frame = swfdec_as_context_get_frame (context); frame != NULL; frame = swfdec_as_frame_get_next (frame)) { char *s = swfdec_as_object_get_debug (SWFDEC_AS_OBJECT (frame)); g_print ("%s\n", s); g_free (s); }
|
a SwfdecAsContext |
Returns : |
the currently executing frame or NULL if none
|
gboolean swfdec_as_context_is_constructing (SwfdecAsContext *context);
Determines if the contexxt is currently constructing. This information is used by various constructors to do different things when they are constructing and when they are not. The Boolean, Number and String functions for example setup the newly constructed objects when constructing but only cast the provided argument when being called.
|
a SwfdecAsConstruct |
Returns : |
TRUE if the currently executing frame is a constructor
|
"aborted"
property"aborted" gboolean : Read
set when the script engine aborts due to an error.
Default value: FALSE
"debugger"
property"debugger" SwfdecAsDebugger* : Read / Write / Construct Only
debugger used in this player.
"memory-until-gc"
property"memory-until-gc" gulong : Read / Write / Construct
amount of bytes that need to be allocated before garbage collection triggers.
"random-seed"
property"random-seed" guint : Write
seed used for calculating random numbers.
Default value: 0
"trace"
signalvoid user_function (SwfdecAsContext *context, gchar *text, gpointer user_data) : Run Last
Emits a debugging string while running. The effect of calling any swfdec
functions on the emitting context
is undefined.
|
the SwfdecAsContext affected |
|
the debugging string |
|
user data set when the signal handler was connected. |