mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-08-06 08:01:47 +02:00
Integrate SQLite module.
Integrate the SQLite module into the host plugin and get it to compile.
This commit is contained in:
@@ -116,6 +116,144 @@ void LongInt< Uint64 >::Random(Type m, Type n)
|
||||
m_Data = GetRandomUint64(m, n);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Int64 PopStackSLong(HSQUIRRELVM vm, SQInteger idx)
|
||||
{
|
||||
// Identify which type must be extracted
|
||||
switch (sq_gettype(vm, idx))
|
||||
{
|
||||
case OT_INTEGER:
|
||||
{
|
||||
SQInteger val;
|
||||
sq_getinteger(vm, idx, &val);
|
||||
return static_cast< Int64 >(val);
|
||||
} break;
|
||||
case OT_FLOAT:
|
||||
{
|
||||
SQFloat val;
|
||||
sq_getfloat(vm, idx, &val);
|
||||
return ConvTo< Int64 >::From(val);
|
||||
} break;
|
||||
case OT_BOOL:
|
||||
{
|
||||
SQBool val;
|
||||
sq_getbool(vm, idx, &val);
|
||||
return static_cast< Int64 >(val);
|
||||
} break;
|
||||
case OT_STRING:
|
||||
{
|
||||
CSStr val = nullptr;
|
||||
// Attempt to retrieve and convert the string
|
||||
if (SQ_SUCCEEDED(sq_getstring(vm, idx, &val)) && val != nullptr && *val != '\0')
|
||||
{
|
||||
return std::strtoll(val, nullptr, 10);
|
||||
}
|
||||
} break;
|
||||
case OT_ARRAY:
|
||||
case OT_TABLE:
|
||||
case OT_CLASS:
|
||||
case OT_USERDATA:
|
||||
{
|
||||
return static_cast< Int64 >(sq_getsize(vm, idx));
|
||||
} break;
|
||||
case OT_INSTANCE:
|
||||
{
|
||||
// Attempt to treat the value as a signed long instance
|
||||
try
|
||||
{
|
||||
return Var< const SLongInt & >(vm, idx).value.GetNum();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Just ignore it...
|
||||
}
|
||||
// Attempt to treat the value as a unsigned long instance
|
||||
try
|
||||
{
|
||||
return ConvTo< Int64 >::From(Var< const ULongInt & >(vm, idx).value.GetNum());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Just ignore it...
|
||||
}
|
||||
// Attempt to get the size of the instance as a fall back
|
||||
return static_cast< Int64 >(sq_getsize(vm, idx));
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
// Default to 0
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Uint64 PopStackULong(HSQUIRRELVM vm, SQInteger idx)
|
||||
{
|
||||
// Identify which type must be extracted
|
||||
switch (sq_gettype(vm, idx))
|
||||
{
|
||||
case OT_INTEGER:
|
||||
{
|
||||
SQInteger val;
|
||||
sq_getinteger(vm, idx, &val);
|
||||
return ConvTo< Uint64 >::From(val);
|
||||
} break;
|
||||
case OT_FLOAT:
|
||||
{
|
||||
SQFloat val;
|
||||
sq_getfloat(vm, idx, &val);
|
||||
return ConvTo< Uint64 >::From(val);
|
||||
} break;
|
||||
case OT_BOOL:
|
||||
{
|
||||
SQBool val;
|
||||
sq_getbool(vm, idx, &val);
|
||||
return ConvTo< Uint64 >::From(val);
|
||||
} break;
|
||||
case OT_STRING:
|
||||
{
|
||||
CSStr val = nullptr;
|
||||
// Attempt to retrieve and convert the string
|
||||
if (SQ_SUCCEEDED(sq_getstring(vm, idx, &val)) && val != nullptr && *val != '\0')
|
||||
{
|
||||
return std::strtoull(val, nullptr, 10);
|
||||
}
|
||||
} break;
|
||||
case OT_ARRAY:
|
||||
case OT_TABLE:
|
||||
case OT_CLASS:
|
||||
case OT_USERDATA:
|
||||
{
|
||||
return ConvTo< Uint64 >::From(sq_getsize(vm, idx));
|
||||
} break;
|
||||
case OT_INSTANCE:
|
||||
{
|
||||
// Attempt to treat the value as a signed long instance
|
||||
try
|
||||
{
|
||||
return ConvTo< Uint64 >::From(Var< const SLongInt & >(vm, idx).value.GetNum());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Just ignore it...
|
||||
}
|
||||
// Attempt to treat the value as a unsigned long instance
|
||||
try
|
||||
{
|
||||
return Var< const ULongInt & >(vm, idx).value.GetNum();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Just ignore it...
|
||||
}
|
||||
// Attempt to get the size of the instance as a fall back
|
||||
return ConvTo< Uint64 >::From(sq_getsize(vm, idx));
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
// Default to 0
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ================================================================================================
|
||||
void Register_LongInt(HSQUIRRELVM vm)
|
||||
{
|
||||
|
@@ -1275,6 +1275,16 @@ inline Int32 LongInt< Int64 >::Cmp(const LongInt< Uint64 > & o) const
|
||||
typedef LongInt< Int64 > SLongInt;
|
||||
typedef LongInt< Uint64 > ULongInt;
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Attempt to pop the value at the specified index on the stack as a signed long integer.
|
||||
*/
|
||||
Int64 PopStackSLong(HSQUIRRELVM vm, SQInteger idx);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Attempt to pop the value at the specified index on the stack as an unsigned long integer.
|
||||
*/
|
||||
Uint64 PopStackULong(HSQUIRRELVM vm, SQInteger idx);
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _LIBRARY_NUMERIC_LONGINT_HPP_
|
||||
|
Reference in New Issue
Block a user