From 8643dec9e5f548c719289adccf66045c9371404e Mon Sep 17 00:00:00 2001 From: ThePhD Date: Mon, 11 Sep 2017 16:44:02 -0400 Subject: [PATCH] with the xmove constructors, we finally are forced to do safety checks. --- examples/coroutine_state.cpp | 3 +++ examples/dynamic_object.cpp | 2 +- single/sol/sol.hpp | 12 ++++++++++-- sol/reference.hpp | 4 ++++ sol/stack_reference.hpp | 4 ++++ 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/examples/coroutine_state.cpp b/examples/coroutine_state.cpp index 2f0770c8..f99b5da4 100644 --- a/examples/coroutine_state.cpp +++ b/examples/coroutine_state.cpp @@ -4,6 +4,7 @@ #include int main(int, char*[]) { + std::cout << "=== coroutine state transfer example ===" << std::endl; sol::state lua; lua.open_libraries(); @@ -42,5 +43,7 @@ int main(int, char*[]) { int i = lua["i"]; assert(i == 1); + std::cout << std::endl; + return 0; } diff --git a/examples/dynamic_object.cpp b/examples/dynamic_object.cpp index 8af23da3..36dc4989 100644 --- a/examples/dynamic_object.cpp +++ b/examples/dynamic_object.cpp @@ -77,7 +77,7 @@ assert(value == 15) auto script_result = lua.safe_script("local value = d1:run(5)", sol::script_pass_on_error); assert(!script_result.valid()); sol::error err = script_result; - std::cout << "received error: " << err.what() << std::endl; + std::cout << "received expected error: " << err.what() << std::endl; std::cout << std::endl; return 0; diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index 54d80b10..38d56622 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 2017-09-11 20:10:45.557320 UTC -// This header was generated with sol v2.18.2 (revision 85c81f6) +// Generated 2017-09-11 20:41:41.805495 UTC +// This header was generated with sol v2.18.2 (revision 074b9ae) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -5570,6 +5570,10 @@ namespace sol { } int push(lua_State* Ls) const noexcept { + if (lua_state() == nullptr) { + lua_pushnil(Ls); + return 1; + } lua_pushvalue(lua_state(), index); if (Ls != lua_state()) { lua_xmove(lua_state(), Ls, 1); @@ -5831,6 +5835,10 @@ namespace sol { } int push(lua_State* Ls) const noexcept { + if (lua_state() == nullptr) { + lua_pushnil(Ls); + return 1; + } lua_rawgeti(lua_state(), LUA_REGISTRYINDEX, ref); if (Ls != lua_state()) { lua_xmove(lua_state(), Ls, 1); diff --git a/sol/reference.hpp b/sol/reference.hpp index 5d170624..37b410ae 100644 --- a/sol/reference.hpp +++ b/sol/reference.hpp @@ -225,6 +225,10 @@ namespace sol { } int push(lua_State* Ls) const noexcept { + if (lua_state() == nullptr) { + lua_pushnil(Ls); + return 1; + } lua_rawgeti(lua_state(), LUA_REGISTRYINDEX, ref); if (Ls != lua_state()) { lua_xmove(lua_state(), Ls, 1); diff --git a/sol/stack_reference.hpp b/sol/stack_reference.hpp index 57720651..bf03797e 100644 --- a/sol/stack_reference.hpp +++ b/sol/stack_reference.hpp @@ -67,6 +67,10 @@ namespace sol { } int push(lua_State* Ls) const noexcept { + if (lua_state() == nullptr) { + lua_pushnil(Ls); + return 1; + } lua_pushvalue(lua_state(), index); if (Ls != lua_state()) { lua_xmove(lua_state(), Ls, 1);