4.8. Raw object handling¶
-
void
sq_addref
(HSQUIRRELVM v, HSQOBJECT * po)¶ Parameters: - v (HSQUIRRELVM) – the target VM
- * po (HSQOBJECT) – pointer to an object handler
adds a reference to an object handler.
-
SQRESULT
sq_getobjtypetag
(HSQOBJECT * o, SQUserPointer * typetag)¶ Parameters: - * o (HSQOBJECT) – pointer to an object handler
- * typetag (SQUserPointer) – a pointer to the variable that will store the tag
Returns: a SQRESULT
Remarks: the function works also with instances. if the target object is an instance, the typetag of it’s base class is fetched.
gets the typetag of a raw object reference(userdata or class).
-
SQUnsignedInteger
sq_getrefcount
(HSQUIRRELVM v, HSQOBJECT * po)¶ Parameters: - v (HSQUIRRELVM) – the target VM
- * po (HSQOBJECT) – object handler
returns the number of references of a given object.
-
SQRESULT
sq_getstackobj
(HSQUIRRELVM v, SQInteger idx, HSQOBJECT * po)¶ Parameters: - v (HSQUIRRELVM) – the target VM
- idx (SQInteger) – index of the target object in the stack
- * po (HSQOBJECT) – pointer to an object handler
Returns: a SQRESULT
gets an object from the stack and stores it in a object handler.
-
SQBool
sq_objtobool
(HSQOBJECT * po)¶ Parameters: - * po (HSQOBJECT) – pointer to an object handler
Remarks: If the object is not a bool will always return false.
return the bool value of a raw object reference.
-
SQFloat
sq_objtofloat
(HSQOBJECT * po)¶ Parameters: - * po (HSQOBJECT) – pointer to an object handler
Remarks: If the object is an integer will convert it to float. If the object is not a number will always return 0.
return the float value of a raw object reference.
-
SQInteger
sq_objtointeger
(HSQOBJECT * po)¶ Parameters: - * po (HSQOBJECT) – pointer to an object handler
Remarks: If the object is a float will convert it to integer. If the object is not a number will always return 0.
return the integer value of a raw object reference.
-
const SQChar*
sq_objtostring
(HSQOBJECT * po)¶ Parameters: - * po (HSQOBJECT) – pointer to an object handler
Remarks: If the object doesn’t reference a string it returns NULL.
return the string value of a raw object reference.
-
SQUserPointer
sq_objtouserpointer
(HSQOBJECT * po)¶ Parameters: - * po (HSQOBJECT) – pointer to an object handler
Remarks: If the object doesn’t reference a userpointer it returns NULL.
return the userpointer value of a raw object reference.
-
void
sq_pushobject
(HSQUIRRELVM v, HSQOBJECT obj)¶ Parameters: - v (HSQUIRRELVM) – the target VM
- obj (HSQOBJECT) – object handler
push an object referenced by an object handler into the stack.
-
SQBool
sq_release
(HSQUIRRELVM v, HSQOBJECT * po)¶ Parameters: - v (HSQUIRRELVM) – the target VM
- * po (HSQOBJECT) – pointer to an object handler
Returns: SQTrue if the object handler released has lost all is references(the ones added with sq_addref). SQFalse otherwise.
Remarks: the function will reset the object handler to null when it loses all references.
remove a reference from an object handler.
-
void
sq_resetobject
(HSQOBJECT * po)¶ Parameters: - * po (HSQOBJECT) – pointer to an object handler
Remarks: Every object handler has to be initialized with this function.
resets(initialize) an object handler.