diff options
Diffstat (limited to '')
-rw-r--r-- | src/compat.hpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/compat.hpp b/src/compat.hpp index d864ae9..9a8dedf 100644 --- a/src/compat.hpp +++ b/src/compat.hpp | |||
@@ -271,6 +271,7 @@ static inline int WrapLuaGetField(LUA_GETFIELD f_, lua_State* const L_, StackInd | |||
271 | 271 | ||
272 | // ------------------------------------------------------------------------------------------------- | 272 | // ------------------------------------------------------------------------------------------------- |
273 | 273 | ||
274 | [[nodiscard]] | ||
274 | static inline LuaType luaG_getfield(lua_State* const L_, StackIndex const idx_, std::string_view const& name_) | 275 | static inline LuaType luaG_getfield(lua_State* const L_, StackIndex const idx_, std::string_view const& name_) |
275 | { | 276 | { |
276 | return static_cast<LuaType>(WrapLuaGetField(lua_getfield, L_, idx_, name_)); | 277 | return static_cast<LuaType>(WrapLuaGetField(lua_getfield, L_, idx_, name_)); |
@@ -278,6 +279,7 @@ static inline LuaType luaG_getfield(lua_State* const L_, StackIndex const idx_, | |||
278 | 279 | ||
279 | // ################################################################################################# | 280 | // ################################################################################################# |
280 | 281 | ||
282 | [[nodiscard]] | ||
281 | LuaType luaG_getmodule(lua_State* L_, std::string_view const& name_); | 283 | LuaType luaG_getmodule(lua_State* L_, std::string_view const& name_); |
282 | 284 | ||
283 | // ################################################################################################# | 285 | // ################################################################################################# |
@@ -350,6 +352,7 @@ static inline int WrapLuaResume(LUA_RESUME const lua_resume_, lua_State* const L | |||
350 | 352 | ||
351 | // ------------------------------------------------------------------------------------------------- | 353 | // ------------------------------------------------------------------------------------------------- |
352 | 354 | ||
355 | [[nodiscard]] | ||
353 | static inline LuaError luaG_resume(lua_State* const L_, lua_State* const from_, int const nargs_, int* const nresults_) | 356 | static inline LuaError luaG_resume(lua_State* const L_, lua_State* const from_, int const nargs_, int* const nresults_) |
354 | { | 357 | { |
355 | return ToLuaError(WrapLuaResume(lua_resume, L_, from_, nargs_, nresults_)); | 358 | return ToLuaError(WrapLuaResume(lua_resume, L_, from_, nargs_, nresults_)); |
@@ -357,6 +360,38 @@ static inline LuaError luaG_resume(lua_State* const L_, lua_State* const from_, | |||
357 | 360 | ||
358 | // ################################################################################################# | 361 | // ################################################################################################# |
359 | 362 | ||
363 | template <typename LUA_RAWGET> | ||
364 | concept RequiresOldLuaRawget = requires(LUA_RAWGET f_) { { f_(nullptr, 0) } -> std::same_as<void>; }; | ||
365 | |||
366 | template <RequiresOldLuaRawget LUA_RAWGET> | ||
367 | static inline LuaType WrapLuaRawget(LUA_RAWGET lua_rawget_, lua_State* const L_, StackIndex const idx_) | ||
368 | { | ||
369 | // until Lua 5.3, lua_rawget -> void | ||
370 | lua_rawget_(L_, idx_); | ||
371 | return luaG_type(L_, kIdxTop); | ||
372 | } | ||
373 | |||
374 | // ------------------------------------------------------------------------------------------------- | ||
375 | |||
376 | template <typename LUA_RAWGET> | ||
377 | concept RequiresNewLuaRawget = requires(LUA_RAWGET f_) { { f_(nullptr, 0) } -> std::same_as<int>; }; | ||
378 | |||
379 | template <RequiresNewLuaRawget LUA_RAWGET> | ||
380 | static inline LuaType WrapLuaRawget(LUA_RAWGET lua_rawget_, lua_State* const L_, StackIndex const idx_) | ||
381 | { | ||
382 | // starting with Lua 5.3, lua_rawget -> int (the type of the extracted value) | ||
383 | return static_cast<LuaType>(lua_rawget_(L_, idx_)); | ||
384 | } | ||
385 | |||
386 | // ------------------------------------------------------------------------------------------------- | ||
387 | |||
388 | static inline LuaType luaG_rawget(lua_State* const L_, StackIndex const idx_) | ||
389 | { | ||
390 | return WrapLuaRawget(lua_rawget, L_, idx_); | ||
391 | } | ||
392 | |||
393 | // ################################################################################################# | ||
394 | |||
360 | static inline LuaType luaG_rawgetfield(lua_State* const L_, StackIndex const idx_, std::string_view const& name_) | 395 | static inline LuaType luaG_rawgetfield(lua_State* const L_, StackIndex const idx_, std::string_view const& name_) |
361 | { | 396 | { |
362 | auto const _absIdx{ luaG_absindex(L_, idx_) }; | 397 | auto const _absIdx{ luaG_absindex(L_, idx_) }; |