1 From 57ca6c191e4422ed3d53d406c9d5b47bb185489d Mon Sep 17 00:00:00 2001
2 From: zeromus <zeromus@users.noreply.github.com>
3 Date: Sat, 29 Jul 2017 14:51:26 -0500
4 Subject: [PATCH] rename `type` macro to `sqtype`
6 --- squirrel/sqapi.cpp.orig 2017-08-31 12:07:29 UTC
9 static bool sq_aux_gettypedarg(HSQUIRRELVM v,SQInteger idx,SQObjectType type,SQObjectPtr **o)
11 *o = &stack_get(v,idx);
12 - if(type(**o) != type){
13 + if(sqtype(**o) != type){
14 SQObjectPtr oval = v->PrintObjVal(**o);
15 v->Raise_Error(_SC("wrong argument type, expected '%s' got '%.50s'"),IdType2Name(type),_stringval(oval));
17 @@ -150,7 +150,7 @@ void sq_notifyallexceptions(HSQUIRRELVM v, SQBool enab
19 void sq_addref(HSQUIRRELVM v,HSQOBJECT *po)
21 - if(!ISREFCOUNTED(type(*po))) return;
22 + if(!ISREFCOUNTED(sqtype(*po))) return;
23 #ifdef NO_GARBAGE_COLLECTOR
24 __AddRef(po->_type,po->_unVal);
26 @@ -160,7 +160,7 @@ void sq_addref(HSQUIRRELVM v,HSQOBJECT *po)
28 SQUnsignedInteger sq_getrefcount(HSQUIRRELVM v,HSQOBJECT *po)
30 - if(!ISREFCOUNTED(type(*po))) return 0;
31 + if(!ISREFCOUNTED(sqtype(*po))) return 0;
32 #ifdef NO_GARBAGE_COLLECTOR
33 return po->_unVal.pRefCounted->_uiRef;
35 @@ -170,7 +170,7 @@ SQUnsignedInteger sq_getrefcount(HSQUIRRELVM v,HSQOBJE
37 SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po)
39 - if(!ISREFCOUNTED(type(*po))) return SQTrue;
40 + if(!ISREFCOUNTED(sqtype(*po))) return SQTrue;
41 #ifdef NO_GARBAGE_COLLECTOR
42 bool ret = (po->_unVal.pRefCounted->_uiRef <= 1) ? SQTrue : SQFalse;
43 __Release(po->_type,po->_unVal);
44 @@ -182,7 +182,7 @@ SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po)
46 SQUnsignedInteger sq_getvmrefcount(HSQUIRRELVM SQ_UNUSED_ARG(v), const HSQOBJECT *po)
48 - if (!ISREFCOUNTED(type(*po))) return 0;
49 + if (!ISREFCOUNTED(sqtype(*po))) return 0;
50 return po->_unVal.pRefCounted->_uiRef;
53 @@ -290,7 +290,7 @@ SQRESULT sq_newclass(HSQUIRRELVM v,SQBool hasbase)
54 SQClass *baseclass = NULL;
56 SQObjectPtr &base = stack_get(v,-1);
57 - if(type(base) != OT_CLASS)
58 + if(sqtype(base) != OT_CLASS)
59 return sq_throwerror(v,_SC("invalid base type"));
60 baseclass = _class(base);
62 @@ -304,7 +304,7 @@ SQBool sq_instanceof(HSQUIRRELVM v)
64 SQObjectPtr &inst = stack_get(v,-1);
65 SQObjectPtr &cl = stack_get(v,-2);
66 - if(type(inst) != OT_INSTANCE || type(cl) != OT_CLASS)
67 + if(sqtype(inst) != OT_INSTANCE || sqtype(cl) != OT_CLASS)
68 return sq_throwerror(v,_SC("invalid param type"));
69 return _instance(inst)->InstanceOf(_class(cl))?SQTrue:SQFalse;
71 @@ -397,14 +397,14 @@ void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUns
72 SQRESULT sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparams,SQUnsignedInteger *nfreevars)
74 SQObject o = stack_get(v, idx);
75 - if(type(o) == OT_CLOSURE) {
76 + if(sqtype(o) == OT_CLOSURE) {
77 SQClosure *c = _closure(o);
78 SQFunctionProto *proto = c->_function;
79 *nparams = (SQUnsignedInteger)proto->_nparameters;
80 *nfreevars = (SQUnsignedInteger)proto->_noutervalues;
83 - else if(type(o) == OT_NATIVECLOSURE)
84 + else if(sqtype(o) == OT_NATIVECLOSURE)
86 SQNativeClosure *c = _nativeclosure(o);
87 *nparams = (SQUnsignedInteger)c->_nparamscheck;
88 @@ -459,7 +459,7 @@ SQRESULT sq_bindenv(HSQUIRRELVM v,SQInteger idx)
91 return sq_throwerror(v,_SC("invalid environment"));
92 - SQWeakRef *w = _refcounted(env)->GetWeakRef(type(env));
93 + SQWeakRef *w = _refcounted(env)->GetWeakRef(sqtype(env));
96 SQClosure *c = _closure(o)->Clone();
97 @@ -524,7 +524,7 @@ SQRESULT sq_getclosureroot(HSQUIRRELVM v,SQInteger idx
98 SQRESULT sq_clear(HSQUIRRELVM v,SQInteger idx)
100 SQObject &o=stack_get(v,idx);
102 + switch(sqtype(o)) {
103 case OT_TABLE: _table(o)->Clear(); break;
104 case OT_ARRAY: _array(o)->Resize(0); break;
106 @@ -619,7 +619,7 @@ void sq_push(HSQUIRRELVM v,SQInteger idx)
108 SQObjectType sq_gettype(HSQUIRRELVM v,SQInteger idx)
110 - return type(stack_get(v, idx));
111 + return sqtype(stack_get(v, idx));
114 SQRESULT sq_typeof(HSQUIRRELVM v,SQInteger idx)
115 @@ -710,7 +710,7 @@ SQRESULT sq_clone(HSQUIRRELVM v,SQInteger idx)
116 SQInteger sq_getsize(HSQUIRRELVM v, SQInteger idx)
118 SQObjectPtr &o = stack_get(v, idx);
119 - SQObjectType type = type(o);
120 + SQObjectType type = sqtype(o);
122 case OT_STRING: return _string(o)->_len;
123 case OT_TABLE: return _table(o)->CountUsed();
124 @@ -741,7 +741,7 @@ SQRESULT sq_getuserdata(HSQUIRRELVM v,SQInteger idx,SQ
125 SQRESULT sq_settypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag)
127 SQObjectPtr &o = stack_get(v,idx);
129 + switch(sqtype(o)) {
130 case OT_USERDATA: _userdata(o)->_typetag = typetag; break;
131 case OT_CLASS: _class(o)->_typetag = typetag; break;
132 default: return sq_throwerror(v,_SC("invalid object type"));
133 @@ -751,7 +751,7 @@ SQRESULT sq_settypetag(HSQUIRRELVM v,SQInteger idx,SQU
135 SQRESULT sq_getobjtypetag(const HSQOBJECT *o,SQUserPointer * typetag)
138 + switch(sqtype(*o)) {
139 case OT_INSTANCE: *typetag = _instance(*o)->_class->_typetag; break;
140 case OT_USERDATA: *typetag = _userdata(*o)->_typetag; break;
141 case OT_CLASS: *typetag = _class(*o)->_typetag; break;
142 @@ -779,7 +779,7 @@ SQRESULT sq_getuserpointer(HSQUIRRELVM v, SQInteger id
143 SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p)
145 SQObjectPtr &o = stack_get(v,idx);
146 - if(type(o) != OT_INSTANCE) return sq_throwerror(v,_SC("the object is not a class instance"));
147 + if(sqtype(o) != OT_INSTANCE) return sq_throwerror(v,_SC("the object is not a class instance"));
148 _instance(o)->_userpointer = p;
151 @@ -787,7 +787,7 @@ SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx
152 SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger idx, SQInteger udsize)
154 SQObjectPtr &o = stack_get(v,idx);
155 - if(type(o) != OT_CLASS) return sq_throwerror(v,_SC("the object is not a class"));
156 + if(sqtype(o) != OT_CLASS) return sq_throwerror(v,_SC("the object is not a class"));
157 if(_class(o)->_locked) return sq_throwerror(v,_SC("the class is locked"));
158 _class(o)->_udsize = udsize;
160 @@ -797,7 +797,7 @@ SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger id
161 SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag)
163 SQObjectPtr &o = stack_get(v,idx);
164 - if(type(o) != OT_INSTANCE) return sq_throwerror(v,_SC("the object is not a class instance"));
165 + if(sqtype(o) != OT_INSTANCE) return sq_throwerror(v,_SC("the object is not a class instance"));
166 (*p) = _instance(o)->_userpointer;
168 SQClass *cl = _instance(o)->_class;
169 @@ -854,9 +854,9 @@ SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx, SQBo
171 sq_aux_paramscheck(v, 3);
172 SQObjectPtr &self = stack_get(v, idx);
173 - if(type(self) == OT_TABLE || type(self) == OT_CLASS) {
174 + if(sqtype(self) == OT_TABLE || sqtype(self) == OT_CLASS) {
175 SQObjectPtr &key = v->GetUp(-2);
176 - if(type(key) == OT_NULL) return sq_throwerror(v, _SC("null is not a valid key"));
177 + if(sqtype(key) == OT_NULL) return sq_throwerror(v, _SC("null is not a valid key"));
178 v->NewSlot(self, key, v->GetUp(-1),bstatic?true:false);
181 @@ -869,7 +869,7 @@ SQRESULT sq_deleteslot(HSQUIRRELVM v,SQInteger idx,SQB
183 _GETSAFE_OBJ(v, idx, OT_TABLE,self);
184 SQObjectPtr &key = v->GetUp(-1);
185 - if(type(key) == OT_NULL) return sq_throwerror(v, _SC("null is not a valid key"));
186 + if(sqtype(key) == OT_NULL) return sq_throwerror(v, _SC("null is not a valid key"));
188 if(!v->DeleteSlot(*self, key, res)){
190 @@ -894,11 +894,11 @@ SQRESULT sq_rawset(HSQUIRRELVM v,SQInteger idx)
192 SQObjectPtr &self = stack_get(v, idx);
193 SQObjectPtr &key = v->GetUp(-2);
194 - if(type(key) == OT_NULL) {
195 + if(sqtype(key) == OT_NULL) {
197 return sq_throwerror(v, _SC("null key"));
199 - switch(type(self)) {
200 + switch(sqtype(self)) {
202 _table(self)->NewSlot(key, v->GetUp(-1));
204 @@ -931,9 +931,9 @@ SQRESULT sq_rawset(HSQUIRRELVM v,SQInteger idx)
205 SQRESULT sq_newmember(HSQUIRRELVM v,SQInteger idx,SQBool bstatic)
207 SQObjectPtr &self = stack_get(v, idx);
208 - if(type(self) != OT_CLASS) return sq_throwerror(v, _SC("new member only works with classes"));
209 + if(sqtype(self) != OT_CLASS) return sq_throwerror(v, _SC("new member only works with classes"));
210 SQObjectPtr &key = v->GetUp(-3);
211 - if(type(key) == OT_NULL) return sq_throwerror(v, _SC("null key"));
212 + if(sqtype(key) == OT_NULL) return sq_throwerror(v, _SC("null key"));
213 if(!v->NewSlotA(self,key,v->GetUp(-2),v->GetUp(-1),bstatic?true:false,false))
216 @@ -942,9 +942,9 @@ SQRESULT sq_newmember(HSQUIRRELVM v,SQInteger idx,SQBo
217 SQRESULT sq_rawnewmember(HSQUIRRELVM v,SQInteger idx,SQBool bstatic)
219 SQObjectPtr &self = stack_get(v, idx);
220 - if(type(self) != OT_CLASS) return sq_throwerror(v, _SC("new member only works with classes"));
221 + if(sqtype(self) != OT_CLASS) return sq_throwerror(v, _SC("new member only works with classes"));
222 SQObjectPtr &key = v->GetUp(-3);
223 - if(type(key) == OT_NULL) return sq_throwerror(v, _SC("null key"));
224 + if(sqtype(key) == OT_NULL) return sq_throwerror(v, _SC("null key"));
225 if(!v->NewSlotA(self,key,v->GetUp(-2),v->GetUp(-1),bstatic?true:false,true))
228 @@ -954,19 +954,19 @@ SQRESULT sq_setdelegate(HSQUIRRELVM v,SQInteger idx)
230 SQObjectPtr &self = stack_get(v, idx);
231 SQObjectPtr &mt = v->GetUp(-1);
232 - SQObjectType type = type(self);
233 + SQObjectType type = sqtype(self);
236 - if(type(mt) == OT_TABLE) {
237 + if(sqtype(mt) == OT_TABLE) {
238 if(!_table(self)->SetDelegate(_table(mt))) return sq_throwerror(v, _SC("delagate cycle")); v->Pop();}
239 - else if(type(mt)==OT_NULL) {
240 + else if(sqtype(mt)==OT_NULL) {
241 _table(self)->SetDelegate(NULL); v->Pop(); }
242 else return sq_aux_invalidtype(v,type);
245 - if(type(mt)==OT_TABLE) {
246 + if(sqtype(mt)==OT_TABLE) {
247 _userdata(self)->SetDelegate(_table(mt)); v->Pop(); }
248 - else if(type(mt)==OT_NULL) {
249 + else if(sqtype(mt)==OT_NULL) {
250 _userdata(self)->SetDelegate(NULL); v->Pop(); }
251 else return sq_aux_invalidtype(v, type);
253 @@ -997,7 +997,7 @@ SQRESULT sq_rawdeleteslot(HSQUIRRELVM v,SQInteger idx,
254 SQRESULT sq_getdelegate(HSQUIRRELVM v,SQInteger idx)
256 SQObjectPtr &self=stack_get(v,idx);
257 - switch(type(self)){
258 + switch(sqtype(self)){
261 if(!_delegable(self)->_delegate){
262 @@ -1026,7 +1026,7 @@ SQRESULT sq_rawget(HSQUIRRELVM v,SQInteger idx)
264 SQObjectPtr &self=stack_get(v,idx);
265 SQObjectPtr &obj = v->GetUp(-1);
266 - switch(type(self)) {
267 + switch(sqtype(self)) {
269 if(_table(self)->Get(obj,obj))
271 @@ -1076,7 +1076,7 @@ const SQChar *sq_getlocal(HSQUIRRELVM v,SQUnsignedInte
272 stackbase-=ci._prevstkbase;
274 SQVM::CallInfo &ci=v->_callsstack[lvl];
275 - if(type(ci._closure)!=OT_CLOSURE)
276 + if(sqtype(ci._closure)!=OT_CLOSURE)
278 SQClosure *c=_closure(ci._closure);
279 SQFunctionProto *func=c->_function;
280 @@ -1137,7 +1137,7 @@ SQRESULT sq_reservestack(HSQUIRRELVM v,SQInteger nsize
282 SQRESULT sq_resume(HSQUIRRELVM v,SQBool retval,SQBool raiseerror)
284 - if (type(v->GetUp(-1)) == OT_GENERATOR)
285 + if (sqtype(v->GetUp(-1)) == OT_GENERATOR)
287 v->PushNull(); //retval
288 if (!v->Execute(v->GetUp(-2), 0, v->_top, v->GetUp(-1), raiseerror, SQVM::ET_RESUME_GENERATOR))
289 @@ -1201,7 +1201,7 @@ void sq_setreleasehook(HSQUIRRELVM v,SQInteger idx,SQR
291 if(sq_gettop(v) >= 1){
292 SQObjectPtr &ud=stack_get(v,idx);
293 - switch( type(ud) ) {
294 + switch( sqtype(ud) ) {
295 case OT_USERDATA: _userdata(ud)->_hook = hook; break;
296 case OT_INSTANCE: _instance(ud)->_hook = hook; break;
297 case OT_CLASS: _class(ud)->_hook = hook; break;
298 @@ -1214,7 +1214,7 @@ SQRELEASEHOOK sq_getreleasehook(HSQUIRRELVM v,SQIntege
300 if(sq_gettop(v) >= 1){
301 SQObjectPtr &ud=stack_get(v,idx);
302 - switch( type(ud) ) {
303 + switch( sqtype(ud) ) {
304 case OT_USERDATA: return _userdata(ud)->_hook; break;
305 case OT_INSTANCE: return _instance(ud)->_hook; break;
306 case OT_CLASS: return _class(ud)->_hook; break;
307 @@ -1296,7 +1296,7 @@ const SQChar *sq_getfreevariable(HSQUIRRELVM v,SQInteg
309 SQObjectPtr &self=stack_get(v,idx);
310 const SQChar *name = NULL;
312 + switch(sqtype(self))
315 SQClosure *clo = _closure(self);
316 @@ -1324,7 +1324,7 @@ const SQChar *sq_getfreevariable(HSQUIRRELVM v,SQInteg
317 SQRESULT sq_setfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval)
319 SQObjectPtr &self=stack_get(v,idx);
321 + switch(sqtype(self))
324 SQFunctionProto *fp = _closure(self)->_function;
325 @@ -1341,7 +1341,7 @@ SQRESULT sq_setfreevariable(HSQUIRRELVM v,SQInteger id
326 else return sq_throwerror(v,_SC("invalid free var index"));
329 - return sq_aux_invalidtype(v,type(self));
330 + return sq_aux_invalidtype(v, sqtype(self));
334 @@ -1354,7 +1354,7 @@ SQRESULT sq_setattributes(HSQUIRRELVM v,SQInteger idx)
335 SQObjectPtr &key = stack_get(v,-2);
336 SQObjectPtr &val = stack_get(v,-1);
338 - if(type(key) == OT_NULL) {
339 + if(sqtype(key) == OT_NULL) {
340 attrs = _class(*o)->_attributes;
341 _class(*o)->_attributes = val;
343 @@ -1375,7 +1375,7 @@ SQRESULT sq_getattributes(HSQUIRRELVM v,SQInteger idx)
344 _GETSAFE_OBJ(v, idx, OT_CLASS,o);
345 SQObjectPtr &key = stack_get(v,-1);
347 - if(type(key) == OT_NULL) {
348 + if(sqtype(key) == OT_NULL) {
349 attrs = _class(*o)->_attributes;
352 @@ -1407,7 +1407,7 @@ SQRESULT sq_getmemberhandle(HSQUIRRELVM v,SQInteger id
354 SQRESULT _getmemberbyhandle(HSQUIRRELVM v,SQObjectPtr &self,const HSQMEMBERHANDLE *handle,SQObjectPtr *&val)
356 - switch(type(self)) {
357 + switch(sqtype(self)) {
359 SQInstance *i = _instance(self);
360 if(handle->_static) {
361 @@ -1490,8 +1490,8 @@ SQRESULT sq_createinstance(HSQUIRRELVM v,SQInteger idx
362 void sq_weakref(HSQUIRRELVM v,SQInteger idx)
364 SQObject &o=stack_get(v,idx);
365 - if(ISREFCOUNTED(type(o))) {
366 - v->Push(_refcounted(o)->GetWeakRef(type(o)));
367 + if(ISREFCOUNTED(sqtype(o))) {
368 + v->Push(_refcounted(o)->GetWeakRef(sqtype(o)));
372 @@ -1500,7 +1500,7 @@ void sq_weakref(HSQUIRRELVM v,SQInteger idx)
373 SQRESULT sq_getweakrefval(HSQUIRRELVM v,SQInteger idx)
375 SQObjectPtr &o = stack_get(v,idx);
376 - if(type(o) != OT_WEAKREF) {
377 + if(sqtype(o) != OT_WEAKREF) {
378 return sq_throwerror(v,_SC("the object must be a weakref"));
380 v->Push(_weakref(o)->_obj);
381 @@ -1529,7 +1529,7 @@ SQRESULT sq_getdefaultdelegate(HSQUIRRELVM v,SQObjectT
382 SQRESULT sq_next(HSQUIRRELVM v,SQInteger idx)
384 SQObjectPtr o=stack_get(v,idx),&refpos = stack_get(v,-1),realkey,val;
385 - if(type(o) == OT_GENERATOR) {
386 + if(sqtype(o) == OT_GENERATOR) {
387 return sq_throwerror(v,_SC("cannot iterate a generator"));
390 --- squirrel/sqbaselib.cpp.orig 2017-08-31 12:07:29 UTC
391 +++ squirrel/sqbaselib.cpp
392 @@ -169,7 +169,7 @@ static SQInteger get_slice_params(HSQUIRRELVM v,SQInte
395 SQObjectPtr &start=stack_get(v,2);
396 - if(type(start)!=OT_NULL && sq_isnumeric(start)){
397 + if(sqtype(start)!=OT_NULL && sq_isnumeric(start)){
398 sidx=tointeger(start);
401 @@ -340,7 +340,7 @@ static SQInteger default_delegate_len(HSQUIRRELVM v)
402 static SQInteger default_delegate_tofloat(HSQUIRRELVM v)
404 SQObjectPtr &o=stack_get(v,1);
409 if(str2num(_stringval(o),res,10)){
410 @@ -369,7 +369,7 @@ static SQInteger default_delegate_tointeger(HSQUIRRELV
411 if(sq_gettop(v) > 1) {
412 sq_getinteger(v,2,&base);
418 if(str2num(_stringval(o),res,base)){
419 @@ -931,7 +931,7 @@ static SQInteger closure_setroot(HSQUIRRELVM v)
420 static SQInteger closure_getinfos(HSQUIRRELVM v) {
421 SQObject o = stack_get(v,1);
422 SQTable *res = SQTable::Create(_ss(v),4);
423 - if(type(o) == OT_CLOSURE) {
424 + if(sqtype(o) == OT_CLOSURE) {
425 SQFunctionProto *f = _closure(o)->_function;
426 SQInteger nparams = f->_nparameters + (f->_varparams?1:0);
427 SQObjectPtr params = SQArray::Create(_ss(v),nparams);
428 @@ -1010,7 +1010,7 @@ const SQRegFunction SQSharedState::_generator_default_
429 static SQInteger thread_call(HSQUIRRELVM v)
431 SQObjectPtr o = stack_get(v,1);
432 - if(type(o) == OT_THREAD) {
433 + if(sqtype(o) == OT_THREAD) {
434 SQInteger nparams = sq_gettop(v);
435 _thread(o)->Push(_thread(o)->_roottable);
436 for(SQInteger i = 2; i<(nparams+1); i++)
437 @@ -1029,7 +1029,7 @@ static SQInteger thread_call(HSQUIRRELVM v)
438 static SQInteger thread_wakeup(HSQUIRRELVM v)
440 SQObjectPtr o = stack_get(v,1);
441 - if(type(o) == OT_THREAD) {
442 + if(sqtype(o) == OT_THREAD) {
443 SQVM *thread = _thread(o);
444 SQInteger state = sq_getvmstate(thread);
445 if(state != SQ_VMSTATE_SUSPENDED) {
446 @@ -1065,7 +1065,7 @@ static SQInteger thread_wakeup(HSQUIRRELVM v)
447 static SQInteger thread_wakeupthrow(HSQUIRRELVM v)
449 SQObjectPtr o = stack_get(v,1);
450 - if(type(o) == OT_THREAD) {
451 + if(sqtype(o) == OT_THREAD) {
452 SQVM *thread = _thread(o);
453 SQInteger state = sq_getvmstate(thread);
454 if(state != SQ_VMSTATE_SUSPENDED) {
455 @@ -1125,7 +1125,7 @@ static SQInteger thread_getstatus(HSQUIRRELVM v)
456 static SQInteger thread_getstackinfos(HSQUIRRELVM v)
458 SQObjectPtr o = stack_get(v,1);
459 - if(type(o) == OT_THREAD) {
460 + if(sqtype(o) == OT_THREAD) {
461 SQVM *thread = _thread(o);
462 SQInteger threadtop = sq_gettop(thread);
464 @@ -1134,7 +1134,7 @@ static SQInteger thread_getstackinfos(HSQUIRRELVM v)
467 sq_settop(thread,threadtop);
468 - if(type(thread->_lasterror) == OT_STRING) {
469 + if(sqtype(thread->_lasterror) == OT_STRING) {
470 sq_throwerror(v,_stringval(thread->_lasterror));
473 --- squirrel/sqclass.cpp.orig 2017-08-31 12:07:29 UTC
474 +++ squirrel/sqclass.cpp
475 @@ -53,7 +53,7 @@ SQClass::~SQClass()
476 bool SQClass::NewSlot(SQSharedState *ss,const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic)
479 - bool belongs_to_static_table = type(val) == OT_CLOSURE || type(val) == OT_NATIVECLOSURE || bstatic;
480 + bool belongs_to_static_table = sqtype(val) == OT_CLOSURE || sqtype(val) == OT_NATIVECLOSURE || bstatic;
481 if(_locked && !belongs_to_static_table)
482 return false; //the class already has an instance so cannot be modified
483 if(_members->Get(key,temp) && _isfield(temp)) //overrides the default value
484 @@ -63,18 +63,18 @@ bool SQClass::NewSlot(SQSharedState *ss,const SQObject
486 if(belongs_to_static_table) {
488 - if((type(val) == OT_CLOSURE || type(val) == OT_NATIVECLOSURE) &&
489 + if((sqtype(val) == OT_CLOSURE || sqtype(val) == OT_NATIVECLOSURE) &&
490 (mmidx = ss->GetMetaMethodIdxByName(key)) != -1) {
491 _metamethods[mmidx] = val;
494 SQObjectPtr theval = val;
495 - if(_base && type(val) == OT_CLOSURE) {
496 + if(_base && sqtype(val) == OT_CLOSURE) {
497 theval = _closure(val)->Clone();
498 _closure(theval)->_base = _base;
499 __ObjAddRef(_base); //ref for the closure
501 - if(type(temp) == OT_NULL) {
502 + if(sqtype(temp) == OT_NULL) {
504 SQVM::IsEqual(ss->_constructoridx, key, isconstructor);
506 @@ -191,7 +191,7 @@ SQInstance::~SQInstance()
508 bool SQInstance::GetMetaMethod(SQVM SQ_UNUSED_ARG(*v),SQMetaMethod mm,SQObjectPtr &res)
510 - if(type(_class->_metamethods[mm]) != OT_NULL) {
511 + if(sqtype(_class->_metamethods[mm]) != OT_NULL) {
512 res = _class->_metamethods[mm];
515 --- squirrel/sqcompiler.cpp.orig 2017-08-31 12:07:29 UTC
516 +++ squirrel/sqcompiler.cpp
517 @@ -191,7 +191,7 @@ class SQCompiler (public)
520 if(_raiseerror && _ss(_vm)->_compilererrorhandler) {
521 - _ss(_vm)->_compilererrorhandler(_vm, _compilererror, type(_sourcename) == OT_STRING?_stringval(_sourcename):_SC("unknown"),
522 + _ss(_vm)->_compilererrorhandler(_vm, _compilererror, sqtype(_sourcename) == OT_STRING?_stringval(_sourcename):_SC("unknown"),
523 _lex._currentline, _lex._currentcolumn);
525 _vm->_lasterror = SQString::Create(_ss(_vm), _compilererror, -1);
526 @@ -762,7 +762,7 @@ class SQCompiler (public)
527 /* Handle named constant */
528 SQObjectPtr constval;
530 - if(type(constant) == OT_TABLE) {
531 + if(sqtype(constant) == OT_TABLE) {
533 constid = Expect(TK_IDENTIFIER);
534 if(!_table(constant)->Get(constid, constval)) {
535 @@ -776,7 +776,7 @@ class SQCompiler (public)
536 _es.epos = _fs->PushTarget();
538 /* generate direct or literal function depending on size */
539 - SQObjectType ctype = type(constval);
540 + SQObjectType ctype = sqtype(constval);
542 case OT_INTEGER: EmitLoadConstInt(_integer(constval),_es.epos); break;
543 case OT_FLOAT: EmitLoadConstFloat(_float(constval),_es.epos); break;
544 --- squirrel/sqdebug.cpp.orig 2017-08-31 12:07:29 UTC
545 +++ squirrel/sqdebug.cpp
546 @@ -17,8 +17,8 @@ SQRESULT sq_getfunctioninfo(HSQUIRRELVM v,SQInteger le
547 SQClosure *c = _closure(ci._closure);
548 SQFunctionProto *proto = c->_function;
550 - fi->name = type(proto->_name) == OT_STRING?_stringval(proto->_name):_SC("unknown");
551 - fi->source = type(proto->_sourcename) == OT_STRING?_stringval(proto->_sourcename):_SC("unknown");
552 + fi->name = sqtype(proto->_name) == OT_STRING?_stringval(proto->_name):_SC("unknown");
553 + fi->source = sqtype(proto->_sourcename) == OT_STRING?_stringval(proto->_sourcename):_SC("unknown");
554 fi->line = proto->_lineinfos[0]._line;
557 @@ -32,12 +32,12 @@ SQRESULT sq_stackinfos(HSQUIRRELVM v, SQInteger level,
558 if (cssize > level) {
559 memset(si, 0, sizeof(SQStackInfos));
560 SQVM::CallInfo &ci = v->_callsstack[cssize-level-1];
561 - switch (type(ci._closure)) {
562 + switch (sqtype(ci._closure)) {
564 SQFunctionProto *func = _closure(ci._closure)->_function;
565 - if (type(func->_name) == OT_STRING)
566 + if (sqtype(func->_name) == OT_STRING)
567 si->funcname = _stringval(func->_name);
568 - if (type(func->_sourcename) == OT_STRING)
569 + if (sqtype(func->_sourcename) == OT_STRING)
570 si->source = _stringval(func->_sourcename);
571 si->line = func->GetLine(ci._ip);
573 @@ -45,7 +45,7 @@ SQRESULT sq_stackinfos(HSQUIRRELVM v, SQInteger level,
574 case OT_NATIVECLOSURE:
575 si->source = _SC("NATIVE");
576 si->funcname = _SC("unknown");
577 - if(type(_nativeclosure(ci._closure)->_name) == OT_STRING)
578 + if(sqtype(_nativeclosure(ci._closure)->_name) == OT_STRING)
579 si->funcname = _stringval(_nativeclosure(ci._closure)->_name);
582 @@ -73,7 +73,7 @@ void SQVM::Raise_Error(const SQObjectPtr &desc)
584 SQString *SQVM::PrintObjVal(const SQObjectPtr &o)
587 + switch(sqtype(o)) {
588 case OT_STRING: return _string(o);
590 scsprintf(_sp(sq_rsl(NUMBER_MAX_CHAR+1)),sq_rsl(NUMBER_MAX_CHAR), _PRINT_INT_FMT, _integer(o));
591 --- squirrel/sqfuncstate.cpp.orig 2017-08-31 12:07:29 UTC
592 +++ squirrel/sqfuncstate.cpp
593 @@ -77,7 +77,7 @@ SQInstructionDesc g_InstrDesc[]={
595 void DumpLiteral(SQObjectPtr &o)
599 case OT_STRING: scprintf(_SC("\"%s\""),_stringval(o));break;
600 case OT_FLOAT: scprintf(_SC("{%f}"),_float(o));break;
601 case OT_INTEGER: scprintf(_SC("{") _PRINT_INT_FMT _SC("}"),_integer(o));break;
602 @@ -290,7 +290,7 @@ SQInteger SQFuncState::PopTarget()
603 SQUnsignedInteger npos=_targetstack.back();
604 assert(npos < _vlocals.size());
605 SQLocalVarInfo &t = _vlocals[npos];
606 - if(type(t._name)==OT_NULL){
607 + if(sqtype(t._name)==OT_NULL){
610 _targetstack.pop_back();
611 @@ -322,7 +322,7 @@ void SQFuncState::SetStackSize(SQInteger n)
614 SQLocalVarInfo lvi = _vlocals.back();
615 - if(type(lvi._name)!=OT_NULL){
616 + if(sqtype(lvi._name)!=OT_NULL){
617 if(lvi._end_op == UINT_MINUS_ONE) { //this means is an outer
620 @@ -346,7 +346,7 @@ bool SQFuncState::IsConstant(const SQObject &name,SQOb
621 bool SQFuncState::IsLocal(SQUnsignedInteger stkpos)
623 if(stkpos>=_vlocals.size())return false;
624 - else if(type(_vlocals[stkpos]._name)!=OT_NULL)return true;
625 + else if(sqtype(_vlocals[stkpos]._name)!=OT_NULL)return true;
629 @@ -369,7 +369,7 @@ SQInteger SQFuncState::GetLocalVariable(const SQObject
630 SQInteger locals=_vlocals.size();
632 SQLocalVarInfo &lvi = _vlocals[locals-1];
633 - if(type(lvi._name)==OT_STRING && _string(lvi._name)==_string(name)){
634 + if(sqtype(lvi._name)==OT_STRING && _string(lvi._name)==_string(name)){
638 --- squirrel/sqobject.cpp.orig 2017-08-31 12:07:29 UTC
639 +++ squirrel/sqobject.cpp
640 @@ -43,7 +43,7 @@ const SQChar *IdType2Name(SQObjectType type)
642 const SQChar *GetTypeName(const SQObjectPtr &obj1)
644 - return IdType2Name(type(obj1));
645 + return IdType2Name(sqtype(obj1));
648 SQString *SQString::Create(SQSharedState *ss,const SQChar *s,SQInteger len)
649 @@ -72,7 +72,7 @@ SQInteger SQString::Next(const SQObjectPtr &refpos, SQ
651 SQUnsignedInteger TranslateIndex(const SQObjectPtr &idx)
654 + switch(sqtype(idx)){
658 @@ -139,7 +139,7 @@ bool SQGenerator::Yield(SQVM *v,SQInteger target)
661 SQObject _this = v->_stack[v->_stackbase];
662 - _stack._vals[0] = ISREFCOUNTED(type(_this)) ? SQObjectPtr(_refcounted(_this)->GetWeakRef(type(_this))) : _this;
663 + _stack._vals[0] = ISREFCOUNTED(sqtype(_this)) ? SQObjectPtr(_refcounted(_this)->GetWeakRef(sqtype(_this))) : _this;
664 for(SQInteger n =1; n<target; n++) {
665 _stack._vals[n] = v->_stack[v->_stackbase+n];
667 @@ -191,7 +191,7 @@ bool SQGenerator::Resume(SQVM *v,SQObjectPtr &dest)
668 et._stacksize += newbase;
670 SQObject _this = _stack._vals[0];
671 - v->_stack[v->_stackbase] = type(_this) == OT_WEAKREF ? _weakref(_this)->_obj : _this;
672 + v->_stack[v->_stackbase] = sqtype(_this) == OT_WEAKREF ? _weakref(_this)->_obj : _this;
674 for(SQInteger n = 1; n<size; n++) {
675 v->_stack[v->_stackbase+n] = _stack._vals[n];
676 @@ -312,9 +312,9 @@ bool CheckTag(HSQUIRRELVM v,SQWRITEFUNC read,SQUserPoi
678 bool WriteObject(HSQUIRRELVM v,SQUserPointer up,SQWRITEFUNC write,SQObjectPtr &o)
680 - SQUnsignedInteger32 _type = (SQUnsignedInteger32)type(o);
681 + SQUnsignedInteger32 _type = (SQUnsignedInteger32)sqtype(o);
682 _CHECK_IO(SafeWrite(v,write,up,&_type,sizeof(_type)));
686 _CHECK_IO(SafeWrite(v,write,up,&_string(o)->_len,sizeof(SQInteger)));
687 _CHECK_IO(SafeWrite(v,write,up,_stringval(o),sq_rsl(_string(o)->_len)));
688 --- squirrel/sqobject.h.orig 2017-08-31 12:07:29 UTC
689 +++ squirrel/sqobject.h
690 @@ -101,7 +101,7 @@ struct SQWeakRef : SQRefCounted
694 -#define _realval(o) (type((o)) != OT_WEAKREF?(SQObject)o:_weakref(o)->_obj)
695 +#define _realval(o) (sqtype((o)) != OT_WEAKREF?(SQObject)o:_weakref(o)->_obj)
699 @@ -128,8 +128,8 @@ struct SQObjectPtr;
703 -#define type(obj) ((obj)._type)
704 -#define is_delegable(t) (type(t)&SQOBJECT_DELEGABLE)
705 +#define sqtype(obj) ((obj)._type)
706 +#define is_delegable(t) (sqtype(t)&SQOBJECT_DELEGABLE)
707 #define raw_type(obj) _RAW_TYPE((obj)._type)
709 #define _integer(obj) ((obj)._unVal.nInteger)
710 @@ -155,8 +155,8 @@ struct SQObjectPtr;
711 #define _stringval(obj) (obj)._unVal.pString->_val
712 #define _userdataval(obj) ((SQUserPointer)sq_aligning((obj)._unVal.pUserData + 1))
714 -#define tofloat(num) ((type(num)==OT_INTEGER)?(SQFloat)_integer(num):_float(num))
715 -#define tointeger(num) ((type(num)==OT_FLOAT)?(SQInteger)_float(num):_integer(num))
716 +#define tofloat(num) ((sqtype(num)==OT_INTEGER)?(SQFloat)_integer(num):_float(num))
717 +#define tointeger(num) ((sqtype(num)==OT_FLOAT)?(SQInteger)_float(num):_integer(num))
718 /////////////////////////////////////////////////////////////////////////////////////
719 /////////////////////////////////////////////////////////////////////////////////////
720 #if defined(SQUSEDOUBLE) && !defined(_SQ64) || !defined(SQUSEDOUBLE) && defined(_SQ64)
721 --- squirrel/sqstate.cpp.orig 2017-08-31 12:07:29 UTC
722 +++ squirrel/sqstate.cpp
723 @@ -221,7 +221,7 @@ SQSharedState::~SQSharedState()
725 SQInteger SQSharedState::GetMetaMethodIdxByName(const SQObjectPtr &name)
727 - if(type(name) != OT_STRING)
728 + if(sqtype(name) != OT_STRING)
731 if(_table(_metamethodsmap)->Get(name,ret)) {
732 @@ -234,7 +234,7 @@ SQInteger SQSharedState::GetMetaMethodIdxByName(const
734 void SQSharedState::MarkObject(SQObjectPtr &o,SQCollectable **chain)
738 case OT_TABLE:_table(o)->Mark(chain);break;
739 case OT_ARRAY:_array(o)->Mark(chain);break;
740 case OT_USERDATA:_userdata(o)->Mark(chain);break;
741 @@ -423,7 +423,7 @@ void RefTable::Mark(SQCollectable **chain)
743 RefNode *nodes = (RefNode *)_nodes;
744 for(SQUnsignedInteger n = 0; n < _numofslots; n++) {
745 - if(type(nodes->obj) != OT_NULL) {
746 + if(sqtype(nodes->obj) != OT_NULL) {
747 SQSharedState::MarkObject(nodes->obj,chain);
750 @@ -485,7 +485,7 @@ void RefTable::Resize(SQUnsignedInteger size)
752 SQUnsignedInteger nfound = 0;
753 for(SQUnsignedInteger n = 0; n < oldnumofslots; n++) {
754 - if(type(t->obj) != OT_NULL) {
755 + if(sqtype(t->obj) != OT_NULL) {
757 assert(t->refs != 0);
758 RefNode *nn = Add(::HashObj(t->obj)&(_numofslots-1),t->obj);
759 @@ -518,7 +518,7 @@ RefTable::RefNode *RefTable::Get(SQObject &obj,SQHash
760 mainpos = ::HashObj(obj)&(_numofslots-1);
762 for (ref = _buckets[mainpos]; ref; ) {
763 - if(_rawval(ref->obj) == _rawval(obj) && type(ref->obj) == type(obj))
764 + if(_rawval(ref->obj) == _rawval(obj) && sqtype(ref->obj) == sqtype(obj))
768 --- squirrel/sqtable.cpp.orig 2017-08-31 12:07:29 UTC
769 +++ squirrel/sqtable.cpp
770 @@ -62,7 +62,7 @@ void SQTable::Rehash(bool force)
772 for (SQInteger i=0; i<oldsize; i++) {
773 _HashNode *old = nold+i;
774 - if (type(old->key) != OT_NULL)
775 + if (sqtype(old->key) != OT_NULL)
776 NewSlot(old->key,old->val);
778 for(SQInteger k=0;k<oldsize;k++)
779 @@ -107,7 +107,7 @@ SQTable *SQTable::Clone()
781 bool SQTable::Get(const SQObjectPtr &key,SQObjectPtr &val)
783 - if(type(key) == OT_NULL)
784 + if(sqtype(key) == OT_NULL)
786 _HashNode *n = _Get(key, HashObj(key) & (_numofnodes - 1));
788 @@ -118,7 +118,7 @@ bool SQTable::Get(const SQObjectPtr &key,SQObjectPtr &
790 bool SQTable::NewSlot(const SQObjectPtr &key,const SQObjectPtr &val)
792 - assert(type(key) != OT_NULL);
793 + assert(sqtype(key) != OT_NULL);
794 SQHash h = HashObj(key) & (_numofnodes - 1);
795 _HashNode *n = _Get(key, h);
797 @@ -132,7 +132,7 @@ bool SQTable::NewSlot(const SQObjectPtr &key,const SQO
798 //key not found I'll insert it
799 //main pos is not free
801 - if(type(mp->key) != OT_NULL) {
802 + if(sqtype(mp->key) != OT_NULL) {
803 n = _firstfree; /* get a free place */
804 SQHash mph = HashObj(mp->key) & (_numofnodes - 1);
805 _HashNode *othern; /* main position of colliding node */
806 @@ -161,7 +161,7 @@ bool SQTable::NewSlot(const SQObjectPtr &key,const SQO
809 for (;;) { /* correct `firstfree' */
810 - if (type(_firstfree->key) == OT_NULL && _firstfree->next == NULL) {
811 + if (sqtype(_firstfree->key) == OT_NULL && _firstfree->next == NULL) {
814 return true; /* OK; table still has a free place */
815 @@ -177,7 +177,7 @@ SQInteger SQTable::Next(bool getweakrefs,const SQObjec
817 SQInteger idx = (SQInteger)TranslateIndex(refpos);
818 while (idx < _numofnodes) {
819 - if(type(_nodes[idx].key) != OT_NULL) {
820 + if(sqtype(_nodes[idx].key) != OT_NULL) {
822 _HashNode &n = _nodes[idx];
824 --- squirrel/sqtable.h.orig 2017-08-31 12:07:29 UTC
825 +++ squirrel/sqtable.h
828 inline SQHash HashObj(const SQObjectPtr &key)
830 - switch(type(key)) {
831 + switch(sqtype(key)) {
832 case OT_STRING: return _string(key)->_hash;
833 case OT_FLOAT: return (SQHash)((SQInteger)_float(key));
834 case OT_BOOL: case OT_INTEGER: return (SQHash)((SQInteger)_integer(key));
835 @@ -67,7 +67,7 @@ struct SQTable : public SQDelegable (public)
837 _HashNode *n = &_nodes[hash];
839 - if(_rawval(n->key) == _rawval(key) && type(n->key) == type(key)){
840 + if(_rawval(n->key) == _rawval(key) && sqtype(n->key) == sqtype(key)){
843 }while((n = n->next));
844 @@ -80,7 +80,7 @@ struct SQTable : public SQDelegable (public)
845 _HashNode *n = &_nodes[hash & (_numofnodes - 1)];
846 _HashNode *res = NULL;
848 - if(type(n->key) == OT_STRING && (scstrcmp(_stringval(n->key),key) == 0)){
849 + if(sqtype(n->key) == OT_STRING && (scstrcmp(_stringval(n->key),key) == 0)){
853 --- squirrel/sqvm.cpp.orig 2017-08-31 12:07:29 UTC
854 +++ squirrel/sqvm.cpp
856 bool SQVM::BW_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObjectPtr &o2)
859 - if((type(o1)|type(o2)) == OT_INTEGER)
860 + if((sqtype(o1)| sqtype(o2)) == OT_INTEGER)
862 SQInteger i1 = _integer(o1), i2 = _integer(o2);
864 @@ -39,7 +39,7 @@ bool SQVM::BW_OP(SQUnsignedInteger op,SQObjectPtr &trg
866 #define _ARITH_(op,trg,o1,o2) \
868 - SQInteger tmask = type(o1)|type(o2); \
869 + SQInteger tmask = sqtype(o1)|sqtype(o2); \
871 case OT_INTEGER: trg = _integer(o1) op _integer(o2);break; \
872 case (OT_FLOAT|OT_INTEGER): \
873 @@ -50,7 +50,7 @@ bool SQVM::BW_OP(SQUnsignedInteger op,SQObjectPtr &trg
875 #define _ARITH_NOZERO(op,trg,o1,o2,err) \
877 - SQInteger tmask = type(o1)|type(o2); \
878 + SQInteger tmask = sqtype(o1)|sqtype(o2); \
880 case OT_INTEGER: { SQInteger i2 = _integer(o2); if(i2 == 0) { Raise_Error(err); SQ_THROW(); } trg = _integer(o1) op i2; } break;\
881 case (OT_FLOAT|OT_INTEGER): \
882 @@ -61,7 +61,7 @@ bool SQVM::BW_OP(SQUnsignedInteger op,SQObjectPtr &trg
884 bool SQVM::ARITH_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObjectPtr &o2)
886 - SQInteger tmask = type(o1)|type(o2);
887 + SQInteger tmask = sqtype(o1)| sqtype(o2);
890 SQInteger res, i1 = _integer(o1), i2 = _integer(o2);
891 @@ -175,7 +175,7 @@ bool SQVM::ArithMetaMethod(SQInteger op,const SQObject
892 bool SQVM::NEG_OP(SQObjectPtr &trg,const SQObjectPtr &o)
896 + switch(sqtype(o)) {
900 @@ -204,7 +204,7 @@ bool SQVM::NEG_OP(SQObjectPtr &trg,const SQObjectPtr &
901 #define _RET_SUCCEED(exp) { result = (exp); return true; }
902 bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,SQInteger &result)
904 - SQObjectType t1 = type(o1), t2 = type(o2);
905 + SQObjectType t1 = sqtype(o1), t2 = sqtype(o2);
907 if(_rawval(o1) == _rawval(o2))_RET_SUCCEED(0);
909 @@ -223,7 +223,7 @@ bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObject
910 if(_delegable(o1)->GetMetaMethod(this, MT_CMP, closure)) {
912 if(CallMetaMethod(closure,MT_CMP,2,res)) {
913 - if(type(res) != OT_INTEGER) {
914 + if(sqtype(res) != OT_INTEGER) {
915 Raise_Error(_SC("_cmp must return an integer"));
918 @@ -281,7 +281,7 @@ bool SQVM::CMP_OP(CmpOP op, const SQObjectPtr &o1,cons
920 bool SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res)
923 + switch(sqtype(o)) {
927 @@ -302,7 +302,7 @@ bool SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &
928 if(_delegable(o)->GetMetaMethod(this, MT_TOSTRING, closure)) {
930 if(CallMetaMethod(closure,MT_TOSTRING,1,res)) {;
931 - if(type(res) == OT_STRING)
932 + if(sqtype(res) == OT_STRING)
936 @@ -517,7 +517,7 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,
937 &o3,SQObjectPtr &o4,SQInteger SQ_UNUSED_ARG(arg_2),int exitpos,int &jump)
941 + switch(sqtype(o1)) {
943 if((nrefidx = _table(o1)->Next(false,o4, o2, o3)) == -1) _FINISH(exitpos);
944 o4 = (SQInteger)nrefidx; _FINISH(1);
945 @@ -540,7 +540,7 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,
947 if(CallMetaMethod(closure, MT_NEXTI, 2, itr)) {
949 - if(type(itr) == OT_NULL) _FINISH(exitpos);
950 + if(sqtype(itr) == OT_NULL) _FINISH(exitpos);
951 if(!Get(o1, itr, o3, 0, DONT_FALL_BACK)) {
952 Raise_Error(_SC("_nexti returned an invalid idx")); // cloud be changed
954 @@ -559,7 +559,7 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,
955 if(_generator(o1)->_state == SQGenerator::eDead) _FINISH(exitpos);
956 if(_generator(o1)->_state == SQGenerator::eSuspended) {
958 - if(type(o4) == OT_INTEGER) {
959 + if(sqtype(o4) == OT_INTEGER) {
960 idx = _integer(o4) + 1;
963 @@ -614,14 +614,14 @@ bool SQVM::CLASS_OP(SQObjectPtr &target,SQInteger base
964 SQClass *base = NULL;
966 if(baseclass != -1) {
967 - if(type(_stack._vals[_stackbase+baseclass]) != OT_CLASS) { Raise_Error(_SC("trying to inherit from a %s"),GetTypeName(_stack._vals[_stackbase+baseclass])); return false; }
968 + if(sqtype(_stack._vals[_stackbase+baseclass]) != OT_CLASS) { Raise_Error(_SC("trying to inherit from a %s"),GetTypeName(_stack._vals[_stackbase+baseclass])); return false; }
969 base = _class(_stack._vals[_stackbase + baseclass]);
971 if(attributes != MAX_FUNC_STACKSIZE) {
972 attrs = _stack._vals[_stackbase+attributes];
974 target = SQClass::Create(_ss(this),base);
975 - if(type(_class(target)->_metamethods[MT_INHERITED]) != OT_NULL) {
976 + if(sqtype(_class(target)->_metamethods[MT_INHERITED]) != OT_NULL) {
979 Push(target); Push(attrs);
980 @@ -637,7 +637,7 @@ bool SQVM::CLASS_OP(SQObjectPtr &target,SQInteger base
982 bool SQVM::IsEqual(const SQObjectPtr &o1,const SQObjectPtr &o2,bool &res)
984 - if(type(o1) == type(o2)) {
985 + if(sqtype(o1) == sqtype(o2)) {
986 res = (_rawval(o1) == _rawval(o2));
989 @@ -653,12 +653,12 @@ bool SQVM::IsEqual(const SQObjectPtr &o1,const SQObjec
991 bool SQVM::IsFalse(SQObjectPtr &o)
993 - if(((type(o) & SQOBJECT_CANBEFALSE)
994 - && ( ((type(o) == OT_FLOAT) && (_float(o) == SQFloat(0.0))) ))
995 + if(((sqtype(o) & SQOBJECT_CANBEFALSE)
996 + && ( ((sqtype(o) == OT_FLOAT) && (_float(o) == SQFloat(0.0))) ))
997 #if !defined(SQUSEDOUBLE) || (defined(SQUSEDOUBLE) && defined(_SQ64))
998 || (_integer(o) == 0) ) //OT_NULL|OT_INTEGER|OT_BOOL
1000 - || (((type(o) != OT_FLOAT) && (_integer(o) == 0))) ) //OT_NULL|OT_INTEGER|OT_BOOL
1001 + || (((sqtype(o) != OT_FLOAT) && (_integer(o) == 0))) ) //OT_NULL|OT_INTEGER|OT_BOOL
1005 @@ -721,7 +721,7 @@ exception_restore:
1006 case _OP_DLOAD: TARGET = ci->_literals[arg1]; STK(arg2) = ci->_literals[arg3];continue;
1008 SQObjectPtr &t = STK(arg1);
1009 - if (type(t) == OT_CLOSURE
1010 + if (sqtype(t) == OT_CLOSURE
1011 && (!_closure(t)->_function->_bgenerator)){
1012 SQObjectPtr clo = t;
1013 if(_openouters) CloseOuters(&(_stack._vals[_stackbase]));
1014 @@ -732,7 +732,7 @@ exception_restore:
1017 SQObjectPtr clo = STK(arg1);
1018 - switch (type(clo)) {
1019 + switch (sqtype(clo)) {
1021 _GUARD(StartCall(_closure(clo), sarg0, arg3, _stackbase+arg2, false));
1023 @@ -759,7 +759,7 @@ exception_restore:
1027 - switch(type(clo)) {
1028 + switch(sqtype(clo)) {
1030 stkbase = _stackbase+arg2;
1031 _stack._vals[stkbase] = inst;
1032 @@ -857,7 +857,7 @@ exception_restore:
1033 case _OP_LOADNULLS:{ for(SQInt32 n=0; n < arg1; n++) STK(arg0+n).Null(); }continue;
1034 case _OP_LOADROOT: {
1035 SQWeakRef *w = _closure(ci->_closure)->_root;
1036 - if(type(w->_obj) != OT_NULL) {
1037 + if(sqtype(w->_obj) != OT_NULL) {
1040 TARGET = _roottable; //shoud this be like this? or null
1041 @@ -933,7 +933,7 @@ exception_restore:
1042 case _OP_INC: {SQObjectPtr o(sarg3); _GUARD(DerefInc('+',TARGET, STK(arg1), STK(arg2), o, false, arg1));} continue;
1044 SQObjectPtr &a = STK(arg1);
1045 - if(type(a) == OT_INTEGER) {
1046 + if(sqtype(a) == OT_INTEGER) {
1047 a._unVal.nInteger = _integer(a) + sarg3;
1050 @@ -944,7 +944,7 @@ exception_restore:
1051 case _OP_PINC: {SQObjectPtr o(sarg3); _GUARD(DerefInc('+',TARGET, STK(arg1), STK(arg2), o, true, arg1));} continue;
1053 SQObjectPtr &a = STK(arg1);
1054 - if(type(a) == OT_INTEGER) {
1055 + if(sqtype(a) == OT_INTEGER) {
1057 a._unVal.nInteger = _integer(a) + sarg3;
1059 @@ -956,9 +956,9 @@ exception_restore:
1060 case _OP_CMP: _GUARD(CMP_OP((CmpOP)arg3,STK(arg2),STK(arg1),TARGET)) continue;
1061 case _OP_EXISTS: TARGET = Get(STK(arg1), STK(arg2), temp_reg, GET_FLAG_DO_NOT_RAISE_ERROR | GET_FLAG_RAW, DONT_FALL_BACK) ? true : false; continue;
1062 case _OP_INSTANCEOF:
1063 - if(type(STK(arg1)) != OT_CLASS)
1064 + if(sqtype(STK(arg1)) != OT_CLASS)
1065 {Raise_Error(_SC("cannot apply instanceof between a %s and a %s"),GetTypeName(STK(arg1)),GetTypeName(STK(arg2))); SQ_THROW();}
1066 - TARGET = (type(STK(arg2)) == OT_INSTANCE) ? (_instance(STK(arg2))->InstanceOf(_class(STK(arg1)))?true:false) : false;
1067 + TARGET = (sqtype(STK(arg2)) == OT_INSTANCE) ? (_instance(STK(arg2))->InstanceOf(_class(STK(arg1)))?true:false) : false;
1070 if(IsFalse(STK(arg2))) {
1071 @@ -975,7 +975,7 @@ exception_restore:
1072 case _OP_NEG: _GUARD(NEG_OP(TARGET,STK(arg1))); continue;
1073 case _OP_NOT: TARGET = IsFalse(STK(arg1)); continue;
1075 - if(type(STK(arg1)) == OT_INTEGER) {
1076 + if(sqtype(STK(arg1)) == OT_INTEGER) {
1077 SQInteger t = _integer(STK(arg1));
1078 TARGET = SQInteger(~t);
1080 @@ -1005,7 +1005,7 @@ exception_restore:
1084 - if(type(STK(arg1)) != OT_GENERATOR){ Raise_Error(_SC("trying to resume a '%s',only genenerator can be resumed"), GetTypeName(STK(arg1))); SQ_THROW();}
1085 + if(sqtype(STK(arg1)) != OT_GENERATOR){ Raise_Error(_SC("trying to resume a '%s',only genenerator can be resumed"), GetTypeName(STK(arg1))); SQ_THROW();}
1086 _GUARD(_generator(STK(arg1))->Resume(this, TARGET));
1087 traps += ci->_etraps;
1089 @@ -1014,7 +1014,7 @@ exception_restore:
1090 ci->_ip += tojump; }
1092 case _OP_POSTFOREACH:
1093 - assert(type(STK(arg0)) == OT_GENERATOR);
1094 + assert(sqtype(STK(arg0)) == OT_GENERATOR);
1095 if(_generator(STK(arg0))->_state == SQGenerator::eDead)
1096 ci->_ip += (sarg1 - 1);
1098 @@ -1104,7 +1104,7 @@ bool SQVM::CreateClassInstance(SQClass *theclass, SQOb
1100 void SQVM::CallErrorHandler(SQObjectPtr &error)
1102 - if(type(_errorhandler) != OT_NULL) {
1103 + if(sqtype(_errorhandler) != OT_NULL) {
1105 Push(_roottable); Push(error);
1106 Call(_errorhandler, 2, _top-2, out,SQFalse);
1107 @@ -1118,8 +1118,8 @@ void SQVM::CallDebugHook(SQInteger type,SQInteger forc
1109 SQFunctionProto *func=_closure(ci->_closure)->_function;
1110 if(_debughook_native) {
1111 - const SQChar *src = type(func->_sourcename) == OT_STRING?_stringval(func->_sourcename):NULL;
1112 - const SQChar *fname = type(func->_name) == OT_STRING?_stringval(func->_name):NULL;
1113 + const SQChar *src = sqtype(func->_sourcename) == OT_STRING?_stringval(func->_sourcename):NULL;
1114 + const SQChar *fname = sqtype(func->_name) == OT_STRING?_stringval(func->_name):NULL;
1115 SQInteger line = forcedline?forcedline:func->GetLine(ci->_ip);
1116 _debughook_native(this,type,src,line,fname);
1118 @@ -1154,8 +1154,8 @@ bool SQVM::CallNative(SQNativeClosure *nclosure, SQInt
1119 SQIntVec &tc = nclosure->_typecheck;
1120 if((tcs = tc.size())) {
1121 for(SQInteger i = 0; i < nargs && i < tcs; i++) {
1122 - if((tc._vals[i] != -1) && !(type(_stack._vals[newbase+i]) & tc._vals[i])) {
1123 - Raise_ParamTypeError(i,tc._vals[i],type(_stack._vals[newbase+i]));
1124 + if((tc._vals[i] != -1) && !(sqtype(_stack._vals[newbase+i]) & tc._vals[i])) {
1125 + Raise_ParamTypeError(i,tc._vals[i], sqtype(_stack._vals[newbase+i]));
1129 @@ -1202,7 +1202,7 @@ bool SQVM::CallNative(SQNativeClosure *nclosure, SQInt
1131 bool SQVM::Get(const SQObjectPtr &self, const SQObjectPtr &key, SQObjectPtr &dest, SQUnsignedInteger getflags, SQInteger selfidx)
1133 - switch(type(self)){
1134 + switch(sqtype(self)){
1136 if(_table(self)->Get(key,dest))return true;
1138 @@ -1243,7 +1243,7 @@ bool SQVM::Get(const SQObjectPtr &self, const SQObject
1139 //#ifdef ROOT_FALLBACK
1141 SQWeakRef *w = _closure(ci->_closure)->_root;
1142 - if(type(w->_obj) != OT_NULL)
1143 + if(sqtype(w->_obj) != OT_NULL)
1145 if(Get(*((const SQObjectPtr *)&w->_obj),key,dest,0,DONT_FALL_BACK)) return true;
1147 @@ -1257,7 +1257,7 @@ bool SQVM::Get(const SQObjectPtr &self, const SQObject
1148 bool SQVM::InvokeDefaultDelegate(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest)
1150 SQTable *ddel = NULL;
1151 - switch(type(self)) {
1152 + switch(sqtype(self)) {
1153 case OT_CLASS: ddel = _class_ddel; break;
1154 case OT_TABLE: ddel = _table_ddel; break;
1155 case OT_ARRAY: ddel = _array_ddel; break;
1156 @@ -1276,7 +1276,7 @@ bool SQVM::InvokeDefaultDelegate(const SQObjectPtr &se
1158 SQInteger SQVM::FallBackGet(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest)
1160 - switch(type(self)){
1161 + switch(sqtype(self)){
1165 @@ -1299,7 +1299,7 @@ SQInteger SQVM::FallBackGet(const SQObjectPtr &self,co
1169 - if(type(_lasterror) != OT_NULL) { //NULL means "clean failure" (not found)
1170 + if(sqtype(_lasterror) != OT_NULL) { //NULL means "clean failure" (not found)
1171 return FALLBACK_ERROR;
1174 @@ -1314,7 +1314,7 @@ SQInteger SQVM::FallBackGet(const SQObjectPtr &self,co
1176 bool SQVM::Set(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,SQInteger selfidx)
1178 - switch(type(self)){
1179 + switch(sqtype(self)){
1181 if(_table(self)->Set(key,val)) return true;
1183 @@ -1348,7 +1348,7 @@ bool SQVM::Set(const SQObjectPtr &self,const SQObjectP
1185 SQInteger SQVM::FallBackSet(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val)
1187 - switch(type(self)) {
1188 + switch(sqtype(self)) {
1190 if(_table(self)->_delegate) {
1191 if(Set(_table(self)->_delegate,key,val,DONT_FALL_BACK)) return FALLBACK_OK;
1192 @@ -1367,7 +1367,7 @@ SQInteger SQVM::FallBackSet(const SQObjectPtr &self,co
1196 - if(type(_lasterror) != OT_NULL) { //NULL means "clean failure" (not found)
1197 + if(sqtype(_lasterror) != OT_NULL) { //NULL means "clean failure" (not found)
1200 return FALLBACK_ERROR;
1201 @@ -1386,7 +1386,7 @@ bool SQVM::Clone(const SQObjectPtr &self,SQObjectPtr &
1203 SQObjectPtr temp_reg;
1205 - switch(type(self)){
1206 + switch(sqtype(self)){
1208 newobj = _table(self)->Clone();
1210 @@ -1414,14 +1414,14 @@ cloned_mt:
1212 bool SQVM::NewSlotA(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,const SQObjectPtr &attrs,bool bstatic,bool raw)
1214 - if(type(self) != OT_CLASS) {
1215 + if(sqtype(self) != OT_CLASS) {
1216 Raise_Error(_SC("object must be a class"));
1219 SQClass *c = _class(self);
1221 SQObjectPtr &mm = c->_metamethods[MT_NEWMEMBER];
1222 - if(type(mm) != OT_NULL ) {
1223 + if(sqtype(mm) != OT_NULL ) {
1224 Push(self); Push(key); Push(val);
1227 @@ -1430,7 +1430,7 @@ bool SQVM::NewSlotA(const SQObjectPtr &self,const SQOb
1229 if(!NewSlot(self, key, val,bstatic))
1231 - if(type(attrs) != OT_NULL) {
1232 + if(sqtype(attrs) != OT_NULL) {
1233 c->SetAttributes(key,attrs);
1236 @@ -1438,8 +1438,8 @@ bool SQVM::NewSlotA(const SQObjectPtr &self,const SQOb
1238 bool SQVM::NewSlot(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic)
1240 - if(type(key) == OT_NULL) { Raise_Error(_SC("null cannot be used as index")); return false; }
1241 - switch(type(self)) {
1242 + if(sqtype(key) == OT_NULL) { Raise_Error(_SC("null cannot be used as index")); return false; }
1243 + switch(sqtype(self)) {
1245 bool rawcall = true;
1246 if(_table(self)->_delegate) {
1247 @@ -1499,7 +1499,7 @@ bool SQVM::NewSlot(const SQObjectPtr &self,const SQObj
1249 bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &res)
1251 - switch(type(self)) {
1252 + switch(sqtype(self)) {
1256 @@ -1511,7 +1511,7 @@ bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQ
1257 return CallMetaMethod(closure,MT_DELSLOT,2,res);
1260 - if(type(self) == OT_TABLE) {
1261 + if(sqtype(self) == OT_TABLE) {
1262 if(_table(self)->Get(key,t)) {
1263 _table(self)->Remove(key);
1265 @@ -1540,7 +1540,7 @@ bool SQVM::Call(SQObjectPtr &closure,SQInteger nparams
1267 SQInteger prevstackbase = _stackbase;
1269 - switch(type(closure)) {
1270 + switch(sqtype(closure)) {
1272 return Execute(closure, nparams, stackbase, outres, raiseerror);
1274 @@ -1554,7 +1554,7 @@ SQInteger prevstackbase = _stackbase;
1277 CreateClassInstance(_class(closure),outres,constr);
1278 - SQObjectType ctype = type(constr);
1279 + SQObjectType ctype = sqtype(constr);
1280 if (ctype == OT_NATIVECLOSURE || ctype == OT_CLOSURE) {
1281 _stack[stackbase] = outres;
1282 return Call(constr,nparams,stackbase,temp,raiseerror);
1283 @@ -1717,7 +1717,7 @@ void SQVM::dumpstack(SQInteger stackbase,bool dumpall)
1284 SQObjectPtr &obj=_stack[i];
1285 if(stackbase==i)scprintf(_SC(">"));else scprintf(_SC(" "));
1286 scprintf(_SC("[%d]:"),n);
1287 - switch(type(obj)){
1288 + switch(sqtype(obj)){
1289 case OT_FLOAT: scprintf(_SC("FLOAT %.3f"),_float(obj));break;
1290 case OT_INTEGER: scprintf(_SC("INTEGER %d"),_integer(obj));break;
1291 case OT_BOOL: scprintf(_SC("BOOL %s"),_integer(obj)?"true":"false");break;