From 5afe1f8127a01addb3ebbcb601c460b9ba388d09 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Tue, 15 Nov 2016 21:21:07 +0200 Subject: [PATCH] Implement the pure typename meta-methods in Vector2i type using the standard method. --- source/Base/Vector2i.cpp | 17 ++++++----------- source/Base/Vector2i.hpp | 5 ----- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/source/Base/Vector2i.cpp b/source/Base/Vector2i.cpp index e3679be0..57ee9ec6 100644 --- a/source/Base/Vector2i.cpp +++ b/source/Base/Vector2i.cpp @@ -11,6 +11,9 @@ // ------------------------------------------------------------------------------------------------ namespace SqMod { +// ------------------------------------------------------------------------------------------------ +SQMODE_DECL_TYPENAME(Typename, _SC("Vector2i")) + // ------------------------------------------------------------------------------------------------ const Vector2i Vector2i::NIL = Vector2i(0); const Vector2i Vector2i::MIN = Vector2i(std::numeric_limits< Vector2i::Value >::min()); @@ -19,14 +22,6 @@ const Vector2i Vector2i::MAX = Vector2i(std::numeric_limits< Vector2i::Value >:: // ------------------------------------------------------------------------------------------------ SQChar Vector2i::Delim = ','; -// ------------------------------------------------------------------------------------------------ -SQInteger Vector2i::Typename(HSQUIRRELVM vm) -{ - static const SQChar name[] = _SC("Vector2i"); - sq_pushstring(vm, name, sizeof(name)); - return 1; -} - // ------------------------------------------------------------------------------------------------ Vector2i::Vector2i() : x(0), y(0) @@ -597,7 +592,7 @@ void Register_Vector2i(HSQUIRRELVM vm) { typedef Vector2i::Value Val; - RootTable(vm).Bind(_SC("Vector2i"), Class< Vector2i >(vm, _SC("Vector2i")) + RootTable(vm).Bind(Typename::Str, Class< Vector2i >(vm, Typename::Str) // Constructors .Ctor() .Ctor< Val >() @@ -608,9 +603,9 @@ void Register_Vector2i(HSQUIRRELVM vm) .Var(_SC("X"), &Vector2i::x) .Var(_SC("Y"), &Vector2i::y) // Core Meta-methods - .Func(_SC("_tostring"), &Vector2i::ToString) - .SquirrelFunc(_SC("_typename"), &Vector2i::Typename) .SquirrelFunc(_SC("cmp"), &SqDynArgFwd< SqDynArgCmpFn< Vector2i >, SQFloat, SQInteger, bool, std::nullptr_t, Vector2i >) + .SquirrelFunc(_SC("_typename"), &Typename::Fn) + .Func(_SC("_tostring"), &Vector2i::ToString) // Meta-methods .SquirrelFunc(_SC("_add"), &SqDynArgFwd< SqDynArgAddFn< Vector2i >, SQFloat, SQInteger, bool, std::nullptr_t, Vector2i >) .SquirrelFunc(_SC("_sub"), &SqDynArgFwd< SqDynArgSubFn< Vector2i >, SQFloat, SQInteger, bool, std::nullptr_t, Vector2i >) diff --git a/source/Base/Vector2i.hpp b/source/Base/Vector2i.hpp index b21b78ad..9fd2363e 100644 --- a/source/Base/Vector2i.hpp +++ b/source/Base/Vector2i.hpp @@ -396,11 +396,6 @@ struct Vector2i */ 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. */