with the xmove constructors, we finally are forced to do safety checks.

This commit is contained in:
ThePhD 2017-09-11 16:44:02 -04:00
parent 074b9ae655
commit 8643dec9e5
5 changed files with 22 additions and 3 deletions

View File

@ -4,6 +4,7 @@
#include <iostream>
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;
}

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);