4 #include "sqpcheader.h" 9 #include "sqfuncproto.h" 10 #include "sqclosure.h" 11 #include "squserdata.h" 12 #include "sqcompiler.h" 13 #include "sqfuncstate.h" 18 *o = &stack_get(v,idx);
19 if(type(**o) != type){
20 SQObjectPtr oval = v->PrintObjVal(**o);
21 v->Raise_Error(_SC(
"wrong argument type, expected '%s' got '%.50s'"),
IdType2Name(type),_stringval(oval));
27 #define _GETSAFE_OBJ(v,idx,type,o) { if(!sq_aux_gettypedarg(v,idx,type,&o)) return SQ_ERROR; } 29 #define sq_aux_paramscheck(v,count) \ 31 if(sq_gettop(v) < count){ v->Raise_Error(_SC("not enough params in the stack")); return SQ_ERROR; }\ 42 scsprintf(_ss(v)->GetScratchPad(100), _SC(
"unexpected type %s"),
IdType2Name(type));
46 HSQUIRRELVM
sq_open(SQInteger initialstacksize)
50 sq_new(ss, SQSharedState);
52 v = (SQVM *)SQ_MALLOC(
sizeof(SQVM));
55 if(v->Init(
NULL, initialstacksize)) {
64 HSQUIRRELVM
sq_newthread(HSQUIRRELVM friendvm, SQInteger initialstacksize)
70 v= (SQVM *)SQ_MALLOC(
sizeof(SQVM));
73 if(v->Init(friendvm, initialstacksize)) {
85 return SQ_VMSTATE_SUSPENDED;
87 if(v->_callsstacksize != 0)
return SQ_VMSTATE_RUNNING;
88 else return SQ_VMSTATE_IDLE;
94 SQObject o = stack_get(v, -1);
95 if(sq_isclosure(o) || sq_isnativeclosure(o) || sq_isnull(o)) {
103 SQObject o = stack_get(v,-1);
104 if(sq_isclosure(o) || sq_isnativeclosure(o) || sq_isnull(o)) {
112 SQSharedState *ss = _ss(v);
113 _thread(ss->_root_vm)->Finalize();
114 sq_delete(ss, SQSharedState);
117 SQRESULT
sq_compile(HSQUIRRELVM v,SQLEXREADFUNC read,SQUserPointer p,
const SQChar *sourcename,SQBool raiseerror)
120 if(
Compile(v, read, p, sourcename, o, raiseerror?
true:
false, _ss(v)->_debuginfo)) {
121 v->Push(SQClosure::Create(_ss(v), _funcproto(o)));
129 _ss(v)->_debuginfo = enable?
true:
false;
134 _ss(v)->_notifyallexceptions = enable?
true:
false;
139 if(!ISREFCOUNTED(type(*po)))
return;
140 #ifdef NO_GARBAGE_COLLECTOR 141 __AddRef(po->_type,po->_unVal);
143 _ss(v)->_refs_table.AddRef(*po);
149 if(!ISREFCOUNTED(type(*po)))
return SQTrue;
150 #ifdef NO_GARBAGE_COLLECTOR 151 __Release(po->_type,po->_unVal);
154 return _ss(v)->_refs_table.Release(*po);
160 if(sq_type(*o) == OT_STRING) {
161 return _stringval(*o);
168 if(sq_isnumeric(*o)) {
169 return tointeger(*o);
176 if(sq_isnumeric(*o)) {
198 v->Push(SQObjectPtr(SQString::Create(_ss(v), s, len)));
209 v->Push(b?
true:
false);
224 SQUserData *ud = SQUserData::Create(_ss(v), size);
231 v->Push(SQTable::Create(_ss(v), 0));
236 v->Push(SQArray::Create(_ss(v), size));
241 SQClass *baseclass =
NULL;
243 SQObjectPtr &base = stack_get(v,-1);
244 if(type(base) != OT_CLASS)
246 baseclass = _class(base);
248 SQClass *newclass = SQClass::Create(_ss(v), baseclass);
249 if(baseclass) v->Pop();
256 SQObjectPtr &inst = stack_get(v,-1);
257 SQObjectPtr &cl = stack_get(v,-2);
258 if(type(inst) != OT_INSTANCE || type(cl) != OT_CLASS)
260 return _instance(inst)->InstanceOf(_class(cl))?SQTrue:SQFalse;
268 _array(*arr)->Append(v->GetUp(-1));
278 if(_array(*arr)->Size() > 0) {
279 if(pushval != 0){ v->Push(_array(*arr)->Top()); }
292 _array(*arr)->Resize(newsize);
304 SQArray *arr = _array(*o);
305 if(arr->Size() > 0) {
307 SQInteger size = arr->Size();
308 SQInteger n = size >> 1; size -= 1;
309 for(SQInteger i = 0; i < n; i++) {
311 arr->_values[i] = arr->_values[size-i];
312 arr->_values[size-i] = t;
324 return _array(*arr)->Remove(itemidx) ? SQ_OK :
sq_throwerror(v,_SC(
"index out of range"));
332 SQRESULT ret = _array(*arr)->Insert(destpos, v->GetUp(-1)) ? SQ_OK :
sq_throwerror(v,_SC(
"index out of range"));
338 void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars)
340 SQNativeClosure *nc = SQNativeClosure::Create(_ss(v), func);
341 nc->_nparamscheck = 0;
342 for(SQUnsignedInteger i = 0; i < nfreevars; i++) {
343 nc->_outervalues.push_back(v->Top());
346 v->Push(SQObjectPtr(nc));
349 SQRESULT
sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparams,SQUnsignedInteger *nfreevars)
351 SQObject o = stack_get(v, idx);
352 if(sq_isclosure(o)) {
353 SQClosure *c = _closure(o);
354 SQFunctionProto *proto = _funcproto(c->_function);
355 *nparams = (SQUnsignedInteger)proto->_nparameters;
356 *nfreevars = (SQUnsignedInteger)c->_outervalues.size();
364 SQObject o = stack_get(v, idx);
365 if(sq_isnativeclosure(o)) {
366 SQNativeClosure *nc = _nativeclosure(o);
367 nc->_name = SQString::Create(_ss(v),name);
370 return sq_throwerror(v,_SC(
"the object is not a nativeclosure"));
375 SQObject o = stack_get(v, -1);
376 if(!sq_isnativeclosure(o))
378 SQNativeClosure *nc = _nativeclosure(o);
379 nc->_nparamscheck = nparamscheck;
384 nc->_typecheck.copy(res);
387 nc->_typecheck.resize(0);
389 if(nparamscheck == SQ_MATCHTYPEMASKSTRING) {
390 nc->_nparamscheck = nc->_typecheck.size();
397 SQObjectPtr &o = stack_get(v,idx);
398 if(!sq_isnativeclosure(o) &&
401 SQObjectPtr &env = stack_get(v,-1);
402 if(!sq_istable(env) &&
406 SQObjectPtr w = _refcounted(env)->GetWeakRef(type(env));
408 if(sq_isclosure(o)) {
409 SQClosure *c = _closure(o)->Clone();
414 SQNativeClosure *c = _nativeclosure(o)->Clone();
425 SQObject &o=stack_get(v,idx);
427 case OT_TABLE: _table(o)->Clear();
break;
428 case OT_ARRAY: _array(o)->Resize(0);
break;
430 return sq_throwerror(v, _SC(
"clear only works on table and array"));
439 v->Push(v->_roottable);
444 v->Push(_ss(v)->_registry);
449 v->Push(_ss(v)->_consts);
454 SQObject o = stack_get(v, -1);
455 if(sq_istable(o) || sq_isnull(o)) {
465 SQObject o = stack_get(v, -1);
481 return v->_foreignptr;
486 v->Push(stack_get(v, idx));
491 return type(stack_get(v, idx));
497 SQObjectPtr &o = stack_get(v, idx);
505 SQObjectPtr &o = stack_get(v, idx);
506 *b = v->IsFalse(o)?SQFalse:SQTrue;
511 SQObjectPtr &o = stack_get(v, idx);
512 if(sq_isnumeric(o)) {
521 SQObjectPtr &o = stack_get(v, idx);
522 if(sq_isnumeric(o)) {
531 SQObjectPtr &o = stack_get(v, idx);
541 SQObjectPtr *o =
NULL;
549 SQObjectPtr *o =
NULL;
551 *thread = _thread(*o);
557 SQObjectPtr &o = stack_get(v,idx);
559 if(!v->Clone(o, stack_get(v, -1))){
568 SQObjectPtr &o = stack_get(v, idx);
569 SQObjectType type = type(o);
571 case OT_STRING:
return _string(o)->_len;
572 case OT_TABLE:
return _table(o)->CountUsed();
573 case OT_ARRAY:
return _array(o)->Size();
574 case OT_USERDATA:
return _userdata(o)->_size;
575 case OT_INSTANCE:
return _instance(o)->_class->_udsize;
576 case OT_CLASS:
return _class(o)->_udsize;
582 SQRESULT
sq_getuserdata(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p,SQUserPointer *typetag)
584 SQObjectPtr *o =
NULL;
586 (*p) = _userdataval(*o);
587 if(typetag) *typetag = _userdata(*o)->_typetag;
593 SQObjectPtr &o = stack_get(v,idx);
595 case OT_USERDATA: _userdata(o)->_typetag = typetag;
break;
596 case OT_CLASS: _class(o)->_typetag = typetag;
break;
605 case OT_INSTANCE: *typetag = _instance(*o)->_class->_typetag;
break;
606 case OT_USERDATA: *typetag = _userdata(*o)->_typetag;
break;
607 case OT_CLASS: *typetag = _class(*o)->_typetag;
break;
608 default:
return SQ_ERROR;
615 SQObjectPtr &o = stack_get(v,idx);
623 SQObjectPtr *o =
NULL;
625 (*p) = _userpointer(*o);
631 SQObjectPtr &o = stack_get(v,idx);
632 if(type(o) != OT_INSTANCE)
return sq_throwerror(v,_SC(
"the object is not a class instance"));
633 _instance(o)->_userpointer = p;
639 SQObjectPtr &o = stack_get(v,idx);
640 if(type(o) != OT_CLASS)
return sq_throwerror(v,_SC(
"the object is not a class"));
641 if(_class(o)->_locked)
return sq_throwerror(v,_SC(
"the class is locked"));
642 _class(o)->_udsize = udsize;
647 SQRESULT
sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag)
649 SQObjectPtr &o = stack_get(v,idx);
650 if(type(o) != OT_INSTANCE)
return sq_throwerror(v,_SC(
"the object is not a class instance"));
651 (*p) = _instance(o)->_userpointer;
653 SQClass *cl = _instance(o)->_class;
655 if(cl->_typetag == typetag)
666 return (v->_top) - v->_stackbase;
678 void sq_pop(HSQUIRRELVM v, SQInteger nelemstopop)
680 assert(v->_top >= nelemstopop);
686 assert(v->_top >= 1);
699 v->ObjCmp(stack_get(v, -1), stack_get(v, -2),res);
703 SQRESULT
sq_newslot(HSQUIRRELVM v, SQInteger idx, SQBool bstatic)
706 SQObjectPtr &
self = stack_get(v, idx);
707 if(type(
self) == OT_TABLE || type(
self) == OT_CLASS) {
708 SQObjectPtr &key = v->GetUp(-2);
709 if(type(key) == OT_NULL)
return sq_throwerror(v, _SC(
"null is not a valid key"));
710 v->NewSlot(
self, key, v->GetUp(-1),bstatic?
true:
false);
721 SQObjectPtr &key = v->GetUp(-1);
722 if(type(key) == OT_NULL)
return sq_throwerror(v, _SC(
"null is not a valid key"));
724 if(!v->DeleteSlot(*
self, key, res)){
727 if(pushval) v->GetUp(-1) = res;
732 SQRESULT
sq_set(HSQUIRRELVM v,SQInteger idx)
734 SQObjectPtr &
self = stack_get(v, idx);
735 if(v->Set(
self, v->GetUp(-2), v->GetUp(-1),
false)) {
739 v->Raise_IdxError(v->GetUp(-2));
return SQ_ERROR;
744 SQObjectPtr &
self = stack_get(v, idx);
745 if(type(v->GetUp(-2)) == OT_NULL)
return sq_throwerror(v, _SC(
"null key"));
748 _table(
self)->NewSlot(v->GetUp(-2), v->GetUp(-1));
753 _class(
self)->NewSlot(_ss(v), v->GetUp(-2), v->GetUp(-1),
false);
758 if(_instance(
self)->Set(v->GetUp(-2), v->GetUp(-1))) {
764 if(v->Set(
self, v->GetUp(-2), v->GetUp(-1),
false)) {
771 return sq_throwerror(v, _SC(
"rawset works only on array/table/class and instance"));
773 v->Raise_IdxError(v->GetUp(-2));
return SQ_ERROR;
778 SQObjectPtr &
self = stack_get(v, idx);
779 SQObjectPtr &mt = v->GetUp(-1);
780 SQObjectType type = type(
self);
783 if(type(mt) == OT_TABLE) {
784 if(!_table(
self)->SetDelegate(_table(mt)))
return sq_throwerror(v, _SC(
"delagate cycle")); v->Pop();}
785 else if(type(mt)==OT_NULL) {
786 _table(
self)->SetDelegate(
NULL); v->Pop(); }
790 if(type(mt)==OT_TABLE) {
791 _userdata(
self)->SetDelegate(_table(mt)); v->Pop(); }
792 else if(type(mt)==OT_NULL) {
793 _userdata(
self)->SetDelegate(
NULL); v->Pop(); }
808 SQObjectPtr &key = v->GetUp(-1);
810 if(_table(*self)->Get(key,t)) {
811 _table(*self)->Remove(key);
815 if(pushval) v->GetUp(-1) = t;
824 SQObjectPtr &
self=stack_get(v,idx);
828 if(!_delegable(
self)->_delegate){
832 v->Push(SQObjectPtr(_delegable(
self)->_delegate));
840 SQRESULT
sq_get(HSQUIRRELVM v,SQInteger idx)
842 SQObjectPtr &
self=stack_get(v,idx);
843 if(v->Get(
self,v->GetUp(-1),v->GetUp(-1),
false,
false))
851 SQObjectPtr &
self=stack_get(v,idx);
854 if(_table(
self)->Get(v->GetUp(-1),v->GetUp(-1)))
858 if(_class(
self)->Get(v->GetUp(-1),v->GetUp(-1)))
862 if(_instance(
self)->Get(v->GetUp(-1),v->GetUp(-1)))
866 if(v->Get(
self,v->GetUp(-1),v->GetUp(-1),
false,
false))
871 return sq_throwerror(v,_SC(
"rawget works only on array/table/instance and class"));
879 *po=stack_get(v,idx);
885 SQUnsignedInteger cstksize=v->_callsstacksize;
886 SQUnsignedInteger lvl=(cstksize-level)-1;
887 SQInteger stackbase=v->_stackbase;
889 for(SQUnsignedInteger i=0;i<level;i++){
890 SQVM::CallInfo &ci=v->_callsstack[(cstksize-i)-1];
891 stackbase-=ci._prevstkbase;
893 SQVM::CallInfo &ci=v->_callsstack[lvl];
894 if(type(ci._closure)!=OT_CLOSURE)
896 SQClosure *c=_closure(ci._closure);
897 SQFunctionProto *func=_funcproto(c->_function);
898 if(func->_noutervalues > (SQInteger)idx) {
899 v->Push(c->_outervalues[idx]);
900 return _stringval(func->_outervalues[idx]._name);
902 idx -= func->_noutervalues;
903 return func->GetLocal(v,stackbase,idx,(SQInteger)(ci._ip-func->_instructions)-1);
910 v->Push(SQObjectPtr(obj));
915 po->_unVal.pUserPointer=
NULL;po->_type=OT_NULL;
920 v->_lasterror=SQString::Create(_ss(v),err);
931 v->Push(v->_lasterror);
936 if (((SQUnsignedInteger)v->_top + nsize) > v->_stack.size()) {
937 v->_stack.resize(v->_stack.size() + ((v->_top + nsize) - v->_stack.size()));
941 SQRESULT
sq_resume(HSQUIRRELVM v,SQBool retval,SQBool raiseerror)
943 if(type(v->GetUp(-1))==OT_GENERATOR){
945 if(!v->Execute(v->GetUp(-2),v->_top,0,v->_top,v->GetUp(-1),raiseerror,SQVM::ET_RESUME_GENERATOR))
946 {v->Raise_Error(v->_lasterror);
return SQ_ERROR;}
951 return sq_throwerror(v,_SC(
"only generators can be resumed"));
954 SQRESULT
sq_call(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror)
957 if(v->Call(v->GetUp(-(params+1)),params,v->_top-params,res,raiseerror?
true:
false)){
962 v->Push(res);
return SQ_OK;
980 SQRESULT
sq_wakeupvm(HSQUIRRELVM v,SQBool wakeupret,SQBool retval,SQBool raiseerror,SQBool throwerror)
984 return sq_throwerror(v,_SC(
"cannot resume a vm that is not running any code"));
986 v->GetAt(v->_stackbase+v->_suspended_target)=v->GetUp(-1);
988 }
else v->GetAt(v->_stackbase+v->_suspended_target)=
_null_;
989 if(!v->Execute(
_null_,v->_top,-1,-1,ret,raiseerror,throwerror?SQVM::ET_RESUME_THROW_VM : SQVM::ET_RESUME_VM))
992 while (v->_top > 1) v->_stack[--v->_top] =
_null_;
1002 SQObjectPtr &ud=stack_get(v,idx);
1003 switch( type(ud) ) {
1004 case OT_USERDATA: _userdata(ud)->_hook = hook;
break;
1005 case OT_INSTANCE: _instance(ud)->_hook = hook;
break;
1006 case OT_CLASS: _class(ud)->_hook = hook;
break;
1014 _ss(v)->_compilererrorhandler = f;
1019 SQObjectPtr *o =
NULL;
1021 unsigned short tag = SQ_BYTECODE_STREAM_TAG;
1022 if(w(up,&tag,2) != 2)
1024 if(!_closure(*o)->Save(v,up,w))
1031 SQObjectPtr closure;
1034 if(r(up,&tag,2) != 2)
1036 if(tag != SQ_BYTECODE_STREAM_TAG)
1038 if(!SQClosure::Load(v,up,r,closure))
1046 return _ss(v)->GetScratchPad(minsize);
1051 #ifndef NO_GARBAGE_COLLECTOR 1052 return _ss(v)->CollectGarbage(v);
1060 SQObjectPtr &
self = stack_get(v,idx);
1062 if(type(
self) == OT_CLOSURE) {
1063 if(_closure(
self)->_outervalues.size()>nval) {
1064 v->Push(_closure(
self)->_outervalues[nval]);
1065 SQFunctionProto *fp = _funcproto(_closure(
self)->_function);
1066 SQOuterVar &ov = fp->_outervalues[nval];
1067 name = _stringval(ov._name);
1075 SQObjectPtr &
self=stack_get(v,idx);
1079 if(_closure(
self)->_outervalues.size()>nval){
1080 _closure(
self)->_outervalues[nval]=stack_get(v,-1);
1084 case OT_NATIVECLOSURE:
1085 if(_nativeclosure(
self)->_outervalues.size()>nval){
1086 _nativeclosure(
self)->_outervalues[nval]=stack_get(v,-1);
1099 SQObjectPtr *o =
NULL;
1101 SQObjectPtr &key = stack_get(v,-2);
1102 SQObjectPtr &val = stack_get(v,-1);
1104 if(type(key) == OT_NULL) {
1105 attrs = _class(*o)->_attributes;
1106 _class(*o)->_attributes = val;
1110 }
else if(_class(*o)->GetAttributes(key,attrs)) {
1111 _class(*o)->SetAttributes(key,val);
1121 SQObjectPtr *o =
NULL;
1123 SQObjectPtr &key = stack_get(v,-1);
1125 if(type(key) == OT_NULL) {
1126 attrs = _class(*o)->_attributes;
1131 else if(_class(*o)->GetAttributes(key,attrs)) {
1141 SQObjectPtr *o =
NULL;
1143 if(_class(*o)->_base)
1144 v->Push(SQObjectPtr(_class(*o)->_base));
1152 SQObjectPtr *o =
NULL;
1154 v->Push(SQObjectPtr(_instance(*o)->_class));
1160 SQObjectPtr *o =
NULL;
1162 v->Push(_class(*o)->CreateInstance());
1168 SQObject &o=stack_get(v,idx);
1169 if(ISREFCOUNTED(type(o))) {
1170 v->Push(_refcounted(o)->GetWeakRef(type(o)));
1178 SQObjectPtr &o = stack_get(v,idx);
1179 if(type(o) != OT_WEAKREF) {
1180 return sq_throwerror(v,_SC(
"the object must be a weakref"));
1182 v->Push(_weakref(o)->_obj);
1188 SQSharedState *ss = _ss(v);
1190 case OT_TABLE: v->Push(ss->_table_default_delegate);
break;
1191 case OT_ARRAY: v->Push(ss->_array_default_delegate);
break;
1192 case OT_STRING: v->Push(ss->_string_default_delegate);
break;
1193 case OT_INTEGER:
case OT_FLOAT: v->Push(ss->_number_default_delegate);
break;
1194 case OT_GENERATOR: v->Push(ss->_generator_default_delegate);
break;
1195 case OT_CLOSURE:
case OT_NATIVECLOSURE: v->Push(ss->_closure_default_delegate);
break;
1196 case OT_THREAD: v->Push(ss->_thread_default_delegate);
break;
1197 case OT_CLASS: v->Push(ss->_class_default_delegate);
break;
1198 case OT_INSTANCE: v->Push(ss->_instance_default_delegate);
break;
1199 case OT_WEAKREF: v->Push(ss->_weakref_default_delegate);
break;
1200 default:
return sq_throwerror(v,_SC(
"the type doesn't have a default delegate"));
1207 SQObjectPtr o=stack_get(v,idx),&refpos = stack_get(v,-1),realkey,val;
1208 if(type(o) == OT_GENERATOR) {
1212 if(!v->FOREACH_OP(o,realkey,val,refpos,0,666,faketojump))
1214 if(faketojump != 666) {
1233 return buf->
buf[buf->
ptr++];
1244 void sq_move(HSQUIRRELVM dest,HSQUIRRELVM src,SQInteger idx)
1246 dest->Push(stack_get(src,idx));
1251 _ss(v)->_printfunc = printfunc;
1256 return _ss(v)->_printfunc;
1261 return SQ_MALLOC(size);
1264 void *
sq_realloc(
void* p,SQUnsignedInteger oldsize,SQUnsignedInteger newsize)
1266 return SQ_REALLOC(p,oldsize,newsize);
SQRESULT sq_resume(HSQUIRRELVM v, SQBool retval, SQBool raiseerror)
SQRESULT sq_get(HSQUIRRELVM v, SQInteger idx)
void sq_setdebughook(HSQUIRRELVM v)
SQRESULT sq_arraypop(HSQUIRRELVM v, SQInteger idx, SQBool pushval)
SQRESULT sq_setconsttable(HSQUIRRELVM v)
SQRESULT sq_newclass(HSQUIRRELVM v, SQBool hasbase)
SQRESULT sq_rawget(HSQUIRRELVM v, SQInteger idx)
SQRESULT sq_arrayinsert(HSQUIRRELVM v, SQInteger idx, SQInteger destpos)
SQRESULT sq_setattributes(HSQUIRRELVM v, SQInteger idx)
SQRESULT sq_rawdeleteslot(HSQUIRRELVM v, SQInteger idx, SQBool pushval)
SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p, SQUserPointer typetag)
SQRESULT sq_clone(HSQUIRRELVM v, SQInteger idx)
void * sq_malloc(SQUnsignedInteger size)
void sq_pop(HSQUIRRELVM v, SQInteger nelemstopop)
SQRESULT sq_getuserdata(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p, SQUserPointer *typetag)
const SQChar * sq_getfreevariable(HSQUIRRELVM v, SQInteger idx, SQUnsignedInteger nval)
SQRESULT sq_setroottable(HSQUIRRELVM v)
SQRESULT sq_gettypetag(HSQUIRRELVM v, SQInteger idx, SQUserPointer *typetag)
SQRESULT sq_throwerror(HSQUIRRELVM v, const SQChar *err)
SQInteger sq_collectgarbage(HSQUIRRELVM v)
void sq_newtable(HSQUIRRELVM v)
void sq_enabledebuginfo(HSQUIRRELVM v, SQBool enable)
SQInteger buf_lexfeed(SQUserPointer file)
SQRESULT sq_rawset(HSQUIRRELVM v, SQInteger idx)
SQRESULT sq_wakeupvm(HSQUIRRELVM v, SQBool wakeupret, SQBool retval, SQBool raiseerror, SQBool throwerror)
SQRESULT sq_getdefaultdelegate(HSQUIRRELVM v, SQObjectType t)
void sq_reservestack(HSQUIRRELVM v, SQInteger nsize)
void sq_pushnull(HSQUIRRELVM v)
SQRESULT sq_getweakrefval(HSQUIRRELVM v, SQInteger idx)
SQRESULT sq_bindenv(HSQUIRRELVM v, SQInteger idx)
SQRESULT sq_getbase(HSQUIRRELVM v, SQInteger idx)
void sq_pushroottable(HSQUIRRELVM v)
void sq_pushregistrytable(HSQUIRRELVM v)
bool CompileTypemask(SQIntVec &res, const SQChar *typemask)
void sq_tobool(HSQUIRRELVM v, SQInteger idx, SQBool *b)
SQRESULT sq_arrayappend(HSQUIRRELVM v, SQInteger idx)
void sq_pushfloat(HSQUIRRELVM v, SQFloat n)
SQInteger sq_getvmstate(HSQUIRRELVM v)
SQUserPointer sq_getforeignptr(HSQUIRRELVM v)
HSQUIRRELVM sq_newthread(HSQUIRRELVM friendvm, SQInteger initialstacksize)
SQRESULT sq_writeclosure(HSQUIRRELVM v, SQWRITEFUNC w, SQUserPointer up)
SQRESULT sq_getinteger(HSQUIRRELVM v, SQInteger idx, SQInteger *i)
SQInteger sq_getsize(HSQUIRRELVM v, SQInteger idx)
SQInteger sq_gettop(HSQUIRRELVM v)
void sq_pushconsttable(HSQUIRRELVM v)
void sq_pushinteger(HSQUIRRELVM v, SQInteger n)
void sq_newclosure(HSQUIRRELVM v, SQFUNCTION func, SQUnsignedInteger nfreevars)
SQRESULT sq_next(HSQUIRRELVM v, SQInteger idx)
SQRESULT sq_call(HSQUIRRELVM v, SQInteger params, SQBool retval, SQBool raiseerror)
void sq_push(HSQUIRRELVM v, SQInteger idx)
#define _GETSAFE_OBJ(v, idx, type, o)
SQRESULT sq_arrayremove(HSQUIRRELVM v, SQInteger idx, SQInteger itemidx)
void sq_poptop(HSQUIRRELVM v)
SQRESULT sq_getclosureinfo(HSQUIRRELVM v, SQInteger idx, SQUnsignedInteger *nparams, SQUnsignedInteger *nfreevars)
SQBool sq_release(HSQUIRRELVM v, HSQOBJECT *po)
void sq_setcompilererrorhandler(HSQUIRRELVM v, SQCOMPILERERROR f)
SQRESULT sq_clear(HSQUIRRELVM v, SQInteger idx)
SQRESULT sq_setnativeclosurename(HSQUIRRELVM v, SQInteger idx, const SQChar *name)
void sq_settop(HSQUIRRELVM v, SQInteger newtop)
SQPRINTFUNCTION sq_getprintfunc(HSQUIRRELVM v)
SQRESULT sq_compile(HSQUIRRELVM v, SQLEXREADFUNC read, SQUserPointer p, const SQChar *sourcename, SQBool raiseerror)
void sq_tostring(HSQUIRRELVM v, SQInteger idx)
SQRESULT sq_getthread(HSQUIRRELVM v, SQInteger idx, HSQUIRRELVM *thread)
void sq_reseterror(HSQUIRRELVM v)
SQInteger sq_cmp(HSQUIRRELVM v)
bool Compile(SQVM *vm, SQLEXREADFUNC rg, SQUserPointer up, const SQChar *sourcename, SQObjectPtr &out, bool raiseerror, bool lineinfo)
SQRESULT sq_arrayresize(HSQUIRRELVM v, SQInteger idx, SQInteger newsize)
SQRESULT sq_getfloat(HSQUIRRELVM v, SQInteger idx, SQFloat *f)
SQRESULT sq_getattributes(HSQUIRRELVM v, SQInteger idx)
void * sq_realloc(void *p, SQUnsignedInteger oldsize, SQUnsignedInteger newsize)
SQRESULT sq_suspendvm(HSQUIRRELVM v)
void sq_remove(HSQUIRRELVM v, SQInteger idx)
SQRESULT sq_setparamscheck(HSQUIRRELVM v, SQInteger nparamscheck, const SQChar *typemask)
void sq_setforeignptr(HSQUIRRELVM v, SQUserPointer p)
SQRESULT sq_getobjtypetag(HSQOBJECT *o, SQUserPointer *typetag)
void sq_pushstring(HSQUIRRELVM v, const SQChar *s, SQInteger len)
SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p)
const SQChar * IdType2Name(SQObjectType type)
SQObjectType sq_gettype(HSQUIRRELVM v, SQInteger idx)
SQRESULT sq_setfreevariable(HSQUIRRELVM v, SQInteger idx, SQUnsignedInteger nval)
SQBool sq_instanceof(HSQUIRRELVM v)
SQRESULT sq_getclass(HSQUIRRELVM v, SQInteger idx)
void sq_close(HSQUIRRELVM v)
SQRESULT sq_getstring(HSQUIRRELVM v, SQInteger idx, const SQChar **c)
SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger idx, SQInteger udsize)
void sq_seterrorhandler(HSQUIRRELVM v)
void sq_getlasterror(HSQUIRRELVM v)
const SQChar * sq_objtostring(HSQOBJECT *o)
const SQChar * sq_getlocal(HSQUIRRELVM v, SQUnsignedInteger level, SQUnsignedInteger idx)
SQRESULT sq_readclosure(HSQUIRRELVM v, SQREADFUNC r, SQUserPointer up)
SQRESULT sq_getuserpointer(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p)
SQRESULT sq_getbool(HSQUIRRELVM v, SQInteger idx, SQBool *b)
void sq_setprintfunc(HSQUIRRELVM v, SQPRINTFUNCTION printfunc)
void sq_free(void *p, SQUnsignedInteger size)
void sq_resetobject(HSQOBJECT *po)
SQInteger sq_aux_invalidtype(HSQUIRRELVM v, SQObjectType type)
SQUserPointer sq_newuserdata(HSQUIRRELVM v, SQUnsignedInteger size)
SQRESULT sq_settypetag(HSQUIRRELVM v, SQInteger idx, SQUserPointer typetag)
HSQUIRRELVM sq_open(SQInteger initialstacksize)
SQInteger sq_aux_throwobject(HSQUIRRELVM v, SQObjectPtr &e)
void sq_pushbool(HSQUIRRELVM v, SQBool b)
void sq_weakref(HSQUIRRELVM v, SQInteger idx)
void sq_addref(HSQUIRRELVM v, HSQOBJECT *po)
void sq_newarray(HSQUIRRELVM v, SQInteger size)
SQInteger sq_objtointeger(HSQOBJECT *o)
SQRESULT sq_arrayreverse(HSQUIRRELVM v, SQInteger idx)
SQChar * sq_getscratchpad(HSQUIRRELVM v, SQInteger minsize)
SQRESULT sq_getdelegate(HSQUIRRELVM v, SQInteger idx)
SQRESULT sq_set(HSQUIRRELVM v, SQInteger idx)
bool sq_aux_gettypedarg(HSQUIRRELVM v, SQInteger idx, SQObjectType type, SQObjectPtr **o)
SQRESULT sq_getstackobj(HSQUIRRELVM v, SQInteger idx, HSQOBJECT *po)
SQBool sq_objtobool(HSQOBJECT *o)
SQRESULT sq_setdelegate(HSQUIRRELVM v, SQInteger idx)
SQRESULT sq_deleteslot(HSQUIRRELVM v, SQInteger idx, SQBool pushval)
void sq_setreleasehook(HSQUIRRELVM v, SQInteger idx, SQRELEASEHOOK hook)
#define sq_aux_paramscheck(v, count)
SQRESULT sq_compilebuffer(HSQUIRRELVM v, const SQChar *s, SQInteger size, const SQChar *sourcename, SQBool raiseerror)
void sq_pushobject(HSQUIRRELVM v, HSQOBJECT obj)
SQFloat sq_objtofloat(HSQOBJECT *o)
void sq_pushuserpointer(HSQUIRRELVM v, SQUserPointer p)
SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx, SQBool bstatic)
SQRESULT sq_createinstance(HSQUIRRELVM v, SQInteger idx)
void sq_move(HSQUIRRELVM dest, HSQUIRRELVM src, SQInteger idx)
void sq_notifyallexceptions(HSQUIRRELVM v, SQBool enable)