mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
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:
commit
be3d0ac27c
21
build.ninja
21
build.ninja
|
@ -4,9 +4,11 @@ ninja_required_version = 1.3
|
|||
builddir = bin
|
||||
objdir = obj
|
||||
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
|
||||
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_win = -static -L"./lib" -llua5.2
|
||||
|
||||
rule compile
|
||||
command = $cxx -MMD -MF $out.d $cxxflags -c $in -o $out $incflags
|
||||
|
@ -14,14 +16,33 @@ rule compile
|
|||
depfile = $out.d
|
||||
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
|
||||
command = $cxx $in -o $out $linkflags
|
||||
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/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/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_debug: phony $builddir/debug/tests
|
||||
build install_win: phony $builddir/win/tests
|
||||
build install_win_debug: phony $builddir/win/debug/tests
|
||||
|
||||
default install
|
||||
|
|
|
@ -108,7 +108,7 @@ inline std::function<Signature> get_std_func(types<FxArgs...> t, types<>, lua_St
|
|||
}
|
||||
|
||||
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 typename fx_t::args_type args_t;
|
||||
typedef typename tuple_types<typename fx_t::return_type>::type ret_t;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <utility>
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
|
||||
namespace sol {
|
||||
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);
|
||||
}
|
||||
|
||||
template <typename Signature>
|
||||
inline std::function<Signature> get(types<std::function<Signature>>, lua_State* L, int index = -1);
|
||||
|
||||
template<typename T>
|
||||
inline T get_unsigned(std::true_type, lua_State* L, int index = -1) {
|
||||
return lua_tounsigned(L, index);
|
||||
|
|
|
@ -8,7 +8,8 @@ void test_free_func(std::function<void()> f) {
|
|||
|
||||
void test_free_func2(std::function<int(int)> f, int arg1) {
|
||||
int val = f(arg1);
|
||||
assert(arg1 == val);
|
||||
if(val != arg1)
|
||||
throw sol::error("failed function call!");
|
||||
}
|
||||
|
||||
std::string free_function() {
|
||||
|
@ -30,8 +31,10 @@ struct self_test {
|
|||
|
||||
void f(const self_test& t) {
|
||||
std::cout << "got test" << '\n';
|
||||
assert(t.bark == bark);
|
||||
assert(&t == this);
|
||||
if (t.bark != bark)
|
||||
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");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user