mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-02-21 12:17:12 +01:00
Implement the pure typename meta-methods in Sphere type using the standard method.
This commit is contained in:
parent
f3a485177b
commit
f18d4c948a
@ -10,6 +10,9 @@
|
|||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
namespace SqMod {
|
namespace SqMod {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
SQMODE_DECL_TYPENAME(Typename, _SC("Sphere"))
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
const Sphere Sphere::NIL = Sphere();
|
const Sphere Sphere::NIL = Sphere();
|
||||||
const Sphere Sphere::MIN = Sphere(0.0);
|
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 = ',';
|
SQChar Sphere::Delim = ',';
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
|
||||||
SQInteger Sphere::Typename(HSQUIRRELVM vm)
|
|
||||||
{
|
|
||||||
static const SQChar name[] = _SC("Sphere");
|
|
||||||
sq_pushstring(vm, name, sizeof(name));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
Sphere::Sphere()
|
Sphere::Sphere()
|
||||||
: pos(0.0), rad(0.0)
|
: pos(0.0), rad(0.0)
|
||||||
@ -546,7 +541,7 @@ void Register_Sphere(HSQUIRRELVM vm)
|
|||||||
{
|
{
|
||||||
typedef Sphere::Value Val;
|
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
|
// Constructors
|
||||||
.Ctor()
|
.Ctor()
|
||||||
.Ctor< Val >()
|
.Ctor< Val >()
|
||||||
@ -558,9 +553,9 @@ void Register_Sphere(HSQUIRRELVM vm)
|
|||||||
.Var(_SC("Pos"), &Sphere::pos)
|
.Var(_SC("Pos"), &Sphere::pos)
|
||||||
.Var(_SC("Rad"), &Sphere::rad)
|
.Var(_SC("Rad"), &Sphere::rad)
|
||||||
// Core Meta-methods
|
// 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("cmp"), &SqDynArgFwd< SqDynArgCmpFn< Sphere >, SQFloat, SQInteger, bool, std::nullptr_t, Sphere >)
|
||||||
|
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
|
||||||
|
.Func(_SC("_tostring"), &Sphere::ToString)
|
||||||
// Meta-methods
|
// Meta-methods
|
||||||
.SquirrelFunc(_SC("_add"), &SqDynArgFwd< SqDynArgAddFn< Sphere >, SQFloat, SQInteger, bool, std::nullptr_t, Sphere >)
|
.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 >)
|
.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
|
@ -343,11 +343,6 @@ struct Sphere
|
|||||||
*/
|
*/
|
||||||
CSStr ToString() const;
|
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.
|
* Set the specified radius.
|
||||||
*/
|
*/
|
||||||
@ -430,4 +425,4 @@ struct Sphere
|
|||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
|
|
||||||
#endif // _BASE_SPHERE_HPP_
|
#endif // _BASE_SPHERE_HPP_
|
Loading…
x
Reference in New Issue
Block a user