diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-07 09:51:45 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-07 09:51:45 +0200 |
commit | 57ca292c8844e566184e3f7e5c98fa98991684bd (patch) | |
tree | 9356cf33935ac4dc130cb71ba701d8d9c286597d /src/luaerrors.h | |
parent | 91a34bd09900967e8b9cccdbd6d94a9f8cc8506c (diff) | |
download | lanes-57ca292c8844e566184e3f7e5c98fa98991684bd.tar.gz lanes-57ca292c8844e566184e3f7e5c98fa98991684bd.tar.bz2 lanes-57ca292c8844e566184e3f7e5c98fa98991684bd.zip |
Reorganized debug stuff
Diffstat (limited to 'src/luaerrors.h')
-rw-r--r-- | src/luaerrors.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/luaerrors.h b/src/luaerrors.h new file mode 100644 index 0000000..9399427 --- /dev/null +++ b/src/luaerrors.h | |||
@@ -0,0 +1,57 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #ifdef __cplusplus | ||
4 | extern "C" | ||
5 | { | ||
6 | #endif // __cplusplus | ||
7 | #include "lua.h" | ||
8 | #include "lualib.h" | ||
9 | #include "lauxlib.h" | ||
10 | #ifdef __cplusplus | ||
11 | } | ||
12 | #endif // __cplusplus | ||
13 | |||
14 | #include <cassert> | ||
15 | #include <string_view> | ||
16 | #include <tuple> | ||
17 | |||
18 | // ################################################################################################# | ||
19 | |||
20 | // use this instead of Lua's lua_error | ||
21 | [[noreturn]] static inline void raise_lua_error(lua_State* const L_) | ||
22 | { | ||
23 | std::ignore = lua_error(L_); // doesn't return | ||
24 | assert(false); // we should never get here, but i'm paranoid | ||
25 | } | ||
26 | |||
27 | // ################################################################################################# | ||
28 | |||
29 | // use this instead of Lua's luaL_error | ||
30 | template <typename... ARGS> | ||
31 | [[noreturn]] static inline void raise_luaL_error(lua_State* const L_, std::string_view const& fmt_, ARGS... args_) | ||
32 | { | ||
33 | std::ignore = luaL_error(L_, fmt_.data(), std::forward<ARGS>(args_)...); // doesn't return | ||
34 | assert(false); // we should never get here, but i'm paranoid | ||
35 | } | ||
36 | |||
37 | // ################################################################################################# | ||
38 | |||
39 | // use this instead of Lua's luaL_argerror | ||
40 | template <typename... ARGS> | ||
41 | [[noreturn]] static inline void raise_luaL_argerror(lua_State* const L_, int const arg_, std::string_view const& extramsg_) | ||
42 | { | ||
43 | std::ignore = luaL_argerror(L_, arg_, extramsg_.data()); // doesn't return | ||
44 | assert(false); // we should never get here, but i'm paranoid | ||
45 | } | ||
46 | |||
47 | // ################################################################################################# | ||
48 | |||
49 | #if LUA_VERSION_NUM >= 504 | ||
50 | // use this instead of Lua's luaL_typeerror | ||
51 | template <typename... ARGS> | ||
52 | [[noreturn]] static inline void raise_luaL_typeerror(lua_State* const L_, int const arg_, std::string_view const& tname_) | ||
53 | { | ||
54 | std::ignore = luaL_typeerror(L_, arg_, tname_.data()); // doesn't return | ||
55 | assert(false); // we should never get here, but i'm paranoid | ||
56 | } | ||
57 | #endif // LUA_VERSION_NUM | ||