Bindings for reflect to Mozilla’s Spidermonkey (v1.7.0).
This provides a basic ECMA script runtime with the following runtime support
print() | A basic print method. |
GC() | Run the garbage collector. |
Console() | Runs a very basic Javascript console. |
Native | An object which provides access to the reflected types by namespace. |
JavaScript.h | Bindings for reflect to Mozilla’s Spidermonkey (v1.7.0). |
JavaScriptRuntime | Wraps a JSRuntime, a JSRuntime object represents a single JavaScript object space which can hold multiple contexts. |
Functions | |
SharedRuntime | |
GetRuntime | |
JavaScriptContext | Represents a javascript context |
Functions | |
JavaScriptContext | |
GC | Runs the garbage collector. |
RegisterFunction | Registers a function in this context. |
RegisterFunction (template) | Like RegisterFunction, but takes a regular C function pointer, creates the function::Function object wrapper and marks it for deletion. |
Eval (toss result) | |
Eval (typed result) | |
Eval | Assigns the result of Eval into the variant result. |
IncRef | Increments the reference count on a pointer that the java runtime knows about. |
DecRef | |
ThrowError | Throws an error from a function to the JavaScript runtime. |
GetJSContext | Returns the native context pointer. |
CallContext | Retrieves the current context from within a javascript call. |
CallArgumentCount | Retrieves the number of arguments actually passed to the native function. |
CallArgument | Retrieves the argument index passed to the native function through a Variant. |
CallArgumentText | Retrieves the argument index as text (converted by javascript). |
CallArgumentValue | Retrieves the argument index as whatever (converted by Variant). |
CallReturn | Sets the return value of a void native function by variant. |
CallReturnValue | Sets the return value of a void native function by value. |
class ReflectExport( reflect_js ) JavaScriptRuntime : public utility::Shared<JavaScriptRuntime>
Wraps a JSRuntime, a JSRuntime object represents a single JavaScript object space which can hold multiple contexts. JavaScript objects in different JavaScriptContexts but within the same runtime may be shared.
A SharedRuntime is automatically used by default, client code only needs to instantate a runtime object if they want to have completely seperate runtimes.
class ReflectExport( reflect_js ) JavaScriptContext
Represents a javascript context
Functions | |
JavaScriptContext | |
GC | Runs the garbage collector. |
RegisterFunction | Registers a function in this context. |
RegisterFunction (template) | Like RegisterFunction, but takes a regular C function pointer, creates the function::Function object wrapper and marks it for deletion. |
Eval (toss result) | |
Eval (typed result) | |
Eval | Assigns the result of Eval into the variant result. |
IncRef | Increments the reference count on a pointer that the java runtime knows about. |
DecRef | |
ThrowError | Throws an error from a function to the JavaScript runtime. |
GetJSContext | Returns the native context pointer. |
CallContext | Retrieves the current context from within a javascript call. |
CallArgumentCount | Retrieves the number of arguments actually passed to the native function. |
CallArgument | Retrieves the argument index passed to the native function through a Variant. |
CallArgumentText | Retrieves the argument index as text (converted by javascript). |
CallArgumentValue | Retrieves the argument index as whatever (converted by Variant). |
CallReturn | Sets the return value of a void native function by variant. |
CallReturnValue | Sets the return value of a void native function by value. |
bool RegisterFunction( string:: ConstString name, const function:: Function * function, bool take_ownership = false )
Registers a function in this context.
name | the javascript name of this function |
function | the function to use |
take_ownership | if true, delete the function when destructing this context. |
template<typename FunctionType> bool RegisterFunction( string:: ConstString name, FunctionType function )
Like RegisterFunction, but takes a regular C function pointer, creates the function::Function object wrapper and marks it for deletion.
template<typename T> void IncRef( T * object ) const
Increments the reference count on a pointer that the java runtime knows about. When java finalizes the assoicated object, the pointer will not be deleted if it has a positive reference count. The default reference count on an object is one, functions that allocate new objects for javascript should DecRef the reference count. Note that an IncRef-ed object will never be deleted by the object system if it never makes it to the java runtime.
static bool CallArgument( int index, Variant & variant )
Retrieves the argument index passed to the native function through a Variant.
template<typename T> static bool CallArgumentValue( int index, T & value )
Retrieves the argument index as whatever (converted by Variant).
Wraps a JSRuntime, a JSRuntime object represents a single JavaScript object space which can hold multiple contexts.
class ReflectExport( reflect_js ) JavaScriptRuntime : public utility::Shared<JavaScriptRuntime>
static JavaScriptRuntime SharedRuntime()
JSRuntime *GetRuntime() const
Represents a javascript context
class ReflectExport( reflect_js ) JavaScriptContext
JavaScriptContext( const JavaScriptRuntime & = JavaScriptRuntime::SharedRuntime() )
Runs the garbage collector.
void GC() const
Registers a function in this context.
bool RegisterFunction( string:: ConstString name, const function:: Function * function, bool take_ownership = false )
Like RegisterFunction, but takes a regular C function pointer, creates the function::Function object wrapper and marks it for deletion.
template<typename FunctionType> bool RegisterFunction( string:: ConstString name, FunctionType function )
bool Eval( string:: Fragment script ) const
template<typename T> bool Eval( string:: Fragment script, T & result ) const
Assigns the result of Eval into the variant result.
bool Eval( string:: Fragment script, Variant & result ) const
Increments the reference count on a pointer that the java runtime knows about.
template<typename T> void IncRef( T * object ) const
template<typename T> void DecRef( T * object ) const
Throws an error from a function to the JavaScript runtime.
void ThrowError( const char * format, ... ) const
Returns the native context pointer.
JSContext *GetJSContext() const
Retrieves the current context from within a javascript call.
static const JavaScriptContext *CallContext()
Retrieves the number of arguments actually passed to the native function.
static int CallArgumentCount()
Retrieves the argument index passed to the native function through a Variant.
static bool CallArgument( int index, Variant & variant )
Variants represent objects of any reflected type.
class ReflectExport( reflect ) Variant
Retrieves the argument index as text (converted by javascript).
static const char *CallArgumentText( int index )
Retrieves the argument index as whatever (converted by Variant).
template<typename T> static bool CallArgumentValue( int index, T & value )
Sets the return value of a void native function by variant.
static bool CallReturn( Variant & value )
Sets the return value of a void native function by value.
template<typename T> static bool CallReturnValue( const T & value )