Skip to content

Commit

Permalink
Fix SOL2 build on GCC 10.2 by working around overload resolution problem
Browse files Browse the repository at this point in the history
  • Loading branch information
ajrhacker committed Jul 29, 2020
1 parent b453be4 commit a27476c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions 3rdparty/sol2/sol/container_usertype_metatable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ namespace sol {
auto& src = get_src(L);
using std::begin;
stack::push(L, pairs_next_call);
stack::push<user<iter>>(L, src, begin(src));
stack::push_specific<user<iter>>(L, src, begin(src));
stack::push(L, 1);
return 3;
}
Expand All @@ -296,7 +296,7 @@ namespace sol {
auto& src = get_src(L);
using std::begin;
stack::push(L, pairs_next_call);
stack::push<user<iter>>(L, src, begin(src));
stack::push_specific<user<iter>>(L, src, begin(src));
stack::push(L, 0);
return 3;
}
Expand Down
12 changes: 6 additions & 6 deletions 3rdparty/sol2/sol/function_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ namespace sol {
static void set_fx(lua_State* L, Args&&... args) {
lua_CFunction freefunc = function_detail::call<meta::unqualified_t<Fx>>;

stack::push<user<Fx>>(L, std::forward<Args>(args)...);
stack::push_specific<user<Fx>>(L, std::forward<Args>(args)...);
stack::push(L, c_closure(freefunc, 1));
}

Expand All @@ -181,7 +181,7 @@ namespace sol {
struct pusher<function_arguments<T, Args...>> {
template <std::size_t... I, typename FP>
static int push_func(std::index_sequence<I...>, lua_State* L, FP&& fp) {
return stack::push<T>(L, detail::forward_get<I>(fp.arguments)...);
return stack::push_specific<T>(L, detail::forward_get<I>(fp.arguments)...);
}

static int push(lua_State* L, const function_arguments<T, Args...>& fp) {
Expand Down Expand Up @@ -235,13 +235,13 @@ namespace sol {
struct pusher<protect_t<T>> {
static int push(lua_State* L, protect_t<T>&& pw) {
lua_CFunction cf = call_detail::call_user<void, false, false, protect_t<T>>;
int closures = stack::push<user<protect_t<T>>>(L, std::move(pw.value));
int closures = stack::push_specific<user<protect_t<T>>>(L, std::move(pw.value));
return stack::push(L, c_closure(cf, closures));
}

static int push(lua_State* L, const protect_t<T>& pw) {
lua_CFunction cf = call_detail::call_user<void, false, false, protect_t<T>>;
int closures = stack::push<user<protect_t<T>>>(L, pw.value);
int closures = stack::push_specific<user<protect_t<T>>>(L, pw.value);
return stack::push(L, c_closure(cf, closures));
}
};
Expand Down Expand Up @@ -314,7 +314,7 @@ namespace sol {
template <typename C>
static int push(lua_State* L, C&& c) {
lua_CFunction cf = call_detail::call_user<T, false, false, constructor_wrapper<Fxs...>>;
int closures = stack::push<user<constructor_wrapper<Fxs...>>>(L, std::forward<C>(c));
int closures = stack::push_specific<user<constructor_wrapper<Fxs...>>>(L, std::forward<C>(c));
return stack::push(L, c_closure(cf, closures));
}
};
Expand All @@ -331,7 +331,7 @@ namespace sol {
struct pusher<detail::tagged<T, destructor_wrapper<Fx>>> {
static int push(lua_State* L, destructor_wrapper<Fx> c) {
lua_CFunction cf = call_detail::call_user<T, false, false, destructor_wrapper<Fx>>;
int closures = stack::push<user<T>>(L, std::move(c));
int closures = stack::push_specific<user<T>>(L, std::move(c));
return stack::push(L, c_closure(cf, closures));
}
};
Expand Down
4 changes: 2 additions & 2 deletions 3rdparty/sol2/sol/object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace sol {

template <typename T, typename R = reference, bool should_pop = !std::is_base_of<stack_reference, R>::value, typename... Args>
R make_reference(lua_State* L, Args&&... args) {
int backpedal = stack::push<T>(L, std::forward<Args>(args)...);
int backpedal = stack::push_specific<T>(L, std::forward<Args>(args)...);
R r = stack::get<R>(L, -backpedal);
if (should_pop) {
lua_pop(L, backpedal);
Expand Down Expand Up @@ -99,7 +99,7 @@ namespace sol {
basic_object(lua_State* L, int index = -1) noexcept : base_t(L, index) {}
basic_object(lua_State* L, ref_index index) noexcept : base_t(L, index) {}
template <typename T, typename... Args>
basic_object(lua_State* L, in_place_type_t<T>, Args&&... args) noexcept : basic_object(std::integral_constant<bool, !std::is_base_of<stack_reference, base_t>::value>(), L, -stack::push<T>(L, std::forward<Args>(args)...)) {}
basic_object(lua_State* L, in_place_type_t<T>, Args&&... args) noexcept : basic_object(std::integral_constant<bool, !std::is_base_of<stack_reference, base_t>::value>(), L, -stack::push_specific<T>(L, std::forward<Args>(args)...)) {}
template <typename T, typename... Args>
basic_object(lua_State* L, in_place_t, T&& arg, Args&&... args) noexcept : basic_object(L, in_place<T>, std::forward<T>(arg), std::forward<Args>(args)...) {}
basic_object& operator=(const basic_object&) = default;
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/sol2/sol/simple_usertype_metatable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ namespace sol {
++uniqueness;

const char* gcmetakey = &usertype_traits<T>::gc_table()[0];
stack::push<user<usertype_detail::simple_map>>(L, metatable_key, uniquegcmetakey, &usertype_traits<T>::metatable()[0],
stack::push_specific<user<usertype_detail::simple_map>>(L, metatable_key, uniquegcmetakey, &usertype_traits<T>::metatable()[0],
umx.indexbaseclasspropogation, umx.newindexbaseclasspropogation,
std::move(umx.varmap), std::move(umx.registrations)
);
Expand Down
6 changes: 3 additions & 3 deletions 3rdparty/sol2/sol/stack_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ namespace sol {
return pusher<meta::unqualified_t<T>>{}.push(L, std::forward<T>(t), std::forward<Args>(args)...);
}

// overload allows to use a pusher of a specific type, but pass in any kind of args
template<typename T, typename Arg, typename... Args, typename = std::enable_if_t<!std::is_same<T, Arg>::value>>
inline int push(lua_State* L, Arg&& arg, Args&&... args) {
// allow a pusher of a specific type, but pass in any kind of args
template<typename T, typename Arg, typename... Args>
inline int push_specific(lua_State* L, Arg&& arg, Args&&... args) {
return pusher<meta::unqualified_t<T>>{}.push(L, std::forward<Arg>(arg), std::forward<Args>(args)...);
}

Expand Down
6 changes: 3 additions & 3 deletions 3rdparty/sol2/sol/stack_push.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ namespace sol {
}

static int push(lua_State* L, const wchar_t(&str)[N], std::size_t sz) {
return stack::push<const wchar_t*>(L, str, str + sz);
return stack::push_specific<const wchar_t*>(L, str, str + sz);
}
};

Expand All @@ -557,7 +557,7 @@ namespace sol {
}

static int push(lua_State* L, const char16_t(&str)[N], std::size_t sz) {
return stack::push<const char16_t*>(L, str, str + sz);
return stack::push_specific<const char16_t*>(L, str, str + sz);
}
};

Expand All @@ -568,7 +568,7 @@ namespace sol {
}

static int push(lua_State* L, const char32_t(&str)[N], std::size_t sz) {
return stack::push<const char32_t*>(L, str, str + sz);
return stack::push_specific<const char32_t*>(L, str, str + sz);
}
};

Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/sol2/sol/usertype_metatable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ namespace sol {
const char* gcmetakey = &usertype_traits<T>::gc_table()[0];
// Make sure userdata's memory is properly in lua first,
// otherwise all the light userdata we make later will become invalid
stack::push<user<umt_t>>(L, metatable_key, uniquegcmetakey, std::move(umx));
stack::push_specific<user<umt_t>>(L, metatable_key, uniquegcmetakey, std::move(umx));
// Create the top level thing that will act as our deleter later on
stack_reference umt(L, -1);
stack::set_field<true>(L, gcmetakey, umt);
Expand Down

0 comments on commit a27476c

Please sign in to comment.