raw_object_handling.rst 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. .. _api_ref_raw_object_handling:
  2. ===================
  3. Raw object handling
  4. ===================
  5. .. _sq_addref:
  6. .. c:function:: void sq_addref(HSQUIRRELVM v, HSQOBJECT* po)
  7. :param HSQUIRRELVM v: the target VM
  8. :param HSQOBJECT* po: pointer to an object handler
  9. adds a reference to an object handler.
  10. .. _sq_getobjtypetag:
  11. .. c:function:: SQRESULT sq_getobjtypetag(HSQOBJECT* o, SQUserPointer* typetag)
  12. :param HSQOBJECT* o: pointer to an object handler
  13. :param SQUserPointer* typetag: a pointer to the variable that will store the tag
  14. :returns: a SQRESULT
  15. :remarks: the function works also with instances. if the taget object is an instance, the typetag of it's base class is fetched.
  16. gets the typetag of a raw object reference(userdata or class).
  17. .. _sq_getrefcount:
  18. .. c:function:: SQUnsignedInteger sq_getrefcount(HSQUIRRELVM v, HSQOBJECT* po)
  19. :param HSQUIRRELVM v: the target VM
  20. :param HSQOBJECT* po: object handler
  21. returns the number of references of a given object.
  22. .. _sq_getstackobj:
  23. .. c:function:: SQRESULT sq_getstackobj(HSQUIRRELVM v, SQInteger idx, HSQOBJECT* po)
  24. :param HSQUIRRELVM v: the target VM
  25. :param SQInteger idx: index of the target object in the stack
  26. :param HSQOBJECT* po: pointer to an object handler
  27. :returns: a SQRESULT
  28. gets an object from the stack and stores it in a object handler.
  29. .. _sq_objtobool:
  30. .. c:function:: SQBool sq_objtobool(HSQOBJECT* po)
  31. :param HSQOBJECT* po: pointer to an object handler
  32. :remarks: If the object is not a bool will always return false.
  33. return the bool value of a raw object reference.
  34. .. _sq_objtofloat:
  35. .. c:function:: SQFloat sq_objtofloat(HSQOBJECT* po)
  36. :param HSQOBJECT* po: pointer to an object handler
  37. :remarks: If the object is an integer will convert it to float. If the object is not a number will always return 0.
  38. return the float value of a raw object reference.
  39. .. _sq_objtointeger:
  40. .. c:function:: SQInteger sq_objtointeger(HSQOBJECT* po)
  41. :param HSQOBJECT* po: pointer to an object handler
  42. :remarks: If the object is a float will convert it to integer. If the object is not a number will always return 0.
  43. return the integer value of a raw object reference.
  44. .. _sq_objtostring:
  45. .. c:function:: const SQChar* sq_objtostring(HSQOBJECT* po)
  46. :param HSQOBJECT* po: pointer to an object handler
  47. :remarks: If the object doesn't reference a string it returns NULL.
  48. return the string value of a raw object reference.
  49. .. _sq_objtouserpointer:
  50. .. c:function:: SQUserPointer sq_objtouserpointer(HSQOBJECT* po)
  51. :param HSQOBJECT* po: pointer to an object handler
  52. :remarks: If the object doesn't reference a userpointer it returns NULL.
  53. return the userpointer value of a raw object reference.
  54. .. _sq_pushobject:
  55. .. c:function:: void sq_pushobject(HSQUIRRELVM v, HSQOBJECT obj)
  56. :param HSQUIRRELVM v: the target VM
  57. :param HSQOBJECT obj: object handler
  58. push an object referenced by an object handler into the stack.
  59. .. _sq_release:
  60. .. c:function:: SQBool sq_release(HSQUIRRELVM v, HSQOBJECT* po)
  61. :param HSQUIRRELVM v: the target VM
  62. :param HSQOBJECT* po: pointer to an object handler
  63. :returns: SQTrue if the object handler released has lost all is references(the ones added with sq_addref). SQFalse otherwise.
  64. :remarks: the function will reset the object handler to null when it losts all references.
  65. remove a reference from an object handler.
  66. .. _sq_resetobject:
  67. .. c:function:: void sq_resetobject(HSQOBJECT* po)
  68. :param HSQOBJECT* po: pointer to an object handler
  69. :remarks: Every object handler has to be initialized with this function.
  70. resets(initialize) an object handler.