AngelScript
asIScriptEngine Class Referenceabstract

The engine interface. More...

Public Member Functions

Memory management
virtual int AddRef () const =0
 Increase reference counter. More...
 
virtual int Release () const =0
 Decrease reference counter. More...
 
virtual int ShutDownAndRelease ()=0
 Shuts down the engine then decrease the reference counter. More...
 
Engine properties
virtual int SetEngineProperty (asEEngineProp property, asPWORD value)=0
 Dynamically change some engine properties. More...
 
virtual asPWORD GetEngineProperty (asEEngineProp property) const =0
 Retrieve current engine property settings. More...
 
Compiler messages
virtual int SetMessageCallback (const asSFuncPtr &callback, void *obj, asDWORD callConv)=0
 Sets a message callback that will receive compiler messages. More...
 
virtual int ClearMessageCallback ()=0
 Clears the registered message callback routine. More...
 
virtual int WriteMessage (const char *section, int row, int col, asEMsgType type, const char *message)=0
 Writes a message to the message callback. More...
 
JIT compiler
virtual int SetJITCompiler (asIJITCompiler *compiler)=0
 Sets the JIT compiler. More...
 
virtual asIJITCompilerGetJITCompiler () const =0
 Returns the JIT compiler. More...
 
Global functions
virtual int RegisterGlobalFunction (const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary=0)=0
 Registers a global function. More...
 
virtual asUINT GetGlobalFunctionCount () const =0
 Returns the number of registered functions. More...
 
virtual asIScriptFunctionGetGlobalFunctionByIndex (asUINT index) const =0
 Returns the registered function. More...
 
virtual asIScriptFunctionGetGlobalFunctionByDecl (const char *declaration) const =0
 Returns the registered function. More...
 
Global properties
virtual int RegisterGlobalProperty (const char *declaration, void *pointer)=0
 Registers a global property. More...
 
virtual asUINT GetGlobalPropertyCount () const =0
 Returns the number of registered global properties. More...
 
virtual int GetGlobalPropertyByIndex (asUINT index, const char **name, const char **nameSpace=0, int *typeId=0, bool *isConst=0, const char **configGroup=0, void **pointer=0, asDWORD *accessMask=0) const =0
 Returns the detail on the registered global property. More...
 
virtual int GetGlobalPropertyIndexByName (const char *name) const =0
 Returns the index of the property. More...
 
virtual int GetGlobalPropertyIndexByDecl (const char *decl) const =0
 Returns the index of the property. More...
 
Object types
virtual int RegisterObjectType (const char *obj, int byteSize, asDWORD flags)=0
 Registers a new object type. More...
 
virtual int RegisterObjectProperty (const char *obj, const char *declaration, int byteOffset, int compositeOffset=0, bool isCompositeIndirect=false)=0
 Registers a property for the object type. More...
 
virtual int RegisterObjectMethod (const char *obj, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary=0, int compositeOffset=0, bool isCompositeIndirect=false)=0
 Registers a method for the object type. More...
 
virtual int RegisterObjectBehaviour (const char *obj, asEBehaviours behaviour, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv, void *auxiliary=0, int compositeOffset=0, bool isCompositeIndirect=false)=0
 Registers a behaviour for the object type. More...
 
virtual int RegisterInterface (const char *name)=0
 Registers a script interface. More...
 
virtual int RegisterInterfaceMethod (const char *intf, const char *declaration)=0
 Registers a script interface method. More...
 
virtual asUINT GetObjectTypeCount () const =0
 Returns the number of registered object types. More...
 
virtual asITypeInfoGetObjectTypeByIndex (asUINT index) const =0
 Returns the object type interface by index. More...
 
String factory
virtual int RegisterStringFactory (const char *datatype, asIStringFactory *factory)=0
 Registers the string factory. More...
 
virtual int GetStringFactoryReturnTypeId (asDWORD *flags=0) const =0
 Returns the type id of the type that the string factory returns. More...
 
Default array type
virtual int RegisterDefaultArrayType (const char *type)=0
 Registers the type that should be used as the default array. More...
 
virtual int GetDefaultArrayTypeId () const =0
 Returns the type id of the registered type. More...
 
Enums
virtual int RegisterEnum (const char *type)=0
 Registers an enum type. More...
 
virtual int RegisterEnumValue (const char *type, const char *name, int value)=0
 Registers an enum value. More...
 
virtual asUINT GetEnumCount () const =0
 Returns the number of registered enum types. More...
 
virtual asITypeInfoGetEnumByIndex (asUINT index) const =0
 Returns the registered enum type. More...
 
Funcdefs
virtual int RegisterFuncdef (const char *decl)=0
 Registers a function definition. More...
 
virtual asUINT GetFuncdefCount () const =0
 Returns the number of registered function definitions. More...
 
virtual asITypeInfoGetFuncdefByIndex (asUINT index) const =0
 Returns a registered function definition. More...
 
Typedefs
virtual int RegisterTypedef (const char *type, const char *decl)=0
 Registers a typedef. More...
 
virtual asUINT GetTypedefCount () const =0
 Returns the number of registered typedefs. More...
 
virtual asITypeInfoGetTypedefByIndex (asUINT index) const =0
 Returns a registered typedef. More...
 
Configuration groups
virtual int BeginConfigGroup (const char *groupName)=0
 Starts a new dynamic configuration group. More...
 
virtual int EndConfigGroup ()=0
 Ends the configuration group. More...
 
virtual int RemoveConfigGroup (const char *groupName)=0
 Removes a previously registered configuration group. More...
 
virtual asDWORD SetDefaultAccessMask (asDWORD defaultMask)=0
 Sets the access mask that should be used for subsequent registered entities. More...
 
virtual int SetDefaultNamespace (const char *nameSpace)=0
 Sets the current default namespace for registrations and searches. More...
 
virtual const char * GetDefaultNamespace () const =0
 Returns the current default namespace. More...
 
Script modules
virtual asIScriptModuleGetModule (const char *module, asEGMFlags flag=asGM_ONLY_IF_EXISTS)=0
 Return an interface pointer to the module. More...
 
virtual int DiscardModule (const char *module)=0
 Discard a module. More...
 
virtual asUINT GetModuleCount () const =0
 Get the number of modules. More...
 
virtual asIScriptModuleGetModuleByIndex (asUINT index) const =0
 Get a module by index. More...
 
Script functions
virtual asIScriptFunctionGetFunctionById (int funcId) const =0
 Returns the function by its id. More...
 
Type identification
virtual int GetTypeIdByDecl (const char *decl) const =0
 Returns a type id by declaration. More...
 
virtual const char * GetTypeDeclaration (int typeId, bool includeNamespace=false) const =0
 Returns a type declaration. More...
 
virtual int GetSizeOfPrimitiveType (int typeId) const =0
 Returns the size of a primitive type. More...
 
virtual asITypeInfoGetTypeInfoById (int typeId) const =0
 Returns the type interface for type. More...
 
virtual asITypeInfoGetTypeInfoByName (const char *name) const =0
 Returns the type interface by name. More...
 
virtual asITypeInfoGetTypeInfoByDecl (const char *decl) const =0
 Returns a type by declaration. More...
 
Script execution
virtual asIScriptContextCreateContext ()=0
 Creates a new script context. More...
 
virtual void * CreateScriptObject (const asITypeInfo *type)=0
 Creates an object defined by its type. More...
 
