aboutsummaryrefslogtreecommitdiff
path: root/src/compat.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/compat.h')
-rw-r--r--src/compat.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/compat.h b/src/compat.h
index bc8b165..e0a2e6f 100644
--- a/src/compat.h
+++ b/src/compat.h
@@ -357,7 +357,7 @@ inline void luaG_setmetatable(lua_State* const L_, std::string_view const& tname
357 357
358// a small helper to extract a full userdata pointer from the stack in a safe way 358// a small helper to extract a full userdata pointer from the stack in a safe way
359template <typename T> 359template <typename T>
360[[nodiscard]] T* luaG_tofulluserdata(lua_State* L_, int index_) 360[[nodiscard]] T* luaG_tofulluserdata(lua_State* const L_, int const index_)
361{ 361{
362 LUA_ASSERT(L_, lua_isnil(L_, index_) || lua_type(L_, index_) == LUA_TUSERDATA); 362 LUA_ASSERT(L_, lua_isnil(L_, index_) || lua_type(L_, index_) == LUA_TUSERDATA);
363 return static_cast<T*>(lua_touserdata(L_, index_)); 363 return static_cast<T*>(lua_touserdata(L_, index_));
@@ -366,7 +366,7 @@ template <typename T>
366// ------------------------------------------------------------------------------------------------- 366// -------------------------------------------------------------------------------------------------
367 367
368template <typename T> 368template <typename T>
369[[nodiscard]] auto luaG_tolightuserdata(lua_State* L_, int index_) 369[[nodiscard]] auto luaG_tolightuserdata(lua_State* const L_, int const index_)
370{ 370{
371 LUA_ASSERT(L_, lua_isnil(L_, index_) || lua_islightuserdata(L_, index_)); 371 LUA_ASSERT(L_, lua_isnil(L_, index_) || lua_islightuserdata(L_, index_));
372 if constexpr (std::is_pointer_v<T>) { 372 if constexpr (std::is_pointer_v<T>) {
@@ -378,11 +378,18 @@ template <typename T>
378 378
379// ------------------------------------------------------------------------------------------------- 379// -------------------------------------------------------------------------------------------------
380 380
381inline char const* luaG_typename(lua_State* L_, LuaType t_) 381[[nodiscard]] inline std::string_view luaG_typename(lua_State* const L_, LuaType const t_)
382{ 382{
383 return lua_typename(L_, static_cast<int>(t_)); 383 return lua_typename(L_, static_cast<int>(t_));
384} 384}
385 385
386// -------------------------------------------------------------------------------------------------
387
388[[nodiscard]] inline std::string_view luaG_typename(lua_State* const L_, int const idx_)
389{
390 return luaG_typename(L_, luaG_type(L_, idx_));
391}
392
386// ################################################################################################# 393// #################################################################################################
387 394
388// must keep as a macro as long as we do constant string concatenations 395// must keep as a macro as long as we do constant string concatenations