Class IJSScriptRunner
Defined in File IJSScriptRunner.h
Inheritance Relationships
Derived Type
public csp::systems::ScriptSystem
(Class ScriptSystem)
Class Documentation
-
class IJSScriptRunner
Subclassed by csp::systems::ScriptSystem
Public Functions
-
virtual ~IJSScriptRunner() = default
Virtual destructor.
-
inline virtual bool RunScript(int64_t ContextId, const String &ScriptText)
Attempts to execute a script in a given context.
- Parameters
ContextId – int64_t : The Id of the CSP script context in which to run the script. If the provided context does not exist, the script run will fail.
ScriptText – String& : The text of the script to be executed by the javascript engine.
- Returns
Whether the script was successfully run.
-
inline virtual void RegisterScriptBinding(IScriptBinding *ScriptBinding)
Register a binding object with the script runner.
The script runner should store this for use.
- Parameters
ScriptBinding – IScriptBinding* : Object capable of binding a script. The binding is eventually used to call back into IJSScriptRunner.
-
inline virtual void UnregisterScriptBinding(IScriptBinding *ScriptBinding)
Unregister a binding object with the script runner.
- Parameters
ScriptBinding – IScriptBinding : Object capable of binding a script.
- Pre
ScriptBinding has been registered via RegisterScriptBinding
-
inline virtual bool BindContext(int64_t ContextId)
Perform the script binding on any bindings registered via RegisterScriptBinding.
- Parameters
ContextId – int64_t : The Id of the CSP script context in which to run the script. If the provided context does not exist, the script bind will fail.
- Returns
Whether the context was successfully bound.
-
inline virtual bool ResetContext(int64_t ContextId)
Reset the script context.
This will likely shutdown and re-initialize any modules in the context.
- Parameters
ContextId – int64_t : The Id of the CSP script context in which to run the script. If the provided context does not exist, the script reset will fail.
- Returns
Whether the context was successfully reset.
-
inline virtual void *GetContext(int64_t ContextId)
Get the script context object.
- Parameters
ContextId – int64_t : The Id of the CSP script context in which to run the script.
- Returns
The script context object. This specific type of this is implementation defined. However, if using CSP’s ScriptSystem at time of writing, it will be a csp::systems::ScriptContext*, which you should cast to. Returns nullptr if the provided context does not exist.
-
inline virtual void *GetModule(int64_t ContextId, const String &ModuleName)
Get a script module object within a context.
- Parameters
ContextId – int64_t : The Id of the CSP script context in which to run the script.
ModuleName – String& : Name of the module to return.
- Returns
The script module. This specific type of this is implementation defined. However, if using CSP’s ScriptSystem at time of writing, it will be a csp::systems::ScriptModule*, which you should cast to. Returns nullptr if the specified module does not exist in the context.
-
inline virtual bool CreateContext(int64_t ContextId)
Create a new context with specified ID.
- Parameters
ContextId – int64_t : The Id of the context to create, must be unique to other contexts.
- Returns
Whether the context was created successfully.
-
inline virtual bool DestroyContext(int64_t ContextId)
Destroy a pre-existing context with specified ID.
- Parameters
ContextId – int64_t : The Id of the context to destroy.
- Returns
Whether the context was destroyed successfully.
Protected Functions
-
IJSScriptRunner() = default
-
virtual ~IJSScriptRunner() = default