# asIScriptEngine Class Reference

The engine interface.

List of all members.

## Public Member Functions
virtual int | AddRef ()=0
| Increase reference counter.
virtual int | Release ()=0
| Decrease reference counter.
virtual int | SetEngineProperty (asEEngineProp property, asPWORD value)=0
| Dynamically change some engine properties.
virtual asPWORD | GetEngineProperty (asEEngineProp property)=0
| Retrieve current engine property settings.
virtual int | SetMessageCallback (const asSFuncPtr &callback, void *obj, asDWORD callConv)=0
| Sets a message callback that will receive compiler messages.
virtual int | ClearMessageCallback ()=0
| Clears the registered message callback routine.
virtual int | WriteMessage (const char *section, int row, int col, asEMsgType type, const char *message)=0
| Writes a message to the message callback.
virtual int | RegisterObjectType (const char *obj, int byteSize, asDWORD flags)=0
| Registers a new object type.
virtual int | RegisterObjectProperty (const char *obj, const char *declaration, int byteOffset)=0
| Registers a property for the object type.
virtual int | RegisterObjectMethod (const char *obj, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv)=0
| Registers a method for the object type.
virtual int | RegisterObjectBehaviour (const char *obj, asEBehaviours behaviour, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv)=0
| Registers a behaviour for the object type.
virtual int | RegisterGlobalProperty (const char *declaration, void *pointer)=0
| Registers a global property.
virtual int | RegisterGlobalFunction (const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv)=0
| Registers a global function.
virtual int | RegisterGlobalBehaviour (asEBehaviours behaviour, const char *declaration, const asSFuncPtr &funcPointer, asDWORD callConv)=0
| Registers a global behaviour, e.g. operators.
virtual int | RegisterInterface (const char *name)=0
| Registers an interface.
virtual int | RegisterInterfaceMethod (const char *intf, const char *declaration)=0
| Registers an interface method.
virtual int | RegisterEnum (const char *type)=0
| Registers an enum type.
virtual int | RegisterEnumValue (const char *type, const char *name, int value)=0
| Registers an enum value.
virtual int | RegisterTypedef (const char *type, const char *decl)=0
| Registers a typedef.
virtual int | RegisterStringFactory (const char *datatype, const asSFuncPtr &factoryFunc, asDWORD callConv)=0
| Registers the string factory.
virtual int | BeginConfigGroup (const char *groupName)=0
| Starts a new dynamic configuration group.
virtual int | EndConfigGroup ()=0
| Ends the configuration group.
virtual int | RemoveConfigGroup (const char *groupName)=0
| Removes a previously registered configuration group.
virtual int | SetConfigGroupModuleAccess (const char *groupName, const char *module, bool hasAccess)=0
| Tell AngelScript which modules have access to which configuration groups.
virtual asIScriptModule * | GetModule (const char *module, asEGMFlags flag=asGM_ONLY_IF_EXISTS)=0
| Return an interface pointer to the module.
virtual int | DiscardModule (const char *module)=0
| Discard a module.
virtual asIScriptFunction * | GetFunctionDescriptorById (int funcId)=0
| Returns the function descriptor for the script function.
virtual int | GetObjectTypeCount ()=0
| Returns the number of object types.
virtual asIObjectType * | GetObjectTypeByIndex (asUINT index)=0
| Returns the object type interface by index.
virtual asIObjectType * | GetObjectTypeById (int typeId)=0
| Returns the object type interface for type.
virtual int | GetTypeIdByDecl (const char *decl)=0
| Returns a type id by declaration.
virtual const char * | GetTypeDeclaration (int typeId, int *length=0)=0
| Returns a type declaration.
virtual int | GetSizeOfPrimitiveType (int typeId)=0
| Returns the size of a primitive type.
virtual asIScriptContext * | CreateContext ()=0
| Creates a new script context.
virtual void * | CreateScriptObject (int typeId)=0
| Creates a script object defined by its type id.
virtual void * | CreateScriptObjectCopy (void *obj, int typeId)=0
| Creates a copy of a script object.
virtual void | CopyScriptObject (void *dstObj, void *srcObj, int typeId)=0
| Copy one script object to another.
virtual void | ReleaseScriptObject (void *obj, int typeId)=0
| Release the script object pointer.
virtual void | AddRefScriptObject (void *obj, int typeId)=0
| Increase the reference counter for the script object.
virtual bool | IsHandleCompatibleWithObject (void *obj, int objTypeId, int handleTypeId)=0
| Returns true if the object referenced by a handle compatible with the specified type.
virtual int | CompareScriptObjects (bool &result, int behaviour, void *leftObj, void *rightObj, int typeId)=0
| Performs a comparison of two objects using the specified operator behaviour.
virtual asETokenClass | ParseToken (const char *string, size_t stringLength=0, int *tokenLength=0)=0
| Returns the class and length of the first token in the string.
virtual int | ExecuteString (const char *module, const char *script, asIScriptContext **ctx=0, asDWORD flags=0)=0
| Compiles and executes script statements within the context of a module.
virtual int | GarbageCollect (asEGCFlags flags=asGC_FULL_CYCLE)=0
| Perform garbage collection.
virtual void | GetGCStatistics (asUINT *currentSize, asUINT *totalDestroyed=0, asUINT *totalDetected=0)=0
| Obtain statistics from the garbage collector.
virtual void | NotifyGarbageCollectorOfNewObject (void *obj, int typeId)=0
| Notify the garbage collector of a new object that needs to be managed.
virtual void | GCEnumCallback (void *reference)=0
| Used by the garbage collector to enumerate all references held by an object.
virtual void * | SetUserData (void *data)=0
| Register the memory address of some user data.
virtual void * | GetUserData ()=0
| Returns the address of the previously registered user data.
virtual int | AddScriptSection (const char *module, const char *name, const char *code, size_t codeLength=0, int lineOffset=0)=0
virtual int | Build (const char *module)=0
virtual int | Discard (const char *module)=0
virtual int | ResetModule (const char *module)=0
virtual int | GetFunctionCount (const char *module)=0
virtual int | GetFunctionIDByIndex (const char *module, int index)=0
virtual int | GetFunctionIDByName (const char *module, const char *name)=0
virtual int | GetFunctionIDByDecl (const char *module, const char *decl)=0
virtual asIScriptFunction * | GetFunctionDescriptorByIndex (const char *module, int index)=0
virtual int | GetGlobalVarCount (const char *module)=0
virtual int | GetGlobalVarIndexByName (const char *module, const char *name)=0
virtual int | GetGlobalVarIndexByDecl (const char *module, const char *decl)=0
virtual const char * | GetGlobalVarDeclaration (const char *module, int index, int *length=0)=0
virtual const char * | GetGlobalVarName (const char *module, int index, int *length=0)=0
virtual void * | GetAddressOfGlobalVar (const char *module, int index)=0
virtual int | GetGlobalVarIDByIndex (const char *module, int index)=0
virtual int | GetGlobalVarIDByName (const char *module, const char *name)=0
virtual int | GetGlobalVarIDByDecl (const char *module, const char *decl)=0
virtual const char * | GetGlobalVarDeclaration (int gvarID, int *length=0)=0
virtual const char * | GetGlobalVarName (int gvarID, int *length=0)=0
virtual void * | GetGlobalVarPointer (int gvarID)=0
virtual int | GetTypeIdByDecl (const char *module, const char *decl)=0
virtual int | GetImportedFunctionCount (const char *module)=0
virtual int | GetImportedFunctionIndexByDecl (const char *module, const char *decl)=0
virtual const char * | GetImportedFunctionDeclaration (const char *module, int importIndex, int *length=0)=0
virtual const char * | GetImportedFunctionSourceModule (const char *module, int importIndex, int *length=0)=0
virtual int | BindImportedFunction (const char *module, int importIndex, int funcId)=0
virtual int | UnbindImportedFunction (const char *module, int importIndex)=0
virtual int | BindAllImportedFunctions (const char *module)=0
virtual int | UnbindAllImportedFunctions (const char *module)=0
virtual int | GetObjectsInGarbageCollectorCount ()=0
virtual int | SaveByteCode (const char *module, asIBinaryStream *out)=0
virtual int | LoadByteCode (const char *module, asIBinaryStream *in)=0

