Fixing lua function, attempting another fix for rtl_pop

This commit is contained in:
ThePhD 2013-12-15 16:45:40 -05:00
parent 8ef3ceb8a0
commit 94405d0346
2 changed files with 15 additions and 9 deletions

View File

@ -63,11 +63,6 @@ struct static_lua_func {
typedef typename std::remove_pointer<typename std::decay<TFx>::type>::type fx_t;
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>
static int typed_call(types<void>, types<Args...> t, fx_t* fx, lua_State* L) {
stack::pop_call(L, fx, t);
@ -81,6 +76,11 @@ struct static_lua_func {
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) {
int upvalue = 1;
fx_t* fx;
@ -99,6 +99,7 @@ struct static_object_lua_func {
typedef typename std::decay<TFx>::type fx_t;
typedef function_traits<fx_t> fx_traits;
template<typename... Args>
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)...); };
@ -124,6 +125,11 @@ struct static_object_lua_func {
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) {
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;

View File

@ -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)...)) {
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>
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)...)) {
template<typename F, typename Head, typename... Tail, typename... Vs, typename... Args>
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)...);
}
} // detail
@ -270,8 +270,8 @@ inline auto pop_call(lua_State* L, TFx&& fx, types<Args...>) -> decltype(detail:
}
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...>())) {
return detail::rtl_pop(L, std::forward<TFx>(fx), reversed<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), types<Args...>(), reversed<Args...>());
}
void push_args(lua_State*) {