1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-02-20 19:57:12 +01:00

Implement the pure typename meta-methods in AABB type using the standard method.

This commit is contained in:
Sandu Liviu Catalin 2016-11-15 21:20:57 +02:00
parent 60d6a96e07
commit 2cce140e1b
2 changed files with 6 additions and 17 deletions

View File

@ -7,6 +7,9 @@
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
SQMODE_DECL_TYPENAME(Typename, _SC("AABB"))
// ------------------------------------------------------------------------------------------------
const AABB AABB::NIL = AABB(0, 0);
const AABB AABB::MIN = AABB(-1, -1, -1, 1, 1, 1);
@ -15,14 +18,6 @@ const AABB AABB::MAX = AABB(HUGE_VALF, -HUGE_VALF);
// ------------------------------------------------------------------------------------------------
SQChar AABB::Delim = ',';
// ------------------------------------------------------------------------------------------------
SQInteger AABB::Typename(HSQUIRRELVM vm)
{
static const SQChar name[] = _SC("AABB");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
// ------------------------------------------------------------------------------------------------
AABB::AABB()
: min(HUGE_VALF), max(-HUGE_VALF)
@ -822,7 +817,7 @@ void Register_AABB(HSQUIRRELVM vm)
{
typedef AABB::Value Val;
RootTable(vm).Bind(_SC("AABB"), Class< AABB >(vm, _SC("AABB"))
RootTable(vm).Bind(Typename::Str, Class< AABB >(vm, Typename::Str)
// Constructors
.Ctor()
.Ctor< const AABB & >()
@ -835,10 +830,9 @@ void Register_AABB(HSQUIRRELVM vm)
.Var(_SC("Min"), &AABB::min)
.Var(_SC("Max"), &AABB::max)
// Core Meta-methods
.Func(_SC("_tostring"), &AABB::ToString)
.SquirrelFunc(_SC("_typename"), &AABB::Typename)
// We cannot set _cmp for c++ classes so we use this instead
.SquirrelFunc(_SC("cmp"), &SqDynArgFwd< SqDynArgCmpFn< AABB >, SQFloat, SQInteger, bool, std::nullptr_t, AABB >)
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
.Func(_SC("_tostring"), &AABB::ToString)
// Meta-methods
.SquirrelFunc(_SC("_add"), &SqDynArgFwd< SqDynArgAddFn< AABB >, SQFloat, SQInteger, bool, std::nullptr_t, AABB >)
.SquirrelFunc(_SC("_sub"), &SqDynArgFwd< SqDynArgSubFn< AABB >, SQFloat, SQInteger, bool, std::nullptr_t, AABB >)

View File

@ -297,11 +297,6 @@ struct AABB
*/
CSStr ToString() const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to retrieve the name from instances of this type.
*/
static SQInteger Typename(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Set the values extracted from the specified string using the specified delimiter.
*/