1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

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

This commit is contained in:
Sandu Liviu Catalin 2016-11-15 21:21:15 +02:00
parent 2cce140e1b
commit 8d5efe524e
2 changed files with 6 additions and 16 deletions

View File

@ -10,6 +10,9 @@
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
SQMODE_DECL_TYPENAME(Typename, _SC("Circle"))
// ------------------------------------------------------------------------------------------------
const Circle Circle::NIL = Circle();
const Circle Circle::MIN = Circle(0.0);
@ -18,14 +21,6 @@ const Circle Circle::MAX = Circle(std::numeric_limits< Circle::Value >::max());
// ------------------------------------------------------------------------------------------------
SQChar Circle::Delim = ',';
// ------------------------------------------------------------------------------------------------
SQInteger Circle::Typename(HSQUIRRELVM vm)
{
static const SQChar name[] = _SC("Circle");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
// ------------------------------------------------------------------------------------------------
Circle::Circle()
: pos(0.0, 0.0), rad(0.0)
@ -545,7 +540,7 @@ void Register_Circle(HSQUIRRELVM vm)
{
typedef Circle::Value Val;
RootTable(vm).Bind(_SC("Circle"), Class< Circle >(vm, _SC("Circle"))
RootTable(vm).Bind(Typename::Str, Class< Circle >(vm, Typename::Str)
// Constructors
.Ctor()
.Ctor< Val >()
@ -557,9 +552,9 @@ void Register_Circle(HSQUIRRELVM vm)
.Var(_SC("Pos"), &Circle::pos)
.Var(_SC("Rad"), &Circle::rad)
// Core Meta-methods
.Func(_SC("_tostring"), &Circle::ToString)
.SquirrelFunc(_SC("_typename"), &Circle::Typename)
.SquirrelFunc(_SC("cmp"), &SqDynArgFwd< SqDynArgCmpFn< Circle >, SQFloat, SQInteger, bool, std::nullptr_t, Circle >)
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
.Func(_SC("_tostring"), &Circle::ToString)
// Meta-methods
.SquirrelFunc(_SC("_add"), &SqDynArgFwd< SqDynArgAddFn< Circle >, SQFloat, SQInteger, bool, std::nullptr_t, Circle >)
.SquirrelFunc(_SC("_sub"), &SqDynArgFwd< SqDynArgSubFn< Circle >, SQFloat, SQInteger, bool, std::nullptr_t, Circle >)

View File

@ -343,11 +343,6 @@ struct Circle
*/
CSStr ToString() const;
/* --------------------------------------------------------------------------------------------
* Used by the script engine to retrieve the name from instances of this type.
*/
static SQInteger Typename(HSQUIRRELVM vm);
/* --------------------------------------------------------------------------------------------
* Set the specified radius.
*/