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 Vector2 type using the standard method.
This commit is contained in:
parent
0f2967aa05
commit
b2d003424e
@ -11,6 +11,9 @@
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace SqMod {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQMODE_DECL_TYPENAME(Typename, _SC("Vector2"))
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
const Vector2 Vector2::NIL = Vector2(0);
|
||||
const Vector2 Vector2::MIN = Vector2(std::numeric_limits< Vector2::Value >::min());
|
||||
@ -19,14 +22,6 @@ const Vector2 Vector2::MAX = Vector2(std::numeric_limits< Vector2::Value >::max(
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQChar Vector2::Delim = ',';
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
SQInteger Vector2::Typename(HSQUIRRELVM vm)
|
||||
{
|
||||
static const SQChar name[] = _SC("Vector2");
|
||||
sq_pushstring(vm, name, sizeof(name));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
Vector2::Vector2()
|
||||
: x(0.0), y(0.0)
|
||||
@ -451,7 +446,7 @@ void Register_Vector2(HSQUIRRELVM vm)
|
||||
{
|
||||
typedef Vector2::Value Val;
|
||||
|
||||
RootTable(vm).Bind(_SC("Vector2"), Class< Vector2 >(vm, _SC("Vector2"))
|
||||
RootTable(vm).Bind(Typename::Str, Class< Vector2 >(vm, Typename::Str)
|
||||
// Constructors
|
||||
.Ctor()
|
||||
.Ctor< Val >()
|
||||
@ -462,9 +457,9 @@ void Register_Vector2(HSQUIRRELVM vm)
|
||||
.Var(_SC("X"), &Vector2::x)
|
||||
.Var(_SC("Y"), &Vector2::y)
|
||||
// Core Meta-methods
|
||||
.Func(_SC("_tostring"), &Vector2::ToString)
|
||||
.SquirrelFunc(_SC("_typename"), &Vector2::Typename)
|
||||
.SquirrelFunc(_SC("cmp"), &SqDynArgFwd< SqDynArgCmpFn< Vector2 >, SQFloat, SQInteger, bool, std::nullptr_t, Vector2 >)
|
||||
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
|
||||
.Func(_SC("_tostring"), &Vector2::ToString)
|
||||
// Meta-methods
|
||||
.SquirrelFunc(_SC("_add"), &SqDynArgFwd< SqDynArgAddFn< Vector2 >, SQFloat, SQInteger, bool, std::nullptr_t, Vector2 >)
|
||||
.SquirrelFunc(_SC("_sub"), &SqDynArgFwd< SqDynArgSubFn< Vector2 >, SQFloat, SQInteger, bool, std::nullptr_t, Vector2 >)
|
||||
|
@ -291,11 +291,6 @@ struct Vector2
|
||||
*/
|
||||
CSStr ToString() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Used by the script engine to retrieve the name from instances of this type.
|
||||
*/
|
||||
static SQInteger Typename(HSQUIRRELVM vm);
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Set all components to the specified scalar value.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user