Use invoke_result_t to get rid of deprecated result_of_t (Fixes #986).

Make thread local keyword optional by using a config macro SOL_NO_THREAD_LOCAL (off by default) (Fixes #979).
Cannot do anything for #985; that's an architecture issue.
This commit is contained in:
ThePhD 2020-07-04 03:58:24 -04:00
parent 62a831cda7
commit 862c01019a
No known key found for this signature in database
GPG Key ID: 1509DB1C0F702BFA
20 changed files with 721 additions and 606 deletions

View File

@ -35,18 +35,12 @@ include(Common/Core)
set(LUA_VANILLA_5.1_LATEST_VERSION 5.1.5)
set(LUA_VANILLA_5.2_LATEST_VERSION 5.2.4)
set(LUA_VANILLA_5.3_LATEST_VERSION 5.3.5)
set(LUA_VANILLA_5.4_LATEST_VERSION 5.4.0-beta)
set(LUA_VANILLA_5.4_LATEST_VERSION 5.4.0)
# exact version, coming from CI: pull directly from Lua and use external project to build
# list of known md5 / sha1: must update when there are changes
set(LUA_VANILLA_MD5_5.4.0-beta 961e2692a10a4a3c6fe80086e4cbefd5)
set(LUA_VANILLA_SHA1_5.4.0-beta 5d018de9b1f69b7e334dc3fa43b815669e103880)
set(LUA_VANILLA_MD5_5.4.0-alpha d49d30b394794b96ffad53513ac647a5)
set(LUA_VANILLA_SHA1_5.4.0-alpha cf3559dc43cad35463740c6fbedeb1ea501e5e23)
set(LUA_VANILLA_MD5_5.4.0-work2 3cdf2a4eb84dde6b6aaf5d2d1de07be9)
set(LUA_VANILLA_SHA1_5.4.0-work2 e8484e61c5c338e3ec2f75dbe0f6703d079fecf9)
set(LUA_VANILLA_MD5_5.4.0-work1 0ff232b8658884155a43cf72212edbd9)
set(LUA_VANILLA_SHA1_5.4.0-work1 a8193b14ed3869917d1102cb0418cf9dfb0d9baf)
set(LUA_VANILLA_MD5_5.4.0 dbf155764e5d433fc55ae80ea7060b60)
set(LUA_VANILLA_SHA1_5.4.0 8cdbffa8a214a23d190d7c45f38c19518ae62e89)
set(LUA_VANILLA_MD5_5.3.5 4f4b4f323fd3514a68e0ab3da8ce3455)
set(LUA_VANILLA_SHA1_5.3.5 112eb10ff04d1b4c9898e121d6bdf54a81482447)
set(LUA_VANILLA_MD5_5.3.4 53a9c68bcc0eda58bdc2095ad5cdfc63)

View File

@ -30,7 +30,8 @@
// though the core abstractions remain the same
#include "feature_test.hpp"
#include "compatibility/version.hpp"
#include "compatibility/lua_version.hpp"
#include "version.hpp"
#if !defined(SOL_NO_COMPAT) || !(SOL_NO_COMPAT)

View File

@ -21,11 +21,13 @@
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef SOL_VERSION_HPP
#define SOL_VERSION_HPP
#ifndef SOL_COMPATIBILITY_VERSION_HPP
#define SOL_COMPATIBILITY_VERSION_HPP
#include "../feature_test.hpp"
// clang-format off
#if defined(SOL_USING_CXX_LUA) && SOL_USING_CXX_LUA
#include <lua.h>
#include <lualib.h>
@ -95,4 +97,6 @@
#define SOL_LUA_VERSION 503
#endif // Lua Version 503, 502, 501 || luajit, 500
#endif // SOL_VERSION_HPP
// clang-format on
#endif // SOL_COMPATIBILITY_VERSION_HPP

View File

@ -1,29 +0,0 @@
// sol3
// The MIT License (MIT)
// Copyright (c) 2013-2019 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
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef SOL_CONFIG_SETUP_HPP
#define SOL_CONFIG_SETUP_HPP
#endif // SOL_CONFIG_SETUP_HPP

View File

@ -49,6 +49,6 @@
#endif // Clang screws up variant
#include <sol/config.hpp>
#include "config_setup.hpp"
#include "version.hpp"
#endif // SOL_FEATURE_TEST_HPP

View File

@ -34,6 +34,7 @@ namespace sol {
struct arr : detail::ebco<std::initializer_list<lua_value>> {
private:
using base_t = detail::ebco<std::initializer_list<lua_value>>;
public:
using base_t::base_t;
};
@ -47,7 +48,11 @@ namespace sol {
using is_lua_value_single_constructible = meta::any<std::is_same<T, lua_value>, is_reference_or_lua_value_init_list<T>>;
static lua_State*& thread_local_lua_state() {
#if SOL_ON(SOL_USE_THREAD_LOCAL_)
static thread_local lua_State* L = nullptr;
#else
static lua_State* L = nullptr;
#endif
return L;
}
@ -151,7 +156,7 @@ namespace sol {
return lua_value(L, stack::get<reference>(L, index, tracking));
}
};
}
} // namespace stack
} // namespace sol
#endif // SOL_LUA_VALUE_HPP

