1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Update sqratFunction.h

This commit is contained in:
Sandu Liviu Catalin 2021-03-15 07:00:39 +02:00
parent 405afbb72d
commit e2528e88dd

View File

@ -85,6 +85,33 @@ struct Function {
if (value_type != OT_CLOSURE && value_type != OT_NATIVECLOSURE) { if (value_type != OT_CLOSURE && value_type != OT_NATIVECLOSURE) {
SQTHROW(vm, FormatTypeError(vm, idx, _SC("closure"))); SQTHROW(vm, FormatTypeError(vm, idx, _SC("closure")));
} }
#endif
}
// Constructs a Function from a table off the stack at the specified index
Function(HSQUIRRELVM vm, SQInteger idx, const SQChar* slot) {
sq_pushstring(vm, slot, -1);
#if !defined (SCRAT_NO_ERROR_CHECKING)
if(SQ_FAILED(sq_get(vm, idx))) {
sq_poptop(vm);
sq_resetobject(&mEnv);
sq_resetobject(&mObj);
} else {
sq_getstackobj(vm, -1, &mObj);
sq_getstackobj(vm, idx, &mEnv);
if (sq_type(mObj) == OT_CLOSURE || sq_type(mObj) == OT_NATIVECLOSURE) {
sq_addref(vm, &mEnv);
sq_addref(vm, &mObj);
} else {
sq_resetobject(&mEnv);
sq_resetobject(&mObj);
}
sq_poptop(vm);
}
#else
sq_get(vm, idx);
sq_getstackobj(vm, -1, &mObj);
sq_getstackobj(vm, idx, &mEnv);
sq_poptop(vm);
#endif #endif
} }
// Constructs a Function from a value off the stack at the specified index pointed by `idx2` // Constructs a Function from a value off the stack at the specified index pointed by `idx2`