diff options
Diffstat (limited to '3rdparty/sol2/sol/usertype_metatable.hpp')
-rw-r--r-- | 3rdparty/sol2/sol/usertype_metatable.hpp | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/3rdparty/sol2/sol/usertype_metatable.hpp b/3rdparty/sol2/sol/usertype_metatable.hpp index fff5f60dab8..37693227a75 100644 --- a/3rdparty/sol2/sol/usertype_metatable.hpp +++ b/3rdparty/sol2/sol/usertype_metatable.hpp @@ -107,9 +107,9 @@ namespace sol { auto maybeaccessor = stack::get<optional<string_detail::string_shim>>(L, is_index ? -1 : -2); string_detail::string_shim accessor = maybeaccessor.value_or(string_detail::string_shim("(unknown)")); if (is_index) - return luaL_error(L, "sol: attempt to index (get) nil value \"%s\" on userdata (bad (misspelled?) key name or does not exist)", accessor.c_str()); + return luaL_error(L, "sol: attempt to index (get) lua_nil value \"%s\" on userdata (bad (misspelled?) key name or does not exist)", accessor.c_str()); else - return luaL_error(L, "sol: attempt to index (set) nil value \"%s\" on userdata (bad (misspelled?) key name or does not exist)", accessor.c_str()); + return luaL_error(L, "sol: attempt to index (set) lua_nil value \"%s\" on userdata (bad (misspelled?) key name or does not exist)", accessor.c_str()); } template <bool is_index, typename Base> @@ -121,13 +121,13 @@ namespace sol { const char* basewalkkey = is_index ? detail::base_class_index_propogation_key() : detail::base_class_new_index_propogation_key(); luaL_getmetatable(L, metakey); - if (type_of(L, -1) == type::nil) { + if (type_of(L, -1) == type::lua_nil) { lua_pop(L, 1); return; } stack::get_field(L, basewalkkey); - if (type_of(L, -1) == type::nil) { + if (type_of(L, -1) == type::lua_nil) { lua_pop(L, 2); return; } @@ -187,20 +187,23 @@ namespace sol { struct verified_tag {} const verified{}; template <typename T> - struct is_constructor : std::false_type {}; - + struct is_non_factory_constructor : std::false_type {}; + template <typename... Args> - struct is_constructor<constructors<Args...>> : std::true_type {}; + struct is_non_factory_constructor<constructors<Args...>> : std::true_type {}; template <typename... Args> - struct is_constructor<constructor_wrapper<Args...>> : std::true_type {}; + struct is_non_factory_constructor<constructor_wrapper<Args...>> : std::true_type {}; + + template <> + struct is_non_factory_constructor<no_construction> : std::true_type {}; + + template <typename T> + struct is_constructor : is_non_factory_constructor<T> {}; template <typename... Args> struct is_constructor<factory_wrapper<Args...>> : std::true_type {}; - template <> - struct is_constructor<no_construction> : std::true_type {}; - template <typename... Args> using has_constructor = meta::any<is_constructor<meta::unqualified_t<Args>>...>; @@ -425,8 +428,14 @@ namespace sol { template <std::size_t Idx, bool is_index = true, bool is_variable = false> static int real_call_with(lua_State* L, usertype_metatable& um) { + typedef meta::unqualified_tuple_element_t<Idx - 1, Tuple> K; + typedef meta::unqualified_tuple_element_t<Idx, Tuple> F; + static const int boost = + !usertype_detail::is_non_factory_constructor<F>::value + && std::is_same<K, call_construction>::value ? + 1 : 0; auto& f = std::get<Idx>(um.functions); - return call_detail::call_wrapped<T, is_index, is_variable>(L, f); + return call_detail::call_wrapped<T, is_index, is_variable, boost>(L, f); } template <std::size_t Idx, bool is_index = true, bool is_variable = false> |