From 94405d0346f8043ffa24e3aac0a91bdb1beeb4a3 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Sun, 15 Dec 2013 16:45:40 -0500 Subject: [PATCH] Fixing lua function, attempting another fix for rtl_pop --- sol/lua_function.hpp | 16 +++++++++++----- sol/stack.hpp | 8 ++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/sol/lua_function.hpp b/sol/lua_function.hpp index 0d278f7b..b4fe39c4 100644 --- a/sol/lua_function.hpp +++ b/sol/lua_function.hpp @@ -63,11 +63,6 @@ struct static_lua_func { typedef typename std::remove_pointer::type>::type fx_t; typedef function_traits fx_traits; - template - static int typed_call(types<>, types t, fx_t* fx, lua_State* L) { - return (*this)(types(), t, fx, L); - } - template static int typed_call(types, types 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 + static int typed_call(types<>, types t, fx_t* fx, lua_State* L) { + return typed_call(types(), 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::type fx_t; typedef function_traits fx_traits; + template static int typed_call(types, types, T& item, fx_t& ifx, lua_State* L) { auto fx = [&item, &ifx](Args&&... args) { (item.*ifx)(std::forward(args)...); }; @@ -124,6 +125,11 @@ struct static_object_lua_func { return sizeof...(Ret); } + template + static int typed_call(types<>, types, T& item, fx_t& ifx, lua_State* L) { + return typed_call(types(), 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 data_t; diff --git a/sol/stack.hpp b/sol/stack.hpp index a0c5c230..769f38b3 100644 --- a/sol/stack.hpp +++ b/sol/stack.hpp @@ -233,8 +233,8 @@ template auto rtl_pop(lua_State* L, F&& f, types, Vs&&... vs) -> decltype(rtl_pop(L, std::forward(f), types<>(), pop(L), std::forward(vs)...)) { return rtl_pop(L, std::forward(f), types<>(), pop(L), std::forward(vs)...); } -template -auto rtl_pop(lua_State* L, F&& f, types, Vs&&... vs) -> decltype(rtl_pop(L, std::forward(f), types(), pop(L), std::forward(vs)...)) { +template +auto rtl_pop(lua_State* L, F&& f, types, types, Vs&&... vs) -> decltype(f(std::forward(declval())...)) { return rtl_pop(L, std::forward(f), types(), pop(L), std::forward(vs)...); } } // detail @@ -270,8 +270,8 @@ inline auto pop_call(lua_State* L, TFx&& fx, types) -> decltype(detail: } template -inline auto pop_reverse_call(lua_State* L, TFx&& fx, types) -> decltype(detail::rtl_pop(L, std::forward(fx), types())) { - return detail::rtl_pop(L, std::forward(fx), reversed()); +inline auto pop_reverse_call(lua_State* L, TFx&& fx, types) -> decltype(detail::rtl_pop(L, std::forward(fx), types(), reversed())) { + return detail::rtl_pop(L, std::forward(fx), types(), reversed()); } void push_args(lua_State*) {