From 275c5586ef6a66f81a502e68089fdb8518697abf Mon Sep 17 00:00:00 2001 From: Justin L Date: Fri, 28 Jul 2023 21:47:00 +1000 Subject: [PATCH] update sol.hpp lib to be compatible with latest gcc --- external/sol/sol.hpp | 27876 ++++++++++++++++++++++++++--------------- 1 file changed, 18061 insertions(+), 9815 deletions(-) diff --git a/external/sol/sol.hpp b/external/sol/sol.hpp index d30d9697c..a236b339d 100644 --- a/external/sol/sol.hpp +++ b/external/sol/sol.hpp @@ -1,6 +1,6 @@ // The MIT License (MIT) -// Copyright (c) 2013-2016 Rapptz, ThePhD and contributors +// Copyright (c) 2013-2018 Rapptz, ThePhD and contributors // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in @@ -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-03-24 01:12:07.656967 UTC -// This header was generated with sol v2.16.0 (revision 7c29964) +// Generated 2018-05-22 19:42:19.603781 UTC +// This header was generated with sol v2.20.2 (revision d67c5b7) // https://github.com/ThePhD/sol2 #ifndef SOL_SINGLE_INCLUDE_HPP @@ -33,24 +33,359 @@ #define SOL_HPP #if defined(UE_BUILD_DEBUG) || defined(UE_BUILD_DEVELOPMENT) || defined(UE_BUILD_TEST) || defined(UE_BUILD_SHIPPING) || defined(UE_SERVER) -#define SOL_INSIDE_UNREAL +#define SOL_INSIDE_UNREAL 1 #endif // Unreal Engine 4 bullshit -#ifdef SOL_INSIDE_UNREAL +#if defined(SOL_INSIDE_UNREAL) && SOL_INSIDE_UNREAL #ifdef check #define SOL_INSIDE_UNREAL_REMOVED_CHECK #undef check #endif #endif // Unreal Engine 4 Bullshit -#ifdef __GNUC__ +#if defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wshadow" #pragma GCC diagnostic ignored "-Wconversion" +#if __GNUC__ > 6 +#pragma GCC diagnostic ignored "-Wnoexcept-type" +#endif +#elif defined(__clang__) #elif defined _MSC_VER #pragma warning( push ) #pragma warning( disable : 4324 ) // structure was padded due to alignment specifier -#endif // g++ +#pragma warning( disable : 4503 ) // decorated name horse shit +#pragma warning( disable : 4702 ) // unreachable code +#pragma warning( disable: 4127 ) // 'conditional expression is constant' yeah that's the point your old compilers don't have `if constexpr` you jerk +#pragma warning( disable: 4505 ) // some other nonsense warning +#endif // clang++ vs. g++ vs. VC++ + +// beginning of sol/forward.hpp + +// beginning of sol/feature_test.hpp + +#if (defined(__cplusplus) && __cplusplus == 201703L) || (defined(_MSC_VER) && _MSC_VER > 1900 && ((defined(_HAS_CXX17) && _HAS_CXX17 == 1) || (defined(_MSVC_LANG) && (_MSVC_LANG > 201402L)))) +#ifndef SOL_CXX17_FEATURES +#define SOL_CXX17_FEATURES 1 +#endif // C++17 features macro +#endif // C++17 features check + +#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES +#if defined(__cpp_noexcept_function_type) || ((defined(_MSC_VER) && _MSC_VER > 1911) && (defined(_MSVC_LANG) && ((_MSVC_LANG >= 201403L)))) +#ifndef SOL_NOEXCEPT_FUNCTION_TYPE +#define SOL_NOEXCEPT_FUNCTION_TYPE 1 +#endif // noexcept is part of a function's type +#endif // compiler-specific checks +#if defined(__clang__) && defined(__APPLE__) +#if defined(__has_include) +#if __has_include() +#define SOL_STD_VARIANT 1 +#endif // has include nonsense +#endif // __has_include +#else +#define SOL_STD_VARIANT 1 +#endif // Clang screws up variant +#endif // C++17 only + +// beginning of sol/config.hpp + +#ifdef _MSC_VER + #if defined(_DEBUG) && !defined(NDEBUG) + + #ifndef SOL_IN_DEBUG_DETECTED + #define SOL_IN_DEBUG_DETECTED 1 + #endif + + #endif // VC++ Debug macros + + #ifndef _CPPUNWIND + #ifndef SOL_NO_EXCEPTIONS + #define SOL_NO_EXCEPTIONS 1 + #endif + #endif // Automatic Exceptions + + #ifndef _CPPRTTI + #ifndef SOL_NO_RTTI + #define SOL_NO_RTTI 1 + #endif + #endif // Automatic RTTI +#elif defined(__GNUC__) || defined(__clang__) + + #if !defined(NDEBUG) && !defined(__OPTIMIZE__) + + #ifndef SOL_IN_DEBUG_DETECTED + #define SOL_IN_DEBUG_DETECTED 1 + #endif + + #endif // Not Debug && g++ optimizer flag + + #ifndef __EXCEPTIONS + #ifndef SOL_NO_EXCEPTIONS + #define SOL_NO_EXCEPTIONS 1 + #endif + #endif // No Exceptions + + #ifndef __GXX_RTTI + #ifndef SOL_NO_RTII + #define SOL_NO_RTTI 1 + #endif + #endif // No RTTI + +#endif // vc++ || clang++/g++ + +#if defined(SOL_CHECK_ARGUMENTS) && SOL_CHECK_ARGUMENTS + + // Checks low-level getter function + // (and thusly, affects nearly entire framework) + #if !defined(SOL_SAFE_GETTER) + #define SOL_SAFE_GETTER 1 + #endif + + // Checks access on usertype functions + // local my_obj = my_type.new() + // my_obj.my_member_function() + // -- bad syntax and crash + #if !defined(SOL_SAFE_USERTYPE) + #define SOL_SAFE_USERTYPE 1 + #endif + + // Checks sol::reference derived boundaries + // sol::function ref(L, 1); + // sol::userdata sref(L, 2); + #if !defined(SOL_SAFE_REFERENCES) + #define SOL_SAFE_REFERENCES 1 + #endif + + // Changes all typedefs of sol::function to point to the + // protected_function version, instead of unsafe_function + #if !defined(SOL_SAFE_FUNCTION) + #define SOL_SAFE_FUNCTION 1 + #endif + + // Checks function parameters and + // returns upon call into/from Lua + // local a = 1 + // local b = "woof" + // my_c_function(a, b) + #if !defined(SOL_SAFE_FUNCTION_CALLS) + #define SOL_SAFE_FUNCTION_CALLS 1 + #endif + + // Checks conversions + // int v = lua["bark"]; + // int v2 = my_sol_function(); + #if !defined(SOL_SAFE_PROXIES) + #define SOL_SAFE_PROXIES 1 + #endif + + // Check overflowing number conversions + // for things like 64 bit integers that don't fit in a typical lua_Number + // for Lua 5.1 and 5.2 + #if !defined(SOL_SAFE_NUMERICS) + #define SOL_SAFE_NUMERICS 1 + #endif + + // Turn off Number Precision Checks + // if this is defined, we do not do range + // checks on integers / unsigned integers that might + // be bigger than what Lua can represent + #if !defined(SOL_NO_CHECK_NUMBER_PRECISION) + // off by default + #define SOL_NO_CHECK_NUMBER_PRECISION 0 + #endif + +#endif // Turn on Safety for all if top-level macro is defined + +#if defined(SOL_IN_DEBUG_DETECTED) && SOL_IN_DEBUG_DETECTED + + #if !defined(SOL_SAFE_REFERENCES) + // Ensure that references are forcefully type-checked upon construction + #define SOL_SAFE_REFERENCES 1 + #endif + + // Safe usertypes checks for errors such as + // obj = my_type.new() + // obj.f() -- note the '.' instead of ':' + // usertypes should be safe no matter what + #if !defined(SOL_SAFE_USERTYPE) + #define SOL_SAFE_USERTYPE 1 + #endif + + #if !defined(SOL_SAFE_FUNCTION_CALLS) + // Function calls from Lua should be automatically safe in debug mode + #define SOL_SAFE_FUNCTION_CALLS 1 + #endif + + // Print any exceptions / errors that occur + // in debug mode to the default error stream / console + #if !defined(SOL_PRINT_ERRORS) + #define SOL_PRINT_ERRORS 1 + #endif + +#endif // DEBUG: Turn on all debug safety features for VC++ / g++ / clang++ and similar + +#if !defined(SOL_PRINT_ERRORS) +#define SOL_PRINT_ERRORS 0 +#endif + +#if !defined(SOL_DEFAULT_PASS_ON_ERROR) +#define SOL_DEFAULT_PASS_ON_ERROR 0 +#endif + +#if !defined(SOL_ENABLE_INTEROP) +#define SOL_ENABLE_INTEROP 0 +#endif + +#if defined(__MAC_OS_X_VERSION_MAX_ALLOWED) || defined(__OBJC__) || defined(nil) +#if !defined(SOL_NO_NIL) +#define SOL_NO_NIL 1 +#endif +#endif // avoiding nil defines / keywords + +#if defined(SOL_USE_BOOST) && SOL_USE_BOOST +#ifndef SOL_UNORDERED_MAP_COMPATIBLE_HASH +#define SOL_UNORDERED_MAP_COMPATIBLE_HASH 1 +#endif // SOL_UNORDERED_MAP_COMPATIBLE_HASH +#endif + +#ifndef SOL_STACK_STRING_OPTIMIZATION_SIZE +#define SOL_STACK_STRING_OPTIMIZATION_SIZE 1024 +#endif // Optimized conversion routines using a KB or so off the stack + +// end of sol/config.hpp + +// end of sol/feature_test.hpp + +namespace sol { + + template + class basic_reference; + using reference = basic_reference; + using main_reference = basic_reference; + class stack_reference; + + struct proxy_base_tag; + template + struct proxy_base; + template + struct proxy; + + template + class usertype; + template + class simple_usertype; + template + class basic_table_core; + template + using table_core = basic_table_core; + template + using main_table_core = basic_table_core; + template + using stack_table_core = basic_table_core; + template + using basic_table = basic_table_core; + typedef table_core table; + typedef table_core global_table; + typedef main_table_core main_table; + typedef main_table_core main_global_table; + typedef stack_table_core stack_table; + typedef stack_table_core stack_global_table; + template + struct basic_environment; + using environment = basic_environment; + using main_environment = basic_environment; + using stack_environment = basic_environment; + template + class basic_function; + template + class basic_protected_function; + using unsafe_function = basic_function; + using safe_function = basic_protected_function; + using main_unsafe_function = basic_function; + using main_safe_function = basic_protected_function; + using stack_unsafe_function = basic_function; + using stack_safe_function = basic_protected_function; + using stack_aligned_unsafe_function = basic_function; + using stack_aligned_safe_function = basic_protected_function; + using protected_function = safe_function; + using main_protected_function = main_safe_function; + using stack_protected_function = stack_safe_function; + using stack_aligned_protected_function = stack_aligned_safe_function; +#if defined(SOL_SAFE_FUNCTION) && SOL_SAFE_FUNCTION + using function = protected_function; + using main_function = main_protected_function; + using stack_function = stack_protected_function; +#else + using function = unsafe_function; + using main_function = main_unsafe_function; + using stack_function = stack_unsafe_function; +#endif + using stack_aligned_function = stack_aligned_unsafe_function; + using stack_aligned_stack_handler_function = basic_protected_function; + + struct unsafe_function_result; + struct protected_function_result; + using safe_function_result = protected_function_result; +#if defined(SOL_SAFE_FUNCTION) && SOL_SAFE_FUNCTION + using function_result = safe_function_result; +#else + using function_result = unsafe_function_result; +#endif + + template + class basic_object; + template + class basic_userdata; + template + class basic_lightuserdata; + template + class basic_coroutine; + template + class basic_thread; + + using object = basic_object; + using userdata = basic_userdata; + using lightuserdata = basic_lightuserdata; + using thread = basic_thread; + using coroutine = basic_coroutine; + using main_object = basic_object; + using main_userdata = basic_userdata; + using main_lightuserdata = basic_lightuserdata; + using main_coroutine = basic_coroutine; + using stack_object = basic_object; + using stack_userdata = basic_userdata; + using stack_lightuserdata = basic_lightuserdata; + using stack_thread = basic_thread; + using stack_coroutine = basic_coroutine; + + struct stack_proxy_base; + struct stack_proxy; + struct variadic_args; + struct variadic_results; + struct stack_count; + struct this_state; + struct this_main_state; + struct this_environment; + + template + struct as_table_t; + template + struct as_container_t; + template + struct nested; + template + struct light; + template + struct user; + template + struct as_args_t; + template + struct protect_t; + template + struct filter_wrapper; +} // namespace sol + +// end of sol/forward.hpp // beginning of sol/state.hpp @@ -60,22 +395,32 @@ #include #include +#include namespace sol { namespace detail { struct direct_error_tag {}; const auto direct_error = direct_error_tag{}; - } // detail - + } // namespace detail + class error : public std::runtime_error { private: - // Because VC++ is a fuccboi + // Because VC++ is upsetting, most of the time! std::string w; + public: - error(const std::string& str) : error(detail::direct_error, "lua: error: " + str) {} - error(std::string&& str) : error(detail::direct_error, "lua: error: " + std::move(str)) {} - error(detail::direct_error_tag, const std::string& str) : std::runtime_error(""), w(str) {} - error(detail::direct_error_tag, std::string&& str) : std::runtime_error(""), w(std::move(str)) {} + error(const std::string& str) + : error(detail::direct_error, "lua: error: " + str) { + } + error(std::string&& str) + : error(detail::direct_error, "lua: error: " + std::move(str)) { + } + error(detail::direct_error_tag, const std::string& str) + : std::runtime_error(""), w(str) { + } + error(detail::direct_error_tag, std::string&& str) + : std::runtime_error(""), w(std::move(str)) { + } error(const error& e) = default; error(error&& e) = default; @@ -87,7 +432,7 @@ namespace sol { } }; -} // sol +} // namespace sol // end of sol/error.hpp @@ -107,45 +452,56 @@ namespace sol { namespace sol { namespace detail { using swallow = std::initializer_list; - } // detail + } // namespace detail - template - struct types { typedef std::make_index_sequence indices; static constexpr std::size_t size() { return sizeof...(Args); } }; + template + struct types { + typedef std::make_index_sequence indices; + static constexpr std::size_t size() { + return sizeof...(Args); + } + }; namespace meta { namespace detail { - template + template struct tuple_types_ { typedef types type; }; - template + template struct tuple_types_> { typedef types type; }; - } // detail + } // namespace detail - template + template using unqualified = std::remove_cv>; - template + template using unqualified_t = typename unqualified::type; - template + template using tuple_types = typename detail::tuple_types_::type; - template + template struct pop_front_type; - template + template using pop_front_type_t = typename pop_front_type::type; - template - struct pop_front_type> { typedef void front_type; typedef types type; }; + template + struct pop_front_type> { + typedef void front_type; + typedef types type; + }; - template - struct pop_front_type> { typedef Arg front_type; typedef types type; }; + template + struct pop_front_type> { + typedef Arg front_type; + typedef types type; + }; template - using tuple_element = std::tuple_element>; + using tuple_element = std::tuple_element>; template - using tuple_element_t = std::tuple_element_t>; + using tuple_element_t = std::tuple_element_t>; template using unqualified_tuple_element = unqualified>; @@ -153,10679 +509,17349 @@ namespace sol { template using unqualified_tuple_element_t = unqualified_t>; - } // meta -} // sol + } // namespace meta +} // namespace sol // end of sol/tuple.hpp // beginning of sol/bind_traits.hpp namespace sol { - namespace meta { - namespace meta_detail { - - template - struct check_deducible_signature { - struct nat {}; - template - static auto test(int) -> decltype(&G::operator(), void()); - template - static auto test(...)->nat; +namespace meta { + namespace meta_detail { + + template + struct check_deducible_signature { + struct nat {}; + template + static auto test(int) -> decltype(&G::operator(), void()); + template + static auto test(...) -> nat; + + using type = std::is_void(0))>; + }; + } // namespace meta_detail - using type = std::is_void(0))>; - }; - } // meta_detail + template + struct has_deducible_signature : meta_detail::check_deducible_signature::type {}; - template - struct has_deducible_signature : meta_detail::check_deducible_signature::type { }; + namespace meta_detail { - namespace meta_detail { + template + struct void_tuple_element : meta::tuple_element {}; - template - struct void_tuple_element : meta::tuple_element {}; + template + struct void_tuple_element> { typedef void type; }; - template - struct void_tuple_element> { typedef void type; }; + template + using void_tuple_element_t = typename void_tuple_element::type; - template - using void_tuple_element_t = typename void_tuple_element::type; + template + struct basic_traits { + private: + typedef std::conditional_t::value, int, T>& first_type; - template - struct basic_traits { - private: - typedef std::conditional_t::value, int, T>& first_type; + public: + static const bool is_noexcept = it_is_noexcept; + static const bool is_member_function = std::is_void::value; + static const bool has_c_var_arg = has_c_variadic; + static const std::size_t arity = sizeof...(Args); + static const std::size_t free_arity = sizeof...(Args) + static_cast(!std::is_void::value); + typedef types args_list; + typedef std::tuple args_tuple; + typedef T object_type; + typedef R return_type; + typedef tuple_types returns_list; + typedef R(function_type)(Args...); + typedef std::conditional_t::value, args_list, types> free_args_list; + typedef std::conditional_t::value, R(Args...), R(first_type, Args...)> free_function_type; + typedef std::conditional_t::value, R (*)(Args...), R (*)(first_type, Args...)> free_function_pointer_type; + typedef std::remove_pointer_t signature_type; + template + using arg_at = void_tuple_element_t; + }; - public: - static const bool is_member_function = std::is_void::value; - static const bool has_c_var_arg = has_c_variadic; - static const std::size_t arity = sizeof...(Args); - static const std::size_t free_arity = sizeof...(Args)+static_cast(!std::is_void::value); - typedef types args_list; - typedef std::tuple args_tuple; - typedef T object_type; - typedef R return_type; - typedef tuple_types returns_list; - typedef R(function_type)(Args...); - typedef std::conditional_t::value, args_list, types> free_args_list; - typedef std::conditional_t::value, R(Args...), R(first_type, Args...)> free_function_type; - typedef std::conditional_t::value, R(*)(Args...), R(*)(first_type, Args...)> free_function_pointer_type; - typedef std::remove_pointer_t signature_type; - template - using arg_at = void_tuple_element_t; - }; + template ::value> + struct fx_traits : basic_traits {}; - template::value> - struct fx_traits : basic_traits {}; + // Free Functions + template + struct fx_traits : basic_traits { + typedef R (*function_pointer_type)(Args...); + }; - // Free Functions - template - struct fx_traits : basic_traits { - typedef R(*function_pointer_type)(Args...); - }; + template + struct fx_traits : basic_traits { + typedef R (*function_pointer_type)(Args...); + }; - template - struct fx_traits : basic_traits { - typedef R(*function_pointer_type)(Args...); - }; + template + struct fx_traits : basic_traits { + typedef R (*function_pointer_type)(Args..., ...); + }; - template - struct fx_traits : basic_traits { - typedef R(*function_pointer_type)(Args..., ...); - }; + template + struct fx_traits : basic_traits { + typedef R (*function_pointer_type)(Args..., ...); + }; - template - struct fx_traits : basic_traits { - typedef R(*function_pointer_type)(Args..., ...); - }; + // Member Functions + /* C-Style Variadics */ + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args...); + }; - // Member Functions - /* C-Style Variadics */ - template - struct fx_traits : basic_traits { - typedef R(T::* function_pointer_type)(Args...); - }; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args..., ...); + }; - template - struct fx_traits : basic_traits { - typedef R(T::* function_pointer_type)(Args..., ...); - }; + /* Const Volatile */ + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args...) const; + }; - /* Const Volatile */ - template - struct fx_traits : basic_traits { - typedef R(T::* function_pointer_type)(Args...) const; - }; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args..., ...) const; + }; - template - struct fx_traits : basic_traits { - typedef R(T::* function_pointer_type)(Args..., ...) const; - }; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args...) const volatile; + }; - template - struct fx_traits : basic_traits { - typedef R(T::* function_pointer_type)(Args...) const volatile; - }; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args..., ...) const volatile; + }; - template - struct fx_traits : basic_traits { - typedef R(T::* function_pointer_type)(Args..., ...) const volatile; - }; + /* Member Function Qualifiers */ + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args...) &; + }; - /* Member Function Qualifiers */ - template - struct fx_traits : basic_traits { - typedef R(T::* function_pointer_type)(Args...) &; - }; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args..., ...) &; + }; - template - struct fx_traits : basic_traits { - typedef R(T::* function_pointer_type)(Args..., ...) &; - }; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args...) const&; + }; - template - struct fx_traits : basic_traits { - typedef R(T::* function_pointer_type)(Args...) const &; - }; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args..., ...) const&; + }; - template - struct fx_traits : basic_traits { - typedef R(T::* function_pointer_type)(Args..., ...) const &; - }; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args...) const volatile&; + }; - template - struct fx_traits : basic_traits { - typedef R(T::* function_pointer_type)(Args...) const volatile &; - }; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args..., ...) const volatile&; + }; - template - struct fx_traits : basic_traits { - typedef R(T::* function_pointer_type)(Args..., ...) const volatile &; - }; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args...) &&; + }; - template - struct fx_traits : basic_traits { - typedef R(T::* function_pointer_type)(Args...) && ; - }; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args..., ...) &&; + }; - template - struct fx_traits : basic_traits { - typedef R(T::* function_pointer_type)(Args..., ...) && ; - }; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args...) const&&; + }; - template - struct fx_traits : basic_traits { - typedef R(T::* function_pointer_type)(Args...) const &&; - }; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args..., ...) const&&; + }; - template - struct fx_traits : basic_traits { - typedef R(T::* function_pointer_type)(Args..., ...) const &&; - }; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args...) const volatile&&; + }; - template - struct fx_traits : basic_traits { - typedef R(T::* function_pointer_type)(Args...) const volatile &&; - }; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args..., ...) const volatile&&; + }; - template - struct fx_traits : basic_traits { - typedef R(T::* function_pointer_type)(Args..., ...) const volatile &&; - }; +#if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE - template - struct fx_traits : fx_traits::function_type, false> {}; + template + struct fx_traits : basic_traits { + typedef R (*function_pointer_type)(Args...) noexcept; + }; - template::value> - struct callable_traits : fx_traits> { + template + struct fx_traits : basic_traits { + typedef R (*function_pointer_type)(Args...) noexcept; + }; - }; + template + struct fx_traits : basic_traits { + typedef R (*function_pointer_type)(Args..., ...) noexcept; + }; - template - struct callable_traits { - typedef R Arg; - typedef T object_type; - using signature_type = R(T::*); - static const bool is_member_function = false; - static const std::size_t arity = 1; - static const std::size_t free_arity = 2; - typedef std::tuple args_tuple; - typedef R return_type; - typedef types args_list; - typedef types free_args_list; - typedef meta::tuple_types returns_list; - typedef R(function_type)(T&, R); - typedef R(*function_pointer_type)(T&, R); - typedef R(*free_function_pointer_type)(T&, R); - template - using arg_at = void_tuple_element_t; - }; - } // meta_detail + template + struct fx_traits : basic_traits { + typedef R (*function_pointer_type)(Args..., ...) noexcept; + }; - template - struct bind_traits : meta_detail::callable_traits {}; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args...) noexcept; + }; - template - using function_args_t = typename bind_traits::args_list; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args..., ...) noexcept; + }; - template - using function_signature_t = typename bind_traits::signature_type; + /* Const Volatile */ + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args...) const noexcept; + }; - template - using function_return_t = typename bind_traits::return_type; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args..., ...) const noexcept; + }; - } // meta -} // sol + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args...) const volatile noexcept; + }; -// end of sol/bind_traits.hpp + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args..., ...) const volatile noexcept; + }; -#include -#include -#include + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args...) & noexcept; + }; -namespace sol { - template - using index_value = std::integral_constant; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args..., ...) & noexcept; + }; - namespace meta { - template - struct identity { typedef T type; }; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args...) const& noexcept; + }; - template - using identity_t = typename identity::type; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args..., ...) const& noexcept; + }; - template - struct is_tuple : std::false_type { }; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args...) const volatile& noexcept; + }; - template - struct is_tuple> : std::true_type { }; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args..., ...) const volatile& noexcept; + }; - template - struct is_builtin_type : std::integral_constant::value || std::is_pointer::value || std::is_array::value> {}; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args...) && noexcept; + }; - template - struct unwrapped { - typedef T type; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args..., ...) && noexcept; }; - template - struct unwrapped> { - typedef T type; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args...) const&& noexcept; }; - template - using unwrapped_t = typename unwrapped::type; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args..., ...) const&& noexcept; + }; - template - struct unwrap_unqualified : unwrapped> {}; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args...) const volatile&& noexcept; + }; - template - using unwrap_unqualified_t = typename unwrap_unqualified::type; + template + struct fx_traits : basic_traits { + typedef R (T::*function_pointer_type)(Args..., ...) const volatile&& noexcept; + }; - template - struct remove_member_pointer; +#endif // noexcept is part of a function's type - template - struct remove_member_pointer { - typedef R type; +#if defined(_MSC_VER) && defined(_M_IX86) + template + struct fx_traits : basic_traits { + typedef R(__stdcall* function_pointer_type)(Args...); }; - template - struct remove_member_pointer { - typedef R type; + template + struct fx_traits : basic_traits { + typedef R(__stdcall* function_pointer_type)(Args...); }; - template - using remove_member_pointer_t = remove_member_pointer; + template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args...); + }; - template class Templ, typename T> - struct is_specialization_of : std::false_type { }; - template class Templ> - struct is_specialization_of> : std::true_type { }; + /* Const Volatile */ + template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args...) const; + }; - template - struct all_same : std::true_type { }; + template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile; + }; - template - struct all_same : std::integral_constant ::value && all_same::value> { }; + /* Member Function Qualifiers */ + template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args...) &; + }; - template - struct any_same : std::false_type { }; + template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args...) const&; + }; - template - struct any_same : std::integral_constant ::value || any_same::value> { }; + template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile&; + }; - template - using invoke_t = typename T::type; + template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args...) &&; + }; - template - using boolean = std::integral_constant; + template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args...) const&&; + }; - template - using neg = boolean; + template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile&&; + }; - template - using condition = std::conditional_t; +#if defined(SOL_NOEXCEPT_FUNCTION_TYPE) && SOL_NOEXCEPT_FUNCTION_TYPE - template - struct all : boolean {}; + template + struct fx_traits : basic_traits { + typedef R(__stdcall* function_pointer_type)(Args...) noexcept; + }; - template - struct all : condition, boolean> {}; + template + struct fx_traits : basic_traits { + typedef R(__stdcall* function_pointer_type)(Args...) noexcept; + }; - template - struct any : boolean {}; + /* __stdcall cannot be applied to functions with varargs*/ + /*template + struct fx_traits<__stdcall R(Args..., ...) noexcept, false> : basic_traits { + typedef R(__stdcall* function_pointer_type)(Args..., ...) noexcept; + }; - template - struct any : condition, any> {}; + template + struct fx_traits : basic_traits { + typedef R(__stdcall* function_pointer_type)(Args..., ...) noexcept; + };*/ - enum class enable_t { - _ + template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args...) noexcept; }; - constexpr const auto enabler = enable_t::_; + /* __stdcall does not work with varargs */ + /*template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args..., ...) noexcept; + };*/ - template - using disable_if_t = std::enable_if_t; + /* Const Volatile */ + template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args...) const noexcept; + }; - template - using enable = std::enable_if_t::value, enable_t>; + /* __stdcall does not work with varargs */ + /*template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args..., ...) const noexcept; + };*/ - template - using disable = std::enable_if_t>::value, enable_t>; + template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile noexcept; + }; - template - using disable_any = std::enable_if_t>::value, enable_t>; + /* __stdcall does not work with varargs */ + /*template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args..., ...) const volatile noexcept; + };*/ - template - struct find_in_pack_v : boolean { }; + template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args...) & noexcept; + }; - template - struct find_in_pack_v : any, find_in_pack_v> { }; + /* __stdcall does not work with varargs */ + /*template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args..., ...) & noexcept; + };*/ - namespace meta_detail { - template - struct index_in_pack : std::integral_constant { }; + template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args...) const& noexcept; + }; - template - struct index_in_pack : std::conditional_t::value, std::integral_constant, index_in_pack> { }; - } + /* __stdcall does not work with varargs */ + /*template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args..., ...) const& noexcept; + };*/ - template - struct index_in_pack : meta_detail::index_in_pack<0, T, Args...> { }; + template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile& noexcept; + }; - template - struct index_in : meta_detail::index_in_pack<0, T, List> { }; + /* __stdcall does not work with varargs */ + /*template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args..., ...) const volatile& noexcept; + };*/ - template - struct index_in> : meta_detail::index_in_pack<0, T, Args...> { }; - - template - struct at_in_pack {}; - - template - using at_in_pack_t = typename at_in_pack::type; - - template - struct at_in_pack : std::conditional> {}; - - template - struct at_in_pack<0, Arg, Args...> { typedef Arg type; }; - - namespace meta_detail { - template class Pred, typename... Ts> - struct count_for_pack : std::integral_constant {}; - template class Pred, typename T, typename... Ts> - struct count_for_pack : std::conditional_t < sizeof...(Ts) == 0 || Limit < 2, - std::integral_constant(Limit != 0 && Pred::value)>, - count_for_pack(Pred::value), Pred, Ts...> - > { }; - template class Pred, typename... Ts> - struct count_2_for_pack : std::integral_constant {}; - template class Pred, typename T, typename U, typename... Ts> - struct count_2_for_pack : std::conditional_t(Pred::value)>, - count_2_for_pack(Pred::value), Pred, Ts...> - > { }; - } // meta_detail - - template class Pred, typename... Ts> - struct count_for_pack : meta_detail::count_for_pack { }; - - template class Pred, typename List> - struct count_for; - - template class Pred, typename... Args> - struct count_for> : count_for_pack {}; - - template class Pred, typename... Ts> - struct count_for_to_pack : meta_detail::count_for_pack { }; - - template class Pred, typename... Ts> - struct count_2_for_pack : meta_detail::count_2_for_pack<0, Pred, Ts...> { }; - - template - struct return_type { - typedef std::tuple type; + template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args...) && noexcept; }; - template - struct return_type { - typedef T type; - }; + /* __stdcall does not work with varargs */ + /*template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args..., ...) && noexcept; + };*/ - template<> - struct return_type<> { - typedef void type; + template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args...) const&& noexcept; }; - template - using return_type_t = typename return_type::type; - - namespace meta_detail { - template struct always_true : std::true_type {}; - struct is_invokable_tester { - template - always_true()(std::declval()...))> static test(int); - template - std::false_type static test(...); - }; - } // meta_detail - - template - struct is_invokable; - template - struct is_invokable : decltype(meta_detail::is_invokable_tester::test(0)) {}; - - namespace meta_detail { - - template>::value> - struct is_callable : std::is_function> {}; - - template - struct is_callable { - using yes = char; - using no = struct { char s[2]; }; - - struct F { void operator()(); }; - struct Derived : T, F {}; - template struct Check; - - template - static no test(Check*); - - template - static yes test(...); + /* __stdcall does not work with varargs */ + /*template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args..., ...) const&& noexcept; + };*/ - static const bool value = sizeof(test(0)) == sizeof(yes); - }; + template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args...) const volatile&& noexcept; + }; - struct has_begin_end_impl { - template, - typename B = decltype(std::declval().begin()), - typename E = decltype(std::declval().end())> - static std::true_type test(int); + /* __stdcall does not work with varargs */ + /*template + struct fx_traits : basic_traits { + typedef R (__stdcall T::*function_pointer_type)(Args..., ...) const volatile&& noexcept; + };*/ +#endif // noexcept is part of a function's type +#endif // __stdcall x86 VC++ bug - template - static std::false_type test(...); - }; + template + struct fx_traits : fx_traits::function_type, false> {}; - struct has_key_value_pair_impl { - template, - typename V = typename U::value_type, - typename F = decltype(std::declval().first), - typename S = decltype(std::declval().second)> - static std::true_type test(int); + template ::value> + struct callable_traits : fx_traits> { + }; - template - static std::false_type test(...); - }; + template + struct callable_traits { + typedef std::conditional_t::value, std::add_lvalue_reference_t, R> return_type; + typedef return_type Arg; + typedef T object_type; + using signature_type = R(T::*); + static const bool is_noexcept = false; + static const bool is_member_function = false; + static const std::size_t arity = 1; + static const std::size_t free_arity = 2; + typedef std::tuple args_tuple; + typedef types args_list; + typedef types free_args_list; + typedef meta::tuple_types returns_list; + typedef return_type(function_type)(T&, return_type); + typedef return_type(*function_pointer_type)(T&, Arg); + typedef return_type(*free_function_pointer_type)(T&, Arg); + template + using arg_at = void_tuple_element_t; + }; - template () < std::declval())> - std::true_type supports_op_less_test(const T&); - std::false_type supports_op_less_test(...); - template () == std::declval())> - std::true_type supports_op_equal_test(const T&); - std::false_type supports_op_equal_test(...); - template () <= std::declval())> - std::true_type supports_op_less_equal_test(const T&); - std::false_type supports_op_less_equal_test(...); + } // namespace meta_detail - } // meta_detail + template + struct bind_traits : meta_detail::callable_traits {}; - template - using supports_op_less = decltype(meta_detail::supports_op_less_test(std::declval())); - template - using supports_op_equal = decltype(meta_detail::supports_op_equal_test(std::declval())); - template - using supports_op_less_equal = decltype(meta_detail::supports_op_less_equal_test(std::declval())); + template + using function_args_t = typename bind_traits::args_list; - template - struct is_callable : boolean::value> {}; + template + using function_signature_t = typename bind_traits::signature_type; - template - struct has_begin_end : decltype(meta_detail::has_begin_end_impl::test(0)) {}; + template + using function_return_t = typename bind_traits::return_type; +} +} // namespace sol::meta - template - struct has_key_value_pair : decltype(meta_detail::has_key_value_pair_impl::test(0)) {}; +// end of sol/bind_traits.hpp - template - using is_string_constructible = any, const char*>, std::is_same, char>, std::is_same, std::string>, std::is_same, std::initializer_list>>; +// beginning of sol/string_view.hpp - template - using is_c_str = any< - std::is_same>, const char*>, - std::is_same>, char*>, - std::is_same, std::string> - >; +#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES +#include +#endif // C++17 features +#include +#if defined(SOL_USE_BOOST) && SOL_USE_BOOST +#include +#endif - template - struct is_move_only : all< - neg>, - neg>>, - std::is_move_constructible> - > {}; +namespace sol { +#if defined(SOL_CXX17_FEATURES) && SOL_CXX17_FEATURES + template > + using basic_string_view = std::basic_string_view; + typedef std::string_view string_view; + typedef std::wstring_view wstring_view; + typedef std::u16string_view u16string_view; + typedef std::u32string_view u32string_view; + typedef std::hash string_view_hash; +#else + template > + struct basic_string_view { + std::size_t s; + const Char* p; - template - using is_not_move_only = neg>; + basic_string_view(const std::string& r) + : basic_string_view(r.data(), r.size()) { + } + basic_string_view(const Char* ptr) + : basic_string_view(ptr, Traits::length(ptr)) { + } + basic_string_view(const Char* ptr, std::size_t sz) + : s(sz), p(ptr) { + } - namespace meta_detail { - template >> = meta::enabler> - decltype(auto) force_tuple(T&& x) { - return std::forward_as_tuple(std::forward(x)); - } + static int compare(const Char* lhs_p, std::size_t lhs_sz, const Char* rhs_p, std::size_t rhs_sz) { + int result = Traits::compare(lhs_p, rhs_p, lhs_sz < rhs_sz ? lhs_sz : rhs_sz); + if (result != 0) + return result; + if (lhs_sz < rhs_sz) + return -1; + if (lhs_sz > rhs_sz) + return 1; + return 0; + } - template >> = meta::enabler> - decltype(auto) force_tuple(T&& x) { - return std::forward(x); - } - } // meta_detail + const Char* begin() const { + return p; + } - template - decltype(auto) tuplefy(X&&... x) { - return std::tuple_cat(meta_detail::force_tuple(std::forward(x))...); + const Char* end() const { + return p + s; } - } // meta - namespace detail { - template - decltype(auto) forward_get(Tuple&& tuple) { - return std::forward>(std::get(tuple)); + + const Char* cbegin() const { + return p; } - template - auto forward_tuple_impl(std::index_sequence, Tuple&& tuple) -> decltype(std::tuple(tuple))...>(forward_get(tuple)...)) { - return std::tuple(tuple))...>(std::move(std::get(tuple))...); + const Char* cend() const { + return p + s; } - template - auto forward_tuple(Tuple&& tuple) { - auto x = forward_tuple_impl(std::make_index_sequence>::value>(), std::forward(tuple)); - return x; + const Char* data() const { + return p; } - template - auto unwrap(T&& item) -> decltype(std::forward(item)) { - return std::forward(item); + std::size_t size() const { + return s; } - template - T& unwrap(std::reference_wrapper arg) { - return arg.get(); + std::size_t length() const { + return size(); } - template - auto deref(T&& item) -> decltype(std::forward(item)) { - return std::forward(item); + operator std::basic_string() const { + return std::basic_string(data(), size()); } - template - inline T& deref(T* item) { - return *item; + bool operator==(const basic_string_view& r) const { + return compare(p, s, r.data(), r.size()) == 0; } - template - inline std::add_lvalue_reference_t deref(std::unique_ptr& item) { - return *item; + bool operator==(const Char* r) const { + return compare(r, Traits::length(r), p, s) == 0; } - template - inline std::add_lvalue_reference_t deref(std::shared_ptr& item) { - return *item; + bool operator==(const std::basic_string& r) const { + return compare(r.data(), r.size(), p, s) == 0; } - template - inline std::add_lvalue_reference_t deref(const std::unique_ptr& item) { - return *item; + bool operator!=(const basic_string_view& r) const { + return !(*this == r); } - template - inline std::add_lvalue_reference_t deref(const std::shared_ptr& item) { - return *item; + bool operator!=(const char* r) const { + return !(*this == r); } - template - inline T* ptr(T& val) { - return std::addressof(val); + bool operator!=(const std::basic_string& r) const { + return !(*this == r); } + }; - template - inline T* ptr(std::reference_wrapper val) { - return std::addressof(val.get()); + template > + struct basic_string_view_hash { + typedef basic_string_view argument_type; + typedef std::size_t result_type; + + template + result_type operator()(const std::basic_string& r) const { + return (*this)(argument_type(r.c_str(), r.size())); } - template - inline T* ptr(T* val) { - return val; + result_type operator()(const argument_type& r) const { +#if defined(SOL_USE_BOOST) && SOL_USE_BOOST + return boost::hash_range(r.begin(), r.end()); +#else + // Modified, from libstdc++ + // An implementation attempt at Fowler No Voll, 1a. + // Supposedly, used in MSVC, + // GCC (libstdc++) uses MurmurHash of some sort for 64-bit though...? + // But, well. Can't win them all, right? + // This should normally only apply when NOT using boost, + // so this should almost never be tapped into... + std::size_t hash = 0; + const unsigned char* cptr = reinterpret_cast(r.data()); + for (std::size_t sz = r.size(); sz != 0; --sz) { + hash ^= static_cast(*cptr++); + hash *= static_cast(1099511628211ULL); + } + return hash; +#endif } - } // detail -} // sol + }; +} // namespace sol -// end of sol/traits.hpp +namespace std { + template + struct hash< ::sol::basic_string_view > : ::sol::basic_string_view_hash {}; +} // namespace std -// beginning of sol/object.hpp +namespace sol { + using string_view = basic_string_view; + using wstring_view = basic_string_view; + using u16string_view = basic_string_view; + using u32string_view = basic_string_view; + using string_view_hash = std::hash; +#endif // C++17 Support +} // namespace sol -// beginning of sol/reference.hpp +// end of sol/string_view.hpp -// beginning of sol/types.hpp +#include +#include +#include +#include +#include -// beginning of sol/optional.hpp +namespace sol { + template + using index_value = std::integral_constant; -// beginning of sol/compatibility.hpp + namespace meta { + template + struct identity { typedef T type; }; -// beginning of sol/compatibility/version.hpp + template + using identity_t = typename identity::type; -#ifdef SOL_USING_CXX_LUA -#include -#include -#include -#else -#include -#endif // C++-compiler Lua - -#if defined(_WIN32) || defined(_MSC_VER) -#ifndef SOL_CODECVT_SUPPORT -#define SOL_CODECVT_SUPPORT 1 -#endif // sol codecvt support -#elif defined(__GNUC__) -#if __GNUC__ >= 5 -#ifndef SOL_CODECVT_SUPPORT -#define SOL_CODECVT_SUPPORT 1 -#endif // codecvt support -#endif // g++ 5.x.x (MinGW too) -#else -#endif // Windows/VC++ vs. g++ vs Others + template + struct is_tuple : std::false_type {}; -#ifdef LUAJIT_VERSION -#ifndef SOL_LUAJIT -#define SOL_LUAJIT -#define SOL_LUAJIT_VERSION LUAJIT_VERSION_NUM -#endif // sol luajit -#endif // luajit + template + struct is_tuple> : std::true_type {}; -#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 502 -#define SOL_LUA_VERSION LUA_VERSION_NUM -#elif defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501 -#define SOL_LUA_VERSION LUA_VERSION_NUM -#elif !defined(LUA_VERSION_NUM) -#define SOL_LUA_VERSION 500 -#else -#define SOL_LUA_VERSION 502 -#endif // Lua Version 502, 501 || luajit, 500 + template + struct is_builtin_type : std::integral_constant::value || std::is_pointer::value || std::is_array::value> {}; -#ifdef _MSC_VER -#ifdef _DEBUG -#ifndef NDEBUG -#ifndef SOL_CHECK_ARGUMENTS -#endif // Check Arguments -#ifndef SOL_SAFE_USERTYPE -#define SOL_SAFE_USERTYPE -#endif // Safe Usertypes -#endif // NDEBUG -#endif // Debug - -#ifndef _CPPUNWIND -#ifndef SOL_NO_EXCEPTIONS -#define SOL_NO_EXCEPTIONS 1 -#endif -#endif // Automatic Exceptions + template + struct unwrapped { + typedef T type; + }; -#ifndef _CPPRTTI -#ifndef SOL_NO_RTTI -#define SOL_NO_RTTI 1 -#endif -#endif // Automatic RTTI + template + struct unwrapped> { + typedef T type; + }; -#elif defined(__GNUC__) || defined(__clang__) + template + using unwrapped_t = typename unwrapped::type; -#ifndef NDEBUG -#ifndef __OPTIMIZE__ -#ifndef SOL_CHECK_ARGUMENTS -#endif // Check Arguments -#ifndef SOL_SAFE_USERTYPE -#define SOL_SAFE_USERTYPE -#endif // Safe Usertypes -#endif // g++ optimizer flag -#endif // Not Debug - -#ifndef __EXCEPTIONS -#ifndef SOL_NO_EXCEPTIONS -#define SOL_NO_EXCEPTIONS 1 -#endif -#endif // No Exceptions + template + struct unwrap_unqualified : unwrapped> {}; -#ifndef __GXX_RTTI -#ifndef SOL_NO_RTII -#define SOL_NO_RTTI 1 -#endif -#endif // No RTTI + template + using unwrap_unqualified_t = typename unwrap_unqualified::type; -#endif // vc++ || clang++/g++ + template + struct remove_member_pointer; -#ifndef SOL_SAFE_USERTYPE -#ifdef SOL_CHECK_ARGUMENTS -#define SOL_SAFE_USERTYPE -#endif // Turn on Safety for all -#endif // Safe Usertypes + template + struct remove_member_pointer { + typedef R type; + }; -// end of sol/compatibility/version.hpp + template + struct remove_member_pointer { + typedef R type; + }; -#ifndef SOL_NO_COMPAT + template + using remove_member_pointer_t = remove_member_pointer; -#ifdef __cplusplus -extern "C" { -#endif -// beginning of sol/compatibility/5.1.0.h + namespace meta_detail { + template class Templ> + struct is_specialization_of : std::false_type {}; + template class Templ> + struct is_specialization_of, Templ> : std::true_type {}; + } -#ifndef SOL_5_1_0_H -#define SOL_5_1_0_H + template class Templ> + using is_specialization_of = meta_detail::is_specialization_of, Templ>; -#if SOL_LUA_VERSION == 501 -/* Lua 5.1 */ + template + struct all_same : std::true_type {}; -#include -#include -#include + template + struct all_same : std::integral_constant::value && all_same::value> {}; -/* LuaJIT doesn't define these unofficial macros ... */ -#if !defined(LUAI_INT32) -#include -#if INT_MAX-20 < 32760 -#define LUAI_INT32 long -#define LUAI_UINT32 unsigned long -#elif INT_MAX > 2147483640L -#define LUAI_INT32 int -#define LUAI_UINT32 unsigned int -#else -#error "could not detect suitable lua_Unsigned datatype" -#endif -#endif - -/* LuaJIT does not have the updated error codes for thread status/function returns */ -#ifndef LUA_ERRGCMM -#define LUA_ERRGCMM (LUA_ERRERR + 1) -#endif // LUA_ERRGCMM - -/* LuaJIT does not support continuation contexts / return error codes? */ -#ifndef LUA_KCONTEXT -#define LUA_KCONTEXT std::ptrdiff_t -typedef LUA_KCONTEXT lua_KContext; -typedef int(*lua_KFunction) (lua_State *L, int status, lua_KContext ctx); -#endif // LUA_KCONTEXT - -#define LUA_OPADD 0 -#define LUA_OPSUB 1 -#define LUA_OPMUL 2 -#define LUA_OPDIV 3 -#define LUA_OPMOD 4 -#define LUA_OPPOW 5 -#define LUA_OPUNM 6 -#define LUA_OPEQ 0 -#define LUA_OPLT 1 -#define LUA_OPLE 2 - -typedef LUAI_UINT32 lua_Unsigned; - -typedef struct luaL_Buffer_52 { - luaL_Buffer b; /* make incorrect code crash! */ - char *ptr; - size_t nelems; - size_t capacity; - lua_State *L2; -} luaL_Buffer_52; -#define luaL_Buffer luaL_Buffer_52 - -#define lua_tounsigned(L, i) lua_tounsignedx(L, i, NULL) - -#define lua_rawlen(L, i) lua_objlen(L, i) - -inline void lua_callk(lua_State *L, int nargs, int nresults, lua_KContext, lua_KFunction) { - // should probably warn the user of Lua 5.1 that continuation isn't supported... - lua_call(L, nargs, nresults); -} -inline int lua_pcallk(lua_State *L, int nargs, int nresults, int errfunc, lua_KContext, lua_KFunction) { - // should probably warn the user of Lua 5.1 that continuation isn't supported... - return lua_pcall(L, nargs, nresults, errfunc); -} -void lua_arith(lua_State *L, int op); -int lua_compare(lua_State *L, int idx1, int idx2, int op); -void lua_pushunsigned(lua_State *L, lua_Unsigned n); -lua_Unsigned luaL_checkunsigned(lua_State *L, int i); -lua_Unsigned lua_tounsignedx(lua_State *L, int i, int *isnum); -lua_Unsigned luaL_optunsigned(lua_State *L, int i, lua_Unsigned def); -lua_Integer lua_tointegerx(lua_State *L, int i, int *isnum); -void lua_len(lua_State *L, int i); -int luaL_len(lua_State *L, int i); -const char *luaL_tolstring(lua_State *L, int idx, size_t *len); -void luaL_requiref(lua_State *L, char const* modname, lua_CFunction openf, int glb); + template + struct any_same : std::false_type {}; -#define luaL_buffinit luaL_buffinit_52 -void luaL_buffinit(lua_State *L, luaL_Buffer_52 *B); + template + struct any_same : std::integral_constant::value || any_same::value> {}; -#define luaL_prepbuffsize luaL_prepbuffsize_52 -char *luaL_prepbuffsize(luaL_Buffer_52 *B, size_t s); + template + using boolean = std::integral_constant; -#define luaL_addlstring luaL_addlstring_52 -void luaL_addlstring(luaL_Buffer_52 *B, const char *s, size_t l); + template + using invoke_t = typename T::type; -#define luaL_addvalue luaL_addvalue_52 -void luaL_addvalue(luaL_Buffer_52 *B); + template + using invoke_b = boolean; -#define luaL_pushresult luaL_pushresult_52 -void luaL_pushresult(luaL_Buffer_52 *B); + template + using neg = boolean; -#undef luaL_buffinitsize -#define luaL_buffinitsize(L, B, s) \ - (luaL_buffinit(L, B), luaL_prepbuffsize(B, s)) + template + using condition = std::conditional_t; -#undef luaL_prepbuffer -#define luaL_prepbuffer(B) \ - luaL_prepbuffsize(B, LUAL_BUFFERSIZE) + template + struct all : boolean {}; -#undef luaL_addchar -#define luaL_addchar(B, c) \ - ((void)((B)->nelems < (B)->capacity || luaL_prepbuffsize(B, 1)), \ - ((B)->ptr[(B)->nelems++] = (c))) + template + struct all : condition, boolean> {}; -#undef luaL_addsize -#define luaL_addsize(B, s) \ - ((B)->nelems += (s)) + template + struct any : boolean {}; -#undef luaL_addstring -#define luaL_addstring(B, s) \ - luaL_addlstring(B, s, strlen(s)) + template + struct any : condition, any> {}; -#undef luaL_pushresultsize -#define luaL_pushresultsize(B, s) \ - (luaL_addsize(B, s), luaL_pushresult(B)) - -typedef struct kepler_lua_compat_get_string_view { - const char *s; - size_t size; -} kepler_lua_compat_get_string_view; - -inline const char* kepler_lua_compat_get_string(lua_State* L, void* ud, size_t* size) { - kepler_lua_compat_get_string_view* ls = (kepler_lua_compat_get_string_view*) ud; - (void)L; - if (ls->size == 0) return NULL; - *size = ls->size; - ls->size = 0; - return ls->s; -} + enum class enable_t { + _ + }; -#if !defined(SOL_LUAJIT) || (SOL_LUAJIT_VERSION < 20100) + constexpr const auto enabler = enable_t::_; -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; - ls.s = buff; - ls.size = size; - return lua_load(L, kepler_lua_compat_get_string, &ls, name/*, mode*/); -} + template + using disable_if_t = std::enable_if_t; -#endif // LuaJIT 2.1.x beta and beyond + template + using enable = std::enable_if_t::value, enable_t>; -#endif /* Lua 5.1 */ + template + using disable = std::enable_if_t>::value, enable_t>; -#endif // SOL_5_1_0_H -// end of sol/compatibility/5.1.0.h + template + using enable_any = std::enable_if_t::value, enable_t>; -// beginning of sol/compatibility/5.0.0.h + template + using disable_any = std::enable_if_t>::value, enable_t>; -#ifndef SOL_5_0_0_H -#define SOL_5_0_0_H + template + struct find_in_pack_v : boolean {}; -#if SOL_LUA_VERSION < 501 -/* Lua 5.0 */ + template + struct find_in_pack_v : any, find_in_pack_v> {}; -#define LUA_QL(x) "'" x "'" -#define LUA_QS LUA_QL("%s") + namespace meta_detail { + template + struct index_in_pack : std::integral_constant {}; -#define luaL_Reg luaL_reg + template + struct index_in_pack : std::conditional_t::value, std::integral_constant, index_in_pack> {}; + } // namespace meta_detail -#define luaL_opt(L, f, n, d) \ - (lua_isnoneornil(L, n) ? (d) : f(L, n)) + template + struct index_in_pack : meta_detail::index_in_pack<0, T, Args...> {}; -#define luaL_addchar(B,c) \ - ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ - (*(B)->p++ = (char)(c))) + template + struct index_in : meta_detail::index_in_pack<0, T, List> {}; -#endif // Lua 5.0 + template + struct index_in> : meta_detail::index_in_pack<0, T, Args...> {}; -#endif // SOL_5_0_0_H -// end of sol/compatibility/5.0.0.h + template + struct at_in_pack {}; -// beginning of sol/compatibility/5.x.x.h + template + using at_in_pack_t = typename at_in_pack::type; -#ifndef SOL_5_X_X_H -#define SOL_5_X_X_H + template + struct at_in_pack : std::conditional> {}; -#if SOL_LUA_VERSION < 502 + template + struct at_in_pack<0, Arg, Args...> { typedef Arg type; }; -#define LUA_RIDX_GLOBALS LUA_GLOBALSINDEX + namespace meta_detail { + template class Pred, typename... Ts> + struct count_for_pack : std::integral_constant {}; + template class Pred, typename T, typename... Ts> + struct count_for_pack : std::conditional_t < sizeof...(Ts) + == 0 + || Limit<2, + std::integral_constant(Limit != 0 && Pred::value)>, + count_for_pack(Pred::value), Pred, Ts...>> {}; + template class Pred, typename... Ts> + struct count_2_for_pack : std::integral_constant {}; + template class Pred, typename T, typename U, typename... Ts> + struct count_2_for_pack : std::conditional_t(Pred::value)>, + count_2_for_pack(Pred::value), Pred, Ts...>> {}; + } // namespace meta_detail -#define LUA_OK 0 + template