virtual void * CreateScriptObjectCopy (void *obj, const asITypeInfo *type)=0
 Creates a copy of a script object. More...
 
virtual void * CreateUninitializedScriptObject (const asITypeInfo *type)=0
 Creates an uninitialized script object defined by its type. More...
 
virtual asIScriptFunctionCreateDelegate (asIScriptFunction *func, void *obj)=0
 Create a delegate for an object and method. More...
 
virtual int AssignScriptObject (void *dstObj, void *srcObj, const asITypeInfo *type)=0
 Copy one script object to another. More...
 
virtual void ReleaseScriptObject (void *obj, const asITypeInfo *type)=0
 Release the object pointer. More...
 
virtual void AddRefScriptObject (void *obj, const asITypeInfo *type)=0
 Increase the reference counter for the script object. More...
 
virtual int RefCastObject (void *obj, asITypeInfo *fromType, asITypeInfo *toType, void **newPtr, bool useOnlyImplicitCast=false)=0
 Returns the handle on a successful reference cast to desired type. More...
 
virtual asILockableSharedBoolGetWeakRefFlagOfScriptObject (void *obj, const asITypeInfo *type) const =0
 Returns the weak ref flag from the object. More...
 
Context pooling
virtual asIScriptContextRequestContext ()=0
 Request a context. More...
 
virtual void ReturnContext (asIScriptContext *ctx)=0
 Return a context when it won't be used anymore. More...
 
virtual int SetContextCallbacks (asREQUESTCONTEXTFUNC_t requestCtx, asRETURNCONTEXTFUNC_t returnCtx, void *param=0)=0
 Register context callbacks for pooling. More...
 
String interpretation
virtual asETokenClass ParseToken (const char *string, size_t stringLength=0, asUINT *tokenLength=0) const =0
 Returns the class and length of the first token in the string. More...
 
Garbage collection
virtual int GarbageCollect (asDWORD flags=asGC_FULL_CYCLE, asUINT numIterations=1)=0
 Perform garbage collection. More...
 
virtual void GetGCStatistics (asUINT *currentSize, asUINT *totalDestroyed=0, asUINT *totalDetected=0, asUINT *newObjects=0, asUINT *totalNewDestroyed=0) const =0
 Obtain statistics from the garbage collector. More...
 
virtual int NotifyGarbageCollectorOfNewObject (void *obj, asITypeInfo *type)=0
 Notify the garbage collector of a new object that needs to be managed. More...
 
virtual int GetObjectInGC (asUINT idx, asUINT *seqNbr=0, void **obj=0, asITypeInfo **type=0)=0
 Gets an object in the garbage collector. More...
 
virtual void GCEnumCallback (void *reference)=0
 Used by the garbage collector to enumerate all references held by an object. More...
 
virtual void ForwardGCEnumReferences (void *ref, asITypeInfo *type)=0
 Used to forward GC callback to held value types that may contain references. More...
 
virtual void ForwardGCReleaseReferences (void *ref, asITypeInfo *type)=0
 Used to forward GC callback to held value types that may contain references. More...
 
virtual void SetCircularRefDetectedCallback (asCIRCULARREFFUNC_t callback, void *param=0)=0
 Set a callback for capturing more info on circular reference for debugging. More...
 
User data
virtual void * SetUserData (void *data, asPWORD type=0)=0
 Register the memory address of some user data. More...
 
virtual void * GetUserData (asPWORD type=0) const =0
 Returns the address of the previously registered user data. More...
 
virtual void SetEngineUserDataCleanupCallback (asCLEANENGINEFUNC_t callback, asPWORD type=0)=0
 Set the function that should be called when the engine is destroyed. More...
 
virtual void SetModuleUserDataCleanupCallback (asCLEANMODULEFUNC_t callback, asPWORD type=0)=0
 Set the function that should be called when the module is destroyed. More...
 
virtual void SetContextUserDataCleanupCallback (asCLEANCONTEXTFUNC_t callback, asPWORD type=0)=0
 Set the function that should be called when a context is destroyed. More...
 
virtual void SetFunctionUserDataCleanupCallback (asCLEANFUNCTIONFUNC_t callback, asPWORD type=0)=0
 Set the function that should be called when a function is destroyed. More...
 
virtual void SetTypeInfoUserDataCleanupCallback (asCLEANTYPEINFOFUNC_t callback, asPWORD type=0)=0
 Set the function that should be called when a type info is destroyed. More...
 
virtual void SetScriptObjectUserDataCleanupCallback (asCLEANSCRIPTOBJECTFUNC_t callback, asPWORD type=0)=0
 Set the function that should be called when a script object is destroyed. More...
 
Exception handling
virtual int SetTranslateAppExceptionCallback (asSFuncPtr callback, void *param, int callConv)=0
 Register the exception translation callback. More...
 

Detailed Description

The engine is the central object. It is where the application registers the application interface that the scripts should be able to use, and it is where the application can request modules to build scripts and contexts to execute them.

The engine instance is created with a call to asCreateScriptEngine.

It is allowed to have multiple instances of script engines, but there is rarely a need for it. Even if the application needs to expose different interfaces to different types of scripts this can usually be accomplished through the use of configuration groups and access profiles.

Member Function Documentation

◆ AddRef()

virtual int asIScriptEngine::AddRef ( ) const
pure virtual
Returns
The number of references to this object.

Call this method when storing an additional reference to the object. Remember that the first reference that is received from asCreateScriptEngine is already accounted for.

◆ AddRefScriptObject()

virtual void asIScriptEngine::AddRefScriptObject ( void *  obj,
const asITypeInfo type 
)
pure virtual
Parameters
[in]objA pointer to the object.
[in]typeThe type of the object.

This calls the add ref method of the object to increase the reference count.

◆ AssignScriptObject()

virtual int asIScriptEngine::AssignScriptObject ( void *  dstObj,
void *  srcObj,
const asITypeInfo type 
)
pure virtual
Parameters
[in]dstObjA pointer to the destination object.
[in]srcObjA pointer to the source object.
[in]typeThe type of the objects.
Returns
A negative value on error
Return values
asINVALID_ARGOne of the arguments is null
asNOT_SUPPORTEDThe object type is a ref type and value assignment has been turned off

This calls the assignment operator to copy the object from one to the other.

This only works for objects.

◆ BeginConfigGroup()

virtual int asIScriptEngine::BeginConfigGroup ( const char *  groupName)
pure virtual
Parameters
[in]groupNameThe name of the configuration group
Returns
A negative value on error
Return values
asNAME_TAKENAnother group with the same name already exists.
asNOT_SUPPORTEDNesting configuration groups is not supported.

Starts a new dynamic configuration group. This group can be setup so that it is only visible to specific modules, and it can also be removed when it is no longer used.

See also
Dynamic configurations

◆ ClearMessageCallback()

virtual int asIScriptEngine::ClearMessageCallback ( )
pure virtual
Returns
A negative value on error.

Call this method to remove the message callback.

◆ CreateContext()

virtual asIScriptContext* asIScriptEngine::CreateContext ( )
pure virtual
Returns
A pointer to the new script context.

This method creates a context that will be used to execute the script functions. The context interface created will have its reference counter already increased.

See also
RequestContext

◆ CreateDelegate()

virtual asIScriptFunction* asIScriptEngine::CreateDelegate ( asIScriptFunction func,
void *  obj 
)
pure virtual
Parameters
[in]funcThe object method
[in]objThe object pointer
Returns
The new delegate instance

