1#ifndef CODEX_LUA_READER_H
2#define CODEX_LUA_READER_H
11template<std::
size_t N>
13 using T =
const char(&)[
N];
14 constexpr X(
T s_) :
s{s_} {}
20 std::cout <<
"number: " << lua_tonumber(L, -1) <<
'\n';
25 std::cout <<
"string: " << lua_tostring(L, -1) <<
'\n';
30 luaL_tolstring(L, -1,
nullptr);
31 std::cout << lua_tostring(L, -1) <<
'\n';
33 if(!lua_type(L, -1) == LUA_TTABLE)
34 std::cerr << __func__ <<
": invalid stack state\n";
42 std::cout <<
"table_key: " << k <<
'\n';
43 lua_pushlstring(L, k.data(), k.size());
49template<
typename T,
typename ...Ts>
52 constexpr types<Ts...> next = {};
53 if constexpr(std::derived_from<T, number_base>) {
56 }
else if constexpr(std::derived_from<T, string_base>) {
59 }
else if constexpr(std::same_as<T, table_begin>) {
62 }
else if constexpr(std::same_as<T, table_key>) {
65 }
else if constexpr(std::same_as<T, table_end>) {
#define T(f, T, C)
Definition bench.cpp:136
#define N
Definition queue_atomic.c:4
void read_table_key(lua_State *L, std::string_view k)
Definition reader.hpp:41
void read_number(lua_State *L)
Definition reader.hpp:19
void read_table_end(lua_State *L)
Definition reader.hpp:37
void read_table(lua_State *L)
Definition reader.hpp:29
void read(lua_State *, types<>)
Definition reader.hpp:47
void read_string(lua_State *L)
Definition reader.hpp:24
T s
Definition reader.hpp:16
constexpr X(T s_)
Definition reader.hpp:14
const char(&)[N] T
Definition reader.hpp:13
constexpr T operator--(void)
Definition reader.hpp:15
constexpr fixed_string s
Definition test.cpp:6