aboutsummaryrefslogtreecommitdiff
path: root/src/compat.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/compat.h')
-rw-r--r--src/compat.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/compat.h b/src/compat.h
index 0e95cde..3fb4e2d 100644
--- a/src/compat.h
+++ b/src/compat.h
@@ -25,6 +25,7 @@ extern "C"
25#endif // LUA_JITLIBNAME 25#endif // LUA_JITLIBNAME
26 26
27#include <cassert> 27#include <cassert>
28#include <string_view>
28 29
29// code is now preferring Lua 5.4 API 30// code is now preferring Lua 5.4 API
30 31
@@ -249,3 +250,13 @@ inline constexpr LuaError ToLuaError(int rc_)
249// ################################################################################################# 250// #################################################################################################
250 251
251LuaType luaG_getmodule(lua_State* L_, char const* name_); 252LuaType luaG_getmodule(lua_State* L_, char const* name_);
253
254// #################################################################################################
255
256// a replacement of lua_tolstring
257inline std::string_view lua_tostringview(lua_State* L_, int idx_)
258{
259 size_t _len{ 0 };
260 char const* _str{ lua_tolstring(L_, idx_, &_len) };
261 return std::string_view{ _str, _len };
262}