◆ CreateScriptObject()

virtual void* asIScriptEngine::CreateScriptObject ( const asITypeInfo type)
pure virtual
Parameters
[in]typeThe type of the object to create.
Returns
A pointer to the new object if successful, or null if not.

This method is used to create an object based on it's type. The method will call the object type's default factory. If the object type doesn't have a default factory the call will fail and no object will be created.

Created objects will have their reference counter set to 1 so the application needs to release the pointer when it will no longer use it.

If the type is a registered value type, then the memory for the object will be allocated using the default memory routine. To destroy and and deallocate the object it is best to use ReleaseScriptObject.

The method only works for objects, for primitive types and object handles the method doesn't do anything and returns a null pointer.

◆ CreateScriptObjectCopy()

virtual void* asIScriptEngine::CreateScriptObjectCopy ( void *  obj,
const asITypeInfo type 
)
pure virtual
Parameters
[in]objA pointer to the source object.
[in]typeThe type of the object.
Returns
A pointer to the new object if successful, or null if not.

This method is used to create a copy of an existing object.

This only works for objects, for primitive types and object handles the method doesn't do anything and returns a null pointer.

◆ CreateUninitializedScriptObject()

virtual void* asIScriptEngine::CreateUninitializedScriptObject ( const asITypeInfo type)
pure virtual
Parameters
[in]typeThe type of the object to create.
Returns
A pointer to the new object if successful, or null if not.

This method can only be used to create instances of script classes.

The returned object will only be initialized so far that there are no invalid pointers or references. The constructor of the script class will not be invoked.

If the script class has any registered types as members, the default constructor for those members will be executed.

This method is meant for objects that will be initialized manually by the application, e.g. when restoring a serialized object.

◆ DiscardModule()

virtual int asIScriptEngine::DiscardModule ( const char *  module)
pure virtual
Parameters
[in]moduleThe name of the module
Returns
A negative value on error
Return values
asNO_MODULEThe module was not found.

Discards a module and frees its memory. Any pointers that the application holds to this module will be invalid after this call.

◆ EndConfigGroup()

virtual int asIScriptEngine::EndConfigGroup ( )
pure virtual
Returns
A negative value on error
Return values
asERRORCan't end a group that hasn't been begun.

Ends the current configuration group. Once finished a config group cannot be changed, but it can be removed when it is no longer used.

See also
Dynamic configurations

◆ ForwardGCEnumReferences()

virtual void asIScriptEngine::ForwardGCEnumReferences ( void *  ref,
asITypeInfo type 
)
pure virtual
Parameters
[in]refThe object pointer
[in]typeThe type of the object

This should be used by reference types that implement the asBEHAVE_ENUMREFS behaviour when the object holds a value type that can in turn contain references.

See also
Garbage collected objects

◆ ForwardGCReleaseReferences()

virtual void asIScriptEngine::ForwardGCReleaseReferences ( void *  ref,
asITypeInfo type 
)
pure virtual
Parameters
[in]refThe object pointer
[in]typeThe type of the object

This should be used by reference types that implement the asBEHAVE_RELEASEREFS behaviour when the object holds a value type that can in turn contain references.

See also
Garbage collected objects

◆ GarbageCollect()

virtual int asIScriptEngine::GarbageCollect ( asDWORD  flags = asGC_FULL_CYCLE,
asUINT  numIterations = 1 
)
pure virtual
Parameters
[in]flagsSet to a combination of the asEGCFlags.
[in]numIterationsThe number of iterations to perform when not doing a full cycle
Returns
1 if the cycle wasn't completed, 0 if it was.

This method will free script objects that can no longer be reached. When the engine is released the garbage collector will automatically do a full cycle to release all objects still alive. If the engine is long living it is important to call this method every once in a while to free up memory allocated by the scripts. If a script does a lot of allocations before returning it may be necessary to implement a line callback function that calls the garbage collector during execution of the script.

It is not necessary to do a full cycle with every call. This makes it possible to spread out the garbage collection time over a large period, thus not impacting the responsiveness of the application.

See also
Garbage collection

◆ GCEnumCallback()

virtual void asIScriptEngine::GCEnumCallback ( void *  reference)
pure virtual
Parameters
[in]referenceA pointer to the referenced object.

When processing the asBEHAVE_ENUMREFS call the called object should call GCEnumCallback for each of the references it holds to other objects. If the object holds a value type that may contain references, then use the ForwardGCEnumReferences.

See also
Garbage collected objects

◆ GetDefaultArrayTypeId()

virtual int asIScriptEngine::GetDefaultArrayTypeId ( ) const
pure virtual
Returns
The type id, or a negative value on error.
Return values
asINVALID_TYPEThe default array type hasn't been registered.

◆ GetDefaultNamespace()

virtual const char* asIScriptEngine::GetDefaultNamespace ( ) const
pure virtual
Returns
The current default namespace

◆ GetEngineProperty()

virtual asPWORD asIScriptEngine::GetEngineProperty ( asEEngineProp  property) const
pure virtual
Parameters
[in]propertyOne of the asEEngineProp values.
Returns
The value of the property, or 0 if it is an invalid property.

Calling this method lets you determine the current value of the engine properties.

◆ GetEnumByIndex()

virtual asITypeInfo* asIScriptEngine::GetEnumByIndex ( asUINT  index) const
pure virtual
Parameters
[in]indexThe index of the enum type.
Returns
The type info of the registered enum type, or null on error.

◆ GetEnumCount()

virtual asUINT asIScriptEngine::GetEnumCount ( ) const
pure virtual
Returns
The number of registered enum types.

◆ GetFuncdefByIndex()

virtual asITypeInfo* asIScriptEngine::GetFuncdefByIndex ( asUINT  index) const
pure virtual
Parameters
[in]indexThe index of the funcdef.
Returns
The type info of the funcdef.

This function does not increase the reference count of the returned function definition.

◆ GetFuncdefCount()

virtual asUINT asIScriptEngine::GetFuncdefCount ( ) const
pure virtual
Returns
The number of registered funcdefs.

◆ GetFunctionById()

virtual asIScriptFunction* asIScriptEngine::GetFunctionById ( int  funcId) const
pure virtual
Parameters
[in]funcIdThe id of the function or method.
Returns
A pointer to the function description interface, or null if not found.

This does not increment the reference count of the returned function interface.

◆ GetGCStatistics()

virtual void asIScriptEngine::GetGCStatistics ( asUINT currentSize,
asUINT totalDestroyed = 0,
asUINT totalDetected = 0,
asUINT newObjects = 0,
asUINT totalNewDestroyed = 0 
) const
pure virtual
Parameters
[out]currentSizeThe current number of objects known to the garbage collector.
[out]totalDestroyedThe total number of objects destroyed by the garbage collector.
[out]totalDetectedThe total number of objects detected as garbage with circular references.
[out]newObjectsThe current number of objects in the new generation.
[out]totalNewDestroyedThe total number of objects destroyed while still in the new generation.

This method can be used to query the number of objects that the garbage collector is keeping track of. If the number is very large then it is probably time to call the GarbageCollect method so that some of the objects ca be freed.

See also
Garbage collection

◆ GetGlobalFunctionByDecl()

virtual asIScriptFunction* asIScriptEngine::GetGlobalFunctionByDecl ( const char *  declaration) const
pure virtual
Parameters
[in]declarationThe signature of the function.
Returns
The function object, or null on error.

◆ GetGlobalFunctionByIndex()

