mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Initial implementation of the standard math library.
Implemented utilities to convert between fundamental types. Implemented helper functions to retrieve numeric values from the stack at all costs. Implemented various delegates on the long integer types to mimic the standard types. Moved most of the stack utilities in a separate source. Various other fixes and improvements.
This commit is contained in:
parent
ea9f60e32c
commit
b818a162ee
@ -431,6 +431,8 @@
|
||||
<Unit filename="../source/Base/Shared.hpp" />
|
||||
<Unit filename="../source/Base/Sphere.cpp" />
|
||||
<Unit filename="../source/Base/Sphere.hpp" />
|
||||
<Unit filename="../source/Base/Stack.cpp" />
|
||||
<Unit filename="../source/Base/Stack.hpp" />
|
||||
<Unit filename="../source/Base/Vector2.cpp" />
|
||||
<Unit filename="../source/Base/Vector2.hpp" />
|
||||
<Unit filename="../source/Base/Vector2i.cpp" />
|
||||
|
@ -5,16 +5,7 @@
|
||||
#include "Library/String.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Base/AABB.hpp"
|
||||
#include "Base/Circle.hpp"
|
||||
#include "Base/Color3.hpp"
|
||||
#include "Base/Color4.hpp"
|
||||
#include "Base/Quaternion.hpp"
|
||||
#include "Base/Sphere.hpp"
|
||||
#include "Base/Vector2.hpp"
|
||||
#include "Base/Vector2i.hpp"
|
||||
#include "Base/Vector3.hpp"
|
||||
#include "Base/Vector4.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <ctime>
|
||||
@ -23,9 +14,6 @@
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <sqstdstring.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
@ -67,123 +55,6 @@ Function & NullFunction()
|
||||
return f;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object BufferToStrObj(const Buffer & b)
|
||||
{
|
||||
// Obtain the initial stack size
|
||||
const StackGuard sg(DefaultVM::Get());
|
||||
// Push the string onto the stack
|
||||
sq_pushstring(DefaultVM::Get(), b.Data(), b.Position());
|
||||
// Obtain the object from the stack and return it
|
||||
return Var< Object >(DefaultVM::Get(), -1).value;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
Object BufferToStrObj(const Buffer & b, Uint32 size)
|
||||
{
|
||||
// Perform a range check on the specified buffer
|
||||
if (size > b.Capacity())
|
||||
{
|
||||
STHROWF("The specified buffer size is out of range: %u >= %u", size, b.Capacity());
|
||||
}
|
||||
// Obtain the initial stack size
|
||||
const StackGuard sg(DefaultVM::Get());
|
||||
// Push the string onto the stack
|
||||
sq_pushstring(DefaultVM::Get(), b.Data(), size);
|
||||
// Obtain the object from the stack and return it
|
||||
return Var< Object >(DefaultVM::Get(), -1).value;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
StackStrF::StackStrF(HSQUIRRELVM vm, SQInteger idx, bool fmt)
|
||||
: mPtr(nullptr)
|
||||
, mLen(-1)
|
||||
, mRes(SQ_OK)
|
||||
, mObj()
|
||||
, mVM(vm)
|
||||
{
|
||||
const Int32 top = sq_gettop(vm);
|
||||
// Reset the converted value object
|
||||
sq_resetobject(&mObj);
|
||||
// Was the string or value specified?
|
||||
if (top <= (idx - 1))
|
||||
{
|
||||
mRes = sq_throwerror(vm, "Missing string or value");
|
||||
}
|
||||
// Do we have enough values to call the format function and are we allowed to?
|
||||
else if (top > idx && fmt)
|
||||
{
|
||||
// Pointer to the generated string
|
||||
SStr str = nullptr;
|
||||
// Attempt to generate the specified string format
|
||||
mRes = sqstd_format(vm, idx, &mLen, &str);
|
||||
// Did the format succeeded but ended up with a null string pointer?
|
||||
if (SQ_SUCCEEDED(mRes) && !str)
|
||||
{
|
||||
mRes = sq_throwerror(vm, "Unable to generate the string");
|
||||
}
|
||||
else
|
||||
{
|
||||
mPtr = const_cast< CSStr >(str);
|
||||
}
|
||||
}
|
||||
// Is the value on the stack an actual string?
|
||||
else if (sq_gettype(vm, idx) == OT_STRING)
|
||||
{
|
||||
// Obtain a reference to the string object
|
||||
mRes = sq_getstackobj(vm, idx, &mObj);
|
||||
// Could we retrieve the object from the stack?
|
||||
if (SQ_SUCCEEDED(mRes))
|
||||
{
|
||||
// Keep a strong reference to the object
|
||||
sq_addref(vm, &mObj);
|
||||
// Attempt to retrieve the string value from the stack
|
||||
mRes = sq_getstring(vm, idx, &mPtr);
|
||||
}
|
||||
// Did the retrieval succeeded but ended up with a null string pointer?
|
||||
if (SQ_SUCCEEDED(mRes) && !mPtr)
|
||||
{
|
||||
mRes = sq_throwerror(vm, "Unable to retrieve the string");
|
||||
}
|
||||
}
|
||||
// We have to try and convert it to string
|
||||
else
|
||||
{
|
||||
// Attempt to convert the value from the stack to a string
|
||||
mRes = sq_tostring(vm, idx);
|
||||
// Could we convert the specified value to string?
|
||||
if (SQ_SUCCEEDED(mRes))
|
||||
{
|
||||
// Obtain a reference to the resulted object
|
||||
mRes = sq_getstackobj(vm, -1, &mObj);
|
||||
// Could we retrieve the object from the stack?
|
||||
if (SQ_SUCCEEDED(mRes))
|
||||
{
|
||||
// Keep a strong reference to the object
|
||||
sq_addref(vm, &mObj);
|
||||
// Attempt to obtain the string pointer
|
||||
mRes = sq_getstring(vm, -1, &mPtr);
|
||||
}
|
||||
}
|
||||
// Pop a value from the stack regardless of the result
|
||||
sq_pop(vm, 1);
|
||||
// Did the retrieval succeeded but ended up with a null string pointer?
|
||||
if (SQ_SUCCEEDED(mRes) && !mPtr)
|
||||
{
|
||||
mRes = sq_throwerror(vm, "Unable to retrieve the value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
StackStrF::~StackStrF()
|
||||
{
|
||||
if (mVM && !sq_isnull(mObj))
|
||||
{
|
||||
sq_release(mVM, &mObj);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool SToB(CSStr str)
|
||||
{
|
||||
|
@ -25,107 +25,6 @@ extern PluginFuncs* _Func;
|
||||
extern PluginCallbacks* _Clbk;
|
||||
extern PluginInfo* _Info;
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Implements RAII to restore the VM stack to it's initial size on function exit.
|
||||
*/
|
||||
struct StackGuard
|
||||
{
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
StackGuard()
|
||||
: m_VM(DefaultVM::Get()), m_Top(sq_gettop(m_VM))
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Base constructor.
|
||||
*/
|
||||
StackGuard(HSQUIRRELVM vm)
|
||||
: m_VM(vm), m_Top(sq_gettop(vm))
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
StackGuard(const StackGuard &) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor. (disabled)
|
||||
*/
|
||||
StackGuard(StackGuard &&) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
~StackGuard()
|
||||
{
|
||||
sq_pop(m_VM, sq_gettop(m_VM) - m_Top);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator. (disabled)
|
||||
*/
|
||||
StackGuard & operator = (const StackGuard &) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator. (disabled)
|
||||
*/
|
||||
StackGuard & operator = (StackGuard &&) = delete;
|
||||
|
||||
private:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
HSQUIRRELVM m_VM; // The VM where the stack should be restored.
|
||||
Int32 m_Top; // The top of the stack when this instance was created.
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Helper structure for retrieving a value from the stack as a string or a formatted string.
|
||||
*/
|
||||
struct StackStrF
|
||||
{
|
||||
// --------------------------------------------------------------------------------------------
|
||||
CSStr mPtr; // Pointer to the C string that was retrieved.
|
||||
SQInteger mLen; // The string length if it could be retrieved.
|
||||
SQRESULT mRes; // The result of the retrieval attempts.
|
||||
HSQOBJECT mObj; // Strong reference to the string object.
|
||||
HSQUIRRELVM mVM; // The associated virtual machine.
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Base constructor.
|
||||
*/
|
||||
StackStrF(HSQUIRRELVM vm, SQInteger idx, bool fmt = true);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
StackStrF(const StackStrF & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
StackStrF(StackStrF && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
~StackStrF();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
StackStrF & operator = (const StackStrF & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
StackStrF & operator = (StackStrF && o) = delete;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Perform an equality comparison between two values taking into account floating point issues.
|
||||
*/
|
||||
@ -218,31 +117,549 @@ template <> inline bool EpsGtEq(const Float64 a, const Float64 b)
|
||||
return !EpsEq(a, b) || (a - b) > 0.000000001d;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
*
|
||||
*/
|
||||
template < typename T > struct ConvTo
|
||||
{
|
||||
// --------------------------------------------------------------------------------------------
|
||||
static constexpr T Min = std::numeric_limits< T >::min();
|
||||
static constexpr T Max = std::numeric_limits< T >::max();
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
template < typename U > static inline T From(U v)
|
||||
{
|
||||
if (v > Max)
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
else if (v < Min)
|
||||
{
|
||||
return Min;
|
||||
}
|
||||
return static_cast< T >(v);
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Int8 ConvTo< Int8 >::From< Uint8 >(Uint8 v)
|
||||
{
|
||||
return (v >= static_cast< Uint8 >(Max)) ? Max : static_cast< Int8 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Int8 ConvTo< Int8 >::From< Uint16 >(Uint16 v)
|
||||
{
|
||||
return (v >= static_cast< Uint16 >(Max)) ? Max : static_cast< Int8 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Int8 ConvTo< Int8 >::From< Uint32 >(Uint32 v)
|
||||
{
|
||||
return (v >= static_cast< Uint32 >(Max)) ? Max : static_cast< Int8 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Int8 ConvTo< Int8 >::From< Uint64 >(Uint64 v)
|
||||
{
|
||||
return (v >= static_cast< Uint64 >(Max)) ? Max : static_cast< Int8 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Int16 ConvTo< Int16 >::From< Uint8 >(Uint8 v)
|
||||
{
|
||||
return static_cast< Int16 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Int16 ConvTo< Int16 >::From< Uint16 >(Uint16 v)
|
||||
{
|
||||
return (v >= static_cast< Uint16 >(Max)) ? Max : static_cast< Int16 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Int16 ConvTo< Int16 >::From< Uint32 >(Uint32 v)
|
||||
{
|
||||
return (v >= static_cast< Uint32 >(Max)) ? Max : static_cast< Int16 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Int16 ConvTo< Int16 >::From< Uint64 >(Uint64 v)
|
||||
{
|
||||
return (v >= static_cast< Uint64 >(Max)) ? Max : static_cast< Int16 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Int32 ConvTo< Int32 >::From< Uint8 >(Uint8 v)
|
||||
{
|
||||
return static_cast< Int32 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Int32 ConvTo< Int32 >::From< Uint16 >(Uint16 v)
|
||||
{
|
||||
return static_cast< Int32 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Int32 ConvTo< Int32 >::From< Uint32 >(Uint32 v)
|
||||
{
|
||||
return (v >= static_cast< Uint32 >(Max)) ? Max : static_cast< Int32 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Int32 ConvTo< Int32 >::From< Uint64 >(Uint64 v)
|
||||
{
|
||||
return (v >= static_cast< Uint64 >(Max)) ? Max : static_cast< Int32 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Uint8 ConvTo< Uint8 >::From< Int8 >(Int8 v)
|
||||
{
|
||||
return (v <= 0) ? 0 : static_cast< Uint8 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Uint8 ConvTo< Uint8 >::From< Int16 >(Int16 v)
|
||||
{
|
||||
if (v <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (v >= static_cast< Int16 >(Max))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
return static_cast< Uint8 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Uint8 ConvTo< Uint8 >::From< Int32 >(Int32 v)
|
||||
{
|
||||
if (v <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (v >= static_cast< Int32 >(Max))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
return static_cast< Uint8 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Uint8 ConvTo< Uint8 >::From< Int64 >(Int64 v)
|
||||
{
|
||||
if (v <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (v >= static_cast< Int64 >(Max))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
return static_cast< Uint8 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Uint16 ConvTo< Uint16 >::From< Int8 >(Int8 v)
|
||||
{
|
||||
return (v <= 0) ? 0 : static_cast< Uint16 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Uint16 ConvTo< Uint16 >::From< Int16 >(Int16 v)
|
||||
{
|
||||
return (v <= 0) ? 0 : static_cast< Uint16 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Uint16 ConvTo< Uint16 >::From< Int32 >(Int32 v)
|
||||
{
|
||||
if (v <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (v >= static_cast< Int32 >(Max))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
return static_cast< Uint16 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Uint16 ConvTo< Uint16 >::From< Int64 >(Int64 v)
|
||||
{
|
||||
if (v <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (v >= static_cast< Int64 >(Max))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
return static_cast< Uint16 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Uint32 ConvTo< Uint32 >::From< Int8 >(Int8 v)
|
||||
{
|
||||
return (v <= 0) ? 0 : static_cast< Uint32 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Uint32 ConvTo< Uint32 >::From< Int16 >(Int16 v)
|
||||
{
|
||||
return (v <= 0) ? 0 : static_cast< Uint32 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Uint32 ConvTo< Uint32 >::From< Int32 >(Int32 v)
|
||||
{
|
||||
return (v <= 0) ? 0 : static_cast< Uint32 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Uint32 ConvTo< Uint32 >::From< Int64 >(Int64 v)
|
||||
{
|
||||
if (v <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else if (v >= static_cast< Int64 >(Max))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
return static_cast< Uint32 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Int8 ConvTo< Int8 >::From< Float32 >(Float32 v)
|
||||
{
|
||||
if (EpsLt(v, static_cast< Float32 >(Min)))
|
||||
{
|
||||
return Min;
|
||||
}
|
||||
else if (EpsGt(v, static_cast< Float32 >(Max)))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
return static_cast< Int8 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Int16 ConvTo< Int16 >::From< Float32 >(Float32 v)
|
||||
{
|
||||
if (EpsLt(v, static_cast< Float32 >(Min)))
|
||||
{
|
||||
return Min;
|
||||
}
|
||||
else if (EpsGt(v, static_cast< Float32 >(Max)))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
return static_cast< Int16 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Int32 ConvTo< Int32 >::From< Float32 >(Float32 v)
|
||||
{
|
||||
if (EpsLt(v, static_cast< Float32 >(Min)))
|
||||
{
|
||||
return Min;
|
||||
}
|
||||
else if (EpsGt(v, static_cast< Float32 >(Max)))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
return static_cast< Int32 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Int8 ConvTo< Int8 >::From< Float64 >(Float64 v)
|
||||
{
|
||||
if (EpsLt(v, static_cast< Float64 >(Min)))
|
||||
{
|
||||
return Min;
|
||||
}
|
||||
else if (EpsGt(v, static_cast< Float64 >(Max)))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
return static_cast< Int8 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Int16 ConvTo< Int16 >::From< Float64 >(Float64 v)
|
||||
{
|
||||
if (EpsLt(v, static_cast< Float64 >(Min)))
|
||||
{
|
||||
return Min;
|
||||
}
|
||||
else if (EpsGt(v, static_cast< Float64 >(Max)))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
return static_cast< Int16 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Int32 ConvTo< Int32 >::From< Float64 >(Float64 v)
|
||||
{
|
||||
if (EpsLt(v, static_cast< Float64 >(Min)))
|
||||
{
|
||||
return Min;
|
||||
}
|
||||
else if (EpsGt(v, static_cast< Float64 >(Max)))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
return static_cast< Int32 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Uint8 ConvTo< Uint8 >::From< Float32 >(Float32 v)
|
||||
{
|
||||
if (EpsLt(v, static_cast< Float32 >(Min)))
|
||||
{
|
||||
return Min;
|
||||
}
|
||||
else if (EpsGt(v, static_cast< Float32 >(Max)))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
return static_cast< Uint8 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Uint16 ConvTo< Uint16 >::From< Float32 >(Float32 v)
|
||||
{
|
||||
if (EpsLt(v, static_cast< Float32 >(Min)))
|
||||
{
|
||||
return Min;
|
||||
}
|
||||
else if (EpsGt(v, static_cast< Float32 >(Max)))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
return static_cast< Uint16 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Uint32 ConvTo< Uint32 >::From< Float32 >(Float32 v)
|
||||
{
|
||||
if (EpsLt(v, static_cast< Float32 >(Min)))
|
||||
{
|
||||
return Min;
|
||||
}
|
||||
else if (EpsGt(v, static_cast< Float32 >(Max)))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
return static_cast< Uint32 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Uint8 ConvTo< Uint8 >::From< Float64 >(Float64 v)
|
||||
{
|
||||
if (EpsLt(v, static_cast< Float64 >(Min)))
|
||||
{
|
||||
return Min;
|
||||
}
|
||||
else if (EpsGt(v, static_cast< Float64 >(Max)))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
return static_cast< Uint8 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Uint16 ConvTo< Uint16 >::From< Float64 >(Float64 v)
|
||||
{
|
||||
if (EpsLt(v, static_cast< Float64 >(Min)))
|
||||
{
|
||||
return Min;
|
||||
}
|
||||
else if (EpsGt(v, static_cast< Float64 >(Max)))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
return static_cast< Uint16 >(v);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> template <> inline Uint32 ConvTo< Uint32 >::From< Float64 >(Float64 v)
|
||||
{
|
||||
if (EpsLt(v, static_cast< Float64 >(Min)))
|
||||
{
|
||||
return Min;
|
||||
}
|
||||
else if (EpsGt(v, static_cast< Float64 >(Max)))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
return static_cast< Uint32 >(v);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Convert other numeric values to signed long long integer.
|
||||
*/
|
||||
template <> struct ConvTo< Int64 >
|
||||
{
|
||||
// --------------------------------------------------------------------------------------------
|
||||
static constexpr Int64 Min = std::numeric_limits< Int64 >::min();
|
||||
static constexpr Int64 Max = std::numeric_limits< Int64 >::max();
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
template < typename T > static inline Int64 From(T v)
|
||||
{
|
||||
return static_cast< Int64 >(v);
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> inline Int64 ConvTo< Int64 >::From< Uint64 >(Uint64 v)
|
||||
{
|
||||
return (v >= static_cast< Uint64 >(Max)) ? Max : static_cast< Int64 >(v);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Convert other numeric values to unsigned long long integer.
|
||||
*/
|
||||
template <> struct ConvTo< Uint64 >
|
||||
{
|
||||
// --------------------------------------------------------------------------------------------
|
||||
static constexpr Uint64 Min = std::numeric_limits< Uint64 >::min();
|
||||
static constexpr Uint64 Max = std::numeric_limits< Uint64 >::max();
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
template < typename T > static inline Uint64 From(T v)
|
||||
{
|
||||
return (v <= static_cast< T >(0)) ? 0 : static_cast< Uint64 >(v);
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> inline Uint64 ConvTo< Uint64 >::From< Float32 >(Float32 v)
|
||||
{
|
||||
return From(ConvTo< Int64 >::From(v));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> inline Uint64 ConvTo< Uint64 >::From< Float64 >(Float64 v)
|
||||
{
|
||||
return From(ConvTo< Int64 >::From(v));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Convert other numeric values to a floating point value.
|
||||
*/
|
||||
template <> struct ConvTo< Float32 >
|
||||
{
|
||||
// --------------------------------------------------------------------------------------------
|
||||
static constexpr Float32 Min = std::numeric_limits< Float32 >::min();
|
||||
static constexpr Float32 Max = std::numeric_limits< Float32 >::max();
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
template < typename T > static inline Float32 From(T v)
|
||||
{
|
||||
return static_cast< Float32 >(v);
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template <> inline Float32 ConvTo< Float32 >::From< Float64 >(Float64 v)
|
||||
{
|
||||
if (EpsGt(v, static_cast< Float64 >(Max)))
|
||||
{
|
||||
return Max;
|
||||
}
|
||||
else if (EpsLt(v, static_cast< Float64 >(Min)))
|
||||
{
|
||||
return Min;
|
||||
}
|
||||
return static_cast< Float32 >(v);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Convert other numeric values to a double floating point value.
|
||||
*/
|
||||
template <> struct ConvTo< Float64 >
|
||||
{
|
||||
// --------------------------------------------------------------------------------------------
|
||||
static constexpr Float64 Min = std::numeric_limits< Float64 >::min();
|
||||
static constexpr Float64 Max = std::numeric_limits< Float64 >::max();
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
template < typename T > static inline Float64 From(T v)
|
||||
{
|
||||
return static_cast< Float64 >(v);
|
||||
}
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Force a value to be within a certain range.
|
||||
*/
|
||||
template< typename T > inline T Clamp(T val, T min, T max)
|
||||
{
|
||||
return val < min ? min : (val > max ? max : val);
|
||||
// Is the specified value bellow the minimum?
|
||||
if (val < min)
|
||||
{
|
||||
return min;
|
||||
}
|
||||
// Is the specified value above the maximum?
|
||||
else if (val > max)
|
||||
{
|
||||
return max;
|
||||
}
|
||||
// Return the value as is
|
||||
return val;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Force a value to be within a certain range.
|
||||
*/
|
||||
template<> inline Float32 Clamp(Float32 val, Float32 min, Float32 max)
|
||||
{
|
||||
// Is the specified value bellow the minimum?
|
||||
if (EpsLt(val, min))
|
||||
{
|
||||
return min;
|
||||
}
|
||||
// Is the specified value above the maximum?
|
||||
else if (EpsGt(val, max))
|
||||
{
|
||||
return max;
|
||||
}
|
||||
// Return the value as is
|
||||
return val;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Force a value to be within a certain range.
|
||||
*/
|
||||
template<> inline Float64 Clamp(Float64 val, Float64 min, Float64 max)
|
||||
{
|
||||
// Is the specified value bellow the minimum?
|
||||
if (EpsLt(val, min))
|
||||
{
|
||||
return min;
|
||||
}
|
||||
// Is the specified value above the maximum?
|
||||
else if (EpsGt(val, max))
|
||||
{
|
||||
return max;
|
||||
}
|
||||
// Return the value as is
|
||||
return val;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Force a value to be the boundaries of the specified type.
|
||||
*/
|
||||
template< typename T, typename U > inline U ClampL(T val)
|
||||
template < typename T, typename U > inline U ClampL(T v)
|
||||
{
|
||||
// Is the specified value bellow the minimum?
|
||||
if (val < std::numeric_limits< U >::min())
|
||||
{
|
||||
return std::numeric_limits< U >::min();
|
||||
}
|
||||
// Is the specified value above the maximum?
|
||||
else if (val > std::numeric_limits< U >::max())
|
||||
{
|
||||
return std::numeric_limits< U >::max();
|
||||
}
|
||||
// Return the value as is
|
||||
return static_cast< U >(val);
|
||||
return ConvTo< U >::From(v);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
@ -289,42 +706,6 @@ Array & NullArray();
|
||||
*/
|
||||
Function & NullFunction();
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Create a script string object from a buffer.
|
||||
*/
|
||||
Object BufferToStrObj(const Buffer & b);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Create a script string object from a portion of a buffer.
|
||||
*/
|
||||
Object BufferToStrObj(const Buffer & b, Uint32 size);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Create a script object from the specified value on the default VM.
|
||||
*/
|
||||
template < typename T > Object MakeObject(const T & v)
|
||||
{
|
||||
// Remember the current stack size
|
||||
const StackGuard sg;
|
||||
// Transform the specified value into a script object
|
||||
PushVar< T >(DefaultVM::Get(), v);
|
||||
// Get the object from the stack and return it
|
||||
return Var< Object >(DefaultVM::Get(), -1).value;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Create a script object from the specified value on the specified VM.
|
||||
*/
|
||||
template < typename T > Object MakeObject(HSQUIRRELVM vm, const T & v)
|
||||
{
|
||||
// Remember the current stack size
|
||||
const StackGuard sg;
|
||||
// Transform the specified value into a script object
|
||||
PushVar< T >(vm, v);
|
||||
// Get the object from the stack and return it
|
||||
return Var< Object >(vm, -1).value;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Simple function to check whether the specified string can be considered as a boolean value
|
||||
*/
|
||||
|
413
source/Base/Stack.cpp
Normal file
413
source/Base/Stack.cpp
Normal file
@ -0,0 +1,413 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Base/Stack.hpp"
|
||||
#include "Base/Shared.hpp"
|
||||
#include "Base/Buffer.hpp"
|
||||
#include "Library/Numeric.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <sqstdstring.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger PopStackInteger(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 val;
|
||||
} break;
|
||||
case OT_FLOAT:
|
||||
{
|
||||
SQFloat val;
|
||||
sq_getfloat(vm, idx, &val);
|
||||
return ConvTo< SQInteger >::From(val);
|
||||
} break;
|
||||
case OT_BOOL:
|
||||
{
|
||||
SQBool val;
|
||||
sq_getbool(vm, idx, &val);
|
||||
return static_cast< SQInteger >(val);
|
||||
} break;
|
||||
case OT_STRING:
|
||||
{
|
||||
CSStr val = nullptr;
|
||||
// Attempt to retrieve and convert the string
|
||||
if (SQ_SUCCEEDED(sq_getstring(vm, idx, &val)) && val != nullptr && *val != '\0')
|
||||
{
|
||||
return ConvTo< SQInteger >::From(std::strtoll(val, nullptr, 10));
|
||||
}
|
||||
} break;
|
||||
case OT_ARRAY:
|
||||
case OT_TABLE:
|
||||
case OT_CLASS:
|
||||
case OT_USERDATA:
|
||||
{
|
||||
return sq_getsize(vm, idx);
|
||||
} break;
|
||||
case OT_INSTANCE:
|
||||
{
|
||||
// Attempt to treat the value as a signed long instance
|
||||
try
|
||||
{
|
||||
return ConvTo< SQInteger >::From(Var< const SLongInt & >(vm, idx).value.GetNum());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Just ignore it...
|
||||
}
|
||||
// Attempt to treat the value as a unsigned long instance
|
||||
try
|
||||
{
|
||||
return ConvTo< SQInteger >::From(Var< const ULongInt & >(vm, idx).value.GetNum());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Just ignore it...
|
||||
}
|
||||
// Attempt to get the size of the instance as a fallback
|
||||
return sq_getsize(vm, idx);
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
// Default to 0
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQFloat PopStackFloat(HSQUIRRELVM vm, SQInteger idx)
|
||||
{
|
||||
// Identify which type must be extracted
|
||||
switch (sq_gettype(vm, idx))
|
||||
{
|
||||
case OT_FLOAT:
|
||||
{
|
||||
SQFloat val;
|
||||
sq_getfloat(vm, idx, &val);
|
||||
return val;
|
||||
} break;
|
||||
case OT_INTEGER:
|
||||
{
|
||||
SQInteger val;
|
||||
sq_getinteger(vm, idx, &val);
|
||||
return ConvTo< SQFloat >::From(val);
|
||||
} break;
|
||||
case OT_BOOL:
|
||||
{
|
||||
SQBool val;
|
||||
sq_getbool(vm, idx, &val);
|
||||
return ConvTo< SQFloat >::From(val);
|
||||
} break;
|
||||
case OT_STRING:
|
||||
{
|
||||
CSStr val = nullptr;
|
||||
// Attempt to retrieve and convert the string
|
||||
if (SQ_SUCCEEDED(sq_getstring(vm, idx, &val)) && val != nullptr && *val != '\0')
|
||||
{
|
||||
#ifdef SQUSEDOUBLE
|
||||
return std::strtod(val, nullptr);
|
||||
#else
|
||||
return std::strtof(val, nullptr);
|
||||
#endif // SQUSEDOUBLE
|
||||
}
|
||||
} break;
|
||||
case OT_ARRAY:
|
||||
case OT_TABLE:
|
||||
case OT_CLASS:
|
||||
case OT_USERDATA:
|
||||
{
|
||||
return ConvTo< SQFloat >::From(sq_getsize(vm, idx));
|
||||
} break;
|
||||
case OT_INSTANCE:
|
||||
{
|
||||
// Attempt to treat the value as a signed long instance
|
||||
try
|
||||
{
|
||||
return ConvTo< SQFloat >::From(Var< const SLongInt & >(vm, idx).value.GetNum());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Just ignore it...
|
||||
}
|
||||
// Attempt to treat the value as a unsigned long instance
|
||||
try
|
||||
{
|
||||
return ConvTo< SQFloat >::From(Var< const ULongInt & >(vm, idx).value.GetNum());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Just ignore it...
|
||||
}
|
||||
// Attempt to get the size of the instance as a fallback
|
||||
return ConvTo< SQFloat >::From(sq_getsize(vm, idx));
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
// Default to 0
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Int64 PopStackLong(HSQUIRRELVM vm, SQInteger idx)
|
||||
{
|
||||
// Identify which type must be extracted
|
||||
switch (sq_gettype(vm, idx))
|
||||
{
|
||||
case OT_INTEGER:
|
||||
{
|
||||
SQInteger val;
|
||||
sq_getinteger(vm, idx, &val);
|
||||
return static_cast< Int64 >(val);
|
||||
} break;
|
||||
case OT_FLOAT:
|
||||
{
|
||||
SQFloat val;
|
||||
sq_getfloat(vm, idx, &val);
|
||||
return ConvTo< Int64 >::From(val);
|
||||
} break;
|
||||
case OT_BOOL:
|
||||
{
|
||||
SQBool val;
|
||||
sq_getbool(vm, idx, &val);
|
||||
return static_cast< Int64 >(val);
|
||||
} break;
|
||||
case OT_STRING:
|
||||
{
|
||||
CSStr val = nullptr;
|
||||
// Attempt to retrieve and convert the string
|
||||
if (SQ_SUCCEEDED(sq_getstring(vm, idx, &val)) && val != nullptr && *val != '\0')
|
||||
{
|
||||
return std::strtoll(val, nullptr, 10);
|
||||
}
|
||||
} break;
|
||||
case OT_ARRAY:
|
||||
case OT_TABLE:
|
||||
case OT_CLASS:
|
||||
case OT_USERDATA:
|
||||
{
|
||||
return static_cast< Int64 >(sq_getsize(vm, idx));
|
||||
} break;
|
||||
case OT_INSTANCE:
|
||||
{
|
||||
// Attempt to treat the value as a signed long instance
|
||||
try
|
||||
{
|
||||
return Var< const SLongInt & >(vm, idx).value.GetNum();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Just ignore it...
|
||||
}
|
||||
// Attempt to treat the value as a unsigned long instance
|
||||
try
|
||||
{
|
||||
return ConvTo< Int64 >::From(Var< const ULongInt & >(vm, idx).value.GetNum());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Just ignore it...
|
||||
}
|
||||
// Attempt to get the size of the instance as a fallback
|
||||
return static_cast< Int64 >(sq_getsize(vm, idx));
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
// Default to 0
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Uint64 PopStackULong(HSQUIRRELVM vm, SQInteger idx)
|
||||
{
|
||||
// Identify which type must be extracted
|
||||
switch (sq_gettype(vm, idx))
|
||||
{
|
||||
case OT_INTEGER:
|
||||
{
|
||||
SQInteger val;
|
||||
sq_getinteger(vm, idx, &val);
|
||||
return ConvTo< Uint64 >::From(val);
|
||||
} break;
|
||||
case OT_FLOAT:
|
||||
{
|
||||
SQFloat val;
|
||||
sq_getfloat(vm, idx, &val);
|
||||
return ConvTo< Uint64 >::From(val);
|
||||
} break;
|
||||
case OT_BOOL:
|
||||
{
|
||||
SQBool val;
|
||||
sq_getbool(vm, idx, &val);
|
||||
return ConvTo< Uint64 >::From(val);
|
||||
} break;
|
||||
case OT_STRING:
|
||||
{
|
||||
CSStr val = nullptr;
|
||||
// Attempt to retrieve and convert the string
|
||||
if (SQ_SUCCEEDED(sq_getstring(vm, idx, &val)) && val != nullptr && *val != '\0')
|
||||
{
|
||||
return std::strtoull(val, nullptr, 10);
|
||||
}
|
||||
} break;
|
||||
case OT_ARRAY:
|
||||
case OT_TABLE:
|
||||
case OT_CLASS:
|
||||
case OT_USERDATA:
|
||||
{
|
||||
return ConvTo< Uint64 >::From(sq_getsize(vm, idx));
|
||||
} break;
|
||||
case OT_INSTANCE:
|
||||
{
|
||||
// Attempt to treat the value as a signed long instance
|
||||
try
|
||||
{
|
||||
return ConvTo< Uint64 >::From(Var< const SLongInt & >(vm, idx).value.GetNum());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Just ignore it...
|
||||
}
|
||||
// Attempt to treat the value as a unsigned long instance
|
||||
try
|
||||
{
|
||||
return Var< const ULongInt & >(vm, idx).value.GetNum();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Just ignore it...
|
||||
}
|
||||
// Attempt to get the size of the instance as a fallback
|
||||
return ConvTo< Uint64 >::From(sq_getsize(vm, idx));
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
// Default to 0
|
||||
return 0;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
StackStrF::StackStrF(HSQUIRRELVM vm, SQInteger idx, bool fmt)
|
||||
: mPtr(nullptr)
|
||||
, mLen(-1)
|
||||
, mRes(SQ_OK)
|
||||
, mObj()
|
||||
, mVM(vm)
|
||||
{
|
||||
const Int32 top = sq_gettop(vm);
|
||||
// Reset the converted value object
|
||||
sq_resetobject(&mObj);
|
||||
// Was the string or value specified?
|
||||
if (top <= (idx - 1))
|
||||
{
|
||||
mRes = sq_throwerror(vm, "Missing string or value");
|
||||
}
|
||||
// Do we have enough values to call the format function and are we allowed to?
|
||||
else if (top > idx && fmt)
|
||||
{
|
||||
// Pointer to the generated string
|
||||
SStr str = nullptr;
|
||||
// Attempt to generate the specified string format
|
||||
mRes = sqstd_format(vm, idx, &mLen, &str);
|
||||
// Did the format succeeded but ended up with a null string pointer?
|
||||
if (SQ_SUCCEEDED(mRes) && !str)
|
||||
{
|
||||
mRes = sq_throwerror(vm, "Unable to generate the string");
|
||||
}
|
||||
else
|
||||
{
|
||||
mPtr = const_cast< CSStr >(str);
|
||||
}
|
||||
}
|
||||
// Is the value on the stack an actual string?
|
||||
else if (sq_gettype(vm, idx) == OT_STRING)
|
||||
{
|
||||
// Obtain a reference to the string object
|
||||
mRes = sq_getstackobj(vm, idx, &mObj);
|
||||
// Could we retrieve the object from the stack?
|
||||
if (SQ_SUCCEEDED(mRes))
|
||||
{
|
||||
// Keep a strong reference to the object
|
||||
sq_addref(vm, &mObj);
|
||||
// Attempt to retrieve the string value from the stack
|
||||
mRes = sq_getstring(vm, idx, &mPtr);
|
||||
}
|
||||
// Did the retrieval succeeded but ended up with a null string pointer?
|
||||
if (SQ_SUCCEEDED(mRes) && !mPtr)
|
||||
{
|
||||
mRes = sq_throwerror(vm, "Unable to retrieve the string");
|
||||
}
|
||||
}
|
||||
// We have to try and convert it to string
|
||||
else
|
||||
{
|
||||
// Attempt to convert the value from the stack to a string
|
||||
mRes = sq_tostring(vm, idx);
|
||||
// Could we convert the specified value to string?
|
||||
if (SQ_SUCCEEDED(mRes))
|
||||
{
|
||||
// Obtain a reference to the resulted object
|
||||
mRes = sq_getstackobj(vm, -1, &mObj);
|
||||
// Could we retrieve the object from the stack?
|
||||
if (SQ_SUCCEEDED(mRes))
|
||||
{
|
||||
// Keep a strong reference to the object
|
||||
sq_addref(vm, &mObj);
|
||||
// Attempt to obtain the string pointer
|
||||
mRes = sq_getstring(vm, -1, &mPtr);
|
||||
}
|
||||
}
|
||||
// Pop a value from the stack regardless of the result
|
||||
sq_pop(vm, 1);
|
||||
// Did the retrieval succeeded but ended up with a null string pointer?
|
||||
if (SQ_SUCCEEDED(mRes) && !mPtr)
|
||||
{
|
||||
mRes = sq_throwerror(vm, "Unable to retrieve the value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
StackStrF::~StackStrF()
|
||||
{
|
||||
if (mVM && !sq_isnull(mObj))
|
||||
{
|
||||
sq_release(mVM, &mObj);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object BufferToStrObj(const Buffer & b)
|
||||
{
|
||||
// Obtain the initial stack size
|
||||
const StackGuard sg(DefaultVM::Get());
|
||||
// Push the string onto the stack
|
||||
sq_pushstring(DefaultVM::Get(), b.Data(), b.Position());
|
||||
// Obtain the object from the stack and return it
|
||||
return Var< Object >(DefaultVM::Get(), -1).value;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
Object BufferToStrObj(const Buffer & b, Uint32 size)
|
||||
{
|
||||
// Perform a range check on the specified buffer
|
||||
if (size > b.Capacity())
|
||||
{
|
||||
STHROWF("The specified buffer size is out of range: %u >= %u", size, b.Capacity());
|
||||
}
|
||||
// Obtain the initial stack size
|
||||
const StackGuard sg(DefaultVM::Get());
|
||||
// Push the string onto the stack
|
||||
sq_pushstring(DefaultVM::Get(), b.Data(), size);
|
||||
// Obtain the object from the stack and return it
|
||||
return Var< Object >(DefaultVM::Get(), -1).value;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
} // Namespace:: SqMod
|
172
source/Base/Stack.hpp
Normal file
172
source/Base/Stack.hpp
Normal file
@ -0,0 +1,172 @@
|
||||
#ifndef _BASE_STACK_HPP_
|
||||
#define _BASE_STACK_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "SqBase.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <sqrat.h>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Attempt to pop the value at the specified index on the stack as a native integer.
|
||||
*/
|
||||
SQInteger PopStackInteger(HSQUIRRELVM vm, SQInteger idx);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Attempt to pop the value at the specified index on the stack as a native float.
|
||||
*/
|
||||
SQFloat PopStackFloat(HSQUIRRELVM vm, SQInteger idx);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Attempt to pop the value at the specified index on the stack as a signed long integer.
|
||||
*/
|
||||
Int64 PopStackLong(HSQUIRRELVM vm, SQInteger idx);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Attempt to pop the value at the specified index on the stack as an unsigned long integer.
|
||||
*/
|
||||
Uint64 PopStackULong(HSQUIRRELVM vm, SQInteger idx);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Create a script string object from a buffer.
|
||||
*/
|
||||
Object BufferToStrObj(const Buffer & b);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Create a script string object from a portion of a buffer.
|
||||
*/
|
||||
Object BufferToStrObj(const Buffer & b, Uint32 size);
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Implements RAII to restore the VM stack to it's initial size on function exit.
|
||||
*/
|
||||
struct StackGuard
|
||||
{
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Default constructor.
|
||||
*/
|
||||
StackGuard()
|
||||
: m_VM(DefaultVM::Get()), m_Top(sq_gettop(m_VM))
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Base constructor.
|
||||
*/
|
||||
StackGuard(HSQUIRRELVM vm)
|
||||
: m_VM(vm), m_Top(sq_gettop(vm))
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
StackGuard(const StackGuard &) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move constructor. (disabled)
|
||||
*/
|
||||
StackGuard(StackGuard &&) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
~StackGuard()
|
||||
{
|
||||
sq_pop(m_VM, sq_gettop(m_VM) - m_Top);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy assignment operator. (disabled)
|
||||
*/
|
||||
StackGuard & operator = (const StackGuard &) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Move assignment operator. (disabled)
|
||||
*/
|
||||
StackGuard & operator = (StackGuard &&) = delete;
|
||||
|
||||
private:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
HSQUIRRELVM m_VM; // The VM where the stack should be restored.
|
||||
Int32 m_Top; // The top of the stack when this instance was created.
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Helper structure for retrieving a value from the stack as a string or a formatted string.
|
||||
*/
|
||||
struct StackStrF
|
||||
{
|
||||
// --------------------------------------------------------------------------------------------
|
||||
CSStr mPtr; // Pointer to the C string that was retrieved.
|
||||
SQInteger mLen; // The string length if it could be retrieved.
|
||||
SQRESULT mRes; // The result of the retrieval attempts.
|
||||
HSQOBJECT mObj; // Strong reference to the string object.
|
||||
HSQUIRRELVM mVM; // The associated virtual machine.
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Base constructor.
|
||||
*/
|
||||
StackStrF(HSQUIRRELVM vm, SQInteger idx, bool fmt = true);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
StackStrF(const StackStrF & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
StackStrF(StackStrF && o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
~StackStrF();
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
StackStrF & operator = (const StackStrF & o) = delete;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
StackStrF & operator = (StackStrF && o) = delete;
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Create a script object from the specified value on the default VM.
|
||||
*/
|
||||
template < typename T > Object MakeObject(const T & v)
|
||||
{
|
||||
// Remember the current stack size
|
||||
const StackGuard sg;
|
||||
// Transform the specified value into a script object
|
||||
PushVar< T >(DefaultVM::Get(), v);
|
||||
// Get the object from the stack and return it
|
||||
return Var< Object >(DefaultVM::Get(), -1).value;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Create a script object from the specified value on the specified VM.
|
||||
*/
|
||||
template < typename T > Object MakeObject(HSQUIRRELVM vm, const T & v)
|
||||
{
|
||||
// Remember the current stack size
|
||||
const StackGuard sg;
|
||||
// Transform the specified value into a script object
|
||||
PushVar< T >(vm, v);
|
||||
// Get the object from the stack and return it
|
||||
return Var< Object >(vm, -1).value;
|
||||
}
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _BASE_STACK_HPP_
|
@ -1,6 +1,7 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Command.hpp"
|
||||
#include "Core.hpp"
|
||||
#include "Base/Stack.hpp"
|
||||
#include "Entity/Player.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -38,6 +38,20 @@ void Register_Constants(HSQUIRRELVM vm)
|
||||
.Const(_SC("MaxFloat"), std::numeric_limits< SQFloat >::max())
|
||||
.Const(_SC("MinFloat32"), std::numeric_limits< Float32 >::min())
|
||||
.Const(_SC("MaxFloat32"), std::numeric_limits< Float32 >::max())
|
||||
.Const(_SC("FpNormal"), FP_NORMAL)
|
||||
.Const(_SC("FpSubnormal"), FP_SUBNORMAL)
|
||||
.Const(_SC("FpZero"), FP_ZERO)
|
||||
.Const(_SC("FpInfinite"), FP_INFINITE)
|
||||
.Const(_SC("FpNan"), FP_NAN)
|
||||
#ifdef SQUSEDOUBLE
|
||||
.Const(_SC("HugeVal"), HUGE_VAL)
|
||||
#else
|
||||
.Const(_SC("HugeVal"), HUGE_VALF)
|
||||
#endif // SQUSEDOUBLE
|
||||
.Const(_SC("Infinity"), static_cast< float >(INFINITY))
|
||||
.Const(_SC("Inf"), static_cast< float >(INFINITY))
|
||||
.Const(_SC("Nan"), static_cast< float >(NAN))
|
||||
|
||||
);
|
||||
|
||||
ConstTable(vm).Enum(_SC("SqArchitectre"), Enumeration(vm)
|
||||
|
@ -1,5 +1,6 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Entity/Blip.hpp"
|
||||
#include "Base/Stack.hpp"
|
||||
#include "Core.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "Entity/Player.hpp"
|
||||
#include "Base/Color4.hpp"
|
||||
#include "Base/Vector3.hpp"
|
||||
#include "Base/Stack.hpp"
|
||||
#include "Core.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "Entity/Player.hpp"
|
||||
#include "Base/Color3.hpp"
|
||||
#include "Base/Vector3.hpp"
|
||||
#include "Base/Stack.hpp"
|
||||
#include "Core.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -1,5 +1,6 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Entity/Keybind.hpp"
|
||||
#include "Base/Stack.hpp"
|
||||
#include "Core.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "Entity/Player.hpp"
|
||||
#include "Base/Quaternion.hpp"
|
||||
#include "Base/Vector3.hpp"
|
||||
#include "Base/Stack.hpp"
|
||||
#include "Core.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "Entity/Pickup.hpp"
|
||||
#include "Entity/Player.hpp"
|
||||
#include "Base/Vector3.hpp"
|
||||
#include "Base/Stack.hpp"
|
||||
#include "Core.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "Entity/Vehicle.hpp"
|
||||
#include "Base/Color3.hpp"
|
||||
#include "Base/Vector3.hpp"
|
||||
#include "Base/Stack.hpp"
|
||||
#include "Core.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "Entity/Sprite.hpp"
|
||||
#include "Entity/Player.hpp"
|
||||
#include "Base/Vector2i.hpp"
|
||||
#include "Base/Stack.hpp"
|
||||
#include "Core.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "Entity/Textdraw.hpp"
|
||||
#include "Entity/Player.hpp"
|
||||
#include "Base/Vector2i.hpp"
|
||||
#include "Base/Stack.hpp"
|
||||
#include "Core.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "Entity/Player.hpp"
|
||||
#include "Base/Quaternion.hpp"
|
||||
#include "Base/Vector4.hpp"
|
||||
#include "Base/Stack.hpp"
|
||||
#include "Core.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -173,7 +173,7 @@ extern void Register_ChronoTime(HSQUIRRELVM vm, Table & cns);
|
||||
extern void Register_ChronoTimer(HSQUIRRELVM vm, Table & cns);
|
||||
extern void Register_ChronoTimestamp(HSQUIRRELVM vm, Table & cns);
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// ================================================================================================
|
||||
void Register_Chrono(HSQUIRRELVM vm)
|
||||
{
|
||||
Table cns(vm);
|
||||
|
@ -1,6 +1,7 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/Crypt.hpp"
|
||||
#include "Base/Shared.hpp"
|
||||
#include "Base/Stack.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <cstdlib>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,12 @@
|
||||
#ifndef _LIBRARY_MATH_HPP_
|
||||
#define _LIBRARY_MATH_HPP_
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Base/Shared.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
} // Namespace:: SqMod
|
||||
|
||||
#endif // _LIBRARY_MATH_HPP_
|
@ -54,7 +54,7 @@ LongInt< Uint64 > & LongInt< Uint64 >::operator = (CSStr text)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CSStr LongInt< Uint64 >::ToString()
|
||||
{
|
||||
if (snprintf(m_Text, sizeof(m_Text), "%llu", m_Data) < 0)
|
||||
if (std::snprintf(m_Text, sizeof(m_Text), "%llu", m_Data) < 0)
|
||||
{
|
||||
m_Text[0] = 0;
|
||||
}
|
||||
@ -82,6 +82,12 @@ void Register_Numeric(HSQUIRRELVM vm)
|
||||
.Func(_SC("_tostring"), &SLongInt::ToString)
|
||||
.Func(_SC("_typename"), &SLongInt::Typename)
|
||||
.Func(_SC("_cmp"), &SLongInt::Cmp)
|
||||
/* 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)
|
||||
/* Metamethods */
|
||||
.Func< SLongInt (SLongInt::*)(const SLongInt &) const >(_SC("_add"), &SLongInt::operator +)
|
||||
.Func< SLongInt (SLongInt::*)(const SLongInt &) const >(_SC("_sub"), &SLongInt::operator -)
|
||||
@ -112,6 +118,12 @@ void Register_Numeric(HSQUIRRELVM vm)
|
||||
.Func(_SC("_tostring"), &ULongInt::ToString)
|
||||
.Func(_SC("_typename"), &ULongInt::Typename)
|
||||
.Func(_SC("_cmp"), &ULongInt::Cmp)
|
||||
/* 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)
|
||||
/* Metamethods */
|
||||
.Func< ULongInt (ULongInt::*)(const ULongInt &) const >(_SC("_add"), &ULongInt::operator +)
|
||||
.Func< ULongInt (ULongInt::*)(const ULongInt &) const >(_SC("_sub"), &ULongInt::operator -)
|
||||
|
@ -199,7 +199,7 @@ public:
|
||||
*/
|
||||
SQInteger GetSNum() const
|
||||
{
|
||||
return (SQInteger)(m_Data);
|
||||
return ClampL< Type, SQInteger >(m_Data);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
@ -222,6 +222,46 @@ public:
|
||||
void Random(Type n);
|
||||
void Random(Type m, Type n);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to convert the long integer to a squirrel integer.
|
||||
*/
|
||||
SQInteger ToSqInteger() const
|
||||
{
|
||||
return ClampL< Type, SQInteger >(m_Data);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to convert the long integer to a squirrel float.
|
||||
*/
|
||||
SQFloat ToSqFloat() const
|
||||
{
|
||||
return ClampL< Float64, SQFloat >(static_cast< Float64 >(m_Data));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to convert the long integer to a squirrel string.
|
||||
*/
|
||||
CSStr ToSqString()
|
||||
{
|
||||
return ToString();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to convert the long integer to a squirrel boolean.
|
||||
*/
|
||||
bool ToSqBool() const
|
||||
{
|
||||
return (m_Data > 0);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to convert the long integer to a squirrel character.
|
||||
*/
|
||||
SQChar ToSqChar() const
|
||||
{
|
||||
return ClampL< Type, SQChar >(m_Data);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
@ -441,6 +481,46 @@ public:
|
||||
void Random(Type n);
|
||||
void Random(Type m, Type n);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to convert the long integer to a squirrel integer.
|
||||
*/
|
||||
SQInteger ToSqInteger() const
|
||||
{
|
||||
return ClampL< Type, SQInteger >(m_Data);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to convert the long integer to a squirrel float.
|
||||
*/
|
||||
SQFloat ToSqFloat() const
|
||||
{
|
||||
return ClampL< Float64, SQFloat >(static_cast< Float64 >(m_Data));
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to convert the long integer to a squirrel string.
|
||||
*/
|
||||
CSStr ToSqString()
|
||||
{
|
||||
return ToString();
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to convert the long integer to a squirrel boolean.
|
||||
*/
|
||||
bool ToSqBool() const
|
||||
{
|
||||
return (m_Data > 0);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Attempt to convert the long integer to a squirrel character.
|
||||
*/
|
||||
SQChar ToSqChar() const
|
||||
{
|
||||
return ClampL< Type, SQChar >(m_Data);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include "Library/String.hpp"
|
||||
#include "Base/Shared.hpp"
|
||||
#include "Base/Buffer.hpp"
|
||||
#include "Base/Stack.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <cctype>
|
||||
|
@ -1,5 +1,6 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/SysEnv.hpp"
|
||||
#include "Base/Stack.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <cctype>
|
||||
|
@ -1,6 +1,7 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Library/SysPath.hpp"
|
||||
#include "Library/SysEnv.hpp"
|
||||
#include "Base/Stack.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <cctype>
|
||||
|
@ -37,6 +37,7 @@ extern void Register_Entity(HSQUIRRELVM vm);
|
||||
extern void Register_Chrono(HSQUIRRELVM vm);
|
||||
extern void Register_Crypt(HSQUIRRELVM vm);
|
||||
extern void Register_Numeric(HSQUIRRELVM vm);
|
||||
extern void Register_Math(HSQUIRRELVM vm);
|
||||
extern void Register_Random(HSQUIRRELVM vm);
|
||||
extern void Register_String(HSQUIRRELVM vm);
|
||||
extern void Register_SysEnv(HSQUIRRELVM vm);
|
||||
@ -82,6 +83,7 @@ bool RegisterAPI(HSQUIRRELVM vm)
|
||||
Register_Crypt(vm);
|
||||
Register_Random(vm);
|
||||
Register_Numeric(vm);
|
||||
Register_Math(vm);
|
||||
Register_String(vm);
|
||||
Register_SysEnv(vm);
|
||||
Register_SysPath(vm);
|
||||
|
@ -1,5 +1,6 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Routine.hpp"
|
||||
#include "Base/Stack.hpp"
|
||||
#include "Library/Chrono.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user