From 644a5c549ba77025b4d9798d46371adf6dd9bcb5 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Fri, 11 Aug 2017 09:59:42 -0400 Subject: [PATCH] modifying tests to find out where crash is... --- single/sol/sol.hpp | 40 +++++++++++++++++-------------- sol/simple_usertype_metatable.hpp | 14 ++++++----- sol/usertype_metatable.hpp | 15 ++++++------ test_container_semantics.cpp | 3 ++- test_containers.cpp | 27 ++++++++++++--------- 5 files changed, 56 insertions(+), 43 deletions(-) diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index ffc7cc4d..42412a97 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-08-11 07:26:11.352579 UTC -// This header was generated with sol v2.18.0 (revision eb1560d) +// Generated 2017-08-11 13:58:32.882633 UTC +// This header was generated with sol v2.18.0 (revision 10a59b2) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -226,6 +226,8 @@ namespace sol { template struct as_table_t; template + struct as_container_t; + template struct nested; template struct light; @@ -14110,7 +14112,7 @@ namespace sol { template = meta::enabler> inline void make_reg_op(Regs& l, int& index, const char* name) { - l[index] = { name, &c_call), &operator_wrap> }; + l[index] = luaL_Reg{ name, &c_call), &operator_wrap> }; ++index; } @@ -14122,7 +14124,7 @@ namespace sol { template = meta::enabler> inline void make_to_string_op(Regs& l, int& index) { const char* name = to_string(meta_function::to_string).c_str(); - l[index] = { name, &c_call), &default_to_string> }; + l[index] = luaL_Reg{ name, &c_call), &default_to_string> }; ++index; } @@ -14134,7 +14136,7 @@ namespace sol { template > = meta::enabler> inline void make_call_op(Regs& l, int& index) { const char* name = to_string(meta_function::call).c_str(); - l[index] = { name, &c_call }; + l[index] = luaL_Reg{ name, &c_call }; ++index; } @@ -14146,7 +14148,7 @@ namespace sol { template > = meta::enabler> inline void make_length_op(Regs& l, int& index) { const char* name = to_string(meta_function::length).c_str(); - l[index] = { name, &c_call }; + l[index] = luaL_Reg{ name, &c_call }; ++index; } @@ -14225,7 +14227,7 @@ namespace sol { } if (!properties[static_cast(meta_function::pairs)]) { const char* name = to_string(meta_function::pairs).c_str(); - l[index] = { name, container_usertype_metatable>::pairs_call }; + l[index] = luaL_Reg{ name, container_usertype_metatable>::pairs_call }; ++index; } if (!properties[static_cast(meta_function::length)]) { @@ -14238,7 +14240,7 @@ namespace sol { usertype_detail::make_call_op(l, index); } if (destructfunc != nullptr) { - l[index] = { to_string(meta_function::garbage_collect).c_str(), destructfunc }; + l[index] = luaL_Reg{ to_string(meta_function::garbage_collect).c_str(), destructfunc }; ++index; } return index; @@ -14317,7 +14319,8 @@ namespace sol { indexbaseclasspropogation(usertype_detail::walk_all_bases), newindexbaseclasspropogation(usertype_detail::walk_all_bases), baseclasscheck(nullptr), baseclasscast(nullptr), secondarymeta(contains_variable()), - properties({}) { + properties() { + properties.fill(false); std::initializer_list ilist{ { std::pair( usertype_detail::make_string(std::get(functions)), usertype_detail::call_information(&usertype_metatable::real_find_call, @@ -14885,18 +14888,17 @@ namespace sol { private: template simple_usertype_metatable(usertype_detail::verified_tag, std::index_sequence, lua_State* L, Tuple&& args) - : callconstructfunc(lua_nil), - indexfunc(lua_nil), newindexfunc(lua_nil), - indexbase(&usertype_detail::simple_core_indexing_call), newindexbase(&usertype_detail::simple_core_indexing_call), - indexbaseclasspropogation(usertype_detail::walk_all_bases), newindexbaseclasspropogation(&usertype_detail::walk_all_bases), - baseclasscheck(nullptr), baseclasscast(nullptr), - mustindex(false), secondarymeta(false), properties() { + : callconstructfunc(lua_nil), + indexfunc(lua_nil), newindexfunc(lua_nil), + indexbase(&usertype_detail::simple_core_indexing_call), newindexbase(&usertype_detail::simple_core_indexing_call), + indexbaseclasspropogation(usertype_detail::walk_all_bases), newindexbaseclasspropogation(&usertype_detail::walk_all_bases), + baseclasscheck(nullptr), baseclasscast(nullptr), + mustindex(false), secondarymeta(false), properties() { + properties.fill(false); + (void)detail::swallow{ 0, (add(L, detail::forward_get(args), detail::forward_get(args)),0)... }; - std::array regs{}; - int index = 0; - } template @@ -14992,6 +14994,8 @@ namespace sol { case meta_function::new_index: umx.newindexfunc = second; break; + default: + break; } } break; diff --git a/sol/simple_usertype_metatable.hpp b/sol/simple_usertype_metatable.hpp index fe6120b3..d0df409d 100644 --- a/sol/simple_usertype_metatable.hpp +++ b/sol/simple_usertype_metatable.hpp @@ -323,12 +323,14 @@ namespace sol { private: template simple_usertype_metatable(usertype_detail::verified_tag, std::index_sequence, lua_State* L, Tuple&& args) - : callconstructfunc(lua_nil), - indexfunc(lua_nil), newindexfunc(lua_nil), - indexbase(&usertype_detail::simple_core_indexing_call), newindexbase(&usertype_detail::simple_core_indexing_call), - indexbaseclasspropogation(usertype_detail::walk_all_bases), newindexbaseclasspropogation(&usertype_detail::walk_all_bases), - baseclasscheck(nullptr), baseclasscast(nullptr), - mustindex(false), secondarymeta(false), properties() { + : callconstructfunc(lua_nil), + indexfunc(lua_nil), newindexfunc(lua_nil), + indexbase(&usertype_detail::simple_core_indexing_call), newindexbase(&usertype_detail::simple_core_indexing_call), + indexbaseclasspropogation(usertype_detail::walk_all_bases), newindexbaseclasspropogation(&usertype_detail::walk_all_bases), + baseclasscheck(nullptr), baseclasscast(nullptr), + mustindex(false), secondarymeta(false), properties() { + properties.fill(false); + (void)detail::swallow{ 0, (add(L, detail::forward_get(args), detail::forward_get(args)),0)... }; diff --git a/sol/usertype_metatable.hpp b/sol/usertype_metatable.hpp index 26cb72ce..30be716e 100644 --- a/sol/usertype_metatable.hpp +++ b/sol/usertype_metatable.hpp @@ -432,7 +432,7 @@ namespace sol { template = meta::enabler> inline void make_reg_op(Regs& l, int& index, const char* name) { - l[index] = { name, &c_call), &operator_wrap> }; + l[index] = luaL_Reg{ name, &c_call), &operator_wrap> }; ++index; } @@ -444,7 +444,7 @@ namespace sol { template = meta::enabler> inline void make_to_string_op(Regs& l, int& index) { const char* name = to_string(meta_function::to_string).c_str(); - l[index] = { name, &c_call), &default_to_string> }; + l[index] = luaL_Reg{ name, &c_call), &default_to_string> }; ++index; } @@ -456,7 +456,7 @@ namespace sol { template > = meta::enabler> inline void make_call_op(Regs& l, int& index) { const char* name = to_string(meta_function::call).c_str(); - l[index] = { name, &c_call }; + l[index] = luaL_Reg{ name, &c_call }; ++index; } @@ -468,7 +468,7 @@ namespace sol { template > = meta::enabler> inline void make_length_op(Regs& l, int& index) { const char* name = to_string(meta_function::length).c_str(); - l[index] = { name, &c_call }; + l[index] = luaL_Reg{ name, &c_call }; ++index; } @@ -547,7 +547,7 @@ namespace sol { } if (!properties[static_cast(meta_function::pairs)]) { const char* name = to_string(meta_function::pairs).c_str(); - l[index] = { name, container_usertype_metatable>::pairs_call }; + l[index] = luaL_Reg{ name, container_usertype_metatable>::pairs_call }; ++index; } if (!properties[static_cast(meta_function::length)]) { @@ -560,7 +560,7 @@ namespace sol { usertype_detail::make_call_op(l, index); } if (destructfunc != nullptr) { - l[index] = { to_string(meta_function::garbage_collect).c_str(), destructfunc }; + l[index] = luaL_Reg{ to_string(meta_function::garbage_collect).c_str(), destructfunc }; ++index; } return index; @@ -639,7 +639,8 @@ namespace sol { indexbaseclasspropogation(usertype_detail::walk_all_bases), newindexbaseclasspropogation(usertype_detail::walk_all_bases), baseclasscheck(nullptr), baseclasscast(nullptr), secondarymeta(contains_variable()), - properties({}) { + properties() { + properties.fill(false); std::initializer_list ilist{ { std::pair( usertype_detail::make_string(std::get(functions)), usertype_detail::call_information(&usertype_metatable::real_find_call, diff --git a/test_container_semantics.cpp b/test_container_semantics.cpp index 2797a36b..b59c1d88 100644 --- a/test_container_semantics.cpp +++ b/test_container_semantics.cpp @@ -1007,7 +1007,7 @@ TEST_CASE("containers/as_container", "test that we can force a container to be t #if SOL_LUA_VERSION > 501 REQUIRE_NOTHROW([&]() { - lua.script(R"( + lua.safe_script(R"( mop = my_object.new(20) for i, v in pairs(mop) do assert(i == v) @@ -1027,6 +1027,7 @@ c_mo = mo c_iterable = mo:iterable() )"); }()); + my_object& mo = lua["c_mo"]; my_object& mo_iterable = lua["c_iterable"]; REQUIRE(&mo == &mo_iterable); diff --git a/test_containers.cpp b/test_containers.cpp index a51fbe7d..891843e4 100644 --- a/test_containers.cpp +++ b/test_containers.cpp @@ -922,17 +922,22 @@ TEST_CASE("containers/pointer types", "check that containers with unique usertyp std::vector v2; v2.push_back(&d1); v2.push_back(&d2); + REQUIRE_NOTHROW([&]() { + lua["c1"] = std::move(v1); + lua["c2"] = &v2; + }()); - lua["c1"] = std::move(v1); - lua["c2"] = &v2; + REQUIRE_NOTHROW([&]() { + lua.safe_script("b1 = c1[1]"); + base_t* b1 = lua["b1"]; + int val1 = b1->get(); + REQUIRE(val1 == 250); + }()); - lua.safe_script("b1 = c1[1]"); - base_t* b1 = lua["b1"]; - int val1 = b1->get(); - REQUIRE(val1 == 250); - - lua.safe_script("b2 = c2[2]"); - base_t* b2 = lua["b2"]; - int val2 = b2->get(); - REQUIRE(val2 == 500); + REQUIRE_NOTHROW([&]() { + lua.safe_script("b2 = c2[2]"); + base_t* b2 = lua["b2"]; + int val2 = b2->get(); + REQUIRE(val2 == 500); + }()); }