virtual asIScriptFunction* asIScriptEngine::GetGlobalFunctionByIndex ( asUINT  index) const
pure virtual
Parameters
[in]indexThe index of the registered global function.
Returns
The function object, or null on error.

◆ GetGlobalFunctionCount()

virtual asUINT asIScriptEngine::GetGlobalFunctionCount ( ) const
pure virtual
Returns
The number of registered functions.

◆ GetGlobalPropertyByIndex()

virtual int asIScriptEngine::GetGlobalPropertyByIndex ( asUINT  index,
const char **  name,
const char **  nameSpace = 0,
int *  typeId = 0,
bool *  isConst = 0,
const char **  configGroup = 0,
void **  pointer = 0,
asDWORD accessMask = 0 
) const
pure virtual
Parameters
[in]indexThe index of the global variable.
[out]nameReceives the name of the property.
[out]nameSpaceReceives the namespace of the property.
[out]typeIdReceives the typeId of the property.
[out]isConstReceives the constness indicator of the property.
[out]configGroupReceives the config group in which the property was registered.
[out]pointerReceives the pointer of the property.
[out]accessMaskReceives the access mask of the property.
Returns
A negative value on error.
Return values
asINVALID_ARGindex is too large.

◆ GetGlobalPropertyCount()

virtual asUINT asIScriptEngine::GetGlobalPropertyCount ( ) const
pure virtual
Returns
The number of registered global properties.

◆ GetGlobalPropertyIndexByDecl()

virtual int asIScriptEngine::GetGlobalPropertyIndexByDecl ( const char *  decl) const
pure virtual
Parameters
[in]declThe declaration of the property to search for.
Returns
The index of the matching property or negative on error.
Return values
asNO_GLOBAL_VARNo matching property was found.
asINVALID_DECLARATIONThe given declaration is invalid.

◆ GetGlobalPropertyIndexByName()

virtual int asIScriptEngine::GetGlobalPropertyIndexByName ( const char *  name) const
pure virtual
Parameters
[in]nameThe name of the property.
Returns
The index of the matching property or negative on error.
Return values
asNO_GLOBAL_VARNo matching property was found.
asINVALID_ARGThe name and scope for search cannot be determined.

The search for global properties will be performed in the default namespace as given by SetDefaultNamespace unless the name is prefixed with a scope, using the scoping operator ::. If the scope starts with :: it will be used as the absolute scope, otherwise it will be relative to the default namespace.

◆ GetJITCompiler()

virtual asIJITCompiler* asIScriptEngine::GetJITCompiler ( ) const
pure virtual
Returns
Returns a pointer to the JIT compiler

◆ GetModule()

virtual asIScriptModule* asIScriptEngine::GetModule ( const char *  module,
asEGMFlags  flag = asGM_ONLY_IF_EXISTS 
)
pure virtual
Parameters
[in]moduleThe name of the module
[in]flagOne of the asEGMFlags flags
Returns
A pointer to the module interface

Use this method to get access to the module interface, which will let you build new scripts, and enumerate functions and types in existing modules.

If asGM_ALWAYS_CREATE is informed as the flag the previous module with the same name will be discarded, thus any pointers that the engine holds to it will be invalid after the call.

◆ GetModuleByIndex()

virtual asIScriptModule* asIScriptEngine::GetModuleByIndex ( asUINT  index) const
pure virtual
Parameters
[in]indexThe index of the module.
Returns
A pointer to the module or null on error.

◆ GetModuleCount()

virtual asUINT asIScriptEngine::GetModuleCount ( ) const
pure virtual
Returns
The number of modules.

◆ GetObjectInGC()

virtual int asIScriptEngine::GetObjectInGC ( asUINT  idx,
asUINT seqNbr = 0,
void **  obj = 0,
asITypeInfo **  type = 0 
)
pure virtual
Parameters
[in]idxThe index of the desired object
[out]seqNbrThe sequence number of the obtained object
[out]objThe object pointer
[out]typeThe type of the obtained object
Returns
A negative value on error
Return values
asINVALID_ARGThe index is not valid

◆ GetObjectTypeByIndex()

virtual asITypeInfo* asIScriptEngine::GetObjectTypeByIndex ( asUINT  index) const
pure virtual
Parameters
[in]indexThe index of the type.
Returns
The registered object type interface for the type, or null if not found.

◆ GetObjectTypeCount()

virtual asUINT asIScriptEngine::GetObjectTypeCount ( ) const
pure virtual
Returns
The number of object types registered by the application.

◆ GetSizeOfPrimitiveType()

virtual int asIScriptEngine::GetSizeOfPrimitiveType ( int  typeId) const
pure virtual
Parameters
[in]typeIdThe type id of the type.
Returns
The size of the type in bytes, or zero if it is not a primitive type.

This method can be used to return the size of any built-in primitive type, and also for script declared or application registered enums.

◆ GetStringFactoryReturnTypeId()

virtual int asIScriptEngine::GetStringFactoryReturnTypeId ( asDWORD flags = 0) const
pure virtual
Returns
The type id of the type that the string type returns, or a negative value on error.
Parameters
[out]flagsThe type modifiers for the return type
Return values
asNO_FUNCTIONThe string factory has not been registered.

◆ GetTypeDeclaration()

virtual const char* asIScriptEngine::GetTypeDeclaration ( int  typeId,
bool  includeNamespace = false 
) const
pure virtual
Parameters
[in]typeIdThe type id of the type.
[in]includeNamespaceSet to true if the namespace should be included in the formatted declaration.
Returns
A null terminated string with the type declaration, or null if not found.

◆ GetTypedefByIndex()

virtual asITypeInfo* asIScriptEngine::GetTypedefByIndex ( asUINT  index) const
pure virtual
Parameters
[in]indexThe index of the typedef.
Returns
The type info of the typedef.

◆ GetTypedefCount()

virtual asUINT asIScriptEngine::GetTypedefCount ( ) const
pure virtual
Returns
The number of registered typedefs.

◆ GetTypeIdByDecl()

virtual int asIScriptEngine::GetTypeIdByDecl ( const char *  decl) const
pure virtual
Parameters
[in]declThe declaration of the type.
Returns
A negative value on error, or the type id of the type.
Return values
asINVALID_TYPEdecl is not a valid type.

Translates a type declaration into a type id. The returned type id is valid for as long as the type is valid, so you can safely store it for later use to avoid potential overhead by calling this function each time. Just remember to update the type id, any time the type is changed within the engine, e.g. when recompiling script declared classes, or changing the engine configuration.

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.

This method is only able to return the type id that are not specific for a script module, i.e. built-in types and application registered types. Type ids for script declared types should be obtained through the script module's GetTypeIdByDecl.

◆ GetTypeInfoByDecl()

virtual asITypeInfo* asIScriptEngine::GetTypeInfoByDecl ( const char *  decl) const
pure virtual
Parameters
[in]declThe declaration of the type.
Returns
The type or null on error.

Translates a type declaration into the type info. The returned type is valid for as long as the type is valid, so you can safely store it for later use to avoid potential overhead from calling this function each time. Just remember to update the type info pointer any time the type is changed within the engine, e.g. when recompiling script declared classes, or changing the engine configuration.

◆ GetTypeInfoById()

virtual asITypeInfo* asIScriptEngine::GetTypeInfoById ( int  typeId) const
pure virtual
Parameters
[in]typeIdThe type id of the type.
Returns
The type interface for the type, or null if not found.

