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 Sphere type using the standard method.

This commit is contained in:
Sandu Liviu Catalin 2016-11-15 21:24:39 +02:00
parent f3a485177b
commit f18d4c948a
2 changed files with 8 additions and 18 deletions

View File

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

View File

@ -343,11 +343,6 @@ struct Sphere
*/
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.
*/
@ -430,4 +425,4 @@ struct Sphere
} // Namespace:: SqMod
#endif // _BASE_SPHERE_HPP_
#endif // _BASE_SPHERE_HPP_