mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Proper defaults for bootstrap.py
Checks in g++ to make sure things compile clang++ is a major asshole...
This commit is contained in:
parent
e046435b49
commit
9c21d11b8c
@ -32,8 +32,8 @@ def replace_extension(f, e):
|
|||||||
# Default install dir
|
# Default install dir
|
||||||
install_dir = os.path.join('/usr', 'include') if 'linux' in sys.platform else 'include'
|
install_dir = os.path.join('/usr', 'include') if 'linux' in sys.platform else 'include'
|
||||||
|
|
||||||
# Compiler: Read from environment
|
# Compiler: Read from environment or defaulted
|
||||||
cxx = os.environ['CXX']
|
cxx = os.environ.get('CXX', "g++")
|
||||||
|
|
||||||
# command line stuff
|
# command line stuff
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
@ -78,9 +78,9 @@ if args.lua_dir:
|
|||||||
ldflags.extend(library_includes([os.path.join(args.lua_dir, 'lib')]))
|
ldflags.extend(library_includes([os.path.join(args.lua_dir, 'lib')]))
|
||||||
|
|
||||||
if args.ci:
|
if args.ci:
|
||||||
ldflags.extend(libraries(['lua5.2']))
|
ldflags.extend(libraries(['lua5.3']))
|
||||||
ldflags.extend(library_includes(['lib']))
|
ldflags.extend(library_includes(['lib']))
|
||||||
include.extend(['/usr/include/lua5.2', './lua-5.2.2/src', './include'])
|
include.extend(['/usr/include/lua5.3', './lua-5.3.2/src', './include'])
|
||||||
else:
|
else:
|
||||||
ldflags.extend(libraries(['lua']))
|
ldflags.extend(libraries(['lua']))
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ struct pusher<function_sig<Sigs...>> {
|
|||||||
template<typename Fx, typename R, typename... Args>
|
template<typename Fx, typename R, typename... Args>
|
||||||
static void set_isconvertible_fx(std::false_type, types<R(Args...)>, lua_State* L, Fx&& fx) {
|
static void set_isconvertible_fx(std::false_type, types<R(Args...)>, lua_State* L, Fx&& fx) {
|
||||||
typedef meta::Unwrapped<std::decay_t<Fx>> fx_t;
|
typedef meta::Unwrapped<std::decay_t<Fx>> fx_t;
|
||||||
std::unique_ptr<base_function> sptr = std::make_unique<function_detail::functor_function<fx_t>>(std::forward<Fx>(fx));
|
std::unique_ptr<function_detail::base_function> sptr = std::make_unique<function_detail::functor_function<fx_t>>(std::forward<Fx>(fx));
|
||||||
set_fx<Fx>(L, std::move(sptr));
|
set_fx<Fx>(L, std::move(sptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ struct void_call;
|
|||||||
|
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
struct void_call<T, types<Args...>> {
|
struct void_call<T, types<Args...>> {
|
||||||
static void call(Args... args) {}
|
static void call(Args...) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -80,7 +80,7 @@ struct member_function : public base_function {
|
|||||||
member_function(Tm&& m, Args&&... args): fx(std::forward<Tm>(m), std::forward<Args>(args)...) {}
|
member_function(Tm&& m, Args&&... args): fx(std::forward<Tm>(m), std::forward<Args>(args)...) {}
|
||||||
|
|
||||||
virtual int operator()(lua_State* L) override {
|
virtual int operator()(lua_State* L) override {
|
||||||
return stack::typed_call(meta::tuple_types<return_type>(), args_types(), fx, L);
|
return stack::typed_call(meta::tuple_types<return_type>(), args_types(), fx, L, 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // function_detail
|
} // function_detail
|
||||||
|
@ -57,7 +57,7 @@ inline int overload_match_arity(types<Fx, Fxs...>, std::index_sequence<I, In...>
|
|||||||
if (traits::arity != fxarity) {
|
if (traits::arity != fxarity) {
|
||||||
return overload_match_arity(types<Fxs...>(), std::index_sequence<In...>(), std::index_sequence<traits::arity, M...>(), std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
|
return overload_match_arity(types<Fxs...>(), std::index_sequence<In...>(), std::index_sequence<traits::arity, M...>(), std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
if (sizeof...(Fxs) != 0 && function_detail::check_types(args_type(), args_indices(), L, start)) {
|
if (sizeof...(Fxs) != 0 && !function_detail::check_types(args_type(), args_indices(), L, start)) {
|
||||||
return overload_match_arity(types<Fxs...>(), std::index_sequence<In...>(), std::index_sequence<M...>(), std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
|
return overload_match_arity(types<Fxs...>(), std::index_sequence<In...>(), std::index_sequence<M...>(), std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
return matchfx(meta::Bool<sizeof...(Fxs) != 0>(), types<Fx>(), Index<I>(), return_types(), args_type(), L, fxarity, start, std::forward<Args>(args)...);
|
return matchfx(meta::Bool<sizeof...(Fxs) != 0>(), types<Fx>(), Index<I>(), return_types(), args_type(), L, fxarity, start, std::forward<Args>(args)...);
|
||||||
@ -65,12 +65,12 @@ inline int overload_match_arity(types<Fx, Fxs...>, std::index_sequence<I, In...>
|
|||||||
} // internals
|
} // internals
|
||||||
|
|
||||||
template <typename... Functions, typename Match, typename... Args>
|
template <typename... Functions, typename Match, typename... Args>
|
||||||
inline int overload_match_arity(Match&& matchfx, lua_State* L, int fxarity, int start = 1, Args&&... args) {
|
inline int overload_match_arity(Match&& matchfx, lua_State* L, int fxarity, int start, Args&&... args) {
|
||||||
return internals::overload_match_arity(types<Functions...>(), std::index_sequence_for<Functions...>(), std::index_sequence<>(), std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
|
return internals::overload_match_arity(types<Functions...>(), std::index_sequence_for<Functions...>(), std::index_sequence<>(), std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Functions, typename Match, typename... Args>
|
template <typename... Functions, typename Match, typename... Args>
|
||||||
inline int overload_match(Match&& matchfx, lua_State* L, int start = 1, Args&&... args) {
|
inline int overload_match(Match&& matchfx, lua_State* L, int start, Args&&... args) {
|
||||||
int fxarity = lua_gettop(L) - (start - 1);
|
int fxarity = lua_gettop(L) - (start - 1);
|
||||||
return overload_match_arity<Functions...>(std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
|
return overload_match_arity<Functions...>(std::forward<Match>(matchfx), L, fxarity, start, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ struct overloaded_function : base_function {
|
|||||||
|
|
||||||
virtual int operator()(lua_State* L) override {
|
virtual int operator()(lua_State* L) override {
|
||||||
auto mfx = [&](auto&&... args){ return this->call(std::forward<decltype(args)>(args)...); };
|
auto mfx = [&](auto&&... args){ return this->call(std::forward<decltype(args)>(args)...); };
|
||||||
return overload_match<Functions...>(mfx, L);
|
return overload_match<Functions...>(mfx, L, 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -111,12 +111,7 @@ struct usertype_overloaded_function : base_function {
|
|||||||
typedef std::index_sequence_for<Functions...> indices;
|
typedef std::index_sequence_for<Functions...> indices;
|
||||||
overload_list overloads;
|
overload_list overloads;
|
||||||
|
|
||||||
usertype_overloaded_function(overload_set<Functions...> set) : usertype_overloaded_function(indices(), set) {}
|
usertype_overloaded_function(std::tuple<Functions...> set) : overloads(std::move(set)) {}
|
||||||
|
|
||||||
template <std::size_t... I>
|
|
||||||
usertype_overloaded_function(std::index_sequence<I...>, overload_set<Functions...> set) : usertype_overloaded_function(std::get<I>(set)...) {}
|
|
||||||
|
|
||||||
usertype_overloaded_function(Functions... fxs) : overloads(fxs...) {}
|
|
||||||
|
|
||||||
template <bool b,typename Fx, std::size_t I, typename... R, typename... Args>
|
template <bool b,typename Fx, std::size_t I, typename... R, typename... Args>
|
||||||
int call(meta::Bool<b>, types<Fx>, Index<I>, types<R...> r, types<Args...> a, lua_State* L, int, int start) {
|
int call(meta::Bool<b>, types<Fx>, Index<I>, types<R...> r, types<Args...> a, lua_State* L, int, int start) {
|
||||||
|
@ -34,7 +34,7 @@ struct static_function {
|
|||||||
static int call(lua_State* L) {
|
static int call(lua_State* L) {
|
||||||
auto udata = stack::stack_detail::get_as_upvalues<function_type*>(L);
|
auto udata = stack::stack_detail::get_as_upvalues<function_type*>(L);
|
||||||
function_type* fx = udata.first;
|
function_type* fx = udata.first;
|
||||||
int r = stack::typed_call(meta::tuple_types<typename traits_type::return_type>(), typename traits_type::args_type(), fx, L);
|
int r = stack::typed_call(meta::tuple_types<typename traits_type::return_type>(), typename traits_type::args_type(), fx, L, 1);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ struct static_member_function {
|
|||||||
function_type& memfx = memberdata.first;
|
function_type& memfx = memberdata.first;
|
||||||
T& item = *objdata.first;
|
T& item = *objdata.first;
|
||||||
auto fx = [&item, &memfx](auto&&... args) -> typename traits_type::return_type { return (item.*memfx)(std::forward<decltype(args)>(args)...); };
|
auto fx = [&item, &memfx](auto&&... args) -> typename traits_type::return_type { return (item.*memfx)(std::forward<decltype(args)>(args)...); };
|
||||||
return stack::typed_call(meta::tuple_types<typename traits_type::return_type>(), typename traits_type::args_type(), fx, L);
|
return stack::typed_call(meta::tuple_types<typename traits_type::return_type>(), typename traits_type::args_type(), fx, L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int operator()(lua_State* L) {
|
int operator()(lua_State* L) {
|
||||||
|
@ -85,7 +85,7 @@ public:
|
|||||||
|
|
||||||
template<typename... Ret, typename... Args>
|
template<typename... Ret, typename... Args>
|
||||||
decltype(auto) call(Args&&... args) {
|
decltype(auto) call(Args&&... args) {
|
||||||
return get<function>().call<Ret...>(std::forward<Args>(args)...);
|
return get<function>().template call<Ret...>(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
|
@ -43,6 +43,10 @@ push_pop<top_level, T> push_popper(T&& x) {
|
|||||||
}
|
}
|
||||||
} // stack
|
} // stack
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
struct global_tag { } const global_{};
|
||||||
|
} // detail
|
||||||
|
|
||||||
class reference {
|
class reference {
|
||||||
private:
|
private:
|
||||||
lua_State* L = nullptr; // non-owning
|
lua_State* L = nullptr; // non-owning
|
||||||
@ -54,6 +58,12 @@ private:
|
|||||||
push();
|
push();
|
||||||
return luaL_ref(L, LUA_REGISTRYINDEX);
|
return luaL_ref(L, LUA_REGISTRYINDEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
reference(lua_State* L, detail::global_tag) : L(L) {
|
||||||
|
lua_pushglobaltable(L);
|
||||||
|
ref = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||||
|
}
|
||||||
public:
|
public:
|
||||||
reference() noexcept = default;
|
reference() noexcept = default;
|
||||||
|
|
||||||
|
@ -36,19 +36,19 @@ inline auto resolve_i(types<R(Args...)>, F&&) -> R(meta::Unqualified<F>::*)(Args
|
|||||||
|
|
||||||
template<typename F, typename U = meta::Unqualified<F>>
|
template<typename F, typename U = meta::Unqualified<F>>
|
||||||
inline auto resolve_f(std::true_type, F&& f)
|
inline auto resolve_f(std::true_type, F&& f)
|
||||||
-> decltype(resolve_i(types<function_signature_t<decltype(&U::operator())>>(), std::forward<F>(f))) {
|
-> decltype(resolve_i(types<meta::function_signature_t<decltype(&U::operator())>>(), std::forward<F>(f))) {
|
||||||
return resolve_i(types<function_signature_t<decltype(&U::operator())>>(), std::forward<F>(f));
|
return resolve_i(types<meta::function_signature_t<decltype(&U::operator())>>(), std::forward<F>(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
inline void resolve_f(std::false_type, F&&) {
|
inline void resolve_f(std::false_type, F&&) {
|
||||||
static_assert(has_deducible_signature<F>::value,
|
static_assert(meta::has_deducible_signature<F>::value,
|
||||||
"Cannot use no-template-parameter call with an overloaded functor: specify the signature");
|
"Cannot use no-template-parameter call with an overloaded functor: specify the signature");
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename F, typename U = meta::Unqualified<F>>
|
template<typename F, typename U = meta::Unqualified<F>>
|
||||||
inline auto resolve_i(types<>, F&& f) -> decltype(resolve_f(has_deducible_signature<U> {}, std::forward<F>(f))) {
|
inline auto resolve_i(types<>, F&& f) -> decltype(resolve_f(meta::has_deducible_signature<U>(), std::forward<F>(f))) {
|
||||||
return resolve_f(has_deducible_signature<U> {}, std::forward<F>(f));
|
return resolve_f(meta::has_deducible_signature<U> {}, std::forward<F>(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args, typename F, typename R = std::result_of_t<F&(Args...)>>
|
template<typename... Args, typename F, typename R = std::result_of_t<F&(Args...)>>
|
||||||
|
124
sol/stack.hpp
124
sol/stack.hpp
@ -175,7 +175,7 @@ struct userdata_pusher<T*> {
|
|||||||
template<typename T, std::size_t... I>
|
template<typename T, std::size_t... I>
|
||||||
inline int push_tuple(std::index_sequence<I...>, lua_State* L, T&& tuplen) {
|
inline int push_tuple(std::index_sequence<I...>, lua_State* L, T&& tuplen) {
|
||||||
int pushcount = 0;
|
int pushcount = 0;
|
||||||
detail::swallow{(pushcount += sol::stack::push(L, std::get<I>(tuplen)), '\0')... };
|
void(detail::swallow{(pushcount += sol::stack::push(L, std::get<I>(tuplen)), '\0')... });
|
||||||
return pushcount;
|
return pushcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,64 +218,6 @@ inline int push_userdata(lua_State* L, Key&& metatablekey, Args&&... args) {
|
|||||||
}
|
}
|
||||||
} // stack_detail
|
} // stack_detail
|
||||||
|
|
||||||
template <typename T, type expected, typename>
|
|
||||||
struct checker {
|
|
||||||
template <typename Handler>
|
|
||||||
static bool check (lua_State* L, int index, const Handler& handler) {
|
|
||||||
const type indextype = type_of(L, index);
|
|
||||||
bool success = expected == indextype;
|
|
||||||
if (!success) {
|
|
||||||
// expected type, actual type
|
|
||||||
handler(L, index, expected, indextype);
|
|
||||||
}
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, typename C>
|
|
||||||
struct checker<T*, type::userdata, C> {
|
|
||||||
template <typename Handler>
|
|
||||||
static bool check (lua_State* L, int index, const Handler& handler) {
|
|
||||||
const type indextype = type_of(L, index);
|
|
||||||
// Allow nil to be transformed to nullptr
|
|
||||||
if (indextype == type::nil) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return checker<T, type::userdata, C>{}.check(L, indextype, index, handler);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T,typename C>
|
|
||||||
struct checker<T, type::userdata, C> {
|
|
||||||
template <typename Handler>
|
|
||||||
static bool check (lua_State* L, type indextype, int index, const Handler& handler) {
|
|
||||||
if (indextype != type::userdata) {
|
|
||||||
handler(L, index, type::userdata, indextype);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (lua_getmetatable(L, index) == 0) {
|
|
||||||
handler(L, index, type::userdata, indextype);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
luaL_getmetatable(L, &usertype_traits<T>::metatable[0]);
|
|
||||||
const type expectedmetatabletype = get<type>(L);
|
|
||||||
if (expectedmetatabletype == type::nil) {
|
|
||||||
lua_pop(L, 2);
|
|
||||||
handler(L, index, type::userdata, indextype);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bool success = lua_rawequal(L, -1, -2) == 1;
|
|
||||||
lua_pop(L, 2);
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Handler>
|
|
||||||
static bool check (lua_State* L, int index, const Handler& handler) {
|
|
||||||
const type indextype = type_of(L, index);
|
|
||||||
return check(L, indextype, index, handler);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T, typename>
|
template<typename T, typename>
|
||||||
struct getter {
|
struct getter {
|
||||||
static T& get(lua_State* L, int index = -1) {
|
static T& get(lua_State* L, int index = -1) {
|
||||||
@ -433,6 +375,64 @@ struct getter<std::tuple<Args...>> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T, type expected, typename>
|
||||||
|
struct checker {
|
||||||
|
template <typename Handler>
|
||||||
|
static bool check (lua_State* L, int index, const Handler& handler) {
|
||||||
|
const type indextype = type_of(L, index);
|
||||||
|
bool success = expected == indextype;
|
||||||
|
if (!success) {
|
||||||
|
// expected type, actual type
|
||||||
|
handler(L, index, expected, indextype);
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T, typename C>
|
||||||
|
struct checker<T*, type::userdata, C> {
|
||||||
|
template <typename Handler>
|
||||||
|
static bool check (lua_State* L, int index, const Handler& handler) {
|
||||||
|
const type indextype = type_of(L, index);
|
||||||
|
// Allow nil to be transformed to nullptr
|
||||||
|
if (indextype == type::nil) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return checker<T, type::userdata, C>{}.check(L, indextype, index, handler);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T,typename C>
|
||||||
|
struct checker<T, type::userdata, C> {
|
||||||
|
template <typename Handler>
|
||||||
|
static bool check (lua_State* L, type indextype, int index, const Handler& handler) {
|
||||||
|
if (indextype != type::userdata) {
|
||||||
|
handler(L, index, type::userdata, indextype);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (lua_getmetatable(L, index) == 0) {
|
||||||
|
handler(L, index, type::userdata, indextype);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
luaL_getmetatable(L, &usertype_traits<T>::metatable[0]);
|
||||||
|
const type expectedmetatabletype = get<type>(L);
|
||||||
|
if (expectedmetatabletype == type::nil) {
|
||||||
|
lua_pop(L, 2);
|
||||||
|
handler(L, index, type::userdata, indextype);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool success = lua_rawequal(L, -1, -2) == 1;
|
||||||
|
lua_pop(L, 2);
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Handler>
|
||||||
|
static bool check (lua_State* L, int index, const Handler& handler) {
|
||||||
|
const type indextype = type_of(L, index);
|
||||||
|
return check(L, indextype, index, handler);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T, typename>
|
template <typename T, typename>
|
||||||
struct popper {
|
struct popper {
|
||||||
inline decltype(auto) pop(lua_State* L) {
|
inline decltype(auto) pop(lua_State* L) {
|
||||||
@ -656,7 +656,7 @@ struct field_getter<std::tuple<Args...>, b, C> {
|
|||||||
template <std::size_t I0, std::size_t... I, typename Key>
|
template <std::size_t I0, std::size_t... I, typename Key>
|
||||||
void apply(std::index_sequence<I0, I...>, lua_State* L, Key&& key, int tableindex) {
|
void apply(std::index_sequence<I0, I...>, lua_State* L, Key&& key, int tableindex) {
|
||||||
get_field<b>(L, std::get<I0>(key), tableindex);
|
get_field<b>(L, std::get<I0>(key), tableindex);
|
||||||
detail::swallow{ (get_field(L, std::get<I>(key)), 0)... };
|
void(detail::swallow{ (get_field(L, std::get<I>(key)), 0)... });
|
||||||
reference saved(L, -1);
|
reference saved(L, -1);
|
||||||
lua_pop(L, static_cast<int>(sizeof...(I) + 1));
|
lua_pop(L, static_cast<int>(sizeof...(I) + 1));
|
||||||
saved.push();
|
saved.push();
|
||||||
@ -853,7 +853,7 @@ inline void top_call(types<void> tr, types<Args...> ta, lua_State* L, Fx&& fx, F
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<bool check_args = stack_detail::default_check_arguments, typename... Args, typename Fx, typename... FxArgs>
|
template<bool check_args = stack_detail::default_check_arguments, typename... Args, typename Fx, typename... FxArgs>
|
||||||
inline int typed_call(types<void> tr, types<Args...> ta, Fx&& fx, lua_State* L, int start = 1, FxArgs&&... fxargs) {
|
inline int typed_call(types<void> tr, types<Args...> ta, Fx&& fx, lua_State* L, int start, FxArgs&&... fxargs) {
|
||||||
call<check_args>(tr, ta, L, start, fx, std::forward<FxArgs>(fxargs)...);
|
call<check_args>(tr, ta, L, start, fx, std::forward<FxArgs>(fxargs)...);
|
||||||
int nargs = static_cast<int>(sizeof...(Args));
|
int nargs = static_cast<int>(sizeof...(Args));
|
||||||
lua_pop(L, nargs);
|
lua_pop(L, nargs);
|
||||||
@ -861,7 +861,7 @@ inline int typed_call(types<void> tr, types<Args...> ta, Fx&& fx, lua_State* L,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<bool check_args = stack_detail::default_check_arguments, typename Ret0, typename... Ret, typename... Args, typename Fx, typename... FxArgs, typename = std::enable_if_t<meta::Not<std::is_void<Ret0>>::value>>
|
template<bool check_args = stack_detail::default_check_arguments, typename Ret0, typename... Ret, typename... Args, typename Fx, typename... FxArgs, typename = std::enable_if_t<meta::Not<std::is_void<Ret0>>::value>>
|
||||||
inline int typed_call(types<Ret0, Ret...>, types<Args...> ta, Fx&& fx, lua_State* L, int start = 1, FxArgs&&... fxargs) {
|
inline int typed_call(types<Ret0, Ret...>, types<Args...> ta, Fx&& fx, lua_State* L, int start, FxArgs&&... fxargs) {
|
||||||
decltype(auto) r = call<check_args>(types<meta::return_type_t<Ret0, Ret...>>(), ta, L, start, fx, std::forward<FxArgs>(fxargs)...);
|
decltype(auto) r = call<check_args>(types<meta::return_type_t<Ret0, Ret...>>(), ta, L, start, fx, std::forward<FxArgs>(fxargs)...);
|
||||||
int nargs = static_cast<int>(sizeof...(Args));
|
int nargs = static_cast<int>(sizeof...(Args));
|
||||||
lua_pop(L, nargs);
|
lua_pop(L, nargs);
|
||||||
|
@ -58,7 +58,7 @@ public:
|
|||||||
state_view(lua_State* L):
|
state_view(lua_State* L):
|
||||||
L(L),
|
L(L),
|
||||||
reg(L, LUA_REGISTRYINDEX),
|
reg(L, LUA_REGISTRYINDEX),
|
||||||
globals(detail::global_overload, reg) {
|
globals(L, detail::global_) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,10 +28,6 @@
|
|||||||
#include "usertype.hpp"
|
#include "usertype.hpp"
|
||||||
|
|
||||||
namespace sol {
|
namespace sol {
|
||||||
namespace detail {
|
|
||||||
struct global_overload_tag { } const global_overload;
|
|
||||||
} // detail
|
|
||||||
|
|
||||||
template <bool top_level>
|
template <bool top_level>
|
||||||
class table_core : public reference {
|
class table_core : public reference {
|
||||||
friend class state;
|
friend class state;
|
||||||
@ -45,7 +41,7 @@ class table_core : public reference {
|
|||||||
-> decltype(stack::pop<std::tuple<Ret...>>(nullptr)){
|
-> decltype(stack::pop<std::tuple<Ret...>>(nullptr)){
|
||||||
auto pp = stack::push_popper<is_global<decltype(std::get<I>(keys))...>::value>(*this);
|
auto pp = stack::push_popper<is_global<decltype(std::get<I>(keys))...>::value>(*this);
|
||||||
int tableindex = lua_gettop(lua_state());
|
int tableindex = lua_gettop(lua_state());
|
||||||
detail::swallow{ ( stack::get_field<top_level>(lua_state(), std::get<I>(keys), tableindex), 0)... };
|
void(detail::swallow{ ( stack::get_field<top_level>(lua_state(), std::get<I>(keys), tableindex), 0)... });
|
||||||
return stack::pop<std::tuple<Ret...>>( lua_state() );
|
return stack::pop<std::tuple<Ret...>>( lua_state() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +55,7 @@ class table_core : public reference {
|
|||||||
template<typename Pairs, std::size_t... I>
|
template<typename Pairs, std::size_t... I>
|
||||||
void tuple_set( std::index_sequence<I...>, Pairs&& pairs ) {
|
void tuple_set( std::index_sequence<I...>, Pairs&& pairs ) {
|
||||||
auto pp = stack::push_popper<is_global<decltype(std::get<I * 2>(pairs))...>::value>(*this);
|
auto pp = stack::push_popper<is_global<decltype(std::get<I * 2>(pairs))...>::value>(*this);
|
||||||
detail::swallow{ (stack::set_field<top_level>(lua_state(), std::get<I * 2>(pairs), std::get<I * 2 + 1>(pairs)), 0)... };
|
void(detail::swallow{ (stack::set_field<top_level>(lua_state(), std::get<I * 2>(pairs), std::get<I * 2 + 1>(pairs)), 0)... });
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool global, typename T, typename Key>
|
template <bool global, typename T, typename Key>
|
||||||
@ -85,11 +81,8 @@ class table_core : public reference {
|
|||||||
traverse_set_deep<false>(std::forward<Keys>(keys)...);
|
traverse_set_deep<false>(std::forward<Keys>(keys)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOL_LUA_VERSION < 502
|
table_core(lua_State* L, detail::global_tag t) noexcept : reference(L, t) { }
|
||||||
table_core( detail::global_overload_tag, const table_core<false>& reg ) noexcept : reference( reg.lua_state(), LUA_GLOBALSINDEX ) { }
|
|
||||||
#else
|
|
||||||
table_core( detail::global_overload_tag, const table& reg ) noexcept : reference( reg.get<table>( LUA_RIDX_GLOBALS ) ) { }
|
|
||||||
#endif
|
|
||||||
public:
|
public:
|
||||||
table_core( ) noexcept : reference( ) { }
|
table_core( ) noexcept : reference( ) { }
|
||||||
table_core( const table_core<true>& global ) : reference( global ) { }
|
table_core( const table_core<true>& global ) : reference( global ) { }
|
||||||
|
@ -73,7 +73,7 @@ using remove_member_pointer_t = remove_member_pointer<T>;
|
|||||||
template<typename T, template<typename...> class Templ>
|
template<typename T, template<typename...> class Templ>
|
||||||
struct is_specialization_of : std::false_type { };
|
struct is_specialization_of : std::false_type { };
|
||||||
template<typename... T, template<typename...> class Templ>
|
template<typename... T, template<typename...> class Templ>
|
||||||
struct meta::is_specialization_of<Templ<T...>, Templ> : std::true_type { };
|
struct is_specialization_of<Templ<T...>, Templ> : std::true_type { };
|
||||||
|
|
||||||
template<class T, class...>
|
template<class T, class...>
|
||||||
struct are_same : std::true_type { };
|
struct are_same : std::true_type { };
|
||||||
|
@ -238,7 +238,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int true_a = 156;
|
static const int true_a;
|
||||||
int a;
|
int a;
|
||||||
|
|
||||||
static std::unique_ptr<factory_test, deleter> make() {
|
static std::unique_ptr<factory_test, deleter> make() {
|
||||||
@ -258,6 +258,7 @@ public:
|
|||||||
|
|
||||||
int factory_test::num_saved = 0;
|
int factory_test::num_saved = 0;
|
||||||
int factory_test::num_killed = 0;
|
int factory_test::num_killed = 0;
|
||||||
|
const int factory_test::true_a = 156;
|
||||||
|
|
||||||
TEST_CASE("table/traversal", "ensure that we can chain requests and tunnel down into a value if we desire") {
|
TEST_CASE("table/traversal", "ensure that we can chain requests and tunnel down into a value if we desire") {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user