From adff0ccbcefcb3749b44a1fda726937a581cfcf7 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Tue, 5 Sep 2017 23:06:02 -0400 Subject: [PATCH] one day, i'll make a commit and it'll work first try --- single/sol/sol.hpp | 17 +++++++++-------- sol/simple_usertype_metatable.hpp | 5 +++-- sol/usertype_metatable.hpp | 8 ++++---- test_simple_usertypes.cpp | 3 +-- test_strings.cpp | 2 +- test_usertypes.cpp | 2 +- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/single/sol/sol.hpp b/single/sol/sol.hpp index 09307856..ea40c3f5 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-06 01:05:13.658647 UTC -// This header was generated with sol v2.18.2 (revision eb313eb) +// Generated 2017-09-06 03:05:33.019474 UTC +// This header was generated with sol v2.18.2 (revision fc91147) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -14933,7 +14933,7 @@ namespace sol { void* baseclasscheck; void* baseclasscast; bool secondarymeta; - std::array properties; + std::array properties; template >> = meta::enabler> lua_CFunction make_func() const { @@ -15274,6 +15274,7 @@ namespace sol { // for call constructor purposes and such lua_createtable(L, 0, 3); stack_reference metabehind(L, -1); + stack::set_field(L, meta_function::type, type_table, metabehind.stack_index()); if (um.callconstructfunc != nullptr) { stack::set_field(L, meta_function::call_function, make_closure(um.callconstructfunc, nullptr, make_light(um), make_light(umc)), metabehind.stack_index()); } @@ -15282,7 +15283,6 @@ namespace sol { stack::set_field(L, meta_function::new_index, make_closure(umt_t::new_index_call, nullptr, make_light(um), make_light(umc)), metabehind.stack_index()); } // type information needs to be present on the behind-tables too - stack::set_field(L, meta_function::type, type_table, metabehind.stack_index()); stack::set_field(L, metatable_key, metabehind, t.stack_index()); metabehind.pop(); @@ -15302,6 +15302,8 @@ namespace sol { { lua_createtable(L, 0, 3); stack_reference metabehind(L, -1); + // type information needs to be present on the behind-tables too + stack::set_field(L, meta_function::type, type_table, metabehind.stack_index()); if (um.callconstructfunc != nullptr) { stack::set_field(L, meta_function::call_function, make_closure(um.callconstructfunc, nullptr, make_light(um), make_light(umc)), metabehind.stack_index()); } @@ -15309,8 +15311,6 @@ namespace sol { stack::set_field(L, meta_function::index, make_closure(umt_t::index_call, nullptr, make_light(um), make_light(umc), nullptr, usertype_detail::toplevel_magic), metabehind.stack_index()); stack::set_field(L, meta_function::new_index, make_closure(umt_t::new_index_call, nullptr, make_light(um), make_light(umc), nullptr, usertype_detail::toplevel_magic), metabehind.stack_index()); stack::set_field(L, metatable_key, metabehind, t.stack_index()); - // type information needs to be present on the behind-tables too - stack::set_field(L, meta_function::type, type_table, metabehind.stack_index()); metabehind.pop(); } @@ -15484,7 +15484,7 @@ namespace sol { void* baseclasscast; bool mustindex; bool secondarymeta; - std::array properties; + std::array properties; template void insert(N&& n, object&& o) { @@ -15783,7 +15783,7 @@ namespace sol { auto& second = std::get<1>(kvp); register_kvp(i, t, first, second); } - luaL_Reg opregs[32]{}; + luaL_Reg opregs[34]{}; int opregsindex = 0; auto prop_fx = [&](meta_function mf) { return !properties[static_cast(mf)]; }; usertype_detail::insert_default_registrations(opregs, opregsindex, prop_fx); @@ -15849,6 +15849,7 @@ namespace sol { luaL_newmetatable(L, &usertype_traits::user_metatable()[0]); stack_reference t(L, -1); stack::set_field(L, meta_function::type, type_table, t.stack_index()); + for (auto& kvp : varmap.functions) { auto& first = std::get<0>(kvp); auto& second = std::get<1>(kvp); diff --git a/sol/simple_usertype_metatable.hpp b/sol/simple_usertype_metatable.hpp index e9215c85..0a4cba46 100644 --- a/sol/simple_usertype_metatable.hpp +++ b/sol/simple_usertype_metatable.hpp @@ -184,7 +184,7 @@ namespace sol { void* baseclasscast; bool mustindex; bool secondarymeta; - std::array properties; + std::array properties; template void insert(N&& n, object&& o) { @@ -483,7 +483,7 @@ namespace sol { auto& second = std::get<1>(kvp); register_kvp(i, t, first, second); } - luaL_Reg opregs[32]{}; + luaL_Reg opregs[34]{}; int opregsindex = 0; auto prop_fx = [&](meta_function mf) { return !properties[static_cast(mf)]; }; usertype_detail::insert_default_registrations(opregs, opregsindex, prop_fx); @@ -549,6 +549,7 @@ namespace sol { luaL_newmetatable(L, &usertype_traits::user_metatable()[0]); stack_reference t(L, -1); stack::set_field(L, meta_function::type, type_table, t.stack_index()); + for (auto& kvp : varmap.functions) { auto& first = std::get<0>(kvp); auto& second = std::get<1>(kvp); diff --git a/sol/usertype_metatable.hpp b/sol/usertype_metatable.hpp index 6a8d89c1..00cef1e3 100644 --- a/sol/usertype_metatable.hpp +++ b/sol/usertype_metatable.hpp @@ -394,7 +394,7 @@ namespace sol { void* baseclasscheck; void* baseclasscast; bool secondarymeta; - std::array properties; + std::array properties; template >> = meta::enabler> lua_CFunction make_func() const { @@ -735,6 +735,7 @@ namespace sol { // for call constructor purposes and such lua_createtable(L, 0, 3); stack_reference metabehind(L, -1); + stack::set_field(L, meta_function::type, type_table, metabehind.stack_index()); if (um.callconstructfunc != nullptr) { stack::set_field(L, meta_function::call_function, make_closure(um.callconstructfunc, nullptr, make_light(um), make_light(umc)), metabehind.stack_index()); } @@ -743,7 +744,6 @@ namespace sol { stack::set_field(L, meta_function::new_index, make_closure(umt_t::new_index_call, nullptr, make_light(um), make_light(umc)), metabehind.stack_index()); } // type information needs to be present on the behind-tables too - stack::set_field(L, meta_function::type, type_table, metabehind.stack_index()); stack::set_field(L, metatable_key, metabehind, t.stack_index()); metabehind.pop(); @@ -763,6 +763,8 @@ namespace sol { { lua_createtable(L, 0, 3); stack_reference metabehind(L, -1); + // type information needs to be present on the behind-tables too + stack::set_field(L, meta_function::type, type_table, metabehind.stack_index()); if (um.callconstructfunc != nullptr) { stack::set_field(L, meta_function::call_function, make_closure(um.callconstructfunc, nullptr, make_light(um), make_light(umc)), metabehind.stack_index()); } @@ -770,8 +772,6 @@ namespace sol { stack::set_field(L, meta_function::index, make_closure(umt_t::index_call, nullptr, make_light(um), make_light(umc), nullptr, usertype_detail::toplevel_magic), metabehind.stack_index()); stack::set_field(L, meta_function::new_index, make_closure(umt_t::new_index_call, nullptr, make_light(um), make_light(umc), nullptr, usertype_detail::toplevel_magic), metabehind.stack_index()); stack::set_field(L, metatable_key, metabehind, t.stack_index()); - // type information needs to be present on the behind-tables too - stack::set_field(L, meta_function::type, type_table, metabehind.stack_index()); metabehind.pop(); } diff --git a/test_simple_usertypes.cpp b/test_simple_usertypes.cpp index aa72aaf1..fc4f4eb2 100644 --- a/test_simple_usertypes.cpp +++ b/test_simple_usertypes.cpp @@ -895,7 +895,7 @@ TEST_CASE("simple_usertype/basic type information", "check that we can query som sol::state lua; lua.open_libraries(sol::lib::base); - lua.new_usertype("my_thing"); + lua.new_simple_usertype("my_thing"); lua.safe_script("obj = my_thing.new()"); @@ -919,4 +919,3 @@ TEST_CASE("simple_usertype/basic type information", "check that we can query som lua.safe_script("assert(not getmetatable(obj).__type.is(\"not a thing\"))"); lua.safe_script("print(getmetatable(obj).__type.name)"); } - diff --git a/test_strings.cpp b/test_strings.cpp index 95c7eb0c..e26e9f37 100644 --- a/test_strings.cpp +++ b/test_strings.cpp @@ -115,7 +115,7 @@ TEST_CASE("object/string-pushers", "test some basic string pushers with in_place sol::object ocs(lua, sol::in_place, "bark\0bark", 9); sol::object os(lua, sol::in_place_type, std::string("bark\0bark", 9), 8); - sol::object osv(lua, sol::in_place_type, std::string_view("woofwoof", 8), 8); + sol::object osv(lua, sol::in_place_type, sol::string_view("woofwoof", 8), 8); bool test1 = ocs.as() == std::string("bark\0bark", 9); bool test2 = os.as() == std::string("bark\0bar", 8); bool test3 = osv.as() == std::string("woofwoof", 8); diff --git a/test_usertypes.cpp b/test_usertypes.cpp index 2b16b569..1d422780 100644 --- a/test_usertypes.cpp +++ b/test_usertypes.cpp @@ -1771,7 +1771,7 @@ TEST_CASE("usertype/basic type information", "check that we can query some basic sol::state lua; lua.open_libraries(sol::lib::base); - lua.new_simple_usertype("my_thing"); + lua.new_usertype("my_thing"); lua.safe_script("obj = my_thing.new()");