From 7b63057ba8288fa6b0e3dd5269309ebc675cf6a4 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Sat, 26 Nov 2016 03:32:28 -0500 Subject: [PATCH] PRAISE BASED EEVEE --- single/sol/sol.hpp | 6 +++--- sol/stack.hpp | 2 +- test_functions.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index e5a0b767..ffc559c2 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-11-26 01:46:59.897910 UTC -// This header was generated with sol v2.15.2 (revision 49a0f71) +// Generated 2016-11-26 08:32:10.873025 UTC +// This header was generated with sol v2.15.2 (revision 289ded3) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -6936,7 +6936,7 @@ namespace sol { } int last = index + count; for (int i = index; i < last; ++i) { - lua_remove(L, i); + lua_remove(L, index); } } diff --git a/sol/stack.hpp b/sol/stack.hpp index 83cc59bc..7b5c991e 100644 --- a/sol/stack.hpp +++ b/sol/stack.hpp @@ -123,7 +123,7 @@ namespace sol { } int last = index + count; for (int i = index; i < last; ++i) { - lua_remove(L, i); + lua_remove(L, index); } } diff --git a/test_functions.cpp b/test_functions.cpp index fd582d98..447a0d1f 100644 --- a/test_functions.cpp +++ b/test_functions.cpp @@ -986,3 +986,49 @@ TEST_CASE("functions/same-type-closures", "make sure destructions are per-object REQUIRE_FALSE(check_failed); REQUIRE(last_my_closures.size() == 2); } + +TEST_CASE("functions/stack-multi-return", "Make sure the stack is protected after multi-returns") { + sol::state lua; + lua.script("function f () return 1, 2, 3, 4, 5 end"); + + { + sol::stack_guard sg(lua); + sol::stack::push(lua, double(256.78)); + { + int a, b, c, d, e; + sol::stack_guard sg2(lua); + sol::function f = lua["f"]; + sol::tie(a, b, c, d, e) = f(); + REQUIRE(a == 1); + REQUIRE(b == 2); + REQUIRE(c == 3); + REQUIRE(d == 4); + REQUIRE(e == 5); + } + double f = sol::stack::pop(lua); + REQUIRE(f == 256.78); + } +} + +TEST_CASE("functions/protected-stack-multi-return", "Make sure the stack is protected after multi-returns") { + sol::state lua; + lua.script("function f () return 1, 2, 3, 4, 5 end"); + + { + sol::stack_guard sg(lua); + sol::stack::push(lua, double(256.78)); + { + int a, b, c, d, e; + sol::stack_guard sg2(lua); + sol::protected_function pf = lua["f"]; + sol::tie(a, b, c, d, e) = pf(); + REQUIRE(a == 1); + REQUIRE(b == 2); + REQUIRE(c == 3); + REQUIRE(d == 4); + REQUIRE(e == 5); + } + double f = sol::stack::pop(lua); + REQUIRE(f == 256.78); + } +}