static SQRESULT map_single(HSQUIRRELVM vm) { SQObjectPtr closure = vm->GetAt(vm->_top-1); if ((sq_type(closure) != OT_CLOSURE) && (sq_type(closure) != OT_NATIVECLOSURE)) { vm->Raise_ParamTypeError(1, OT_CLOSURE | OT_NATIVECLOSURE, sq_type(closure)); return 0; } SQObjectPtr result; result.Null(); sq_push(vm, -2); // push self as implicit `this` sq_push(vm, -3); // push self as parameter vm->Call(closure, 2, vm->_top-2, result, SQTrue); sq_pop(vm, 1); // pop self x2 vm->Push(result); return 1; }