This does not increment the reference count of the returned type.

◆ GetTypeInfoByName()

virtual asITypeInfo* asIScriptEngine::GetTypeInfoByName ( const char *  name) const
pure virtual
Parameters
[in]nameThe name of the type.
Returns
The type interface for the type, or null if not found.

The search for types will be performed in the default namespace as given by SetDefaultNamespace unless the name is prefixed with a scope, using the scoping operator ::. If the scope starts with :: it will be used as the absolute scope, otherwise it will be relative to the default namespace.

◆ GetUserData()

virtual void* asIScriptEngine::GetUserData ( asPWORD  type = 0) const
pure virtual
Parameters
[in]typeAn identifier specifying the user data to get.
Returns
The pointer to the user data.

◆ GetWeakRefFlagOfScriptObject()

virtual asILockableSharedBool* asIScriptEngine::GetWeakRefFlagOfScriptObject ( void *  obj,
const asITypeInfo type 
) const
pure virtual
Parameters
[in]objThe object
[in]typeThe object type
Returns
The weak ref flag, if the object supports weak references.

As long as the weak ref flag is not set, the owning object is still alive. Once the weak ref flag is set, the object is dead and should no longer be accessed. Check if the flag is set with the asILockableSharedBool::Get method.

This method doesn't increase the reference to the returned shared boolean.

◆ NotifyGarbageCollectorOfNewObject()

virtual int asIScriptEngine::NotifyGarbageCollectorOfNewObject ( void *  obj,
asITypeInfo type 
)
pure virtual
Parameters
[in]objA pointer to the newly created object.
[in]typeThe type of the object.
Returns
The sequence number of the added object, or a negative value on error.
Return values
asINVALID_ARGEither the object or the type is null

This method should be called when a new garbage collected object is created. The GC will then store a reference to the object so that it can automatically detect whether the object is involved in any circular references that should be released.

See also
Garbage collected objects

◆ ParseToken()

virtual asETokenClass asIScriptEngine::ParseToken ( const char *  string,
size_t  stringLength = 0,
asUINT tokenLength = 0 
) const
pure virtual
Parameters
[in]stringThe string to parse.
[in]stringLengthThe length of the string. Can be 0 if the string is null terminated.
[out]tokenLengthGives the length of the identified token.
Returns
One of the asETokenClass values.

This function is useful for those applications that want to tokenize strings into tokens that the script language uses, e.g. IDEs providing syntax highlighting, or intellisense. It can also be used to parse the meta data strings that may be declared for script entities.

◆ RefCastObject()

virtual int asIScriptEngine::RefCastObject ( void *  obj,
asITypeInfo fromType,
asITypeInfo toType,
void **  newPtr,
bool  useOnlyImplicitCast = false 
)
pure virtual
Parameters
[in]objA pointer to the object.
[in]fromTypeThe type of the object.
[in]toTypeThe desired type for the cast.
[out]newPtrThe new pointer to the object if successful.
[in]useOnlyImplicitCastIf only the implicit reference cast operators should be used.
Returns
A negative value on error
Return values
asINVALID_ARGA null pointer was supplied

This method is used to cast an pointer to a different type. While both the new and old pointers are expected to refer to the same instance, the address of the pointers are not necessarily the same.

If the cast is successful the newPtr will be set to the new pointer, and the reference counter will be incremented. If the cast is not successful, the newPtr will be set to null, and the reference count left unchanged.

◆ RegisterDefaultArrayType()

virtual int asIScriptEngine::RegisterDefaultArrayType ( const char *  type)
pure virtual
Parameters
[in]typeThe name of the template type, e.g. array<T>
Returns
A negative value on error.
Return values
asINVALID_TYPEThe type is not a template type

◆ RegisterEnum()

virtual int asIScriptEngine::RegisterEnum ( const char *  type)
pure virtual
Parameters
[in]typeThe name of the enum type.
Returns
The type id on success, or a negative value on error.
Return values
asINVALID_NAMEtype is null, not an identifier, or it is a reserved keyword.
asALREADY_REGISTEREDAnother type with this name already exists.
asERRORThe type couldn't be parsed.
asNAME_TAKENThe type name is already taken.

This method registers an enum type in the engine. The enum values should then be registered with RegisterEnumValue.

◆ RegisterEnumValue()

virtual int asIScriptEngine::RegisterEnumValue ( const char *  type,
const char *  name,
int  value 
)
pure virtual
Parameters
[in]typeThe name of the enum type.
[in]nameThe name of the enum value.
[in]valueThe integer value of the enum value.
Returns
A negative value on error.
Return values
asWRONG_CONFIG_GROUPThe enum type was registered in a different configuration group.
asINVALID_TYPEThe type is invalid.
asALREADY_REGISTEREDThe name is already registered for this enum.

This method registers an enum value for a previously registered enum type.

◆ RegisterFuncdef()

virtual int asIScriptEngine::RegisterFuncdef ( const char *  decl)
pure virtual
Parameters
[in]declThe declaration of the function definition.
Returns
The type id on success, else a negative value on error.
Return values
asINVALID_ARGThe decl parameter is not given.
asINVALID_DECLARATIONdecl is not a valid function definition.
asNAME_TAKENThe name of the funcdef conflicts with another name.

Funcdefs are used to define the signature of function pointers. If the application is going to receive function pointers from scripts, it is necessary to first register the funcdef before registering the function or property that will be used to receive it.

Funcdefs are usually registered as global entities, but can also be registered as a child of a class. To do this simply prefix the name of the funcdef with the name of the class and the scope operator to specify which class should be the owner.

◆ RegisterGlobalFunction()

virtual int asIScriptEngine::RegisterGlobalFunction ( const char *  declaration,
const asSFuncPtr funcPointer,
asDWORD  callConv,
void *  auxiliary = 0 
)
pure virtual
Parameters
[in]declarationThe declaration of the global function in script syntax.
[in]funcPointerThe function pointer.
[in]callConvThe calling convention for the function.
[in]auxiliaryA helper object for use with some calling conventions.
Returns
A negative value on error, or the function id if successful.
Return values
asNOT_SUPPORTEDThe calling convention is not supported.
asWRONG_CALLING_CONVThe function's calling convention doesn't match callConv.
asINVALID_DECLARATIONThe function declaration is invalid.
asNAME_TAKENThe function name is already used elsewhere.
asALREADY_REGISTEREDThe function has already been registered with the same parameter list.
asINVALID_ARGThe auxiliary pointer wasn't set according to calling convention.

This method registers system functions that the scripts may use to communicate with the host application.

The auxiliary pointer can optionally be used with asCALL_GENERIC. For the calling convention asCALL_THISCALL_ASGLOBAL the auxiliary is required.

See also
Registering a function

◆ RegisterGlobalProperty()

virtual int asIScriptEngine::RegisterGlobalProperty ( const char *  declaration,
void *  pointer 
)
pure virtual
Parameters
[in]declarationThe declaration of the global property in script syntax.
[in]pointerThe address of the property that will be used to access the property value.
Returns
The index of the property on success, or a negative value on error.
Return values
asINVALID_DECLARATIONThe declaration has invalid syntax.
asINVALID_TYPEThe declaration is a reference.
asINVALID_ARGThe pointer is null.
asNAME_TAKENThe name is already taken.

Use this method to register a global property that the scripts will be able to access as global variables. The property may optionally be registered as const, if the scripts shouldn't be allowed to modify it.

