mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Fixing lua function, attempting another fix for rtl_pop
This commit is contained in:
parent
8ef3ceb8a0
commit
94405d0346
|
@ -63,11 +63,6 @@ struct static_lua_func {
|
||||||
typedef typename std::remove_pointer<typename std::decay<TFx>::type>::type fx_t;
|
typedef typename std::remove_pointer<typename std::decay<TFx>::type>::type fx_t;
|
||||||
typedef function_traits<fx_t> fx_traits;
|
typedef function_traits<fx_t> fx_traits;
|
||||||
|
|
||||||
template<typename... Args>
|
|
||||||
static int typed_call(types<>, types<Args...> t, fx_t* fx, lua_State* L) {
|
|
||||||
return (*this)(types<void>(), t, fx, L);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
static int typed_call(types<void>, types<Args...> t, fx_t* fx, lua_State* L) {
|
static int typed_call(types<void>, types<Args...> t, fx_t* fx, lua_State* L) {
|
||||||
stack::pop_call(L, fx, t);
|
stack::pop_call(L, fx, t);
|
||||||
|
@ -81,6 +76,11 @@ struct static_lua_func {
|
||||||
return sizeof...(Ret);
|
return sizeof...(Ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
|
static int typed_call(types<>, types<Args...> t, fx_t* fx, lua_State* L) {
|
||||||
|
return typed_call(types<void>(), t, fx, L);
|
||||||
|
}
|
||||||
|
|
||||||
static int call(lua_State* L) {
|
static int call(lua_State* L) {
|
||||||
int upvalue = 1;
|
int upvalue = 1;
|
||||||
fx_t* fx;
|
fx_t* fx;
|
||||||
|
@ -99,6 +99,7 @@ struct static_object_lua_func {
|
||||||
typedef typename std::decay<TFx>::type fx_t;
|
typedef typename std::decay<TFx>::type fx_t;
|
||||||
typedef function_traits<fx_t> fx_traits;
|
typedef function_traits<fx_t> fx_traits;
|
||||||
|
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
static int typed_call(types<void>, types<Args...>, T& item, fx_t& ifx, lua_State* L) {
|
static int typed_call(types<void>, types<Args...>, T& item, fx_t& ifx, lua_State* L) {
|
||||||
auto fx = [&item, &ifx](Args&&... args) { (item.*ifx)(std::forward<Args>(args)...); };
|
auto fx = [&item, &ifx](Args&&... args) { (item.*ifx)(std::forward<Args>(args)...); };
|
||||||
|
@ -124,6 +125,11 @@ struct static_object_lua_func {
|
||||||
return sizeof...(Ret);
|
return sizeof...(Ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename... Args>
|
||||||
|
static int typed_call(types<>, types<Args...>, T& item, fx_t& ifx, lua_State* L) {
|
||||||
|
return typed_call(types<void>(), item, ifx, L);
|
||||||
|
}
|
||||||
|
|
||||||
static int call(lua_State* L) {
|
static int call(lua_State* L) {
|
||||||
const static std::size_t data_t_count = (sizeof(fx_t)+(sizeof(void*)-1)) / sizeof(void*);
|
const static std::size_t data_t_count = (sizeof(fx_t)+(sizeof(void*)-1)) / sizeof(void*);
|
||||||
typedef std::array<void*, data_t_count> data_t;
|
typedef std::array<void*, data_t_count> data_t;
|
||||||
|
|
|
@ -233,8 +233,8 @@ template<typename F, typename Head, typename... Vs>
|
||||||
auto rtl_pop(lua_State* L, F&& f, types<Head>, Vs&&... vs) -> decltype(rtl_pop(L, std::forward<F>(f), types<>(), pop<Head>(L), std::forward<Vs>(vs)...)) {
|
auto rtl_pop(lua_State* L, F&& f, types<Head>, Vs&&... vs) -> decltype(rtl_pop(L, std::forward<F>(f), types<>(), pop<Head>(L), std::forward<Vs>(vs)...)) {
|
||||||
return rtl_pop(L, std::forward<F>(f), types<>(), pop<Head>(L), std::forward<Vs>(vs)...);
|
return rtl_pop(L, std::forward<F>(f), types<>(), pop<Head>(L), std::forward<Vs>(vs)...);
|
||||||
}
|
}
|
||||||
template<typename F, typename Head, typename... Tail, typename... Vs>
|
template<typename F, typename Head, typename... Tail, typename... Vs, typename... Args>
|
||||||
auto rtl_pop(lua_State* L, F&& f, types<Head, Tail...>, Vs&&... vs) -> decltype(rtl_pop(L, std::forward<F>(f), types<Tail...>(), pop<Head>(L), std::forward<Vs>(vs)...)) {
|
auto rtl_pop(lua_State* L, F&& f, types<Args...>, types<Head, Tail...>, Vs&&... vs) -> decltype(f(std::forward<Args>(declval<Args>())...)) {
|
||||||
return rtl_pop(L, std::forward<F>(f), types<Tail...>(), pop<Head>(L), std::forward<Vs>(vs)...);
|
return rtl_pop(L, std::forward<F>(f), types<Tail...>(), pop<Head>(L), std::forward<Vs>(vs)...);
|
||||||
}
|
}
|
||||||
} // detail
|
} // detail
|
||||||
|
@ -270,8 +270,8 @@ inline auto pop_call(lua_State* L, TFx&& fx, types<Args...>) -> decltype(detail:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args, typename TFx>
|
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...>())) {
|
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), reversed<Args...>());
|
return detail::rtl_pop(L, std::forward<TFx>(fx), types<Args...>(), reversed<Args...>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void push_args(lua_State*) {
|
void push_args(lua_State*) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user