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());
34 inline void pi_lua_generic_pull(lua_State *l,
int index,
bool &out) { out = lua_toboolean(l, index); }
35 inline void pi_lua_generic_pull(lua_State *l,
int index,
int &out) { out = luaL_checkinteger(l, index); }
36 inline void pi_lua_generic_pull(lua_State *l,
int index, int64_t &out) { out = luaL_checkinteger(l, index); }
37 inline 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
39 inline void pi_lua_generic_pull(lua_State *l,
int index,
size_t &out) { out = luaL_checkunsigned(l, index); }
41 inline void pi_lua_generic_pull(lua_State *l,
int index,
float &out) { out = luaL_checknumber(l, index); }
42 inline void pi_lua_generic_pull(lua_State *l,
int index,
double &out) { out = luaL_checknumber(l, index); }
43 inline 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);
58 template <
typename Type>
59 inline void LuaPush(lua_State *l, Type value)
64 template <
typename Type>
65 inline std::remove_reference_t<Type>
LuaPull(lua_State *l,
int index)
67 std::decay_t<Type> value;
73 template <
typename Type>
74 inline 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);
132 template <
typename... Types>
135 #if defined(_MSC_VER)
136 template <
typename Arg1>
142 template <
typename Arg1,
typename Arg2>
149 template <
typename Arg1,
typename Arg2,
typename Arg3>
157 template <
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4>
166 template <
typename Head,
typename... Tail>
179 #if defined(_MSC_VER)
180 template <
typename Arg1,
typename Arg2>
183 beg = lua_absindex(l, beg);
188 return std::make_tuple(arg1, arg2);
190 template <
typename Arg1,
typename Arg2,
typename Arg3>
193 beg = lua_absindex(l, beg);
200 return std::make_tuple(arg1, arg2, arg3);
202 template <
typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4>
205 beg = lua_absindex(l, beg);
214 return std::make_tuple(arg1, arg2, arg3, arg4);
219 template <
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);
230 template <
int _bogus>
233 return std::tuple<>();
236 template <
typename... Types>
void LuaPush(lua_State *l, Type value)
Definition: LuaPushPull.h:59
std::tuple< Head, Tail... > __helper_pi_lua_multiple_pull(lua_State *l, int beg)
Definition: LuaPushPull.h:220
bool pi_lua_strict_pull(lua_State *l, int index, bool &out)
Definition: LuaPushPull.h:82
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