From e52a8e060b6900b1f04050886bc1ae2ba9ae90b1 Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Sun, 19 Feb 2017 17:17:51 +0100 Subject: [PATCH] Updates sol2 to v2.15.8, resolves #3733 --- third_party/sol2/sol2/sol.hpp | 323 ++++++++++++++++++++++++---------- 1 file changed, 229 insertions(+), 94 deletions(-) diff --git a/third_party/sol2/sol2/sol.hpp b/third_party/sol2/sol2/sol.hpp index 79794ded3e..ff868d73cf 100644 --- a/third_party/sol2/sol2/sol.hpp +++ b/third_party/sol2/sol2/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 2016-12-16 05:28:22.940422 UTC -// This header was generated with sol v2.15.5 (revision bbcbd41) +// Generated 2017-02-19 09:59:38.638408 UTC +// This header was generated with sol v2.15.8 (revision 0c8ec82) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -47,6 +47,9 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" #pragma GCC diagnostic ignored "-Wconversion" +#elif defined _MSC_VER +#pragma warning( push ) +#pragma warning( disable : 4324 ) // structure was padded due to alignment specifier #endif // g++ // beginning of sol/state.hpp @@ -790,7 +793,13 @@ namespace sol { // beginning of sol/compatibility/version.hpp +#ifdef SOL_USING_CXX_LUA +#include +#include +#include +#else #include +#endif // C++-compiler Lua #if defined(_WIN32) || defined(_MSC_VER) #ifndef SOL_CODECVT_SUPPORT @@ -1022,7 +1031,7 @@ inline const char* kepler_lua_compat_get_string(lua_State* L, void* ud, size_t* return ls->s; } -#if !defined(SOL_LUAJIT) || ((SOL_LUAJIT_VERSION - 20100) <= 0) +#if !defined(SOL_LUAJIT) || (SOL_LUAJIT_VERSION < 20100) inline int luaL_loadbufferx(lua_State* L, const char* buff, size_t size, const char* name, const char*) { kepler_lua_compat_get_string_view ls; @@ -1035,7 +1044,8 @@ inline int luaL_loadbufferx(lua_State* L, const char* buff, size_t size, const c #endif /* Lua 5.1 */ -#endif // SOL_5_1_0_H// end of sol/compatibility/5.1.0.h +#endif // SOL_5_1_0_H +// end of sol/compatibility/5.1.0.h // beginning of sol/compatibility/5.0.0.h @@ -2089,8 +2099,8 @@ namespace sol { }; template - struct optional_base { - char storage_[sizeof(T) + (sizeof(T) % alignof(T))]; + struct alignas(T) optional_base { + char storage_[sizeof(T)]; bool init_; constexpr optional_base() noexcept : storage_(), init_(false) {}; @@ -2137,8 +2147,8 @@ namespace sol { using constexpr_optional_base = optional_base; #else template - struct constexpr_optional_base { - char storage_[sizeof(T) + (sizeof(T) % alignof(T))]; + struct alignas(T) constexpr_optional_base { + char storage_[sizeof(T)]; bool init_; constexpr constexpr_optional_base() noexcept : storage_(), init_(false) {} @@ -3315,7 +3325,7 @@ namespace sol { memory = LUA_ERRMEM, gc = LUA_ERRGCMM, handler = LUA_ERRERR, - dead, + dead = -1, }; enum class load_status : int { @@ -3374,6 +3384,8 @@ namespace sol { bitwise_and, bitwise_or, bitwise_xor, + pairs, + next }; typedef meta_function meta_method; @@ -3383,7 +3395,7 @@ namespace sol { "__newindex", } }; - const std::array meta_function_names = { { + const std::array meta_function_names = { { "new", "__index", "__newindex", @@ -3404,6 +3416,17 @@ namespace sol { "__lt", "__le", "__gc", + + "__idiv", + "__shl", + "__shr", + "__bnot", + "__band", + "__bor", + "__bxor", + + "__pairs", + "__next" } }; inline const std::string& name_of(meta_function mf) { @@ -3473,6 +3496,10 @@ namespace sol { using protected_function = basic_protected_function; using stack_function = basic_function; using stack_protected_function = basic_protected_function; + using unsafe_function = basic_function; + using safe_function = basic_protected_function; + using stack_unsafe_function = basic_function; + using stack_safe_function = basic_protected_function; template class basic_object; template @@ -3716,11 +3743,15 @@ namespace sol { template <> struct is_transparent_argument : std::true_type {}; + template + struct is_variadic_arguments : std::is_same {}; + template struct lua_bind_traits : meta::bind_traits { private: typedef meta::bind_traits base_t; public: + typedef std::integral_constant::value != 0> runtime_variadics_t; static const std::size_t true_arity = base_t::arity; static const std::size_t arity = base_t::arity - meta::count_for::value; static const std::size_t true_free_arity = base_t::free_arity; @@ -3790,7 +3821,10 @@ namespace sol { } int push(lua_State* Ls) const noexcept { - lua_pushvalue(Ls, index); + lua_pushvalue(lua_state(), index); + if (Ls != lua_state()) { + lua_xmove(lua_state(), Ls, 1); + } return 1; } @@ -3923,6 +3957,9 @@ namespace sol { } reference& operator=(reference&& o) noexcept { + if (valid()) { + deref(); + } luastate = o.luastate; ref = o.ref; @@ -4114,7 +4151,7 @@ namespace sol { void set_extra(std::true_type, std::index_sequence, T&& target) { using std::get; (void)detail::swallow{ 0, - (get(*this) = get(types(), target), 0)... + (get(static_cast(*this)) = get(types(), target), 0)... , 0 }; } @@ -4122,7 +4159,7 @@ namespace sol { void set_extra(std::false_type, std::index_sequence, T&& target) { using std::get; (void)detail::swallow{ 0, - (get(*this) = get(target), 0)... + (get(static_cast(*this)) = get(target), 0)... , 0 }; } @@ -4580,26 +4617,25 @@ namespace sol { namespace sol { namespace detail { -#ifdef _MSC_VER - template +#if defined(__GNUC__) || defined(__clang__) + template inline std::string ctti_get_type_name() { - const static std::array removals = { { "public:", "private:", "protected:", "struct ", "class ", "`anonymous-namespace'", "`anonymous namespace'" } }; - std::string name = __FUNCSIG__; - std::size_t start = name.find("get_type_name"); + const static std::array removals = { { "{anonymous}", "(anonymous namespace)" } }; + std::string name = __PRETTY_FUNCTION__; + std::size_t start = name.find_first_of('['); + start = name.find_first_of('=', start); + std::size_t end = name.find_last_of(']'); + if (end == std::string::npos) + end = name.size(); if (start == std::string::npos) start = 0; - else - start += 13; if (start < name.size() - 1) start += 1; - std::size_t end = name.find_last_of('>'); - if (end == std::string::npos) - end = name.size(); name = name.substr(start, end - start); - if (name.find("struct", 0) == 0) - name.replace(0, 6, "", 0); - if (name.find("class", 0) == 0) - name.replace(0, 5, "", 0); + start = name.rfind("seperator_mark"); + if (start != std::string::npos) { + name.erase(start - 2, name.length()); + } while (!name.empty() && std::isblank(name.front())) name.erase(name.begin()); while (!name.empty() && std::isblank(name.back())) name.pop_back(); @@ -4613,25 +4649,26 @@ namespace sol { return name; } -#elif defined(__GNUC__) || defined(__clang__) - template +#elif defined(_MSC_VER) + template inline std::string ctti_get_type_name() { - const static std::array removals = { { "{anonymous}", "(anonymous namespace)" } }; - std::string name = __PRETTY_FUNCTION__; - std::size_t start = name.find_first_of('['); - start = name.find_first_of('=', start); - std::size_t end = name.find_last_of(']'); - if (end == std::string::npos) - end = name.size(); + const static std::array removals = { { "public:", "private:", "protected:", "struct ", "class ", "`anonymous-namespace'", "`anonymous namespace'" } }; + std::string name = __FUNCSIG__; + std::size_t start = name.find("get_type_name"); if (start == std::string::npos) start = 0; + else + start += 13; if (start < name.size() - 1) start += 1; + std::size_t end = name.find_last_of('>'); + if (end == std::string::npos) + end = name.size(); name = name.substr(start, end - start); - start = name.rfind("seperator_mark"); - if (start != std::string::npos) { - name.erase(start - 2, name.length()); - } + if (name.find("struct", 0) == 0) + name.replace(0, 6, "", 0); + if (name.find("class", 0) == 0) + name.replace(0, 5, "", 0); while (!name.empty() && std::isblank(name.front())) name.erase(name.begin()); while (!name.empty() && std::isblank(name.back())) name.pop_back(); @@ -5458,7 +5495,7 @@ namespace sol { if (len < 1) return std::wstring(); if (sizeof(wchar_t) == 2) { - std::wstring_convert> convert; + static std::wstring_convert> convert; std::wstring r = convert.from_bytes(str, str + len); #ifdef __MINGW32__ // Fuck you, MinGW, and fuck you libstdc++ for introducing this absolutely asinine bug @@ -5471,7 +5508,7 @@ namespace sol { #endif return r; } - std::wstring_convert> convert; + static std::wstring_convert> convert; std::wstring r = convert.from_bytes(str, str + len); return r; } @@ -5486,12 +5523,12 @@ namespace sol { if (len < 1) return std::u16string(); #ifdef _MSC_VER - std::wstring_convert, int16_t> convert; + static std::wstring_convert, int16_t> convert; auto intd = convert.from_bytes(str, str + len); std::u16string r(intd.size(), '\0'); std::memcpy(&r[0], intd.data(), intd.size() * sizeof(char16_t)); #else - std::wstring_convert, char16_t> convert; + static std::wstring_convert, char16_t> convert; std::u16string r = convert.from_bytes(str, str + len); #endif // VC++ is a shit return r; @@ -5507,12 +5544,12 @@ namespace sol { if (len < 1) return std::u32string(); #ifdef _MSC_VER - std::wstring_convert, int32_t> convert; + static std::wstring_convert, int32_t> convert; auto intd = convert.from_bytes(str, str + len); std::u32string r(intd.size(), '\0'); std::memcpy(&r[0], intd.data(), r.size() * sizeof(char32_t)); #else - std::wstring_convert, char32_t> convert; + static std::wstring_convert, char32_t> convert; std::u32string r = convert.from_bytes(str, str + len); #endif // VC++ is a shit return r; @@ -6394,11 +6431,11 @@ namespace sol { static int push(lua_State* L, const wchar_t* strb, const wchar_t* stre) { if (sizeof(wchar_t) == 2) { - std::wstring_convert> convert; + static std::wstring_convert> convert; std::string u8str = convert.to_bytes(strb, stre); return stack::push(L, u8str); } - std::wstring_convert> convert; + static std::wstring_convert> convert; std::string u8str = convert.to_bytes(strb, stre); return stack::push(L, u8str); } @@ -6416,10 +6453,10 @@ namespace sol { static int push(lua_State* L, const char16_t* strb, const char16_t* stre) { #ifdef _MSC_VER - std::wstring_convert, int16_t> convert; + static std::wstring_convert, int16_t> convert; std::string u8str = convert.to_bytes(reinterpret_cast(strb), reinterpret_cast(stre)); #else - std::wstring_convert, char16_t> convert; + static std::wstring_convert, char16_t> convert; std::string u8str = convert.to_bytes(strb, stre); #endif // VC++ is a shit return stack::push(L, u8str); @@ -6438,10 +6475,10 @@ namespace sol { static int push(lua_State* L, const char32_t* strb, const char32_t* stre) { #ifdef _MSC_VER - std::wstring_convert, int32_t> convert; + static std::wstring_convert, int32_t> convert; std::string u8str = convert.to_bytes(reinterpret_cast(strb), reinterpret_cast(stre)); #else - std::wstring_convert, char32_t> convert; + static std::wstring_convert, char32_t> convert; std::string u8str = convert.to_bytes(strb, stre); #endif // VC++ is a shit return stack::push(L, u8str); @@ -7632,7 +7669,7 @@ namespace sol { if (meta::find_in_pack_v, index_value...>::value) { return overload_match_arity(types(), std::index_sequence(), std::index_sequence(), std::forward(matchfx), L, fxarity, start, std::forward(args)...); } - if (traits::free_arity != fxarity) { + if (!traits::runtime_variadics_t::value && traits::free_arity != fxarity) { return overload_match_arity(types(), std::index_sequence(), std::index_sequence(), std::forward(matchfx), L, fxarity, start, std::forward(args)...); } stack::record tracking{}; @@ -7656,7 +7693,7 @@ namespace sol { if (meta::find_in_pack_v, index_value...>::value) { return overload_match_arity(types<>(), std::index_sequence<>(), std::index_sequence(), std::forward(matchfx), L, fxarity, start, std::forward(args)...); } - if (traits::free_arity != fxarity) { + if (!traits::runtime_variadics_t::value && traits::free_arity != fxarity) { return overload_match_arity(types<>(), std::index_sequence<>(), std::index_sequence(), std::forward(matchfx), L, fxarity, start, std::forward(args)...); } return matchfx(types(), index_value(), return_types(), args_list(), L, fxarity, start, std::forward(args)...); @@ -7671,7 +7708,7 @@ namespace sol { if (meta::find_in_pack_v, index_value...>::value) { return overload_match_arity(types(), std::index_sequence(), std::index_sequence(), std::forward(matchfx), L, fxarity, start, std::forward(args)...); } - if (traits::free_arity != fxarity) { + if (!traits::runtime_variadics_t::value && traits::free_arity != fxarity) { return overload_match_arity(types(), std::index_sequence(), std::index_sequence(), std::forward(matchfx), L, fxarity, start, std::forward(args)...); } stack::record tracking{}; @@ -8057,7 +8094,7 @@ namespace sol { }; static int call(lua_State* L, F& fx) { - return overload_match_arity(on_match(), L, lua_gettop(L), 1, fx); + return overload_match_arity(on_match(), L, lua_gettop(L) - boost, 1 + boost, fx); } }; @@ -8498,7 +8535,7 @@ namespace sol { namespace sol { namespace function_detail { - template + template struct overloaded_function { typedef std::tuple overload_list; typedef std::make_index_sequence indices; @@ -8515,12 +8552,12 @@ namespace sol { template int call(types, index_value, types, types, lua_State* L, int, int) { auto& func = std::get(overloads); - return call_detail::call_wrapped(L, func); + return call_detail::call_wrapped(L, func); } int operator()(lua_State* L) { auto mfx = [&](auto&&... args) { return this->call(std::forward(args)...); }; - return call_detail::overload_match(mfx, L, 1); + return call_detail::overload_match(mfx, L, 1 + start_skew); } }; } // function_detail @@ -8531,9 +8568,10 @@ namespace sol { // beginning of sol/resolve.hpp namespace sol { - // Clang has distinct problems with constexpr arguments, - // so don't use the constexpr versions inside of clang. + #ifndef __clang__ + // constexpr is fine for not-clang + namespace detail { template(Args...)>> inline constexpr auto resolve_i(types, F&&)->R(meta::unqualified_t::*)(Args...) { @@ -8600,6 +8638,10 @@ namespace sol { return detail::resolve_i(types(), std::forward(f)); } #else + + // Clang has distinct problems with constexpr arguments, + // so don't use the constexpr versions inside of clang. + namespace detail { template(Args...)>> inline auto resolve_i(types, F&&)->R(meta::unqualified_t::*)(Args...) { @@ -8665,12 +8707,20 @@ namespace sol { inline auto resolve(F&& f) -> decltype(detail::resolve_i(types(), std::forward(f))) { return detail::resolve_i(types(), std::forward(f)); } + #endif + } // sol // end of sol/resolve.hpp namespace sol { + namespace function_detail { + template + struct class_indicator {}; + + struct call_indicator {}; + } namespace stack { template struct pusher> { @@ -8726,12 +8776,19 @@ namespace sol { select_convertible(types(), L, std::forward(fx), std::forward(args)...); } - template + template >> = meta::enabler> static void select_member_variable(std::true_type, lua_State* L, Fx&& fx, T&& obj, Args&&... args) { typedef meta::boolean>::value || std::is_pointer::value> is_reference; select_reference_member_variable(is_reference(), L, std::forward(fx), std::forward(obj), std::forward(args)...); } + template + static void select_member_variable(std::true_type, lua_State* L, Fx&& fx, function_detail::class_indicator) { + lua_CFunction freefunc = &function_detail::upvalue_this_member_variable::call; + int upvalues = stack::stack_detail::push_as_upvalues(L, fx); + stack::push(L, c_closure(freefunc, upvalues)); + } + template static void select_member_variable(std::true_type, lua_State* L, Fx&& fx) { typedef typename meta::bind_traits>::object_type C; @@ -8764,12 +8821,19 @@ namespace sol { select_member_variable(std::is_member_object_pointer>(), L, std::forward(fx), std::forward(args)...); } - template + template >> = meta::enabler> static void select_member_function(std::true_type, lua_State* L, Fx&& fx, T&& obj, Args&&... args) { typedef meta::boolean>::value || std::is_pointer::value> is_reference; select_reference_member_function(is_reference(), L, std::forward(fx), std::forward(obj), std::forward(args)...); } + template + static void select_member_function(std::true_type, lua_State* L, Fx&& fx, function_detail::class_indicator) { + lua_CFunction freefunc = &function_detail::upvalue_this_member_function::call; + int upvalues = stack::stack_detail::push_as_upvalues(L, fx); + stack::push(L, c_closure(freefunc, upvalues)); + } + template static void select_member_function(std::true_type, lua_State* L, Fx&& fx) { typedef typename meta::bind_traits>::object_type C; @@ -8842,9 +8906,9 @@ namespace sol { template struct pusher::value>> { - template - static int push(lua_State* L, F&& f) { - return pusher>{}.push(L, std::forward(f)); + template + static int push(lua_State* L, F&& f, Args&&... args) { + return pusher>{}.push(L, std::forward(f), std::forward(args)...); } }; @@ -8859,13 +8923,13 @@ namespace sol { template struct pusher> { static int push(lua_State* L, overload_set&& set) { - typedef function_detail::overloaded_function F; + typedef function_detail::overloaded_function<0, Functions...> F; pusher>{}.set_fx(L, std::move(set.functions)); return 1; } static int push(lua_State* L, const overload_set& set) { - typedef function_detail::overloaded_function F; + typedef function_detail::overloaded_function<0, Functions...> F; pusher>{}.set_fx(L, set.functions); return 1; } @@ -8929,16 +8993,28 @@ namespace sol { template struct pusher> { static int push(lua_State* L, const factory_wrapper& fw) { - typedef function_detail::overloaded_function F; + typedef function_detail::overloaded_function<0, Functions...> F; pusher>{}.set_fx(L, fw.functions); return 1; } static int push(lua_State* L, factory_wrapper&& fw) { - typedef function_detail::overloaded_function F; + typedef function_detail::overloaded_function<0, Functions...> F; pusher>{}.set_fx(L, std::move(fw.functions)); return 1; } + + static int push(lua_State* L, const factory_wrapper& set, function_detail::call_indicator) { + typedef function_detail::overloaded_function<1, Functions...> F; + pusher>{}.set_fx(L, set.functions); + return 1; + } + + static int push(lua_State* L, factory_wrapper&& set, function_detail::call_indicator) { + typedef function_detail::overloaded_function<1, Functions...> F; + pusher>{}.set_fx(L, std::move(set.functions)); + return 1; + } }; template @@ -9653,11 +9729,18 @@ namespace sol { const_reverse_iterator crend() const { return std::reverse_iterator(cend()); } int push() const { + return push(L); + } + + int push(lua_State* target) const { int pushcount = 0; for (int i = index; i <= stacktop; ++i) { lua_pushvalue(L, i); pushcount += 1; } + if (target != L) { + lua_xmove(L, target, pushcount); + } return pushcount; } @@ -9687,8 +9770,8 @@ namespace sol { template <> struct pusher { - static int push(lua_State*, const variadic_args& ref) { - return ref.push(); + static int push(lua_State* L, const variadic_args& ref) { + return ref.push(L); } }; } // stack @@ -9906,7 +9989,7 @@ namespace sol { } bool valid() const { - stack::push_pop(tbl); + auto pp = stack::push_pop(tbl); auto p = stack::probe_get_field, global_table>::value>(tbl.lua_state(), key, lua_gettop(tbl.lua_state())); lua_pop(tbl.lua_state(), p.levels); return p; @@ -10073,9 +10156,9 @@ namespace sol { auto maybeaccessor = stack::get>(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) lua_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) 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) lua_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) nil value \"%s\" on userdata (bad (misspelled?) key name or does not exist)", accessor.c_str()); } template @@ -10153,20 +10236,23 @@ namespace sol { struct verified_tag {} const verified{}; template - struct is_constructor : std::false_type {}; - + struct is_non_factory_constructor : std::false_type {}; + template - struct is_constructor> : std::true_type {}; + struct is_non_factory_constructor> : std::true_type {}; template - struct is_constructor> : std::true_type {}; + struct is_non_factory_constructor> : std::true_type {}; + + template <> + struct is_non_factory_constructor : std::true_type {}; + + template + struct is_constructor : is_non_factory_constructor {}; template struct is_constructor> : std::true_type {}; - template <> - struct is_constructor : std::true_type {}; - template using has_constructor = meta::any>...>; @@ -10391,8 +10477,14 @@ namespace sol { template static int real_call_with(lua_State* L, usertype_metatable& um) { + typedef meta::unqualified_tuple_element_t K; + typedef meta::unqualified_tuple_element_t F; + static const int boost = + !usertype_detail::is_non_factory_constructor::value + && std::is_same::value ? + 1 : 0; auto& f = std::get(um.functions); - return call_detail::call_wrapped(L, f); + return call_detail::call_wrapped(L, f); } template @@ -10637,10 +10729,13 @@ namespace sol { lua_settop(L, 0); return 0; } - lua_pop(L, 1); return indexing_fail(L); } + inline int simple_indexing_fail(lua_State* L) { + return stack::push(L, sol::lua_nil); + } + template inline int simple_core_indexing_call(lua_State* L) { simple_map& sm = toplevel ? stack::get>(L, upvalue_index(1)) : stack::pop>(L); @@ -10747,14 +10842,31 @@ namespace sol { hint->second = std::move(o); } - template >> = meta::enabler> - void add_function(lua_State* L, N&& n, F&& f) { - insert(std::forward(n), make_object(L, as_function_reference(std::forward(f)))); + template + void insert_prepare(std::true_type, lua_State* L, N&&, F&& f, Args&&... args) { + object o = make_object(L, std::forward(f), function_detail::call_indicator(), std::forward(args)...); + callconstructfunc = std::move(o); } - template >> = meta::enabler> + template + void insert_prepare(std::false_type, lua_State* L, N&& n, F&& f, Args&&... args) { + object o = make_object(L, std::forward(f), std::forward(args)...); + insert(std::forward(n), std::move(o)); + } + + template + void add_member_function(std::true_type, lua_State* L, N&& n, F&& f) { + insert_prepare(std::is_same, call_construction>(), L, std::forward(n), std::forward(f), function_detail::class_indicator()); + } + + template + void add_member_function(std::false_type, lua_State* L, N&& n, F&& f) { + insert_prepare(std::is_same, call_construction>(), L, std::forward(n), std::forward(f)); + } + + template >> = meta::enabler> void add_function(lua_State* L, N&& n, F&& f) { - object o = make_object(L, std::forward(f)); + object o = make_object(L, as_function_reference(std::forward(f))); if (std::is_same, call_construction>::value) { callconstructfunc = std::move(o); return; @@ -10762,6 +10874,11 @@ namespace sol { insert(std::forward(n), std::move(o)); } + template >> = meta::enabler> + void add_function(lua_State* L, N&& n, F&& f) { + add_member_function(std::is_member_pointer>(), L, std::forward(n), std::forward(f)); + } + template >> = meta::enabler> void add(lua_State* L, N&& n, F&& f) { add_function(L, std::forward(n), std::forward(f)); @@ -10842,7 +10959,7 @@ namespace sol { template simple_usertype_metatable(usertype_detail::verified_tag, std::index_sequence, lua_State* L, Tuple&& args) : callconstructfunc(lua_nil), - indexfunc(&usertype_detail::indexing_fail), newindexfunc(&usertype_detail::indexing_fail), + indexfunc(&usertype_detail::simple_indexing_fail), newindexfunc(&usertype_detail::simple_metatable_newindex), 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), @@ -11072,15 +11189,15 @@ namespace sol { stack::set_field(L, meta_function::index, make_closure(&usertype_detail::simple_index_call, make_light(varmap), - &usertype_detail::simple_index_call, - &usertype_detail::simple_metatable_newindex, + umx.indexfunc, + umx.newindexfunc, usertype_detail::toplevel_magic ), metabehind.stack_index()); stack::set_field(L, meta_function::new_index, make_closure(&usertype_detail::simple_new_index_call, make_light(varmap), - &usertype_detail::simple_index_call, - &usertype_detail::simple_metatable_newindex, + umx.indexfunc, + umx.newindexfunc, usertype_detail::toplevel_magic ), metabehind.stack_index()); stack::set_field(L, metatable_key, metabehind, t.stack_index()); @@ -12829,7 +12946,23 @@ namespace sol { stack::luajit_exception_handler(unique_base::get()); } + state(const state&) = delete; + state(state&&) = default; + state& operator=(const state&) = delete; + state& operator=(state&& that) { + state_view::operator=(std::move(that)); + unique_base::operator=(std::move(that)); + return *this; + } + using state_view::get; + + ~state() { + auto& handler = protected_function::get_default_handler(); + if (handler.lua_state() == this->lua_state()) { + protected_function::set_default_handler(reference()); + } + } }; } // sol @@ -13079,6 +13212,8 @@ namespace sol { #ifdef __GNUC__ #pragma GCC diagnostic pop +#elif defined _MSC_VER +#pragma warning( push ) #endif // g++ #ifdef SOL_INSIDE_UNREAL