The Squirrel interpreter. See http://www.squirrel-lang.org/

Dependents:   Squirrel

Committer:
jhnwkmn
Date:
Tue Dec 16 10:20:34 2014 +0000
Revision:
0:97a4f8cc534c
Initial import of Squirrel.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jhnwkmn 0:97a4f8cc534c 1 /*
jhnwkmn 0:97a4f8cc534c 2 Copyright (c) 2003-2014 Alberto Demichelis
jhnwkmn 0:97a4f8cc534c 3
jhnwkmn 0:97a4f8cc534c 4 Permission is hereby granted, free of charge, to any person obtaining a copy
jhnwkmn 0:97a4f8cc534c 5 of this software and associated documentation files (the "Software"), to deal
jhnwkmn 0:97a4f8cc534c 6 in the Software without restriction, including without limitation the rights
jhnwkmn 0:97a4f8cc534c 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
jhnwkmn 0:97a4f8cc534c 8 copies of the Software, and to permit persons to whom the Software is
jhnwkmn 0:97a4f8cc534c 9 furnished to do so, subject to the following conditions:
jhnwkmn 0:97a4f8cc534c 10
jhnwkmn 0:97a4f8cc534c 11 The above copyright notice and this permission notice shall be included in
jhnwkmn 0:97a4f8cc534c 12 all copies or substantial portions of the Software.
jhnwkmn 0:97a4f8cc534c 13
jhnwkmn 0:97a4f8cc534c 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
jhnwkmn 0:97a4f8cc534c 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
jhnwkmn 0:97a4f8cc534c 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
jhnwkmn 0:97a4f8cc534c 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
jhnwkmn 0:97a4f8cc534c 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
jhnwkmn 0:97a4f8cc534c 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
jhnwkmn 0:97a4f8cc534c 20 THE SOFTWARE.
jhnwkmn 0:97a4f8cc534c 21 */
jhnwkmn 0:97a4f8cc534c 22 #ifndef _SQUIRREL_H_
jhnwkmn 0:97a4f8cc534c 23 #define _SQUIRREL_H_
jhnwkmn 0:97a4f8cc534c 24
jhnwkmn 0:97a4f8cc534c 25 #ifdef __cplusplus
jhnwkmn 0:97a4f8cc534c 26 extern "C" {
jhnwkmn 0:97a4f8cc534c 27 #endif
jhnwkmn 0:97a4f8cc534c 28
jhnwkmn 0:97a4f8cc534c 29 #ifndef SQUIRREL_API
jhnwkmn 0:97a4f8cc534c 30 #define SQUIRREL_API extern
jhnwkmn 0:97a4f8cc534c 31 #endif
jhnwkmn 0:97a4f8cc534c 32
jhnwkmn 0:97a4f8cc534c 33 #if (defined(_WIN64) || defined(_LP64))
jhnwkmn 0:97a4f8cc534c 34 #ifndef _SQ64
jhnwkmn 0:97a4f8cc534c 35 #define _SQ64
jhnwkmn 0:97a4f8cc534c 36 #endif
jhnwkmn 0:97a4f8cc534c 37 #endif
jhnwkmn 0:97a4f8cc534c 38
jhnwkmn 0:97a4f8cc534c 39 #ifdef _SQ64
jhnwkmn 0:97a4f8cc534c 40
jhnwkmn 0:97a4f8cc534c 41 #ifdef _MSC_VER
jhnwkmn 0:97a4f8cc534c 42 typedef __int64 SQInteger;
jhnwkmn 0:97a4f8cc534c 43 typedef unsigned __int64 SQUnsignedInteger;
jhnwkmn 0:97a4f8cc534c 44 typedef unsigned __int64 SQHash; /*should be the same size of a pointer*/
jhnwkmn 0:97a4f8cc534c 45 #else
jhnwkmn 0:97a4f8cc534c 46 typedef long long SQInteger;
jhnwkmn 0:97a4f8cc534c 47 typedef unsigned long long SQUnsignedInteger;
jhnwkmn 0:97a4f8cc534c 48 typedef unsigned long long SQHash; /*should be the same size of a pointer*/
jhnwkmn 0:97a4f8cc534c 49 #endif
jhnwkmn 0:97a4f8cc534c 50 typedef int SQInt32;
jhnwkmn 0:97a4f8cc534c 51 typedef unsigned int SQUnsignedInteger32;
jhnwkmn 0:97a4f8cc534c 52 #else
jhnwkmn 0:97a4f8cc534c 53 typedef int SQInteger;
jhnwkmn 0:97a4f8cc534c 54 typedef int SQInt32; /*must be 32 bits(also on 64bits processors)*/
jhnwkmn 0:97a4f8cc534c 55 typedef unsigned int SQUnsignedInteger32; /*must be 32 bits(also on 64bits processors)*/
jhnwkmn 0:97a4f8cc534c 56 typedef unsigned int SQUnsignedInteger;
jhnwkmn 0:97a4f8cc534c 57 typedef unsigned int SQHash; /*should be the same size of a pointer*/
jhnwkmn 0:97a4f8cc534c 58 #endif
jhnwkmn 0:97a4f8cc534c 59
jhnwkmn 0:97a4f8cc534c 60
jhnwkmn 0:97a4f8cc534c 61 #ifdef SQUSEDOUBLE
jhnwkmn 0:97a4f8cc534c 62 typedef double SQFloat;
jhnwkmn 0:97a4f8cc534c 63 #else
jhnwkmn 0:97a4f8cc534c 64 typedef float SQFloat;
jhnwkmn 0:97a4f8cc534c 65 #endif
jhnwkmn 0:97a4f8cc534c 66
jhnwkmn 0:97a4f8cc534c 67 #if defined(SQUSEDOUBLE) && !defined(_SQ64) || !defined(SQUSEDOUBLE) && defined(_SQ64)
jhnwkmn 0:97a4f8cc534c 68 #ifdef _MSC_VER
jhnwkmn 0:97a4f8cc534c 69 typedef __int64 SQRawObjectVal; //must be 64bits
jhnwkmn 0:97a4f8cc534c 70 #else
jhnwkmn 0:97a4f8cc534c 71 typedef long long SQRawObjectVal; //must be 64bits
jhnwkmn 0:97a4f8cc534c 72 #endif
jhnwkmn 0:97a4f8cc534c 73 #define SQ_OBJECT_RAWINIT() { _unVal.raw = 0; }
jhnwkmn 0:97a4f8cc534c 74 #else
jhnwkmn 0:97a4f8cc534c 75 typedef SQUnsignedInteger SQRawObjectVal; //is 32 bits on 32 bits builds and 64 bits otherwise
jhnwkmn 0:97a4f8cc534c 76 #define SQ_OBJECT_RAWINIT()
jhnwkmn 0:97a4f8cc534c 77 #endif
jhnwkmn 0:97a4f8cc534c 78
jhnwkmn 0:97a4f8cc534c 79 #ifndef SQ_ALIGNMENT // SQ_ALIGNMENT shall be less than or equal to SQ_MALLOC alignments, and its value shall be power of 2.
jhnwkmn 0:97a4f8cc534c 80 #if defined(SQUSEDOUBLE) || defined(_SQ64)
jhnwkmn 0:97a4f8cc534c 81 #define SQ_ALIGNMENT 8
jhnwkmn 0:97a4f8cc534c 82 #else
jhnwkmn 0:97a4f8cc534c 83 #define SQ_ALIGNMENT 4
jhnwkmn 0:97a4f8cc534c 84 #endif
jhnwkmn 0:97a4f8cc534c 85 #endif
jhnwkmn 0:97a4f8cc534c 86
jhnwkmn 0:97a4f8cc534c 87 typedef void* SQUserPointer;
jhnwkmn 0:97a4f8cc534c 88 typedef SQUnsignedInteger SQBool;
jhnwkmn 0:97a4f8cc534c 89 typedef SQInteger SQRESULT;
jhnwkmn 0:97a4f8cc534c 90
jhnwkmn 0:97a4f8cc534c 91 #define SQTrue (1)
jhnwkmn 0:97a4f8cc534c 92 #define SQFalse (0)
jhnwkmn 0:97a4f8cc534c 93
jhnwkmn 0:97a4f8cc534c 94 struct SQVM;
jhnwkmn 0:97a4f8cc534c 95 struct SQTable;
jhnwkmn 0:97a4f8cc534c 96 struct SQArray;
jhnwkmn 0:97a4f8cc534c 97 struct SQString;
jhnwkmn 0:97a4f8cc534c 98 struct SQClosure;
jhnwkmn 0:97a4f8cc534c 99 struct SQGenerator;
jhnwkmn 0:97a4f8cc534c 100 struct SQNativeClosure;
jhnwkmn 0:97a4f8cc534c 101 struct SQUserData;
jhnwkmn 0:97a4f8cc534c 102 struct SQFunctionProto;
jhnwkmn 0:97a4f8cc534c 103 struct SQRefCounted;
jhnwkmn 0:97a4f8cc534c 104 struct SQClass;
jhnwkmn 0:97a4f8cc534c 105 struct SQInstance;
jhnwkmn 0:97a4f8cc534c 106 struct SQDelegable;
jhnwkmn 0:97a4f8cc534c 107 struct SQOuter;
jhnwkmn 0:97a4f8cc534c 108
jhnwkmn 0:97a4f8cc534c 109 #ifdef _UNICODE
jhnwkmn 0:97a4f8cc534c 110 #define SQUNICODE
jhnwkmn 0:97a4f8cc534c 111 #endif
jhnwkmn 0:97a4f8cc534c 112
jhnwkmn 0:97a4f8cc534c 113 #ifdef SQUNICODE
jhnwkmn 0:97a4f8cc534c 114 #if (defined(_MSC_VER) && _MSC_VER >= 1400) // 1400 = VS8
jhnwkmn 0:97a4f8cc534c 115
jhnwkmn 0:97a4f8cc534c 116 #if !defined(_NATIVE_WCHAR_T_DEFINED) //this is if the compiler considers wchar_t as native type
jhnwkmn 0:97a4f8cc534c 117 #define wchar_t unsigned short
jhnwkmn 0:97a4f8cc534c 118 #endif
jhnwkmn 0:97a4f8cc534c 119
jhnwkmn 0:97a4f8cc534c 120 #else
jhnwkmn 0:97a4f8cc534c 121 typedef unsigned short wchar_t;
jhnwkmn 0:97a4f8cc534c 122 #endif
jhnwkmn 0:97a4f8cc534c 123
jhnwkmn 0:97a4f8cc534c 124 typedef wchar_t SQChar;
jhnwkmn 0:97a4f8cc534c 125 #define _SC(a) L##a
jhnwkmn 0:97a4f8cc534c 126 #define scstrcmp wcscmp
jhnwkmn 0:97a4f8cc534c 127 #define scsprintf swprintf
jhnwkmn 0:97a4f8cc534c 128 #define scstrlen wcslen
jhnwkmn 0:97a4f8cc534c 129 #define scstrtod wcstod
jhnwkmn 0:97a4f8cc534c 130 #ifdef _SQ64
jhnwkmn 0:97a4f8cc534c 131 #define scstrtol _wcstoi64
jhnwkmn 0:97a4f8cc534c 132 #else
jhnwkmn 0:97a4f8cc534c 133 #define scstrtol wcstol
jhnwkmn 0:97a4f8cc534c 134 #endif
jhnwkmn 0:97a4f8cc534c 135 #define scatoi _wtoi
jhnwkmn 0:97a4f8cc534c 136 #define scstrtoul wcstoul
jhnwkmn 0:97a4f8cc534c 137 #define scvsprintf vswprintf
jhnwkmn 0:97a4f8cc534c 138 #define scstrstr wcsstr
jhnwkmn 0:97a4f8cc534c 139 #define scisspace iswspace
jhnwkmn 0:97a4f8cc534c 140 #define scisdigit iswdigit
jhnwkmn 0:97a4f8cc534c 141 #define scisxdigit iswxdigit
jhnwkmn 0:97a4f8cc534c 142 #define scisalpha iswalpha
jhnwkmn 0:97a4f8cc534c 143 #define sciscntrl iswcntrl
jhnwkmn 0:97a4f8cc534c 144 #define scisalnum iswalnum
jhnwkmn 0:97a4f8cc534c 145 #define scprintf wprintf
jhnwkmn 0:97a4f8cc534c 146 #define MAX_CHAR 0xFFFF
jhnwkmn 0:97a4f8cc534c 147 #else
jhnwkmn 0:97a4f8cc534c 148 typedef char SQChar;
jhnwkmn 0:97a4f8cc534c 149 #define _SC(a) a
jhnwkmn 0:97a4f8cc534c 150 #define scstrcmp strcmp
jhnwkmn 0:97a4f8cc534c 151 #define scsprintf sprintf
jhnwkmn 0:97a4f8cc534c 152 #define scstrlen strlen
jhnwkmn 0:97a4f8cc534c 153 #define scstrtod strtod
jhnwkmn 0:97a4f8cc534c 154 #ifdef _SQ64
jhnwkmn 0:97a4f8cc534c 155 #ifdef _MSC_VER
jhnwkmn 0:97a4f8cc534c 156 #define scstrtol _strtoi64
jhnwkmn 0:97a4f8cc534c 157 #else
jhnwkmn 0:97a4f8cc534c 158 #define scstrtol strtoll
jhnwkmn 0:97a4f8cc534c 159 #endif
jhnwkmn 0:97a4f8cc534c 160 #else
jhnwkmn 0:97a4f8cc534c 161 #define scstrtol strtol
jhnwkmn 0:97a4f8cc534c 162 #endif
jhnwkmn 0:97a4f8cc534c 163 #define scatoi atoi
jhnwkmn 0:97a4f8cc534c 164 #define scstrtoul strtoul
jhnwkmn 0:97a4f8cc534c 165 #define scvsprintf vsprintf
jhnwkmn 0:97a4f8cc534c 166 #define scstrstr strstr
jhnwkmn 0:97a4f8cc534c 167 #define scisspace isspace
jhnwkmn 0:97a4f8cc534c 168 #define scisdigit isdigit
jhnwkmn 0:97a4f8cc534c 169 #define scisxdigit isxdigit
jhnwkmn 0:97a4f8cc534c 170 #define sciscntrl iscntrl
jhnwkmn 0:97a4f8cc534c 171 #define scisalpha isalpha
jhnwkmn 0:97a4f8cc534c 172 #define scisalnum isalnum
jhnwkmn 0:97a4f8cc534c 173 #define scprintf printf
jhnwkmn 0:97a4f8cc534c 174 #define MAX_CHAR 0xFF
jhnwkmn 0:97a4f8cc534c 175 #endif
jhnwkmn 0:97a4f8cc534c 176
jhnwkmn 0:97a4f8cc534c 177 #ifdef _SQ64
jhnwkmn 0:97a4f8cc534c 178 #define _PRINT_INT_PREC _SC("ll")
jhnwkmn 0:97a4f8cc534c 179 #define _PRINT_INT_FMT _SC("%lld")
jhnwkmn 0:97a4f8cc534c 180 #else
jhnwkmn 0:97a4f8cc534c 181 #define _PRINT_INT_FMT _SC("%d")
jhnwkmn 0:97a4f8cc534c 182 #endif
jhnwkmn 0:97a4f8cc534c 183
jhnwkmn 0:97a4f8cc534c 184 #define SQUIRREL_VERSION _SC("Squirrel 3.0.6 stable")
jhnwkmn 0:97a4f8cc534c 185 #define SQUIRREL_COPYRIGHT _SC("Copyright (C) 2003-2014 Alberto Demichelis")
jhnwkmn 0:97a4f8cc534c 186 #define SQUIRREL_AUTHOR _SC("Alberto Demichelis")
jhnwkmn 0:97a4f8cc534c 187 #define SQUIRREL_VERSION_NUMBER 306
jhnwkmn 0:97a4f8cc534c 188
jhnwkmn 0:97a4f8cc534c 189 #define SQ_VMSTATE_IDLE 0
jhnwkmn 0:97a4f8cc534c 190 #define SQ_VMSTATE_RUNNING 1
jhnwkmn 0:97a4f8cc534c 191 #define SQ_VMSTATE_SUSPENDED 2
jhnwkmn 0:97a4f8cc534c 192
jhnwkmn 0:97a4f8cc534c 193 #define SQUIRREL_EOB 0
jhnwkmn 0:97a4f8cc534c 194 #define SQ_BYTECODE_STREAM_TAG 0xFAFA
jhnwkmn 0:97a4f8cc534c 195
jhnwkmn 0:97a4f8cc534c 196 #define SQOBJECT_REF_COUNTED 0x08000000
jhnwkmn 0:97a4f8cc534c 197 #define SQOBJECT_NUMERIC 0x04000000
jhnwkmn 0:97a4f8cc534c 198 #define SQOBJECT_DELEGABLE 0x02000000
jhnwkmn 0:97a4f8cc534c 199 #define SQOBJECT_CANBEFALSE 0x01000000
jhnwkmn 0:97a4f8cc534c 200
jhnwkmn 0:97a4f8cc534c 201 #define SQ_MATCHTYPEMASKSTRING (-99999)
jhnwkmn 0:97a4f8cc534c 202
jhnwkmn 0:97a4f8cc534c 203 #define _RT_MASK 0x00FFFFFF
jhnwkmn 0:97a4f8cc534c 204 #define _RAW_TYPE(type) (type&_RT_MASK)
jhnwkmn 0:97a4f8cc534c 205
jhnwkmn 0:97a4f8cc534c 206 #define _RT_NULL 0x00000001
jhnwkmn 0:97a4f8cc534c 207 #define _RT_INTEGER 0x00000002
jhnwkmn 0:97a4f8cc534c 208 #define _RT_FLOAT 0x00000004
jhnwkmn 0:97a4f8cc534c 209 #define _RT_BOOL 0x00000008
jhnwkmn 0:97a4f8cc534c 210 #define _RT_STRING 0x00000010
jhnwkmn 0:97a4f8cc534c 211 #define _RT_TABLE 0x00000020
jhnwkmn 0:97a4f8cc534c 212 #define _RT_ARRAY 0x00000040
jhnwkmn 0:97a4f8cc534c 213 #define _RT_USERDATA 0x00000080
jhnwkmn 0:97a4f8cc534c 214 #define _RT_CLOSURE 0x00000100
jhnwkmn 0:97a4f8cc534c 215 #define _RT_NATIVECLOSURE 0x00000200
jhnwkmn 0:97a4f8cc534c 216 #define _RT_GENERATOR 0x00000400
jhnwkmn 0:97a4f8cc534c 217 #define _RT_USERPOINTER 0x00000800
jhnwkmn 0:97a4f8cc534c 218 #define _RT_THREAD 0x00001000
jhnwkmn 0:97a4f8cc534c 219 #define _RT_FUNCPROTO 0x00002000
jhnwkmn 0:97a4f8cc534c 220 #define _RT_CLASS 0x00004000
jhnwkmn 0:97a4f8cc534c 221 #define _RT_INSTANCE 0x00008000
jhnwkmn 0:97a4f8cc534c 222 #define _RT_WEAKREF 0x00010000
jhnwkmn 0:97a4f8cc534c 223 #define _RT_OUTER 0x00020000
jhnwkmn 0:97a4f8cc534c 224
jhnwkmn 0:97a4f8cc534c 225 typedef enum tagSQObjectType{
jhnwkmn 0:97a4f8cc534c 226 OT_NULL = (_RT_NULL|SQOBJECT_CANBEFALSE),
jhnwkmn 0:97a4f8cc534c 227 OT_INTEGER = (_RT_INTEGER|SQOBJECT_NUMERIC|SQOBJECT_CANBEFALSE),
jhnwkmn 0:97a4f8cc534c 228 OT_FLOAT = (_RT_FLOAT|SQOBJECT_NUMERIC|SQOBJECT_CANBEFALSE),
jhnwkmn 0:97a4f8cc534c 229 OT_BOOL = (_RT_BOOL|SQOBJECT_CANBEFALSE),
jhnwkmn 0:97a4f8cc534c 230 OT_STRING = (_RT_STRING|SQOBJECT_REF_COUNTED),
jhnwkmn 0:97a4f8cc534c 231 OT_TABLE = (_RT_TABLE|SQOBJECT_REF_COUNTED|SQOBJECT_DELEGABLE),
jhnwkmn 0:97a4f8cc534c 232 OT_ARRAY = (_RT_ARRAY|SQOBJECT_REF_COUNTED),
jhnwkmn 0:97a4f8cc534c 233 OT_USERDATA = (_RT_USERDATA|SQOBJECT_REF_COUNTED|SQOBJECT_DELEGABLE),
jhnwkmn 0:97a4f8cc534c 234 OT_CLOSURE = (_RT_CLOSURE|SQOBJECT_REF_COUNTED),
jhnwkmn 0:97a4f8cc534c 235 OT_NATIVECLOSURE = (_RT_NATIVECLOSURE|SQOBJECT_REF_COUNTED),
jhnwkmn 0:97a4f8cc534c 236 OT_GENERATOR = (_RT_GENERATOR|SQOBJECT_REF_COUNTED),
jhnwkmn 0:97a4f8cc534c 237 OT_USERPOINTER = _RT_USERPOINTER,
jhnwkmn 0:97a4f8cc534c 238 OT_THREAD = (_RT_THREAD|SQOBJECT_REF_COUNTED) ,
jhnwkmn 0:97a4f8cc534c 239 OT_FUNCPROTO = (_RT_FUNCPROTO|SQOBJECT_REF_COUNTED), //internal usage only
jhnwkmn 0:97a4f8cc534c 240 OT_CLASS = (_RT_CLASS|SQOBJECT_REF_COUNTED),
jhnwkmn 0:97a4f8cc534c 241 OT_INSTANCE = (_RT_INSTANCE|SQOBJECT_REF_COUNTED|SQOBJECT_DELEGABLE),
jhnwkmn 0:97a4f8cc534c 242 OT_WEAKREF = (_RT_WEAKREF|SQOBJECT_REF_COUNTED),
jhnwkmn 0:97a4f8cc534c 243 OT_OUTER = (_RT_OUTER|SQOBJECT_REF_COUNTED) //internal usage only
jhnwkmn 0:97a4f8cc534c 244 }SQObjectType;
jhnwkmn 0:97a4f8cc534c 245
jhnwkmn 0:97a4f8cc534c 246 #define ISREFCOUNTED(t) (t&SQOBJECT_REF_COUNTED)
jhnwkmn 0:97a4f8cc534c 247
jhnwkmn 0:97a4f8cc534c 248
jhnwkmn 0:97a4f8cc534c 249 typedef union tagSQObjectValue
jhnwkmn 0:97a4f8cc534c 250 {
jhnwkmn 0:97a4f8cc534c 251 struct SQTable *pTable;
jhnwkmn 0:97a4f8cc534c 252 struct SQArray *pArray;
jhnwkmn 0:97a4f8cc534c 253 struct SQClosure *pClosure;
jhnwkmn 0:97a4f8cc534c 254 struct SQOuter *pOuter;
jhnwkmn 0:97a4f8cc534c 255 struct SQGenerator *pGenerator;
jhnwkmn 0:97a4f8cc534c 256 struct SQNativeClosure *pNativeClosure;
jhnwkmn 0:97a4f8cc534c 257 struct SQString *pString;
jhnwkmn 0:97a4f8cc534c 258 struct SQUserData *pUserData;
jhnwkmn 0:97a4f8cc534c 259 SQInteger nInteger;
jhnwkmn 0:97a4f8cc534c 260 SQFloat fFloat;
jhnwkmn 0:97a4f8cc534c 261 SQUserPointer pUserPointer;
jhnwkmn 0:97a4f8cc534c 262 struct SQFunctionProto *pFunctionProto;
jhnwkmn 0:97a4f8cc534c 263 struct SQRefCounted *pRefCounted;
jhnwkmn 0:97a4f8cc534c 264 struct SQDelegable *pDelegable;
jhnwkmn 0:97a4f8cc534c 265 struct SQVM *pThread;
jhnwkmn 0:97a4f8cc534c 266 struct SQClass *pClass;
jhnwkmn 0:97a4f8cc534c 267 struct SQInstance *pInstance;
jhnwkmn 0:97a4f8cc534c 268 struct SQWeakRef *pWeakRef;
jhnwkmn 0:97a4f8cc534c 269 SQRawObjectVal raw;
jhnwkmn 0:97a4f8cc534c 270 }SQObjectValue;
jhnwkmn 0:97a4f8cc534c 271
jhnwkmn 0:97a4f8cc534c 272
jhnwkmn 0:97a4f8cc534c 273 typedef struct tagSQObject
jhnwkmn 0:97a4f8cc534c 274 {
jhnwkmn 0:97a4f8cc534c 275 SQObjectType _type;
jhnwkmn 0:97a4f8cc534c 276 SQObjectValue _unVal;
jhnwkmn 0:97a4f8cc534c 277 }SQObject;
jhnwkmn 0:97a4f8cc534c 278
jhnwkmn 0:97a4f8cc534c 279 typedef struct tagSQMemberHandle{
jhnwkmn 0:97a4f8cc534c 280 SQBool _static;
jhnwkmn 0:97a4f8cc534c 281 SQInteger _index;
jhnwkmn 0:97a4f8cc534c 282 }SQMemberHandle;
jhnwkmn 0:97a4f8cc534c 283
jhnwkmn 0:97a4f8cc534c 284 typedef struct tagSQStackInfos{
jhnwkmn 0:97a4f8cc534c 285 const SQChar* funcname;
jhnwkmn 0:97a4f8cc534c 286 const SQChar* source;
jhnwkmn 0:97a4f8cc534c 287 SQInteger line;
jhnwkmn 0:97a4f8cc534c 288 }SQStackInfos;
jhnwkmn 0:97a4f8cc534c 289
jhnwkmn 0:97a4f8cc534c 290 typedef struct SQVM* HSQUIRRELVM;
jhnwkmn 0:97a4f8cc534c 291 typedef SQObject HSQOBJECT;
jhnwkmn 0:97a4f8cc534c 292 typedef SQMemberHandle HSQMEMBERHANDLE;
jhnwkmn 0:97a4f8cc534c 293 typedef SQInteger (*SQFUNCTION)(HSQUIRRELVM);
jhnwkmn 0:97a4f8cc534c 294 typedef SQInteger (*SQRELEASEHOOK)(SQUserPointer,SQInteger size);
jhnwkmn 0:97a4f8cc534c 295 typedef void (*SQCOMPILERERROR)(HSQUIRRELVM,const SQChar * /*desc*/,const SQChar * /*source*/,SQInteger /*line*/,SQInteger /*column*/);
jhnwkmn 0:97a4f8cc534c 296 typedef void (*SQPRINTFUNCTION)(HSQUIRRELVM,const SQChar * ,...);
jhnwkmn 0:97a4f8cc534c 297 typedef void (*SQDEBUGHOOK)(HSQUIRRELVM /*v*/, SQInteger /*type*/, const SQChar * /*sourcename*/, SQInteger /*line*/, const SQChar * /*funcname*/);
jhnwkmn 0:97a4f8cc534c 298 typedef SQInteger (*SQWRITEFUNC)(SQUserPointer,SQUserPointer,SQInteger);
jhnwkmn 0:97a4f8cc534c 299 typedef SQInteger (*SQREADFUNC)(SQUserPointer,SQUserPointer,SQInteger);
jhnwkmn 0:97a4f8cc534c 300
jhnwkmn 0:97a4f8cc534c 301 typedef SQInteger (*SQLEXREADFUNC)(SQUserPointer);
jhnwkmn 0:97a4f8cc534c 302
jhnwkmn 0:97a4f8cc534c 303 typedef struct tagSQRegFunction{
jhnwkmn 0:97a4f8cc534c 304 const SQChar *name;
jhnwkmn 0:97a4f8cc534c 305 SQFUNCTION f;
jhnwkmn 0:97a4f8cc534c 306 SQInteger nparamscheck;
jhnwkmn 0:97a4f8cc534c 307 const SQChar *typemask;
jhnwkmn 0:97a4f8cc534c 308 }SQRegFunction;
jhnwkmn 0:97a4f8cc534c 309
jhnwkmn 0:97a4f8cc534c 310 typedef struct tagSQFunctionInfo {
jhnwkmn 0:97a4f8cc534c 311 SQUserPointer funcid;
jhnwkmn 0:97a4f8cc534c 312 const SQChar *name;
jhnwkmn 0:97a4f8cc534c 313 const SQChar *source;
jhnwkmn 0:97a4f8cc534c 314 }SQFunctionInfo;
jhnwkmn 0:97a4f8cc534c 315
jhnwkmn 0:97a4f8cc534c 316 /*vm*/
jhnwkmn 0:97a4f8cc534c 317 SQUIRREL_API HSQUIRRELVM sq_open(SQInteger initialstacksize);
jhnwkmn 0:97a4f8cc534c 318 SQUIRREL_API HSQUIRRELVM sq_newthread(HSQUIRRELVM friendvm, SQInteger initialstacksize);
jhnwkmn 0:97a4f8cc534c 319 SQUIRREL_API void sq_seterrorhandler(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 320 SQUIRREL_API void sq_close(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 321 SQUIRREL_API void sq_setforeignptr(HSQUIRRELVM v,SQUserPointer p);
jhnwkmn 0:97a4f8cc534c 322 SQUIRREL_API SQUserPointer sq_getforeignptr(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 323 SQUIRREL_API void sq_setprintfunc(HSQUIRRELVM v, SQPRINTFUNCTION printfunc,SQPRINTFUNCTION errfunc);
jhnwkmn 0:97a4f8cc534c 324 SQUIRREL_API SQPRINTFUNCTION sq_getprintfunc(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 325 SQUIRREL_API SQPRINTFUNCTION sq_geterrorfunc(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 326 SQUIRREL_API SQRESULT sq_suspendvm(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 327 SQUIRREL_API SQRESULT sq_wakeupvm(HSQUIRRELVM v,SQBool resumedret,SQBool retval,SQBool raiseerror,SQBool throwerror);
jhnwkmn 0:97a4f8cc534c 328 SQUIRREL_API SQInteger sq_getvmstate(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 329 SQUIRREL_API SQInteger sq_getversion();
jhnwkmn 0:97a4f8cc534c 330
jhnwkmn 0:97a4f8cc534c 331 /*compiler*/
jhnwkmn 0:97a4f8cc534c 332 SQUIRREL_API SQRESULT sq_compile(HSQUIRRELVM v,SQLEXREADFUNC read,SQUserPointer p,const SQChar *sourcename,SQBool raiseerror);
jhnwkmn 0:97a4f8cc534c 333 SQUIRREL_API SQRESULT sq_compilebuffer(HSQUIRRELVM v,const SQChar *s,SQInteger size,const SQChar *sourcename,SQBool raiseerror);
jhnwkmn 0:97a4f8cc534c 334 SQUIRREL_API void sq_enabledebuginfo(HSQUIRRELVM v, SQBool enable);
jhnwkmn 0:97a4f8cc534c 335 SQUIRREL_API void sq_notifyallexceptions(HSQUIRRELVM v, SQBool enable);
jhnwkmn 0:97a4f8cc534c 336 SQUIRREL_API void sq_setcompilererrorhandler(HSQUIRRELVM v,SQCOMPILERERROR f);
jhnwkmn 0:97a4f8cc534c 337
jhnwkmn 0:97a4f8cc534c 338 /*stack operations*/
jhnwkmn 0:97a4f8cc534c 339 SQUIRREL_API void sq_push(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 340 SQUIRREL_API void sq_pop(HSQUIRRELVM v,SQInteger nelemstopop);
jhnwkmn 0:97a4f8cc534c 341 SQUIRREL_API void sq_poptop(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 342 SQUIRREL_API void sq_remove(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 343 SQUIRREL_API SQInteger sq_gettop(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 344 SQUIRREL_API void sq_settop(HSQUIRRELVM v,SQInteger newtop);
jhnwkmn 0:97a4f8cc534c 345 SQUIRREL_API SQRESULT sq_reservestack(HSQUIRRELVM v,SQInteger nsize);
jhnwkmn 0:97a4f8cc534c 346 SQUIRREL_API SQInteger sq_cmp(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 347 SQUIRREL_API void sq_move(HSQUIRRELVM dest,HSQUIRRELVM src,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 348
jhnwkmn 0:97a4f8cc534c 349 /*object creation handling*/
jhnwkmn 0:97a4f8cc534c 350 SQUIRREL_API SQUserPointer sq_newuserdata(HSQUIRRELVM v,SQUnsignedInteger size);
jhnwkmn 0:97a4f8cc534c 351 SQUIRREL_API void sq_newtable(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 352 SQUIRREL_API void sq_newtableex(HSQUIRRELVM v,SQInteger initialcapacity);
jhnwkmn 0:97a4f8cc534c 353 SQUIRREL_API void sq_newarray(HSQUIRRELVM v,SQInteger size);
jhnwkmn 0:97a4f8cc534c 354 SQUIRREL_API void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars);
jhnwkmn 0:97a4f8cc534c 355 SQUIRREL_API SQRESULT sq_setparamscheck(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask);
jhnwkmn 0:97a4f8cc534c 356 SQUIRREL_API SQRESULT sq_bindenv(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 357 SQUIRREL_API void sq_pushstring(HSQUIRRELVM v,const SQChar *s,SQInteger len);
jhnwkmn 0:97a4f8cc534c 358 SQUIRREL_API void sq_pushfloat(HSQUIRRELVM v,SQFloat f);
jhnwkmn 0:97a4f8cc534c 359 SQUIRREL_API void sq_pushinteger(HSQUIRRELVM v,SQInteger n);
jhnwkmn 0:97a4f8cc534c 360 SQUIRREL_API void sq_pushbool(HSQUIRRELVM v,SQBool b);
jhnwkmn 0:97a4f8cc534c 361 SQUIRREL_API void sq_pushuserpointer(HSQUIRRELVM v,SQUserPointer p);
jhnwkmn 0:97a4f8cc534c 362 SQUIRREL_API void sq_pushnull(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 363 SQUIRREL_API SQObjectType sq_gettype(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 364 SQUIRREL_API SQRESULT sq_typeof(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 365 SQUIRREL_API SQInteger sq_getsize(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 366 SQUIRREL_API SQHash sq_gethash(HSQUIRRELVM v, SQInteger idx);
jhnwkmn 0:97a4f8cc534c 367 SQUIRREL_API SQRESULT sq_getbase(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 368 SQUIRREL_API SQBool sq_instanceof(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 369 SQUIRREL_API SQRESULT sq_tostring(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 370 SQUIRREL_API void sq_tobool(HSQUIRRELVM v, SQInteger idx, SQBool *b);
jhnwkmn 0:97a4f8cc534c 371 SQUIRREL_API SQRESULT sq_getstring(HSQUIRRELVM v,SQInteger idx,const SQChar **c);
jhnwkmn 0:97a4f8cc534c 372 SQUIRREL_API SQRESULT sq_getinteger(HSQUIRRELVM v,SQInteger idx,SQInteger *i);
jhnwkmn 0:97a4f8cc534c 373 SQUIRREL_API SQRESULT sq_getfloat(HSQUIRRELVM v,SQInteger idx,SQFloat *f);
jhnwkmn 0:97a4f8cc534c 374 SQUIRREL_API SQRESULT sq_getbool(HSQUIRRELVM v,SQInteger idx,SQBool *b);
jhnwkmn 0:97a4f8cc534c 375 SQUIRREL_API SQRESULT sq_getthread(HSQUIRRELVM v,SQInteger idx,HSQUIRRELVM *thread);
jhnwkmn 0:97a4f8cc534c 376 SQUIRREL_API SQRESULT sq_getuserpointer(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p);
jhnwkmn 0:97a4f8cc534c 377 SQUIRREL_API SQRESULT sq_getuserdata(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p,SQUserPointer *typetag);
jhnwkmn 0:97a4f8cc534c 378 SQUIRREL_API SQRESULT sq_settypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag);
jhnwkmn 0:97a4f8cc534c 379 SQUIRREL_API SQRESULT sq_gettypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer *typetag);
jhnwkmn 0:97a4f8cc534c 380 SQUIRREL_API void sq_setreleasehook(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook);
jhnwkmn 0:97a4f8cc534c 381 SQUIRREL_API SQChar *sq_getscratchpad(HSQUIRRELVM v,SQInteger minsize);
jhnwkmn 0:97a4f8cc534c 382 SQUIRREL_API SQRESULT sq_getfunctioninfo(HSQUIRRELVM v,SQInteger level,SQFunctionInfo *fi);
jhnwkmn 0:97a4f8cc534c 383 SQUIRREL_API SQRESULT sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparams,SQUnsignedInteger *nfreevars);
jhnwkmn 0:97a4f8cc534c 384 SQUIRREL_API SQRESULT sq_getclosurename(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 385 SQUIRREL_API SQRESULT sq_setnativeclosurename(HSQUIRRELVM v,SQInteger idx,const SQChar *name);
jhnwkmn 0:97a4f8cc534c 386 SQUIRREL_API SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p);
jhnwkmn 0:97a4f8cc534c 387 SQUIRREL_API SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag);
jhnwkmn 0:97a4f8cc534c 388 SQUIRREL_API SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger idx, SQInteger udsize);
jhnwkmn 0:97a4f8cc534c 389 SQUIRREL_API SQRESULT sq_newclass(HSQUIRRELVM v,SQBool hasbase);
jhnwkmn 0:97a4f8cc534c 390 SQUIRREL_API SQRESULT sq_createinstance(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 391 SQUIRREL_API SQRESULT sq_setattributes(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 392 SQUIRREL_API SQRESULT sq_getattributes(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 393 SQUIRREL_API SQRESULT sq_getclass(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 394 SQUIRREL_API void sq_weakref(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 395 SQUIRREL_API SQRESULT sq_getdefaultdelegate(HSQUIRRELVM v,SQObjectType t);
jhnwkmn 0:97a4f8cc534c 396 SQUIRREL_API SQRESULT sq_getmemberhandle(HSQUIRRELVM v,SQInteger idx,HSQMEMBERHANDLE *handle);
jhnwkmn 0:97a4f8cc534c 397 SQUIRREL_API SQRESULT sq_getbyhandle(HSQUIRRELVM v,SQInteger idx,const HSQMEMBERHANDLE *handle);
jhnwkmn 0:97a4f8cc534c 398 SQUIRREL_API SQRESULT sq_setbyhandle(HSQUIRRELVM v,SQInteger idx,const HSQMEMBERHANDLE *handle);
jhnwkmn 0:97a4f8cc534c 399
jhnwkmn 0:97a4f8cc534c 400 /*object manipulation*/
jhnwkmn 0:97a4f8cc534c 401 SQUIRREL_API void sq_pushroottable(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 402 SQUIRREL_API void sq_pushregistrytable(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 403 SQUIRREL_API void sq_pushconsttable(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 404 SQUIRREL_API SQRESULT sq_setroottable(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 405 SQUIRREL_API SQRESULT sq_setconsttable(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 406 SQUIRREL_API SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx, SQBool bstatic);
jhnwkmn 0:97a4f8cc534c 407 SQUIRREL_API SQRESULT sq_deleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval);
jhnwkmn 0:97a4f8cc534c 408 SQUIRREL_API SQRESULT sq_set(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 409 SQUIRREL_API SQRESULT sq_get(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 410 SQUIRREL_API SQRESULT sq_rawget(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 411 SQUIRREL_API SQRESULT sq_rawset(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 412 SQUIRREL_API SQRESULT sq_rawdeleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval);
jhnwkmn 0:97a4f8cc534c 413 SQUIRREL_API SQRESULT sq_newmember(HSQUIRRELVM v,SQInteger idx,SQBool bstatic);
jhnwkmn 0:97a4f8cc534c 414 SQUIRREL_API SQRESULT sq_rawnewmember(HSQUIRRELVM v,SQInteger idx,SQBool bstatic);
jhnwkmn 0:97a4f8cc534c 415 SQUIRREL_API SQRESULT sq_arrayappend(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 416 SQUIRREL_API SQRESULT sq_arraypop(HSQUIRRELVM v,SQInteger idx,SQBool pushval);
jhnwkmn 0:97a4f8cc534c 417 SQUIRREL_API SQRESULT sq_arrayresize(HSQUIRRELVM v,SQInteger idx,SQInteger newsize);
jhnwkmn 0:97a4f8cc534c 418 SQUIRREL_API SQRESULT sq_arrayreverse(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 419 SQUIRREL_API SQRESULT sq_arrayremove(HSQUIRRELVM v,SQInteger idx,SQInteger itemidx);
jhnwkmn 0:97a4f8cc534c 420 SQUIRREL_API SQRESULT sq_arrayinsert(HSQUIRRELVM v,SQInteger idx,SQInteger destpos);
jhnwkmn 0:97a4f8cc534c 421 SQUIRREL_API SQRESULT sq_setdelegate(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 422 SQUIRREL_API SQRESULT sq_getdelegate(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 423 SQUIRREL_API SQRESULT sq_clone(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 424 SQUIRREL_API SQRESULT sq_setfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval);
jhnwkmn 0:97a4f8cc534c 425 SQUIRREL_API SQRESULT sq_next(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 426 SQUIRREL_API SQRESULT sq_getweakrefval(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 427 SQUIRREL_API SQRESULT sq_clear(HSQUIRRELVM v,SQInteger idx);
jhnwkmn 0:97a4f8cc534c 428
jhnwkmn 0:97a4f8cc534c 429 /*calls*/
jhnwkmn 0:97a4f8cc534c 430 SQUIRREL_API SQRESULT sq_call(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror);
jhnwkmn 0:97a4f8cc534c 431 SQUIRREL_API SQRESULT sq_resume(HSQUIRRELVM v,SQBool retval,SQBool raiseerror);
jhnwkmn 0:97a4f8cc534c 432 SQUIRREL_API const SQChar *sq_getlocal(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedInteger idx);
jhnwkmn 0:97a4f8cc534c 433 SQUIRREL_API SQRESULT sq_getcallee(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 434 SQUIRREL_API const SQChar *sq_getfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval);
jhnwkmn 0:97a4f8cc534c 435 SQUIRREL_API SQRESULT sq_throwerror(HSQUIRRELVM v,const SQChar *err);
jhnwkmn 0:97a4f8cc534c 436 SQUIRREL_API SQRESULT sq_throwobject(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 437 SQUIRREL_API void sq_reseterror(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 438 SQUIRREL_API void sq_getlasterror(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 439
jhnwkmn 0:97a4f8cc534c 440 /*raw object handling*/
jhnwkmn 0:97a4f8cc534c 441 SQUIRREL_API SQRESULT sq_getstackobj(HSQUIRRELVM v,SQInteger idx,HSQOBJECT *po);
jhnwkmn 0:97a4f8cc534c 442 SQUIRREL_API void sq_pushobject(HSQUIRRELVM v,HSQOBJECT obj);
jhnwkmn 0:97a4f8cc534c 443 SQUIRREL_API void sq_addref(HSQUIRRELVM v,HSQOBJECT *po);
jhnwkmn 0:97a4f8cc534c 444 SQUIRREL_API SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po);
jhnwkmn 0:97a4f8cc534c 445 SQUIRREL_API SQUnsignedInteger sq_getrefcount(HSQUIRRELVM v,HSQOBJECT *po);
jhnwkmn 0:97a4f8cc534c 446 SQUIRREL_API void sq_resetobject(HSQOBJECT *po);
jhnwkmn 0:97a4f8cc534c 447 SQUIRREL_API const SQChar *sq_objtostring(const HSQOBJECT *o);
jhnwkmn 0:97a4f8cc534c 448 SQUIRREL_API SQBool sq_objtobool(const HSQOBJECT *o);
jhnwkmn 0:97a4f8cc534c 449 SQUIRREL_API SQInteger sq_objtointeger(const HSQOBJECT *o);
jhnwkmn 0:97a4f8cc534c 450 SQUIRREL_API SQFloat sq_objtofloat(const HSQOBJECT *o);
jhnwkmn 0:97a4f8cc534c 451 SQUIRREL_API SQUserPointer sq_objtouserpointer(const HSQOBJECT *o);
jhnwkmn 0:97a4f8cc534c 452 SQUIRREL_API SQRESULT sq_getobjtypetag(const HSQOBJECT *o,SQUserPointer * typetag);
jhnwkmn 0:97a4f8cc534c 453
jhnwkmn 0:97a4f8cc534c 454 /*GC*/
jhnwkmn 0:97a4f8cc534c 455 SQUIRREL_API SQInteger sq_collectgarbage(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 456 SQUIRREL_API SQRESULT sq_resurrectunreachable(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 457
jhnwkmn 0:97a4f8cc534c 458 /*serialization*/
jhnwkmn 0:97a4f8cc534c 459 SQUIRREL_API SQRESULT sq_writeclosure(HSQUIRRELVM vm,SQWRITEFUNC writef,SQUserPointer up);
jhnwkmn 0:97a4f8cc534c 460 SQUIRREL_API SQRESULT sq_readclosure(HSQUIRRELVM vm,SQREADFUNC readf,SQUserPointer up);
jhnwkmn 0:97a4f8cc534c 461
jhnwkmn 0:97a4f8cc534c 462 /*mem allocation*/
jhnwkmn 0:97a4f8cc534c 463 SQUIRREL_API void *sq_malloc(SQUnsignedInteger size);
jhnwkmn 0:97a4f8cc534c 464 SQUIRREL_API void *sq_realloc(void* p,SQUnsignedInteger oldsize,SQUnsignedInteger newsize);
jhnwkmn 0:97a4f8cc534c 465 SQUIRREL_API void sq_free(void *p,SQUnsignedInteger size);
jhnwkmn 0:97a4f8cc534c 466
jhnwkmn 0:97a4f8cc534c 467 /*debug*/
jhnwkmn 0:97a4f8cc534c 468 SQUIRREL_API SQRESULT sq_stackinfos(HSQUIRRELVM v,SQInteger level,SQStackInfos *si);
jhnwkmn 0:97a4f8cc534c 469 SQUIRREL_API void sq_setdebughook(HSQUIRRELVM v);
jhnwkmn 0:97a4f8cc534c 470 SQUIRREL_API void sq_setnativedebughook(HSQUIRRELVM v,SQDEBUGHOOK hook);
jhnwkmn 0:97a4f8cc534c 471
jhnwkmn 0:97a4f8cc534c 472 /*UTILITY MACRO*/
jhnwkmn 0:97a4f8cc534c 473 #define sq_isnumeric(o) ((o)._type&SQOBJECT_NUMERIC)
jhnwkmn 0:97a4f8cc534c 474 #define sq_istable(o) ((o)._type==OT_TABLE)
jhnwkmn 0:97a4f8cc534c 475 #define sq_isarray(o) ((o)._type==OT_ARRAY)
jhnwkmn 0:97a4f8cc534c 476 #define sq_isfunction(o) ((o)._type==OT_FUNCPROTO)
jhnwkmn 0:97a4f8cc534c 477 #define sq_isclosure(o) ((o)._type==OT_CLOSURE)
jhnwkmn 0:97a4f8cc534c 478 #define sq_isgenerator(o) ((o)._type==OT_GENERATOR)
jhnwkmn 0:97a4f8cc534c 479 #define sq_isnativeclosure(o) ((o)._type==OT_NATIVECLOSURE)
jhnwkmn 0:97a4f8cc534c 480 #define sq_isstring(o) ((o)._type==OT_STRING)
jhnwkmn 0:97a4f8cc534c 481 #define sq_isinteger(o) ((o)._type==OT_INTEGER)
jhnwkmn 0:97a4f8cc534c 482 #define sq_isfloat(o) ((o)._type==OT_FLOAT)
jhnwkmn 0:97a4f8cc534c 483 #define sq_isuserpointer(o) ((o)._type==OT_USERPOINTER)
jhnwkmn 0:97a4f8cc534c 484 #define sq_isuserdata(o) ((o)._type==OT_USERDATA)
jhnwkmn 0:97a4f8cc534c 485 #define sq_isthread(o) ((o)._type==OT_THREAD)
jhnwkmn 0:97a4f8cc534c 486 #define sq_isnull(o) ((o)._type==OT_NULL)
jhnwkmn 0:97a4f8cc534c 487 #define sq_isclass(o) ((o)._type==OT_CLASS)
jhnwkmn 0:97a4f8cc534c 488 #define sq_isinstance(o) ((o)._type==OT_INSTANCE)
jhnwkmn 0:97a4f8cc534c 489 #define sq_isbool(o) ((o)._type==OT_BOOL)
jhnwkmn 0:97a4f8cc534c 490 #define sq_isweakref(o) ((o)._type==OT_WEAKREF)
jhnwkmn 0:97a4f8cc534c 491 #define sq_type(o) ((o)._type)
jhnwkmn 0:97a4f8cc534c 492
jhnwkmn 0:97a4f8cc534c 493 /* deprecated */
jhnwkmn 0:97a4f8cc534c 494 #define sq_createslot(v,n) sq_newslot(v,n,SQFalse)
jhnwkmn 0:97a4f8cc534c 495
jhnwkmn 0:97a4f8cc534c 496 #define SQ_OK (0)
jhnwkmn 0:97a4f8cc534c 497 #define SQ_ERROR (-1)
jhnwkmn 0:97a4f8cc534c 498
jhnwkmn 0:97a4f8cc534c 499 #define SQ_FAILED(res) (res<0)
jhnwkmn 0:97a4f8cc534c 500 #define SQ_SUCCEEDED(res) (res>=0)
jhnwkmn 0:97a4f8cc534c 501
jhnwkmn 0:97a4f8cc534c 502 #ifdef __cplusplus
jhnwkmn 0:97a4f8cc534c 503 } /*extern "C"*/
jhnwkmn 0:97a4f8cc534c 504 #endif
jhnwkmn 0:97a4f8cc534c 505
jhnwkmn 0:97a4f8cc534c 506 #endif /*_SQUIRREL_H_*/