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

Update sqratTypes.h

This commit is contained in:
Sandu Liviu Catalin 2023-08-06 21:32:04 +03:00
parent 9298065cef
commit 237683e6ce

View File

@ -45,28 +45,28 @@ struct popAsInt
T value; T value;
popAsInt(HSQUIRRELVM vm, SQInteger idx) popAsInt(HSQUIRRELVM vm, SQInteger idx)
{ {
SQObjectType value_type = sq_gettype(vm, idx); const SQObjectType value_type = sq_gettype(vm, idx);
switch(value_type) { switch(value_type) {
case OT_BOOL: case OT_BOOL:
SQBool sqValueb; SQBool sqValueb;
sq_getbool(vm, idx, &sqValueb); sq_getbool(vm, idx, &sqValueb);
value = static_cast<T>(sqValueb); value = static_cast<T>(sqValueb);
break; break;
case OT_INTEGER: case OT_INTEGER:
SQInteger sqValue; SQInteger sqValue;
sq_getinteger(vm, idx, &sqValue); sq_getinteger(vm, idx, &sqValue);
value = static_cast<T>(sqValue); value = static_cast<T>(sqValue);
break; break;
case OT_FLOAT: case OT_FLOAT:
SQFloat sqValuef; SQFloat sqValuef;
sq_getfloat(vm, idx, &sqValuef); sq_getfloat(vm, idx, &sqValuef);
value = static_cast<T>(static_cast<int>(sqValuef)); value = static_cast<T>(static_cast<SQInteger>(sqValuef));
break; break;
default: default:
SQTHROW(vm, FormatTypeError(vm, idx, _SC("integer"))); SQTHROW(vm, FormatTypeError(vm, idx, _SC("integer")));
value = static_cast<T>(0); value = static_cast<T>(0);
break; break;
} }
} }
}; };
@ -86,26 +86,26 @@ struct popAsFloat
T value; T value;
popAsFloat(HSQUIRRELVM vm, SQInteger idx) popAsFloat(HSQUIRRELVM vm, SQInteger idx)
{ {
SQObjectType value_type = sq_gettype(vm, idx); const SQObjectType value_type = sq_gettype(vm, idx);
switch(value_type) { switch(value_type) {
case OT_BOOL: case OT_BOOL:
SQBool sqValueb; SQBool sqValueb;
sq_getbool(vm, idx, &sqValueb); sq_getbool(vm, idx, &sqValueb);
value = static_cast<T>(sqValueb); value = static_cast<T>(sqValueb);
break; break;
case OT_INTEGER: case OT_INTEGER:
SQInteger sqValue; \ SQInteger sqValue; \
sq_getinteger(vm, idx, &sqValue); sq_getinteger(vm, idx, &sqValue);
value = static_cast<T>(sqValue); value = static_cast<T>(sqValue);
break; break;
case OT_FLOAT: case OT_FLOAT:
SQFloat sqValuef; SQFloat sqValuef;
sq_getfloat(vm, idx, &sqValuef); sq_getfloat(vm, idx, &sqValuef);
value = static_cast<T>(sqValuef); value = static_cast<T>(sqValuef);
break; break;
default: default:
SQTHROW(vm, FormatTypeError(vm, idx, _SC("float"))); SQTHROW(vm, FormatTypeError(vm, idx, _SC("float")));
value = 0; value = 0;
break; break;
} }
} }