cohtml::ScriptCompiler
#include <Library.h>
Public Types
Name | |
---|---|
enum | ScriptType { ST_Classic, ST_Module, ST_Unknown} The enumeration tells the ScriptCompiler how to compile the provided source. |
Public Functions
Name | |
---|---|
virtual DataBuffer * | Compile(DataBuffer * utf8Source, ScriptType scriptType =ST_Unknown) =0 Compiles a script file synchronously. |
virtual void | Destroy() =0 Destroys the ScriptCompiler and frees memory. |
Protected Functions
Name | |
---|---|
virtual | ~ScriptCompiler() |
Public Types Documentation
enum ScriptType
Enumerator | Value | Description |
---|---|---|
ST_Classic | ||
ST_Module | Try to compile the provided source as a classic script. | |
ST_Unknown | Try to compile the provided source as a module. |
The enumeration tells the ScriptCompiler how to compile the provided source.
Public Functions Documentation
function Compile
virtual DataBuffer * Compile(
DataBuffer * utf8Source,
ScriptType scriptType =ST_Unknown
) =0
Compiles a script file synchronously.
Parameters:
- utf8Source a data buffer, containing an utf8 encoded script source
- scriptType specify if the provided source is classic script, module or unknown
Return: A data buffer, containing the compiled data.
Note:
- Can be used on any thread, should not be used on multiple threads simultaneously.
- Scripts can be precompiled on Windows then later used on other platforms where Cohtml works with V8’s pointer compression feature enabled. Currently, those are only Microsoft Xbox consoles.
- If ST_Unknown is passed as scriptType, Cohtml will try to compile it either as a classic script or a module if that fails. V8 might print an error in such case even when the module is compiled successfully, for example if the source contains the “import” keyword because Cohtml will try to compile it as a classic script first.
function Destroy
virtual void Destroy() =0
Destroys the ScriptCompiler and frees memory.
Protected Functions Documentation
function ~ScriptCompiler
virtual ~ScriptCompiler()