1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-02-21 20:27:13 +01:00

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

This commit is contained in:
Sandu Liviu Catalin 2016-11-15 21:42:27 +02:00
parent e562f06948
commit 7fde39fb6d
2 changed files with 6 additions and 16 deletions

View File

@ -33,6 +33,9 @@ namespace SqMod {
typedef CharT PChar; typedef CharT PChar;
#endif // SQMOD_OS_WINDOWS #endif // SQMOD_OS_WINDOWS
// ------------------------------------------------------------------------------------------------
SQMODE_DECL_TYPENAME(Typename, _SC("SqSysPath"))
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Buffer GetRealFilePath(CSStr path) Buffer GetRealFilePath(CSStr path)
{ {
@ -76,14 +79,6 @@ Buffer GetRealFilePath(CSStr path)
return std::move(b); 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() SysPath::SysPath()
: m_Dirs() : m_Dirs()
@ -1719,14 +1714,14 @@ SysPath SysPath::MakeDynamic(CSStr path)
// ================================================================================================ // ================================================================================================
void Register_SysPath(HSQUIRRELVM vm) void Register_SysPath(HSQUIRRELVM vm)
{ {
RootTable(vm).Bind("SqSysPath", Class< SysPath >(vm, "SqSysPath") RootTable(vm).Bind(Typename::Str, Class< SysPath >(vm, Typename::Str)
// Constructors // Constructors
.Ctor() .Ctor()
.Ctor< CSStr >() .Ctor< CSStr >()
.Ctor< CSStr, Int32 >() .Ctor< CSStr, Int32 >()
// Meta-methods // Meta-methods
.Func(_SC("_cmp"), &SysPath::Cmp) .SquirrelFunc(_SC("_typename"), &Typename::Fn)
.SquirrelFunc(_SC("_typename"), &SysPath::Typename) .Func(_SC("cmp"), &SysPath::Cmp)
.Func(_SC("_tostring"), &SysPath::ToString) .Func(_SC("_tostring"), &SysPath::ToString)
// Properties // Properties
.Prop(_SC("String"), &SysPath::ToString, &SysPath::FromString) .Prop(_SC("String"), &SysPath::ToString, &SysPath::FromString)

View File

@ -165,11 +165,6 @@ public:
*/ */
Object ToString() const; 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. * Swaps the path with another one.
*/ */