When registering the property, the application must pass the address to the actual value. The application must also make sure that this address remains valid throughout the life time of this registration, i.e. until the engine is released or the dynamic configuration group is removed.

Upon success the function returns the index of the registered property
that can be used to lookup the info with GetGlobalPropertyByIndex. Note that this index may not stay valid after a dynamic config group has been removed, which would reorganize the internal structure.

◆ RegisterInterface()

virtual int asIScriptEngine::RegisterInterface ( const char *  name)
pure virtual
Parameters
[in]nameThe name of the interface.
Returns
The type id of the interface on success, else a negative value on error.
Return values
asINVALID_NAMEThe name is null, or a reserved keyword.
asALREADY_REGISTEREDAn object type with this name already exists.
asERRORThe name is not a proper identifier.
asNAME_TAKENThe name is already used elsewhere.

This registers an interface that script classes can implement. By doing this the application can register functions and methods that receives an asIScriptObject and still be sure that the class implements certain methods needed by the application.

See also
Receiving script classes

◆ RegisterInterfaceMethod()

virtual int asIScriptEngine::RegisterInterfaceMethod ( const char *  intf,
const char *  declaration 
)
pure virtual
Parameters
[in]intfThe name of the interface.
[in]declarationThe method declaration.
Returns
A negative value on error.
Return values
asWRONG_CONFIG_GROUPThe interface was registered in another configuration group.
asINVALID_TYPEintf is not an interface type.
asINVALID_DECLARATIONThe declaration is invalid.
asNAME_TAKENThe method name is already taken.

This registers a method that the class that implements the script interface must have.

◆ RegisterObjectBehaviour()

virtual int asIScriptEngine::RegisterObjectBehaviour ( const char *  obj,
asEBehaviours  behaviour,
const char *  declaration,
const asSFuncPtr funcPointer,
asDWORD  callConv,
void *  auxiliary = 0,
int  compositeOffset = 0,
bool  isCompositeIndirect = false 
)
pure virtual
Parameters
[in]objThe name of the type.
[in]behaviourOne of the object behaviours from asEBehaviours.
[in]declarationThe declaration of the method in script syntax.
[in]funcPointerThe method or function pointer.
[in]callConvThe calling convention for the method or function.
[in]auxiliaryA helper object for use with some calling conventions.
[in]compositeOffsetThe offset to the composite object.
[in]isCompositeIndirectSet to false if the composite object is inline, and true if it is refered to by pointer.
Returns
A negative value on error, or the function id is successful.
Return values
asWRONG_CONFIG_GROUPThe object type was registered in a different configuration group.
asINVALID_ARGobj is not set, or a global behaviour is given in behaviour, or the objForThiscall pointer wasn't set according to calling convention.
asWRONG_CALLING_CONVThe function's calling convention isn't compatible with callConv.
asNOT_SUPPORTEDThe calling convention or the behaviour signature is not supported.
asINVALID_TYPEThe obj parameter is not a valid object name.
asINVALID_DECLARATIONThe declaration is invalid.
asILLEGAL_BEHAVIOUR_FOR_TYPEThe behaviour is not allowed for this type.
asALREADY_REGISTEREDThe behaviour is already registered with the same signature.

Use this method to register behaviour functions that will be called by the virtual machine to perform certain operations, such as memory management, math operations, comparisons, etc.

The declaration must form a valid function signature, but the give function name will not be used or stored in the application so there is no need to provide a meaningful function name.

The auxiliary pointer can optionally be used with asCALL_GENERIC. For the calling conventions asCALL_THISCALL_ASGLOBAL, asCALL_THISCALL_OBJFIRST and asCALL_THISCALL_OBJLAST the auxiliary is required.

In case the method to be registered is part of a composite member, then the compositeOffset should be used to give the offset to the composite member, and the method pointer should be method of the composite member. If the composite member is inline then set isCompositeIndirect as false, else set it to true for proper indirection.

See also
Registering a function, Registering operator behaviours

◆ RegisterObjectMethod()

virtual int asIScriptEngine::RegisterObjectMethod ( const char *  obj,
const char *  declaration,
const asSFuncPtr funcPointer,
asDWORD  callConv,
void *  auxiliary = 0,
int  compositeOffset = 0,
bool  isCompositeIndirect = false 
)
pure virtual
Parameters
[in]objThe name of the type.
[in]declarationThe declaration of the method in script syntax.
[in]funcPointerThe method or function pointer.
[in]callConvThe calling convention for the method or function.
[in]auxiliaryA helper object for use with some calling conventions.
[in]compositeOffsetThe offset to the composite object.
[in]isCompositeIndirectSet to false if the composite object is inline, and true if it is refered to by pointer.
Returns
A negative value on error, or the function id if successful.
Return values
asWRONG_CONFIG_GROUPThe object type was registered in a different configuration group.
asNOT_SUPPORTEDThe calling convention is not supported.
asINVALID_TYPEThe obj parameter is not a valid object name.
asINVALID_DECLARATIONThe declaration is invalid.
asNAME_TAKENThe name conflicts with other members.
asWRONG_CALLING_CONVThe function's calling convention isn't compatible with callConv.
asALREADY_REGISTEREDThe method has already been registered with the same parameter list.
asINVALID_ARGThe auxiliary pointer wasn't set according to calling convention.

Use this method to register a member method for the type. The method that is registered may be an actual class method, or a global function that takes the object pointer as either the first or last parameter. Or it may be a global function implemented with the generic calling convention.

The auxiliary pointer can optionally be used with asCALL_GENERIC. For the calling conventions asCALL_THISCALL_OBJFIRST and asCALL_THISCALL_OBJLAST the auxiliary is required.

In case the method to be registered is part of a composite member, then the compositeOffset should be used to give the offset to the composite member, and the method pointer should be method of the composite member. If the composite member is inline then set isCompositeIndirect as false, else set it to true for proper indirection.

See also
Registering a function

◆ RegisterObjectProperty()

virtual int asIScriptEngine::RegisterObjectProperty ( const char *  obj,
const char *  declaration,
int  byteOffset,
int  compositeOffset = 0,
bool  isCompositeIndirect = false 
)
pure virtual
Parameters
[in]objThe name of the type.
[in]declarationThe property declaration in script syntax.
[in]byteOffsetThe offset into the memory block where this property is found.
[in]compositeOffsetThe offset to the composite object.
[in]isCompositeIndirectSet to false if the composite object is inline, and true if it is refered to by pointer.
Returns
The index of the property on success, or a negative value on error.
Return values
asWRONG_CONFIG_GROUPThe object type was registered in a different configuration group.
asINVALID_OBJECTThe obj does not specify an object type.
asINVALID_TYPEThe obj parameter has invalid syntax.
asINVALID_DECLARATIONThe declaration is invalid.
asNAME_TAKENThe name conflicts with other members.

Use this method to register a member property of a class. The property must be local to the object, i.e. not a global variable or a static member. The easiest way to get the offset of the property is to use the asOFFSET macro.

struct MyType {float prop;};
r = engine->RegisterObjectProperty("MyType", "float prop", asOFFSET(MyType, prop)));

In case the property to be registered is part of a composite member, then the compositeOffset should be used to give the offset to the composite member, and byteOffset should be the offset to the property in that composite member. If the composite member is inline then set isCompositeIndirect as false, else set it to true for proper indirection.

The method returns the index of the property upon success. This can be used to look up the property in the object type with asITypeInfo::GetProperty.

◆ RegisterObjectType()

