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

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

This commit is contained in:
Sandu Liviu Catalin 2016-11-15 21:21:07 +02:00
parent b2d003424e
commit 5afe1f8127
2 changed files with 6 additions and 16 deletions

View File

@ -11,6 +11,9 @@
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
namespace SqMod { namespace SqMod {
// ------------------------------------------------------------------------------------------------
SQMODE_DECL_TYPENAME(Typename, _SC("Vector2i"))
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
const Vector2i Vector2i::NIL = Vector2i(0); const Vector2i Vector2i::NIL = Vector2i(0);
const Vector2i Vector2i::MIN = Vector2i(std::numeric_limits< Vector2i::Value >::min()); 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 = ','; SQChar Vector2i::Delim = ',';
// ------------------------------------------------------------------------------------------------
SQInteger Vector2i::Typename(HSQUIRRELVM vm)
{
static const SQChar name[] = _SC("Vector2i");
sq_pushstring(vm, name, sizeof(name));
return 1;
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Vector2i::Vector2i() Vector2i::Vector2i()
: x(0), y(0) : x(0), y(0)
@ -597,7 +592,7 @@ void Register_Vector2i(HSQUIRRELVM vm)
{ {
typedef Vector2i::Value Val; 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 // Constructors
.Ctor() .Ctor()
.Ctor< Val >() .Ctor< Val >()
@ -608,9 +603,9 @@ void Register_Vector2i(HSQUIRRELVM vm)
.Var(_SC("X"), &Vector2i::x) .Var(_SC("X"), &Vector2i::x)
.Var(_SC("Y"), &Vector2i::y) .Var(_SC("Y"), &Vector2i::y)
// Core Meta-methods // 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("cmp"), &SqDynArgFwd< SqDynArgCmpFn< Vector2i >, SQFloat, SQInteger, bool, std::nullptr_t, Vector2i >)
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
.Func(_SC("_tostring"), &Vector2i::ToString)
// Meta-methods // Meta-methods
.SquirrelFunc(_SC("_add"), &SqDynArgFwd< SqDynArgAddFn< Vector2i >, SQFloat, SQInteger, bool, std::nullptr_t, Vector2i >) .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 >) .SquirrelFunc(_SC("_sub"), &SqDynArgFwd< SqDynArgSubFn< Vector2i >, SQFloat, SQInteger, bool, std::nullptr_t, Vector2i >)

View File

@ -396,11 +396,6 @@ struct Vector2i
*/ */
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 all components to the specified scalar value. * Set all components to the specified scalar value.
*/ */