## Member Function Documentation

virtual int asIScriptEngine::AddRef | ( |  | ) | `[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.

virtual int asIScriptEngine::Release | ( |  | ) | `[pure virtual]`

Returns:
  The number of references to this object.

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

virtual int asIScriptEngine::SetEngineProperty | ( | asEEngineProp | property,
|  | asPWORD | value |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | property | One of the asEEngineProp values.
  `[in]` | value | The new value of the property.

Returns:
  Negative value on error.

Return values:

  | asINVALID_ARG | Invalid property.

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

virtual asPWORD asIScriptEngine::GetEngineProperty | ( | asEEngineProp | property | ) | `[pure virtual]`

Parameters:

  `[in]` | property | One 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.

virtual int asIScriptEngine::SetMessageCallback | ( | const asSFuncPtr & | callback,
|  | void * | obj,
|  | asDWORD | callConv |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | callback | A function or class method pointer.
  `[in]` | obj | The object for methods, or an optional parameter for functions.
  `[in]` | callConv | The calling convention.

Returns:
  A negative value for an error.

Return values:

  | asINVALID_ARG | One of the arguments is incorrect, e.g. obj is null for a class method.
  | asNOT_SUPPORTED | The 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.

virtual int asIScriptEngine::ClearMessageCallback | ( |  | ) | `[pure virtual]`

Returns:
  A negative value on error.

Call this method to remove the message callback.

virtual int asIScriptEngine::WriteMessage | ( | const char * | section,
|  | int | row,
|  | int | col,
|  | asEMsgType | type,
|  | const char * | message |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | section | The name of the script section.
  `[in]` | row | The row number.
  `[in]` | col | The column number.
  `[in]` | type | The message type.
  `[in]` | message | The message text.

Returns:
  A negative value on error.

Return values:

  | asINVALID_ARG | The 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.

virtual int asIScriptEngine::RegisterObjectType | ( | const char * | obj,
|  | int | byteSize,
|  | asDWORD | flags |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | obj | The name of the type.
  `[in]` | byteSize | The size of the type in bytes. Only necessary for value types.
  `[in]` | flags | One or more of the asEObjTypeFlags.

Returns:
  A negative value on error.

Return values:

  | asINVALID_ARG | The flags are invalid.
  | asINVALID_NAME | The name is invalid.
  | asALREADY_REGISTERED | Another type of the same name already exists.
  | asNAME_TAKEN | The name conflicts with other symbol names.
  | asLOWER_ARRAY_DIMENSION_NOT_REGISTERED | When registering an array type the array element must be a primitive or a registered type.
  | asINVALID_TYPE | The array type was not properly formed.
  | asNOT_SUPPORTED | The 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

virtual int asIScriptEngine::RegisterObjectProperty | ( | const char * | obj,
|  | const char * | declaration,
|  | int | byteOffset |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | obj | The name of the type.
  `[in]` | declaration | The property declaration in script syntax.
  `[in]` | byteOffset | The offset into the memory block where this property is found.

Returns:
  A negative value on error.

Return values:

  | asWRONG_CONFIG_GROUP | The object type was registered in a different configuration group.
  | asINVALID_OBJECT | The obj does not specify an object type.
  | asINVALID_TYPE | The obj parameter has invalid syntax.
  | asINVALID_DECLARATION | The declaration is invalid.
  | asNAME_TAKEN | The 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 offsetof macro from stddef.h.

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

virtual int asIScriptEngine::RegisterObjectMethod | ( | const char * | obj,
|  | const char * | declaration,
|  | const asSFuncPtr & | funcPointer,
|  | asDWORD | callConv |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | obj | The name of the type.
  `[in]` | declaration | The declaration of the method in script syntax.
  `[in]` | funcPointer | The method or function pointer.
  `[in]` | callConv | The calling convention for the method or function.

Returns:
  A negative value on error, or the function id if successful.

Return values:

  | asWRONG_CONFIG_GROUP | The object type was registered in a different configuration group.
  | asNOT_SUPPORTED | The calling convention is not supported.
  | asINVALID_TYPE | The obj parameter is not a valid object name.
  | asINVALID_DECLARATION | The declaration is invalid.
  | asNAME_TAKEN | The name conflicts with other members.
  | asWRONG_CALLING_CONV | The function's calling convention isn't compatible with callConv.

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.

See also:
  Registering a function

virtual int asIScriptEngine::RegisterObjectBehaviour | ( | const char * | obj,
|  | asEBehaviours | behaviour,
|  | const char * | declaration,
|  | const asSFuncPtr & | funcPointer,
|  | asDWORD | callConv |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | obj | The name of the type.
  `[in]` | behaviour | One of the object behaviours from asEBehaviours.
  `[in]` | declaration | The declaration of the method in script syntax.
  `[in]` | funcPointer | The method or function pointer.
  `[in]` | callConv | The calling convention for the method or function.

Returns:
  A negative value on error, or the function id is successful.

Return values:

  | asWRONG_CONFIG_GROUP | The object type was registered in a different configuration group.
  | asINVALID_ARG | obj is not set, or a global behaviour is given in behaviour.
  | asWRONG_CALLING_CONV | The function's calling convention isn't compatible with callConv.
  | asNOT_SUPPORTED | The calling convention or the behaviour signature is not supported.
  | asINVALID_TYPE | The obj parameter is not a valid object name.
  | asINVALID_DECLARATION | The declaration is invalid.
  | asILLEGAL_BEHAVIOUR_FOR_TYPE | The behaviour is not allowed for this type.
  | asALREADY_REGISTERED | The 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.

See also:
  Registering a function, Type behaviours

virtual int asIScriptEngine::RegisterGlobalProperty | ( | const char * | declaration,
|  | void * | pointer |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | declaration | The declaration of the global property in script syntax.
  `[in]` | pointer | The address of the property that will be used to access the property value.

Returns:
  A negative value on error.

Return values:

  | asINVALID_DECLARATION | The declaration has invalid syntax.
  | asINVALID_TYPE | The declaration is a reference.
  | asNAME_TAKEN | The 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.

virtual int asIScriptEngine::RegisterGlobalFunction | ( | const char * | declaration,
|  | const asSFuncPtr & | funcPointer,
|  | asDWORD | callConv |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | declaration | The declaration of the global function in script syntax.
  `[in]` | funcPointer | The function pointer.
  `[in]` | callConv | The calling convention for the function.

Returns:
  A negative value on error, or the function id if successful.

Return values:

  | asNOT_SUPPORTED | The calling convention is not supported.
  | asWRONG_CALLING_CONV | The function's calling convention doesn't match callConv.
  | asINVALID_DECLARATION | The function declaration is invalid.
  | asNAME_TAKEN | The function name is already used elsewhere.

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

See also:
  Registering a function

virtual int asIScriptEngine::RegisterGlobalBehaviour | ( | asEBehaviours | behaviour,
|  | const char * | declaration,
|  | const asSFuncPtr & | funcPointer,
|  | asDWORD | callConv |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | behaviour | The global behaviour.
  `[in]` | declaration | The declaration of the behaviour function in script syntax.
  `[in]` | funcPointer | The function pointer.
  `[in]` | callConv | The calling convention for the function.

Returns:
  A negative value on error, or the function id if successful.

Return values:

  | asNOT_SUPPORTED | The calling convention is not supported.
  | asWRONG_CALLING_CONV | The function's calling convention doesn't match callConv.
  | asINVALID_DECLARATION | The function declaration is invalid.
  | asINVALID_ARG | The behaviour is not a global behaviour.

By registering behaviour functions for a data type AngelScript is able to improve object handling. You can for example easily control how references are counted, or create objects that can be manipulated in expressions through operators.

Behaviours may only be registered for object types registered by the application.

Behaviours shouldn't be registered to take handles as their parameters, use references instead. Unlike functions, methods, and constructors, overloaded operators may receive a reference to the true object instead of a dummy object, but it also may not so don't rely on it. Output references are not supported by behaviours.

If the parameter is sent by reference, then declare it as const, as it may allow the compiler to optimize the code to execute faster.

See also:
  Registering a function, Type behaviours

virtual int asIScriptEngine::RegisterInterface | ( | const char * | name | ) | `[pure virtual]`

Parameters:

  `[in]` | name | The name of the interface.

Returns:
  A negative value on error.

Return values:

  | asINVALID_NAME | The name is null, or a reserved keyword.
  | asALREADY_REGISTERED | An object type with this name already exists.
  | asERROR | The name is not a proper identifier.
  | asNAME_TAKEN | The 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 asIScriptStruct and still be sure that the structure implements certain methods needed by the application.

virtual int asIScriptEngine::RegisterInterfaceMethod | ( | const char * | intf,
|  | const char * | declaration |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | intf | The name of the interface.
  `[in]` | declaration | The method declaration.

Returns:
  A negative value on error.

Return values:

  | asWRONG_CONFIG_GROUP | The interface was registered in another configuration group.
  | asINVALID_TYPE | intf is not an interface type.
  | asINVALID_DECLARATION | The declaration is invalid.
  | asNAME_TAKEN | The method name is already taken.

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

virtual int asIScriptEngine::RegisterEnum | ( | const char * | type | ) | `[pure virtual]`

Parameters:

  `[in]` | type | The name of the enum type.

Returns:
  A negative value on error.

Return values:

  | asINVALID_NAME | type is null.
  | asALREADY_REGISTERED | Another type with this name already exists.
  | asERROR | The type couldn't be parsed.
  | asINVALID_NAME | The type is not an identifier, or it is a reserved keyword.
  | asNAME_TAKEN | The type name is already taken.

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

virtual int asIScriptEngine::RegisterEnumValue | ( | const char * | type,
|  | const char * | name,
|  | int | value |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | type | The name of the enum type.
  `[in]` | name | The name of the enum value.
  `[in]` | value | The integer value of the enum value.

Returns:
  A negative value on error.

Return values:

  | asWRONG_CONFIG_GROUP | The enum type was registered in a different configuration group.
  | asINVALID_TYPE | The type is invalid.
  | asALREADY_REGISTERED | The name is already registered for this enum.

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

virtual int asIScriptEngine::RegisterTypedef | ( | const char * | type,
|  | const char * | decl |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | type | The name of the new typedef
  `[in]` | decl | The datatype that the typedef represents

Returns:
  A negative value on error.

Return values:

  | asINVALID_NAME | The type is null.
  | asALREADY_REGISTERED | A type with the same name already exists.
  | asINVALID_TYPE | The decl is not a primitive type.
  | asINVALID_NAME | The type is not an identifier, or it is a reserved keyword.
  | asNAME_TAKEN | The 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.

virtual int asIScriptEngine::RegisterStringFactory | ( | const char * | datatype,
|  | const asSFuncPtr & | factoryFunc,
|  | asDWORD | callConv |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | datatype | The datatype that the string factory returns
  `[in]` | factoryFunc | The pointer to the factory function
  `[in]` | callConv | The calling convention of the factory function

Returns:
  A negative value on error, or the function id if successful.

Return values:

  | asNOT_SUPPORTED | The calling convention is not supported.
  | asWRONG_CALLING_CONV | The function's calling convention doesn't match callConv.
  | asINVALID_TYPE | The datatype is not a valid type.

Use this function to register a string factory that will be called when the virtual machine finds a string constant in an expression. The string factory function will receive two parameters, the length of the string constant and a pointer to the character data. The factory should return a value to a previously registered type that will represent the string. Example:

     // Our string factory implementation
     std::string StringFactory(unsigned int length, const char *s)
     {
         return std::string(s);
     }

     // Registering the string factory
     int r = engine->RegisterStringFactory("string", asFUNCTION(StringFactory), asCALL_CDECL); assert( r >= 0 );

The example assumes that the std::string type has been registered as the string type, with RegisterObjectType.

virtual int asIScriptEngine::BeginConfigGroup | ( | const char * | groupName | ) | `[pure virtual]`

Parameters:

  `[in]` | groupName | The name of the configuration group

Returns:
  A negative value on error

Return values:

  | asNAME_TAKEN | Another group with the same name already exists.
  | asNOT_SUPPORTED | Nesting 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.

virtual int asIScriptEngine::EndConfigGroup | ( |  | ) | `[pure virtual]`

Returns:
  A negative value on error

Return values:

  | asNOT_SUPPORTED | Can'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.

virtual int asIScriptEngine::RemoveConfigGroup | ( | const char * | groupName | ) | `[pure virtual]`

Parameters:

  `[in]` | groupName | The name of the configuration group

Returns:
  A negative value on error

Return values:

  | asCONFIG_GROUP_IS_IN_USE | The 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.

virtual int asIScriptEngine::SetConfigGroupModuleAccess | ( | const char * | groupName,
|  | const char * | module,
|  | bool | hasAccess |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | groupName | The name of the configuration group
  `[in]` | module | The module name
  `[in]` | hasAccess | Whether the module has access or not to the group members

Returns:
  A negative value on error

Return values:

  | asWRONG_CONFIG_GROUP | No group with the groupName was found.

With this method the application can give modules access to individual configuration groups. This is useful when exposing more than one script interface for various parts of the application, e.g. one interface for GUI handling, another for in-game events, etc.

The default module access is granted. The default for a group can be changed by specifying the modulename asALL_MODULES.

virtual asIScriptModule* asIScriptEngine::GetModule | ( | const char * | module,
|  | asEGMFlags | flag = `asGM_ONLY_IF_EXISTS` |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | module | The name of the module
  `[in]` | flag | One 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.

virtual int asIScriptEngine::DiscardModule | ( | const char * | module | ) | `[pure virtual]`

Parameters:

  `[in]` | module | The name of the module

Returns:
  A negative value on error

Return values:

  | asNO_MODULE | The 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.

virtual asIScriptFunction* asIScriptEngine::GetFunctionDescriptorById | ( | int | funcId | ) | `[pure virtual]`

Parameters:

  `[in]` | funcId | The id of the function or method.

Returns:
  A pointer to the function description interface, or null if not found.

virtual int asIScriptEngine::GetObjectTypeCount | ( |  | ) | `[pure virtual]`

Returns:
  The number of object types known to the engine.

virtual asIObjectType* asIScriptEngine::GetObjectTypeByIndex | ( | asUINT | index | ) | `[pure virtual]`

Parameters:

  `[in]` | index | The index of the type.

Returns:
  The object type interface for the type, or null if not found.

virtual asIObjectType* asIScriptEngine::GetObjectTypeById | ( | int | typeId | ) | `[pure virtual]`

Parameters:

  `[in]` | typeId | The type id of the type.

Returns:
  The object type interface for the type, or null if not found.

virtual int asIScriptEngine::GetTypeIdByDecl | ( | const char * | decl | ) | `[pure virtual]`

Parameters:

  `[in]` | decl | The declaration of the type.

Returns:
  A negative value on error, or the type id of the type.

Return values:

  | asINVALID_TYPE | decl 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 structures, 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.

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.

virtual const char* asIScriptEngine::GetTypeDeclaration | ( | int | typeId,
|  | int * | length = `0` |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | typeId | The type id of the type.
  `[out]` | length | The length of the returned string.

Returns:
  A null terminated string with the type declaration, or null if not found.

virtual int asIScriptEngine::GetSizeOfPrimitiveType | ( | int | typeId | ) | `[pure virtual]`

Parameters:

  `[in]` | typeId | The type id of the type.

Returns:
  The size of the type in bytes.

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.

virtual void* asIScriptEngine::CreateScriptObject | ( | int | typeId | ) | `[pure virtual]`

Parameters:

  `[in]` | typeId | The type id of the object to create.

Returns:
  A pointer to the new object if successful, or null if not.

This method is used to create a script object based on it's type id. The method will allocate the memory and call the object's default constructor. Reference counted objects will have their reference counter set to 1 so the application needs to release the pointer when it will no longer use it.

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

virtual void* asIScriptEngine::CreateScriptObjectCopy | ( | void * | obj,
|  | int | typeId |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | obj | A pointer to the source object.
  `[in]` | typeId | The type id 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.

virtual void asIScriptEngine::CopyScriptObject | ( | void * | dstObj,
|  | void * | srcObj,
|  | int | typeId |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | dstObj | A pointer to the destination object.
  `[in]` | srcObj | A pointer to the source object.
  `[in]` | typeId | The type id of the objects.

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

This only works for objects.

virtual void asIScriptEngine::ReleaseScriptObject | ( | void * | obj,
|  | int | typeId |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | obj | A pointer to the object.
  `[in]` | typeId | The type id of the object.

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

This only works for objects.

virtual void asIScriptEngine::AddRefScriptObject | ( | void * | obj,
|  | int | typeId |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | obj | A pointer to the object.
  `[in]` | typeId | The type id of the object.

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

This only works for objects.

virtual bool asIScriptEngine::IsHandleCompatibleWithObject | ( | void * | obj,
|  | int | objTypeId,
|  | int | handleTypeId |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | obj | A pointer to the object.
  `[in]` | objTypeId | The type id of the object.
  `[in]` | handleTypeId | The type id of the handle.

Returns:
  Returns true if the handle type is compatible with the object type.

This method can be used to determine if a handle of a certain type is compatible with an object of another type. This is useful if you have a pointer to a object, but only knows that it implements a certain interface and now you want to determine if it implements another interface.

virtual int asIScriptEngine::CompareScriptObjects | ( | bool & | result,
|  | int | behaviour,
|  | void * | leftObj,
|  | void * | rightObj,
|  | int | typeId |
| ) |  |  | `[pure virtual]`

Parameters:

  `[out]` | result | The result of the comparison
  `[in]` | behaviour | One of the comparison behaviours from asEBehaviours.
  `[in]` | leftObj | A pointer to the left object.
  `[in]` | rightObj | A pointer to the right object.
  `[in]` | typeId | The type id of the objects.

Returns:
  A negative value on error.

Return values:

  | asINVALID_TYPE | The typeId must be an object type.
  | asINVALID_ARG | The behaviour must be one of the comparison behaviours.
  | asNOT_SUPPORTED | The comparison operator is not supported by this type.

This method will allow the application compare two object types without having to know the exact type of the objects being compared. The function will only work on objects, and then only on those objects that permit comparisons, i.e. registered types that have the comparison behaviours registered.

virtual asETokenClass asIScriptEngine::ParseToken | ( | const char * | string,
|  | size_t | stringLength = `0`,
|  | int * | tokenLength = `0` |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | string | The string to parse.
  `[in]` | stringLength | The length of the string. Can be 0 if the string is null terminated.
  `[out]` | tokenLength | Gives 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.

virtual int asIScriptEngine::ExecuteString | ( | const char * | module,
|  | const char * | script,
|  | asIScriptContext ** | ctx = `0`,
|  | asDWORD | flags = `0` |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | module | The name of the module in which the string should be executed.
  `[in]` | script | The script string that will be executed.
  `[in,out]` | ctx | Either pass in your own context or receive the default context, depending on the flags parameter.
  `[in]` | flags | A combination of the values from asEExecStrFlags.

Returns:
  One of asEContextState values, or a negative value on compiler error.

Return values:

  | asINVALID_CONFIGURATION | The engine configuration is invalid.
  | asINVALID_ARG | ctx is null and flags is asEXECSTRING_USE_MY_CONTEXT.
  | asERROR | The string failed to build.
  | asCONTEXT_ACTIVE | The context is already active or in suspended state.
  | asBUILD_IN_PROGRESS | Another thread is currently building.
  | asEXECUTION_PREPARED | The context has been prepared and is ready for execution.
  | asEXECUTION_ABORTED | The execution was aborted with a call to asIScriptContext::Abort.
  | asEXECUTION_SUSPENDED | The execution was suspended with a call to asIScriptContext::Suspend.
  | asEXECUTION_FINISHED | The execution finished successfully.
  | asEXECUTION_EXCEPTION | The execution ended with an exception.

This method allow an application to interpret script statements using the currently compiled code.

virtual int asIScriptEngine::GarbageCollect | ( | asEGCFlags | flags = `asGC_FULL_CYCLE` | ) | `[pure virtual]`

Parameters:

  `[in]` | flags | Set to a combination of the asEGCFlags.

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

virtual void asIScriptEngine::GetGCStatistics | ( | asUINT * | currentSize,
|  | asUINT * | totalDestroyed = `0`,
|  | asUINT * | totalDetected = `0` |
| ) |  |  | `[pure virtual]`

Parameters:

  `[out]` | currentSize | The current number of objects known to the garbage collector.
  `[out]` | totalDestroyed | The total number of objects destroyed by the garbage collector.
  `[out]` | totalDetected | The total number of objects detected as garbage with circular references.

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

virtual void asIScriptEngine::NotifyGarbageCollectorOfNewObject | ( | void * | obj,
|  | int | typeId |
| ) |  |  | `[pure virtual]`

Parameters:

  `[in]` | obj | A pointer to the newly created object.
  `[in]` | typeId | The type id of the object.

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:
  Implementing a garbage collected object

virtual void asIScriptEngine::GCEnumCallback | ( | void * | reference | ) | `[pure virtual]`

Parameters:

  `[in]` | reference | A pointer to the referenced object.

When processing the EnumReferences call the called object should call GCEnumCallback for each of the references it holds to other objects.

See also:
  Implementing a garbage collected object

virtual void* asIScriptEngine::SetUserData | ( | void * | data | ) | `[pure virtual]`

Parameters:

  `[in]` | data | A pointer to the user data.

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.

virtual void* asIScriptEngine::GetUserData | ( |  | ) | `[pure virtual]`

Returns:
  The pointer to the user data.

virtual int asIScriptEngine::AddScriptSection | ( | const char * | module,
|  | const char * | name,
|  | const char * | code,
|  | size_t | codeLength = `0`,
|  | int | lineOffset = `0` |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::AddScriptSection instead.

virtual int asIScriptEngine::Build | ( | const char * | module | ) | `[pure virtual]`

Deprecated:
  Use asIScriptModule::Build instead.

virtual int asIScriptEngine::Discard | ( | const char * | module | ) | `[pure virtual]`

Deprecated:
  Use DiscardModule instead.

virtual int asIScriptEngine::ResetModule | ( | const char * | module | ) | `[pure virtual]`

Deprecated:
  Use asIScriptModule::ResetGlobalVars instead.

virtual int asIScriptEngine::GetFunctionCount | ( | const char * | module | ) | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetFunctionCount instead.

virtual int asIScriptEngine::GetFunctionIDByIndex | ( | const char * | module,
|  | int | index |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetFunctionIdByIndex instead.

virtual int asIScriptEngine::GetFunctionIDByName | ( | const char * | module,
|  | const char * | name |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetFunctionIdByName instead.

virtual int asIScriptEngine::GetFunctionIDByDecl | ( | const char * | module,
|  | const char * | decl |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetFunctionIdByDecl instead.

virtual asIScriptFunction* asIScriptEngine::GetFunctionDescriptorByIndex | ( | const char * | module,
|  | int | index |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetFunctionDescriptorByIndex instead.

virtual int asIScriptEngine::GetGlobalVarCount | ( | const char * | module | ) | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetGlobalVarCount instead.

virtual int asIScriptEngine::GetGlobalVarIndexByName | ( | const char * | module,
|  | const char * | name |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetGlobalVarIndexByName instead.

virtual int asIScriptEngine::GetGlobalVarIndexByDecl | ( | const char * | module,
|  | const char * | decl |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetGlobalVarIndexByDecl instead.

virtual const char* asIScriptEngine::GetGlobalVarDeclaration | ( | const char * | module,
|  | int | index,
|  | int * | length = `0` |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetGlobalVarDeclaration instead.

virtual const char* asIScriptEngine::GetGlobalVarName | ( | const char * | module,
|  | int | index,
|  | int * | length = `0` |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetGlobalVarName instead.

virtual void* asIScriptEngine::GetAddressOfGlobalVar | ( | const char * | module,
|  | int | index |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetAddressOfGlobalVar instead.

virtual int asIScriptEngine::GetGlobalVarIDByIndex | ( | const char * | module,
|  | int | index |
| ) |  |  | `[pure virtual]`

Deprecated:
  Global variables are uniquely identified by module name and index.

virtual int asIScriptEngine::GetGlobalVarIDByName | ( | const char * | module,
|  | const char * | name |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetGlobalVarIndexByName instead

virtual int asIScriptEngine::GetGlobalVarIDByDecl | ( | const char * | module,
|  | const char * | decl |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetGlobalVarIndexByDecl instead

virtual const char* asIScriptEngine::GetGlobalVarDeclaration | ( | int | gvarID,
|  | int * | length = `0` |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetGlobalVarDeclaration instead

virtual const char* asIScriptEngine::GetGlobalVarName | ( | int | gvarID,
|  | int * | length = `0` |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetGlobalVarName instead

virtual void* asIScriptEngine::GetGlobalVarPointer | ( | int | gvarID | ) | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetAddressOfGlobalVar instead

virtual int asIScriptEngine::GetTypeIdByDecl | ( | const char * | module,
|  | const char * | decl |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use GetTypeIdByDecl or asIScriptModule::GetTypeIdByDecl instead.

virtual int asIScriptEngine::GetImportedFunctionCount | ( | const char * | module | ) | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetImportedFunctionCount instead.

virtual int asIScriptEngine::GetImportedFunctionIndexByDecl | ( | const char * | module,
|  | const char * | decl |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetImportedFunctionIndexByDecl instead.

virtual const char* asIScriptEngine::GetImportedFunctionDeclaration | ( | const char * | module,
|  | int | importIndex,
|  | int * | length = `0` |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetImportedFunctionDeclaration instead.

virtual const char* asIScriptEngine::GetImportedFunctionSourceModule | ( | const char * | module,
|  | int | importIndex,
|  | int * | length = `0` |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::GetImportedFunctionSourceModule instead.

virtual int asIScriptEngine::BindImportedFunction | ( | const char * | module,
|  | int | importIndex,
|  | int | funcId |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::BindImportedFunction instead.

virtual int asIScriptEngine::UnbindImportedFunction | ( | const char * | module,
|  | int | importIndex |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::UnbindImportedFunction instead.

virtual int asIScriptEngine::BindAllImportedFunctions | ( | const char * | module | ) | `[pure virtual]`

Deprecated:
  Use asIScriptModule::BindAllImportedFunctions instead.

virtual int asIScriptEngine::UnbindAllImportedFunctions | ( | const char * | module | ) | `[pure virtual]`

Deprecated:
  Use asIScriptModule::UnbindAllImportedFunctions instead.

virtual int asIScriptEngine::GetObjectsInGarbageCollectorCount | ( |  | ) | `[pure virtual]`

Deprecated:
  Use GetGCStatistics instead.

virtual int asIScriptEngine::SaveByteCode | ( | const char * | module,
|  | asIBinaryStream * | out |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::SaveByteCode instead.

virtual int asIScriptEngine::LoadByteCode | ( | const char * | module,
|  | asIBinaryStream * | in |
| ) |  |  | `[pure virtual]`

Deprecated:
  Use asIScriptModule::LoadByteCode instead.