Update Squirrel to 2.2.2 (although README says 2.2.1)
[supertux.git] / src / squirrel / include / squirrel.h
1 /*
2 Copyright (c) 2003-2008 Alberto Demichelis
3
4 This software is provided 'as-is', without any 
5 express or implied warranty. In no event will the 
6 authors be held liable for any damages arising from 
7 the use of this software.
8
9 Permission is granted to anyone to use this software 
10 for any purpose, including commercial applications, 
11 and to alter it and redistribute it freely, subject 
12 to the following restrictions:
13
14                 1. The origin of this software must not be 
15                 misrepresented; you must not claim that 
16                 you wrote the original software. If you 
17                 use this software in a product, an 
18                 acknowledgment in the product 
19                 documentation would be appreciated but is 
20                 not required.
21
22                 2. Altered source versions must be plainly 
23                 marked as such, and must not be 
24                 misrepresented as being the original 
25                 software.
26
27                 3. This notice may not be removed or 
28                 altered from any source distribution.
29
30 */
31 #ifndef _SQUIRREL_H_
32 #define _SQUIRREL_H_
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 #ifndef SQUIRREL_API
39 #define SQUIRREL_API extern
40 #endif
41
42 #if (defined(_WIN64) || defined(_LP64))
43 #define _SQ64
44 #endif
45
46 #ifdef _SQ64
47 #ifdef _MSC_VER
48 typedef __int64 SQInteger;
49 typedef unsigned __int64 SQUnsignedInteger;
50 typedef unsigned __int64 SQHash; /*should be the same size of a pointer*/
51 #else
52 typedef long SQInteger;
53 typedef unsigned long SQUnsignedInteger;
54 typedef unsigned long SQHash; /*should be the same size of a pointer*/
55 #endif
56 typedef int SQInt32; 
57 #else 
58 typedef int SQInteger;
59 typedef int SQInt32; /*must be 32 bits(also on 64bits processors)*/
60 typedef unsigned int SQUnsignedInteger;
61 typedef unsigned int SQHash; /*should be the same size of a pointer*/
62 #endif
63
64
65 typedef float SQFloat;
66 typedef void* SQUserPointer;
67 typedef SQUnsignedInteger SQBool;
68 typedef SQInteger SQRESULT;
69
70 #define SQTrue  (1)
71 #define SQFalse (0)
72
73 struct SQVM;
74 struct SQTable;
75 struct SQArray;
76 struct SQString;
77 struct SQClosure;
78 struct SQGenerator;
79 struct SQNativeClosure;
80 struct SQUserData;
81 struct SQFunctionProto;
82 struct SQRefCounted;
83 struct SQClass;
84 struct SQInstance;
85 struct SQDelegable;
86
87 #ifdef _UNICODE
88 #define SQUNICODE
89 #endif
90
91 #ifdef SQUNICODE
92 #if (defined(_MSC_VER) && _MSC_VER >= 1400) // 1400 = VS8
93
94 #if defined(wchar_t) //this is if the compiler considers wchar_t as native type
95 #define wchar_t unsigned short
96 #endif
97
98 #else
99 typedef unsigned short wchar_t;
100 #endif
101
102 typedef wchar_t SQChar;
103 #define _SC(a) L##a
104 #define scstrcmp        wcscmp
105 #define scsprintf       swprintf
106 #define scstrlen        wcslen
107 #define scstrtod        wcstod
108 #define scstrtol        wcstol
109 #define scatoi          _wtoi
110 #define scstrtoul       wcstoul
111 #define scvsprintf      vswprintf
112 #define scstrstr        wcsstr
113 #define scisspace       iswspace
114 #define scisdigit       iswdigit
115 #define scisxdigit      iswxdigit
116 #define scisalpha       iswalpha
117 #define sciscntrl       iswcntrl
118 #define scisalnum       iswalnum
119 #define scprintf        wprintf
120 #define MAX_CHAR 0xFFFF
121 #else
122 typedef char SQChar;
123 #define _SC(a) a
124 #define scstrcmp        strcmp
125 #define scsprintf       sprintf
126 #define scstrlen        strlen
127 #define scstrtod        strtod
128 #define scstrtol        strtol
129 #define scatoi          atoi
130 #define scstrtoul       strtoul
131 #define scvsprintf      vsprintf
132 #define scstrstr        strstr
133 #define scisspace       isspace
134 #define scisdigit       isdigit
135 #define scisxdigit      isxdigit
136 #define sciscntrl       iscntrl
137 #define scisalpha       isalpha
138 #define scisalnum       isalnum
139 #define scprintf        printf
140 #define MAX_CHAR 0xFF
141 #endif
142
143 #define SQUIRREL_VERSION        _SC("Squirrel 2.2.2 stable")
144 #define SQUIRREL_COPYRIGHT      _SC("Copyright (C) 2003-2008 Alberto Demichelis")
145 #define SQUIRREL_AUTHOR         _SC("Alberto Demichelis")
146
147 #define SQ_VMSTATE_IDLE                 0
148 #define SQ_VMSTATE_RUNNING              1
149 #define SQ_VMSTATE_SUSPENDED    2
150
151 #define SQUIRREL_EOB 0
152 #define SQ_BYTECODE_STREAM_TAG  0xFAFA
153
154 #define SQOBJECT_REF_COUNTED    0x08000000
155 #define SQOBJECT_NUMERIC                0x04000000
156 #define SQOBJECT_DELEGABLE              0x02000000
157 #define SQOBJECT_CANBEFALSE             0x01000000
158
159 #define SQ_MATCHTYPEMASKSTRING (-99999)
160
161 #define _RT_MASK 0x00FFFFFF
162 #define _RAW_TYPE(type) (type&_RT_MASK)
163
164 #define _RT_NULL                        0x00000001
165 #define _RT_INTEGER                     0x00000002
166 #define _RT_FLOAT                       0x00000004
167 #define _RT_BOOL                        0x00000008
168 #define _RT_STRING                      0x00000010
169 #define _RT_TABLE                       0x00000020
170 #define _RT_ARRAY                       0x00000040
171 #define _RT_USERDATA            0x00000080
172 #define _RT_CLOSURE                     0x00000100
173 #define _RT_NATIVECLOSURE       0x00000200
174 #define _RT_GENERATOR           0x00000400
175 #define _RT_USERPOINTER         0x00000800
176 #define _RT_THREAD                      0x00001000
177 #define _RT_FUNCPROTO           0x00002000
178 #define _RT_CLASS                       0x00004000
179 #define _RT_INSTANCE            0x00008000
180 #define _RT_WEAKREF                     0x00010000
181
182 typedef enum tagSQObjectType{
183         OT_NULL =                       (_RT_NULL|SQOBJECT_CANBEFALSE),
184         OT_INTEGER =            (_RT_INTEGER|SQOBJECT_NUMERIC|SQOBJECT_CANBEFALSE),
185         OT_FLOAT =                      (_RT_FLOAT|SQOBJECT_NUMERIC|SQOBJECT_CANBEFALSE),
186         OT_BOOL =                       (_RT_BOOL|SQOBJECT_CANBEFALSE),
187         OT_STRING =                     (_RT_STRING|SQOBJECT_REF_COUNTED),
188         OT_TABLE =                      (_RT_TABLE|SQOBJECT_REF_COUNTED|SQOBJECT_DELEGABLE),
189         OT_ARRAY =                      (_RT_ARRAY|SQOBJECT_REF_COUNTED),
190         OT_USERDATA =           (_RT_USERDATA|SQOBJECT_REF_COUNTED|SQOBJECT_DELEGABLE),
191         OT_CLOSURE =            (_RT_CLOSURE|SQOBJECT_REF_COUNTED),
192         OT_NATIVECLOSURE =      (_RT_NATIVECLOSURE|SQOBJECT_REF_COUNTED),
193         OT_GENERATOR =          (_RT_GENERATOR|SQOBJECT_REF_COUNTED),
194         OT_USERPOINTER =        _RT_USERPOINTER,
195         OT_THREAD =                     (_RT_THREAD|SQOBJECT_REF_COUNTED) ,
196         OT_FUNCPROTO =          (_RT_FUNCPROTO|SQOBJECT_REF_COUNTED), //internal usage only
197         OT_CLASS =                      (_RT_CLASS|SQOBJECT_REF_COUNTED),
198         OT_INSTANCE =           (_RT_INSTANCE|SQOBJECT_REF_COUNTED|SQOBJECT_DELEGABLE),
199         OT_WEAKREF =            (_RT_WEAKREF|SQOBJECT_REF_COUNTED)
200 }SQObjectType;
201
202 #define ISREFCOUNTED(t) (t&SQOBJECT_REF_COUNTED)
203
204
205 typedef union tagSQObjectValue
206 {
207         struct SQTable *pTable;
208         struct SQArray *pArray;
209         struct SQClosure *pClosure;
210         struct SQGenerator *pGenerator;
211         struct SQNativeClosure *pNativeClosure;
212         struct SQString *pString;
213         struct SQUserData *pUserData;
214         SQInteger nInteger;
215         SQFloat fFloat;
216         SQUserPointer pUserPointer;
217         struct SQFunctionProto *pFunctionProto;
218         struct SQRefCounted *pRefCounted;
219         struct SQDelegable *pDelegable;
220         struct SQVM *pThread;
221         struct SQClass *pClass;
222         struct SQInstance *pInstance;
223         struct SQWeakRef *pWeakRef;
224 }SQObjectValue;
225
226
227 typedef struct tagSQObject
228 {
229         SQObjectType _type;
230         SQObjectValue _unVal;
231 }SQObject;
232
233 typedef struct tagSQStackInfos{
234         const SQChar* funcname;
235         const SQChar* source;
236         SQInteger line;
237 }SQStackInfos;
238
239 typedef struct SQVM* HSQUIRRELVM;
240 typedef SQObject HSQOBJECT;
241 typedef SQInteger (*SQFUNCTION)(HSQUIRRELVM);
242 typedef SQInteger (*SQRELEASEHOOK)(SQUserPointer,SQInteger size);
243 typedef void (*SQCOMPILERERROR)(HSQUIRRELVM,const SQChar * /*desc*/,const SQChar * /*source*/,SQInteger /*line*/,SQInteger /*column*/);
244 typedef void (*SQPRINTFUNCTION)(HSQUIRRELVM,const SQChar * ,...);
245
246 typedef SQInteger (*SQWRITEFUNC)(SQUserPointer,SQUserPointer,SQInteger);
247 typedef SQInteger (*SQREADFUNC)(SQUserPointer,SQUserPointer,SQInteger);
248
249 typedef SQInteger (*SQLEXREADFUNC)(SQUserPointer);
250
251 typedef struct tagSQRegFunction{
252         const SQChar *name;
253         SQFUNCTION f;
254         SQInteger nparamscheck;
255         const SQChar *typemask;
256 }SQRegFunction;
257
258 /*vm*/
259 SQUIRREL_API HSQUIRRELVM sq_open(SQInteger initialstacksize);
260 SQUIRREL_API HSQUIRRELVM sq_newthread(HSQUIRRELVM friendvm, SQInteger initialstacksize);
261 SQUIRREL_API void sq_seterrorhandler(HSQUIRRELVM v);
262 SQUIRREL_API void sq_close(HSQUIRRELVM v);
263 SQUIRREL_API void sq_setforeignptr(HSQUIRRELVM v,SQUserPointer p);
264 SQUIRREL_API SQUserPointer sq_getforeignptr(HSQUIRRELVM v);
265 SQUIRREL_API void sq_setprintfunc(HSQUIRRELVM v, SQPRINTFUNCTION printfunc);
266 SQUIRREL_API SQPRINTFUNCTION sq_getprintfunc(HSQUIRRELVM v);
267 SQUIRREL_API SQRESULT sq_suspendvm(HSQUIRRELVM v);
268 SQUIRREL_API SQRESULT sq_wakeupvm(HSQUIRRELVM v,SQBool resumedret,SQBool retval,SQBool raiseerror);
269 SQUIRREL_API SQInteger sq_getvmstate(HSQUIRRELVM v);
270
271 /*compiler*/
272 SQUIRREL_API SQRESULT sq_compile(HSQUIRRELVM v,SQLEXREADFUNC read,SQUserPointer p,const SQChar *sourcename,SQBool raiseerror);
273 SQUIRREL_API SQRESULT sq_compilebuffer(HSQUIRRELVM v,const SQChar *s,SQInteger size,const SQChar *sourcename,SQBool raiseerror);
274 SQUIRREL_API void sq_enabledebuginfo(HSQUIRRELVM v, SQBool enable);
275 SQUIRREL_API void sq_notifyallexceptions(HSQUIRRELVM v, SQBool enable);
276 SQUIRREL_API void sq_setcompilererrorhandler(HSQUIRRELVM v,SQCOMPILERERROR f);
277
278 /*stack operations*/
279 SQUIRREL_API void sq_push(HSQUIRRELVM v,SQInteger idx);
280 SQUIRREL_API void sq_pop(HSQUIRRELVM v,SQInteger nelemstopop);
281 SQUIRREL_API void sq_poptop(HSQUIRRELVM v);
282 SQUIRREL_API void sq_remove(HSQUIRRELVM v,SQInteger idx);
283 SQUIRREL_API SQInteger sq_gettop(HSQUIRRELVM v);
284 SQUIRREL_API void sq_settop(HSQUIRRELVM v,SQInteger newtop);
285 SQUIRREL_API void sq_reservestack(HSQUIRRELVM v,SQInteger nsize);
286 SQUIRREL_API SQInteger sq_cmp(HSQUIRRELVM v);
287 SQUIRREL_API void sq_move(HSQUIRRELVM dest,HSQUIRRELVM src,SQInteger idx);
288
289 /*object creation handling*/
290 SQUIRREL_API SQUserPointer sq_newuserdata(HSQUIRRELVM v,SQUnsignedInteger size);
291 SQUIRREL_API void sq_newtable(HSQUIRRELVM v);
292 SQUIRREL_API void sq_newarray(HSQUIRRELVM v,SQInteger size);
293 SQUIRREL_API void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars);
294 SQUIRREL_API SQRESULT sq_setparamscheck(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask);
295 SQUIRREL_API SQRESULT sq_bindenv(HSQUIRRELVM v,SQInteger idx);
296 SQUIRREL_API void sq_pushstring(HSQUIRRELVM v,const SQChar *s,SQInteger len);
297 SQUIRREL_API void sq_pushfloat(HSQUIRRELVM v,SQFloat f);
298 SQUIRREL_API void sq_pushinteger(HSQUIRRELVM v,SQInteger n);
299 SQUIRREL_API void sq_pushbool(HSQUIRRELVM v,SQBool b);
300 SQUIRREL_API void sq_pushuserpointer(HSQUIRRELVM v,SQUserPointer p);
301 SQUIRREL_API void sq_pushnull(HSQUIRRELVM v);
302 SQUIRREL_API SQObjectType sq_gettype(HSQUIRRELVM v,SQInteger idx);
303 SQUIRREL_API SQInteger sq_getsize(HSQUIRRELVM v,SQInteger idx);
304 SQUIRREL_API SQRESULT sq_getbase(HSQUIRRELVM v,SQInteger idx);
305 SQUIRREL_API SQBool sq_instanceof(HSQUIRRELVM v);
306 SQUIRREL_API void sq_tostring(HSQUIRRELVM v,SQInteger idx);
307 SQUIRREL_API void sq_tobool(HSQUIRRELVM v, SQInteger idx, SQBool *b);
308 SQUIRREL_API SQRESULT sq_getstring(HSQUIRRELVM v,SQInteger idx,const SQChar **c);
309 SQUIRREL_API SQRESULT sq_getinteger(HSQUIRRELVM v,SQInteger idx,SQInteger *i);
310 SQUIRREL_API SQRESULT sq_getfloat(HSQUIRRELVM v,SQInteger idx,SQFloat *f);
311 SQUIRREL_API SQRESULT sq_getbool(HSQUIRRELVM v,SQInteger idx,SQBool *b);
312 SQUIRREL_API SQRESULT sq_getthread(HSQUIRRELVM v,SQInteger idx,HSQUIRRELVM *thread);
313 SQUIRREL_API SQRESULT sq_getuserpointer(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p);
314 SQUIRREL_API SQRESULT sq_getuserdata(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p,SQUserPointer *typetag);
315 SQUIRREL_API SQRESULT sq_settypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag);
316 SQUIRREL_API SQRESULT sq_gettypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer *typetag);
317 SQUIRREL_API void sq_setreleasehook(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook);
318 SQUIRREL_API SQChar *sq_getscratchpad(HSQUIRRELVM v,SQInteger minsize);
319 SQUIRREL_API SQRESULT sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparams,SQUnsignedInteger *nfreevars);
320 SQUIRREL_API SQRESULT sq_setnativeclosurename(HSQUIRRELVM v,SQInteger idx,const SQChar *name);
321 SQUIRREL_API SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p);
322 SQUIRREL_API SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag);
323 SQUIRREL_API SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger idx, SQInteger udsize);
324 SQUIRREL_API SQRESULT sq_newclass(HSQUIRRELVM v,SQBool hasbase);
325 SQUIRREL_API SQRESULT sq_createinstance(HSQUIRRELVM v,SQInteger idx);
326 SQUIRREL_API SQRESULT sq_setattributes(HSQUIRRELVM v,SQInteger idx);
327 SQUIRREL_API SQRESULT sq_getattributes(HSQUIRRELVM v,SQInteger idx);
328 SQUIRREL_API SQRESULT sq_getclass(HSQUIRRELVM v,SQInteger idx);
329 SQUIRREL_API void sq_weakref(HSQUIRRELVM v,SQInteger idx);
330 SQUIRREL_API SQRESULT sq_getdefaultdelegate(HSQUIRRELVM v,SQObjectType t);
331
332 /*object manipulation*/
333 SQUIRREL_API void sq_pushroottable(HSQUIRRELVM v);
334 SQUIRREL_API void sq_pushregistrytable(HSQUIRRELVM v);
335 SQUIRREL_API void sq_pushconsttable(HSQUIRRELVM v);
336 SQUIRREL_API SQRESULT sq_setroottable(HSQUIRRELVM v);
337 SQUIRREL_API SQRESULT sq_setconsttable(HSQUIRRELVM v);
338 SQUIRREL_API SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx, SQBool bstatic);
339 SQUIRREL_API SQRESULT sq_deleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval);
340 SQUIRREL_API SQRESULT sq_set(HSQUIRRELVM v,SQInteger idx);
341 SQUIRREL_API SQRESULT sq_get(HSQUIRRELVM v,SQInteger idx);
342 SQUIRREL_API SQRESULT sq_rawget(HSQUIRRELVM v,SQInteger idx);
343 SQUIRREL_API SQRESULT sq_rawset(HSQUIRRELVM v,SQInteger idx);
344 SQUIRREL_API SQRESULT sq_rawdeleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval);
345 SQUIRREL_API SQRESULT sq_arrayappend(HSQUIRRELVM v,SQInteger idx);
346 SQUIRREL_API SQRESULT sq_arraypop(HSQUIRRELVM v,SQInteger idx,SQBool pushval); 
347 SQUIRREL_API SQRESULT sq_arrayresize(HSQUIRRELVM v,SQInteger idx,SQInteger newsize); 
348 SQUIRREL_API SQRESULT sq_arrayreverse(HSQUIRRELVM v,SQInteger idx); 
349 SQUIRREL_API SQRESULT sq_arrayremove(HSQUIRRELVM v,SQInteger idx,SQInteger itemidx);
350 SQUIRREL_API SQRESULT sq_arrayinsert(HSQUIRRELVM v,SQInteger idx,SQInteger destpos);
351 SQUIRREL_API SQRESULT sq_setdelegate(HSQUIRRELVM v,SQInteger idx);
352 SQUIRREL_API SQRESULT sq_getdelegate(HSQUIRRELVM v,SQInteger idx);
353 SQUIRREL_API SQRESULT sq_clone(HSQUIRRELVM v,SQInteger idx);
354 SQUIRREL_API SQRESULT sq_setfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval);
355 SQUIRREL_API SQRESULT sq_next(HSQUIRRELVM v,SQInteger idx);
356 SQUIRREL_API SQRESULT sq_getweakrefval(HSQUIRRELVM v,SQInteger idx);
357 SQUIRREL_API SQRESULT sq_clear(HSQUIRRELVM v,SQInteger idx);
358
359 /*calls*/
360 SQUIRREL_API SQRESULT sq_call(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror);
361 SQUIRREL_API SQRESULT sq_resume(HSQUIRRELVM v,SQBool retval,SQBool raiseerror);
362 SQUIRREL_API const SQChar *sq_getlocal(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedInteger idx);
363 SQUIRREL_API const SQChar *sq_getfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval);
364 SQUIRREL_API SQRESULT sq_throwerror(HSQUIRRELVM v,const SQChar *err);
365 SQUIRREL_API void sq_reseterror(HSQUIRRELVM v);
366 SQUIRREL_API void sq_getlasterror(HSQUIRRELVM v);
367
368 /*raw object handling*/
369 SQUIRREL_API SQRESULT sq_getstackobj(HSQUIRRELVM v,SQInteger idx,HSQOBJECT *po);
370 SQUIRREL_API void sq_pushobject(HSQUIRRELVM v,HSQOBJECT obj);
371 SQUIRREL_API void sq_addref(HSQUIRRELVM v,HSQOBJECT *po);
372 SQUIRREL_API SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po);
373 SQUIRREL_API void sq_resetobject(HSQOBJECT *po);
374 SQUIRREL_API const SQChar *sq_objtostring(HSQOBJECT *o);
375 SQUIRREL_API SQBool sq_objtobool(HSQOBJECT *o);
376 SQUIRREL_API SQInteger sq_objtointeger(HSQOBJECT *o);
377 SQUIRREL_API SQFloat sq_objtofloat(HSQOBJECT *o);
378 SQUIRREL_API SQRESULT sq_getobjtypetag(HSQOBJECT *o,SQUserPointer * typetag);
379
380 /*GC*/
381 SQUIRREL_API SQInteger sq_collectgarbage(HSQUIRRELVM v);
382
383 /*serialization*/
384 SQUIRREL_API SQRESULT sq_writeclosure(HSQUIRRELVM vm,SQWRITEFUNC writef,SQUserPointer up);
385 SQUIRREL_API SQRESULT sq_readclosure(HSQUIRRELVM vm,SQREADFUNC readf,SQUserPointer up);
386
387 /*mem allocation*/
388 SQUIRREL_API void *sq_malloc(SQUnsignedInteger size);
389 SQUIRREL_API void *sq_realloc(void* p,SQUnsignedInteger oldsize,SQUnsignedInteger newsize);
390 SQUIRREL_API void sq_free(void *p,SQUnsignedInteger size);
391
392 /*debug*/
393 SQUIRREL_API SQRESULT sq_stackinfos(HSQUIRRELVM v,SQInteger level,SQStackInfos *si);
394 SQUIRREL_API void sq_setdebughook(HSQUIRRELVM v);
395
396 /*UTILITY MACRO*/
397 #define sq_isnumeric(o) ((o)._type&SQOBJECT_NUMERIC)
398 #define sq_istable(o) ((o)._type==OT_TABLE)
399 #define sq_isarray(o) ((o)._type==OT_ARRAY)
400 #define sq_isfunction(o) ((o)._type==OT_FUNCPROTO)
401 #define sq_isclosure(o) ((o)._type==OT_CLOSURE)
402 #define sq_isgenerator(o) ((o)._type==OT_GENERATOR)
403 #define sq_isnativeclosure(o) ((o)._type==OT_NATIVECLOSURE)
404 #define sq_isstring(o) ((o)._type==OT_STRING)
405 #define sq_isinteger(o) ((o)._type==OT_INTEGER)
406 #define sq_isfloat(o) ((o)._type==OT_FLOAT)
407 #define sq_isuserpointer(o) ((o)._type==OT_USERPOINTER)
408 #define sq_isuserdata(o) ((o)._type==OT_USERDATA)
409 #define sq_isthread(o) ((o)._type==OT_THREAD)
410 #define sq_isnull(o) ((o)._type==OT_NULL)
411 #define sq_isclass(o) ((o)._type==OT_CLASS)
412 #define sq_isinstance(o) ((o)._type==OT_INSTANCE)
413 #define sq_isbool(o) ((o)._type==OT_BOOL)
414 #define sq_isweakref(o) ((o)._type==OT_WEAKREF)
415 #define sq_type(o) ((o)._type)
416
417 /* deprecated */
418 #define sq_createslot(v,n) sq_newslot(v,n,SQFalse)
419
420 #define SQ_OK (0)
421 #define SQ_ERROR (-1)
422
423 #define SQ_FAILED(res) (res<0)
424 #define SQ_SUCCEEDED(res) (res>=0)
425
426 #ifdef __cplusplus
427 } /*extern "C"*/
428 #endif
429
430 #endif /*_SQUIRREL_H_*/