View File

@ -33,7 +33,7 @@ namespace sol {
// constexpr is fine for not-clang
namespace detail {
template <typename R, typename... Args, typename F, typename = std::result_of_t<meta::unqualified_t<F>(Args...)>>
template <typename R, typename... Args, typename F, typename = std::invoke_result_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;
@ -48,8 +48,8 @@ namespace sol {
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");
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>>
@ -57,7 +57,7 @@ namespace sol {
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...)>>
template <typename... Args, typename F, typename R = std::invoke_result_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));
}
@ -103,7 +103,7 @@ namespace sol {
// so don't use the constexpr versions inside of clang.
namespace detail {
template <typename R, typename... Args, typename F, typename = std::result_of_t<meta::unqualified_t<F>(Args...)>>
template <typename R, typename... Args, typename F, typename = std::invoke_result_t<meta::unqualified_t<F>, Args...>>
inline auto resolve_i(types<R(Args...)>, F &&) -> R (meta::unqualified_t<F>::*)(Args...) {
using Sig = R(Args...);
typedef meta::unqualified_t<F> Fu;
@ -118,8 +118,8 @@ namespace sol {
template <typename F>
inline 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");
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>>
@ -127,7 +127,7 @@ namespace sol {
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...)>>
template <typename... Args, typename F, typename R = std::invoke_result_t<F&, Args...>>
inline 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));
}

View File

@ -32,9 +32,10 @@
#include <cstdlib>
#include <cmath>
#include <optional>
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#if SOL_ON(SOL_STD_VARIANT_)
#include <variant>
#endif // variant
#endif // variant shenanigans (thanks, Mac OSX)
namespace sol { namespace stack {
template <typename T, typename>
@ -129,7 +130,7 @@ namespace sol { namespace stack {
}
};
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#if SOL_ON(SOL_STD_VARIANT_)
template <typename... Tn, typename C>
struct unqualified_check_getter<std::variant<Tn...>, C> {
typedef std::variant<Tn...> V;
@ -170,7 +171,7 @@ namespace sol { namespace stack {
return get_one(std::integral_constant<std::size_t, V_size::value>(), L, index, std::forward<Handler>(handler), tracking);
}
};
#endif // SOL_STD_VARIANT
#endif // standard variant
}} // namespace sol::stack
#endif // SOL_STACK_CHECK_UNQUALIFIED_GET_HPP

View File

@ -32,9 +32,9 @@
#include <utility>
#include <cmath>
#include <optional>
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#if SOL_ON(SOL_STD_VARIANT_)
#include <variant>
#endif // SOL_STD_VARIANT
#endif // variant shenanigans
namespace sol { namespace stack {
namespace stack_detail {
@ -567,7 +567,7 @@ namespace sol { namespace stack {
}
};
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#if SOL_ON(SOL_STD_VARIANT_)
template <typename... Tn>
struct unqualified_checker<std::variant<Tn...>, type::poly> {
@ -604,7 +604,7 @@ namespace sol { namespace stack {
}
};
#endif // SOL_STD_VARIANT
#endif // variant shenanigans
}} // namespace sol::stack

View File

@ -37,7 +37,7 @@
#include <cstdlib>
#include <cmath>
#include <string_view>
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#if SOL_ON(SOL_STD_VARIANT_)
#include <variant>
#endif // Apple clang screwed up
@ -986,7 +986,8 @@ namespace sol { namespace stack {
}
};
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#if SOL_ON(SOL_STD_VARIANT_)
template <typename... Tn>
struct unqualified_getter<std::variant<Tn...>> {
using V = std::variant<Tn...>;
@ -1020,7 +1021,7 @@ namespace sol { namespace stack {
return get_one(std::integral_constant<std::size_t, 0>(), L, index, tracking);
}
};
#endif // SOL_STD_VARIANT
#endif // variant
}} // namespace sol::stack

View File

@ -24,7 +24,7 @@
#ifndef SOL_STACK_GUARD_HPP
#define SOL_STACK_GUARD_HPP
#include "compatibility/version.hpp"
#include "compatibility/lua_version.hpp"
#include "error.hpp"
#include <functional>
@ -46,11 +46,9 @@ namespace sol {
int top;
std::function<void(int, int)> on_mismatch;
stack_guard(lua_State* L)
: stack_guard(L, lua_gettop(L)) {
stack_guard(lua_State* L) : stack_guard(L, lua_gettop(L)) {
}
stack_guard(lua_State* L, int top, std::function<void(int, int)> fx = detail::stack_fail)
: L(L), top(top), on_mismatch(std::move(fx)) {
stack_guard(lua_State* L, int top, std::function<void(int, int)> fx = detail::stack_fail) : L(L), top(top), on_mismatch(std::move(fx)) {
}
bool check_stack(int modification = 0) const {
int bottom = lua_gettop(L) + modification;

View File

@ -37,7 +37,7 @@
#include <limits>
#include <cmath>
#include <string_view>
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#if SOL_ON(SOL_STD_VARIANT_)
#include <variant>
#endif // Can use variant
@ -1189,7 +1189,7 @@ namespace sol { namespace stack {
}
};
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#if SOL_ON(SOL_STD_VARIANT_)
namespace stack_detail {
struct push_function {

View File

@ -116,16 +116,15 @@ namespace sol {
template <bool raw, typename Pairs, std::size_t... I>
void tuple_set(std::index_sequence<I...>, Pairs&& pairs) {
constexpr static bool global = top_level && (meta::count_even_for_pack_v<meta::is_c_str, meta::unqualified_t<decltype(std::get<I * 2>(std::forward<Pairs>(pairs)))>...> > 0);
constexpr static bool global = top_level
&& (meta::count_even_for_pack_v<meta::is_c_str, meta::unqualified_t<decltype(std::get<I * 2>(std::forward<Pairs>(pairs)))>...> > 0);
auto pp = stack::push_pop<global>(*this);
int table_index = pp.index_of(*this);
lua_State* L = base_t::lua_state();
(void)table_index;
(void)L;
void(detail::swallow{ (stack::set_field<(top_level), raw>(L,
std::get<I * 2>(std::forward<Pairs>(pairs)),
std::get<I * 2 + 1>(std::forward<Pairs>(pairs)),
table_index),
void(detail::swallow { (stack::set_field<(top_level), raw>(
L, std::get<I * 2>(std::forward<Pairs>(pairs)), std::get<I * 2 + 1>(std::forward<Pairs>(pairs)), table_index),
0)... });
}
@ -224,7 +223,8 @@ namespace sol {
using KeyU = meta::unqualified_t<Key>;
if constexpr (std::is_same_v<KeyU, update_if_empty_t>) {
(void)key;
traverse_set_deep<global, raw, static_cast<detail::insert_mode>(mode | detail::insert_mode::update_if_empty)>(table_index, std::forward<Keys>(keys)...);
traverse_set_deep<global, raw, static_cast<detail::insert_mode>(mode | detail::insert_mode::update_if_empty)>(
table_index, std::forward<Keys>(keys)...);
}
else if constexpr (std::is_same_v<KeyU, create_if_nil_t>) {
(void)key;
@ -423,7 +423,8 @@ namespace sol {
template <typename... Keys>
basic_table_core& traverse_set(Keys&&... keys) {
static_assert(sizeof...(Keys) > 1, "must pass at least 1 key and 1 value to set");
constexpr static bool global = top_level && (meta::count_when_for_to_pack_v<detail::is_not_insert_mode, 1, meta::is_c_str, meta::unqualified_t<Keys>...> > 0);
constexpr static bool global
= top_level && (meta::count_when_for_to_pack_v<detail::is_not_insert_mode, 1, meta::is_c_str, meta::unqualified_t<Keys>...> > 0);
auto pp = stack::push_pop<global>(*this);
int table_index = pp.index_of(*this);
lua_State* L = base_t::lua_state();
@ -613,7 +614,7 @@ namespace sol {
}
private:
template <typename R, typename... Args, typename Fx, typename Key, typename = std::result_of_t<Fx(Args...)>>
template <typename R, typename... Args, typename Fx, typename Key, typename = std::invoke_result_t<Fx, Args...>>
void set_fx(types<R(Args...)>, Key&& key, Fx&& fx) {
set_resolved_function<R(Args...)>(std::forward<Key>(key), std::forward<Fx>(fx));
}

View File

@ -37,7 +37,7 @@
#include <array>
#include <iterator>
#include <iosfwd>
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT != 0
#if SOL_ON(SOL_STD_VARIANT_)
#include <variant>
#endif // variant is weird on XCode, thanks XCode

View File

@ -41,9 +41,9 @@
#include <string>
#include <string_view>
#include <optional>
#ifdef SOL_STD_VARIANT
#if SOL_ON(SOL_STD_VARIANT_)
#include <variant>
#endif
#endif // variant shenanigans (thanks, Mac OSX)
namespace sol {
namespace detail {
@ -1085,10 +1085,10 @@ namespace sol {
template <>
struct lua_type_of<meta_function> : std::integral_constant<type, type::string> { };
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#if SOL_ON(SOL_STD_VARIANT_)
template <typename... Tn>
struct lua_type_of<std::variant<Tn...>> : std::integral_constant<type, type::poly> { };
#endif // SOL_STD_VARIANT
#endif // std::variant deployment sucks on Clang
template <typename T>
struct lua_type_of<nested<T>> : meta::conditional_t<::sol::is_container_v<T>, std::integral_constant<type, type::table>, lua_type_of<T>> { };
@ -1289,7 +1289,7 @@ namespace sol {
template <typename T>
struct is_automagical
: std::integral_constant<bool,
(SOL_AUTOMAGICAL_TYPES_BY_DEFAULT != 0)
(SOL_ON(SOL_AUTOMAGICAL_TYPES_BY_DEFAULT))
|| (std::is_array_v<
meta::unqualified_t<T>> || (!std::is_same_v<meta::unqualified_t<T>, state> && !std::is_same_v<meta::unqualified_t<T>, state_view>))> {
};

68
include/sol/version.hpp Normal file
View File

@ -0,0 +1,68 @@
// sol3
// The MIT License (MIT)
// Copyright (c) 2013-2019 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
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef SOL_VERSION_HPP
#define SOL_VERSION_HPP
#include "feature_test.hpp"
#include <sol/config.hpp>
#define SOL_ON(X) ((X + X) != 0)
#define SOL_OFF(X) ((X + X) == 0)
// clang-format off
#if defined(SOL_IN_DEBUG_DETECTED) && (SOL_IN_DEBUG_DETECTED != 0)
#define SOL_IN_DEBUG_DETECTED_ 1
#else
#define SOL_IN_DEBUG_DETECTED_ 0
#endif // We are in a debug mode of some sort
#if defined(SOL_NO_THREAD_LOCAL) && (SOL_NO_THREAD_LOCAL != 0)
#define SOL_USE_THREAD_LOCAL_ 0
#else
#define SOL_USE_THREAD_LOCAL_ 1
#endif // thread_local keyword is bjorked on some platforms
#if defined(SOL_USERTYPE_TYPE_BINDING_INFO) && (SOL_USERTYPE_TYPE_BINDING_INFO != 0)
#define SOL_USERTYPE_TYPE_BINDING_INFO_ 1
#else
#define SOL_USERTYPE_TYPE_BINDING_INFO_ 0
#endif // We should generate a my_type.__type table with lots of class information for usertypes
#if defined(SOL_AUTOMAGICAL_TYPES_BY_DEFAULT) && SOL_AUTOMAGICAL_TYPES_BY_DEFAULT != 0
#define SOL_AUTOMAGICAL_TYPES_BY_DEFAULT_ 1
#else
#define SOL_AUTOMAGICAL_TYPES_BY_DEFAULT_ 1
#endif // make is_automagical on/off by default
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT != 0
#define SOL_STD_VARIANT_ 1
#else
#define SOL_STD_VARIANT_ 0
#endif // make is_automagical on/off by default
// clang-format on
#endif // SOL_VERSION_HPP

View File

@ -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 2020-06-06 16:05:17.750133 UTC
// This header was generated with sol v3.2.1 (revision e09d2ff)
// Generated 2020-07-04 07:55:36.492765 UTC
// This header was generated with sol v3.2.1 (revision 62a831c)
// https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_FORWARD_HPP
@ -197,9 +197,42 @@
// end of sol/config.hpp
// beginning of sol/config_setup.hpp
// beginning of sol/version.hpp
// end of sol/config_setup.hpp
#define SOL_ON(X) ((X + X) != 0)
#define SOL_OFF(X) ((X + X) == 0)
#if defined(SOL_IN_DEBUG_DETECTED) && (SOL_IN_DEBUG_DETECTED != 0)
#define SOL_IN_DEBUG_DETECTED_ 1
#else
#define SOL_IN_DEBUG_DETECTED_ 0
#endif // We are in a debug mode of some sort
#if defined(SOL_NO_THREAD_LOCAL) && (SOL_NO_THREAD_LOCAL != 0)
#define SOL_USE_THREAD_LOCAL_ 0
#else
#define SOL_USE_THREAD_LOCAL_ 1
#endif // thread_local keyword is bjorked on some platforms
#if defined(SOL_USERTYPE_TYPE_BINDING_INFO) && (SOL_USERTYPE_TYPE_BINDING_INFO != 0)
#define SOL_USERTYPE_TYPE_BINDING_INFO_ 1
#else
#define SOL_USERTYPE_TYPE_BINDING_INFO_ 0
#endif // We should generate a my_type.__type table with lots of class information for usertypes
#if defined(SOL_AUTOMAGICAL_TYPES_BY_DEFAULT) && SOL_AUTOMAGICAL_TYPES_BY_DEFAULT != 0
#define SOL_AUTOMAGICAL_TYPES_BY_DEFAULT_ 1
#else
#define SOL_AUTOMAGICAL_TYPES_BY_DEFAULT_ 1
#endif // make is_automagical on/off by default
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT != 0
#define SOL_STD_VARIANT_ 1
#else
#define SOL_STD_VARIANT_ 0
#endif // make is_automagical on/off by default
// end of sol/version.hpp
// end of sol/feature_test.hpp

View File

@ -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 2020-06-06 16:05:12.150007 UTC
// This header was generated with sol v3.2.1 (revision e09d2ff)
// Generated 2020-07-04 07:55:34.972735 UTC
// This header was generated with sol v3.2.1 (revision 62a831c)
// https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_HPP
@ -223,9 +223,42 @@
// end of sol/config.hpp
// beginning of sol/config_setup.hpp
// beginning of sol/version.hpp
// end of sol/config_setup.hpp
#define SOL_ON(X) ((X + X) != 0)
#define SOL_OFF(X) ((X + X) == 0)
#if defined(SOL_IN_DEBUG_DETECTED) && (SOL_IN_DEBUG_DETECTED != 0)
#define SOL_IN_DEBUG_DETECTED_ 1
#else
#define SOL_IN_DEBUG_DETECTED_ 0
#endif // We are in a debug mode of some sort
#if defined(SOL_NO_THREAD_LOCAL) && (SOL_NO_THREAD_LOCAL != 0)
#define SOL_USE_THREAD_LOCAL_ 0
#else
#define SOL_USE_THREAD_LOCAL_ 1
#endif // thread_local keyword is bjorked on some platforms
#if defined(SOL_USERTYPE_TYPE_BINDING_INFO) && (SOL_USERTYPE_TYPE_BINDING_INFO != 0)
#define SOL_USERTYPE_TYPE_BINDING_INFO_ 1
#else
#define SOL_USERTYPE_TYPE_BINDING_INFO_ 0
#endif // We should generate a my_type.__type table with lots of class information for usertypes
#if defined(SOL_AUTOMAGICAL_TYPES_BY_DEFAULT) && SOL_AUTOMAGICAL_TYPES_BY_DEFAULT != 0
#define SOL_AUTOMAGICAL_TYPES_BY_DEFAULT_ 1
#else
#define SOL_AUTOMAGICAL_TYPES_BY_DEFAULT_ 1
#endif // make is_automagical on/off by default
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT != 0
#define SOL_STD_VARIANT_ 1
#else
#define SOL_STD_VARIANT_ 0
#endif // make is_automagical on/off by default
// end of sol/version.hpp
// end of sol/feature_test.hpp
@ -1239,7 +1272,7 @@ namespace sol {
#include <array>
#include <iterator>
#include <iosfwd>
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT != 0
#if SOL_ON(SOL_STD_VARIANT_)
#include <variant>
#endif // variant is weird on XCode, thanks XCode
@ -1925,7 +1958,7 @@ namespace sol {
// beginning of sol/compatibility.hpp
// beginning of sol/compatibility/version.hpp
// beginning of sol/compatibility/lua_version.hpp
#if defined(SOL_USING_CXX_LUA) && SOL_USING_CXX_LUA
#include <lua.h>
@ -1987,7 +2020,7 @@ namespace sol {
#define SOL_LUA_VERSION 503
#endif // Lua Version 503, 502, 501 || luajit, 500
// end of sol/compatibility/version.hpp
// end of sol/compatibility/lua_version.hpp
#if !defined(SOL_NO_COMPAT) || !(SOL_NO_COMPAT)
@ -6076,8 +6109,8 @@ namespace sol { namespace detail {
// end of sol/map.hpp
#include <initializer_list>
#ifdef SOL_STD_VARIANT
#endif
#if SOL_ON(SOL_STD_VARIANT_)
#endif // variant shenanigans (thanks, Mac OSX)
namespace sol {
namespace detail {
@ -7119,10 +7152,10 @@ namespace sol {
template <>
struct lua_type_of<meta_function> : std::integral_constant<type, type::string> { };
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#if SOL_ON(SOL_STD_VARIANT_)
template <typename... Tn>
struct lua_type_of<std::variant<Tn...>> : std::integral_constant<type, type::poly> { };
#endif // SOL_STD_VARIANT
#endif // std::variant deployment sucks on Clang
template <typename T>
struct lua_type_of<nested<T>> : meta::conditional_t<::sol::is_container_v<T>, std::integral_constant<type, type::table>, lua_type_of<T>> { };
@ -7322,7 +7355,7 @@ namespace sol {
template <typename T>
struct is_automagical
: std::integral_constant<bool,
(SOL_AUTOMAGICAL_TYPES_BY_DEFAULT != 0)
(SOL_ON(SOL_AUTOMAGICAL_TYPES_BY_DEFAULT))
|| (std::is_array_v<
meta::unqualified_t<T>> || (!std::is_same_v<meta::unqualified_t<T>, state> && !std::is_same_v<meta::unqualified_t<T>, state_view>))> {
};
@ -9223,11 +9256,9 @@ namespace sol {
int top;
std::function<void(int, int)> on_mismatch;
stack_guard(lua_State* L)
: stack_guard(L, lua_gettop(L)) {
stack_guard(lua_State* L) : stack_guard(L, lua_gettop(L)) {
}
stack_guard(lua_State* L, int top, std::function<void(int, int)> fx = detail::stack_fail)
: L(L), top(top), on_mismatch(std::move(fx)) {
stack_guard(lua_State* L, int top, std::function<void(int, int)> fx = detail::stack_fail) : L(L), top(top), on_mismatch(std::move(fx)) {
}
bool check_stack(int modification = 0) const {
int bottom = lua_gettop(L) + modification;
@ -10656,8 +10687,8 @@ namespace sol {
// beginning of sol/stack_check_unqualified.hpp
#include <cmath>
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#endif // SOL_STD_VARIANT
#if SOL_ON(SOL_STD_VARIANT_)
#endif // variant shenanigans
namespace sol { namespace stack {
namespace stack_detail {
@ -11190,7 +11221,7 @@ namespace sol { namespace stack {
}
};
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#if SOL_ON(SOL_STD_VARIANT_)
template <typename... Tn>
struct unqualified_checker<std::variant<Tn...>, type::poly> {
@ -11227,7 +11258,7 @@ namespace sol { namespace stack {
}
};
#endif // SOL_STD_VARIANT
#endif // variant shenanigans
}} // namespace sol::stack
@ -11639,7 +11670,7 @@ namespace sol {
}
// end of sol/unicode.hpp
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#if SOL_ON(SOL_STD_VARIANT_)
#endif // Apple clang screwed up
namespace sol { namespace stack {
@ -12587,7 +12618,8 @@ namespace sol { namespace stack {
}
};
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#if SOL_ON(SOL_STD_VARIANT_)
template <typename... Tn>
struct unqualified_getter<std::variant<Tn...>> {
using V = std::variant<Tn...>;
@ -12621,7 +12653,7 @@ namespace sol { namespace stack {
return get_one(std::integral_constant<std::size_t, 0>(), L, index, tracking);
}
};
#endif // SOL_STD_VARIANT
#endif // variant
}} // namespace sol::stack
@ -12647,8 +12679,8 @@ namespace stack {
// beginning of sol/stack_check_get_unqualified.hpp
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#endif // variant
#if SOL_ON(SOL_STD_VARIANT_)
#endif // variant shenanigans (thanks, Mac OSX)
namespace sol { namespace stack {
template <typename T, typename>
@ -12743,7 +12775,7 @@ namespace sol { namespace stack {
}
};
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#if SOL_ON(SOL_STD_VARIANT_)
template <typename... Tn, typename C>
struct unqualified_check_getter<std::variant<Tn...>, C> {
typedef std::variant<Tn...> V;
@ -12784,7 +12816,7 @@ namespace sol { namespace stack {
return get_one(std::integral_constant<std::size_t, V_size::value>(), L, index, std::forward<Handler>(handler), tracking);
}
};
#endif // SOL_STD_VARIANT
#endif // standard variant
}} // namespace sol::stack
// end of sol/stack_check_get_unqualified.hpp
@ -12855,7 +12887,7 @@ namespace sol { namespace stack {
#include <cassert>
#include <limits>
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#if SOL_ON(SOL_STD_VARIANT_)
#endif // Can use variant
namespace sol { namespace stack {
@ -14006,7 +14038,7 @@ namespace sol { namespace stack {
}
};
#if defined(SOL_STD_VARIANT) && SOL_STD_VARIANT
#if SOL_ON(SOL_STD_VARIANT_)
namespace stack_detail {
struct push_function {
@ -17386,7 +17418,7 @@ namespace sol {
// constexpr is fine for not-clang
namespace detail {
template <typename R, typename... Args, typename F, typename = std::result_of_t<meta::unqualified_t<F>(Args...)>>
template <typename R, typename... Args, typename F, typename = std::invoke_result_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;
@ -17401,8 +17433,8 @@ namespace sol {
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");
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>>
@ -17410,7 +17442,7 @@ namespace sol {
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...)>>
template <typename... Args, typename F, typename R = std::invoke_result_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));
}
@ -17456,7 +17488,7 @@ namespace sol {
// so don't use the constexpr versions inside of clang.
namespace detail {
template <typename R, typename... Args, typename F, typename = std::result_of_t<meta::unqualified_t<F>(Args...)>>
template <typename R, typename... Args, typename F, typename = std::invoke_result_t<meta::unqualified_t<F>, Args...>>
inline auto resolve_i(types<R(Args...)>, F &&) -> R (meta::unqualified_t<F>::*)(Args...) {
using Sig = R(Args...);
typedef meta::unqualified_t<F> Fu;
@ -17471,8 +17503,8 @@ namespace sol {
template <typename F>
inline 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");
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>>
@ -17480,7 +17512,7 @@ namespace sol {
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...)>>
template <typename... Args, typename F, typename R = std::invoke_result_t<F&, Args...>>
inline 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));
}
@ -22728,16 +22760,15 @@ namespace sol {
template <bool raw, typename Pairs, std::size_t... I>
void tuple_set(std::index_sequence<I...>, Pairs&& pairs) {
constexpr static bool global = top_level && (meta::count_even_for_pack_v<meta::is_c_str, meta::unqualified_t<decltype(std::get<I * 2>(std::forward<Pairs>(pairs)))>...> > 0);
constexpr static bool global = top_level
&& (meta::count_even_for_pack_v<meta::is_c_str, meta::unqualified_t<decltype(std::get<I * 2>(std::forward<Pairs>(pairs)))>...> > 0);
auto pp = stack::push_pop<global>(*this);
int table_index = pp.index_of(*this);
lua_State* L = base_t::lua_state();
(void)table_index;
(void)L;
void(detail::swallow{ (stack::set_field<(top_level), raw>(L,
std::get<I * 2>(std::forward<Pairs>(pairs)),
std::get<I * 2 + 1>(std::forward<Pairs>(pairs)),
table_index),
void(detail::swallow { (stack::set_field<(top_level), raw>(
L, std::get<I * 2>(std::forward<Pairs>(pairs)), std::get<I * 2 + 1>(std::forward<Pairs>(pairs)), table_index),
0)... });
}
@ -22836,7 +22867,8 @@ namespace sol {
using KeyU = meta::unqualified_t<Key>;
if constexpr (std::is_same_v<KeyU, update_if_empty_t>) {
(void)key;
traverse_set_deep<global, raw, static_cast<detail::insert_mode>(mode | detail::insert_mode::update_if_empty)>(table_index, std::forward<Keys>(keys)...);
traverse_set_deep<global, raw, static_cast<detail::insert_mode>(mode | detail::insert_mode::update_if_empty)>(
table_index, std::forward<Keys>(keys)...);
}
else if constexpr (std::is_same_v<KeyU, create_if_nil_t>) {
(void)key;
@ -23035,7 +23067,8 @@ namespace sol {
template <typename... Keys>
basic_table_core& traverse_set(Keys&&... keys) {
static_assert(sizeof...(Keys) > 1, "must pass at least 1 key and 1 value to set");
constexpr static bool global = top_level && (meta::count_when_for_to_pack_v<detail::is_not_insert_mode, 1, meta::is_c_str, meta::unqualified_t<Keys>...> > 0);
constexpr static bool global
= top_level && (meta::count_when_for_to_pack_v<detail::is_not_insert_mode, 1, meta::is_c_str, meta::unqualified_t<Keys>...> > 0);
auto pp = stack::push_pop<global>(*this);
int table_index = pp.index_of(*this);
lua_State* L = base_t::lua_state();
@ -23225,7 +23258,7 @@ namespace sol {
}
private:
template <typename R, typename... Args, typename Fx, typename Key, typename = std::result_of_t<Fx(Args...)>>
template <typename R, typename... Args, typename Fx, typename Key, typename = std::invoke_result_t<Fx, Args...>>
void set_fx(types<R(Args...)>, Key&& key, Fx&& fx) {
set_resolved_function<R(Args...)>(std::forward<Key>(key), std::forward<Fx>(fx));
}
@ -23997,6 +24030,7 @@ namespace sol {
struct arr : detail::ebco<std::initializer_list<lua_value>> {
private:
using base_t = detail::ebco<std::initializer_list<lua_value>>;
public:
using base_t::base_t;
};
@ -24010,7 +24044,11 @@ namespace sol {
using is_lua_value_single_constructible = meta::any<std::is_same<T, lua_value>, is_reference_or_lua_value_init_list<T>>;
static lua_State*& thread_local_lua_state() {
#if SOL_ON(SOL_USE_THREAD_LOCAL_)
static thread_local lua_State* L = nullptr;
#else
static lua_State* L = nullptr;
#endif
return L;
}
@ -24114,7 +24152,7 @@ namespace sol {
return lua_value(L, stack::get<reference>(L, index, tracking));
}
};
}
} // namespace stack
} // namespace sol
// end of sol/lua_value.hpp

View File

@ -21,6 +21,6 @@
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "sol_defines.hpp"
#include "../sol_defines.hpp"
#include <sol/config_setup.hpp>
#include <sol/compatibility/lua_version.hpp>

View File

@ -21,6 +21,6 @@
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "../sol_defines.hpp"
#include "sol_defines.hpp"
#include <sol/compatibility/version.hpp>
#include <sol/version.hpp>