extern "C" { AS_API asIScriptEngine * asCreateScriptEngine(asDWORD version); AS_API const char * asGetLibraryVersion(); AS_API const char * asGetLibraryOptions(); AS_API asIScriptContext * asGetActiveContext(); AS_API int asThreadCleanup(); AS_API int asSetGlobalMemoryFunctions(asALLOCFUNC_t allocFunc, asFREEFUNC_t freeFunc); AS_API int asResetGlobalMemoryFunctions(); }
asIScriptEngine *asCreateScriptEngine(asDWORD version);
Exported as "_asCreateScriptEngine".
Creates a new script engine object, based on the version specified.
version |
The engine version wanted. |
Returns a pointer to the engine object if successful, or 0 if the version is not supported or memory couldn't be allocated.
const char *asGetLibraryVersion();
Exported as "_asGetLibraryVersion".
Use this to verify library version.
Returns a pointer to a constant string holding the library version.
const char *asGetLibraryOptions();
Exported as "_asGetLibraryOptions".
This can be used to verify with which options the library was compiled.
Returns a pointer to a constant string holding the name of the compiler options, separated by spaces.
asIScriptContext *asGetActiveContext();
Exported as "_asGetActiveContext".
This function is used to retrieve the context interface from within system functions that need it, e.g to set script exceptions.
Returns a pointer to the script context currently executing, or 0 if no context is executing.
int asThreadCleanup();
Exported as "_asThreadCleanup".
If you are using multiple threads it is a good idea to call this function just before terminating a thread. It will allow AngelScript to cleanup some memory that is local to the current running thread.
If the cleanup couldn't be performed, e.g. if a context is currently active, the function returns a negative value.
int asSetGlobalMemoryFunctions(asALLOCFUNC_t allocFunc, asFREEFUNC_t freeFunc);
Exported as "_asSetGlobalMemoryFunctions".
Sets the memory allocation and deallocation functions that the library will use. The default functions are the standard malloc and free functions from the C library.
Setting these functions allows the application to maintain full control over the memory used by the script library. You should call this before calling the asCreateScriptEngine function, otherwise the library will allocate some memory with malloc and the rest with your function.
allocFunc |
The memory allocation function. Must have the same function signature as malloc. |
freeFunc |
The memory deallocation function. Must have the same function signature as free. |
Returns negative in case of error.
int asResetGlobalMemoryFunctions();
Exported as "_asResetGlobalMemoryFunctions".
Restores the memory functions to the default malloc and free functions from the standard C library.
Only call this when you're sure that no memory is still allocated by the library. To simplify, this function calls the asThreadCleanup function to clean up the memory allocated for the thread.
Returns negative in case of error.