index

Reference: Library functions

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();
}

asCreateScriptEngine

asIScriptEngine *asCreateScriptEngine(asDWORD version);

Exported as "_asCreateScriptEngine".

Description

Creates a new script engine object, based on the version specified.

Parameters

version 

The engine version wanted.

Returns

Returns a pointer to the engine object if successful, or 0 if the version is not supported or memory couldn't be allocated.

asGetLibraryVersion

const char *asGetLibraryVersion();

Exported as "_asGetLibraryVersion".

Description

Use this to verify library version.

Returns

Returns a pointer to a constant string holding the library version.

asGetLibraryOptions

const char *asGetLibraryOptions();

Exported as "_asGetLibraryOptions".

Description

This can be used to verify with which options the library was compiled.

Returns

Returns a pointer to a constant string holding the name of the compiler options, separated by spaces.

asGetActiveContext

asIScriptContext *asGetActiveContext();

Exported as "_asGetActiveContext".

Description

This function is used to retrieve the context interface from within system functions that need it, e.g to set script exceptions.

Returns

Returns a pointer to the script context currently executing, or 0 if no context is executing.

asThreadCleanup

int asThreadCleanup();

Exported as "_asThreadCleanup".

Description

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.

Returns

If the cleanup couldn't be performed, e.g. if a context is currently active, the function returns a negative value.

asSetGlobalMemoryFunctions

int asSetGlobalMemoryFunctions(asALLOCFUNC_t allocFunc, asFREEFUNC_t freeFunc);

Exported as "_asSetGlobalMemoryFunctions".

Description

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.

Parameters

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

Returns negative in case of error.

asResetGlobalMemoryFunctions

int asResetGlobalMemoryFunctions();

Exported as "_asResetGlobalMemoryFunctions".

Description

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

Returns negative in case of error.

top