Public Member Functions | |
Miscellaneous | |
virtual asIScriptEngine * | GetEngine ()=0 |
Returns a pointer to the engine. | |
virtual void | SetName (const char *name)=0 |
Sets the name of the module. | |
virtual const char * | GetName ()=0 |
Gets the name of the module. | |
Compilation | |
virtual int | AddScriptSection (const char *name, const char *code, size_t codeLength=0, int lineOffset=0)=0 |
Add a script section for the next build. | |
virtual int | Build ()=0 |
Build the previously added script sections. | |
virtual int | CompileFunction (const char *sectionName, const char *code, int lineOffset, asDWORD compileFlags, asIScriptFunction **outFunc)=0 |
Compile a single function. | |
virtual int | CompileGlobalVar (const char *sectionName, const char *code, int lineOffset)=0 |
Compile a single global variable and add it to the scope of the module. | |
Functions | |
virtual int | GetFunctionCount ()=0 |
Returns the number of global functions in the module. | |
virtual int | GetFunctionIdByIndex (int index)=0 |
Returns the function id by index. | |
virtual int | GetFunctionIdByName (const char *name)=0 |
Returns the function id by name. | |
virtual int | GetFunctionIdByDecl (const char *decl)=0 |
Returns the function id by declaration. | |
virtual asIScriptFunction * | GetFunctionDescriptorByIndex (int index)=0 |
Returns the function descriptor for the script function. | |
virtual asIScriptFunction * | GetFunctionDescriptorById (int funcId)=0 |
Returns the function descriptor for the script function. | |
virtual int | RemoveFunction (int funcId)=0 |
Remove a single function from the scope of the module. | |
Global variables | |
virtual int | ResetGlobalVars ()=0 |
Reset the global variables of the module. | |
virtual int | GetGlobalVarCount ()=0 |
Returns the number of global variables in the module. | |
virtual int | GetGlobalVarIndexByName (const char *name)=0 |
Returns the global variable index by name. | |
virtual int | GetGlobalVarIndexByDecl (const char *decl)=0 |
Returns the global variable index by declaration. | |
virtual const char * | GetGlobalVarDeclaration (int index)=0 |
Returns the global variable declaration. | |
virtual const char * | GetGlobalVarName (int index)=0 |
Returns the global variable name. | |
virtual int | GetGlobalVarTypeId (int index, bool *isConst=0)=0 |
Returns the type id for the global variable. | |
virtual void * | GetAddressOfGlobalVar (int index)=0 |
Returns the pointer to the global variable. | |
virtual int | RemoveGlobalVar (int index)=0 |
Remove the global variable from the scope of the module. | |
Type identification | |
virtual int | GetObjectTypeCount ()=0 |
Returns the number of object types. | |
virtual asIObjectType * | GetObjectTypeByIndex (asUINT index)=0 |
Returns the object type interface by index. | |
virtual int | GetTypeIdByDecl (const char *decl)=0 |
Returns a type id by declaration. | |
Enums | |
virtual int | GetEnumCount ()=0 |
Returns the number of enum types declared in the module. | |
virtual const char * | GetEnumByIndex (asUINT index, int *enumTypeId)=0 |
Returns the enum type. | |
virtual int | GetEnumValueCount (int enumTypeId)=0 |
Returns the number of values defined for the enum type. | |
virtual const char * | GetEnumValueByIndex (int enumTypeId, asUINT index, int *outValue)=0 |
Returns the name and value of the enum value. | |
Typedefs | |
virtual int | GetTypedefCount ()=0 |
Returns the number of typedefs in the module. | |
virtual const char * | GetTypedefByIndex (asUINT index, int *typeId)=0 |
Returns the typedef. | |
Dynamic binding between modules | |
virtual int | GetImportedFunctionCount ()=0 |
Returns the number of functions declared for import. | |
virtual int | GetImportedFunctionIndexByDecl (const char *decl)=0 |
Returns the imported function index by declaration. | |
virtual const char * | GetImportedFunctionDeclaration (int importIndex)=0 |
Returns the imported function declaration. | |
virtual const char * | GetImportedFunctionSourceModule (int importIndex)=0 |
Returns the declared imported function source module. | |
virtual int | BindImportedFunction (int importIndex, int funcId)=0 |
Binds an imported function to the function from another module. | |
virtual int | UnbindImportedFunction (int importIndex)=0 |
Unbinds an imported function. | |
virtual int | BindAllImportedFunctions ()=0 |
Binds all imported functions in a module, by searching their equivalents in the declared source modules. | |
virtual int | UnbindAllImportedFunctions ()=0 |
Unbinds all imported functions. | |
Bytecode saving and loading | |
virtual int | SaveByteCode (asIBinaryStream *out)=0 |
Save compiled bytecode to a binary stream. | |
virtual int | LoadByteCode (asIBinaryStream *in)=0 |
Load pre-compiled bytecode from a binary stream. |
virtual int asIScriptModule::AddScriptSection | ( | const char * | name, | |
const char * | code, | |||
size_t | codeLength = 0 , |
|||
int | lineOffset = 0 | |||
) | [pure virtual] |
[in] | name | The name of the script section |
[in] | code | The script code buffer |
[in] | codeLength | The length of the script code |
[in] | lineOffset | An offset that will be added to compiler message line numbers |
asMODULE_IS_IN_USE | The module is currently in use. |
The code added is copied by the engine, so there is no need to keep the original buffer after the call. Note that this can be changed by setting the engine property asEP_COPY_SCRIPT_SECTIONS with asIScriptEngine::SetEngineProperty.
virtual int asIScriptModule::BindAllImportedFunctions | ( | ) | [pure virtual] |
asERROR | An error occurred. | |
asCANT_BIND_ALL_FUNCTIONS | Not all functions where bound. |
virtual int asIScriptModule::BindImportedFunction | ( | int | importIndex, | |
int | funcId | |||
) | [pure virtual] |
[in] | importIndex | The index of the imported function. |
[in] | funcId | The function id of the function that will be bound to the imported function. |
asNO_FUNCTION | importIndex or fundId is incorrect. | |
asINVALID_INTERFACE | The signature of function doesn't match the import statement. |
virtual int asIScriptModule::Build | ( | ) | [pure virtual] |
asINVALID_CONFIGURATION | The engine configuration is invalid. | |
asERROR | The script failed to build. | |
asBUILD_IN_PROGRESS | Another thread is currently building. |
Compiler messages are sent to the message callback function set with asIScriptEngine::SetMessageCallback. If there are no errors or warnings, no messages will be sent to the callback function.
Any global variables found in the script will be initialized by the compiler if the engine property asEP_INIT_GLOBAL_VARS_AFTER_BUILD is set.
virtual int asIScriptModule::CompileFunction | ( | const char * | sectionName, | |
const char * | code, | |||
int | lineOffset, | |||
asDWORD | compileFlags, | |||
asIScriptFunction ** | outFunc | |||
) | [pure virtual] |
[in] | sectionName | The name of the script section |
[in] | code | The script code buffer |
[in] | lineOffset | An offset that will be added to compiler message line numbers |
[in] | compileFlags | One of asECompileFlags values |
[out] | outFunc | Optional parameter to receive the compiled function descriptor |
asINVALID_ARG | One or more arguments have invalid values. | |
asINVALID_CONFIGURATION | The engine configuration is invalid. | |
asBUILD_IN_PROGRESS | Another build is in progress. | |
asERROR | The compilation failed. |
If the output function parameter is set, remember to release the function object when you're done with it.
virtual int asIScriptModule::CompileGlobalVar | ( | const char * | sectionName, | |
const char * | code, | |||
int | lineOffset | |||
) | [pure virtual] |
[in] | sectionName | The name of the script section |
[in] | code | The script code buffer |
[in] | lineOffset | An offset that will be added to compiler message line numbers |
asINVALID_ARG | One or more arguments have invalid values. | |
asINVALID_CONFIGURATION | The engine configuration is invalid. | |
asBUILD_IN_PROGRESS | Another build is in progress. | |
asERROR | The compilation failed. |
The script code may contain an initialization expression, which will be executed by the compiler if the engine property asEP_INIT_GLOBAL_VARS_AFTER_BUILD is set.
virtual void* asIScriptModule::GetAddressOfGlobalVar | ( | int | index | ) | [pure virtual] |
[in] | index | The index of the global variable. |
virtual asIScriptEngine* asIScriptModule::GetEngine | ( | ) | [pure virtual] |
virtual const char* asIScriptModule::GetEnumByIndex | ( | asUINT | index, | |
int * | enumTypeId | |||
) | [pure virtual] |
[in] | index | The index of the enum type. |
[out] | enumTypeId | Receives the type id of the enum type. |
virtual int asIScriptModule::GetEnumCount | ( | ) | [pure virtual] |
virtual const char* asIScriptModule::GetEnumValueByIndex | ( | int | enumTypeId, | |
asUINT | index, | |||
int * | outValue | |||
) | [pure virtual] |
[in] | enumTypeId | The type id of the enum type. |
[in] | index | The index of the enum value. |
[out] | outValue | Receives the numeric value. |
virtual int asIScriptModule::GetEnumValueCount | ( | int | enumTypeId | ) | [pure virtual] |
[in] | enumTypeId | The type id of the enum type. |
asINVALID_ARG | enumTypeId is not an enum type. |
virtual int asIScriptModule::GetFunctionCount | ( | ) | [pure virtual] |
asERROR | The module was not compiled successfully. |
virtual asIScriptFunction* asIScriptModule::GetFunctionDescriptorById | ( | int | funcId | ) | [pure virtual] |
[in] | funcId | The id of the function or method. |
virtual asIScriptFunction* asIScriptModule::GetFunctionDescriptorByIndex | ( | int | index | ) | [pure virtual] |
[in] | index | The index of the function. |
virtual int asIScriptModule::GetFunctionIdByDecl | ( | const char * | decl | ) | [pure virtual] |
[in] | decl | The function signature. |
asERROR | The module was not compiled successfully. | |
asINVALID_DECLARATION | The decl is invalid. | |
asMULTIPLE_FUNCTIONS | Found multiple matching functions. | |
asNO_FUNCTION | Didn't find any matching functions. |
The method will find the script function with the exact same declaration.
virtual int asIScriptModule::GetFunctionIdByIndex | ( | int | index | ) | [pure virtual] |
[in] | index | The index of the function. |
asNO_FUNCTION | There is no function with that index. |
virtual int asIScriptModule::GetFunctionIdByName | ( | const char * | name | ) | [pure virtual] |
[in] | name | The name of the function. |
asERROR | The module was not compiled successfully. | |
asMULTIPLE_FUNCTIONS | Found multiple matching functions. | |
asNO_FUNCTION | Didn't find any matching functions. |
virtual int asIScriptModule::GetGlobalVarCount | ( | ) | [pure virtual] |
asERROR | The module was not compiled successfully. | |
asINIT_GLOBAL_VARS_FAILED | The initialization of the global variables failed. |
virtual const char* asIScriptModule::GetGlobalVarDeclaration | ( | int | index | ) | [pure virtual] |
[in] | index | The index of the global variable. |
virtual int asIScriptModule::GetGlobalVarIndexByDecl | ( | const char * | decl | ) | [pure virtual] |
[in] | decl | The global variable declaration. |
asERROR | The module was not built successfully. | |
asNO_GLOBAL_VAR | The matching global variable was found. |
The method will find the script variable with the exact same declaration.
virtual int asIScriptModule::GetGlobalVarIndexByName | ( | const char * | name | ) | [pure virtual] |
[in] | name | The name of the global variable. |
asERROR | The module was not built successfully. | |
asNO_GLOBAL_VAR | The matching global variable was found. |
virtual const char* asIScriptModule::GetGlobalVarName | ( | int | index | ) | [pure virtual] |
[in] | index | The index of the global variable. |
virtual int asIScriptModule::GetGlobalVarTypeId | ( | int | index, | |
bool * | isConst = 0 | |||
) | [pure virtual] |
[in] | index | The index of the global variable. |
[out] | isConst | Receives the constness indicator of the variable. |
asINVALID_ARG | The index is out of range. |
virtual int asIScriptModule::GetImportedFunctionCount | ( | ) | [pure virtual] |
asERROR | The module was not built successfully. |
virtual const char* asIScriptModule::GetImportedFunctionDeclaration | ( | int | importIndex | ) | [pure virtual] |
[in] | importIndex | The index of the imported function. |
virtual int asIScriptModule::GetImportedFunctionIndexByDecl | ( | const char * | decl | ) | [pure virtual] |
[in] | decl | The function declaration of the imported function. |
asERROR | The module was not built successfully. | |
asMULTIPLE_FUNCTIONS | Found multiple matching functions. | |
asNO_FUNCTION | Didn't find any matching function. |
virtual const char* asIScriptModule::GetImportedFunctionSourceModule | ( | int | importIndex | ) | [pure virtual] |
[in] | importIndex | The index of the imported function. |
virtual const char* asIScriptModule::GetName | ( | ) | [pure virtual] |
virtual asIObjectType* asIScriptModule::GetObjectTypeByIndex | ( | asUINT | index | ) | [pure virtual] |
[in] | index | The index of the type. |
virtual int asIScriptModule::GetObjectTypeCount | ( | ) | [pure virtual] |
virtual const char* asIScriptModule::GetTypedefByIndex | ( | asUINT | index, | |
int * | typeId | |||
) | [pure virtual] |
[in] | index | The index of the typedef. |
[out] | typeId | The type that the typedef aliases. |
virtual int asIScriptModule::GetTypedefCount | ( | ) | [pure virtual] |
virtual int asIScriptModule::GetTypeIdByDecl | ( | const char * | decl | ) | [pure virtual] |
[in] | decl | The declaration of the type. |
asINVALID_TYPE | decl is not a valid type. |
The type id is based on a sequence number and depends on the order in which the type ids are queried, thus is not guaranteed to always be the same for each execution of the application. The asETypeIdFlags can be used to obtain some information about the type directly from the id.
A base type yields the same type id whether the declaration is const or not, however if the const is for the subtype then the type id is different, e.g. string@ isn't the same as const string@ but string is the same as const string.
virtual int asIScriptModule::LoadByteCode | ( | asIBinaryStream * | in | ) | [pure virtual] |
[in] | in | The input stream. |
asINVALID_ARG | The stream object wasn't specified. | |
asBUILD_IN_PROGRESS | Another thread is currently building. |
It is expected that the application performs the necessary validations to make sure the pre-compiled byte code is from a trusted source. The application should also make sure the pre-compiled byte code is compatible with the current engine configuration, i.e. that the engine has been configured in the same way as when the byte code was first compiled.
virtual int asIScriptModule::RemoveFunction | ( | int | funcId | ) | [pure virtual] |
[in] | funcId | The id of the function to remove. |
asNO_FUNCTION | The function is not part of the scope. |
virtual int asIScriptModule::RemoveGlobalVar | ( | int | index | ) | [pure virtual] |
[in] | index | The index of the global variable. |
asINVALID_ARG | The index is out of range. |
virtual int asIScriptModule::ResetGlobalVars | ( | ) | [pure virtual] |
asERROR | The module was not compiled successfully. |
virtual int asIScriptModule::SaveByteCode | ( | asIBinaryStream * | out | ) | [pure virtual] |
[in] | out | The output stream. |
asINVALID_ARG | The stream object wasn't specified. |
The pre-compiled byte code is currently not platform independent, so you need to make sure the byte code is compiled on a platform that is compatible with the one that will load it.
virtual void asIScriptModule::SetName | ( | const char * | name | ) | [pure virtual] |
[in] | name | The new name. |
virtual int asIScriptModule::UnbindAllImportedFunctions | ( | ) | [pure virtual] |
virtual int asIScriptModule::UnbindImportedFunction | ( | int | importIndex | ) | [pure virtual] |
[in] | importIndex | The index of the imported function. |
asINVALID_ARG | The index is not valid. Unbinds the imported function. |