ScummVM API documentation
squirrel.h
1 /*
2 Copyright (c) 2003-2017 Alberto Demichelis
3 
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10 
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 THE SOFTWARE.
21 */
22 #ifndef _SQUIRREL_H_
23 #define _SQUIRREL_H_
24 
25 #ifdef _SQ_CONFIG_INCLUDE
26 #include _SQ_CONFIG_INCLUDE
27 #endif
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #ifndef SQUIRREL_API
34 #define SQUIRREL_API extern
35 #endif
36 
37 #if (defined(_WIN64) || defined(_LP64))
38 #ifndef _SQ64
39 #define _SQ64
40 #endif
41 #endif
42 
43 
44 #define SQTrue (1)
45 #define SQFalse (0)
46 
47 struct SQVM;
48 struct SQTable;
49 struct SQArray;
50 struct SQString;
51 struct SQClosure;
52 struct SQGenerator;
53 struct SQNativeClosure;
54 struct SQUserData;
55 struct SQFunctionProto;
56 struct SQRefCounted;
57 struct SQClass;
58 struct SQInstance;
59 struct SQDelegable;
60 struct SQOuter;
61 
62 #include "sqconfig.h"
63 
64 #define SQUIRREL_VERSION _SC("Squirrel 3.1 stable")
65 #define SQUIRREL_COPYRIGHT _SC("Copyright (C) 2003-2017 Alberto Demichelis")
66 #define SQUIRREL_AUTHOR _SC("Alberto Demichelis")
67 #define SQUIRREL_VERSION_NUMBER 310
68 
69 #define SQ_VMSTATE_IDLE 0
70 #define SQ_VMSTATE_RUNNING 1
71 #define SQ_VMSTATE_SUSPENDED 2
72 
73 #define SQUIRREL_EOB 0
74 #define SQ_BYTECODE_STREAM_TAG 0xFAFA
75 
76 #define SQOBJECT_REF_COUNTED 0x08000000
77 #define SQOBJECT_NUMERIC 0x04000000
78 #define SQOBJECT_DELEGABLE 0x02000000
79 #define SQOBJECT_CANBEFALSE 0x01000000
80 
81 #define SQ_MATCHTYPEMASKSTRING (-99999)
82 
83 #define _RT_MASK 0x00FFFFFF
84 #define _RAW_TYPE(type) (type&_RT_MASK)
85 
86 #define _RT_NULL 0x00000001
87 #define _RT_INTEGER 0x00000002
88 #define _RT_FLOAT 0x00000004
89 #define _RT_BOOL 0x00000008
90 #define _RT_STRING 0x00000010
91 #define _RT_TABLE 0x00000020
92 #define _RT_ARRAY 0x00000040
93 #define _RT_USERDATA 0x00000080
94 #define _RT_CLOSURE 0x00000100
95 #define _RT_NATIVECLOSURE 0x00000200
96 #define _RT_GENERATOR 0x00000400
97 #define _RT_USERPOINTER 0x00000800
98 #define _RT_THREAD 0x00001000
99 #define _RT_FUNCPROTO 0x00002000
100 #define _RT_CLASS 0x00004000
101 #define _RT_INSTANCE 0x00008000
102 #define _RT_WEAKREF 0x00010000
103 #define _RT_OUTER 0x00020000
104 
105 typedef enum tagSQObjectType{
106  OT_NULL = (_RT_NULL|SQOBJECT_NUMERIC|SQOBJECT_CANBEFALSE),
107  OT_INTEGER = (_RT_INTEGER|SQOBJECT_NUMERIC|SQOBJECT_CANBEFALSE),
108  OT_FLOAT = (_RT_FLOAT|SQOBJECT_NUMERIC|SQOBJECT_CANBEFALSE),
109  OT_BOOL = (_RT_BOOL|SQOBJECT_NUMERIC|SQOBJECT_CANBEFALSE),
110  OT_STRING = (_RT_STRING|SQOBJECT_REF_COUNTED),
111  OT_TABLE = (_RT_TABLE|SQOBJECT_REF_COUNTED|SQOBJECT_DELEGABLE),
112  OT_ARRAY = (_RT_ARRAY|SQOBJECT_REF_COUNTED),
113  OT_USERDATA = (_RT_USERDATA|SQOBJECT_REF_COUNTED|SQOBJECT_DELEGABLE),
114  OT_CLOSURE = (_RT_CLOSURE|SQOBJECT_REF_COUNTED),
115  OT_NATIVECLOSURE = (_RT_NATIVECLOSURE|SQOBJECT_REF_COUNTED),
116  OT_GENERATOR = (_RT_GENERATOR|SQOBJECT_REF_COUNTED),
117  OT_USERPOINTER = _RT_USERPOINTER,
118  OT_THREAD = (_RT_THREAD|SQOBJECT_REF_COUNTED) ,
119  OT_FUNCPROTO = (_RT_FUNCPROTO|SQOBJECT_REF_COUNTED), //internal usage only
120  OT_CLASS = (_RT_CLASS|SQOBJECT_REF_COUNTED),
121  OT_INSTANCE = (_RT_INSTANCE|SQOBJECT_REF_COUNTED|SQOBJECT_DELEGABLE),
122  OT_WEAKREF = (_RT_WEAKREF|SQOBJECT_REF_COUNTED),
123  OT_OUTER = (_RT_OUTER|SQOBJECT_REF_COUNTED) //internal usage only
124 }SQObjectType;
125 
126 #define ISREFCOUNTED(t) (t&SQOBJECT_REF_COUNTED)
127 
128 
129 typedef union tagSQObjectValue
130 {
131  struct SQTable *pTable;
132  struct SQArray *pArray;
133  struct SQClosure *pClosure;
134  struct SQOuter *pOuter;
135  struct SQGenerator *pGenerator;
136  struct SQNativeClosure *pNativeClosure;
137  struct SQString *pString;
138  struct SQUserData *pUserData;
139  SQInteger nInteger;
140  SQFloat fFloat;
141  SQUserPointer pUserPointer;
142  struct SQFunctionProto *pFunctionProto;
143  struct SQRefCounted *pRefCounted;
144  struct SQDelegable *pDelegable;
145  struct SQVM *pThread;
146  struct SQClass *pClass;
147  struct SQInstance *pInstance;
148  struct SQWeakRef *pWeakRef;
149  SQRawObjectVal raw;
151 
152 
153 typedef struct tagSQObject
154 {
155  SQObjectType _type;
156  SQObjectValue _unVal;
157 }SQObject;
158 
159 typedef struct tagSQMemberHandle{
160  SQBool _static;
161  SQInteger _index;
163 
164 typedef struct tagSQStackInfos{
165  const SQChar* funcname;
166  const SQChar* source;
167  SQInteger line;
168 }SQStackInfos;
169 
170 typedef struct SQVM* HSQUIRRELVM;
171 typedef SQObject HSQOBJECT;
173 typedef SQInteger (*SQFUNCTION)(HSQUIRRELVM);
174 typedef SQInteger (*SQRELEASEHOOK)(SQUserPointer,SQInteger size);
175 typedef void (*SQCOMPILERERROR)(HSQUIRRELVM,const SQChar * /*desc*/,const SQChar * /*source*/,SQInteger /*line*/,SQInteger /*column*/);
176 typedef void (*SQPRINTFUNCTION)(HSQUIRRELVM,const SQChar * ,...);
177 typedef void (*SQDEBUGHOOK)(HSQUIRRELVM /*v*/, SQInteger /*type*/, const SQChar * /*sourcename*/, SQInteger /*line*/, const SQChar * /*funcname*/);
178 typedef SQInteger (*SQWRITEFUNC)(SQUserPointer,SQUserPointer,SQInteger);
179 typedef SQInteger (*SQREADFUNC)(SQUserPointer,SQUserPointer,SQInteger);
180 
181 typedef SQInteger (*SQLEXREADFUNC)(SQUserPointer);
182 
183 typedef struct tagSQRegFunction{
184  const SQChar *name;
185  SQFUNCTION f;
186  SQInteger nparamscheck;
187  const SQChar *typemask;
189 
190 typedef struct tagSQFunctionInfo {
191  SQUserPointer funcid;
192  const SQChar *name;
193  const SQChar *source;
194  SQInteger line;
196 
197 /*vm*/
198 SQUIRREL_API HSQUIRRELVM sq_open(SQInteger initialstacksize);
199 SQUIRREL_API HSQUIRRELVM sq_newthread(HSQUIRRELVM friendvm, SQInteger initialstacksize);
200 SQUIRREL_API void sq_seterrorhandler(HSQUIRRELVM v);
201 SQUIRREL_API void sq_close(HSQUIRRELVM v);
202 SQUIRREL_API void sq_setforeignptr(HSQUIRRELVM v,SQUserPointer p);
203 SQUIRREL_API SQUserPointer sq_getforeignptr(HSQUIRRELVM v);
204 SQUIRREL_API void sq_setsharedforeignptr(HSQUIRRELVM v,SQUserPointer p);
205 SQUIRREL_API SQUserPointer sq_getsharedforeignptr(HSQUIRRELVM v);
206 SQUIRREL_API void sq_setvmreleasehook(HSQUIRRELVM v,SQRELEASEHOOK hook);
207 SQUIRREL_API SQRELEASEHOOK sq_getvmreleasehook(HSQUIRRELVM v);
208 SQUIRREL_API void sq_setsharedreleasehook(HSQUIRRELVM v,SQRELEASEHOOK hook);
209 SQUIRREL_API SQRELEASEHOOK sq_getsharedreleasehook(HSQUIRRELVM v);
210 SQUIRREL_API void sq_setprintfunc(HSQUIRRELVM v, SQPRINTFUNCTION printfunc,SQPRINTFUNCTION errfunc);
211 SQUIRREL_API SQPRINTFUNCTION sq_getprintfunc(HSQUIRRELVM v);
212 SQUIRREL_API SQPRINTFUNCTION sq_geterrorfunc(HSQUIRRELVM v);
213 SQUIRREL_API SQRESULT sq_suspendvm(HSQUIRRELVM v);
214 SQUIRREL_API SQRESULT sq_wakeupvm(HSQUIRRELVM v,SQBool resumedret,SQBool retval,SQBool raiseerror,SQBool throwerror);
215 SQUIRREL_API SQInteger sq_getvmstate(HSQUIRRELVM v);
216 SQUIRREL_API SQInteger sq_getversion();
217 
218 /*compiler*/
219 SQUIRREL_API SQRESULT sq_compile(HSQUIRRELVM v,SQLEXREADFUNC read,SQUserPointer p,const SQChar *sourcename,SQBool raiseerror);
220 SQUIRREL_API SQRESULT sq_compilebuffer(HSQUIRRELVM v,const SQChar *s,SQInteger size,const SQChar *sourcename,SQBool raiseerror);
221 SQUIRREL_API void sq_enabledebuginfo(HSQUIRRELVM v, SQBool enable);
222 SQUIRREL_API void sq_notifyallexceptions(HSQUIRRELVM v, SQBool enable);
223 SQUIRREL_API void sq_setcompilererrorhandler(HSQUIRRELVM v,SQCOMPILERERROR f);
224 
225 /*stack operations*/
226 SQUIRREL_API void sq_push(HSQUIRRELVM v,SQInteger idx);
227 SQUIRREL_API void sq_pop(HSQUIRRELVM v,SQInteger nelemstopop);
228 SQUIRREL_API void sq_poptop(HSQUIRRELVM v);
229 SQUIRREL_API void sq_remove(HSQUIRRELVM v,SQInteger idx);
230 SQUIRREL_API SQInteger sq_gettop(HSQUIRRELVM v);
231 SQUIRREL_API void sq_settop(HSQUIRRELVM v,SQInteger newtop);
232 SQUIRREL_API SQRESULT sq_reservestack(HSQUIRRELVM v,SQInteger nsize);
233 SQUIRREL_API SQInteger sq_cmp(HSQUIRRELVM v);
234 SQUIRREL_API void sq_move(HSQUIRRELVM dest,HSQUIRRELVM src,SQInteger idx);
235 
236 /*object creation handling*/
237 SQUIRREL_API SQUserPointer sq_newuserdata(HSQUIRRELVM v,SQUnsignedInteger size);
238 SQUIRREL_API void sq_newtable(HSQUIRRELVM v);
239 SQUIRREL_API void sq_newtableex(HSQUIRRELVM v,SQInteger initialcapacity);
240 SQUIRREL_API void sq_newarray(HSQUIRRELVM v,SQInteger size);
241 SQUIRREL_API void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars);
242 SQUIRREL_API SQRESULT sq_setparamscheck(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask);
243 SQUIRREL_API SQRESULT sq_bindenv(HSQUIRRELVM v,SQInteger idx);
244 SQUIRREL_API SQRESULT sq_setclosureroot(HSQUIRRELVM v,SQInteger idx);
245 SQUIRREL_API SQRESULT sq_getclosureroot(HSQUIRRELVM v,SQInteger idx);
246 SQUIRREL_API void sq_pushstring(HSQUIRRELVM v,const SQChar *s,SQInteger len);
247 SQUIRREL_API void sq_pushfloat(HSQUIRRELVM v,SQFloat f);
248 SQUIRREL_API void sq_pushinteger(HSQUIRRELVM v,SQInteger n);
249 SQUIRREL_API void sq_pushbool(HSQUIRRELVM v,SQBool b);
250 SQUIRREL_API void sq_pushuserpointer(HSQUIRRELVM v,SQUserPointer p);
251 SQUIRREL_API void sq_pushnull(HSQUIRRELVM v);
252 SQUIRREL_API void sq_pushthread(HSQUIRRELVM v, HSQUIRRELVM thread);
253 SQUIRREL_API SQObjectType sq_gettype(HSQUIRRELVM v,SQInteger idx);
254 SQUIRREL_API SQRESULT sq_typeof(HSQUIRRELVM v,SQInteger idx);
255 SQUIRREL_API SQInteger sq_getsize(HSQUIRRELVM v,SQInteger idx);
256 SQUIRREL_API SQHash sq_gethash(HSQUIRRELVM v, SQInteger idx);
257 SQUIRREL_API SQRESULT sq_getbase(HSQUIRRELVM v,SQInteger idx);
258 SQUIRREL_API SQBool sq_instanceof(HSQUIRRELVM v);
259 SQUIRREL_API SQRESULT sq_tostring(HSQUIRRELVM v,SQInteger idx);
260 SQUIRREL_API void sq_tobool(HSQUIRRELVM v, SQInteger idx, SQBool *b);
261 SQUIRREL_API SQRESULT sq_getstringandsize(HSQUIRRELVM v,SQInteger idx,const SQChar **c,SQInteger *size);
262 SQUIRREL_API SQRESULT sq_getstring(HSQUIRRELVM v,SQInteger idx,const SQChar **c);
263 SQUIRREL_API SQRESULT sq_getinteger(HSQUIRRELVM v,SQInteger idx,SQInteger *i);
264 SQUIRREL_API SQRESULT sq_getfloat(HSQUIRRELVM v,SQInteger idx,SQFloat *f);
265 SQUIRREL_API SQRESULT sq_getbool(HSQUIRRELVM v,SQInteger idx,SQBool *b);
266 SQUIRREL_API SQRESULT sq_getthread(HSQUIRRELVM v,SQInteger idx,HSQUIRRELVM *thread);
267 SQUIRREL_API SQRESULT sq_getuserpointer(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p);
268 SQUIRREL_API SQRESULT sq_getuserdata(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p,SQUserPointer *typetag);
269 SQUIRREL_API SQRESULT sq_settypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag);
270 SQUIRREL_API SQRESULT sq_gettypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer *typetag);
271 SQUIRREL_API void sq_setreleasehook(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook);
272 SQUIRREL_API SQRELEASEHOOK sq_getreleasehook(HSQUIRRELVM v,SQInteger idx);
273 SQUIRREL_API SQChar *sq_getscratchpad(HSQUIRRELVM v,SQInteger minsize);
274 SQUIRREL_API SQRESULT sq_getfunctioninfo(HSQUIRRELVM v,SQInteger level,SQFunctionInfo *fi);
275 SQUIRREL_API SQRESULT sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQInteger *nparams,SQInteger *nfreevars);
276 SQUIRREL_API SQRESULT sq_getclosurename(HSQUIRRELVM v,SQInteger idx);
277 SQUIRREL_API SQRESULT sq_setnativeclosurename(HSQUIRRELVM v,SQInteger idx,const SQChar *name);
278 SQUIRREL_API SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p);
279 SQUIRREL_API SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag);
280 SQUIRREL_API SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger idx, SQInteger udsize);
281 SQUIRREL_API SQRESULT sq_newclass(HSQUIRRELVM v,SQBool hasbase);
282 SQUIRREL_API SQRESULT sq_createinstance(HSQUIRRELVM v,SQInteger idx);
283 SQUIRREL_API SQRESULT sq_setattributes(HSQUIRRELVM v,SQInteger idx);
284 SQUIRREL_API SQRESULT sq_getattributes(HSQUIRRELVM v,SQInteger idx);
285 SQUIRREL_API SQRESULT sq_getclass(HSQUIRRELVM v,SQInteger idx);
286 SQUIRREL_API void sq_weakref(HSQUIRRELVM v,SQInteger idx);
287 SQUIRREL_API SQRESULT sq_getdefaultdelegate(HSQUIRRELVM v,SQObjectType t);
288 SQUIRREL_API SQRESULT sq_getmemberhandle(HSQUIRRELVM v,SQInteger idx,HSQMEMBERHANDLE *handle);
289 SQUIRREL_API SQRESULT sq_getbyhandle(HSQUIRRELVM v,SQInteger idx,const HSQMEMBERHANDLE *handle);
290 SQUIRREL_API SQRESULT sq_setbyhandle(HSQUIRRELVM v,SQInteger idx,const HSQMEMBERHANDLE *handle);
291 
292 /*object manipulation*/
293 SQUIRREL_API void sq_pushroottable(HSQUIRRELVM v);
294 SQUIRREL_API void sq_pushregistrytable(HSQUIRRELVM v);
295 SQUIRREL_API void sq_pushconsttable(HSQUIRRELVM v);
296 SQUIRREL_API SQRESULT sq_setroottable(HSQUIRRELVM v);
297 SQUIRREL_API SQRESULT sq_setconsttable(HSQUIRRELVM v);
298 SQUIRREL_API SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx, SQBool bstatic);
299 SQUIRREL_API SQRESULT sq_deleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval);
300 SQUIRREL_API SQRESULT sq_set(HSQUIRRELVM v,SQInteger idx);
301 SQUIRREL_API SQRESULT sq_get(HSQUIRRELVM v,SQInteger idx);
302 SQUIRREL_API SQRESULT sq_rawget(HSQUIRRELVM v,SQInteger idx);
303 SQUIRREL_API SQRESULT sq_rawset(HSQUIRRELVM v,SQInteger idx);
304 SQUIRREL_API SQRESULT sq_rawdeleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval);
305 SQUIRREL_API SQRESULT sq_newmember(HSQUIRRELVM v,SQInteger idx,SQBool bstatic);
306 SQUIRREL_API SQRESULT sq_rawnewmember(HSQUIRRELVM v,SQInteger idx,SQBool bstatic);
307 SQUIRREL_API SQRESULT sq_arrayappend(HSQUIRRELVM v,SQInteger idx);
308 SQUIRREL_API SQRESULT sq_arraypop(HSQUIRRELVM v,SQInteger idx,SQBool pushval);
309 SQUIRREL_API SQRESULT sq_arrayresize(HSQUIRRELVM v,SQInteger idx,SQInteger newsize);
310 SQUIRREL_API SQRESULT sq_arrayreverse(HSQUIRRELVM v,SQInteger idx);
311 SQUIRREL_API SQRESULT sq_arrayremove(HSQUIRRELVM v,SQInteger idx,SQInteger itemidx);
312 SQUIRREL_API SQRESULT sq_arrayinsert(HSQUIRRELVM v,SQInteger idx,SQInteger destpos);
313 SQUIRREL_API SQRESULT sq_setdelegate(HSQUIRRELVM v,SQInteger idx);
314 SQUIRREL_API SQRESULT sq_getdelegate(HSQUIRRELVM v,SQInteger idx);
315 SQUIRREL_API SQRESULT sq_clone(HSQUIRRELVM v,SQInteger idx);
316 SQUIRREL_API SQRESULT sq_setfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval);
317 SQUIRREL_API SQRESULT sq_next(HSQUIRRELVM v,SQInteger idx);
318 SQUIRREL_API SQRESULT sq_getweakrefval(HSQUIRRELVM v,SQInteger idx);
319 SQUIRREL_API SQRESULT sq_clear(HSQUIRRELVM v,SQInteger idx);
320 
321 /*calls*/
322 SQUIRREL_API SQRESULT sq_call(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror);
323 SQUIRREL_API SQRESULT sq_resume(HSQUIRRELVM v,SQBool retval,SQBool raiseerror);
324 SQUIRREL_API const SQChar *sq_getlocal(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedInteger idx);
325 SQUIRREL_API SQRESULT sq_getcallee(HSQUIRRELVM v);
326 SQUIRREL_API const SQChar *sq_getfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval);
327 SQUIRREL_API SQRESULT sq_throwerror(HSQUIRRELVM v,const SQChar *err);
328 SQUIRREL_API SQRESULT sq_throwobject(HSQUIRRELVM v);
329 SQUIRREL_API void sq_reseterror(HSQUIRRELVM v);
330 SQUIRREL_API void sq_getlasterror(HSQUIRRELVM v);
331 SQUIRREL_API SQRESULT sq_tailcall(HSQUIRRELVM v, SQInteger nparams);
332 
333 /*raw object handling*/
334 SQUIRREL_API SQRESULT sq_getstackobj(HSQUIRRELVM v,SQInteger idx,HSQOBJECT *po);
335 SQUIRREL_API void sq_pushobject(HSQUIRRELVM v,HSQOBJECT obj);
336 SQUIRREL_API void sq_addref(HSQUIRRELVM v,HSQOBJECT *po);
337 SQUIRREL_API SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po);
338 SQUIRREL_API SQUnsignedInteger sq_getrefcount(HSQUIRRELVM v,HSQOBJECT *po);
339 SQUIRREL_API void sq_resetobject(HSQOBJECT *po);
340 SQUIRREL_API const SQChar *sq_objtostring(const HSQOBJECT *o);
341 SQUIRREL_API SQBool sq_objtobool(const HSQOBJECT *o);
342 SQUIRREL_API SQInteger sq_objtointeger(const HSQOBJECT *o);
343 SQUIRREL_API SQFloat sq_objtofloat(const HSQOBJECT *o);
344 SQUIRREL_API SQUserPointer sq_objtouserpointer(const HSQOBJECT *o);
345 SQUIRREL_API SQRESULT sq_getobjtypetag(const HSQOBJECT *o,SQUserPointer * typetag);
346 SQUIRREL_API SQUnsignedInteger sq_getvmrefcount(HSQUIRRELVM v, const HSQOBJECT *po);
347 
348 
349 /*GC*/
350 SQUIRREL_API SQInteger sq_collectgarbage(HSQUIRRELVM v);
351 SQUIRREL_API SQRESULT sq_resurrectunreachable(HSQUIRRELVM v);
352 
353 /*serialization*/
354 SQUIRREL_API SQRESULT sq_writeclosure(HSQUIRRELVM vm,SQWRITEFUNC writef,SQUserPointer up);
355 SQUIRREL_API SQRESULT sq_readclosure(HSQUIRRELVM vm,SQREADFUNC readf,SQUserPointer up);
356 
357 /*mem allocation*/
358 SQUIRREL_API void *sq_malloc(SQUnsignedInteger size);
359 SQUIRREL_API void *sq_realloc(void* p,SQUnsignedInteger oldsize,SQUnsignedInteger newsize);
360 SQUIRREL_API void sq_free(void *p,SQUnsignedInteger size);
361 
362 /*debug*/
363 SQUIRREL_API SQRESULT sq_stackinfos(HSQUIRRELVM v,SQInteger level,SQStackInfos *si);
364 SQUIRREL_API void sq_setdebughook(HSQUIRRELVM v);
365 SQUIRREL_API void sq_setnativedebughook(HSQUIRRELVM v,SQDEBUGHOOK hook);
366 
367 /*UTILITY MACRO*/
368 #define sq_isnumeric(o) ((o)._type&SQOBJECT_NUMERIC)
369 #define sq_istable(o) ((o)._type==OT_TABLE)
370 #define sq_isarray(o) ((o)._type==OT_ARRAY)
371 #define sq_isfunction(o) ((o)._type==OT_FUNCPROTO)
372 #define sq_isclosure(o) ((o)._type==OT_CLOSURE)
373 #define sq_isgenerator(o) ((o)._type==OT_GENERATOR)
374 #define sq_isnativeclosure(o) ((o)._type==OT_NATIVECLOSURE)
375 #define sq_isstring(o) ((o)._type==OT_STRING)
376 #define sq_isinteger(o) ((o)._type==OT_INTEGER)
377 #define sq_isfloat(o) ((o)._type==OT_FLOAT)
378 #define sq_isuserpointer(o) ((o)._type==OT_USERPOINTER)
379 #define sq_isuserdata(o) ((o)._type==OT_USERDATA)
380 #define sq_isthread(o) ((o)._type==OT_THREAD)
381 #define sq_isnull(o) ((o)._type==OT_NULL)
382 #define sq_isclass(o) ((o)._type==OT_CLASS)
383 #define sq_isinstance(o) ((o)._type==OT_INSTANCE)
384 #define sq_isbool(o) ((o)._type==OT_BOOL)
385 #define sq_isweakref(o) ((o)._type==OT_WEAKREF)
386 #define sq_type(o) ((o)._type)
387 
388 /* deprecated */
389 #define sq_createslot(v,n) sq_newslot(v,n,SQFalse)
390 
391 #define SQ_OK (0)
392 #define SQ_ERROR (-1)
393 
394 #define SQ_FAILED(res) (res<0)
395 #define SQ_SUCCEEDED(res) (res>=0)
396 
397 #ifdef __GNUC__
398 # define SQ_UNUSED_ARG(x) x __attribute__((__unused__))
399 #else
400 # define SQ_UNUSED_ARG(x) x
401 #endif
402 
403 #ifdef __cplusplus
404 } /*extern "C"*/
405 #endif
406 
407 #endif /*_SQUIRREL_H_*/
Definition: sqclosure.h:10
Definition: sqvm.h:33
Definition: squirrel.h:164
Definition: sqclass.h:28
Definition: sqtable.h:25
Definition: squirrel.h:190
Definition: sqclosure.h:74
Definition: sqobject.h:339
Definition: sqclosure.h:108
Definition: sqobject.h:98
Definition: sqobject.h:87
Definition: squirrel.h:153
Definition: squserdata.h:5
Definition: squirrel.h:183
Definition: sqclass.h:91
Definition: squirrel.h:129
Definition: sqstring.h:14
Definition: sqclosure.h:147
Definition: sqarray.h:5
Definition: sqfuncproto.h:49
Definition: squirrel.h:159