virtual int asIScriptEngine::RegisterObjectType ( const char *  obj,
int  byteSize,
asDWORD  flags 
)
pure virtual
Parameters
[in]objThe name of the type.
[in]byteSizeThe size of the type in bytes. Only necessary for value types.
[in]flagsOne or more of the asEObjTypeFlags.
Returns
The type id on success or a negative value on error.
Return values
asINVALID_ARGThe flags are invalid.
asINVALID_NAMEThe name is invalid.
asALREADY_REGISTEREDAnother type of the same name already exists.
asNAME_TAKENThe name conflicts with other symbol names.
asLOWER_ARRAY_DIMENSION_NOT_REGISTEREDWhen registering an array type the array element must be a primitive or a registered type.
asINVALID_TYPEThe array type was not properly formed.
asNOT_SUPPORTEDThe array type is not supported, or already in use preventing it from being overloaded.

Use this method to register new types that should be available to the scripts. Reference types, which have their memory managed by the application, should be registered with asOBJ_REF. Value types, which have their memory managed by the engine, should be registered with asOBJ_VALUE.

See also
Registering an object type

◆ RegisterStringFactory()

virtual int asIScriptEngine::RegisterStringFactory ( const char *  datatype,
asIStringFactory factory 
)
pure virtual
Parameters
[in]datatypeThe datatype that the string factory returns
[in]factoryThe pointer to the factory object
Returns
A negative value on error, or the function id if successful.
Return values
asINVALID_ARGThe factory is null.
asINVALID_TYPEThe datatype is not a valid type, or it is a reference or handle.

Use this function to register a string factory that will be called during compilation to create instances of a string constant. The string factory will also be used while saving bytecode in order to get the raw string data for serialization.

The data type that represents the string type should be informed without reference or handle token, as the script engine will assume a const reference anyway.

See also
Custom string type

◆ RegisterTypedef()

virtual int asIScriptEngine::RegisterTypedef ( const char *  type,
const char *  decl 
)
pure virtual
Parameters
[in]typeThe name of the new typedef
[in]declThe datatype that the typedef represents
Returns
The type id on success, else a negative value on error.
Return values
asINVALID_NAMEThe type is null, is not an identifier, or it is a reserved keyword.
asALREADY_REGISTEREDA type with the same name already exists.
asINVALID_TYPEThe decl is not a primitive type.
asNAME_TAKENThe name is already used elsewhere.

This method registers an alias for a data type.

Currently typedefs can only be registered for built-in primitive types.

◆ Release()

virtual int asIScriptEngine::Release ( ) const
pure virtual
Returns
The number of references to this object.

Call this method when you will no longer use the references that you own.

If you know that the engine is supposed to be shut down, then it is recommended to call the ShutDownAndRelease method instead.

◆ ReleaseScriptObject()

virtual void asIScriptEngine::ReleaseScriptObject ( void *  obj,
const asITypeInfo type 
)
pure virtual
Parameters
[in]objA pointer to the object.
[in]typeThe type of the object.

This calls the release method of the object to release the reference.

If the type is a value type, the method will destroy the object and deallocate the memory using the default memory routine.

◆ RemoveConfigGroup()

virtual int asIScriptEngine::RemoveConfigGroup ( const char *  groupName)
pure virtual
Parameters
[in]groupNameThe name of the configuration group
Returns
A negative value on error
Return values
asCONFIG_GROUP_IS_IN_USEThe group is in use and cannot be removed.

Remove the configuration group. If something in the configuration group is currently in use, the function will return with an error code. Examples of uses are compiled modules that have function calls to functions in the group and global variables of types registered in the group.

See also
Dynamic configurations

◆ RequestContext()

virtual asIScriptContext* asIScriptEngine::RequestContext ( )
pure virtual
Returns
An unprepared context

This method will invoke the registered request context callback and return an available context in an unprepared state.

Contexts obtained through this method shouldn't be released, instead they should be returned to the origin with a call to ReturnContext.

See also
CreateContext

◆ ReturnContext()

virtual void asIScriptEngine::ReturnContext ( asIScriptContext ctx)
pure virtual
Parameters
[in]ctxThe context that should be returned to the origin

◆ SetCircularRefDetectedCallback()

virtual void asIScriptEngine::SetCircularRefDetectedCallback ( asCIRCULARREFFUNC_t  callback,
void *  param = 0 
)
pure virtual
Parameters
[in]callbackThe callback function
[in]paramOptional parameter that will be passed back to the callback function

This callback is meant to be used during development to help identify scripts that are creating circular references. As the callback will be invoked when the objects in the circular reference are detected, but before they are destroyed, the application can investigate their content to get hints where the objects are created from.

See also
Garbage collection

◆ SetContextCallbacks()

virtual int asIScriptEngine::SetContextCallbacks ( asREQUESTCONTEXTFUNC_t  requestCtx,
asRETURNCONTEXTFUNC_t  returnCtx,
void *  param = 0 
)
pure virtual
Parameters
[in]requestCtxThe request context callback function
[in]returnCtxThe return context callback function
[in]paramAn optional parameter that will be passed to the callback
Returns
A negative value on error
Return values
asINVALID_ARGOnly one of the context functions is informed

This method can be used by the application to implement a context pool, or to perform custom configuration on the contexts that the engine uses internally.

This can for example be used to debug calls to initialize global variables when building modules, or to detect script exceptions that may occur in script class destructors when called from the garbage collector.

◆ SetContextUserDataCleanupCallback()

virtual void asIScriptEngine::SetContextUserDataCleanupCallback ( asCLEANCONTEXTFUNC_t  callback,
asPWORD  type = 0 
)
pure virtual
Parameters
[in]callbackA pointer to the function
[in]typeAn identifier specifying which user data the callback is to be used with.

The function given with this call will be invoked when a context is destroyed if any user data has been registered with the context.

The function is called from within the context destructor, so the callback should not be used for anything but cleaning up the user data itself.

◆ SetDefaultAccessMask()

virtual asDWORD asIScriptEngine::SetDefaultAccessMask ( asDWORD  defaultMask)
pure virtual
Parameters
[in]defaultMaskThe default access bit mask.
Returns
The previous default mask.
See also
Access masks and exposing different interfaces

◆ SetDefaultNamespace()

virtual int asIScriptEngine::SetDefaultNamespace ( const char *  nameSpace)
pure virtual
Parameters
[in]nameSpaceThe namespace that should be used.
Returns
A negative value on error
Return values
asINVALID_ARGThe namespace is invalid

Call this method to set the default namespace for which the following calls should assume. This applies to registration of the application interface and also to the functions that searches for registered entities.

Nested namespaces can be informed by separating them with the scope token, i.e. ::

◆ SetEngineProperty()

virtual int asIScriptEngine::SetEngineProperty ( asEEngineProp  property,
asPWORD  value 
)
pure virtual
Parameters
[in]propertyOne of the asEEngineProp values.
[in]valueThe new value of the property.
Returns
Negative value on error.
Return values
asINVALID_ARGInvalid property.

With this method you can change the way the script engine works in some regards.

◆ SetEngineUserDataCleanupCallback()

virtual void asIScriptEngine::SetEngineUserDataCleanupCallback ( asCLEANENGINEFUNC_t  callback,
asPWORD  type = 0 
)
pure virtual
Parameters
[in]callbackA pointer to the function
[in]typeAn identifier specifying which user data the callback is to be used with.

