diff options
Diffstat (limited to '3rdparty/sol2/sol')
| -rw-r--r-- | 3rdparty/sol2/sol/call.hpp | 2 | ||||
| -rw-r--r-- | 3rdparty/sol2/sol/compatibility/version.hpp | 4 | ||||
| -rw-r--r-- | 3rdparty/sol2/sol/container_usertype_metatable.hpp | 312 | ||||
| -rw-r--r-- | 3rdparty/sol2/sol/demangle.hpp | 4 | ||||
| -rw-r--r-- | 3rdparty/sol2/sol/function_types_stateful.hpp | 3 | ||||
| -rw-r--r-- | 3rdparty/sol2/sol/optional_implementation.hpp | 2 | ||||
| -rw-r--r-- | 3rdparty/sol2/sol/resolve.hpp | 70 | ||||
| -rw-r--r-- | 3rdparty/sol2/sol/stack.hpp | 11 | ||||
| -rw-r--r-- | 3rdparty/sol2/sol/stack_check.hpp | 8 | ||||
| -rw-r--r-- | 3rdparty/sol2/sol/traits.hpp | 3 | ||||
| -rw-r--r-- | 3rdparty/sol2/sol/types.hpp | 4 | ||||
| -rw-r--r-- | 3rdparty/sol2/sol/usertype_traits.hpp | 6 |
12 files changed, 261 insertions, 168 deletions
diff --git a/3rdparty/sol2/sol/call.hpp b/3rdparty/sol2/sol/call.hpp index ac5f67e7ef3..abd9dd499c1 100644 --- a/3rdparty/sol2/sol/call.hpp +++ b/3rdparty/sol2/sol/call.hpp @@ -443,7 +443,7 @@ namespace sol { }; static int call(lua_State* L, F& f) { - call_syntax syntax = stack::get_call_syntax(L, &usertype_traits<T>::user_metatable()[0]); + call_syntax syntax = stack::get_call_syntax(L, &usertype_traits<T>::user_metatable()[0], 1); int syntaxval = static_cast<int>(syntax); int argcount = lua_gettop(L) - syntaxval; return construct_match<T, meta::pop_front_type_t<meta::function_args_t<Cxs>>...>(onmatch(), L, argcount, 1 + syntaxval, f); diff --git a/3rdparty/sol2/sol/compatibility/version.hpp b/3rdparty/sol2/sol/compatibility/version.hpp index 5ddc23d91e6..cf23c712a79 100644 --- a/3rdparty/sol2/sol/compatibility/version.hpp +++ b/3rdparty/sol2/sol/compatibility/version.hpp @@ -24,7 +24,7 @@ #include <lua.hpp> -#if defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) +#if defined(_WIN32) || defined(_MSC_VER) #ifndef SOL_CODECVT_SUPPORT #define SOL_CODECVT_SUPPORT 1 #endif // sol codecvt support @@ -33,7 +33,7 @@ #ifndef SOL_CODECVT_SUPPORT #define SOL_CODECVT_SUPPORT 1 #endif // codecvt support -#endif // g++ 5.x.x +#endif // g++ 5.x.x (MinGW too) #else // Clang sucks and doesn't really utilize codecvt support, // not without checking the library versions explicitly (and we're not gonna do that, so fuck you) diff --git a/3rdparty/sol2/sol/container_usertype_metatable.hpp b/3rdparty/sol2/sol/container_usertype_metatable.hpp index 2cbc97f0e6f..cd27b7aeeac 100644 --- a/3rdparty/sol2/sol/container_usertype_metatable.hpp +++ b/3rdparty/sol2/sol/container_usertype_metatable.hpp @@ -47,7 +47,33 @@ namespace sol { typedef std::array<char, 1> one; typedef std::array<char, 2> two; - template <typename C> static one test(decltype(&C::push_back)); + template <typename C> static one test(decltype(std::declval<C>().push_back(std::declval<std::add_rvalue_reference_t<typename C::value_type>>()))*); + template <typename C> static two test(...); + + public: + static const bool value = sizeof(test<T>(0)) == sizeof(char); + }; + + template <typename T> + struct has_clear { + private: + typedef std::array<char, 1> one; + typedef std::array<char, 2> two; + + template <typename C> static one test(decltype(&C::clear)); + template <typename C> static two test(...); + + public: + static const bool value = sizeof(test<T>(0)) == sizeof(char); + }; + + template <typename T> + struct has_insert { + private: + typedef std::array<char, 1> one; + typedef std::array<char, 2> two; + + template <typename C> static one test(decltype(std::declval<C>().insert(std::declval<std::add_rvalue_reference_t<typename C::const_iterator>>(), std::declval<std::add_rvalue_reference_t<typename C::value_type>>()))*); template <typename C> static two test(...); public: @@ -82,10 +108,12 @@ namespace sol { template <typename Raw, typename C = void> struct container_usertype_metatable { + typedef meta::has_key_value_pair<meta::unqualified_t<Raw>> is_associative; typedef meta::unqualified_t<Raw> T; - typedef std::size_t K; - typedef typename T::value_type V; typedef typename T::iterator I; + typedef std::conditional_t<is_associative::value, typename T::value_type, std::pair<std::size_t, typename T::value_type>> KV; + typedef typename KV::first_type K; + typedef typename KV::second_type V; typedef std::remove_reference_t<decltype(*std::declval<I&>())> IR; struct iter { @@ -107,7 +135,36 @@ namespace sol { #endif } - static int real_index_call(lua_State* L) { + static int real_index_call_associative(std::true_type, lua_State* L) { + auto k = stack::check_get<K>(L, 2); + if (k) { + auto& src = get_src(L); + using std::end; + auto it = detail::find(src, *k); + if (it != end(src)) { + auto& v = *it; + return stack::push_reference(L, v.second); + } + } + else { + auto maybename = stack::check_get<string_detail::string_shim>(L, 2); + if (maybename) { + auto& name = *maybename; + if (name == "add") { + return stack::push(L, &add_call); + } + else if (name == "insert") { + return stack::push(L, &insert_call); + } + else if (name == "clear") { + return stack::push(L, &clear_call); + } + } + } + return stack::push(L, nil); + } + + static int real_index_call_associative(std::false_type, lua_State* L) { auto& src = get_src(L); auto maybek = stack::check_get<K>(L, 2); if (maybek) { @@ -143,12 +200,36 @@ namespace sol { return stack::push(L, nil); } - static int real_new_index_call_const(std::false_type, lua_State* L) { - luaL_error(L, "sol: cannot write to a const value type or an immutable iterator (e.g., std::set)"); + static int real_index_call(lua_State* L) { + return real_index_call_associative(is_associative(), L); + } + + static int real_new_index_call_const(std::false_type, std::false_type, lua_State* L) { + return luaL_error(L, "sol: cannot write to a const value type or an immutable iterator (e.g., std::set)"); + } + + static int real_new_index_call_const(std::false_type, std::true_type, lua_State* L) { + return luaL_error(L, "sol: cannot write to a const value type or an immutable iterator (e.g., std::set)"); + } + + static int real_new_index_call_const(std::true_type, std::true_type, lua_State* L) { + auto& src = get_src(L); + auto k = stack::check_get<K>(L, 2); + if (k) { + using std::end; + auto it = detail::find(src, *k); + if (it != end(src)) { + auto& v = *it; + v.second = stack::get<V>(L, 3); + } + else { + src.insert(it, { std::move(*k), stack::get<V>(L, 3) }); + } + } return 0; } - static int real_new_index_call_const(std::true_type, lua_State* L) { + static int real_new_index_call_const(std::true_type, std::false_type, lua_State* L) { auto& src = get_src(L); #ifdef SOL_SAFE_USERTYPE auto maybek = stack::check_get<K>(L, 2); @@ -172,219 +253,150 @@ namespace sol { } static int real_new_index_call(lua_State* L) { - return real_new_index_call_const(meta::neg<meta::any<std::is_const<V>, std::is_const<IR>>>(), L); + return real_new_index_call_const(meta::neg<meta::any<std::is_const<V>, std::is_const<IR>>>(), is_associative(), L); } - static int real_pairs_next_call(lua_State* L) { + static int real_pairs_next_call_assoc(std::true_type, lua_State* L) { using std::end; iter& i = stack::get<user<iter>>(L, 1); auto& source = i.source; auto& it = i.it; - K k = stack::get<K>(L, 2); if (it == end(source)) { return 0; } - int p = stack::multi_push_reference(L, k + 1, *it); + int p = stack::multi_push_reference(L, it->first, it->second); std::advance(it, 1); return p; } - static int real_pairs_call(lua_State* L) { + static int real_pairs_call_assoc(std::true_type, lua_State* L) { auto& src = get_src(L); using std::begin; stack::push(L, pairs_next_call); stack::push<user<iter>>(L, src, begin(src)); - stack::push(L, 0); + stack::push(L, 1); return 3; } - static int real_length_call(lua_State*L) { - auto& src = get_src(L); - return stack::push(L, src.size()); + static int real_pairs_next_call_assoc(std::false_type, lua_State* L) { + using std::end; + iter& i = stack::get<user<iter>>(L, 1); + auto& source = i.source; + auto& it = i.it; + K k = stack::get<K>(L, 2); + if (it == end(source)) { + return 0; + } + int p = stack::multi_push_reference(L, k + 1, *it); + std::advance(it, 1); + return p; } - static int real_add_call_push(std::true_type, lua_State*L, T& src, int boost = 0) { - src.push_back(stack::get<V>(L, 2 + boost)); - return 0; + static int real_pairs_call_assoc(std::false_type, lua_State* L) { + auto& src = get_src(L); + using std::begin; + stack::push(L, pairs_next_call); + stack::push<user<iter>>(L, src, begin(src)); + stack::push(L, 0); + return 3; } - static int real_add_call_push(std::false_type, lua_State*L, T& src, int boost = 0) { - using std::end; - src.insert(end(src), stack::get<V>(L, 2 + boost)); - return 0; + static int real_pairs_next_call(lua_State* L) { + return real_pairs_next_call_assoc(is_associative(), L); } - static int real_add_call(lua_State*L) { - auto& src = get_src(L); - return real_add_call_push(std::integral_constant<bool, detail::has_push_back<T>::value>(), L, src); + static int real_pairs_call(lua_State* L) { + return real_pairs_call_assoc(is_associative(), L); } - static int real_insert_call(lua_State*L) { - using std::begin; + static int real_length_call(lua_State*L) { auto& src = get_src(L); - src.insert(std::next(begin(src), stack::get<K>(L, 2)), stack::get<V>(L, 3)); - return 0; + return stack::push(L, src.size()); } - static int real_clear_call(lua_State*L) { - auto& src = get_src(L); - src.clear(); + static int real_add_call_insert(std::true_type, lua_State*L, T& src, int boost = 0) { + using std::end; + src.insert(end(src), stack::get<V>(L, 2 + boost)); return 0; } - static int add_call(lua_State*L) { - return detail::static_trampoline<(&real_add_call)>(L); + static int real_add_call_insert(std::false_type, lua_State*L, T&, int = 0) { + static const std::string& s = detail::demangle<T>(); + return luaL_error(L, "sol: cannot call insert on type %s", s.c_str()); } - static int insert_call(lua_State*L) { - return detail::static_trampoline<(&real_insert_call)>(L); + static int real_add_call_push(std::true_type, lua_State*L, T& src, int boost = 0) { + src.push_back(stack::get<V>(L, 2 + boost)); + return 0; } - static int clear_call(lua_State*L) { - return detail::static_trampoline<(&real_clear_call)>(L); + static int real_add_call_push(std::false_type, lua_State*L, T& src, int boost = 0) { + return real_add_call_insert(std::integral_constant<bool, detail::has_insert<T>::value>(), L, src, boost); } - static int length_call(lua_State*L) { - return detail::static_trampoline<(&real_length_call)>(L); + static int real_add_call_associative(std::true_type, lua_State* L) { + return real_insert_call(L); } - static int pairs_next_call(lua_State*L) { - return detail::static_trampoline<(&real_pairs_next_call)>(L); + static int real_add_call_associative(std::false_type, lua_State* L) { + auto& src = get_src(L); + return real_add_call_push(std::integral_constant<bool, detail::has_push_back<T>::value>(), L, src); } - static int pairs_call(lua_State*L) { - return detail::static_trampoline<(&real_pairs_call)>(L); + static int real_add_call_capable(std::true_type, lua_State* L) { + return real_add_call_associative(is_associative(), L); } - static int index_call(lua_State*L) { - return detail::static_trampoline<(&real_index_call)>(L); + static int real_add_call_capable(std::false_type, lua_State* L) { + static const std::string& s = detail::demangle<T>(); + return luaL_error(L, "sol: cannot call add on type %s", s.c_str()); } - static int new_index_call(lua_State*L) { - return detail::static_trampoline<(&real_new_index_call)>(L); + static int real_add_call(lua_State* L) { + return real_add_call_capable(std::integral_constant<bool, detail::has_push_back<T>::value || detail::has_insert<T>::value>(), L); } - }; - - template <typename Raw> - struct container_usertype_metatable<Raw, std::enable_if_t<meta::has_key_value_pair<meta::unqualified_t<Raw>>::value>> { - typedef meta::unqualified_t<Raw> T; - typedef typename T::value_type KV; - typedef typename KV::first_type K; - typedef typename KV::second_type V; - typedef typename T::iterator I; - struct iter { - T& source; - I it; - iter(T& source, I it) : source(source), it(std::move(it)) {} - }; - - static auto& get_src(lua_State* L) { -#ifdef SOL_SAFE_USERTYPE - auto p = stack::check_get<T*>(L, 1); - if (!p || p.value() == nullptr) { - luaL_error(L, "sol: 'self' argument is nil (pass 'self' as first argument or call on proper type)"); - } - return *p.value(); -#else - return stack::get<T>(L, 1); -#endif + static int real_insert_call_capable(std::false_type, std::false_type, lua_State*L) { + static const std::string& s = detail::demangle<T>(); + return luaL_error(L, "sol: cannot call insert on type %s", s.c_str()); } - static int real_index_call(lua_State* L) { - auto k = stack::check_get<K>(L, 2); - if (k) { - auto& src = get_src(L); - using std::end; - auto it = detail::find(src, *k); - if (it != end(src)) { - auto& v = *it; - return stack::push_reference(L, v.second); - } - } - else { - auto maybename = stack::check_get<string_detail::string_shim>(L, 2); - if (maybename) { - auto& name = *maybename; - if (name == "add") { - return stack::push(L, &add_call); - } - else if (name == "insert") { - return stack::push(L, &insert_call); - } - else if (name == "clear") { - return stack::push(L, &clear_call); - } - } - } - return stack::push(L, nil); - } - - static int real_new_index_call_const(std::false_type, lua_State* L) { - luaL_error(L, "sol: cannot write to a const value type"); - return 0; + static int real_insert_call_capable(std::false_type, std::true_type, lua_State*L) { + return real_insert_call_capable(std::false_type(), std::false_type(), L); } - static int real_new_index_call_const(std::true_type, lua_State* L) { + static int real_insert_call_capable(std::true_type, std::false_type, lua_State* L) { + using std::begin; auto& src = get_src(L); - auto k = stack::check_get<K>(L, 2); - if (k) { - using std::end; - auto it = detail::find(src, *k); - if (it != end(src)) { - auto& v = *it; - v.second = stack::get<V>(L, 3); - } - else { - src.insert(it, { std::move(*k), stack::get<V>(L, 3) }); - } - } + src.insert(std::next(begin(src), stack::get<K>(L, 2)), stack::get<V>(L, 3)); return 0; } - static int real_new_index_call(lua_State* L) { - return real_new_index_call_const(meta::neg<std::is_const<V>>(), L); + static int real_insert_call_capable(std::true_type, std::true_type, lua_State* L) { + return real_new_index_call(L); } - static int real_pairs_next_call(lua_State* L) { - using std::end; - iter& i = stack::get<user<iter>>(L, 1); - auto& source = i.source; - auto& it = i.it; - if (it == end(source)) { - return 0; - } - int p = stack::multi_push_reference(L, it->first, it->second); - std::advance(it, 1); - return p; + static int real_insert_call(lua_State*L) { + return real_insert_call_capable(std::integral_constant<bool, detail::has_insert<T>::value>(), is_associative(), L); } - static int real_pairs_call(lua_State* L) { - auto& src = get_src(L); - using std::begin; - stack::push(L, pairs_next_call); - stack::push<user<iter>>(L, src, begin(src)); - stack::push(L, 1); - return 3; + static int real_clear_call_capable(std::false_type, lua_State* L) { + static const std::string& s = detail::demangle<T>(); + return luaL_error(L, "sol: cannot call clear on type %s", s.c_str()); } - static int real_length_call(lua_State*L) { + static int real_clear_call_capable(std::true_type, lua_State* L) { auto& src = get_src(L); - return stack::push(L, src.size()); - } - - static int real_insert_call(lua_State*L) { - return real_new_index_call(L); + src.clear(); + return 0; } static int real_clear_call(lua_State*L) { - auto& src = get_src(L); - src.clear(); - return 0; + return real_clear_call_capable(std::integral_constant<bool, detail::has_clear<T>::value>(), L); } static int add_call(lua_State*L) { - return detail::static_trampoline<(&real_insert_call)>(L); + return detail::static_trampoline<(&real_add_call)>(L); } static int insert_call(lua_State*L) { @@ -490,7 +502,7 @@ namespace sol { template<typename T> struct pusher<T*, std::enable_if_t<meta::all<is_container<T>, meta::neg<meta::any<std::is_base_of<reference, meta::unqualified_t<T>>, std::is_base_of<stack_reference, meta::unqualified_t<T>>>>>::value>> { static int push(lua_State* L, T* cont) { - stack_detail::metatable_setup<T*> fx(L); + stack_detail::metatable_setup<meta::unqualified_t<std::remove_pointer_t<T>>*> fx(L); return pusher<detail::as_pointer_tag<T>>{}.push_fx(L, fx, cont); } }; diff --git a/3rdparty/sol2/sol/demangle.hpp b/3rdparty/sol2/sol/demangle.hpp index 2d3bc518aeb..be9aa30594c 100644 --- a/3rdparty/sol2/sol/demangle.hpp +++ b/3rdparty/sol2/sol/demangle.hpp @@ -142,13 +142,13 @@ namespace sol { } template <typename T> - inline std::string demangle() { + inline const std::string& demangle() { static const std::string d = demangle_once<T>(); return d; } template <typename T> - inline std::string short_demangle() { + inline const std::string& short_demangle() { static const std::string d = short_demangle_once<T>(); return d; } diff --git a/3rdparty/sol2/sol/function_types_stateful.hpp b/3rdparty/sol2/sol/function_types_stateful.hpp index 6846ed87474..5ec2bc256d4 100644 --- a/3rdparty/sol2/sol/function_types_stateful.hpp +++ b/3rdparty/sol2/sol/function_types_stateful.hpp @@ -29,9 +29,6 @@ namespace sol { template<typename Func> struct functor_function { typedef meta::unwrapped_t<meta::unqualified_t<Func>> Function; - typedef decltype(&Function::operator()) function_type; - typedef meta::function_return_t<function_type> return_type; - typedef meta::function_args_t<function_type> args_lists; Function fx; template<typename... Args> diff --git a/3rdparty/sol2/sol/optional_implementation.hpp b/3rdparty/sol2/sol/optional_implementation.hpp index 374b80e7c36..d7c5a1ecb2e 100644 --- a/3rdparty/sol2/sol/optional_implementation.hpp +++ b/3rdparty/sol2/sol/optional_implementation.hpp @@ -636,7 +636,7 @@ namespace sol { #ifdef SOL_NO_EXCEPTIONS // we can abort here // but the others are constexpr, so we can't... - : (std::abort(), *(T*)nullptr) + : (std::abort(), *(T*)nullptr); #else : (throw bad_optional_access("bad optional access"), contained_val()); #endif diff --git a/3rdparty/sol2/sol/resolve.hpp b/3rdparty/sol2/sol/resolve.hpp index 7445a8150a9..30e0400d755 100644 --- a/3rdparty/sol2/sol/resolve.hpp +++ b/3rdparty/sol2/sol/resolve.hpp @@ -26,6 +26,75 @@ #include "tuple.hpp" namespace sol { + // Clang has distinct problems with constexpr arguments, + // so don't use the constexpr versions inside of clang. +#ifndef __clang__ + namespace detail { + template<typename R, typename... Args, typename F, typename = std::result_of_t<meta::unqualified_t<F>(Args...)>> + inline constexpr auto resolve_i(types<R(Args...)>, F&&)->R(meta::unqualified_t<F>::*)(Args...) { + using Sig = R(Args...); + typedef meta::unqualified_t<F> Fu; + return static_cast<Sig Fu::*>(&Fu::operator()); + } + + template<typename F, typename U = meta::unqualified_t<F>> + inline constexpr auto resolve_f(std::true_type, F&& f) + -> decltype(resolve_i(types<meta::function_signature_t<decltype(&U::operator())>>(), std::forward<F>(f))) { + return resolve_i(types<meta::function_signature_t<decltype(&U::operator())>>(), std::forward<F>(f)); + } + + template<typename F> + inline constexpr void resolve_f(std::false_type, F&&) { + static_assert(meta::has_deducible_signature<F>::value, + "Cannot use no-template-parameter call with an overloaded functor: specify the signature"); + } + + template<typename F, typename U = meta::unqualified_t<F>> + inline constexpr auto resolve_i(types<>, F&& f) -> decltype(resolve_f(meta::has_deducible_signature<U>(), std::forward<F>(f))) { + return resolve_f(meta::has_deducible_signature<U> {}, std::forward<F>(f)); + } + + template<typename... Args, typename F, typename R = std::result_of_t<F&(Args...)>> + inline constexpr auto resolve_i(types<Args...>, F&& f) -> decltype(resolve_i(types<R(Args...)>(), std::forward<F>(f))) { + return resolve_i(types<R(Args...)>(), std::forward<F>(f)); + } + + template<typename Sig, typename C> + inline constexpr Sig C::* resolve_v(std::false_type, Sig C::* mem_func_ptr) { + return mem_func_ptr; + } + + template<typename Sig, typename C> + inline constexpr Sig C::* resolve_v(std::true_type, Sig C::* mem_variable_ptr) { + return mem_variable_ptr; + } + } // detail + + template<typename... Args, typename R> + inline constexpr auto resolve(R fun_ptr(Args...))->R(*)(Args...) { + return fun_ptr; + } + + template<typename Sig> + inline constexpr Sig* resolve(Sig* fun_ptr) { + return fun_ptr; + } + + template<typename... Args, typename R, typename C> + inline constexpr auto resolve(R(C::*mem_ptr)(Args...))->R(C::*)(Args...) { + return mem_ptr; + } + + template<typename Sig, typename C> + inline constexpr Sig C::* resolve(Sig C::* mem_ptr) { + return detail::resolve_v(std::is_member_object_pointer<Sig C::*>(), mem_ptr); + } + + template<typename... Sig, typename F, meta::disable<std::is_function<meta::unqualified_t<F>>> = meta::enabler> + inline constexpr auto resolve(F&& f) -> decltype(detail::resolve_i(types<Sig...>(), std::forward<F>(f))) { + return detail::resolve_i(types<Sig...>(), std::forward<F>(f)); + } +#else namespace detail { template<typename R, typename... Args, typename F, typename = std::result_of_t<meta::unqualified_t<F>(Args...)>> inline auto resolve_i(types<R(Args...)>, F&&)->R(meta::unqualified_t<F>::*)(Args...) { @@ -91,6 +160,7 @@ namespace sol { inline auto resolve(F&& f) -> decltype(detail::resolve_i(types<Sig...>(), std::forward<F>(f))) { return detail::resolve_i(types<Sig...>(), std::forward<F>(f)); } +#endif } // sol #endif // SOL_RESOLVE_HPP diff --git a/3rdparty/sol2/sol/stack.hpp b/3rdparty/sol2/sol/stack.hpp index f612d483f82..5113cd8912b 100644 --- a/3rdparty/sol2/sol/stack.hpp +++ b/3rdparty/sol2/sol/stack.hpp @@ -181,13 +181,16 @@ namespace sol { return call_into_lua(returns_list(), args_list(), L, start, std::forward<Fx>(fx), std::forward<FxArgs>(fxargs)...); } - inline call_syntax get_call_syntax(lua_State* L, const std::string& key, int index = -2) { + inline call_syntax get_call_syntax(lua_State* L, const std::string& key, int index) { + if (lua_gettop(L) == 0) { + return call_syntax::dot; + } luaL_getmetatable(L, key.c_str()); auto pn = pop_n(L, 1); - if (lua_compare(L, -1, index, LUA_OPEQ) == 1) { - return call_syntax::colon; + if (lua_compare(L, -1, index, LUA_OPEQ) != 1) { + return call_syntax::dot; } - return call_syntax::dot; + return call_syntax::colon; } inline void script(lua_State* L, const std::string& code) { diff --git a/3rdparty/sol2/sol/stack_check.hpp b/3rdparty/sol2/sol/stack_check.hpp index 5a8610f270a..19a7ec9069b 100644 --- a/3rdparty/sol2/sol/stack_check.hpp +++ b/3rdparty/sol2/sol/stack_check.hpp @@ -366,13 +366,17 @@ namespace sol { template<typename T, typename C> struct checker<optional<T>, type::poly, C> { template <typename Handler> - static bool check(lua_State* L, int index, Handler&& handler, record& tracking) { + static bool check(lua_State* L, int index, Handler&&, record& tracking) { type t = type_of(L, index); if (t == type::none) { tracking.use(0); return true; } - return t == type::nil || stack::check<T>(L, index, std::forward<Handler>(handler), tracking); + if (t == type::nil) { + tracking.use(1); + return true; + } + return stack::check<T>(L, index, no_panic, tracking); } }; } // stack diff --git a/3rdparty/sol2/sol/traits.hpp b/3rdparty/sol2/sol/traits.hpp index 1721b90e866..1ed95a1656e 100644 --- a/3rdparty/sol2/sol/traits.hpp +++ b/3rdparty/sol2/sol/traits.hpp @@ -45,6 +45,9 @@ namespace sol { template<typename... Args> struct is_tuple<std::tuple<Args...>> : std::true_type { }; + template <typename T> + struct is_builtin_type : std::integral_constant<bool, std::is_arithmetic<T>::value || std::is_pointer<T>::value || std::is_array<T>::value> {}; + template<typename T> struct unwrapped { typedef T type; diff --git a/3rdparty/sol2/sol/types.hpp b/3rdparty/sol2/sol/types.hpp index 7761be6d0f2..421035ad2c9 100644 --- a/3rdparty/sol2/sol/types.hpp +++ b/3rdparty/sol2/sol/types.hpp @@ -57,9 +57,11 @@ namespace sol { catch (const std::exception& e) { lua_pushstring(L, e.what()); } +#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) catch (...) { lua_pushstring(L, "caught (...) exception"); } +#endif return lua_error(L); } @@ -74,9 +76,11 @@ namespace sol { catch (const std::exception& e) { lua_pushstring(L, e.what()); } +#if !defined(SOL_EXCEPTIONS_SAFE_PROPAGATION) catch (...) { lua_pushstring(L, "caught (...) exception"); } +#endif return lua_error(L); } diff --git a/3rdparty/sol2/sol/usertype_traits.hpp b/3rdparty/sol2/sol/usertype_traits.hpp index 0857b30e0c2..a10ff082529 100644 --- a/3rdparty/sol2/sol/usertype_traits.hpp +++ b/3rdparty/sol2/sol/usertype_traits.hpp @@ -29,11 +29,11 @@ namespace sol { template<typename T> struct usertype_traits { static const std::string& name() { - static const std::string n = detail::short_demangle<T>(); + static const std::string& n = detail::short_demangle<T>(); return n; } static const std::string& qualified_name() { - static const std::string q_n = detail::demangle<T>(); + static const std::string& q_n = detail::demangle<T>(); return q_n; } static const std::string& metatable() { @@ -49,7 +49,7 @@ namespace sol { return u_g_m; } static const std::string& gc_table() { - static const std::string g_t = std::string("sol.").append(detail::demangle<T>().append(".\xE2\x99\xBB")); + static const std::string g_t = std::string("sol.").append(detail::demangle<T>()).append(".\xE2\x99\xBB"); return g_t; } }; |
