From 0aab55cea4b148c6df2990ff2f158af4120137c4 Mon Sep 17 00:00:00 2001 From: PrincessNyanara Date: Mon, 9 Jun 2014 02:06:51 -0400 Subject: [PATCH] inline fixes static getter/pusher container with Unqualified not sure how I can make containers play nice without lookup... --- sol/container.hpp | 2 +- sol/stack.hpp | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/sol/container.hpp b/sol/container.hpp index 946ba3ea..b1432ea3 100644 --- a/sol/container.hpp +++ b/sol/container.hpp @@ -7,7 +7,7 @@ namespace sol { template struct container { - typedef typename std::conditional::value, Tc, Decay>::type T; + typedef typename std::conditional::value, Tc, Unqualified>::type T; typedef Unqualified().begin()))> value_type; T cont; diff --git a/sol/stack.hpp b/sol/stack.hpp index 900617b4..875836ca 100644 --- a/sol/stack.hpp +++ b/sol/stack.hpp @@ -35,12 +35,12 @@ namespace sol { namespace detail { template -T* get_ptr(T& val) { +inline T* get_ptr(T& val) { return std::addressof(val); } template -T* get_ptr(T* val) { +inline T* get_ptr(T* val) { return val; } } // detail @@ -102,7 +102,7 @@ struct getter { template <> struct getter { - type get(lua_State *L, int index){ + static type get(lua_State *L, int index){ return static_cast(lua_type(L, index)); } }; @@ -125,14 +125,14 @@ struct getter { template <> struct getter { - const char* get(lua_State* L, int index = -1) { + static const char* get(lua_State* L, int index = -1) { return lua_tostring(L, index); } }; template <> struct getter { - nil_t get(lua_State* L, int index = -1) { + static nil_t get(lua_State* L, int index = -1) { if (lua_isnil(L, index) == 0) throw sol::error("not nil"); return nil_t{ }; @@ -141,28 +141,28 @@ struct getter { template <> struct getter { - userdata_t get(lua_State* L, int index = -1) { + static userdata_t get(lua_State* L, int index = -1) { return{ lua_touserdata(L, index) }; } }; template <> struct getter { - lightuserdata_t get(lua_State* L, int index = 1) { + static lightuserdata_t get(lua_State* L, int index = 1) { return{ lua_touserdata(L, index) }; } }; template <> struct getter { - upvalue_t get(lua_State* L, int index = 1) { + static upvalue_t get(lua_State* L, int index = 1) { return{ lua_touserdata(L, lua_upvalueindex(index)) }; } }; template <> struct getter { - void* get(lua_State* L, int index = 1) { + static void* get(lua_State* L, int index = 1) { return lua_touserdata(L, index); } }; @@ -316,15 +316,17 @@ struct pusher { } }; -inline void push(lua_State*) { - -} - template inline void push(lua_State* L, T&& t, Args&&... args) { pusher>{}.push(L, std::forward(t), std::forward(args)...); } +// overload allows to use a pusher of a specific type, but pass in any kind of args +template +inline void push(lua_State* L, Arg&& t, Args&&... args) { + pusher>{}.push(L, std::forward(t), std::forward(args)...); +} + inline void push_args(lua_State*) { // do nothing }