AngelScript
Principal functions

Functions

AS_API asIScriptEngineasCreateScriptEngine (asDWORD version=ANGELSCRIPT_VERSION)
 Creates the script engine. More...
 
AS_API asIScriptContextasGetActiveContext ()
 Returns the currently active context. More...
 
template<typename T >
asUINT asGetTypeTraits ()
 Returns the appropriate flags for use with RegisterObjectType. More...
 

Detailed Description

Function Documentation

◆ asCreateScriptEngine()

AS_API asIScriptEngine* asCreateScriptEngine ( asDWORD  version = ANGELSCRIPT_VERSION)
Parameters
[in]versionThe library version. Should always be ANGELSCRIPT_VERSION.
Returns
A pointer to the script engine interface, or null on error.

Call this function to create a new script engine. When you're done with the script engine, i.e. after you've executed all your scripts, you should call ShutDownAndRelease on the pointer to cleanup any objects that may still be alive and free the engine object.

The version argument is there to allow AngelScript to validate that the application has been compiled with the correct interface. This is especially important when linking dynamically against the library. If the version is incorrect a null pointer is returned.

◆ asGetActiveContext()

AS_API asIScriptContext* asGetActiveContext ( )
Returns
A pointer to the currently executing context, or null if no context is executing.

This function is most useful for registered functions, as it will allow them to obtain a pointer to the context that is calling the function, and through that get the engine, or custom user data.

If the script library is compiled with multithread support, this function will return the context that is currently active in the thread that is being executed. It will thus work even if there are multiple threads executing scripts at the same time.

This function does not increase the reference count of the context.

◆ asGetTypeTraits()

template<typename T >
asUINT asGetTypeTraits ( )
Template Parameters
TThe type for which the flags should be determined
Returns
The flags necessary to register this type as a value type
Note
This function is only availabe if the compiler supports C++11 feature set. Check existance with #if AS_CAN_USE_CPP11.

This template function uses C++11 STL template functions to determine the appropriate flags to use when registering the desired type as a value type with asIScriptEngine::RegisterObjectType.

It is capable to determine all the asOBJ_APP_xxx flags, except for asOBJ_APP_CLASS_ALLINTS, asOBJ_APP_CLASS_ALLFLOATS, and asOBJ_APP_CLASS_ALIGN8. These flags must still be informed manually when needed.

See also
Value types and native calling conventions