mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Remove SLongInt and ULongInt helper types.
Fix a bunch of bugs and mistakes discovered along the way.
This commit is contained in:
parent
60467782e3
commit
f49452c165
@ -78,7 +78,6 @@ add_library(SqModule MODULE SqBase.hpp Main.cpp
|
|||||||
Library/MMDB.cpp Library/MMDB.hpp
|
Library/MMDB.cpp Library/MMDB.hpp
|
||||||
Library/Net.cpp Library/Net.hpp
|
Library/Net.cpp Library/Net.hpp
|
||||||
Library/Numeric.cpp Library/Numeric.hpp
|
Library/Numeric.cpp Library/Numeric.hpp
|
||||||
Library/Numeric/Long.cpp Library/Numeric/Long.hpp
|
|
||||||
Library/Numeric/Math.cpp Library/Numeric/Math.hpp
|
Library/Numeric/Math.cpp Library/Numeric/Math.hpp
|
||||||
Library/Numeric/Random.cpp Library/Numeric/Random.hpp
|
Library/Numeric/Random.cpp Library/Numeric/Random.hpp
|
||||||
Library/String.cpp Library/String.hpp
|
Library/String.cpp Library/String.hpp
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include "Core/Common.hpp"
|
#include "Core/Common.hpp"
|
||||||
#include "Core/Buffer.hpp"
|
#include "Core/Buffer.hpp"
|
||||||
#include "Core/Utility.hpp"
|
#include "Core/Utility.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
@ -313,46 +312,10 @@ SQInteger PopStackInteger(HSQUIRRELVM vm, SQInteger idx)
|
|||||||
case OT_TABLE:
|
case OT_TABLE:
|
||||||
case OT_CLASS:
|
case OT_CLASS:
|
||||||
case OT_USERDATA:
|
case OT_USERDATA:
|
||||||
{
|
|
||||||
return sq_getsize(vm, idx);
|
|
||||||
}
|
|
||||||
case OT_INSTANCE:
|
case OT_INSTANCE:
|
||||||
{
|
{
|
||||||
SQUserPointer tag;
|
// Attempt to get the size of the instance as a fall back
|
||||||
// Attempt to retrieve the type tag
|
return sq_getsize(vm, idx);
|
||||||
if (SQ_FAILED(sq_gettypetag(vm, -1, &tag)))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Is the instance SLongInt? (signed long)
|
|
||||||
else if (static_cast< AbstractStaticClassData * >(tag) == StaticClassTypeTag< SLongInt >::Get())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return ConvTo< SQInteger >::From(Var< const SLongInt & >(vm, idx).value.GetNum());
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
// Just ignore it...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Is the instance ULongInt? (unsigned long)
|
|
||||||
else if (static_cast< AbstractStaticClassData * >(tag) == StaticClassTypeTag< ULongInt >::Get())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return ConvTo< SQInteger >::From(Var< const ULongInt & >(vm, idx).value.GetNum());
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
// Just ignore it...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Attempt to get the size of the instance as a fall back
|
|
||||||
return sq_getsize(vm, idx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
@ -406,41 +369,8 @@ SQFloat PopStackFloat(HSQUIRRELVM vm, SQInteger idx)
|
|||||||
}
|
}
|
||||||
case OT_INSTANCE:
|
case OT_INSTANCE:
|
||||||
{
|
{
|
||||||
SQUserPointer tag;
|
// Attempt to get the size of the instance as a fall back
|
||||||
// Attempt to retrieve the type tag
|
return ConvTo< SQFloat >::From(sq_getsize(vm, idx));
|
||||||
if (SQ_FAILED(sq_gettypetag(vm, -1, &tag)))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Is the instance SLongInt? (signed long)
|
|
||||||
else if (static_cast< AbstractStaticClassData * >(tag) == StaticClassTypeTag< SLongInt >::Get())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return ConvTo< SQFloat >::From(Var< const SLongInt & >(vm, idx).value.GetNum());
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
// Just ignore it...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Is the instance ULongInt? (unsigned long)
|
|
||||||
else if (static_cast< AbstractStaticClassData * >(tag) == StaticClassTypeTag< ULongInt >::Get())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return ConvTo< SQFloat >::From(Var< const ULongInt & >(vm, idx).value.GetNum());
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
// Just ignore it...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Attempt to get the size of the instance as a fall back
|
|
||||||
return ConvTo< SQFloat >::From(sq_getsize(vm, idx));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include "Library/Chrono/Date.hpp"
|
#include "Library/Chrono/Date.hpp"
|
||||||
#include "Library/Chrono/Timer.hpp"
|
#include "Library/Chrono/Timer.hpp"
|
||||||
#include "Library/Chrono/Timestamp.hpp"
|
#include "Library/Chrono/Timestamp.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
#include "Core/Utility.hpp"
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -243,33 +242,38 @@ int64_t Chrono::DateRangeToSeconds(uint16_t _year, uint8_t _month, uint8_t _day,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static SLongInt SqGetEpochTimeMicro()
|
static SQRESULT SqGetEpochTimeMicro(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
return SLongInt(Chrono::GetEpochTimeMicro());
|
sq_pushinteger(vm, Chrono::GetEpochTimeMicro());
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static SLongInt SqGetEpochTimeMilli()
|
static SQRESULT SqGetEpochTimeMilli(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
return SLongInt(Chrono::GetEpochTimeMilli());
|
sq_pushinteger(vm, Chrono::GetEpochTimeMilli());
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static SLongInt SqGetCurrentSysTime()
|
static SQRESULT SqGetCurrentSysTime(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
return SLongInt(Chrono::GetCurrentSysTime());
|
sq_pushinteger(vm, Chrono::GetCurrentSysTime());
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static SQInteger SqGetTickCount()
|
static SQRESULT SqGetTickCount(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
return ConvTo< SQInteger >::From(GetTickCount());
|
sq_pushinteger(vm, ConvTo< SQInteger >::From(GetTickCount()));
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static SLongInt SqGetTickCount64()
|
static SQRESULT SqGetTickCount64(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
return SLongInt(GetTickCount64());
|
sq_pushinteger(vm, ConvTo< SQInteger >::From(GetTickCount64()));
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
@ -284,11 +288,11 @@ void Register_Chrono(HSQUIRRELVM vm)
|
|||||||
Register_ChronoTimestamp(vm, cns);
|
Register_ChronoTimestamp(vm, cns);
|
||||||
|
|
||||||
cns
|
cns
|
||||||
.Func(_SC("EpochMicro"), &SqGetEpochTimeMicro)
|
.SquirrelFunc(_SC("EpochMicro"), &SqGetEpochTimeMicro)
|
||||||
.Func(_SC("EpochMilli"), &SqGetEpochTimeMilli)
|
.SquirrelFunc(_SC("EpochMilli"), &SqGetEpochTimeMilli)
|
||||||
.Func(_SC("Current"), &SqGetCurrentSysTime)
|
.SquirrelFunc(_SC("Current"), &SqGetCurrentSysTime)
|
||||||
.Func(_SC("TickCount"), &SqGetTickCount)
|
.SquirrelFunc(_SC("TickCount"), &SqGetTickCount)
|
||||||
.Func(_SC("TickCount64"), &SqGetTickCount64)
|
.SquirrelFunc(_SC("TickCount64"), &SqGetTickCount64)
|
||||||
.Func(_SC("IsLeapYear"), &Chrono::IsLeapYear)
|
.Func(_SC("IsLeapYear"), &Chrono::IsLeapYear)
|
||||||
.Func(_SC("IsDateValid"), &Chrono::ValidDate)
|
.Func(_SC("IsDateValid"), &Chrono::ValidDate)
|
||||||
.Func(_SC("DaysInYear"), &Chrono::DaysInYear)
|
.Func(_SC("DaysInYear"), &Chrono::DaysInYear)
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include "Library/Chrono/Time.hpp"
|
#include "Library/Chrono/Time.hpp"
|
||||||
#include "Library/Chrono/Date.hpp"
|
#include "Library/Chrono/Date.hpp"
|
||||||
#include "Library/Chrono/Datetime.hpp"
|
#include "Library/Chrono/Datetime.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@ -15,13 +14,6 @@ namespace SqMod {
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQMOD_DECL_TYPENAME(Typename, _SC("SqTimestamp"))
|
SQMOD_DECL_TYPENAME(Typename, _SC("SqTimestamp"))
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
Timestamp::Timestamp(const SLongInt & t)
|
|
||||||
: m_Timestamp(t.GetNum())
|
|
||||||
{
|
|
||||||
/* ... */
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int32_t Timestamp::Cmp(const Timestamp & o) const
|
int32_t Timestamp::Cmp(const Timestamp & o) const
|
||||||
{
|
{
|
||||||
@ -52,36 +44,36 @@ void Timestamp::SetNow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SLongInt Timestamp::GetMicroseconds() const
|
SQInteger Timestamp::GetMicroseconds() const
|
||||||
{
|
{
|
||||||
return SLongInt(m_Timestamp);
|
return m_Timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Timestamp::SetMicroseconds(const SLongInt & amount)
|
void Timestamp::SetMicroseconds(SQInteger amount)
|
||||||
{
|
{
|
||||||
m_Timestamp = amount.GetNum();
|
m_Timestamp = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Timestamp & Timestamp::AddMicroseconds(const SLongInt & amount) { m_Timestamp += amount.GetNum(); return *this; }
|
Timestamp & Timestamp::AddMicroseconds(SQInteger amount) { m_Timestamp += amount; return *this; }
|
||||||
Timestamp & Timestamp::SubMicroseconds(const SLongInt & amount) { m_Timestamp -= amount.GetNum(); return *this; }
|
Timestamp & Timestamp::SubMicroseconds(SQInteger amount) { m_Timestamp -= amount; return *this; }
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SLongInt Timestamp::GetMilliseconds() const
|
SQInteger Timestamp::GetMilliseconds() const
|
||||||
{
|
{
|
||||||
return SLongInt(m_Timestamp / 1000L);
|
return m_Timestamp / 1000L;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Timestamp::SetMilliseconds(const SLongInt & amount)
|
void Timestamp::SetMilliseconds(SQInteger amount)
|
||||||
{
|
{
|
||||||
m_Timestamp = (amount.GetNum() * 1000L);
|
m_Timestamp = (amount * 1000L);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Timestamp & Timestamp::AddMilliseconds(const SLongInt & amount) { m_Timestamp += (amount.GetNum() * 1000L); return *this; }
|
Timestamp & Timestamp::AddMilliseconds(SQInteger amount) { m_Timestamp += (amount * 1000L); return *this; }
|
||||||
Timestamp & Timestamp::SubMilliseconds(const SLongInt & amount) { m_Timestamp -= (amount.GetNum() * 1000L); return *this; }
|
Timestamp & Timestamp::SubMilliseconds(SQInteger amount) { m_Timestamp -= (amount * 1000L); return *this; }
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Time Timestamp::GetTime() const
|
Time Timestamp::GetTime() const
|
||||||
@ -213,7 +205,7 @@ static Timestamp SqGetMicrosecondsRaw(int64_t amount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
static Timestamp SqGetMicroseconds(const SLongInt & amount)
|
static Timestamp SqGetMicroseconds(SQInteger amount)
|
||||||
{
|
{
|
||||||
return Timestamp(amount);
|
return Timestamp(amount);
|
||||||
}
|
}
|
||||||
|
@ -40,11 +40,6 @@ public:
|
|||||||
/* ... */
|
/* ... */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
explicit Timestamp(const SLongInt & t);
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -122,18 +117,18 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD SLongInt GetMicroseconds() const;
|
SQMOD_NODISCARD SQInteger GetMicroseconds() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void SetMicroseconds(const SLongInt & amount);
|
void SetMicroseconds(SQInteger amount);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Timestamp & AddMicroseconds(const SLongInt & amount);
|
Timestamp & AddMicroseconds(SQInteger amount);
|
||||||
Timestamp & SubMicroseconds(const SLongInt & amount);
|
Timestamp & SubMicroseconds(SQInteger amount);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
@ -160,18 +155,18 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD SLongInt GetMilliseconds() const;
|
SQMOD_NODISCARD SQInteger GetMilliseconds() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void SetMilliseconds(const SLongInt & amount);
|
void SetMilliseconds(SQInteger amount);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Timestamp & AddMilliseconds(const SLongInt & amount);
|
Timestamp & AddMilliseconds(SQInteger amount);
|
||||||
Timestamp & SubMilliseconds(const SLongInt & amount);
|
Timestamp & SubMilliseconds(SQInteger amount);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
@ -244,7 +239,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD SQFloat GetMinutesF() const
|
SQMOD_NODISCARD SQFloat GetMinutesF() const
|
||||||
{
|
{
|
||||||
return SQFloat(m_Timestamp / 60000000.0);
|
return SQFloat(m_Timestamp) / 60000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -288,7 +283,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD SQFloat GetHoursF() const
|
SQMOD_NODISCARD SQFloat GetHoursF() const
|
||||||
{
|
{
|
||||||
return SQFloat(m_Timestamp / 3600000000.0);
|
return SQFloat(m_Timestamp) / 3600000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -332,7 +327,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD SQFloat GetDaysF() const
|
SQMOD_NODISCARD SQFloat GetDaysF() const
|
||||||
{
|
{
|
||||||
return SQFloat(m_Timestamp / 86400000000.0);
|
return SQFloat(m_Timestamp) / 86400000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -376,7 +371,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD SQFloat GetYearsF() const
|
SQMOD_NODISCARD SQFloat GetYearsF() const
|
||||||
{
|
{
|
||||||
return SQFloat(m_Timestamp / 31557600000000.0);
|
return SQFloat(m_Timestamp) / 31557600000000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -466,7 +461,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
std::time_t ToTimeT() const;
|
SQMOD_NODISCARD std::time_t ToTimeT() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Library/IO/Buffer.hpp"
|
#include "Library/IO/Buffer.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
#include "Base/AABB.hpp"
|
#include "Base/AABB.hpp"
|
||||||
#include "Base/Circle.hpp"
|
#include "Base/Circle.hpp"
|
||||||
#include "Base/Color3.hpp"
|
#include "Base/Color3.hpp"
|
||||||
@ -20,19 +19,7 @@ namespace SqMod {
|
|||||||
SQMOD_DECL_TYPENAME(Typename, _SC("SqBuffer"))
|
SQMOD_DECL_TYPENAME(Typename, _SC("SqBuffer"))
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteInt64(const SLongInt & val)
|
SQInteger SqBuffer::WriteRawString(StackStrF & val) const
|
||||||
{
|
|
||||||
Valid().Push< int64_t >(val.GetNum());
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void SqBuffer::WriteUint64(const ULongInt & val)
|
|
||||||
{
|
|
||||||
Valid().Push< uint64_t >(val.GetNum());
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
SQInteger SqBuffer::WriteRawString(StackStrF & val)
|
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
Validate();
|
Validate();
|
||||||
@ -50,7 +37,7 @@ SQInteger SqBuffer::WriteRawString(StackStrF & val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQInteger SqBuffer::WriteClientString(StackStrF & val)
|
SQInteger SqBuffer::WriteClientString(StackStrF & val) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
Validate();
|
Validate();
|
||||||
@ -75,67 +62,67 @@ SQInteger SqBuffer::WriteClientString(StackStrF & val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteAABB(const AABB & val)
|
void SqBuffer::WriteAABB(const AABB & val) const
|
||||||
{
|
{
|
||||||
Valid().Push< AABB >(val);
|
Valid().Push< AABB >(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteCircle(const Circle & val)
|
void SqBuffer::WriteCircle(const Circle & val) const
|
||||||
{
|
{
|
||||||
Valid().Push< Circle >(val);
|
Valid().Push< Circle >(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteColor3(const Color3 & val)
|
void SqBuffer::WriteColor3(const Color3 & val) const
|
||||||
{
|
{
|
||||||
Valid().Push< Color3 >(val);
|
Valid().Push< Color3 >(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteColor4(const Color4 & val)
|
void SqBuffer::WriteColor4(const Color4 & val) const
|
||||||
{
|
{
|
||||||
Valid().Push< Color4 >(val);
|
Valid().Push< Color4 >(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteQuaternion(const Quaternion & val)
|
void SqBuffer::WriteQuaternion(const Quaternion & val) const
|
||||||
{
|
{
|
||||||
Valid().Push< Quaternion >(val);
|
Valid().Push< Quaternion >(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteSphere(const Sphere &val)
|
void SqBuffer::WriteSphere(const Sphere &val) const
|
||||||
{
|
{
|
||||||
Valid().Push< Sphere >(val);
|
Valid().Push< Sphere >(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteVector2(const Vector2 & val)
|
void SqBuffer::WriteVector2(const Vector2 & val) const
|
||||||
{
|
{
|
||||||
Valid().Push< Vector2 >(val);
|
Valid().Push< Vector2 >(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteVector2i(const Vector2i & val)
|
void SqBuffer::WriteVector2i(const Vector2i & val) const
|
||||||
{
|
{
|
||||||
Valid().Push< Vector2i >(val);
|
Valid().Push< Vector2i >(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteVector3(const Vector3 & val)
|
void SqBuffer::WriteVector3(const Vector3 & val) const
|
||||||
{
|
{
|
||||||
Valid().Push< Vector3 >(val);
|
Valid().Push< Vector3 >(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SqBuffer::WriteVector4(const Vector4 & val)
|
void SqBuffer::WriteVector4(const Vector4 & val) const
|
||||||
{
|
{
|
||||||
Valid().Push< Vector4 >(val);
|
Valid().Push< Vector4 >(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SLongInt SqBuffer::ReadInt64()
|
SQInteger SqBuffer::ReadInt64() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -144,11 +131,11 @@ SLongInt SqBuffer::ReadInt64()
|
|||||||
// Advance the buffer cursor
|
// Advance the buffer cursor
|
||||||
m_Buffer->Advance< int64_t >(1);
|
m_Buffer->Advance< int64_t >(1);
|
||||||
// Return the requested information
|
// Return the requested information
|
||||||
return SLongInt(value);
|
return static_cast< SQInteger >(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
ULongInt SqBuffer::ReadUint64()
|
SQInteger SqBuffer::ReadUint64() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -157,11 +144,11 @@ ULongInt SqBuffer::ReadUint64()
|
|||||||
// Advance the buffer cursor
|
// Advance the buffer cursor
|
||||||
m_Buffer->Advance< uint64_t >(1);
|
m_Buffer->Advance< uint64_t >(1);
|
||||||
// Return the requested information
|
// Return the requested information
|
||||||
return ULongInt(value);
|
return static_cast< SQInteger >(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj SqBuffer::ReadRawString(SQInteger length)
|
LightObj SqBuffer::ReadRawString(SQInteger length) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -201,7 +188,7 @@ LightObj SqBuffer::ReadRawString(SQInteger length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj SqBuffer::ReadClientString()
|
LightObj SqBuffer::ReadClientString() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -228,7 +215,7 @@ LightObj SqBuffer::ReadClientString()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
AABB SqBuffer::ReadAABB()
|
AABB SqBuffer::ReadAABB() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -241,7 +228,7 @@ AABB SqBuffer::ReadAABB()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Circle SqBuffer::ReadCircle()
|
Circle SqBuffer::ReadCircle() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -254,7 +241,7 @@ Circle SqBuffer::ReadCircle()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Color3 SqBuffer::ReadColor3()
|
Color3 SqBuffer::ReadColor3() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -267,7 +254,7 @@ Color3 SqBuffer::ReadColor3()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Color4 SqBuffer::ReadColor4()
|
Color4 SqBuffer::ReadColor4() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -280,7 +267,7 @@ Color4 SqBuffer::ReadColor4()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Quaternion SqBuffer::ReadQuaternion()
|
Quaternion SqBuffer::ReadQuaternion() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -293,7 +280,7 @@ Quaternion SqBuffer::ReadQuaternion()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Sphere SqBuffer::ReadSphere()
|
Sphere SqBuffer::ReadSphere() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -306,7 +293,7 @@ Sphere SqBuffer::ReadSphere()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Vector2 SqBuffer::ReadVector2()
|
Vector2 SqBuffer::ReadVector2() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -319,7 +306,7 @@ Vector2 SqBuffer::ReadVector2()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Vector2i SqBuffer::ReadVector2i()
|
Vector2i SqBuffer::ReadVector2i() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -332,7 +319,7 @@ Vector2i SqBuffer::ReadVector2i()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Vector3 SqBuffer::ReadVector3()
|
Vector3 SqBuffer::ReadVector3() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -345,7 +332,7 @@ Vector3 SqBuffer::ReadVector3()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Vector4 SqBuffer::ReadVector4()
|
Vector4 SqBuffer::ReadVector4() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -358,7 +345,7 @@ Vector4 SqBuffer::ReadVector4()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQInteger SqBuffer::GetCRC32(SQInteger n)
|
SQInteger SqBuffer::GetCRC32(SQInteger n) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -371,7 +358,7 @@ SQInteger SqBuffer::GetCRC32(SQInteger n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQInteger SqBuffer::GetADLER32(SQInteger n)
|
SQInteger SqBuffer::GetADLER32(SQInteger n) const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
|
@ -176,7 +176,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed memory buffer reference.
|
* Validate the managed memory buffer reference.
|
||||||
*/
|
*/
|
||||||
Buffer & Valid() const
|
SQMOD_NODISCARD Buffer & Valid() const
|
||||||
{
|
{
|
||||||
Validate();
|
Validate();
|
||||||
// Return the buffer
|
// Return the buffer
|
||||||
@ -186,7 +186,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Validate the managed memory buffer reference and the buffer itself.
|
* Validate the managed memory buffer reference and the buffer itself.
|
||||||
*/
|
*/
|
||||||
Buffer & ValidDeeper() const
|
SQMOD_NODISCARD Buffer & ValidDeeper() const
|
||||||
{
|
{
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
// Return the buffer
|
// Return the buffer
|
||||||
@ -204,7 +204,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify a certain element type at the specified position.
|
* Modify a certain element type at the specified position.
|
||||||
*/
|
*/
|
||||||
void Set(SQInteger n, SQInteger v)
|
void Set(SQInteger n, SQInteger v) const
|
||||||
{
|
{
|
||||||
Valid().At(ConvTo< SzType >::From(n)) = ConvTo< Value >::From(v);
|
Valid().At(ConvTo< SzType >::From(n)) = ConvTo< Value >::From(v);
|
||||||
}
|
}
|
||||||
@ -220,7 +220,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the element at the front of the buffer.
|
* Modify the element at the front of the buffer.
|
||||||
*/
|
*/
|
||||||
void SetFront(SQInteger v)
|
void SetFront(SQInteger v) const
|
||||||
{
|
{
|
||||||
Valid().Front() = ConvTo< Value >::From(v);
|
Valid().Front() = ConvTo< Value >::From(v);
|
||||||
}
|
}
|
||||||
@ -236,7 +236,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the element after the first element in the buffer.
|
* Modify the element after the first element in the buffer.
|
||||||
*/
|
*/
|
||||||
void SetNext(SQInteger v)
|
void SetNext(SQInteger v) const
|
||||||
{
|
{
|
||||||
Valid().Next() = ConvTo< Value >::From(v);
|
Valid().Next() = ConvTo< Value >::From(v);
|
||||||
}
|
}
|
||||||
@ -252,7 +252,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the element at the back of the buffer.
|
* Modify the element at the back of the buffer.
|
||||||
*/
|
*/
|
||||||
void SetBack(SQInteger v)
|
void SetBack(SQInteger v) const
|
||||||
{
|
{
|
||||||
Valid().Back() = ConvTo< Value >::From(v);
|
Valid().Back() = ConvTo< Value >::From(v);
|
||||||
}
|
}
|
||||||
@ -268,7 +268,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the element before the last element in the buffer.
|
* Modify the element before the last element in the buffer.
|
||||||
*/
|
*/
|
||||||
void SetPrev(SQInteger v)
|
void SetPrev(SQInteger v) const
|
||||||
{
|
{
|
||||||
Valid().Prev() = ConvTo< Value >::From(v);
|
Valid().Prev() = ConvTo< Value >::From(v);
|
||||||
}
|
}
|
||||||
@ -276,7 +276,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Reposition the edit cursor to the specified number of elements ahead.
|
* Reposition the edit cursor to the specified number of elements ahead.
|
||||||
*/
|
*/
|
||||||
void Advance(SQInteger n)
|
void Advance(SQInteger n) const
|
||||||
{
|
{
|
||||||
Valid().Advance(ConvTo< SzType >::From(n));
|
Valid().Advance(ConvTo< SzType >::From(n));
|
||||||
}
|
}
|
||||||
@ -284,7 +284,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Reposition the edit cursor to the specified number of elements behind.
|
* Reposition the edit cursor to the specified number of elements behind.
|
||||||
*/
|
*/
|
||||||
void Retreat(SQInteger n)
|
void Retreat(SQInteger n) const
|
||||||
{
|
{
|
||||||
Valid().Retreat(ConvTo< SzType >::From(n));
|
Valid().Retreat(ConvTo< SzType >::From(n));
|
||||||
}
|
}
|
||||||
@ -292,7 +292,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Reposition the edit cursor to a fixed position within the buffer.
|
* Reposition the edit cursor to a fixed position within the buffer.
|
||||||
*/
|
*/
|
||||||
void Move(SQInteger n)
|
void Move(SQInteger n) const
|
||||||
{
|
{
|
||||||
Valid().Move(ConvTo< SzType >::From(n));
|
Valid().Move(ConvTo< SzType >::From(n));
|
||||||
}
|
}
|
||||||
@ -300,7 +300,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Append a value to the current cursor location and advance the cursor.
|
* Append a value to the current cursor location and advance the cursor.
|
||||||
*/
|
*/
|
||||||
void Push(SQInteger v)
|
void Push(SQInteger v) const
|
||||||
{
|
{
|
||||||
Valid().Push(ConvTo< Value >::From(v));
|
Valid().Push(ConvTo< Value >::From(v));
|
||||||
}
|
}
|
||||||
@ -316,7 +316,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the element at the cursor position.
|
* Modify the element at the cursor position.
|
||||||
*/
|
*/
|
||||||
void SetCursor(SQInteger v)
|
void SetCursor(SQInteger v) const
|
||||||
{
|
{
|
||||||
Valid().Cursor() = ConvTo< Value >::From(v);
|
Valid().Cursor() = ConvTo< Value >::From(v);
|
||||||
}
|
}
|
||||||
@ -332,7 +332,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the element before the cursor position.
|
* Modify the element before the cursor position.
|
||||||
*/
|
*/
|
||||||
void SetBefore(SQInteger v)
|
void SetBefore(SQInteger v) const
|
||||||
{
|
{
|
||||||
Valid().Before() = ConvTo< Value >::From(v);
|
Valid().Before() = ConvTo< Value >::From(v);
|
||||||
}
|
}
|
||||||
@ -348,7 +348,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the element after the cursor position.
|
* Modify the element after the cursor position.
|
||||||
*/
|
*/
|
||||||
void SetAfter(SQInteger v)
|
void SetAfter(SQInteger v) const
|
||||||
{
|
{
|
||||||
Valid().After() = ConvTo< Value >::From(v);
|
Valid().After() = ConvTo< Value >::From(v);
|
||||||
}
|
}
|
||||||
@ -396,7 +396,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Grow the size of the internal buffer by the specified amount of bytes.
|
* Grow the size of the internal buffer by the specified amount of bytes.
|
||||||
*/
|
*/
|
||||||
void Grow(SQInteger n)
|
void Grow(SQInteger n) const
|
||||||
{
|
{
|
||||||
return Valid().Grow(ConvTo< SzType >::From(n) * sizeof(Value));
|
return Valid().Grow(ConvTo< SzType >::From(n) * sizeof(Value));
|
||||||
}
|
}
|
||||||
@ -425,65 +425,71 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a signed 8 bit integer to the buffer.
|
* Write a signed 8 bit integer to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteInt8(SQInteger val)
|
void WriteInt8(SQInteger val) const
|
||||||
{
|
{
|
||||||
Valid().Push< int8_t >(ConvTo< int8_t >::From(val));
|
Valid().Push< int8_t >(static_cast< int8_t >(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write an unsigned 8 bit integer to the buffer.
|
* Write an unsigned 8 bit integer to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteUint8(SQInteger val)
|
void WriteUint8(SQInteger val) const
|
||||||
{
|
{
|
||||||
Valid().Push< uint8_t >(ConvTo< uint8_t >::From(val));
|
Valid().Push< uint8_t >(static_cast< uint8_t >(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a signed 16 bit integer to the buffer.
|
* Write a signed 16 bit integer to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteInt16(SQInteger val)
|
void WriteInt16(SQInteger val) const
|
||||||
{
|
{
|
||||||
Valid().Push< int16_t >(ConvTo< int16_t >::From(val));
|
Valid().Push< int16_t >(static_cast< int16_t >(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write an unsigned 16 bit integer to the buffer.
|
* Write an unsigned 16 bit integer to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteUint16(SQInteger val)
|
void WriteUint16(SQInteger val) const
|
||||||
{
|
{
|
||||||
Valid().Push< uint16_t >(ConvTo< uint16_t >::From(val));
|
Valid().Push< uint16_t >(static_cast< uint16_t >(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a signed 32 bit integer to the buffer.
|
* Write a signed 32 bit integer to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteInt32(SQInteger val)
|
void WriteInt32(SQInteger val) const
|
||||||
{
|
{
|
||||||
Valid().Push< int32_t >(ConvTo< int32_t >::From(val));
|
Valid().Push< int32_t >(static_cast< int32_t >(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write an unsigned 32 bit integer to the buffer.
|
* Write an unsigned 32 bit integer to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteUint32(SQInteger val)
|
void WriteUint32(SQInteger val) const
|
||||||
{
|
{
|
||||||
Valid().Push< uint32_t >(ConvTo< uint32_t >::From(val));
|
Valid().Push< uint32_t >(static_cast< uint32_t >(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a signed 64 bit integer to the buffer.
|
* Write a signed 64 bit integer to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteInt64(const SLongInt & val);
|
void WriteInt64(SQInteger val) const
|
||||||
|
{
|
||||||
|
Valid().Push< int64_t >(static_cast< int64_t >(val));
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write an unsigned 64 bit integer to the buffer.
|
* Write an unsigned 64 bit integer to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteUint64(const ULongInt & val);
|
void WriteUint64(SQInteger val) const
|
||||||
|
{
|
||||||
|
Valid().Push< uint64_t >(static_cast< uint64_t >(val));
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a 32 bit float to the buffer.
|
* Write a 32 bit float to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteFloat32(SQFloat val)
|
void WriteFloat32(SQFloat val) const
|
||||||
{
|
{
|
||||||
Valid().Push< float >(ConvTo< float >::From(val));
|
Valid().Push< float >(ConvTo< float >::From(val));
|
||||||
}
|
}
|
||||||
@ -491,7 +497,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a 64 bit float to the buffer.
|
* Write a 64 bit float to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteFloat64(SQFloat val)
|
void WriteFloat64(SQFloat val) const
|
||||||
{
|
{
|
||||||
Valid().Push< double >(ConvTo< double >::From(val));
|
Valid().Push< double >(ConvTo< double >::From(val));
|
||||||
}
|
}
|
||||||
@ -499,67 +505,67 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a raw string to the buffer.
|
* Write a raw string to the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger WriteRawString(StackStrF & val);
|
SQInteger WriteRawString(StackStrF & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a client encoded string to the buffer.
|
* Write a client encoded string to the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger WriteClientString(StackStrF & val);
|
SQInteger WriteClientString(StackStrF & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a AABB to the buffer.
|
* Write a AABB to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteAABB(const AABB & val);
|
void WriteAABB(const AABB & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a Circle to the buffer.
|
* Write a Circle to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteCircle(const Circle & val);
|
void WriteCircle(const Circle & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a Color3 to the buffer.
|
* Write a Color3 to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteColor3(const Color3 & val);
|
void WriteColor3(const Color3 & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a Color4 to the buffer.
|
* Write a Color4 to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteColor4(const Color4 & val);
|
void WriteColor4(const Color4 & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a Quaternion to the buffer.
|
* Write a Quaternion to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteQuaternion(const Quaternion & val);
|
void WriteQuaternion(const Quaternion & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a Sphere to the buffer.
|
* Write a Sphere to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteSphere(const Sphere &val);
|
void WriteSphere(const Sphere &val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a Vector2 to the buffer.
|
* Write a Vector2 to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteVector2(const Vector2 & val);
|
void WriteVector2(const Vector2 & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a Vector2i to the buffer.
|
* Write a Vector2i to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteVector2i(const Vector2i & val);
|
void WriteVector2i(const Vector2i & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a Vector3 to the buffer.
|
* Write a Vector3 to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteVector3(const Vector3 & val);
|
void WriteVector3(const Vector3 & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a Vector4 to the buffer.
|
* Write a Vector4 to the buffer.
|
||||||
*/
|
*/
|
||||||
void WriteVector4(const Vector4 & val);
|
void WriteVector4(const Vector4 & val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Write a signed 8 bit integer from the buffer.
|
* Write a signed 8 bit integer from the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger ReadInt8()
|
SQMOD_NODISCARD SQInteger ReadInt8() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -574,7 +580,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read an unsigned 8 bit integer from the buffer.
|
* Read an unsigned 8 bit integer from the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger ReadUint8()
|
SQMOD_NODISCARD SQInteger ReadUint8() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -589,7 +595,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a signed 16 bit integer from the buffer.
|
* Read a signed 16 bit integer from the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger ReadInt16()
|
SQMOD_NODISCARD SQInteger ReadInt16() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -604,7 +610,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read an unsigned 16 bit integer from the buffer.
|
* Read an unsigned 16 bit integer from the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger ReadUint16()
|
SQMOD_NODISCARD SQInteger ReadUint16() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -619,7 +625,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a signed 32 bit integer from the buffer.
|
* Read a signed 32 bit integer from the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger ReadInt32()
|
SQMOD_NODISCARD SQInteger ReadInt32() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -634,7 +640,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read an unsigned 32 bit integer from the buffer.
|
* Read an unsigned 32 bit integer from the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger ReadUint32()
|
SQMOD_NODISCARD SQInteger ReadUint32() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -649,17 +655,17 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a signed 64 bit integer from the buffer.
|
* Read a signed 64 bit integer from the buffer.
|
||||||
*/
|
*/
|
||||||
SLongInt ReadInt64();
|
SQMOD_NODISCARD SQInteger ReadInt64() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read an unsigned 64 bit integer from the buffer.
|
* Read an unsigned 64 bit integer from the buffer.
|
||||||
*/
|
*/
|
||||||
ULongInt ReadUint64();
|
SQMOD_NODISCARD SQInteger ReadUint64() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a 32 bit float from the buffer.
|
* Read a 32 bit float from the buffer.
|
||||||
*/
|
*/
|
||||||
SQFloat ReadFloat32()
|
SQMOD_NODISCARD SQFloat ReadFloat32() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -674,7 +680,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a 64 bit float from the buffer.
|
* Read a 64 bit float from the buffer.
|
||||||
*/
|
*/
|
||||||
SQFloat ReadFloat64()
|
SQMOD_NODISCARD SQFloat ReadFloat64() const
|
||||||
{
|
{
|
||||||
// Validate the managed buffer reference
|
// Validate the managed buffer reference
|
||||||
ValidateDeeper();
|
ValidateDeeper();
|
||||||
@ -689,72 +695,72 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a raw string from the buffer.
|
* Read a raw string from the buffer.
|
||||||
*/
|
*/
|
||||||
LightObj ReadRawString(SQInteger length);
|
SQMOD_NODISCARD LightObj ReadRawString(SQInteger length) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a string from the buffer.
|
* Read a string from the buffer.
|
||||||
*/
|
*/
|
||||||
LightObj ReadClientString();
|
SQMOD_NODISCARD LightObj ReadClientString() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a AABB from the buffer.
|
* Read a AABB from the buffer.
|
||||||
*/
|
*/
|
||||||
AABB ReadAABB();
|
SQMOD_NODISCARD AABB ReadAABB() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a Circle from the buffer.
|
* Read a Circle from the buffer.
|
||||||
*/
|
*/
|
||||||
Circle ReadCircle();
|
SQMOD_NODISCARD Circle ReadCircle() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a Color3 from the buffer.
|
* Read a Color3 from the buffer.
|
||||||
*/
|
*/
|
||||||
Color3 ReadColor3();
|
SQMOD_NODISCARD Color3 ReadColor3() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a Color4 from the buffer.
|
* Read a Color4 from the buffer.
|
||||||
*/
|
*/
|
||||||
Color4 ReadColor4();
|
SQMOD_NODISCARD Color4 ReadColor4() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a Quaternion from the buffer.
|
* Read a Quaternion from the buffer.
|
||||||
*/
|
*/
|
||||||
Quaternion ReadQuaternion();
|
SQMOD_NODISCARD Quaternion ReadQuaternion() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a Sphere from the buffer.
|
* Read a Sphere from the buffer.
|
||||||
*/
|
*/
|
||||||
Sphere ReadSphere();
|
SQMOD_NODISCARD Sphere ReadSphere() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a Vector2 from the buffer.
|
* Read a Vector2 from the buffer.
|
||||||
*/
|
*/
|
||||||
Vector2 ReadVector2();
|
SQMOD_NODISCARD Vector2 ReadVector2() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a Vector2i from the buffer.
|
* Read a Vector2i from the buffer.
|
||||||
*/
|
*/
|
||||||
Vector2i ReadVector2i();
|
SQMOD_NODISCARD Vector2i ReadVector2i() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a Vector3 from the buffer.
|
* Read a Vector3 from the buffer.
|
||||||
*/
|
*/
|
||||||
Vector3 ReadVector3();
|
SQMOD_NODISCARD Vector3 ReadVector3() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Read a Vector4 from the buffer.
|
* Read a Vector4 from the buffer.
|
||||||
*/
|
*/
|
||||||
Vector4 ReadVector4();
|
SQMOD_NODISCARD Vector4 ReadVector4() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Compute the CRC-32 checksums on the data in the buffer.
|
* Compute the CRC-32 checksums on the data in the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger GetCRC32(SQInteger n);
|
SQMOD_NODISCARD SQInteger GetCRC32(SQInteger n) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Compute the Adler-32 checksums on the data in the buffer.
|
* Compute the Adler-32 checksums on the data in the buffer.
|
||||||
*/
|
*/
|
||||||
SQInteger GetADLER32(SQInteger n);
|
SQMOD_NODISCARD SQInteger GetADLER32(SQInteger n) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
|
@ -36,7 +36,7 @@ static SQChar * Bin128ToDec(const uint32_t N[4])
|
|||||||
// Add s[] to itself in decimal, doubling it
|
// Add s[] to itself in decimal, doubling it
|
||||||
for (j = sizeof(s) - 2; j >= 0; j--)
|
for (j = sizeof(s) - 2; j >= 0; j--)
|
||||||
{
|
{
|
||||||
s[j] += s[j] - '0' + carry;
|
s[j] += s[j] - '0' + carry; // NOLINT(cppcoreguidelines-narrowing-conversions)
|
||||||
|
|
||||||
carry = (s[j] > '9');
|
carry = (s[j] > '9');
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ SQFloat GetEntryAsFloat(const MMDB_entry_data_s & ed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj GetEntryAsLong(const MMDB_entry_data_s & ed)
|
SQInteger GetEntryAsLong(const MMDB_entry_data_s & ed)
|
||||||
{
|
{
|
||||||
uint64_t value = 0;
|
uint64_t value = 0;
|
||||||
// Identify the type of entry data
|
// Identify the type of entry data
|
||||||
@ -315,7 +315,7 @@ LightObj GetEntryAsLong(const MMDB_entry_data_s & ed)
|
|||||||
STHROWF("Unsupported conversion from ({}) to (long)", AsTypeStr(ed.type));
|
STHROWF("Unsupported conversion from ({}) to (long)", AsTypeStr(ed.type));
|
||||||
}
|
}
|
||||||
// Return a long integer instance with the requested value
|
// Return a long integer instance with the requested value
|
||||||
return LightObj(SqTypeIdentity< ULongInt >{}, SqVM(), value);
|
return static_cast< SQInteger >(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -338,7 +338,7 @@ LightObj GetEntryAsString(const MMDB_entry_data_s & ed)
|
|||||||
sq_pushstring(vm, fmt::format("{}", ed.double_value).c_str(), -1);
|
sq_pushstring(vm, fmt::format("{}", ed.double_value).c_str(), -1);
|
||||||
} break;
|
} break;
|
||||||
case MMDB_DATA_TYPE_BYTES: {
|
case MMDB_DATA_TYPE_BYTES: {
|
||||||
sq_pushstring(vm, reinterpret_cast< const SQChar * >(ed.bytes), ed.data_size / sizeof(SQChar));
|
sq_pushstring(vm, reinterpret_cast< const SQChar * >(ed.bytes), static_cast< SQInteger >(ed.data_size) / sizeof(SQChar));
|
||||||
} break;
|
} break;
|
||||||
case MMDB_DATA_TYPE_UINT16: {
|
case MMDB_DATA_TYPE_UINT16: {
|
||||||
sq_pushstring(vm, fmt::format("{}", ed.uint16).c_str(), -1);
|
sq_pushstring(vm, fmt::format("{}", ed.uint16).c_str(), -1);
|
||||||
@ -1051,7 +1051,7 @@ Object LookupResult::GetEntryDataList()
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQInteger LookupResult::GetValue(HSQUIRRELVM vm)
|
SQInteger LookupResult::GetValue(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
const int32_t top = sq_gettop(vm);
|
const auto top = sq_gettop(vm);
|
||||||
// The lookup result instance
|
// The lookup result instance
|
||||||
LookupResult * lookup;
|
LookupResult * lookup;
|
||||||
// Attempt to extract the lookup result instance
|
// Attempt to extract the lookup result instance
|
||||||
@ -1294,7 +1294,7 @@ Object SearchNode::GetRightRecordEntryDataList()
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
SQInteger SearchNode::GetRecordEntryData(HSQUIRRELVM vm, bool right)
|
SQInteger SearchNode::GetRecordEntryData(HSQUIRRELVM vm, bool right)
|
||||||
{
|
{
|
||||||
const int32_t top = sq_gettop(vm);
|
const auto top = sq_gettop(vm);
|
||||||
// The search node result instance
|
// The search node result instance
|
||||||
SearchNode * node;
|
SearchNode * node;
|
||||||
// Attempt to extract the search node result instance
|
// Attempt to extract the search node result instance
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Library/IO/Buffer.hpp"
|
#include "Library/IO/Buffer.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -76,7 +75,7 @@ SQFloat GetEntryAsFloat(const MMDB_entry_data_s & ed);
|
|||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value from the specified entry data as a long integer.
|
* Retrieve the value from the specified entry data as a long integer.
|
||||||
*/
|
*/
|
||||||
LightObj GetEntryAsLong(const MMDB_entry_data_s & ed);
|
SQInteger GetEntryAsLong(const MMDB_entry_data_s & ed);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value from the specified entry data as a string.
|
* Retrieve the value from the specified entry data as a string.
|
||||||
@ -811,7 +810,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value from the current element as a long integer.
|
* Retrieve the value from the current element as a long integer.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj GetLong() const
|
SQMOD_NODISCARD SQInteger GetLong() const
|
||||||
{
|
{
|
||||||
return GetEntryAsLong(SQMOD_GET_VALID(*this));
|
return GetEntryAsLong(SQMOD_GET_VALID(*this));
|
||||||
}
|
}
|
||||||
@ -1105,7 +1104,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value from the current element as a long integer.
|
* Retrieve the value from the current element as a long integer.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj GetLong() const
|
SQMOD_NODISCARD SQInteger GetLong() const
|
||||||
{
|
{
|
||||||
return GetEntryAsLong(SQMOD_GET_VALID_ELEM(*this)->entry_data);
|
return GetEntryAsLong(SQMOD_GET_VALID_ELEM(*this)->entry_data);
|
||||||
}
|
}
|
||||||
@ -1492,9 +1491,9 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the build epoch.
|
* Retrieve the build epoch.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Object GetBuildEpoch() const
|
SQMOD_NODISCARD SQInteger GetBuildEpoch() const
|
||||||
{
|
{
|
||||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(), ConvTo< uint64_t >::From(SQMOD_GET_VALID(*this)->build_epoch));
|
return ConvTo< SQInteger >::From(SQMOD_GET_VALID(*this)->build_epoch);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -1662,17 +1661,17 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the left record value.
|
* Retrieve the left record value.
|
||||||
*/
|
*/
|
||||||
Object GetLeftRecord()
|
SQInteger GetLeftRecord()
|
||||||
{
|
{
|
||||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(), ConvTo< uint64_t >::From(SQMOD_GET_VALID(*this).left_record));
|
return ConvTo< SQInteger >::From(SQMOD_GET_VALID(*this).left_record);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the right record value.
|
* Retrieve the right record value.
|
||||||
*/
|
*/
|
||||||
Object GetRightRecord()
|
SQInteger GetRightRecord()
|
||||||
{
|
{
|
||||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(), ConvTo< uint64_t >::From(SQMOD_GET_VALID(*this).right_record));
|
return ConvTo< SQInteger >::From(SQMOD_GET_VALID(*this).right_record);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
@ -534,7 +534,7 @@ bool DbConvTo< bool >::From(const SQChar * value, unsigned long length, enum_fie
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool DbConvTo< char >::From(const SQChar * value, unsigned long length, enum_field_types type, const SQChar * tn)
|
char DbConvTo< char >::From(const SQChar * value, unsigned long length, enum_field_types type, const SQChar * tn)
|
||||||
{
|
{
|
||||||
return ConvertToSInt< char >(value, length, type, tn);
|
return ConvertToSInt< char >(value, length, type, tn);
|
||||||
}
|
}
|
||||||
@ -636,7 +636,7 @@ void ConnHnd::Create(const Account & acc)
|
|||||||
SQMOD_THROW_CURRENT(*this, "Cannot connect to database");
|
SQMOD_THROW_CURRENT(*this, "Cannot connect to database");
|
||||||
}
|
}
|
||||||
// Attempt configure the auto-commit option
|
// Attempt configure the auto-commit option
|
||||||
else if (mysql_autocommit(mPtr, mAutoCommit) != 0)
|
else if (mysql_autocommit(mPtr, static_cast< StmtBind::BoolType >(mAutoCommit)) != 0)
|
||||||
{
|
{
|
||||||
SQMOD_THROW_CURRENT(*this, "Cannot configure auto-commit");
|
SQMOD_THROW_CURRENT(*this, "Cannot configure auto-commit");
|
||||||
}
|
}
|
||||||
@ -1555,7 +1555,7 @@ void Account::SetSSL(const SQChar * key, const SQChar * cert, const SQChar * ca,
|
|||||||
Table Account::GetOptionsTable() const
|
Table Account::GetOptionsTable() const
|
||||||
{
|
{
|
||||||
// Allocate an empty table
|
// Allocate an empty table
|
||||||
Table tbl(SqVM(), m_Options.size());
|
Table tbl(SqVM(), static_cast< SQInteger >(m_Options.size()));
|
||||||
// Insert every option into the table
|
// Insert every option into the table
|
||||||
for (const auto & opt : m_Options)
|
for (const auto & opt : m_Options)
|
||||||
{
|
{
|
||||||
@ -1694,7 +1694,7 @@ const ConnRef & Connection::GetCreated() const
|
|||||||
#endif // _DEBUG
|
#endif // _DEBUG
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Object Connection::Insert(const SQChar * query)
|
SQInteger Connection::Insert(const SQChar * query)
|
||||||
{
|
{
|
||||||
// Make sure the specified query is valid
|
// Make sure the specified query is valid
|
||||||
if (!query || *query == '\0')
|
if (!query || *query == '\0')
|
||||||
@ -1707,7 +1707,7 @@ Object Connection::Insert(const SQChar * query)
|
|||||||
SQMOD_THROW_CURRENT(*m_Handle, "Unable to execute MySQL query");
|
SQMOD_THROW_CURRENT(*m_Handle, "Unable to execute MySQL query");
|
||||||
}
|
}
|
||||||
// Return the identifier of the inserted row
|
// Return the identifier of the inserted row
|
||||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(), mysql_insert_id(m_Handle->mPtr));
|
return static_cast< SQInteger >(mysql_insert_id(m_Handle->mPtr));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -1784,12 +1784,11 @@ SQInteger Connection::ExecuteF(HSQUIRRELVM vm)
|
|||||||
// Attempt to execute the specified query
|
// Attempt to execute the specified query
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Var< ULongInt >::push(vm, ULongInt(conn->m_Handle->Execute(val.mPtr, static_cast<unsigned long>(val.mLen))));
|
sq_pushinteger(vm, static_cast< SQInteger >(conn->m_Handle->Execute(val.mPtr, static_cast< unsigned long >(val.mLen))));
|
||||||
}
|
}
|
||||||
catch (const Sqrat::Exception & e)
|
catch (const std::exception & e)
|
||||||
{
|
{
|
||||||
// Propagate the error
|
return sq_throwerror(vm, e.what()); // Propagate the error
|
||||||
return sq_throwerror(vm, e.what());
|
|
||||||
}
|
}
|
||||||
// This function returned a value
|
// This function returned a value
|
||||||
return 1;
|
return 1;
|
||||||
@ -1851,12 +1850,11 @@ SQInteger Connection::InsertF(HSQUIRRELVM vm)
|
|||||||
SQMOD_THROW_CURRENT(*(conn->m_Handle), "Unable to execute MySQL query");
|
SQMOD_THROW_CURRENT(*(conn->m_Handle), "Unable to execute MySQL query");
|
||||||
}
|
}
|
||||||
// Return the identifier of the inserted row
|
// Return the identifier of the inserted row
|
||||||
Var< ULongInt >::push(vm, ULongInt(mysql_insert_id(conn->m_Handle->mPtr)));
|
sq_pushinteger(vm, static_cast< SQInteger >(mysql_insert_id(conn->m_Handle->mPtr)));
|
||||||
}
|
}
|
||||||
catch (const Sqrat::Exception & e)
|
catch (const std::exception & e)
|
||||||
{
|
{
|
||||||
// Propagate the error
|
return sq_throwerror(vm, e.what()); // Propagate the error
|
||||||
return sq_throwerror(vm, e.what());
|
|
||||||
}
|
}
|
||||||
// This function returned a value
|
// This function returned a value
|
||||||
return 1;
|
return 1;
|
||||||
@ -2361,7 +2359,7 @@ SQInteger Field::GetUint32() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Object Field::GetInt64() const
|
SQInteger Field::GetInt64() const
|
||||||
{
|
{
|
||||||
SQMOD_VALIDATE_STEPPED(*this);
|
SQMOD_VALIDATE_STEPPED(*this);
|
||||||
// Obtain the initial stack size
|
// Obtain the initial stack size
|
||||||
@ -2369,18 +2367,16 @@ Object Field::GetInt64() const
|
|||||||
// Should we retrieve the value from the bind wrapper?
|
// Should we retrieve the value from the bind wrapper?
|
||||||
if (m_Handle->mStatement)
|
if (m_Handle->mStatement)
|
||||||
{
|
{
|
||||||
return Object(SqTypeIdentity< SLongInt >{}, SqVM(),
|
return ConvTo< SQInteger >::From(m_Handle->mBinds[m_Index].mInt64);
|
||||||
ConvTo< int64_t >::From(m_Handle->mBinds[m_Index].mInt64));
|
|
||||||
}
|
}
|
||||||
// Retrieve the value directly from the row
|
// Retrieve the value directly from the row
|
||||||
return Object(SqTypeIdentity< SLongInt >{}, SqVM(),
|
return DbConvTo< SQInteger >::From(m_Handle->mRow[m_Index],
|
||||||
DbConvTo< int64_t >::From(m_Handle->mRow[m_Index],
|
|
||||||
m_Handle->mLengths[m_Index],
|
m_Handle->mLengths[m_Index],
|
||||||
m_Handle->mFields[m_Index].type));
|
m_Handle->mFields[m_Index].type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Object Field::GetUint64() const
|
SQInteger Field::GetUint64() const
|
||||||
{
|
{
|
||||||
SQMOD_VALIDATE_STEPPED(*this);
|
SQMOD_VALIDATE_STEPPED(*this);
|
||||||
// Obtain the initial stack size
|
// Obtain the initial stack size
|
||||||
@ -2388,14 +2384,12 @@ Object Field::GetUint64() const
|
|||||||
// Should we retrieve the value from the bind wrapper?
|
// Should we retrieve the value from the bind wrapper?
|
||||||
if (m_Handle->mStatement)
|
if (m_Handle->mStatement)
|
||||||
{
|
{
|
||||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(),
|
return ConvTo< SQInteger >::From(m_Handle->mBinds[m_Index].mUint64);
|
||||||
ConvTo< uint64_t >::From(m_Handle->mBinds[m_Index].mUint64));
|
|
||||||
}
|
}
|
||||||
// Retrieve the value directly from the row
|
// Retrieve the value directly from the row
|
||||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(),
|
return DbConvTo< SQInteger >::From(m_Handle->mRow[m_Index],
|
||||||
DbConvTo< uint64_t >::From(m_Handle->mRow[m_Index],
|
|
||||||
m_Handle->mLengths[m_Index],
|
m_Handle->mLengths[m_Index],
|
||||||
m_Handle->mFields[m_Index].type));
|
m_Handle->mFields[m_Index].type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -2997,23 +2991,23 @@ void Statement::SetUint64(uint32_t idx, SQInteger val) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Statement::SetSLongInt(uint32_t idx, const SLongInt & val) const
|
void Statement::SetSLongInt(uint32_t idx, SQInteger val) const
|
||||||
{
|
{
|
||||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||||
// Attempt to set the input value
|
// Attempt to set the input value
|
||||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_LONGLONG, &(m_Handle->mMyBinds[idx]));
|
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_LONGLONG, &(m_Handle->mMyBinds[idx]));
|
||||||
// Attempt to assign the numeric value inside the specified object
|
// Attempt to assign the numeric value inside the specified object
|
||||||
m_Handle->mBinds[idx].mInt64 = val.GetNum();
|
m_Handle->mBinds[idx].mInt64 = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void Statement::SetULongInt(uint32_t idx, const ULongInt & val) const
|
void Statement::SetULongInt(uint32_t idx, SQInteger val) const
|
||||||
{
|
{
|
||||||
SQMOD_VALIDATE_PARAM(*this, idx);
|
SQMOD_VALIDATE_PARAM(*this, idx);
|
||||||
// Attempt to set the input value
|
// Attempt to set the input value
|
||||||
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_LONGLONG, &(m_Handle->mMyBinds[idx]));
|
m_Handle->mBinds[idx].SetInput(MYSQL_TYPE_LONGLONG, &(m_Handle->mMyBinds[idx]));
|
||||||
// Attempt to assign the numeric value inside the specified object
|
// Attempt to assign the numeric value inside the specified object
|
||||||
m_Handle->mBinds[idx].mUint64 = val.GetNum();
|
m_Handle->mBinds[idx].mUint64 = static_cast< uint64_t >(val);
|
||||||
// Specify that this value is unsigned
|
// Specify that this value is unsigned
|
||||||
m_Handle->mMyBinds[idx].is_unsigned = true;
|
m_Handle->mMyBinds[idx].is_unsigned = true;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Library/IO/Buffer.hpp"
|
#include "Library/IO/Buffer.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
#include "Library/Chrono.hpp"
|
#include "Library/Chrono.hpp"
|
||||||
#include "Library/Chrono/Date.hpp"
|
#include "Library/Chrono/Date.hpp"
|
||||||
#include "Library/Chrono/Datetime.hpp"
|
#include "Library/Chrono/Datetime.hpp"
|
||||||
@ -196,7 +195,7 @@ template < > struct DbConvTo< bool >
|
|||||||
*/
|
*/
|
||||||
template < > struct DbConvTo< char >
|
template < > struct DbConvTo< char >
|
||||||
{
|
{
|
||||||
SQMOD_NODISCARD static bool From(const SQChar * value, unsigned long length, enum_field_types type, const SQChar * tn = _SC("char"));
|
SQMOD_NODISCARD static char From(const SQChar * value, unsigned long length, enum_field_types type, const SQChar * tn = _SC("char"));
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
@ -560,7 +559,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the used buffer.
|
* Retrieve the used buffer.
|
||||||
*/
|
*/
|
||||||
char * GetBuffer()
|
SQMOD_NODISCARD char * GetBuffer()
|
||||||
{
|
{
|
||||||
return mData ? mData.Data() : reinterpret_cast< char * >(&mUint64);
|
return mData ? mData.Data() : reinterpret_cast< char * >(&mUint64);
|
||||||
}
|
}
|
||||||
@ -1457,7 +1456,7 @@ public:
|
|||||||
{
|
{
|
||||||
// Attempt to toggle auto-commit if necessary
|
// Attempt to toggle auto-commit if necessary
|
||||||
if (SQMOD_GET_CREATED(*this)->mAutoCommit != toggle &&
|
if (SQMOD_GET_CREATED(*this)->mAutoCommit != toggle &&
|
||||||
mysql_autocommit(m_Handle->mPtr, toggle) != 0)
|
mysql_autocommit(m_Handle->mPtr, static_cast< StmtBind::BoolType >(toggle)) != 0)
|
||||||
{
|
{
|
||||||
SQMOD_THROW_CURRENT(*m_Handle, "Cannot toggle auto-commit");
|
SQMOD_THROW_CURRENT(*m_Handle, "Cannot toggle auto-commit");
|
||||||
}
|
}
|
||||||
@ -1486,15 +1485,15 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Execute a query on the server.
|
* Execute a query on the server.
|
||||||
*/
|
*/
|
||||||
Object Execute(const SQChar * query)
|
SQInteger Execute(const SQChar * query)
|
||||||
{
|
{
|
||||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(), SQMOD_GET_CREATED(*this)->Execute(query));
|
return static_cast< SQInteger >(SQMOD_GET_CREATED(*this)->Execute(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Execute a query on the server.
|
* Execute a query on the server.
|
||||||
*/
|
*/
|
||||||
Object Insert(const SQChar * query);
|
SQInteger Insert(const SQChar * query);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Execute a query on the server.
|
* Execute a query on the server.
|
||||||
@ -1866,12 +1865,12 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value inside the referenced field as a signed 64 bit integer value.
|
* Retrieve the value inside the referenced field as a signed 64 bit integer value.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Object GetInt64() const;
|
SQMOD_NODISCARD SQInteger GetInt64() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value inside the referenced field as an unsigned 64 bit integer value.
|
* Retrieve the value inside the referenced field as an unsigned 64 bit integer value.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Object GetUint64() const;
|
SQMOD_NODISCARD SQInteger GetUint64() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value inside the referenced field as a 32 bit floating point value.
|
* Retrieve the value inside the referenced field as a 32 bit floating point value.
|
||||||
@ -2111,17 +2110,17 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Returns the current position of the row cursor for the last Next().
|
* Returns the current position of the row cursor for the last Next().
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Object RowIndex() const
|
SQMOD_NODISCARD SQInteger RowIndex() const
|
||||||
{
|
{
|
||||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(), SQMOD_GET_CREATED(*this)->RowIndex());
|
return static_cast< SQInteger >(SQMOD_GET_CREATED(*this)->RowIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Returns the number of rows in the result set.
|
* Returns the number of rows in the result set.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Object RowCount() const
|
SQMOD_NODISCARD SQInteger RowCount() const
|
||||||
{
|
{
|
||||||
return Object(SqTypeIdentity< ULongInt >{}, SqVM(), SQMOD_GET_CREATED(*this)->RowCount());
|
return static_cast< SQInteger >(SQMOD_GET_CREATED(*this)->RowCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -2143,9 +2142,9 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Seeks to an arbitrary row in a query result set.
|
* Seeks to an arbitrary row in a query result set.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD bool SetLongRowIndex(const ULongInt & index) const
|
SQMOD_NODISCARD bool SetLongRowIndex(SQInteger index) const
|
||||||
{
|
{
|
||||||
return SQMOD_GET_CREATED(*this)->SetRowIndex(index.GetNum());
|
return SQMOD_GET_CREATED(*this)->SetRowIndex(static_cast< uint64_t >(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -2422,7 +2421,7 @@ public:
|
|||||||
// Do we have a valid handle?
|
// Do we have a valid handle?
|
||||||
if (m_Handle)
|
if (m_Handle)
|
||||||
{
|
{
|
||||||
m_Handle->mQuery;
|
return m_Handle->mQuery;
|
||||||
}
|
}
|
||||||
// Default to an empty string
|
// Default to an empty string
|
||||||
return NullString();
|
return NullString();
|
||||||
@ -2517,12 +2516,12 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Assign a signed long integer to a parameter.
|
* Assign a signed long integer to a parameter.
|
||||||
*/
|
*/
|
||||||
void SetSLongInt(uint32_t idx, const SLongInt & val) const;
|
void SetSLongInt(uint32_t idx, SQInteger val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Assign an unsigned long integer to a parameter.
|
* Assign an unsigned long integer to a parameter.
|
||||||
*/
|
*/
|
||||||
void SetULongInt(uint32_t idx, const ULongInt & val) const;
|
void SetULongInt(uint32_t idx, SQInteger val) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Assign a native integer to a parameter.
|
* Assign a native integer to a parameter.
|
||||||
|
@ -5,14 +5,12 @@
|
|||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
extern void Register_LongInt(HSQUIRRELVM vm);
|
|
||||||
extern void Register_Math(HSQUIRRELVM vm);
|
extern void Register_Math(HSQUIRRELVM vm);
|
||||||
extern void Register_Random(HSQUIRRELVM vm);
|
extern void Register_Random(HSQUIRRELVM vm);
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
void Register_Numeric(HSQUIRRELVM vm)
|
void Register_Numeric(HSQUIRRELVM vm)
|
||||||
{
|
{
|
||||||
Register_LongInt(vm);
|
|
||||||
Register_Math(vm);
|
Register_Math(vm);
|
||||||
Register_Random(vm);
|
Register_Random(vm);
|
||||||
}
|
}
|
||||||
|
@ -1,376 +0,0 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
#include "Library/Numeric/Random.hpp"
|
|
||||||
#include "Base/DynArg.hpp"
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
namespace SqMod {
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
SQMOD_DECL_TYPENAME(TypenameS, _SC("SLongInt"))
|
|
||||||
SQMOD_DECL_TYPENAME(TypenameU, _SC("ULongInt"))
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
LongInt< signed long long >::LongInt(const SQChar * text)
|
|
||||||
: m_Data(0), m_Text()
|
|
||||||
{
|
|
||||||
m_Data = std::strtoll(text, nullptr, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
LongInt< signed long long >::LongInt(const SQChar * text, uint32_t base)
|
|
||||||
: m_Data(0), m_Text()
|
|
||||||
{
|
|
||||||
m_Data = std::strtoll(text, nullptr, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
LongInt< signed long long > & LongInt< signed long long >::operator = (const SQChar * text)
|
|
||||||
{
|
|
||||||
m_Data = std::strtoll(text, nullptr, 10);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
const SQChar * LongInt< signed long long >::ToString()
|
|
||||||
{
|
|
||||||
if (std::snprintf(m_Text, sizeof(m_Text), "%llu", m_Data) < 0)
|
|
||||||
{
|
|
||||||
m_Text[0] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_Text;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void LongInt< signed long long >::Random()
|
|
||||||
{
|
|
||||||
m_Data = GetRandomInt64();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void LongInt< signed long long >::Random(Type n)
|
|
||||||
{
|
|
||||||
m_Data = GetRandomInt64(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void LongInt< signed long long >::Random(Type m, Type n)
|
|
||||||
{
|
|
||||||
m_Data = GetRandomInt64(m, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
LongInt< unsigned long long >::LongInt(const SQChar * text)
|
|
||||||
: m_Data(0), m_Text()
|
|
||||||
{
|
|
||||||
m_Data = std::strtoull(text, nullptr, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
LongInt< unsigned long long >::LongInt(const SQChar * text, uint32_t base)
|
|
||||||
: m_Data(0), m_Text()
|
|
||||||
{
|
|
||||||
m_Data = std::strtoull(text, nullptr, base);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
LongInt< unsigned long long > & LongInt< unsigned long long >::operator = (const SQChar * text)
|
|
||||||
{
|
|
||||||
m_Data = std::strtoull(text, nullptr, 10);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
const SQChar * LongInt< unsigned long long >::ToString()
|
|
||||||
{
|
|
||||||
if (std::snprintf(m_Text, sizeof(m_Text), "%llu", m_Data) < 0)
|
|
||||||
{
|
|
||||||
m_Text[0] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_Text;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void LongInt< unsigned long long >::Random()
|
|
||||||
{
|
|
||||||
m_Data = GetRandomUint64();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void LongInt< unsigned long long >::Random(Type n)
|
|
||||||
{
|
|
||||||
m_Data = GetRandomUint64(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
void LongInt< unsigned long long >::Random(Type m, Type n)
|
|
||||||
{
|
|
||||||
m_Data = GetRandomUint64(m, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
signed long long 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< signed long long >(val);
|
|
||||||
}
|
|
||||||
case OT_FLOAT:
|
|
||||||
{
|
|
||||||
SQFloat val;
|
|
||||||
sq_getfloat(vm, idx, &val);
|
|
||||||
return ConvTo< signed long long >::From(val);
|
|
||||||
}
|
|
||||||
case OT_BOOL:
|
|
||||||
{
|
|
||||||
SQBool val;
|
|
||||||
sq_getbool(vm, idx, &val);
|
|
||||||
return static_cast< signed long long >(val);
|
|
||||||
}
|
|
||||||
case OT_STRING:
|
|
||||||
{
|
|
||||||
const SQChar * 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< signed long long >(sq_getsize(vm, idx));
|
|
||||||
}
|
|
||||||
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< signed long long >::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< signed long long >(sq_getsize(vm, idx));
|
|
||||||
}
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
// Default to 0
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
unsigned long long 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< unsigned long long >::From(val);
|
|
||||||
}
|
|
||||||
case OT_FLOAT:
|
|
||||||
{
|
|
||||||
SQFloat val;
|
|
||||||
sq_getfloat(vm, idx, &val);
|
|
||||||
return ConvTo< unsigned long long >::From(val);
|
|
||||||
}
|
|
||||||
case OT_BOOL:
|
|
||||||
{
|
|
||||||
SQBool val;
|
|
||||||
sq_getbool(vm, idx, &val);
|
|
||||||
return ConvTo< unsigned long long >::From(val);
|
|
||||||
}
|
|
||||||
case OT_STRING:
|
|
||||||
{
|
|
||||||
const SQChar * 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< unsigned long long >::From(sq_getsize(vm, idx));
|
|
||||||
}
|
|
||||||
case OT_INSTANCE:
|
|
||||||
{
|
|
||||||
// Attempt to treat the value as a signed long instance
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return ConvTo< unsigned long long >::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< unsigned long long >::From(sq_getsize(vm, idx));
|
|
||||||
}
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
// Default to 0
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
const SLongInt & GetSLongInt()
|
|
||||||
{
|
|
||||||
static SLongInt l;
|
|
||||||
l.SetNum(0);
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
const SLongInt & GetSLongInt(signed long long n)
|
|
||||||
{
|
|
||||||
static SLongInt l;
|
|
||||||
l.SetNum(n);
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
const SLongInt & GetSLongInt(const SQChar * s)
|
|
||||||
{
|
|
||||||
static SLongInt l;
|
|
||||||
l = s;
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ULongInt & GetULongInt()
|
|
||||||
{
|
|
||||||
static ULongInt l;
|
|
||||||
l.SetNum(0);
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ULongInt & GetULongInt(unsigned long long n)
|
|
||||||
{
|
|
||||||
static ULongInt l;
|
|
||||||
l.SetNum(n);
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ULongInt & GetULongInt(const SQChar * s)
|
|
||||||
{
|
|
||||||
static ULongInt l;
|
|
||||||
l = s;
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ================================================================================================
|
|
||||||
void Register_LongInt(HSQUIRRELVM vm)
|
|
||||||
{
|
|
||||||
RootTable(vm).Bind(TypenameS::Str,
|
|
||||||
Class< SLongInt >(vm, TypenameS::Str)
|
|
||||||
// Constructors
|
|
||||||
.Ctor()
|
|
||||||
.Ctor< SLongInt::Type >()
|
|
||||||
.template Ctor< const char *, SQInteger >()
|
|
||||||
// Properties
|
|
||||||
.Prop(_SC("Str"), &SLongInt::GetCStr, &SLongInt::SetStr)
|
|
||||||
.Prop(_SC("Num"), &SLongInt::GetSNum, &SLongInt::SetNum)
|
|
||||||
// Core Meta-methods
|
|
||||||
.SquirrelFunc(_SC("cmp"), &SqDynArgFwd< SqDynArgCmpFn< SLongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, SLongInt, ULongInt >)
|
|
||||||
.SquirrelFunc(_SC("_typename"), &TypenameS::Fn)
|
|
||||||
.Func(_SC("_tostring"), &SLongInt::ToString)
|
|
||||||
// Core Functions
|
|
||||||
.Func(_SC("tointeger"), &SLongInt::ToSqInteger)
|
|
||||||
.Func(_SC("tofloat"), &SLongInt::ToSqFloat)
|
|
||||||
.Func(_SC("tostring"), &SLongInt::ToSqString)
|
|
||||||
.Func(_SC("tobool"), &SLongInt::ToSqBool)
|
|
||||||
.Func(_SC("tochar"), &SLongInt::ToSqChar)
|
|
||||||
// Meta-methods
|
|
||||||
.SquirrelFunc(_SC("_add"), &SqDynArgFwd< SqDynArgAddFn< SLongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, SLongInt, ULongInt >)
|
|
||||||
.SquirrelFunc(_SC("_sub"), &SqDynArgFwd< SqDynArgSubFn< SLongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, SLongInt, ULongInt >)
|
|
||||||
.SquirrelFunc(_SC("_mul"), &SqDynArgFwd< SqDynArgMulFn< SLongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, SLongInt, ULongInt >)
|
|
||||||
.SquirrelFunc(_SC("_div"), &SqDynArgFwd< SqDynArgDivFn< SLongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, SLongInt, ULongInt >)
|
|
||||||
.SquirrelFunc(_SC("_modulo"), &SqDynArgFwd< SqDynArgModFn< SLongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, SLongInt, ULongInt >)
|
|
||||||
.Func< SLongInt (SLongInt::*)(void) const >(_SC("_unm"), &SLongInt::operator -)
|
|
||||||
// Functions
|
|
||||||
.Func(_SC("GetStr"), &SLongInt::GetCStr)
|
|
||||||
.Func(_SC("SetStr"), &SLongInt::SetStr)
|
|
||||||
.Func(_SC("GetNum"), &SLongInt::GetSNum)
|
|
||||||
.Func(_SC("SetNum"), &SLongInt::SetNum)
|
|
||||||
// Overloads
|
|
||||||
.Overload< void (SLongInt::*)(void) >(_SC("Random"), &SLongInt::Random)
|
|
||||||
.Overload< void (SLongInt::*)(SLongInt::Type) >(_SC("Random"), &SLongInt::Random)
|
|
||||||
.Overload< void (SLongInt::*)(SLongInt::Type, SLongInt::Type) >(_SC("Random"), &SLongInt::Random)
|
|
||||||
);
|
|
||||||
|
|
||||||
RootTable(vm).Bind(TypenameU::Str,
|
|
||||||
Class< ULongInt >(vm, TypenameU::Str)
|
|
||||||
// Constructors
|
|
||||||
.Ctor()
|
|
||||||
.Ctor< ULongInt::Type >()
|
|
||||||
.Ctor< const char *, SQInteger >()
|
|
||||||
// Properties
|
|
||||||
.Prop(_SC("Str"), &ULongInt::GetCStr, &ULongInt::SetStr)
|
|
||||||
.Prop(_SC("Num"), &ULongInt::GetSNum, &ULongInt::SetNum)
|
|
||||||
// Core Meta-methods
|
|
||||||
.SquirrelFunc(_SC("cmp"), &SqDynArgFwd< SqDynArgCmpFn< ULongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, ULongInt, SLongInt >)
|
|
||||||
.SquirrelFunc(_SC("_typename"), &TypenameU::Fn)
|
|
||||||
.Func(_SC("_tostring"), &ULongInt::ToString)
|
|
||||||
// Core Functions
|
|
||||||
.Func(_SC("tointeger"), &ULongInt::ToSqInteger)
|
|
||||||
.Func(_SC("tofloat"), &ULongInt::ToSqFloat)
|
|
||||||
.Func(_SC("tostring"), &ULongInt::ToSqString)
|
|
||||||
.Func(_SC("tobool"), &ULongInt::ToSqBool)
|
|
||||||
.Func(_SC("tochar"), &ULongInt::ToSqChar)
|
|
||||||
// Meta-methods
|
|
||||||
.SquirrelFunc(_SC("_add"), &SqDynArgFwd< SqDynArgAddFn< ULongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, ULongInt, SLongInt >)
|
|
||||||
.SquirrelFunc(_SC("_sub"), &SqDynArgFwd< SqDynArgSubFn< ULongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, ULongInt, SLongInt >)
|
|
||||||
.SquirrelFunc(_SC("_mul"), &SqDynArgFwd< SqDynArgMulFn< ULongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, ULongInt, SLongInt >)
|
|
||||||
.SquirrelFunc(_SC("_div"), &SqDynArgFwd< SqDynArgDivFn< ULongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, ULongInt, SLongInt >)
|
|
||||||
.SquirrelFunc(_SC("_modulo"), &SqDynArgFwd< SqDynArgModFn< ULongInt >, SQInteger, SQFloat, bool, std::nullptr_t, const SQChar *, ULongInt, SLongInt >)
|
|
||||||
.Func< ULongInt (ULongInt::*)(void) const >(_SC("_unm"), &ULongInt::operator -)
|
|
||||||
// Functions
|
|
||||||
.Func(_SC("GetStr"), &ULongInt::GetCStr)
|
|
||||||
.Func(_SC("SetStr"), &ULongInt::SetStr)
|
|
||||||
.Func(_SC("GetNum"), &ULongInt::GetSNum)
|
|
||||||
.Func(_SC("SetNum"), &ULongInt::SetNum)
|
|
||||||
// Overloads
|
|
||||||
.Overload< void (ULongInt::*)(void) >(_SC("Random"), &ULongInt::Random)
|
|
||||||
.Overload< void (ULongInt::*)(ULongInt::Type) >(_SC("Random"), &ULongInt::Random)
|
|
||||||
.Overload< void (ULongInt::*)(ULongInt::Type, ULongInt::Type) >(_SC("Random"), &ULongInt::Random)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,5 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Library/Numeric/Math.hpp"
|
#include "Library/Numeric/Math.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
@ -66,7 +65,7 @@ static SQInteger SqRemainder(HSQUIRRELVM vm)
|
|||||||
// Are we both arguments integers?
|
// Are we both arguments integers?
|
||||||
else if ((sq_gettype(vm, 2) == OT_INTEGER) && sq_gettype(vm, 3) == OT_INTEGER)
|
else if ((sq_gettype(vm, 2) == OT_INTEGER) && sq_gettype(vm, 3) == OT_INTEGER)
|
||||||
{ // NOLINT(bugprone-branch-clone)
|
{ // NOLINT(bugprone-branch-clone)
|
||||||
sq_pushinteger(vm, std::remainder(PopStackInteger(vm, 2), PopStackInteger(vm, 3)));
|
sq_pushinteger(vm, static_cast< SQInteger >(std::remainder(PopStackInteger(vm, 2), PopStackInteger(vm, 3))));
|
||||||
}
|
}
|
||||||
// Is the first argument float?
|
// Is the first argument float?
|
||||||
else if ((sq_gettype(vm, 2) == OT_FLOAT))
|
else if ((sq_gettype(vm, 2) == OT_FLOAT))
|
||||||
@ -76,7 +75,7 @@ static SQInteger SqRemainder(HSQUIRRELVM vm)
|
|||||||
// Is the first argument integer?
|
// Is the first argument integer?
|
||||||
else if ((sq_gettype(vm, 2) == OT_INTEGER))
|
else if ((sq_gettype(vm, 2) == OT_INTEGER))
|
||||||
{
|
{
|
||||||
sq_pushinteger(vm, std::remainder(PopStackInteger(vm, 2), PopStackInteger(vm, 3)));
|
sq_pushinteger(vm, static_cast< SQInteger >(std::remainder(PopStackInteger(vm, 2), PopStackInteger(vm, 3))));
|
||||||
}
|
}
|
||||||
// Default to both arguments as float so we don't loos precision from the float one
|
// Default to both arguments as float so we don't loos precision from the float one
|
||||||
else
|
else
|
||||||
@ -184,18 +183,7 @@ static SQInteger SqNanL(HSQUIRRELVM vm)
|
|||||||
return val.mRes; // Propagate the error!
|
return val.mRes; // Propagate the error!
|
||||||
}
|
}
|
||||||
// Fetch the arguments from the stack and perform the requested operation
|
// Fetch the arguments from the stack and perform the requested operation
|
||||||
try
|
sq_pushinteger(vm, static_cast< SQInteger >(std::nanl(val.mPtr)));
|
||||||
{
|
|
||||||
Var< SLongInt * >::push(vm, new SLongInt(std::nanl(val.mPtr)));
|
|
||||||
}
|
|
||||||
catch (const std::exception & e)
|
|
||||||
{
|
|
||||||
return sq_throwerror(vm, e.what());
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
return sq_throwerror(vm, _SC("Failed to create a long integer instance"));
|
|
||||||
}
|
|
||||||
// Specify that we have a value on the stack
|
// Specify that we have a value on the stack
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -659,11 +647,11 @@ static SQInteger SqRoundI(HSQUIRRELVM vm)
|
|||||||
// Fetch the arguments from the stack and perform the requested operation
|
// Fetch the arguments from the stack and perform the requested operation
|
||||||
if (sq_gettype(vm, 2) == OT_FLOAT)
|
if (sq_gettype(vm, 2) == OT_FLOAT)
|
||||||
{
|
{
|
||||||
sq_pushinteger(vm, ConvTo< SQInteger >::From(std::llround(PopStackFloat(vm, 2))));
|
sq_pushinteger(vm, static_cast< SQInteger >(std::llround(PopStackFloat(vm, 2))));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sq_pushinteger(vm, ConvTo< SQInteger >::From(std::llround(PopStackInteger(vm, 2))));
|
sq_pushinteger(vm, static_cast< SQInteger >(std::llround(PopStackInteger(vm, 2))));
|
||||||
}
|
}
|
||||||
// Specify that we have a value on the stack
|
// Specify that we have a value on the stack
|
||||||
return 1;
|
return 1;
|
||||||
@ -678,24 +666,13 @@ static SQInteger SqRoundL(HSQUIRRELVM vm)
|
|||||||
return sq_throwerror(vm, "Wrong number of arguments");
|
return sq_throwerror(vm, "Wrong number of arguments");
|
||||||
}
|
}
|
||||||
// Fetch the arguments from the stack and perform the requested operation
|
// Fetch the arguments from the stack and perform the requested operation
|
||||||
try
|
if (sq_gettype(vm, 2) == OT_FLOAT)
|
||||||
{
|
{
|
||||||
if (sq_gettype(vm, 2) == OT_FLOAT)
|
sq_pushinteger(vm, static_cast< SQInteger >(std::llround(PopStackFloat(vm, 2))));
|
||||||
{
|
|
||||||
Var< SLongInt * >::push(vm, new SLongInt(std::llround(PopStackFloat(vm, 2))));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Var< SLongInt * >::push(vm, new SLongInt(std::llround(PopStackInteger(vm, 2))));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (const std::exception & e)
|
else
|
||||||
{
|
{
|
||||||
return sq_throwerror(vm, e.what());
|
sq_pushinteger(vm, static_cast< SQInteger >(std::llround(PopStackInteger(vm, 2))));
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
return sq_throwerror(vm, _SC("Failed to create a long integer instance"));
|
|
||||||
}
|
}
|
||||||
// Specify that we have a value on the stack
|
// Specify that we have a value on the stack
|
||||||
return 1;
|
return 1;
|
||||||
@ -760,7 +737,7 @@ static SQInteger SqLdexp(HSQUIRRELVM vm)
|
|||||||
return sq_throwerror(vm, "Wrong number of arguments");
|
return sq_throwerror(vm, "Wrong number of arguments");
|
||||||
}
|
}
|
||||||
// Fetch the arguments from the stack and perform the requested operation
|
// Fetch the arguments from the stack and perform the requested operation
|
||||||
sq_pushfloat(vm, std::ldexp(PopStackFloat(vm, 2), PopStackInteger(vm, 3)));
|
sq_pushfloat(vm, std::ldexp(PopStackFloat(vm, 2), static_cast< int >(PopStackInteger(vm, 3))));
|
||||||
// Specify that we have a value on the stack
|
// Specify that we have a value on the stack
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -811,9 +788,9 @@ static SQInteger SqScalbn(HSQUIRRELVM vm)
|
|||||||
}
|
}
|
||||||
// Fetch the arguments from the stack and perform the requested operation
|
// Fetch the arguments from the stack and perform the requested operation
|
||||||
#ifdef _SQ64
|
#ifdef _SQ64
|
||||||
sq_pushfloat(vm, std::scalbln(PopStackFloat(vm, 2), PopStackInteger(vm, 3)));
|
sq_pushfloat(vm, std::scalbln(PopStackFloat(vm, 2), static_cast< int >(PopStackInteger(vm, 3))));
|
||||||
#else
|
#else
|
||||||
sq_pushfloat(vm, std::scalbn(PopStackFloat(vm, 2), PopStackInteger(vm, 3)));
|
sq_pushfloat(vm, std::scalbn(PopStackFloat(vm, 2), static_cast< int >(PopStackInteger(vm, 3))));
|
||||||
#endif // _SQ64
|
#endif // _SQ64
|
||||||
// Specify that we have a value on the stack
|
// Specify that we have a value on the stack
|
||||||
return 1;
|
return 1;
|
||||||
@ -1066,7 +1043,7 @@ static SQInteger SqDigits1(HSQUIRRELVM vm)
|
|||||||
return sq_throwerror(vm, "Wrong number of arguments");
|
return sq_throwerror(vm, "Wrong number of arguments");
|
||||||
}
|
}
|
||||||
// Fetch the integer value from the stack
|
// Fetch the integer value from the stack
|
||||||
int64_t n = std::llabs(PopStackSLong(vm, 2));
|
int64_t n = std::llabs(PopStackInteger(vm, 2));
|
||||||
// Start with 0 digits
|
// Start with 0 digits
|
||||||
uint8_t d = 0;
|
uint8_t d = 0;
|
||||||
// Identify the number of digits
|
// Identify the number of digits
|
||||||
@ -1090,7 +1067,7 @@ static SQInteger SqDigits0(HSQUIRRELVM vm)
|
|||||||
return sq_throwerror(vm, "Wrong number of arguments");
|
return sq_throwerror(vm, "Wrong number of arguments");
|
||||||
}
|
}
|
||||||
// Fetch the integer value from the stack
|
// Fetch the integer value from the stack
|
||||||
int64_t n = std::llabs(PopStackSLong(vm, 2));
|
int64_t n = std::llabs(PopStackInteger(vm, 2));
|
||||||
// Start with 0 digits
|
// Start with 0 digits
|
||||||
uint8_t d = 0;
|
uint8_t d = 0;
|
||||||
// Identify the number of digits
|
// Identify the number of digits
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Core/Common.hpp"
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
@ -424,21 +424,21 @@ int32_t ReleaseMemory(int32_t bytes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Object GetMemoryUsage()
|
SQInteger GetMemoryUsage()
|
||||||
{
|
{
|
||||||
// Obtain the initial stack size
|
// Obtain the initial stack size
|
||||||
const StackGuard sg;
|
const StackGuard sg;
|
||||||
// Push a long integer instance with the requested value on the stack
|
// Push a long integer instance with the requested value on the stack
|
||||||
return Object(new SLongInt(sqlite3_memory_used()));
|
return sqlite3_memory_used();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Object GetMemoryHighwaterMark(bool reset)
|
SQInteger GetMemoryHighwaterMark(bool reset)
|
||||||
{
|
{
|
||||||
// Obtain the initial stack size
|
// Obtain the initial stack size
|
||||||
const StackGuard sg;
|
const StackGuard sg;
|
||||||
// Push a long integer instance with the requested value on the stack
|
// Push a long integer instance with the requested value on the stack
|
||||||
return Object(new SLongInt(sqlite3_memory_highwater(reset)));
|
return sqlite3_memory_highwater(reset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -1585,11 +1585,11 @@ void SQLiteParameter::SetUint32(SQInteger value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SQLiteParameter::SetInt64(const Object & value)
|
void SQLiteParameter::SetInt64(SQInteger value)
|
||||||
{
|
{
|
||||||
SQMOD_VALIDATE_CREATED(*this);
|
SQMOD_VALIDATE_CREATED(*this);
|
||||||
// Attempt to bind the specified value
|
// Attempt to bind the specified value
|
||||||
m_Handle->mStatus = sqlite3_bind_int64(m_Handle->mPtr, m_Index, value.Cast< const SLongInt & >().GetNum());
|
m_Handle->mStatus = sqlite3_bind_int64(m_Handle->mPtr, m_Index, value);
|
||||||
// Validate the result
|
// Validate the result
|
||||||
if (m_Handle->mStatus != SQLITE_OK)
|
if (m_Handle->mStatus != SQLITE_OK)
|
||||||
{
|
{
|
||||||
@ -1598,11 +1598,11 @@ void SQLiteParameter::SetInt64(const Object & value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SQLiteParameter::SetUint64(const Object & value)
|
void SQLiteParameter::SetUint64(SQInteger value)
|
||||||
{
|
{
|
||||||
SQMOD_VALIDATE_CREATED(*this);
|
SQMOD_VALIDATE_CREATED(*this);
|
||||||
// Attempt to bind the specified value
|
// Attempt to bind the specified value
|
||||||
m_Handle->mStatus = sqlite3_bind_int64(m_Handle->mPtr, m_Index, value.Cast< const ULongInt & >().GetNum());
|
m_Handle->mStatus = sqlite3_bind_int64(m_Handle->mPtr, m_Index, value);
|
||||||
// Validate the result
|
// Validate the result
|
||||||
if (m_Handle->mStatus != SQLITE_OK)
|
if (m_Handle->mStatus != SQLITE_OK)
|
||||||
{
|
{
|
||||||
@ -2315,11 +2315,11 @@ SQFloat SQLiteColumn::GetFloat() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Object SQLiteColumn::GetLong() const
|
SQInteger SQLiteColumn::GetLong() const
|
||||||
{
|
{
|
||||||
SQMOD_VALIDATE_ROW(*this);
|
SQMOD_VALIDATE_ROW(*this);
|
||||||
// Return the requested information
|
// Return the requested information
|
||||||
return Object(new SLongInt(sqlite3_column_int64(m_Handle->mPtr, m_Index)));
|
return sqlite3_column_int64(m_Handle->mPtr, m_Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Library/IO/Buffer.hpp"
|
#include "Library/IO/Buffer.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
#include "Library/Chrono/Date.hpp"
|
#include "Library/Chrono/Date.hpp"
|
||||||
#include "Library/Chrono/Datetime.hpp"
|
#include "Library/Chrono/Datetime.hpp"
|
||||||
#include "Library/Chrono/Time.hpp"
|
#include "Library/Chrono/Time.hpp"
|
||||||
@ -95,12 +94,12 @@ Object GetStatementObj(const StmtRef & stmt);
|
|||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Tests if a certain query string is empty.
|
* Tests if a certain query string is empty.
|
||||||
*/
|
*/
|
||||||
bool IsQueryEmpty(const SQChar * str);
|
SQMOD_NODISCARD bool IsQueryEmpty(const SQChar * str);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the string representation of a certain status code.
|
* Retrieve the string representation of a certain status code.
|
||||||
*/
|
*/
|
||||||
const SQChar * GetErrStr(int32_t status);
|
SQMOD_NODISCARD const SQChar * GetErrStr(int32_t status);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Set a specific heap limit.
|
* Set a specific heap limit.
|
||||||
@ -115,32 +114,32 @@ int32_t ReleaseMemory(int32_t bytes);
|
|||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the current memory usage.
|
* Retrieve the current memory usage.
|
||||||
*/
|
*/
|
||||||
Object GetMemoryUsage();
|
SQMOD_NODISCARD SQInteger GetMemoryUsage();
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the memory high watermark.
|
* Retrieve the memory high watermark.
|
||||||
*/
|
*/
|
||||||
Object GetMemoryHighwaterMark(bool reset);
|
SQMOD_NODISCARD SQInteger GetMemoryHighwaterMark(bool reset);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the escaped version of the specified string.
|
* Retrieve the escaped version of the specified string.
|
||||||
*/
|
*/
|
||||||
LightObj EscapeString(StackStrF & str);
|
SQMOD_NODISCARD LightObj EscapeString(StackStrF & str);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the escaped version of the specified string using the supplied format specifier.
|
* Retrieve the escaped version of the specified string using the supplied format specifier.
|
||||||
*/
|
*/
|
||||||
LightObj EscapeStringEx(SQChar spec, StackStrF & str);
|
SQMOD_NODISCARD LightObj EscapeStringEx(SQChar spec, StackStrF & str);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Convert the values from the specified array to a list of column names string.
|
* Convert the values from the specified array to a list of column names string.
|
||||||
*/
|
*/
|
||||||
LightObj ArrayToQueryColumns(Array & arr);
|
SQMOD_NODISCARD LightObj ArrayToQueryColumns(Array & arr);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Convert the keys from the specified array to a list of column names string.
|
* Convert the keys from the specified array to a list of column names string.
|
||||||
*/
|
*/
|
||||||
LightObj TableToQueryColumns(Table & tbl);
|
SQMOD_NODISCARD LightObj TableToQueryColumns(Table & tbl);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* The structure that holds the data associated with a certain connection.
|
* The structure that holds the data associated with a certain connection.
|
||||||
@ -701,9 +700,9 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Get the row-id of the most recent successful INSERT into the database from the current connection.
|
* Get the row-id of the most recent successful INSERT into the database from the current connection.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Object GetLastInsertRowID() const
|
SQMOD_NODISCARD SQInteger GetLastInsertRowID() const
|
||||||
{
|
{
|
||||||
return Object(new SLongInt(sqlite3_last_insert_rowid(SQMOD_GET_CREATED(*this)->mPtr)));
|
return sqlite3_last_insert_rowid(SQMOD_GET_CREATED(*this)->mPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
@ -1148,12 +1147,12 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Attempt to bind a signed 64 bit integer value at the referenced parameter index.
|
* Attempt to bind a signed 64 bit integer value at the referenced parameter index.
|
||||||
*/
|
*/
|
||||||
void SetInt64(const Object & value);
|
void SetInt64(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Attempt to bind an unsigned 64 bit integer value at the referenced parameter index.
|
* Attempt to bind an unsigned 64 bit integer value at the referenced parameter index.
|
||||||
*/
|
*/
|
||||||
void SetUint64(const Object & value);
|
void SetUint64(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Attempt to bind a native floating point value at the referenced parameter index.
|
* Attempt to bind a native floating point value at the referenced parameter index.
|
||||||
@ -1538,7 +1537,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value inside the referenced column as a long integer.
|
* Retrieve the value inside the referenced column as a long integer.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD Object GetLong() const;
|
SQMOD_NODISCARD SQInteger GetLong() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value inside the referenced column as a string.
|
* Retrieve the value inside the referenced column as a string.
|
||||||
@ -2101,7 +2100,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Attempt to bind a signed 64 bit integer value at the specified parameter index.
|
* Attempt to bind a signed 64 bit integer value at the specified parameter index.
|
||||||
*/
|
*/
|
||||||
SQLiteStatement & SetInt64(const Object & param, const Object & value)
|
SQLiteStatement & SetInt64(const Object & param, SQInteger value)
|
||||||
{
|
{
|
||||||
SQLiteParameter(SQMOD_GET_CREATED(*this), param).SetInt64(value);
|
SQLiteParameter(SQMOD_GET_CREATED(*this), param).SetInt64(value);
|
||||||
// Allow chaining of operations
|
// Allow chaining of operations
|
||||||
@ -2111,7 +2110,7 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Attempt to bind an unsigned 64 bit integer value at the specified parameter index.
|
* Attempt to bind an unsigned 64 bit integer value at the specified parameter index.
|
||||||
*/
|
*/
|
||||||
SQLiteStatement & SetUint64(const Object & param, const Object & value)
|
SQLiteStatement & SetUint64(const Object & param, SQInteger value)
|
||||||
{
|
{
|
||||||
SQLiteParameter(SQMOD_GET_CREATED(*this), param).SetUint64(value);
|
SQLiteParameter(SQMOD_GET_CREATED(*this), param).SetUint64(value);
|
||||||
// Allow chaining of operations
|
// Allow chaining of operations
|
||||||
|
@ -108,99 +108,99 @@ bool XmlNode::RemoveAttrInst(const XmlAttribute & attr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj XmlAttribute::AsLong(const SLongInt & def) const
|
SQInteger XmlAttribute::AsLong(SQInteger def) const
|
||||||
{
|
{
|
||||||
return LightObj(SqTypeIdentity< SLongInt >{}, SqVM(), m_Attr.as_llong(def.GetNum()));
|
return m_Attr.as_llong(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj XmlAttribute::AsUlong(const ULongInt & def) const
|
SQInteger XmlAttribute::AsUlong(SQInteger def) const
|
||||||
{
|
{
|
||||||
return LightObj(SqTypeIdentity< ULongInt >{}, SqVM(), m_Attr.as_ullong(def.GetNum()));
|
return static_cast< SQInteger >(m_Attr.as_ullong(static_cast< uint64_t >(def)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool XmlAttribute::ApplyLong(const SLongInt & value)
|
bool XmlAttribute::ApplyLong(SQInteger value)
|
||||||
{
|
{
|
||||||
return m_Attr.set_value(value.GetNum());
|
return m_Attr.set_value(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool XmlAttribute::ApplyUlong(const ULongInt & value)
|
bool XmlAttribute::ApplyUlong(SQInteger value)
|
||||||
{
|
{
|
||||||
return m_Attr.set_value(value.GetNum());
|
return m_Attr.set_value(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj XmlAttribute::GetLong() const
|
SQInteger XmlAttribute::GetLong() const
|
||||||
{
|
{
|
||||||
return LightObj(SqTypeIdentity< SLongInt >{}, SqVM(), m_Attr.as_llong());
|
return m_Attr.as_llong();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void XmlAttribute::SetLong(const SLongInt & value)
|
void XmlAttribute::SetLong(SQInteger value)
|
||||||
{
|
{
|
||||||
m_Attr = value.GetNum();
|
m_Attr = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj XmlAttribute::GetUlong() const
|
SQInteger XmlAttribute::GetUlong() const
|
||||||
{
|
{
|
||||||
return LightObj(SqTypeIdentity< ULongInt >{}, SqVM(), m_Attr.as_ullong());
|
return static_cast< SQInteger >(m_Attr.as_ullong());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void XmlAttribute::SetUlong(const ULongInt & value)
|
void XmlAttribute::SetUlong(SQInteger value)
|
||||||
{
|
{
|
||||||
m_Attr = value.GetNum();
|
m_Attr = static_cast< uint64_t >(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj XmlText::AsLong(const SLongInt & def) const
|
SQInteger XmlText::AsLong(SQInteger def) const
|
||||||
{
|
{
|
||||||
return LightObj(SqTypeIdentity< SLongInt >{}, SqVM(), m_Text.as_llong(def.GetNum()));
|
return m_Text.as_llong(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj XmlText::AsUlong(const ULongInt & def) const
|
SQInteger XmlText::AsUlong(SQInteger def) const
|
||||||
{
|
{
|
||||||
return LightObj(SqTypeIdentity< ULongInt >{}, SqVM(), m_Text.as_ullong(def.GetNum()));
|
return static_cast< SQInteger >(m_Text.as_ullong(static_cast< uint64_t >(def)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool XmlText::ApplyLong(const SLongInt & value)
|
bool XmlText::ApplyLong(SQInteger value)
|
||||||
{
|
{
|
||||||
return m_Text.set(value.GetNum());
|
return m_Text.set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
bool XmlText::ApplyUlong(const ULongInt & value)
|
bool XmlText::ApplyUlong(SQInteger value)
|
||||||
{
|
{
|
||||||
return m_Text.set(value.GetNum());
|
return m_Text.set(static_cast< uint64_t >(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj XmlText::GetLong() const
|
SQInteger XmlText::GetLong() const
|
||||||
{
|
{
|
||||||
return LightObj(SqTypeIdentity< SLongInt >{}, SqVM(), m_Text.as_llong());
|
return m_Text.as_llong();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void XmlText::SetLong(const SLongInt & value)
|
void XmlText::SetLong(SQInteger value)
|
||||||
{
|
{
|
||||||
m_Text = value.GetNum();
|
m_Text = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
LightObj XmlText::GetUlong() const
|
SQInteger XmlText::GetUlong() const
|
||||||
{
|
{
|
||||||
return LightObj(SqTypeIdentity< SLongInt >{}, SqVM(), m_Text.as_ullong());
|
return static_cast< SQInteger >(m_Text.as_ullong());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void XmlText::SetUlong(const ULongInt & value)
|
void XmlText::SetUlong(SQInteger value)
|
||||||
{
|
{
|
||||||
m_Text = value.GetNum();
|
m_Text = static_cast< uint64_t >(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
@ -3,9 +3,6 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Core/Utility.hpp"
|
#include "Core/Utility.hpp"
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -1420,12 +1417,12 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a long integer or the specified default value if empty.
|
* Retrieve the value as a long integer or the specified default value if empty.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj AsLong(const SLongInt & def) const;
|
SQMOD_NODISCARD SQInteger AsLong(SQInteger def) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a unsigned long integer or the specified default value if empty.
|
* Retrieve the value as a unsigned long integer or the specified default value if empty.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj AsUlong(const ULongInt & def) const;
|
SQMOD_NODISCARD SQInteger AsUlong(SQInteger def) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a boolean or the specified default value if empty.
|
* Retrieve the value as a boolean or the specified default value if empty.
|
||||||
@ -1478,12 +1475,12 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a long integer.
|
* Modify the value as a long integer.
|
||||||
*/
|
*/
|
||||||
bool ApplyLong(const SLongInt & value);
|
bool ApplyLong(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a unsigned long integer.
|
* Modify the value as a unsigned long integer.
|
||||||
*/
|
*/
|
||||||
bool ApplyUlong(const ULongInt & value);
|
bool ApplyUlong(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a boolean.
|
* Modify the value as a boolean.
|
||||||
@ -1576,22 +1573,22 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a long integer.
|
* Retrieve the value as a long integer.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj GetLong() const;
|
SQMOD_NODISCARD SQInteger GetLong() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a long integer.
|
* Modify the value as a long integer.
|
||||||
*/
|
*/
|
||||||
void SetLong(const SLongInt & value);
|
void SetLong(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a unsigned long integer.
|
* Retrieve the value as a unsigned long integer.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj GetUlong() const;
|
SQMOD_NODISCARD SQInteger GetUlong() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a unsigned long integer.
|
* Modify the value as a unsigned long integer.
|
||||||
*/
|
*/
|
||||||
void SetUlong(const ULongInt & value);
|
void SetUlong(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a boolean.
|
* Retrieve the value as a boolean.
|
||||||
@ -1772,12 +1769,12 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a long integer or the specified default value if empty.
|
* Retrieve the value as a long integer or the specified default value if empty.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj AsLong(const SLongInt & def) const;
|
SQMOD_NODISCARD SQInteger AsLong(SQInteger def) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a unsigned long integer or the specified default value if empty.
|
* Retrieve the value as a unsigned long integer or the specified default value if empty.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj AsUlong(const ULongInt & def) const;
|
SQMOD_NODISCARD SQInteger AsUlong(SQInteger def) const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a boolean or the specified default value if empty.
|
* Retrieve the value as a boolean or the specified default value if empty.
|
||||||
@ -1830,12 +1827,12 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a long integer.
|
* Modify the value as a long integer.
|
||||||
*/
|
*/
|
||||||
bool ApplyLong(const SLongInt & value);
|
bool ApplyLong(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a unsigned long integer.
|
* Modify the value as a unsigned long integer.
|
||||||
*/
|
*/
|
||||||
bool ApplyUlong(const ULongInt & value);
|
bool ApplyUlong(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a boolean.
|
* Modify the value as a boolean.
|
||||||
@ -1928,22 +1925,22 @@ public:
|
|||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a long integer.
|
* Retrieve the value as a long integer.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj GetLong() const;
|
SQMOD_NODISCARD SQInteger GetLong() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a long integer.
|
* Modify the value as a long integer.
|
||||||
*/
|
*/
|
||||||
void SetLong(const SLongInt & value);
|
void SetLong(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a unsigned long integer.
|
* Retrieve the value as a unsigned long integer.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD LightObj GetUlong() const;
|
SQMOD_NODISCARD SQInteger GetUlong() const;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Modify the value as a unsigned long integer.
|
* Modify the value as a unsigned long integer.
|
||||||
*/
|
*/
|
||||||
void SetUlong(const ULongInt & value);
|
void SetUlong(SQInteger value);
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the value as a boolean.
|
* Retrieve the value as a boolean.
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include "Base/Color3.hpp"
|
#include "Base/Color3.hpp"
|
||||||
#include "Base/Vector2.hpp"
|
#include "Base/Vector2.hpp"
|
||||||
#include "Entity/Player.hpp"
|
#include "Entity/Player.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
@ -173,9 +172,9 @@ void SendPluginCommand(uint32_t identifier, StackStrF & payload)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
const ULongInt & GetTime()
|
SQInteger GetTime()
|
||||||
{
|
{
|
||||||
return GetULongInt(_Func->GetTime());
|
return static_cast< SQInteger >(_Func->GetTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
@ -218,7 +217,7 @@ const SQChar * GetPluginAuthor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int32_t GetPluginID()
|
uint32_t GetPluginID()
|
||||||
{
|
{
|
||||||
return _Info->pluginId;
|
return _Info->pluginId;
|
||||||
}
|
}
|
||||||
@ -242,7 +241,7 @@ uint32_t GetServerFlags()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int32_t GetMaxPlayers()
|
uint32_t GetMaxPlayers()
|
||||||
{
|
{
|
||||||
return _Func->GetMaxPlayers();
|
return _Func->GetMaxPlayers();
|
||||||
}
|
}
|
||||||
@ -468,7 +467,7 @@ int32_t GetTimeRate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void SetTimeRate(uint32_t rate)
|
void SetTimeRate(int32_t rate)
|
||||||
{
|
{
|
||||||
_Func->SetTimeRate(rate);
|
_Func->SetTimeRate(rate);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ void SendPluginCommand(uint32_t identifier, StackStrF & payload);
|
|||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the server time.
|
* Retrieve the server time.
|
||||||
*/
|
*/
|
||||||
const ULongInt & GetTime();
|
SQInteger GetTime();
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Send a log message to the server.
|
* Send a log message to the server.
|
||||||
@ -84,7 +84,7 @@ SQMOD_NODISCARD const SQChar * GetPluginAuthor();
|
|||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the id of the host Squirrel plug-in.
|
* Retrieve the id of the host Squirrel plug-in.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD int32_t GetPluginID();
|
SQMOD_NODISCARD uint32_t GetPluginID();
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the port onto which the server was binded.
|
* Retrieve the port onto which the server was binded.
|
||||||
@ -99,7 +99,7 @@ SQMOD_NODISCARD uint32_t GetServerFlags();
|
|||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the maximum number of clients allowed on the server.
|
* Retrieve the maximum number of clients allowed on the server.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD int32_t GetMaxPlayers();
|
SQMOD_NODISCARD uint32_t GetMaxPlayers();
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Modify the maximum number of clients allowed on the server.
|
* Modify the maximum number of clients allowed on the server.
|
||||||
@ -205,7 +205,7 @@ SQMOD_NODISCARD int32_t GetTimeRate();
|
|||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Modify the current time-rate.
|
* Modify the current time-rate.
|
||||||
*/
|
*/
|
||||||
void SetTimeRate(uint32_t rate);
|
void SetTimeRate(int32_t rate);
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
* Retrieve the game hour.
|
* Retrieve the game hour.
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include "Base/Color3.hpp"
|
#include "Base/Color3.hpp"
|
||||||
#include "Base/Vector2.hpp"
|
#include "Base/Vector2.hpp"
|
||||||
#include "Entity/Player.hpp"
|
#include "Entity/Player.hpp"
|
||||||
#include "Library/Numeric/Long.hpp"
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
#include "Misc/Functions.hpp"
|
#include "Misc/Functions.hpp"
|
||||||
|
Loading…
Reference in New Issue
Block a user