19#if SIZE_T_AND_UNSIGNED_INT_ARE_DIFFERENT_TYPES
26 lua_pushlstring(l, value.c_str(), value.size());
30 lua_pushlstring(l, value.data(), value.size());
35inline void pi_lua_generic_pull(lua_State *l,
int index,
int &out) { out = luaL_checkinteger(l, index); }
36inline void pi_lua_generic_pull(lua_State *l,
int index, int64_t &out) { out = luaL_checkinteger(l, index); }
37inline void pi_lua_generic_pull(lua_State *l,
int index,
unsigned int &out) { out = luaL_checkunsigned(l, index); }
38#if SIZE_T_AND_UNSIGNED_INT_ARE_DIFFERENT_TYPES
39inline void pi_lua_generic_pull(lua_State *l,
int index,
size_t &out) { out = luaL_checkunsigned(l, index); }
41inline void pi_lua_generic_pull(lua_State *l,
int index,
float &out) { out = luaL_checknumber(l, index); }
42inline void pi_lua_generic_pull(lua_State *l,
int index,
double &out) { out = luaL_checknumber(l, index); }
43inline void pi_lua_generic_pull(lua_State *l,
int index,
const char *&out) { out = luaL_checkstring(l, index); }
47 const char *buf = luaL_checklstring(l, index, &len);
48 std::string(buf, len).swap(out);
54 const char *buf = luaL_checklstring(l, index, &len);
58template <
typename Type>
59inline void LuaPush(lua_State *l, Type value)
64template <
typename Type>
65inline std::remove_reference_t<Type>
LuaPull(lua_State *l,
int index)
67 std::decay_t<Type> value;
73template <
typename Type>
74inline Type
LuaPull(lua_State *l,
int index, Type defaultVal)
76 Type value = defaultVal;
77 if (lua_gettop(l) >= index && !lua_isnil(l, index))
84 if (lua_type(l, index) == LUA_TBOOLEAN) {
85 out = lua_toboolean(l, index);
92 if (lua_type(l, index) == LUA_TNUMBER) {
93 out = lua_tointeger(l, index);
100 if (lua_type(l, index) == LUA_TNUMBER) {
101 out = lua_tonumber(l, index);
108 if (lua_type(l, index) == LUA_TNUMBER) {
109 out = lua_tonumber(l, index);
116 if (lua_type(l, index) == LUA_TSTRING) {
117 out = lua_tostring(l, index);
124 if (lua_type(l, index) == LUA_TSTRING) {
126 const char *buf = lua_tolstring(l, index, &len);
127 std::string(buf, len).swap(out);
132template <
typename... Types>
136template <
typename Arg1>
142template <
typename Arg1,
typename Arg2>
149template <
typename Arg1,
typename Arg2,
typename Arg3>
157template <
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4>
166template <
typename Head,
typename... Tail>
180template <
typename Arg1,
typename Arg2>
183 beg = lua_absindex(l, beg);
188 return std::make_tuple(arg1, arg2);
190template <
typename Arg1,
typename Arg2,
typename Arg3>
193 beg = lua_absindex(l, beg);
200 return std::make_tuple(arg1, arg2, arg3);
202template <
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4>
205 beg = lua_absindex(l, beg);
214 return std::make_tuple(arg1, arg2, arg3, arg4);
219template <
int _bogus,
typename Head,
typename... Tail>
222 beg = lua_absindex(l, beg);
226 std::tuple<Head> first(hd);
227 return std::tuple_cat(first, rest);
233 return std::tuple<>();
236template <
typename... Types>
void LuaPush(lua_State *l, Type value)
Definition LuaPushPull.h:59
bool pi_lua_strict_pull(lua_State *l, int index, bool &out)
Definition LuaPushPull.h:82
std::tuple< Head, Tail... > __helper_pi_lua_multiple_pull(lua_State *l, int beg)
Definition LuaPushPull.h:220
std::tuple< Types... > pi_lua_multiple_pull(lua_State *l, int beg)
Definition LuaPushPull.h:237
std::remove_reference_t< Type > LuaPull(lua_State *l, int index)
Definition LuaPushPull.h:65
void pi_lua_multiple_push(lua_State *l, Types... args)
void pi_lua_generic_push(lua_State *l, bool value)
Definition LuaPushPull.h:15
void pi_lua_generic_pull(lua_State *l, int index, bool &out)
Definition LuaPushPull.h:34