Public Member Functions | |
virtual int | AddRef ()=0 |
Increase reference counter. | |
virtual int | Release ()=0 |
Decrease reference counter. | |
virtual asIScriptEngine * | GetEngine ()=0 |
Returns a pointer to the engine. | |
virtual asEContextState | GetState ()=0 |
Returns the state of the context. | |
virtual int | Prepare (int funcId)=0 |
Prepares the context for execution of the function identified by funcId. | |
virtual int | Unprepare ()=0 |
Frees resources held by the context. | |
virtual int | SetArgByte (asUINT arg, asBYTE value)=0 |
Sets an 8-bit argument value. | |
virtual int | SetArgWord (asUINT arg, asWORD value)=0 |
Sets a 16-bit argument value. | |
virtual int | SetArgDWord (asUINT arg, asDWORD value)=0 |
Sets a 32-bit integer argument value. | |
virtual int | SetArgQWord (asUINT arg, asQWORD value)=0 |
Sets a 64-bit integer argument value. | |
virtual int | SetArgFloat (asUINT arg, float value)=0 |
Sets a float argument value. | |
virtual int | SetArgDouble (asUINT arg, double value)=0 |
Sets a double argument value. | |
virtual int | SetArgAddress (asUINT arg, void *addr)=0 |
Sets the address of a reference or handle argument. | |
virtual int | SetArgObject (asUINT arg, void *obj)=0 |
Sets the object argument value. | |
virtual void * | GetArgPointer (asUINT arg)=0 |
Returns a pointer to the argument for assignment. | |
virtual int | SetObject (void *obj)=0 |
Sets the object for a class method call. | |
virtual asBYTE | GetReturnByte ()=0 |
Returns the 8-bit return value. | |
virtual asWORD | GetReturnWord ()=0 |
Returns the 16-bit return value. | |
virtual asDWORD | GetReturnDWord ()=0 |
Returns the 32-bit return value. | |
virtual asQWORD | GetReturnQWord ()=0 |
Returns the 64-bit return value. | |
virtual float | GetReturnFloat ()=0 |
Returns the float return value. | |
virtual double | GetReturnDouble ()=0 |
Returns the double return value. | |
virtual void * | GetReturnAddress ()=0 |
Returns the address for a reference or handle return type. | |
virtual void * | GetReturnObject ()=0 |
Return a pointer to the returned object. | |
virtual void * | GetReturnPointer ()=0 |
Returns a pointer to the returned value independent of type. | |
virtual int | Execute ()=0 |
Executes the prepared function. | |
virtual int | Abort ()=0 |
Aborts the execution. | |
virtual int | Suspend ()=0 |
Suspends the execution, which can then be resumed by calling Execute again. | |
virtual int | GetCurrentLineNumber (int *column=0)=0 |
Get the current line number that is being executed. | |
virtual int | GetCurrentFunction ()=0 |
Get the current function that is being executed. | |
virtual int | SetException (const char *string)=0 |
Sets an exception, which aborts the execution. | |
virtual int | GetExceptionLineNumber (int *column=0)=0 |
Returns the line number where the exception occurred. | |
virtual int | GetExceptionFunction ()=0 |
Returns the function id of the function where the exception occurred. | |
virtual const char * | GetExceptionString (int *length=0)=0 |
Returns the exception string text. | |
virtual int | SetLineCallback (asSFuncPtr callback, void *obj, int callConv)=0 |
Sets a line callback function. The function will be called for each executed script statement. | |
virtual void | ClearLineCallback ()=0 |
Removes a previously registered callback. | |
virtual int | SetExceptionCallback (asSFuncPtr callback, void *obj, int callConv)=0 |
Sets an exception callback function. The function will be called if a script exception occurs. | |
virtual void | ClearExceptionCallback ()=0 |
Removes a previously registered callback. | |
virtual int | GetCallstackSize ()=0 |
Returns the size of the callstack, i.e. the number of functions that have yet to complete. | |
virtual int | GetCallstackFunction (int index)=0 |
Returns the function id at the specified callstack level. | |
virtual int | GetCallstackLineNumber (int index, int *column=0)=0 |
Returns the line number at the specified callstack level. | |
virtual int | GetVarCount (int stackLevel=-1)=0 |
Returns the number of local variables at the specified callstack level. | |
virtual const char * | GetVarName (int varIndex, int *length=0, int stackLevel=-1)=0 |
Returns the name of local variable at the specified callstack level. | |
virtual const char * | GetVarDeclaration (int varIndex, int *length=0, int stackLevel=-1)=0 |
Returns the declaration of a local variable at the specified callstack level. | |
virtual int | GetVarTypeId (int varIndex, int stackLevel=-1)=0 |
Returns the type id of a local variable at the specified callstack level. | |
virtual void * | GetVarPointer (int varIndex, int stackLevel=-1)=0 |
Returns a pointer to a local variable at the specified callstack level. | |
virtual int | GetThisTypeId (int stackLevel=-1)=0 |
Returns the type id of the object, if a class method is being executed. | |
virtual void * | GetThisPointer (int stackLevel=-1)=0 |
Returns a pointer to the object, if a class method is being executed. | |
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 asIScriptContext::AddRef | ( | ) | [pure virtual] |
virtual int asIScriptContext::Release | ( | ) | [pure virtual] |
virtual asIScriptEngine* asIScriptContext::GetEngine | ( | ) | [pure virtual] |
virtual asEContextState asIScriptContext::GetState | ( | ) | [pure virtual] |
virtual int asIScriptContext::Prepare | ( | int | funcId | ) | [pure virtual] |
[in] | funcId | The id of the function/method that will be executed. |
asCONTEXT_ACTIVE | The context is still active or suspended. | |
asNO_FUNCTION | The function id doesn't exist. |
virtual int asIScriptContext::Unprepare | ( | ) | [pure virtual] |
asCONTEXT_ACTIVE | The context is still active or suspended. |
[in] | arg | The argument index. |
[in] | value | The value of the argument. |
asCONTEXT_NOT_PREPARED | The context is not in prepared state. | |
asINVALID_ARG | The arg is larger than the number of arguments in the prepared function. | |
asINVALID_TYPE | The argument is not an 8-bit value. |
[in] | arg | The argument index. |
[in] | value | The value of the argument. |
asCONTEXT_NOT_PREPARED | The context is not in prepared state. | |
asINVALID_ARG | The arg is larger than the number of arguments in the prepared function. | |
asINVALID_TYPE | The argument is not a 16-bit value. |
[in] | arg | The argument index. |
[in] | value | The value of the argument. |
asCONTEXT_NOT_PREPARED | The context is not in prepared state. | |
asINVALID_ARG | The arg is larger than the number of arguments in the prepared function. | |
asINVALID_TYPE | The argument is not a 32-bit value. |
[in] | arg | The argument index. |
[in] | value | The value of the argument. |
asCONTEXT_NOT_PREPARED | The context is not in prepared state. | |
asINVALID_ARG | The arg is larger than the number of arguments in the prepared function. | |
asINVALID_TYPE | The argument is not a 64-bit value. |
virtual int asIScriptContext::SetArgFloat | ( | asUINT | arg, | |
float | value | |||
) | [pure virtual] |
[in] | arg | The argument index. |
[in] | value | The value of the argument. |
asCONTEXT_NOT_PREPARED | The context is not in prepared state. | |
asINVALID_ARG | The arg is larger than the number of arguments in the prepared function. | |
asINVALID_TYPE | The argument is not a 32-bit value. |
virtual int asIScriptContext::SetArgDouble | ( | asUINT | arg, | |
double | value | |||
) | [pure virtual] |
[in] | arg | The argument index. |
[in] | value | The value of the argument. |
asCONTEXT_NOT_PREPARED | The context is not in prepared state. | |
asINVALID_ARG | The arg is larger than the number of arguments in the prepared function. | |
asINVALID_TYPE | The argument is not a 64-bit value. |
virtual int asIScriptContext::SetArgAddress | ( | asUINT | arg, | |
void * | addr | |||
) | [pure virtual] |
[in] | arg | The argument index. |
[in] | addr | The address that should be passed in the argument. |
asCONTEXT_NOT_PREPARED | The context is not in prepared state. | |
asINVALID_ARG | The arg is larger than the number of arguments in the prepared function. | |
asINVALID_TYPE | The argument is not a reference or an object handle. |
virtual int asIScriptContext::SetArgObject | ( | asUINT | arg, | |
void * | obj | |||
) | [pure virtual] |
[in] | arg | The argument index. |
[in] | obj | A pointer to the object. |
asCONTEXT_NOT_PREPARED | The context is not in prepared state. | |
asINVALID_ARG | The arg is larger than the number of arguments in the prepared function. | |
asINVALID_TYPE | The argument is not an object or handle. |
virtual void* asIScriptContext::GetArgPointer | ( | asUINT | arg | ) | [pure virtual] |
[in] | arg | The argument index. |
virtual int asIScriptContext::SetObject | ( | void * | obj | ) | [pure virtual] |
[in] | obj | A pointer to the object. |
asCONTEXT_NOT_PREPARED | The context is not in prepared state. | |
asERROR | The prepared function is not a class method. |
virtual asBYTE asIScriptContext::GetReturnByte | ( | ) | [pure virtual] |
virtual asWORD asIScriptContext::GetReturnWord | ( | ) | [pure virtual] |
virtual asDWORD asIScriptContext::GetReturnDWord | ( | ) | [pure virtual] |
virtual asQWORD asIScriptContext::GetReturnQWord | ( | ) | [pure virtual] |
virtual float asIScriptContext::GetReturnFloat | ( | ) | [pure virtual] |
virtual double asIScriptContext::GetReturnDouble | ( | ) | [pure virtual] |
virtual void* asIScriptContext::GetReturnAddress | ( | ) | [pure virtual] |
virtual void* asIScriptContext::GetReturnObject | ( | ) | [pure virtual] |
virtual void* asIScriptContext::GetReturnPointer | ( | ) | [pure virtual] |
virtual int asIScriptContext::Execute | ( | ) | [pure virtual] |
asERROR | Invalid context object, the context is not prepared, or it is not in suspended state. | |
asEXECUTION_ABORTED | The execution was aborted with a call to Abort. | |
asEXECUTION_SUSPENDED | The execution was suspended with a call to Suspend. | |
asEXECUTION_FINISHED | The execution finished successfully. | |
asEXECUTION_EXCEPTION | The execution ended with an exception. |
Note that if the script freezes, e.g. if trapped in a never ending loop, you may call Abort from another thread to stop execution.
virtual int asIScriptContext::Abort | ( | ) | [pure virtual] |
asERROR | Invalid context object. |
virtual int asIScriptContext::Suspend | ( | ) | [pure virtual] |
asERROR | Invalid context object. |
virtual int asIScriptContext::GetCurrentLineNumber | ( | int * | column = 0 |
) | [pure virtual] |
[out] | column | The variable will receive the column number. |
virtual int asIScriptContext::GetCurrentFunction | ( | ) | [pure virtual] |
virtual int asIScriptContext::SetException | ( | const char * | string | ) | [pure virtual] |
[in] | string | A string that describes the exception that occurred. |
asERROR | The context isn't currently calling an application registered function. |
Note that if your system function sets an exception, it should not return any object references because the engine will not release the returned reference.
virtual int asIScriptContext::GetExceptionLineNumber | ( | int * | column = 0 |
) | [pure virtual] |
[out] | column | The variable will receive the column number. |
virtual int asIScriptContext::GetExceptionFunction | ( | ) | [pure virtual] |
virtual const char* asIScriptContext::GetExceptionString | ( | int * | length = 0 |
) | [pure virtual] |
[out] | length | The length of the returned string. |
virtual int asIScriptContext::SetLineCallback | ( | asSFuncPtr | callback, | |
void * | obj, | |||
int | callConv | |||
) | [pure virtual] |
[in] | callback | The callback function/method that should be called for each script line executed. |
[in] | obj | The object pointer on which the callback is called. |
[in] | callConv | The calling convention of the callback function/method. |
asNOT_SUPPORTED | Calling convention must not be asCALL_GENERIC, or the routine's calling convention is not supported. | |
asINVALID_ARG | obj must not be null for class methods. | |
asWRONG_CALLING_CONV | callConv isn't compatible with the routines' calling convention. |
The callback function can be either a global function or a class method. For a global function the VM will pass two parameters, first the context pointer and then the object pointer specified by the application. For a class method, the VM will call the method using the object pointer as the owner.
void Callback(asIScriptContext *ctx, void *obj); void Object::Callback(asIScriptContext *ctx);
The global function can use either asCALL_CDECL or asCALL_STDCALL, and the class method can use either asCALL_THISCALL, asCALL_CDECL_OBJLAST, or asCALL_CDECL_OBJFIRST.
virtual void asIScriptContext::ClearLineCallback | ( | ) | [pure virtual] |
Removes a previously registered callback.
virtual int asIScriptContext::SetExceptionCallback | ( | asSFuncPtr | callback, | |
void * | obj, | |||
int | callConv | |||
) | [pure virtual] |
[in] | callback | The callback function/method that should be called upon an exception. |
[in] | obj | The object pointer on which the callback is called. |
[in] | callConv | The calling convention of the callback function/method. |
asNOT_SUPPORTED | Calling convention must not be asCALL_GENERIC, or the routine's calling convention is not supported. | |
asINVALID_ARG | obj must not be null for class methods. | |
asWRONG_CALLING_CONV | callConv isn't compatible with the routines' calling convention. |
See SetLineCallback for details on the calling convention.
virtual void asIScriptContext::ClearExceptionCallback | ( | ) | [pure virtual] |
Removes a previously registered callback.
virtual int asIScriptContext::GetCallstackSize | ( | ) | [pure virtual] |
virtual int asIScriptContext::GetCallstackFunction | ( | int | index | ) | [pure virtual] |
[in] | index | The index on the call stack. |
virtual int asIScriptContext::GetCallstackLineNumber | ( | int | index, | |
int * | column = 0 | |||
) | [pure virtual] |
[in] | index | The index on the call stack. |
[out] | column | The variable will receive the column number. |
virtual int asIScriptContext::GetVarCount | ( | int | stackLevel = -1 |
) | [pure virtual] |
[in] | stackLevel | The index on the call stack. |
virtual const char* asIScriptContext::GetVarName | ( | int | varIndex, | |
int * | length = 0 , |
|||
int | stackLevel = -1 | |||
) | [pure virtual] |
[in] | varIndex | The index of the variable. |
[out] | length | The length of the returned string. |
[in] | stackLevel | The index on the call stack. |
virtual const char* asIScriptContext::GetVarDeclaration | ( | int | varIndex, | |
int * | length = 0 , |
|||
int | stackLevel = -1 | |||
) | [pure virtual] |
[in] | varIndex | The index of the variable. |
[out] | length | The length of the returned string. |
[in] | stackLevel | The index on the call stack. |
virtual int asIScriptContext::GetVarTypeId | ( | int | varIndex, | |
int | stackLevel = -1 | |||
) | [pure virtual] |
[in] | varIndex | The index of the variable. |
[in] | stackLevel | The index on the call stack. |
virtual void* asIScriptContext::GetVarPointer | ( | int | varIndex, | |
int | stackLevel = -1 | |||
) | [pure virtual] |
[in] | varIndex | The index of the variable. |
[in] | stackLevel | The index on the call stack. |
The address points to the position in the stack where the variable is stored. As primitives are stored directly on the stack, the value of primitive types is gotten by dereferencing the pointer. Object variables are not stored directly on the stack, instead the stack holds a pointer to the object. Thus for object types the object is gotten by dereferencing the pointer twice.
Note that object variables may not be initalized at all moments, thus you must verify if the address returned points to a null pointer, before you try to dereference it.
virtual int asIScriptContext::GetThisTypeId | ( | int | stackLevel = -1 |
) | [pure virtual] |
[in] | stackLevel | The index on the call stack. |
virtual void* asIScriptContext::GetThisPointer | ( | int | stackLevel = -1 |
) | [pure virtual] |
[in] | stackLevel | The index on the call stack. |
virtual void* asIScriptContext::SetUserData | ( | void * | data | ) | [pure virtual] |
[in] | data | A pointer to the user data. |
virtual void* asIScriptContext::GetUserData | ( | ) | [pure virtual] |