diff --git a/sol/function_result.hpp b/sol/function_result.hpp index 5a41ab9d..af55e5c7 100644 --- a/sol/function_result.hpp +++ b/sol/function_result.hpp @@ -63,7 +63,7 @@ public: } template - T get() const { + decltype(auto) get() const { return stack::get(L, index); } diff --git a/sol/stack.hpp b/sol/stack.hpp index 86c71e7c..ba2fca94 100644 --- a/sol/stack.hpp +++ b/sol/stack.hpp @@ -379,6 +379,13 @@ struct getter> { } }; +template +struct getter> { + static decltype(auto) get(lua_State* L, int index = -1) { + return std::pair(L, index)), decltype(stack::get(L, index))>(stack::get(L, index), stack::get(L, index + 1)); + } +}; + template struct checker { template @@ -487,6 +494,15 @@ struct popper> { } }; +template +struct popper> { + inline decltype(auto) pop(lua_State* L) { + decltype(auto) r = get>(L, lua_gettop(L) - 2 + 1); + lua_pop(L, 2); + return r; + } +}; + template struct pusher { template @@ -741,6 +757,16 @@ struct pusher> { } }; +template +struct pusher> { + template + static int push(lua_State* L, T&& t) { + int pushcount = stack::push(L, detail::forward_get<0>(t)); + pushcount += stack::push(L, detail::forward_get<1>(t)); + return pushcount; + } +}; + template struct field_getter { template @@ -766,6 +792,18 @@ struct field_getter, b, C> { } }; +template +struct field_getter, b, C> { + template + void apply(lua_State* L, Keys&& keys, int tableindex) { + get_field(L, detail::forward_get<0>(keys), tableindex); + get_field(L, detail::forward_get<1>(keys), tableindex); + reference saved(L, -1); + lua_pop(L, static_cast(2 + 1)); + saved.push(); + } +}; + template struct field_getter::value>> { template diff --git a/sol/types.hpp b/sol/types.hpp index c9fc88f4..52b45352 100644 --- a/sol/types.hpp +++ b/sol/types.hpp @@ -286,6 +286,9 @@ struct is_proxy_primitive> : std::true_type { }; template struct is_proxy_primitive> : std::true_type { }; +template +struct is_proxy_primitive> : std::true_type { }; + template struct is_unique_usertype : std::false_type {};