Merge pull request #30 from ThePhD/master

Fixed segfault on GCC, updated ninja file for easier windows builds (and easier debug builds)
This commit is contained in:
Danny 2014-05-31 15:30:36 -04:00
commit be3d0ac27c
4 changed files with 32 additions and 4 deletions

View File

@ -4,9 +4,11 @@ ninja_required_version = 1.3
builddir = bin builddir = bin
objdir = obj objdir = obj
cxx = g++ cxx = g++
cxxflagsd = -std=c++11 -pedantic -pedantic-errors -g -Wextra -Wall -O0 -DEBUG
cxxflags = -std=c++11 -pedantic -pedantic-errors -Wextra -Wall -O2 -DNDEBUG cxxflags = -std=c++11 -pedantic -pedantic-errors -Wextra -Wall -O2 -DNDEBUG
incflags = -I"." -I"./include" -I"." -I"/usr/include/lua5.2" -I"./lua-5.2.2/src/" -I"./Catch/include/" incflags = -I"." -I"./include" -I"." -I"/usr/include/lua5.2" -I"./lua-5.2.2/src/" -I"./Catch/include/"
linkflags = -static -L"./lib" -llua5.2 -ldl linkflags = -static -L"./lib" -llua5.2 -ldl
linkflags_win = -static -L"./lib" -llua5.2
rule compile rule compile
command = $cxx -MMD -MF $out.d $cxxflags -c $in -o $out $incflags command = $cxx -MMD -MF $out.d $cxxflags -c $in -o $out $incflags
@ -14,14 +16,33 @@ rule compile
depfile = $out.d depfile = $out.d
description = Compiling $in description = Compiling $in
rule compiled
command = $cxx -MMD -MF $out.d $cxxflagsd -c $in -o $out $incflags
deps = gcc
depfile = $out.d
description = Compiling $in
rule link rule link
command = $cxx $in -o $out $linkflags command = $cxx $in -o $out $linkflags
description = Creating $out description = Creating $out
rule link_win
command = $cxx $in -o $out $linkflags_win
description = Creating $out
build $objdir/tests.o: compile tests.cpp build $objdir/tests.o: compile tests.cpp
build $objdir/debug/tests.o: compiled tests.cpp
build $objdir/win/tests.o: compile tests.cpp
build $objdir/win/debug/tests.o: compiled tests.cpp
build $builddir/tests: link $objdir/tests.o build $builddir/tests: link $objdir/tests.o
build $builddir/debug/tests: link $objdir/debug/tests.o
build $builddir/win/tests: link_win $objdir/win/tests.o
build $builddir/win/debug/tests: link_win $objdir/win/debug/tests.o
build install: phony $builddir/tests build install: phony $builddir/tests
build install_debug: phony $builddir/debug/tests
build install_win: phony $builddir/win/tests
build install_win_debug: phony $builddir/win/debug/tests
default install default install

View File

@ -108,7 +108,7 @@ inline std::function<Signature> get_std_func(types<FxArgs...> t, types<>, lua_St
} }
template <typename Signature> template <typename Signature>
inline std::function<Signature> get(types<std::function<Signature>>, lua_State* L, int index = -1) { inline std::function<Signature> get(types<std::function<Signature>>, lua_State* L, int index) {
typedef function_traits<Signature> fx_t; typedef function_traits<Signature> fx_t;
typedef typename fx_t::args_type args_t; typedef typename fx_t::args_type args_t;
typedef typename tuple_types<typename fx_t::return_type>::type ret_t; typedef typename tuple_types<typename fx_t::return_type>::type ret_t;

View File

@ -29,6 +29,7 @@
#include <utility> #include <utility>
#include <array> #include <array>
#include <cstring> #include <cstring>
#include <functional>
namespace sol { namespace sol {
namespace stack { namespace stack {
@ -78,6 +79,9 @@ inline auto get(types<T> t, lua_State* L, int index = -1) -> decltype(get_sol_ty
return get_sol_type(std::is_base_of<sol::reference, U>(), t, L, index); return get_sol_type(std::is_base_of<sol::reference, U>(), t, L, index);
} }
template <typename Signature>
inline std::function<Signature> get(types<std::function<Signature>>, lua_State* L, int index = -1);
template<typename T> template<typename T>
inline T get_unsigned(std::true_type, lua_State* L, int index = -1) { inline T get_unsigned(std::true_type, lua_State* L, int index = -1) {
return lua_tounsigned(L, index); return lua_tounsigned(L, index);

View File

@ -8,7 +8,8 @@ void test_free_func(std::function<void()> f) {
void test_free_func2(std::function<int(int)> f, int arg1) { void test_free_func2(std::function<int(int)> f, int arg1) {
int val = f(arg1); int val = f(arg1);
assert(arg1 == val); if(val != arg1)
throw sol::error("failed function call!");
} }
std::string free_function() { std::string free_function() {
@ -30,8 +31,10 @@ struct self_test {
void f(const self_test& t) { void f(const self_test& t) {
std::cout << "got test" << '\n'; std::cout << "got test" << '\n';
assert(t.bark == bark); if (t.bark != bark)
assert(&t == this); throw sol::error("bark values are not the same for self_test f function");
if (&t != this)
throw sol::error("call does not reference self for self_test f function");
} }
}; };