1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-07-24 01:31:47 +02:00

Migrated the host module to C++ exceptions as well.

Also enabled the latest C++ revision in the project.
Replaced the Random library with the one provided by C++11.
Implemented a simple AES256 encryption class.
Various other fixes and improvements.
This commit is contained in:
Sandu Liviu Catalin
2016-03-10 05:57:13 +02:00
parent 3162221e7f
commit 70e5f0ba21
124 changed files with 14873 additions and 14062 deletions

View File

@@ -14,6 +14,14 @@ const Circle Circle::MAX = Circle(NumLimit< Circle::Value >::Max);
// ------------------------------------------------------------------------------------------------
SQChar Circle::Delim = ',';
// ------------------------------------------------------------------------------------------------
SQInteger Circle::Typename(HSQUIRRELVM vm)
{
static SQChar name[] = _SC("Circle");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
// ------------------------------------------------------------------------------------------------
Circle::Circle()
: pos(0.0, 0.0), rad(0.0)
@@ -42,27 +50,6 @@ Circle::Circle(Value xv, Value yv, Value rv)
/* ... */
}
// ------------------------------------------------------------------------------------------------
Circle::Circle(const Circle & o)
: pos(o.pos), rad(o.rad)
{
}
// ------------------------------------------------------------------------------------------------
Circle::~Circle()
{
/* ... */
}
// ------------------------------------------------------------------------------------------------
Circle & Circle::operator = (const Circle & o)
{
pos = o.pos;
rad = o.rad;
return *this;
}
// ------------------------------------------------------------------------------------------------
Circle & Circle::operator = (Value r)
{
@@ -341,7 +328,7 @@ Int32 Circle::Cmp(const Circle & o) const
// ------------------------------------------------------------------------------------------------
CSStr Circle::ToString() const
{
return ToStringF("%f,%f,%f", pos.x, pos.y, rad);
return ToStrF("%f,%f,%f", pos.x, pos.y, rad);
}
// ------------------------------------------------------------------------------------------------
@@ -395,35 +382,28 @@ void Circle::Generate()
void Circle::Generate(Value min, Value max, bool r)
{
if (EpsLt(max, min))
{
SqThrow("max value is lower than min value");
}
SqThrowF("max value is lower than min value");
else if (r)
{
rad = GetRandomFloat32(min, max);
}
else
{
pos.Generate(min, max);
}
}
void Circle::Generate(Value xmin, Value xmax, Value ymin, Value ymax)
{
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin))
SqThrowF("max value is lower than min value");
pos.Generate(xmin, xmax, ymin, ymax);
}
void Circle::Generate(Value xmin, Value xmax, Value ymin, Value ymax, Value rmin, Value rmax)
{
if (EpsLt(rmax, rmin))
{
SqThrow("max value is lower than min value");
}
else
{
pos.Generate(xmin, xmax, ymin, ymax);
rad = GetRandomFloat32(rmin, rmax);
}
if (EpsLt(xmax, xmin) || EpsLt(ymax, ymin) || EpsLt(rmax, rmin))
SqThrowF("max value is lower than min value");
pos.Generate(xmin, xmax, ymin, ymax);
rad = GetRandomFloat32(rmin, rmax);
}
// ------------------------------------------------------------------------------------------------
@@ -452,6 +432,7 @@ void Register_Circle(HSQUIRRELVM vm)
.Prop(_SC("abs"), &Circle::Abs)
/* Core Metamethods */
.Func(_SC("_tostring"), &Circle::ToString)
.SquirrelFunc(_SC("_typename"), &Circle::Typename)
.Func(_SC("_cmp"), &Circle::Cmp)
/* Metamethods */
.Func<Circle (Circle::*)(const Circle &) const>(_SC("_add"), &Circle::operator +)