-/*\r
-Copyright (c) 2003-2006 Alberto Demichelis\r
-\r
-This software is provided 'as-is', without any \r
-express or implied warranty. In no event will the \r
-authors be held liable for any damages arising from \r
-the use of this software.\r
-\r
-Permission is granted to anyone to use this software \r
-for any purpose, including commercial applications, \r
-and to alter it and redistribute it freely, subject \r
-to the following restrictions:\r
-\r
- 1. The origin of this software must not be \r
- misrepresented; you must not claim that \r
- you wrote the original software. If you \r
- use this software in a product, an \r
- acknowledgment in the product \r
- documentation would be appreciated but is \r
- not required.\r
-\r
- 2. Altered source versions must be plainly \r
- marked as such, and must not be \r
- misrepresented as being the original \r
- software.\r
-\r
- 3. This notice may not be removed or \r
- altered from any source distribution.\r
-\r
-*/\r
-#ifndef _SQUIRREL_H_\r
-#define _SQUIRREL_H_\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-#ifndef SQUIRREL_API\r
-#define SQUIRREL_API extern\r
-#endif\r
-\r
-#ifdef _SQ64\r
-#ifdef _MSC_VER\r
-typedef __int64 SQInteger;\r
-typedef unsigned __int64 SQUnsignedInteger;\r
-typedef unsigned __int64 SQHash; /*should be the same size of a pointer*/\r
-#else\r
-typedef long SQInteger;\r
-typedef unsigned long SQUnsignedInteger;\r
-typedef unsigned long SQHash; /*should be the same size of a pointer*/\r
-#endif\r
-typedef int SQInt32; \r
-#else \r
-typedef int SQInteger;\r
-typedef int SQInt32; /*must be 32 bits(also on 64bits processors)*/\r
-typedef unsigned int SQUnsignedInteger;\r
-typedef unsigned int SQHash; /*should be the same size of a pointer*/\r
-#endif\r
-\r
-typedef float SQFloat;\r
-typedef void* SQUserPointer;\r
-typedef SQUnsignedInteger SQBool;\r
-typedef SQInteger SQRESULT;\r
-\r
-#define SQTrue (1)\r
-#define SQFalse (0)\r
-\r
-\r
-struct SQVM;\r
-struct SQTable;\r
-struct SQArray;\r
-struct SQString;\r
-struct SQClosure;\r
-struct SQGenerator;\r
-struct SQNativeClosure;\r
-struct SQUserData;\r
-struct SQFunctionProto;\r
-struct SQRefCounted;\r
-struct SQClass;\r
-struct SQInstance;\r
-struct SQDelegable;\r
-\r
-#ifdef _UNICODE\r
-#define SQUNICODE\r
-#endif\r
-\r
-#ifdef SQUNICODE\r
-#if defined(wchar_t) //this is if the compiler considers wchar_t as native type\r
-#define wchar_t unsigned short\r
-#endif\r
-typedef wchar_t SQChar;\r
-#define _SC(a) L##a\r
-#define scstrcmp wcscmp\r
-#define scsprintf swprintf\r
-#define scstrlen wcslen\r
-#define scstrtod wcstod\r
-#define scstrtol wcstol\r
-#define scatoi _wtoi\r
-#define scstrtoul wcstoul\r
-#define scvsprintf vswprintf\r
-#define scstrstr wcsstr\r
-#define scisspace iswspace\r
-#define scisdigit iswdigit\r
-#define scisxdigit iswxdigit\r
-#define scisalpha iswalpha\r
-#define sciscntrl iswcntrl\r
-#define scisalnum iswalnum\r
-#define scprintf wprintf\r
-#define MAX_CHAR 0xFFFF\r
-#else\r
-typedef char SQChar;\r
-#define _SC(a) a\r
-#define scstrcmp strcmp\r
-#define scsprintf sprintf\r
-#define scstrlen strlen\r
-#define scstrtod strtod\r
-#define scstrtol strtol\r
-#define scatoi atoi\r
-#define scstrtoul strtoul\r
-#define scvsprintf vsprintf\r
-#define scstrstr strstr\r
-#define scisspace isspace\r
-#define scisdigit isdigit\r
-#define scisxdigit isxdigit\r
-#define sciscntrl iscntrl\r
-#define scisalpha isalpha\r
-#define scisalnum isalnum\r
-#define scprintf printf\r
-#define MAX_CHAR 0xFF\r
-#endif\r
-\r
-#define SQUIRREL_VERSION _SC("Squirrel 2.1 stable")\r
-#define SQUIRREL_COPYRIGHT _SC("Copyright (C) 2003-2006 Alberto Demichelis")\r
-#define SQUIRREL_AUTHOR _SC("Alberto Demichelis")\r
-\r
-#define SQ_VMSTATE_IDLE 0\r
-#define SQ_VMSTATE_RUNNING 1\r
-#define SQ_VMSTATE_SUSPENDED 2\r
-\r
-#define SQUIRREL_EOB 0\r
-#define SQ_BYTECODE_STREAM_TAG 0xFAFA\r
-\r
-#define SQOBJECT_REF_COUNTED 0x08000000\r
-#define SQOBJECT_NUMERIC 0x04000000\r
-#define SQOBJECT_DELEGABLE 0x02000000\r
-#define SQOBJECT_CANBEFALSE 0x01000000\r
-\r
-#define SQ_MATCHTYPEMASKSTRING (-99999)\r
-\r
-#define _RT_MASK 0x00FFFFFF\r
-#define _RAW_TYPE(type) (type&_RT_MASK)\r
-\r
-#define _RT_NULL 0x00000001\r
-#define _RT_INTEGER 0x00000002\r
-#define _RT_FLOAT 0x00000004\r
-#define _RT_BOOL 0x00000008\r
-#define _RT_STRING 0x00000010\r
-#define _RT_TABLE 0x00000020\r
-#define _RT_ARRAY 0x00000040\r
-#define _RT_USERDATA 0x00000080\r
-#define _RT_CLOSURE 0x00000100\r
-#define _RT_NATIVECLOSURE 0x00000200\r
-#define _RT_GENERATOR 0x00000400\r
-#define _RT_USERPOINTER 0x00000800\r
-#define _RT_THREAD 0x00001000\r
-#define _RT_FUNCPROTO 0x00002000\r
-#define _RT_CLASS 0x00004000\r
-#define _RT_INSTANCE 0x00008000\r
-#define _RT_WEAKREF 0x00010000\r
-\r
-typedef enum tagSQObjectType{\r
- OT_NULL = (_RT_NULL|SQOBJECT_CANBEFALSE),\r
- OT_INTEGER = (_RT_INTEGER|SQOBJECT_NUMERIC|SQOBJECT_CANBEFALSE),\r
- OT_FLOAT = (_RT_FLOAT|SQOBJECT_NUMERIC|SQOBJECT_CANBEFALSE),\r
- OT_BOOL = (_RT_BOOL|SQOBJECT_CANBEFALSE),\r
- OT_STRING = (_RT_STRING|SQOBJECT_REF_COUNTED),\r
- OT_TABLE = (_RT_TABLE|SQOBJECT_REF_COUNTED|SQOBJECT_DELEGABLE),\r
- OT_ARRAY = (_RT_ARRAY|SQOBJECT_REF_COUNTED),\r
- OT_USERDATA = (_RT_USERDATA|SQOBJECT_REF_COUNTED|SQOBJECT_DELEGABLE),\r
- OT_CLOSURE = (_RT_CLOSURE|SQOBJECT_REF_COUNTED),\r
- OT_NATIVECLOSURE = (_RT_NATIVECLOSURE|SQOBJECT_REF_COUNTED),\r
- OT_GENERATOR = (_RT_GENERATOR|SQOBJECT_REF_COUNTED),\r
- OT_USERPOINTER = _RT_USERPOINTER,\r
- OT_THREAD = (_RT_THREAD|SQOBJECT_REF_COUNTED) ,\r
- OT_FUNCPROTO = (_RT_FUNCPROTO|SQOBJECT_REF_COUNTED), //internal usage only\r
- OT_CLASS = (_RT_CLASS|SQOBJECT_REF_COUNTED),\r
- OT_INSTANCE = (_RT_INSTANCE|SQOBJECT_REF_COUNTED|SQOBJECT_DELEGABLE),\r
- OT_WEAKREF = (_RT_WEAKREF|SQOBJECT_REF_COUNTED)\r
-}SQObjectType;\r
-\r
-#define ISREFCOUNTED(t) (t&SQOBJECT_REF_COUNTED)\r
-\r
-\r
-typedef union tagSQObjectValue\r
-{\r
- struct SQTable *pTable;\r
- struct SQArray *pArray;\r
- struct SQClosure *pClosure;\r
- struct SQGenerator *pGenerator;\r
- struct SQNativeClosure *pNativeClosure;\r
- struct SQString *pString;\r
- struct SQUserData *pUserData;\r
- SQInteger nInteger;\r
- SQFloat fFloat;\r
- SQUserPointer pUserPointer;\r
- struct SQFunctionProto *pFunctionProto;\r
- struct SQRefCounted *pRefCounted;\r
- struct SQDelegable *pDelegable;\r
- struct SQVM *pThread;\r
- struct SQClass *pClass;\r
- struct SQInstance *pInstance;\r
- struct SQWeakRef *pWeakRef;\r
-}SQObjectValue;\r
-\r
-\r
-typedef struct tagSQObject\r
-{\r
- SQObjectValue _unVal;\r
- SQObjectType _type;\r
-}SQObject;\r
-\r
-typedef struct tagSQStackInfos{\r
- const SQChar* funcname;\r
- const SQChar* source;\r
- SQInteger line;\r
-}SQStackInfos;\r
-\r
-typedef struct SQVM* HSQUIRRELVM;\r
-typedef SQObject HSQOBJECT;\r
-typedef SQInteger (*SQFUNCTION)(HSQUIRRELVM);\r
-typedef SQInteger (*SQRELEASEHOOK)(SQUserPointer,SQInteger size);\r
-typedef void (*SQCOMPILERERROR)(HSQUIRRELVM,const SQChar * /*desc*/,const SQChar * /*source*/,SQInteger /*line*/,SQInteger /*column*/);\r
-typedef void (*SQPRINTFUNCTION)(HSQUIRRELVM,const SQChar * ,...);\r
-\r
-typedef SQInteger (*SQWRITEFUNC)(SQUserPointer,SQUserPointer,SQInteger);\r
-typedef SQInteger (*SQREADFUNC)(SQUserPointer,SQUserPointer,SQInteger);\r
-\r
-typedef SQInteger (*SQLEXREADFUNC)(SQUserPointer);\r
-\r
-typedef struct tagSQRegFunction{\r
- const SQChar *name;\r
- SQFUNCTION f;\r
- SQInteger nparamscheck;\r
- const SQChar *typemask;\r
-}SQRegFunction;\r
-\r
-/*vm*/\r
-SQUIRREL_API HSQUIRRELVM sq_open(SQInteger initialstacksize);\r
-SQUIRREL_API HSQUIRRELVM sq_newthread(HSQUIRRELVM friendvm, SQInteger initialstacksize);\r
-SQUIRREL_API void sq_seterrorhandler(HSQUIRRELVM v);\r
-SQUIRREL_API void sq_close(HSQUIRRELVM v);\r
-SQUIRREL_API void sq_setforeignptr(HSQUIRRELVM v,SQUserPointer p);\r
-SQUIRREL_API SQUserPointer sq_getforeignptr(HSQUIRRELVM v);\r
-SQUIRREL_API void sq_setprintfunc(HSQUIRRELVM v, SQPRINTFUNCTION printfunc);\r
-SQUIRREL_API SQPRINTFUNCTION sq_getprintfunc(HSQUIRRELVM v);\r
-SQUIRREL_API SQRESULT sq_suspendvm(HSQUIRRELVM v);\r
-SQUIRREL_API SQRESULT sq_wakeupvm(HSQUIRRELVM v,SQBool resumedret,SQBool retval,SQBool raiseerror);\r
-SQUIRREL_API SQInteger sq_getvmstate(HSQUIRRELVM v);\r
-\r
-/*compiler*/\r
-SQUIRREL_API SQRESULT sq_compile(HSQUIRRELVM v,SQLEXREADFUNC read,SQUserPointer p,const SQChar *sourcename,SQBool raiseerror);\r
-SQUIRREL_API SQRESULT sq_compilebuffer(HSQUIRRELVM v,const SQChar *s,SQInteger size,const SQChar *sourcename,SQBool raiseerror);\r
-SQUIRREL_API void sq_enabledebuginfo(HSQUIRRELVM v, SQBool enable);\r
-SQUIRREL_API void sq_notifyallexceptions(HSQUIRRELVM v, SQBool enable);\r
-SQUIRREL_API void sq_setcompilererrorhandler(HSQUIRRELVM v,SQCOMPILERERROR f);\r
-\r
-/*stack operations*/\r
-SQUIRREL_API void sq_push(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API void sq_pop(HSQUIRRELVM v,SQInteger nelemstopop);\r
-SQUIRREL_API void sq_poptop(HSQUIRRELVM v);\r
-SQUIRREL_API void sq_remove(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API SQInteger sq_gettop(HSQUIRRELVM v);\r
-SQUIRREL_API void sq_settop(HSQUIRRELVM v,SQInteger newtop);\r
-SQUIRREL_API void sq_reservestack(HSQUIRRELVM v,SQInteger nsize);\r
-SQUIRREL_API SQInteger sq_cmp(HSQUIRRELVM v);\r
-SQUIRREL_API void sq_move(HSQUIRRELVM dest,HSQUIRRELVM src,SQInteger idx);\r
-\r
-/*object creation handling*/\r
-SQUIRREL_API SQUserPointer sq_newuserdata(HSQUIRRELVM v,SQUnsignedInteger size);\r
-SQUIRREL_API void sq_newtable(HSQUIRRELVM v);\r
-SQUIRREL_API void sq_newarray(HSQUIRRELVM v,SQInteger size);\r
-SQUIRREL_API void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars);\r
-SQUIRREL_API SQRESULT sq_setparamscheck(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask);\r
-SQUIRREL_API SQRESULT sq_bindenv(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API void sq_pushstring(HSQUIRRELVM v,const SQChar *s,SQInteger len);\r
-SQUIRREL_API void sq_pushfloat(HSQUIRRELVM v,SQFloat f);\r
-SQUIRREL_API void sq_pushinteger(HSQUIRRELVM v,SQInteger n);\r
-SQUIRREL_API void sq_pushbool(HSQUIRRELVM v,SQBool b);\r
-SQUIRREL_API void sq_pushuserpointer(HSQUIRRELVM v,SQUserPointer p);\r
-SQUIRREL_API void sq_pushnull(HSQUIRRELVM v);\r
-SQUIRREL_API SQObjectType sq_gettype(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API SQInteger sq_getsize(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API SQRESULT sq_getbase(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API SQBool sq_instanceof(HSQUIRRELVM v);\r
-SQUIRREL_API void sq_tostring(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API void sq_tobool(HSQUIRRELVM v, SQInteger idx, SQBool *b);\r
-SQUIRREL_API SQRESULT sq_getstring(HSQUIRRELVM v,SQInteger idx,const SQChar **c);\r
-SQUIRREL_API SQRESULT sq_getinteger(HSQUIRRELVM v,SQInteger idx,SQInteger *i);\r
-SQUIRREL_API SQRESULT sq_getfloat(HSQUIRRELVM v,SQInteger idx,SQFloat *f);\r
-SQUIRREL_API SQRESULT sq_getbool(HSQUIRRELVM v,SQInteger idx,SQBool *b);\r
-SQUIRREL_API SQRESULT sq_getthread(HSQUIRRELVM v,SQInteger idx,HSQUIRRELVM *thread);\r
-SQUIRREL_API SQRESULT sq_getuserpointer(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p);\r
-SQUIRREL_API SQRESULT sq_getuserdata(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p,SQUserPointer *typetag);\r
-SQUIRREL_API SQRESULT sq_settypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag);\r
-SQUIRREL_API SQRESULT sq_gettypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer *typetag);\r
-SQUIRREL_API void sq_setreleasehook(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook);\r
-SQUIRREL_API SQChar *sq_getscratchpad(HSQUIRRELVM v,SQInteger minsize);\r
-SQUIRREL_API SQRESULT sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparams,SQUnsignedInteger *nfreevars);\r
-SQUIRREL_API SQRESULT sq_setnativeclosurename(HSQUIRRELVM v,SQInteger idx,const SQChar *name);\r
-SQUIRREL_API SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p);\r
-SQUIRREL_API SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag);\r
-SQUIRREL_API SQRESULT sq_newclass(HSQUIRRELVM v,SQBool hasbase);\r
-SQUIRREL_API SQRESULT sq_createinstance(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API SQRESULT sq_setattributes(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API SQRESULT sq_getattributes(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API SQRESULT sq_getclass(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API void sq_weakref(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API SQRESULT sq_getdefaultdelegate(HSQUIRRELVM v,SQObjectType t);\r
-\r
-/*object manipulation*/\r
-SQUIRREL_API void sq_pushroottable(HSQUIRRELVM v);\r
-SQUIRREL_API void sq_pushregistrytable(HSQUIRRELVM v);\r
-SQUIRREL_API SQRESULT sq_setroottable(HSQUIRRELVM v);\r
-/*SQUIRREL_API SQRESULT sq_createslot(HSQUIRRELVM v,SQInteger idx);*/\r
-SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx, SQBool bstatic);\r
-SQUIRREL_API SQRESULT sq_deleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval);\r
-SQUIRREL_API SQRESULT sq_set(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API SQRESULT sq_get(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API SQRESULT sq_rawget(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API SQRESULT sq_rawset(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API SQRESULT sq_rawdeleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval);\r
-SQUIRREL_API SQRESULT sq_arrayappend(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API SQRESULT sq_arraypop(HSQUIRRELVM v,SQInteger idx,SQBool pushval); \r
-SQUIRREL_API SQRESULT sq_arrayresize(HSQUIRRELVM v,SQInteger idx,SQInteger newsize); \r
-SQUIRREL_API SQRESULT sq_arrayreverse(HSQUIRRELVM v,SQInteger idx); \r
-SQUIRREL_API SQRESULT sq_setdelegate(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API SQRESULT sq_getdelegate(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API SQRESULT sq_clone(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API SQRESULT sq_setfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval);\r
-SQUIRREL_API SQRESULT sq_next(HSQUIRRELVM v,SQInteger idx);\r
-SQUIRREL_API SQRESULT sq_getweakrefval(HSQUIRRELVM v,SQInteger idx);\r
-\r
-/*calls*/\r
-SQUIRREL_API SQRESULT sq_call(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror);\r
-SQUIRREL_API SQRESULT sq_resume(HSQUIRRELVM v,SQBool retval,SQBool raiseerror);\r
-SQUIRREL_API const SQChar *sq_getlocal(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedInteger idx);\r
-SQUIRREL_API const SQChar *sq_getfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval);\r
-SQUIRREL_API SQRESULT sq_throwerror(HSQUIRRELVM v,const SQChar *err);\r
-SQUIRREL_API void sq_reseterror(HSQUIRRELVM v);\r
-SQUIRREL_API void sq_getlasterror(HSQUIRRELVM v);\r
-\r
-/*raw object handling*/\r
-SQUIRREL_API SQRESULT sq_getstackobj(HSQUIRRELVM v,SQInteger idx,HSQOBJECT *po);\r
-SQUIRREL_API void sq_pushobject(HSQUIRRELVM v,HSQOBJECT obj);\r
-SQUIRREL_API void sq_addref(HSQUIRRELVM v,HSQOBJECT *po);\r
-SQUIRREL_API SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po);\r
-SQUIRREL_API void sq_resetobject(HSQOBJECT *po);\r
-SQUIRREL_API const SQChar *sq_objtostring(HSQOBJECT *o);\r
-SQUIRREL_API SQBool sq_objtobool(HSQOBJECT *o);\r
-SQUIRREL_API SQInteger sq_objtointeger(HSQOBJECT *o);\r
-SQUIRREL_API SQFloat sq_objtofloat(HSQOBJECT *o);\r
-SQUIRREL_API SQRESULT sq_getobjtypetag(HSQOBJECT *o,SQUserPointer * typetag);\r
-\r
-/*GC*/\r
-SQUIRREL_API SQInteger sq_collectgarbage(HSQUIRRELVM v);\r
-\r
-/*serialization*/\r
-SQUIRREL_API SQRESULT sq_writeclosure(HSQUIRRELVM vm,SQWRITEFUNC writef,SQUserPointer up);\r
-SQUIRREL_API SQRESULT sq_readclosure(HSQUIRRELVM vm,SQREADFUNC readf,SQUserPointer up);\r
-\r
-/*mem allocation*/\r
-SQUIRREL_API void *sq_malloc(SQUnsignedInteger size);\r
-SQUIRREL_API void *sq_realloc(void* p,SQUnsignedInteger oldsize,SQUnsignedInteger newsize);\r
-SQUIRREL_API void sq_free(void *p,SQUnsignedInteger size);\r
-\r
-/*debug*/\r
-SQUIRREL_API SQRESULT sq_stackinfos(HSQUIRRELVM v,SQInteger level,SQStackInfos *si);\r
-SQUIRREL_API void sq_setdebughook(HSQUIRRELVM v);\r
-\r
-/*UTILITY MACRO*/\r
-#define sq_isnumeric(o) ((o)._type&SQOBJECT_NUMERIC)\r
-#define sq_istable(o) ((o)._type==OT_TABLE)\r
-#define sq_isarray(o) ((o)._type==OT_ARRAY)\r
-#define sq_isfunction(o) ((o)._type==OT_FUNCPROTO)\r
-#define sq_isclosure(o) ((o)._type==OT_CLOSURE)\r
-#define sq_isgenerator(o) ((o)._type==OT_GENERATOR)\r
-#define sq_isnativeclosure(o) ((o)._type==OT_NATIVECLOSURE)\r
-#define sq_isstring(o) ((o)._type==OT_STRING)\r
-#define sq_isinteger(o) ((o)._type==OT_INTEGER)\r
-#define sq_isfloat(o) ((o)._type==OT_FLOAT)\r
-#define sq_isuserpointer(o) ((o)._type==OT_USERPOINTER)\r
-#define sq_isuserdata(o) ((o)._type==OT_USERDATA)\r
-#define sq_isthread(o) ((o)._type==OT_THREAD)\r
-#define sq_isnull(o) ((o)._type==OT_NULL)\r
-#define sq_isclass(o) ((o)._type==OT_CLASS)\r
-#define sq_isinstance(o) ((o)._type==OT_INSTANCE)\r
-#define sq_isbool(o) ((o)._type==OT_BOOL)\r
-#define sq_isweakref(o) ((o)._type==OT_WEAKREF)\r
-#define sq_type(o) ((o)._type)\r
-\r
-/* deprecated */\r
-#define sq_createslot(v,n) sq_newslot(v,n,SQFalse)\r
-\r
-#define SQ_OK (0)\r
-#define SQ_ERROR (-1)\r
-\r
-#define SQ_FAILED(res) (res<0)\r
-#define SQ_SUCCEEDED(res) (res>=0)\r
-\r
-#ifdef __cplusplus\r
-} /*extern "C"*/\r
-#endif\r
-\r
-#endif /*_SQUIRREL_H_*/\r
+/*
+Copyright (c) 2003-2008 Alberto Demichelis
+
+This software is provided 'as-is', without any
+express or implied warranty. In no event will the
+authors be held liable for any damages arising from
+the use of this software.
+
+Permission is granted to anyone to use this software
+for any purpose, including commercial applications,
+and to alter it and redistribute it freely, subject
+to the following restrictions:
+
+ 1. The origin of this software must not be
+ misrepresented; you must not claim that
+ you wrote the original software. If you
+ use this software in a product, an
+ acknowledgment in the product
+ documentation would be appreciated but is
+ not required.
+
+ 2. Altered source versions must be plainly
+ marked as such, and must not be
+ misrepresented as being the original
+ software.
+
+ 3. This notice may not be removed or
+ altered from any source distribution.
+
+*/
+#ifndef _SQUIRREL_H_
+#define _SQUIRREL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef SQUIRREL_API
+#define SQUIRREL_API extern
+#endif
+
+#ifdef _SQ64
+#ifdef _MSC_VER
+typedef __int64 SQInteger;
+typedef unsigned __int64 SQUnsignedInteger;
+typedef unsigned __int64 SQHash; /*should be the same size of a pointer*/
+#else
+typedef long SQInteger;
+typedef unsigned long SQUnsignedInteger;
+typedef unsigned long SQHash; /*should be the same size of a pointer*/
+#endif
+typedef int SQInt32;
+#else
+typedef int SQInteger;
+typedef int SQInt32; /*must be 32 bits(also on 64bits processors)*/
+typedef unsigned int SQUnsignedInteger;
+typedef unsigned int SQHash; /*should be the same size of a pointer*/
+#endif
+
+
+typedef float SQFloat;
+typedef void* SQUserPointer;
+typedef SQUnsignedInteger SQBool;
+typedef SQInteger SQRESULT;
+
+#define SQTrue (1)
+#define SQFalse (0)
+
+struct SQVM;
+struct SQTable;
+struct SQArray;
+struct SQString;
+struct SQClosure;
+struct SQGenerator;
+struct SQNativeClosure;
+struct SQUserData;
+struct SQFunctionProto;
+struct SQRefCounted;
+struct SQClass;
+struct SQInstance;
+struct SQDelegable;
+
+#ifdef _UNICODE
+#define SQUNICODE
+#endif
+
+#ifdef SQUNICODE
+#if (defined(_MSC_VER) && _MSC_VER >= 1400) // 1400 = VS8
+
+#if defined(wchar_t) //this is if the compiler considers wchar_t as native type
+#define wchar_t unsigned short
+#endif
+
+#else
+typedef unsigned short wchar_t;
+#endif
+
+typedef wchar_t SQChar;
+#define _SC(a) L##a
+#define scstrcmp wcscmp
+#define scsprintf swprintf
+#define scstrlen wcslen
+#define scstrtod wcstod
+#define scstrtol wcstol
+#define scatoi _wtoi
+#define scstrtoul wcstoul
+#define scvsprintf vswprintf
+#define scstrstr wcsstr
+#define scisspace iswspace
+#define scisdigit iswdigit
+#define scisxdigit iswxdigit
+#define scisalpha iswalpha
+#define sciscntrl iswcntrl
+#define scisalnum iswalnum
+#define scprintf wprintf
+#define MAX_CHAR 0xFFFF
+#else
+typedef char SQChar;
+#define _SC(a) a
+#define scstrcmp strcmp
+#define scsprintf sprintf
+#define scstrlen strlen
+#define scstrtod strtod
+#define scstrtol strtol
+#define scatoi atoi
+#define scstrtoul strtoul
+#define scvsprintf vsprintf
+#define scstrstr strstr
+#define scisspace isspace
+#define scisdigit isdigit
+#define scisxdigit isxdigit
+#define sciscntrl iscntrl
+#define scisalpha isalpha
+#define scisalnum isalnum
+#define scprintf printf
+#define MAX_CHAR 0xFF
+#endif
+
+#define SQUIRREL_VERSION _SC("Squirrel 2.2 stable")
+#define SQUIRREL_COPYRIGHT _SC("Copyright (C) 2003-2008 Alberto Demichelis")
+#define SQUIRREL_AUTHOR _SC("Alberto Demichelis")
+
+#define SQ_VMSTATE_IDLE 0
+#define SQ_VMSTATE_RUNNING 1
+#define SQ_VMSTATE_SUSPENDED 2
+
+#define SQUIRREL_EOB 0
+#define SQ_BYTECODE_STREAM_TAG 0xFAFA
+
+#define SQOBJECT_REF_COUNTED 0x08000000
+#define SQOBJECT_NUMERIC 0x04000000
+#define SQOBJECT_DELEGABLE 0x02000000
+#define SQOBJECT_CANBEFALSE 0x01000000
+
+#define SQ_MATCHTYPEMASKSTRING (-99999)
+
+#define _RT_MASK 0x00FFFFFF
+#define _RAW_TYPE(type) (type&_RT_MASK)
+
+#define _RT_NULL 0x00000001
+#define _RT_INTEGER 0x00000002
+#define _RT_FLOAT 0x00000004
+#define _RT_BOOL 0x00000008
+#define _RT_STRING 0x00000010
+#define _RT_TABLE 0x00000020
+#define _RT_ARRAY 0x00000040
+#define _RT_USERDATA 0x00000080
+#define _RT_CLOSURE 0x00000100
+#define _RT_NATIVECLOSURE 0x00000200
+#define _RT_GENERATOR 0x00000400
+#define _RT_USERPOINTER 0x00000800
+#define _RT_THREAD 0x00001000
+#define _RT_FUNCPROTO 0x00002000
+#define _RT_CLASS 0x00004000
+#define _RT_INSTANCE 0x00008000
+#define _RT_WEAKREF 0x00010000
+
+typedef enum tagSQObjectType{
+ OT_NULL = (_RT_NULL|SQOBJECT_CANBEFALSE),
+ OT_INTEGER = (_RT_INTEGER|SQOBJECT_NUMERIC|SQOBJECT_CANBEFALSE),
+ OT_FLOAT = (_RT_FLOAT|SQOBJECT_NUMERIC|SQOBJECT_CANBEFALSE),
+ OT_BOOL = (_RT_BOOL|SQOBJECT_CANBEFALSE),
+ OT_STRING = (_RT_STRING|SQOBJECT_REF_COUNTED),
+ OT_TABLE = (_RT_TABLE|SQOBJECT_REF_COUNTED|SQOBJECT_DELEGABLE),
+ OT_ARRAY = (_RT_ARRAY|SQOBJECT_REF_COUNTED),
+ OT_USERDATA = (_RT_USERDATA|SQOBJECT_REF_COUNTED|SQOBJECT_DELEGABLE),
+ OT_CLOSURE = (_RT_CLOSURE|SQOBJECT_REF_COUNTED),
+ OT_NATIVECLOSURE = (_RT_NATIVECLOSURE|SQOBJECT_REF_COUNTED),
+ OT_GENERATOR = (_RT_GENERATOR|SQOBJECT_REF_COUNTED),
+ OT_USERPOINTER = _RT_USERPOINTER,
+ OT_THREAD = (_RT_THREAD|SQOBJECT_REF_COUNTED) ,
+ OT_FUNCPROTO = (_RT_FUNCPROTO|SQOBJECT_REF_COUNTED), //internal usage only
+ OT_CLASS = (_RT_CLASS|SQOBJECT_REF_COUNTED),
+ OT_INSTANCE = (_RT_INSTANCE|SQOBJECT_REF_COUNTED|SQOBJECT_DELEGABLE),
+ OT_WEAKREF = (_RT_WEAKREF|SQOBJECT_REF_COUNTED)
+}SQObjectType;
+
+#define ISREFCOUNTED(t) (t&SQOBJECT_REF_COUNTED)
+
+
+typedef union tagSQObjectValue
+{
+ struct SQTable *pTable;
+ struct SQArray *pArray;
+ struct SQClosure *pClosure;
+ struct SQGenerator *pGenerator;
+ struct SQNativeClosure *pNativeClosure;
+ struct SQString *pString;
+ struct SQUserData *pUserData;
+ SQInteger nInteger;
+ SQFloat fFloat;
+ SQUserPointer pUserPointer;
+ struct SQFunctionProto *pFunctionProto;
+ struct SQRefCounted *pRefCounted;
+ struct SQDelegable *pDelegable;
+ struct SQVM *pThread;
+ struct SQClass *pClass;
+ struct SQInstance *pInstance;
+ struct SQWeakRef *pWeakRef;
+}SQObjectValue;
+
+
+typedef struct tagSQObject
+{
+ SQObjectType _type;
+ SQObjectValue _unVal;
+}SQObject;
+
+typedef struct tagSQStackInfos{
+ const SQChar* funcname;
+ const SQChar* source;
+ SQInteger line;
+}SQStackInfos;
+
+typedef struct SQVM* HSQUIRRELVM;
+typedef SQObject HSQOBJECT;
+typedef SQInteger (*SQFUNCTION)(HSQUIRRELVM);
+typedef SQInteger (*SQRELEASEHOOK)(SQUserPointer,SQInteger size);
+typedef void (*SQCOMPILERERROR)(HSQUIRRELVM,const SQChar * /*desc*/,const SQChar * /*source*/,SQInteger /*line*/,SQInteger /*column*/);
+typedef void (*SQPRINTFUNCTION)(HSQUIRRELVM,const SQChar * ,...);
+
+typedef SQInteger (*SQWRITEFUNC)(SQUserPointer,SQUserPointer,SQInteger);
+typedef SQInteger (*SQREADFUNC)(SQUserPointer,SQUserPointer,SQInteger);
+
+typedef SQInteger (*SQLEXREADFUNC)(SQUserPointer);
+
+typedef struct tagSQRegFunction{
+ const SQChar *name;
+ SQFUNCTION f;
+ SQInteger nparamscheck;
+ const SQChar *typemask;
+}SQRegFunction;
+
+/*vm*/
+SQUIRREL_API HSQUIRRELVM sq_open(SQInteger initialstacksize);
+SQUIRREL_API HSQUIRRELVM sq_newthread(HSQUIRRELVM friendvm, SQInteger initialstacksize);
+SQUIRREL_API void sq_seterrorhandler(HSQUIRRELVM v);
+SQUIRREL_API void sq_close(HSQUIRRELVM v);
+SQUIRREL_API void sq_setforeignptr(HSQUIRRELVM v,SQUserPointer p);
+SQUIRREL_API SQUserPointer sq_getforeignptr(HSQUIRRELVM v);
+SQUIRREL_API void sq_setprintfunc(HSQUIRRELVM v, SQPRINTFUNCTION printfunc);
+SQUIRREL_API SQPRINTFUNCTION sq_getprintfunc(HSQUIRRELVM v);
+SQUIRREL_API SQRESULT sq_suspendvm(HSQUIRRELVM v);
+SQUIRREL_API SQRESULT sq_wakeupvm(HSQUIRRELVM v,SQBool resumedret,SQBool retval,SQBool raiseerror);
+SQUIRREL_API SQInteger sq_getvmstate(HSQUIRRELVM v);
+
+/*compiler*/
+SQUIRREL_API SQRESULT sq_compile(HSQUIRRELVM v,SQLEXREADFUNC read,SQUserPointer p,const SQChar *sourcename,SQBool raiseerror);
+SQUIRREL_API SQRESULT sq_compilebuffer(HSQUIRRELVM v,const SQChar *s,SQInteger size,const SQChar *sourcename,SQBool raiseerror);
+SQUIRREL_API void sq_enabledebuginfo(HSQUIRRELVM v, SQBool enable);
+SQUIRREL_API void sq_notifyallexceptions(HSQUIRRELVM v, SQBool enable);
+SQUIRREL_API void sq_setcompilererrorhandler(HSQUIRRELVM v,SQCOMPILERERROR f);
+
+/*stack operations*/
+SQUIRREL_API void sq_push(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API void sq_pop(HSQUIRRELVM v,SQInteger nelemstopop);
+SQUIRREL_API void sq_poptop(HSQUIRRELVM v);
+SQUIRREL_API void sq_remove(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQInteger sq_gettop(HSQUIRRELVM v);
+SQUIRREL_API void sq_settop(HSQUIRRELVM v,SQInteger newtop);
+SQUIRREL_API void sq_reservestack(HSQUIRRELVM v,SQInteger nsize);
+SQUIRREL_API SQInteger sq_cmp(HSQUIRRELVM v);
+SQUIRREL_API void sq_move(HSQUIRRELVM dest,HSQUIRRELVM src,SQInteger idx);
+
+/*object creation handling*/
+SQUIRREL_API SQUserPointer sq_newuserdata(HSQUIRRELVM v,SQUnsignedInteger size);
+SQUIRREL_API void sq_newtable(HSQUIRRELVM v);
+SQUIRREL_API void sq_newarray(HSQUIRRELVM v,SQInteger size);
+SQUIRREL_API void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars);
+SQUIRREL_API SQRESULT sq_setparamscheck(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask);
+SQUIRREL_API SQRESULT sq_bindenv(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API void sq_pushstring(HSQUIRRELVM v,const SQChar *s,SQInteger len);
+SQUIRREL_API void sq_pushfloat(HSQUIRRELVM v,SQFloat f);
+SQUIRREL_API void sq_pushinteger(HSQUIRRELVM v,SQInteger n);
+SQUIRREL_API void sq_pushbool(HSQUIRRELVM v,SQBool b);
+SQUIRREL_API void sq_pushuserpointer(HSQUIRRELVM v,SQUserPointer p);
+SQUIRREL_API void sq_pushnull(HSQUIRRELVM v);
+SQUIRREL_API SQObjectType sq_gettype(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQInteger sq_getsize(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQRESULT sq_getbase(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQBool sq_instanceof(HSQUIRRELVM v);
+SQUIRREL_API void sq_tostring(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API void sq_tobool(HSQUIRRELVM v, SQInteger idx, SQBool *b);
+SQUIRREL_API SQRESULT sq_getstring(HSQUIRRELVM v,SQInteger idx,const SQChar **c);
+SQUIRREL_API SQRESULT sq_getinteger(HSQUIRRELVM v,SQInteger idx,SQInteger *i);
+SQUIRREL_API SQRESULT sq_getfloat(HSQUIRRELVM v,SQInteger idx,SQFloat *f);
+SQUIRREL_API SQRESULT sq_getbool(HSQUIRRELVM v,SQInteger idx,SQBool *b);
+SQUIRREL_API SQRESULT sq_getthread(HSQUIRRELVM v,SQInteger idx,HSQUIRRELVM *thread);
+SQUIRREL_API SQRESULT sq_getuserpointer(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p);
+SQUIRREL_API SQRESULT sq_getuserdata(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p,SQUserPointer *typetag);
+SQUIRREL_API SQRESULT sq_settypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag);
+SQUIRREL_API SQRESULT sq_gettypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer *typetag);
+SQUIRREL_API void sq_setreleasehook(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook);
+SQUIRREL_API SQChar *sq_getscratchpad(HSQUIRRELVM v,SQInteger minsize);
+SQUIRREL_API SQRESULT sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparams,SQUnsignedInteger *nfreevars);
+SQUIRREL_API SQRESULT sq_setnativeclosurename(HSQUIRRELVM v,SQInteger idx,const SQChar *name);
+SQUIRREL_API SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p);
+SQUIRREL_API SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag);
+SQUIRREL_API SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger idx, SQInteger udsize);
+SQUIRREL_API SQRESULT sq_newclass(HSQUIRRELVM v,SQBool hasbase);
+SQUIRREL_API SQRESULT sq_createinstance(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQRESULT sq_setattributes(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQRESULT sq_getattributes(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQRESULT sq_getclass(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API void sq_weakref(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQRESULT sq_getdefaultdelegate(HSQUIRRELVM v,SQObjectType t);
+
+/*object manipulation*/
+SQUIRREL_API void sq_pushroottable(HSQUIRRELVM v);
+SQUIRREL_API void sq_pushregistrytable(HSQUIRRELVM v);
+SQUIRREL_API void sq_pushconsttable(HSQUIRRELVM v);
+SQUIRREL_API SQRESULT sq_setroottable(HSQUIRRELVM v);
+SQUIRREL_API SQRESULT sq_setconsttable(HSQUIRRELVM v);
+SQUIRREL_API SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx, SQBool bstatic);
+SQUIRREL_API SQRESULT sq_deleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval);
+SQUIRREL_API SQRESULT sq_set(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQRESULT sq_get(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQRESULT sq_rawget(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQRESULT sq_rawset(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQRESULT sq_rawdeleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval);
+SQUIRREL_API SQRESULT sq_arrayappend(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQRESULT sq_arraypop(HSQUIRRELVM v,SQInteger idx,SQBool pushval);
+SQUIRREL_API SQRESULT sq_arrayresize(HSQUIRRELVM v,SQInteger idx,SQInteger newsize);
+SQUIRREL_API SQRESULT sq_arrayreverse(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQRESULT sq_setdelegate(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQRESULT sq_getdelegate(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQRESULT sq_clone(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQRESULT sq_setfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval);
+SQUIRREL_API SQRESULT sq_next(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQRESULT sq_getweakrefval(HSQUIRRELVM v,SQInteger idx);
+SQUIRREL_API SQRESULT sq_clear(HSQUIRRELVM v,SQInteger idx);
+
+/*calls*/
+SQUIRREL_API SQRESULT sq_call(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror);
+SQUIRREL_API SQRESULT sq_resume(HSQUIRRELVM v,SQBool retval,SQBool raiseerror);
+SQUIRREL_API const SQChar *sq_getlocal(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedInteger idx);
+SQUIRREL_API const SQChar *sq_getfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval);
+SQUIRREL_API SQRESULT sq_throwerror(HSQUIRRELVM v,const SQChar *err);
+SQUIRREL_API void sq_reseterror(HSQUIRRELVM v);
+SQUIRREL_API void sq_getlasterror(HSQUIRRELVM v);
+
+/*raw object handling*/
+SQUIRREL_API SQRESULT sq_getstackobj(HSQUIRRELVM v,SQInteger idx,HSQOBJECT *po);
+SQUIRREL_API void sq_pushobject(HSQUIRRELVM v,HSQOBJECT obj);
+SQUIRREL_API void sq_addref(HSQUIRRELVM v,HSQOBJECT *po);
+SQUIRREL_API SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po);
+SQUIRREL_API void sq_resetobject(HSQOBJECT *po);
+SQUIRREL_API const SQChar *sq_objtostring(HSQOBJECT *o);
+SQUIRREL_API SQBool sq_objtobool(HSQOBJECT *o);
+SQUIRREL_API SQInteger sq_objtointeger(HSQOBJECT *o);
+SQUIRREL_API SQFloat sq_objtofloat(HSQOBJECT *o);
+SQUIRREL_API SQRESULT sq_getobjtypetag(HSQOBJECT *o,SQUserPointer * typetag);
+
+/*GC*/
+SQUIRREL_API SQInteger sq_collectgarbage(HSQUIRRELVM v);
+
+/*serialization*/
+SQUIRREL_API SQRESULT sq_writeclosure(HSQUIRRELVM vm,SQWRITEFUNC writef,SQUserPointer up);
+SQUIRREL_API SQRESULT sq_readclosure(HSQUIRRELVM vm,SQREADFUNC readf,SQUserPointer up);
+
+/*mem allocation*/
+SQUIRREL_API void *sq_malloc(SQUnsignedInteger size);
+SQUIRREL_API void *sq_realloc(void* p,SQUnsignedInteger oldsize,SQUnsignedInteger newsize);
+SQUIRREL_API void sq_free(void *p,SQUnsignedInteger size);
+
+/*debug*/
+SQUIRREL_API SQRESULT sq_stackinfos(HSQUIRRELVM v,SQInteger level,SQStackInfos *si);
+SQUIRREL_API void sq_setdebughook(HSQUIRRELVM v);
+
+/*UTILITY MACRO*/
+#define sq_isnumeric(o) ((o)._type&SQOBJECT_NUMERIC)
+#define sq_istable(o) ((o)._type==OT_TABLE)
+#define sq_isarray(o) ((o)._type==OT_ARRAY)
+#define sq_isfunction(o) ((o)._type==OT_FUNCPROTO)
+#define sq_isclosure(o) ((o)._type==OT_CLOSURE)
+#define sq_isgenerator(o) ((o)._type==OT_GENERATOR)
+#define sq_isnativeclosure(o) ((o)._type==OT_NATIVECLOSURE)
+#define sq_isstring(o) ((o)._type==OT_STRING)
+#define sq_isinteger(o) ((o)._type==OT_INTEGER)
+#define sq_isfloat(o) ((o)._type==OT_FLOAT)
+#define sq_isuserpointer(o) ((o)._type==OT_USERPOINTER)
+#define sq_isuserdata(o) ((o)._type==OT_USERDATA)
+#define sq_isthread(o) ((o)._type==OT_THREAD)
+#define sq_isnull(o) ((o)._type==OT_NULL)
+#define sq_isclass(o) ((o)._type==OT_CLASS)
+#define sq_isinstance(o) ((o)._type==OT_INSTANCE)
+#define sq_isbool(o) ((o)._type==OT_BOOL)
+#define sq_isweakref(o) ((o)._type==OT_WEAKREF)
+#define sq_type(o) ((o)._type)
+
+/* deprecated */
+#define sq_createslot(v,n) sq_newslot(v,n,SQFalse)
+
+#define SQ_OK (0)
+#define SQ_ERROR (-1)
+
+#define SQ_FAILED(res) (res<0)
+#define SQ_SUCCEEDED(res) (res>=0)
+
+#ifdef __cplusplus
+} /*extern "C"*/
+#endif
+
+#endif /*_SQUIRREL_H_*/