Have I mentioned I hate GCC? I hate GCC.

This commit is contained in:
ThePhD 2013-12-11 11:56:34 -05:00
parent 350f430d74
commit bcf4b9b08f
5 changed files with 16 additions and 11 deletions

1
.gitignore vendored
View File

@ -17,3 +17,4 @@ x64/
liblua.a
sol/include/
.ninja*
include/

View File

@ -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<sol::nil_t>("b"));
REQUIRE_NOTHROW(lua.get<sol::nil_t>("b"));
lua.script("d = 'hello'");
auto d = lua.get<std::string>("d");

View File

@ -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 {

View File

@ -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::return_type>(), typename fx_traits::args_type(), fx, L);
return r;
}
@ -106,7 +106,7 @@ struct static_object_lua_func {
static int typed_call(types<TR>, types<Args...>, T& item, fx_t& ifx, lua_State* L) {
auto fx = [ &item, &ifx ] (Args&&... args) -> TR {
return (item.*ifx)(std::forward<Args>(args)...);
};
};
auto r = stack::pop_call(L, fx, types<Args...>());
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<void*, data_t_count> data_t;
int upvalue = 1;
data_t data = { { } };

View File

@ -60,11 +60,6 @@ inline T get_arithmetic(lua_State* L, std::true_type, int index = -1) {
return get_unsigned<T>(L, std::is_unsigned<T>{}, index);
}
template<typename T>
inline T get_helper(lua_State* L, std::true_type, int index = -1) {
return get_nil<T>(L, std::is_same<nil_t, T>(), index);
}
template<typename T>
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<typename T>
inline T get_helper(lua_State* L, std::true_type, int index = -1) {
return get_nil<T>(L, std::is_same<nil_t, T>(), index);
}
template<typename T>
inline T get_helper(lua_State* L, std::false_type, int index = -1) {
// T is a fundamental type
@ -222,6 +222,10 @@ template<typename F, typename... Vs>
auto ltr_pop(lua_State*, F&& f, types<>, Vs&&... vs) -> decltype(f(std::forward<Vs>(vs)...)) {
return f(std::forward<Vs>(vs)...);
}
template<typename F, typename... Vs>
auto ltr_pop(lua_State*, F&& f, types<void>, Vs&&... vs) -> decltype(f(std::forward<Vs>(vs)...)) {
return f(std::forward<Vs>(vs)...);
}
template<typename F, typename Head, typename... Vs>
auto ltr_pop(lua_State* L, F&& f, types<Head>, Vs&&... vs) -> decltype(ltr_pop(L, std::forward<F>(f), types<>(), std::forward<Vs>(vs)..., pop<Head>(L))) {
return ltr_pop(L, std::forward<F>(f), types<>(), std::forward<Vs>(vs)..., pop<Head>(L));