From 7fde39fb6d8755eee6de479aa286b5a0723e53d6 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Tue, 15 Nov 2016 21:42:27 +0200 Subject: [PATCH] Implement the pure typename meta-methods in system path type using the standard method. --- source/Library/System/Path.cpp | 17 ++++++----------- source/Library/System/Path.hpp | 5 ----- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/source/Library/System/Path.cpp b/source/Library/System/Path.cpp index 17d2fc1d..8635ddc1 100644 --- a/source/Library/System/Path.cpp +++ b/source/Library/System/Path.cpp @@ -33,6 +33,9 @@ namespace SqMod { typedef CharT PChar; #endif // SQMOD_OS_WINDOWS +// ------------------------------------------------------------------------------------------------ +SQMODE_DECL_TYPENAME(Typename, _SC("SqSysPath")) + // ------------------------------------------------------------------------------------------------ Buffer GetRealFilePath(CSStr path) { @@ -76,14 +79,6 @@ Buffer GetRealFilePath(CSStr path) return std::move(b); } -// ------------------------------------------------------------------------------------------------ -SQInteger SysPath::Typename(HSQUIRRELVM vm) -{ - static const SQChar name[] = _SC("SqSysPath"); - sq_pushstring(vm, name, sizeof(name)); - return 1; -} - // ------------------------------------------------------------------------------------------------ SysPath::SysPath() : m_Dirs() @@ -1719,14 +1714,14 @@ SysPath SysPath::MakeDynamic(CSStr path) // ================================================================================================ void Register_SysPath(HSQUIRRELVM vm) { - RootTable(vm).Bind("SqSysPath", Class< SysPath >(vm, "SqSysPath") + RootTable(vm).Bind(Typename::Str, Class< SysPath >(vm, Typename::Str) // Constructors .Ctor() .Ctor< CSStr >() .Ctor< CSStr, Int32 >() // Meta-methods - .Func(_SC("_cmp"), &SysPath::Cmp) - .SquirrelFunc(_SC("_typename"), &SysPath::Typename) + .SquirrelFunc(_SC("_typename"), &Typename::Fn) + .Func(_SC("cmp"), &SysPath::Cmp) .Func(_SC("_tostring"), &SysPath::ToString) // Properties .Prop(_SC("String"), &SysPath::ToString, &SysPath::FromString) diff --git a/source/Library/System/Path.hpp b/source/Library/System/Path.hpp index 80142a1a..88c1a1f0 100644 --- a/source/Library/System/Path.hpp +++ b/source/Library/System/Path.hpp @@ -165,11 +165,6 @@ public: */ Object ToString() const; - /* -------------------------------------------------------------------------------------------- - * Used by the script engine to retrieve the name from instances of this type. - */ - static SQInteger Typename(HSQUIRRELVM vm); - /* -------------------------------------------------------------------------------------------- * Swaps the path with another one. */