mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 08:47:17 +01:00
Replaced the numeric limits from previous legacy implementation with the one provided by C++11.
Added a few extra constants for numeric limits.
This commit is contained in:
parent
8088ba94c2
commit
ec88d0ae30
@ -3,13 +3,16 @@
|
||||
#include "Base/Shared.hpp"
|
||||
#include "Library/Random.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <limits>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Circle Circle::NIL = Circle();
|
||||
const Circle Circle::MIN = Circle(0.0);
|
||||
const Circle Circle::MAX = Circle(NumLimit< Circle::Value >::Max);
|
||||
const Circle Circle::MAX = Circle(std::numeric_limits< Circle::Value >::max());
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQChar Circle::Delim = ',';
|
||||
|
@ -12,8 +12,8 @@ namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Color3 Color3::NIL = Color3();
|
||||
const Color3 Color3::MIN = Color3(NumLimit< Color3::Value >::Min);
|
||||
const Color3 Color3::MAX = Color3(NumLimit< Color3::Value >::Max);
|
||||
const Color3 Color3::MIN = Color3(std::numeric_limits< Color3::Value >::min());
|
||||
const Color3 Color3::MAX = Color3(std::numeric_limits< Color3::Value >::max());
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQChar Color3::Delim = ',';
|
||||
|
@ -12,8 +12,8 @@ namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Color4 Color4::NIL = Color4();
|
||||
const Color4 Color4::MIN = Color4(NumLimit< Color4::Value >::Min);
|
||||
const Color4 Color4::MAX = Color4(NumLimit< Color4::Value >::Max);
|
||||
const Color4 Color4::MIN = Color4(std::numeric_limits< Color4::Value >::min());
|
||||
const Color4 Color4::MAX = Color4(std::numeric_limits< Color4::Value >::max());
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQChar Color4::Delim = ',';
|
||||
|
@ -5,13 +5,16 @@
|
||||
#include "Base/Shared.hpp"
|
||||
#include "Library/Random.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <limits>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Quaternion Quaternion::NIL = Quaternion(0);
|
||||
const Quaternion Quaternion::MIN = Quaternion(NumLimit< Quaternion::Value >::Min);
|
||||
const Quaternion Quaternion::MAX = Quaternion(NumLimit< Quaternion::Value >::Max);
|
||||
const Quaternion Quaternion::MIN = Quaternion(std::numeric_limits< Quaternion::Value >::min());
|
||||
const Quaternion Quaternion::MAX = Quaternion(std::numeric_limits< Quaternion::Value >::max());
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQChar Quaternion::Delim = ',';
|
||||
|
@ -41,38 +41,6 @@ PluginInfo* _Info = NULL;
|
||||
*/
|
||||
static SQChar g_Buffer[4096];
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const char NumLimit< char >::Min = CHAR_MIN;
|
||||
const signed char NumLimit< signed char >::Min = SCHAR_MIN;
|
||||
const unsigned char NumLimit< unsigned char >::Min = 0;
|
||||
const signed short NumLimit< signed short >::Min = SHRT_MIN;
|
||||
const unsigned short NumLimit< unsigned short >::Min = 0;
|
||||
const signed int NumLimit< signed int >::Min = INT_MIN;
|
||||
const unsigned int NumLimit< unsigned int >::Min = 0;
|
||||
const signed long NumLimit< signed long >::Min = LONG_MIN;
|
||||
const unsigned long NumLimit< unsigned long >::Min = 0;
|
||||
const signed long long NumLimit< signed long long >::Min = LLONG_MIN;
|
||||
const unsigned long long NumLimit< unsigned long long >::Min = 0;
|
||||
const float NumLimit< float >::Min = FLT_MIN;
|
||||
const double NumLimit< double >::Min = DBL_MIN;
|
||||
const long double NumLimit< long double >::Min = LDBL_MIN;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const char NumLimit< char >::Max = CHAR_MAX;
|
||||
const signed char NumLimit< signed char >::Max = SCHAR_MAX;
|
||||
const unsigned char NumLimit< unsigned char >::Max = UCHAR_MAX;
|
||||
const signed short NumLimit< signed short >::Max = SHRT_MAX;
|
||||
const unsigned short NumLimit< unsigned short >::Max = USHRT_MAX;
|
||||
const signed int NumLimit< signed int >::Max = INT_MAX;
|
||||
const unsigned int NumLimit< unsigned int >::Max = UINT_MAX;
|
||||
const signed long NumLimit< signed long >::Max = LONG_MAX;
|
||||
const unsigned long NumLimit< unsigned long >::Max = ULONG_MAX;
|
||||
const signed long long NumLimit< signed long long >::Max = LLONG_MAX;
|
||||
const unsigned long long NumLimit< unsigned long long >::Max = ULLONG_MAX;
|
||||
const float NumLimit< float >::Max = FLT_MAX;
|
||||
const double NumLimit< double >::Max = DBL_MAX;
|
||||
const long double NumLimit< long double >::Max = LDBL_MAX;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Object & NullObject()
|
||||
{
|
||||
@ -335,7 +303,7 @@ static const Color3 SQ_Color_List[] =
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Color3 & GetRandomColor()
|
||||
{
|
||||
return SQ_Color_List[GetRandomUint8(0, (sizeof(SQ_Color_List) / sizeof(Color3))-1)];
|
||||
return SQ_Color_List[GetRandomUint8(0, (sizeof(SQ_Color_List) / sizeof(Color3)) - 1)];
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -25,27 +25,6 @@ extern PluginFuncs* _Func;
|
||||
extern PluginCallbacks* _Clbk;
|
||||
extern PluginInfo* _Info;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
template < typename T > struct NumLimit;
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Basic minimum and maximum values for primitive numeric types.
|
||||
*/
|
||||
template <> struct NumLimit< char > { static const char Min, Max; };
|
||||
template <> struct NumLimit< signed char > { static const signed char Min, Max; };
|
||||
template <> struct NumLimit< unsigned char > { static const unsigned char Min, Max; };
|
||||
template <> struct NumLimit< signed short > { static const signed short Min, Max; };
|
||||
template <> struct NumLimit< unsigned short > { static const unsigned short Min, Max; };
|
||||
template <> struct NumLimit< signed int > { static const signed int Min, Max; };
|
||||
template <> struct NumLimit< unsigned int > { static const unsigned int Min, Max; };
|
||||
template <> struct NumLimit< signed long > { static const signed long Min, Max; };
|
||||
template <> struct NumLimit< unsigned long > { static const unsigned long Min, Max; };
|
||||
template <> struct NumLimit< signed long long > { static const signed long long Min, Max; };
|
||||
template <> struct NumLimit< unsigned long long > { static const unsigned long long Min, Max; };
|
||||
template <> struct NumLimit< float > { static const float Min, Max; };
|
||||
template <> struct NumLimit< double > { static const double Min, Max; };
|
||||
template <> struct NumLimit< long double > { static const long double Min, Max; };
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* Implements RAII to restore the VM stack to it's initial size on function exit.
|
||||
*/
|
||||
|
@ -3,13 +3,16 @@
|
||||
#include "Base/Shared.hpp"
|
||||
#include "Library/Random.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <limits>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Sphere Sphere::NIL = Sphere();
|
||||
const Sphere Sphere::MIN = Sphere(0.0);
|
||||
const Sphere Sphere::MAX = Sphere(NumLimit< Sphere::Value >::Max);
|
||||
const Sphere Sphere::MAX = Sphere(std::numeric_limits< Sphere::Value >::max());
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQChar Sphere::Delim = ',';
|
||||
|
@ -4,13 +4,16 @@
|
||||
#include "Base/Shared.hpp"
|
||||
#include "Library/Random.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <limits>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Vector2 Vector2::NIL = Vector2(0);
|
||||
const Vector2 Vector2::MIN = Vector2(NumLimit< Vector2::Value >::Min);
|
||||
const Vector2 Vector2::MAX = Vector2(NumLimit< Vector2::Value >::Max);
|
||||
const Vector2 Vector2::MIN = Vector2(std::numeric_limits< Vector2::Value >::min());
|
||||
const Vector2 Vector2::MAX = Vector2(std::numeric_limits< Vector2::Value >::max());
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQChar Vector2::Delim = ',';
|
||||
|
@ -4,13 +4,16 @@
|
||||
#include "Base/Shared.hpp"
|
||||
#include "Library/Random.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <limits>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Vector2i Vector2i::NIL = Vector2i(0);
|
||||
const Vector2i Vector2i::MIN = Vector2i(NumLimit< Vector2i::Value >::Min);
|
||||
const Vector2i Vector2i::MAX = Vector2i(NumLimit< Vector2i::Value >::Max);
|
||||
const Vector2i Vector2i::MIN = Vector2i(std::numeric_limits< Vector2i::Value >::min());
|
||||
const Vector2i Vector2i::MAX = Vector2i(std::numeric_limits< Vector2i::Value >::max());
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQChar Vector2i::Delim = ',';
|
||||
|
@ -5,13 +5,16 @@
|
||||
#include "Base/Shared.hpp"
|
||||
#include "Library/Random.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <limits>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Vector3 Vector3::NIL = Vector3(0);
|
||||
const Vector3 Vector3::MIN = Vector3(NumLimit< Vector3::Value >::Min);
|
||||
const Vector3 Vector3::MAX = Vector3(NumLimit< Vector3::Value >::Max);
|
||||
const Vector3 Vector3::MIN = Vector3(std::numeric_limits< Vector3::Value >::min());
|
||||
const Vector3 Vector3::MAX = Vector3(std::numeric_limits< Vector3::Value >::max());
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQChar Vector3::Delim = ',';
|
||||
|
@ -5,13 +5,16 @@
|
||||
#include "Base/Shared.hpp"
|
||||
#include "Library/Random.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <limits>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Vector4 Vector4::NIL = Vector4(0);
|
||||
const Vector4 Vector4::MIN = Vector4(NumLimit< Vector4::Value >::Min);
|
||||
const Vector4 Vector4::MAX = Vector4(NumLimit< Vector4::Value >::Max);
|
||||
const Vector4 Vector4::MIN = Vector4(std::numeric_limits< Vector4::Value >::min());
|
||||
const Vector4 Vector4::MAX = Vector4(std::numeric_limits< Vector4::Value >::max());
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQChar Vector4::Delim = ',';
|
||||
|
@ -1,6 +1,9 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include "Base/Shared.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#include <limits>
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
@ -14,18 +17,26 @@ void Register_Constants(HSQUIRRELVM vm)
|
||||
.Const(_SC("Unknown"), SQMOD_UNKNOWN)
|
||||
.Const(_SC("Arch"), SQMOD_ARCHITECTURE)
|
||||
.Const(_SC("Platform"), SQMOD_PLATFORM)
|
||||
.Const(_SC("MinChar"), NumLimit< SQChar>::Min)
|
||||
.Const(_SC("MaxChar"), NumLimit< SQChar >::Max)
|
||||
.Const(_SC("MinShort"), NumLimit< Int16>::Min)
|
||||
.Const(_SC("MaxShort"), NumLimit< Int16 >::Max)
|
||||
.Const(_SC("MinUshort"), NumLimit< Uint16>::Min)
|
||||
.Const(_SC("MaxUshort"), NumLimit< Uint16 >::Max)
|
||||
.Const(_SC("MinInt"), NumLimit< SQInteger>::Min)
|
||||
.Const(_SC("MaxInt"), NumLimit< SQInteger >::Max)
|
||||
.Const(_SC("MinInt32"), NumLimit< SQInt32>::Min)
|
||||
.Const(_SC("MaxInt32"), NumLimit< SQInt32 >::Max)
|
||||
.Const(_SC("MinFloat"), NumLimit< SQFloat>::Min)
|
||||
.Const(_SC("MaxFloat"), NumLimit< SQFloat >::Max)
|
||||
.Const(_SC("MinChar"), std::numeric_limits< SQChar >::min())
|
||||
.Const(_SC("MaxChar"), std::numeric_limits< SQChar >::max())
|
||||
.Const(_SC("MinAchar"), std::numeric_limits< Int8 >::min())
|
||||
.Const(_SC("MaxAchar"), std::numeric_limits< Int8 >::max())
|
||||
.Const(_SC("MinByte"), std::numeric_limits< Uint8 >::min())
|
||||
.Const(_SC("MaxByte"), std::numeric_limits< Uint8 >::max())
|
||||
.Const(_SC("MinShort"), std::numeric_limits< Int16 >::min())
|
||||
.Const(_SC("MaxShort"), std::numeric_limits< Int16 >::max())
|
||||
.Const(_SC("MinUshort"), std::numeric_limits< Uint16 >::min())
|
||||
.Const(_SC("MaxUshort"), std::numeric_limits< Uint16 >::max())
|
||||
.Const(_SC("MinInt"), std::numeric_limits< SQInteger >::min())
|
||||
.Const(_SC("MaxInt"), std::numeric_limits< SQInteger >::max())
|
||||
.Const(_SC("MinInteger"), std::numeric_limits< SQInteger >::min())
|
||||
.Const(_SC("MaxInteger"), std::numeric_limits< SQInteger >::max())
|
||||
.Const(_SC("MinInt32"), std::numeric_limits< SQInt32 >::min())
|
||||
.Const(_SC("MaxInt32"), std::numeric_limits< SQInt32 >::max())
|
||||
.Const(_SC("MinFloat"), std::numeric_limits< SQFloat >::min())
|
||||
.Const(_SC("MaxFloat"), std::numeric_limits< SQFloat >::max())
|
||||
.Const(_SC("MinFloat32"), std::numeric_limits< Float32 >::min())
|
||||
.Const(_SC("MaxFloat32"), std::numeric_limits< Float32 >::max())
|
||||
);
|
||||
|
||||
ConstTable(vm).Enum(_SC("SqArchitectre"), Enumeration(vm)
|
||||
|
Loading…
Reference in New Issue
Block a user