mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Ordering things more nicely for GCC and fixing calls to always used extra types
parameters when they can for early-out decltype deduction, rather than recursive template reliance (compiles better for VC++ and resolves earlier for g++).
This commit is contained in:
parent
c8417d65de
commit
e0bcf5a11e
|
@ -222,10 +222,6 @@ struct explicit_lua_func : public lua_func {
|
|||
template<typename... FxArgs>
|
||||
explicit_lua_func(FxArgs&&... fxargs): fx(std::forward<FxArgs>(fxargs)...) {}
|
||||
|
||||
virtual int operator()(lua_State* L) override {
|
||||
return (*this)(tuple_types<typename fx_traits::return_type>(), typename fx_traits::args_type(), L);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
int operator()(types<>, types<Args...> t, lua_State* L) {
|
||||
return (*this)(types<void>(), t, L);
|
||||
|
@ -243,6 +239,10 @@ struct explicit_lua_func : public lua_func {
|
|||
stack::push_reverse(L, std::move(r));
|
||||
return sizeof...(Ret);
|
||||
}
|
||||
|
||||
virtual int operator()(lua_State* L) override {
|
||||
return (*this)(tuple_types<typename fx_traits::return_type>(), typename fx_traits::args_type(), L);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename TFx, typename T>
|
||||
|
@ -265,8 +265,10 @@ struct explicit_lua_func<TFx, T, true> : public lua_func {
|
|||
template<typename... FxArgs>
|
||||
explicit_lua_func(T m, FxArgs&&... fxargs): fx(std::move(m), std::forward<FxArgs>(fxargs)...) {}
|
||||
|
||||
virtual int operator()(lua_State* L) override {
|
||||
return (*this)(tuple_types<typename fx_traits::return_type>(), typename fx_traits::args_type(), L);
|
||||
template<typename... Args>
|
||||
int operator()(types<void>, types<Args...> t, lua_State* L) {
|
||||
stack::pop_call(L, fx, t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
|
@ -274,18 +276,16 @@ struct explicit_lua_func<TFx, T, true> : public lua_func {
|
|||
return (*this)(types<void>(), t, L);
|
||||
}
|
||||
|
||||
template<typename... Args>
|
||||
int operator()(types<void>, types<Args...> t, lua_State* L) {
|
||||
stack::pop_call(L, fx, t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename... Ret, typename... Args>
|
||||
int operator()(types<Ret...>, types<Args...> t, lua_State* L) {
|
||||
auto r = stack::pop_call(L, fx, t);
|
||||
stack::push_reverse(L, r);
|
||||
stack::push_reverse(L, std::move(r));
|
||||
return sizeof...(Ret);
|
||||
}
|
||||
|
||||
virtual int operator()(lua_State* L) override {
|
||||
return (*this)(tuple_types<typename fx_traits::return_type>(), typename fx_traits::args_type(), L);
|
||||
}
|
||||
};
|
||||
|
||||
} // sol
|
||||
|
|
|
@ -212,27 +212,19 @@ inline void push_tuple(lua_State* L, indices<I...>, T&& tuplen) {
|
|||
swallow {'\0', (sol::stack::push(L, std::get<I>(tuplen)), '\0')... };
|
||||
}
|
||||
|
||||
template<typename F, typename... Vs>
|
||||
auto ltr_pop(lua_State*, F&& f, types<>, Vs&&... vs) -> decltype(f(std::forward<Vs>(vs)...)) {
|
||||
template<typename F, typename... Vs, typename... Args>
|
||||
auto ltr_pop(lua_State*, F&& f, types<Args...> t, types<>, Vs&&... vs) -> decltype(f(std::forward<Vs>(vs)...)) {
|
||||
return f(std::forward<Vs>(vs)...);
|
||||
}
|
||||
template<typename F, typename Head, typename... Vs>
|
||||
auto ltr_pop(lua_State* L, F&& f, types<Head>, Vs&&... vs) -> decltype(ltr_pop(L, std::forward<F>(f), types<>(), std::forward<Vs>(vs)..., pop<Head>(L))) {
|
||||
return ltr_pop(L, std::forward<F>(f), types<>(), std::forward<Vs>(vs)..., pop<Head>(L));
|
||||
}
|
||||
template<typename F, typename Head, typename... Tail, typename... Vs>
|
||||
auto ltr_pop(lua_State* L, F&& f, types<Head, Tail...>, Vs&&... vs) -> decltype(f(std::forward<Vs>(vs)..., std::declval<Head>(), std::declval<Tail>()...)) {
|
||||
return ltr_pop(L, std::forward<F>(f), types<Tail...>(), std::forward<Vs>(vs)..., pop<Head>(L));
|
||||
template<typename F, typename Head, typename... Tail, typename... Vs, typename... Args>
|
||||
auto ltr_pop(lua_State* L, F&& f, types<Args...> t, types<Head, Tail...>, Vs&&... vs) -> decltype(f(std::declval<Args>()...)) {
|
||||
return ltr_pop(L, std::forward<F>(f), t, types<Tail...>(), std::forward<Vs>(vs)..., pop<Head>(L));
|
||||
}
|
||||
|
||||
template<typename F, typename... Vs, typename... Args>
|
||||
auto rtl_pop(lua_State*, F&& f, types<Args...>, types<>, Vs&&... vs) -> decltype(f(std::forward<Vs>(vs)...)) {
|
||||
return f(std::forward<Vs>(vs)...);
|
||||
}
|
||||
template<typename F, typename Head, typename... Vs, typename... Args>
|
||||
auto rtl_pop(lua_State* L, F&& f, types<Args...> t, types<Head>, Vs&&... vs) -> decltype(f(std::declval<Args>()...)) {
|
||||
return rtl_pop(L, std::forward<F>(f), t, types<>(), pop<Head>(L), std::forward<Vs>(vs)...);
|
||||
}
|
||||
template<typename F, typename Head, typename... Tail, typename... Vs, typename... Args>
|
||||
auto rtl_pop(lua_State* L, F&& f, types<Args...> t, types<Head, Tail...>, Vs&&... vs) -> decltype(f(std::declval<Args>()...)) {
|
||||
return rtl_pop(L, std::forward<F>(f), t, types<Tail...>(), pop<Head>(L), std::forward<Vs>(vs)...);
|
||||
|
@ -265,13 +257,13 @@ inline void push_reverse(lua_State* L, std::tuple<Args...>&& tuplen) {
|
|||
}
|
||||
|
||||
template<typename... Args, typename TFx>
|
||||
inline auto pop_call(lua_State* L, TFx&& fx, types<Args...>) -> decltype(detail::ltr_pop(L, std::forward<TFx>(fx), types<Args...>())) {
|
||||
return detail::ltr_pop(L, std::forward<TFx>(fx), types<Args...>());
|
||||
inline auto pop_call(lua_State* L, TFx&& fx, types<Args...> t) -> decltype(detail::ltr_pop(L, std::forward<TFx>(fx), t, t)) {
|
||||
return detail::ltr_pop(L, std::forward<TFx>(fx), t, t);
|
||||
}
|
||||
|
||||
template<typename... Args, typename TFx>
|
||||
inline auto pop_reverse_call(lua_State* L, TFx&& fx, types<Args...>) -> decltype(detail::rtl_pop(L, std::forward<TFx>(fx), types<Args...>(), reversed<Args...>())) {
|
||||
return detail::rtl_pop(L, std::forward<TFx>(fx), types<Args...>(), reversed<Args...>());
|
||||
inline auto pop_reverse_call(lua_State* L, TFx&& fx, types<Args...> t) -> decltype(detail::rtl_pop(L, std::forward<TFx>(fx), t, reversed<Args...>())) {
|
||||
return detail::rtl_pop(L, std::forward<TFx>(fx), t, reversed<Args...>());
|
||||
}
|
||||
|
||||
void push_args(lua_State*) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user