The function given with this call will be invoked when the engine is destroyed if any user data has been registered with the engine.

The function is called from within the engine destructor, so the callback should not be used for anything but cleaning up the user data itself.

◆ SetFunctionUserDataCleanupCallback()

virtual void asIScriptEngine::SetFunctionUserDataCleanupCallback ( asCLEANFUNCTIONFUNC_t  callback,
asPWORD  type = 0 
)
pure virtual
Parameters
[in]callbackA pointer to the function
[in]typeAn identifier specifying which user data the callback is to be used with.

The function given with this call will be invoked when a function is destroyed if any user data has been registered with the function.

The function is called from within the function destructor, so the callback should not be used for anything but cleaning up the user data itself.

◆ SetJITCompiler()

virtual int asIScriptEngine::SetJITCompiler ( asIJITCompiler compiler)
pure virtual
Parameters
[in]compilerA pointer to the JIT compiler
Returns
A negative value on error.

This method is used to set the JIT compiler. The engine will automatically invoke the JIT compiler when it is set after compiling scripts or loading pre-compiled byte code.

See also
How to build a JIT compiler

◆ SetMessageCallback()

virtual int asIScriptEngine::SetMessageCallback ( const asSFuncPtr callback,
void *  obj,
asDWORD  callConv 
)
pure virtual
Parameters
[in]callbackA function or class method pointer.
[in]objThe object for methods, or an optional parameter for functions.
[in]callConvThe calling convention.
Returns
A negative value for an error.
Return values
asINVALID_ARGOne of the arguments is incorrect, e.g. obj is null for a class method.
asNOT_SUPPORTEDThe arguments are not supported, e.g. asCALL_GENERIC.

This method sets the callback routine that will receive compiler messages. The callback routine can be either a class method, e.g:

void MyClass::MessageCallback(const asSMessageInfo *msg);
r = engine->SetMessageCallback(asMETHOD(MyClass,MessageCallback), &obj, asCALL_THISCALL);

or a global function, e.g:

void MessageCallback(const asSMessageInfo *msg, void *param);
r = engine->SetMessageCallback(asFUNCTION(MessageCallback), param, asCALL_CDECL);

It is recommended to register the message callback routine right after creating the engine, as some of the registration functions can provide useful information to better explain errors.

◆ SetModuleUserDataCleanupCallback()

virtual void asIScriptEngine::SetModuleUserDataCleanupCallback ( asCLEANMODULEFUNC_t  callback,
asPWORD  type = 0 
)
pure virtual
Parameters
[in]callbackA pointer to the function
[in]typeAn identifier specifying which user data the callback is to be used with.

The function given with this call will be invoked when the module is destroyed if any user data has been registered with the module.

The function is called from within the module destructor, so the callback should not be used for anything but cleaning up the user data itself.

◆ SetScriptObjectUserDataCleanupCallback()

virtual void asIScriptEngine::SetScriptObjectUserDataCleanupCallback ( asCLEANSCRIPTOBJECTFUNC_t  callback,
asPWORD  type = 0 
)
pure virtual
Parameters
[in]callbackA pointer to the function
[in]typeAn identifier specifying which user data the callback is to be used with.

The function given with this call will be invoked when a script object instance is destroyed if any user data has been registered with the type.

The function is called from within the script object destructor, so the callback should not be used for anything but cleaning up the user data itself.

◆ SetTranslateAppExceptionCallback()

virtual int asIScriptEngine::SetTranslateAppExceptionCallback ( asSFuncPtr  callback,
void *  param,
int  callConv 
)
pure virtual
Parameters
[in]callbackThe callback function/method that should be called upon an exception.
[in]paramA user defined parameter, or the object pointer on which the callback is called.
[in]callConvThe calling convention of the callback function/method.
Returns
A negative value on error.
Return values
asNOT_SUPPORTEDCalling convention must not be asCALL_GENERIC, or the routine's calling convention is not supported.
asINVALID_ARGparam must not be null for class methods.
asWRONG_CALLING_CONVcallConv isn't compatible with the routines' calling convention.

This callback function will be called by the VM when an application exception is raised, which allow the application to translate the exception into a useful string to inform in SetException.

The callback function signature must be either:

  void (*)(asIScriptContext *, void *);

or

  void (param::*)(asIScriptContext *);

See Exceptions for an example on how to use this.

◆ SetTypeInfoUserDataCleanupCallback()

virtual void asIScriptEngine::SetTypeInfoUserDataCleanupCallback ( asCLEANTYPEINFOFUNC_t  callback,
asPWORD  type = 0 
)
pure virtual
Parameters
[in]callbackA pointer to the function
[in]typeAn identifier specifying which user data the callback is to be used with.

The function given with this call will be invoked when a type info is destroyed if any user data has been registered with the type.

The function is called from within the type info destructor, so the callback should not be used for anything but cleaning up the user data itself.

◆ SetUserData()

virtual void* asIScriptEngine::SetUserData ( void *  data,
asPWORD  type = 0 
)
pure virtual
Parameters
[in]dataA pointer to the user data.
[in]typeAn identifier specifying the user data to set.
Returns
The previous pointer stored in the engine.

This method allows the application to associate a value, e.g. a pointer, with the engine instance.

The type values 1000 through 1999 are reserved for use by the official add-ons.

Optionally, a callback function can be registered to clean up the user data when the engine is destroyed.

◆ ShutDownAndRelease()

virtual int asIScriptEngine::ShutDownAndRelease ( )
pure virtual
Returns
The number of references to this object.

Call this method when you know it is time to shut down the engine. This will automatically discard all the script modules and run a complete garbage collection cycle.

Calling this method rather than the ordinary Release method will avoid potential memory leaks if for example there are objects in the modules or garbage collector that indirectly holds a reference to the engine.

◆ WriteMessage()

virtual int asIScriptEngine::WriteMessage ( const char *  section,
int  row,
int  col,
asEMsgType  type,
const char *  message 
)
pure virtual
Parameters
[in]sectionThe name of the script section.
[in]rowThe row number.
[in]colThe column number.
[in]typeThe message type.
[in]messageThe message text.
Returns
A negative value on error.
Return values
asINVALID_ARGThe section or message is null.

This method can be used by the application to write messages to the same message callback that the script compiler uses. This is useful for example if a preprocessor is used.


The documentation for this class was generated from the following file:
asIScriptEngine::SetMessageCallback
virtual int SetMessageCallback(const asSFuncPtr &callback, void *obj, asDWORD callConv)=0
Sets a message callback that will receive compiler messages.
asFUNCTION
#define asFUNCTION(f)
Returns an asSFuncPtr representing the function specified by the name.
Definition: angelscript.h:675
asMETHOD
#define asMETHOD(c, m)
Returns an asSFuncPtr representing the class method specified by class and method name.
Definition: angelscript.h:740
asCALL_THISCALL
@ asCALL_THISCALL
A thiscall class method.
Definition: angelscript.h:232
asIScriptEngine::RegisterObjectProperty
virtual int RegisterObjectProperty(const char *obj, const char *declaration, int byteOffset, int compositeOffset=0, bool isCompositeIndirect=false)=0
Registers a property for the object type.
asCALL_CDECL
@ asCALL_CDECL
A cdecl function.
Definition: angelscript.h:226
asSMessageInfo
Represents a compiler message.
Definition: angelscript.h:767
asOFFSET
#define asOFFSET(s, m)
Returns the offset of an attribute in a struct.
Definition: angelscript.h:672