File: raw_object_handling.rst

package info (click to toggle)
squirrel3 3.1-8.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,380 kB
  • sloc: cpp: 12,722; ansic: 917; makefile: 316; python: 40
file content (163 lines) | stat: -rw-r--r-- 3,736 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
.. _api_ref_raw_object_handling:

===================
Raw object handling
===================

.. _sq_addref:

.. c:function:: void sq_addref(HSQUIRRELVM v, HSQOBJECT* po)

    :param HSQUIRRELVM v: the target VM
    :param HSQOBJECT* po: pointer to an object handler

adds a reference to an object handler.





.. _sq_getobjtypetag:

.. c:function:: SQRESULT sq_getobjtypetag(HSQOBJECT* o, SQUserPointer* typetag)

    :param HSQOBJECT* o: pointer to an object handler
    :param SQUserPointer* typetag: a pointer to the variable that will store the tag
    :returns: a SQRESULT
    :remarks: the function works also with instances. if the taget object is an instance, the typetag of it's base class is fetched.

gets the typetag of a raw object reference(userdata or class).





.. _sq_getrefcount:

.. c:function:: SQUnsignedInteger sq_getrefcount(HSQUIRRELVM v, HSQOBJECT* po)

    :param HSQUIRRELVM v: the target VM
    :param HSQOBJECT* po: object handler

returns the number of references of a given object.





.. _sq_getstackobj:

.. c:function:: SQRESULT sq_getstackobj(HSQUIRRELVM v, SQInteger idx, HSQOBJECT* po)

    :param HSQUIRRELVM v: the target VM
    :param SQInteger idx: index of the target object in the stack
    :param HSQOBJECT* po: pointer to an object handler
    :returns: a SQRESULT

gets an object from the stack and stores it in a object handler.





.. _sq_objtobool:

.. c:function:: SQBool sq_objtobool(HSQOBJECT* po)

    :param HSQOBJECT* po: 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.





.. _sq_objtofloat:

.. c:function:: SQFloat sq_objtofloat(HSQOBJECT* po)

    :param HSQOBJECT* po: 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.





.. _sq_objtointeger:

.. c:function:: SQInteger sq_objtointeger(HSQOBJECT* po)

    :param HSQOBJECT* po: 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.





.. _sq_objtostring:

.. c:function:: const SQChar* sq_objtostring(HSQOBJECT* po)

    :param HSQOBJECT* po: 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.





.. _sq_objtouserpointer:

.. c:function:: SQUserPointer sq_objtouserpointer(HSQOBJECT* po)

    :param HSQOBJECT* po: 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.





.. _sq_pushobject:

.. c:function:: void sq_pushobject(HSQUIRRELVM v, HSQOBJECT obj)

    :param HSQUIRRELVM v: the target VM
    :param HSQOBJECT obj: object handler

push an object referenced by an object handler into the stack.





.. _sq_release:

.. c:function:: SQBool sq_release(HSQUIRRELVM v, HSQOBJECT* po)

    :param HSQUIRRELVM v: the target VM
    :param HSQOBJECT* po: 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 losts all references.

remove a reference from an object handler.





.. _sq_resetobject:

.. c:function:: void sq_resetobject(HSQOBJECT* po)

    :param HSQOBJECT* po: pointer to an object handler
    :remarks: Every object handler has to be initialized with this function.

resets(initialize) an object handler.