From bcf4b9b08fc1fc05afa371babba3ba5f795da248 Mon Sep 17 00:00:00 2001 From: ThePhD Date: Wed, 11 Dec 2013 11:56:34 -0500 Subject: [PATCH] Have I mentioned I hate GCC? I hate GCC. --- .gitignore | 1 + sol.scratch.cpp | 2 +- sol/functional.hpp | 4 ++-- sol/lua_function.hpp | 6 +++--- sol/stack.hpp | 14 +++++++++----- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index bfbe70a6..2ea95f2b 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ x64/ liblua.a sol/include/ .ninja* +include/ diff --git a/sol.scratch.cpp b/sol.scratch.cpp index fb968850..2ee0c5ae 100644 --- a/sol.scratch.cpp +++ b/sol.scratch.cpp @@ -50,7 +50,7 @@ TEST_CASE("simple/get", "Tests if the get function works properly.") { REQUIRE(a == 9.0); lua.script("b = nil"); - REQUIRE_NOTHROW(auto b = lua.get("b")); + REQUIRE_NOTHROW(lua.get("b")); lua.script("d = 'hello'"); auto d = lua.get("d"); diff --git a/sol/functional.hpp b/sol/functional.hpp index 653864db..0ede1e5a 100644 --- a/sol/functional.hpp +++ b/sol/functional.hpp @@ -19,11 +19,11 @@ // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#include "tuple.hpp" - #ifndef SOL_FUNCTIONAL_HPP #define SOL_FUNCTIONAL_HPP +#include "tuple.hpp" + namespace sol { namespace detail { diff --git a/sol/lua_function.hpp b/sol/lua_function.hpp index e73f818e..d98e553b 100644 --- a/sol/lua_function.hpp +++ b/sol/lua_function.hpp @@ -80,7 +80,7 @@ struct static_lua_func { static int call(lua_State* L) { int upvalue = 1; fx_t* fx; - detail::get_upvalue(L, fx, upvalue); + detail::get_upvalue(L, fx, upvalue); int r = typed_call(tuple_types(), typename fx_traits::args_type(), fx, L); return r; } @@ -106,7 +106,7 @@ struct static_object_lua_func { static int typed_call(types, types, T& item, fx_t& ifx, lua_State* L) { auto fx = [ &item, &ifx ] (Args&&... args) -> TR { return (item.*ifx)(std::forward(args)...); - }; + }; auto r = stack::pop_call(L, fx, types()); stack::push(L, std::move(r)); return 1; @@ -121,7 +121,7 @@ struct static_object_lua_func { } 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 data_t; int upvalue = 1; data_t data = { { } }; diff --git a/sol/stack.hpp b/sol/stack.hpp index bda81815..ce8be78e 100644 --- a/sol/stack.hpp +++ b/sol/stack.hpp @@ -60,11 +60,6 @@ inline T get_arithmetic(lua_State* L, std::true_type, int index = -1) { return get_unsigned(L, std::is_unsigned{}, index); } -template -inline T get_helper(lua_State* L, std::true_type, int index = -1) { - return get_nil(L, std::is_same(), index); -} - template inline T get_nil(lua_State* L, std::true_type, int index = -1) { if (lua_isnil(L, index) == 0) @@ -78,6 +73,11 @@ inline T get_nil(lua_State* L, std::false_type, int index = -1) { return T(L, index); } +template +inline T get_helper(lua_State* L, std::true_type, int index = -1) { + return get_nil(L, std::is_same(), index); +} + template inline T get_helper(lua_State* L, std::false_type, int index = -1) { // T is a fundamental type @@ -222,6 +222,10 @@ template auto ltr_pop(lua_State*, F&& f, types<>, Vs&&... vs) -> decltype(f(std::forward(vs)...)) { return f(std::forward(vs)...); } +template +auto ltr_pop(lua_State*, F&& f, types, Vs&&... vs) -> decltype(f(std::forward(vs)...)) { + return f(std::forward(vs)...); +} template auto ltr_pop(lua_State* L, F&& f, types, Vs&&... vs) -> decltype(ltr_pop(L, std::forward(f), types<>(), std::forward(vs)..., pop(L))) { return ltr_pop(L, std::forward(f), types<>(), std::forward(vs)..., pop(L));