diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index 121e74b95..54e74f811 100644 --- a/single/sol/sol.hpp +++ b/single/sol/sol.hpp @@ -20,8 +20,8 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // This file was generated with a script. -// Generated 2016-09-22 16:13:14.308519 UTC -// This header was generated with sol v2.14.2 (revision dc000fb) +// Generated 2016-09-26 08:01:11.472268 UTC +// This header was generated with sol v2.14.2 (revision 63093ec) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -3005,6 +3005,12 @@ namespace sol { operator int() const { return index; } }; + struct raw_index { + int index; + raw_index(int i) : index(i) {} + operator int() const { return index; } + }; + struct absolute_index { int index; absolute_index(lua_State* L, int idx) : index(lua_absindex(L, idx)) {} @@ -3581,6 +3587,8 @@ namespace sol { stack_reference() noexcept = default; stack_reference(nil_t) noexcept : stack_reference() {}; stack_reference(lua_State* L, int i) noexcept : L(L), index(lua_absindex(L, i)) {} + stack_reference(lua_State* L, absolute_index i) noexcept : L(L), index(i) {} + stack_reference(lua_State* L, raw_index i) noexcept : L(L), index(i) {} stack_reference(stack_reference&& o) noexcept = default; stack_reference& operator=(stack_reference&&) noexcept = default; stack_reference(const stack_reference&) noexcept = default; @@ -5354,12 +5362,22 @@ namespace sol { template struct getter> { - template - static decltype(auto) apply(std::index_sequence, lua_State* L, int index, record& tracking) { - return std::tuple(L, index))...>{stack::get(L, index + tracking.used, tracking)...}; + typedef std::tuple(nullptr, 0))...> R; + + template + static R apply(std::index_sequence<>, lua_State*, int, record&, TArgs&&... args) { + // Fuck you too, VC++ + return R{std::forward(args)...}; + } + + template + static R apply(std::index_sequence, lua_State* L, int index, record& tracking, TArgs&&... args) { + // Fuck you too, VC++ + typedef std::tuple_element_t> T; + return apply(std::index_sequence(), L, index, tracking, std::forward(args)..., stack::get(L, index + tracking.used, tracking)); } - static decltype(auto) get(lua_State* L, int index, record& tracking) { + static R get(lua_State* L, int index, record& tracking) { return apply(std::make_index_sequence(), L, index, tracking); } }; diff --git a/sol/stack_get.hpp b/sol/stack_get.hpp index ba4855020..38769ac91 100644 --- a/sol/stack_get.hpp +++ b/sol/stack_get.hpp @@ -504,12 +504,22 @@ namespace sol { template struct getter> { - template - static decltype(auto) apply(std::index_sequence, lua_State* L, int index, record& tracking) { - return std::tuple(L, index))...>{stack::get(L, index + tracking.used, tracking)...}; - } - - static decltype(auto) get(lua_State* L, int index, record& tracking) { + typedef std::tuple(nullptr, 0))...> R; + + template + static R apply(std::index_sequence<>, lua_State*, int, record&, TArgs&&... args) { + // Fuck you too, VC++ + return R{std::forward(args)...}; + } + + template + static R apply(std::index_sequence, lua_State* L, int index, record& tracking, TArgs&&... args) { + // Fuck you too, VC++ + typedef std::tuple_element_t> T; + return apply(std::index_sequence(), L, index, tracking, std::forward(args)..., stack::get(L, index + tracking.used, tracking)); + } + + static R get(lua_State* L, int index, record& tracking) { return apply(std::make_index_sequence(), L, index, tracking); } }; diff --git a/sol/stack_reference.hpp b/sol/stack_reference.hpp index be9b0db7a..5361a8330 100644 --- a/sol/stack_reference.hpp +++ b/sol/stack_reference.hpp @@ -37,6 +37,8 @@ namespace sol { stack_reference() noexcept = default; stack_reference(nil_t) noexcept : stack_reference() {}; stack_reference(lua_State* L, int i) noexcept : L(L), index(lua_absindex(L, i)) {} + stack_reference(lua_State* L, absolute_index i) noexcept : L(L), index(i) {} + stack_reference(lua_State* L, raw_index i) noexcept : L(L), index(i) {} stack_reference(stack_reference&& o) noexcept = default; stack_reference& operator=(stack_reference&&) noexcept = default; stack_reference(const stack_reference&) noexcept = default; diff --git a/sol/types.hpp b/sol/types.hpp index d9ce88ae1..c487cef2d 100644 --- a/sol/types.hpp +++ b/sol/types.hpp @@ -174,6 +174,12 @@ namespace sol { operator int() const { return index; } }; + struct raw_index { + int index; + raw_index(int i) : index(i) {} + operator int() const { return index; } + }; + struct absolute_index { int index; absolute_index(lua_State* L, int idx) : index(lua_absindex(L, idx)) {} diff --git a/test_functions.cpp b/test_functions.cpp index 798a69056..609341da6 100644 --- a/test_functions.cpp +++ b/test_functions.cpp @@ -86,6 +86,17 @@ struct fer { } }; +TEST_CASE("functions/tuple-returns", "Make sure tuple returns are ordered properly") { + sol::state lua; + lua.script("function f() return '3', 4 end"); + + std::tuple result = lua["f"](); + auto s = std::get<0>(result); + auto v = std::get<1>(result); + REQUIRE(s == "3"); + REQUIRE(v == 4); +} + TEST_CASE("functions/overload-resolution", "Check if overloaded function resolution templates compile/work") { sol::state lua; lua.open_libraries(sol::lib::base);