diff --git a/module/Core/Common.cpp b/module/Core/Common.cpp index b3a92763..55002bac 100644 --- a/module/Core/Common.cpp +++ b/module/Core/Common.cpp @@ -248,6 +248,14 @@ String SqTypeName(HSQUIRRELVM vm, SQInteger idx) return String(val.mPtr, static_cast< size_t >(val.mLen)); } +// ------------------------------------------------------------------------------------------------ +String SqTypeName(HSQUIRRELVM vm, LightObj & obj) +{ + const StackGuard sg(vm); + sq_pushobject(vm, obj); + return SqTypeName(vm, -1); +} + // ------------------------------------------------------------------------------------------------ LightObj BufferToStrObj(const Buffer & b) { diff --git a/module/Core/Common.hpp b/module/Core/Common.hpp index 531060bd..15083510 100644 --- a/module/Core/Common.hpp +++ b/module/Core/Common.hpp @@ -242,6 +242,11 @@ SQMOD_NODISCARD const SQChar * SqTypeName(SQObjectType type); */ SQMOD_NODISCARD String SqTypeName(HSQUIRRELVM vm, SQInteger idx); +/* ------------------------------------------------------------------------------------------------ + * Retrieve the string representation of a certain type from a script object. +*/ +SQMOD_NODISCARD String SqTypeName(HSQUIRRELVM vm, LightObj & obj); + /* ------------------------------------------------------------------------------------------------ * Create a script string instance from a buffer. */