mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Bark. I always forget things.
This commit is contained in:
parent
46b107712f
commit
0e56783de9
|
@ -20,8 +20,8 @@
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// This file was generated with a script.
|
// This file was generated with a script.
|
||||||
// Generated 2016-09-13 16:53:17.844066 UTC
|
// Generated 2016-09-14 04:01:54.009414 UTC
|
||||||
// This header was generated with sol v2.12.4 (revision 22d5a70)
|
// This header was generated with sol v2.14.0 (revision 46b1077)
|
||||||
// https://github.com/ThePhD/sol2
|
// https://github.com/ThePhD/sol2
|
||||||
|
|
||||||
#ifndef SOL_SINGLE_INCLUDE_HPP
|
#ifndef SOL_SINGLE_INCLUDE_HPP
|
||||||
|
@ -3092,18 +3092,18 @@ namespace sol {
|
||||||
|
|
||||||
template <typename Sig, typename... Ps>
|
template <typename Sig, typename... Ps>
|
||||||
struct function_arguments {
|
struct function_arguments {
|
||||||
std::tuple<Ps...> params;
|
std::tuple<Ps...> arguments;
|
||||||
template <typename Arg, typename... Args, meta::disable<std::is_same<meta::unqualified_t<Arg>, function_arguments>> = meta::enabler>
|
template <typename Arg, typename... Args, meta::disable<std::is_same<meta::unqualified_t<Arg>, function_arguments>> = meta::enabler>
|
||||||
function_arguments(Arg&& arg, Args&&... args) : params(std::forward<Arg>(arg), std::forward<Args>(args)...) {}
|
function_arguments(Arg&& arg, Args&&... args) : arguments(std::forward<Arg>(arg), std::forward<Args>(args)...) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Sig = function_sig<>, typename... Args>
|
template <typename Sig = function_sig<>, typename... Args>
|
||||||
function_arguments<Sig, std::decay_t<Args>...> as_function(Args&&... args) {
|
auto as_function(Args&&... args) {
|
||||||
return function_arguments<Sig, std::decay_t<Args>...>(std::forward<Args>(args)...);
|
return function_arguments<Sig, std::decay_t<Args>...>(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Sig = function_sig<>, typename... Args>
|
template <typename Sig = function_sig<>, typename... Args>
|
||||||
function_arguments<Sig, Args...> as_function_reference(Args&&... args) {
|
auto as_function_reference(Args&&... args) {
|
||||||
return function_arguments<Sig, Args...>(std::forward<Args>(args)...);
|
return function_arguments<Sig, Args...>(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4861,9 +4861,9 @@ namespace sol {
|
||||||
namespace sol {
|
namespace sol {
|
||||||
template <typename... Functions>
|
template <typename... Functions>
|
||||||
struct overload_set {
|
struct overload_set {
|
||||||
std::tuple<Functions...> set;
|
std::tuple<Functions...> functions;
|
||||||
template <typename Arg, typename... Args, meta::disable<std::is_same<overload_set, meta::unqualified_t<Arg>>> = meta::enabler>
|
template <typename Arg, typename... Args, meta::disable<std::is_same<overload_set, meta::unqualified_t<Arg>>> = meta::enabler>
|
||||||
overload_set (Arg&& arg, Args&&... args) : set(std::forward<Arg>(arg), std::forward<Args>(args)...) {}
|
overload_set (Arg&& arg, Args&&... args) : functions(std::forward<Arg>(arg), std::forward<Args>(args)...) {}
|
||||||
overload_set(const overload_set&) = default;
|
overload_set(const overload_set&) = default;
|
||||||
overload_set(overload_set&&) = default;
|
overload_set(overload_set&&) = default;
|
||||||
overload_set& operator=(const overload_set&) = default;
|
overload_set& operator=(const overload_set&) = default;
|
||||||
|
@ -5506,9 +5506,11 @@ namespace sol {
|
||||||
return std::unique_ptr<T, Dx>(new T(std::forward<Args>(args)...));
|
return std::unique_ptr<T, Dx>(new T(std::forward<Args>(args)...));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename List>
|
template <typename Tag, typename T>
|
||||||
struct tagged {
|
struct tagged {
|
||||||
List l;
|
T value;
|
||||||
|
template <typename Arg, typename... Args, meta::disable<std::is_same<meta::unqualified_t<Arg>, tagged>> = meta::enabler>
|
||||||
|
tagged(Arg&& arg, Args&&... args) : value(std::forward<Arg>(arg), std::forward<Args>(args)...) {}
|
||||||
};
|
};
|
||||||
} // detail
|
} // detail
|
||||||
|
|
||||||
|
@ -5528,9 +5530,9 @@ namespace sol {
|
||||||
|
|
||||||
template <typename... Functions>
|
template <typename... Functions>
|
||||||
struct constructor_wrapper {
|
struct constructor_wrapper {
|
||||||
std::tuple<Functions...> set;
|
std::tuple<Functions...> functions;
|
||||||
template <typename... Args>
|
template <typename Arg, typename... Args, meta::disable<std::is_same<meta::unqualified_t<Arg>, constructor_wrapper>> = meta::enabler>
|
||||||
constructor_wrapper(Args&&... args) : set(std::forward<Args>(args)...) {}
|
constructor_wrapper(Arg&& arg, Args&&... args) : functions(std::forward<Arg>(arg), std::forward<Args>(args)...) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... Functions>
|
template <typename... Functions>
|
||||||
|
@ -5540,9 +5542,9 @@ namespace sol {
|
||||||
|
|
||||||
template <typename... Functions>
|
template <typename... Functions>
|
||||||
struct factory_wrapper {
|
struct factory_wrapper {
|
||||||
std::tuple<Functions...> set;
|
std::tuple<Functions...> functions;
|
||||||
template <typename... Args>
|
template <typename Arg, typename... Args, meta::disable<std::is_same<meta::unqualified_t<Arg>, factory_wrapper>> = meta::enabler>
|
||||||
factory_wrapper(Args&&... args) : set(std::forward<Args>(args)...) {}
|
factory_wrapper(Arg&& arg, Args&&... args) : functions(std::forward<Arg>(arg), std::forward<Args>(args)...) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... Functions>
|
template <typename... Functions>
|
||||||
|
@ -7531,7 +7533,7 @@ namespace sol {
|
||||||
T* obj = reinterpret_cast<T*>(pointerpointer + 1);
|
T* obj = reinterpret_cast<T*>(pointerpointer + 1);
|
||||||
referencepointer = obj;
|
referencepointer = obj;
|
||||||
|
|
||||||
auto& func = std::get<I>(f.set);
|
auto& func = std::get<I>(f.functions);
|
||||||
stack::call_into_lua<checked>(r, a, L, boost + start, func, detail::implicit_wrapper<T>(obj));
|
stack::call_into_lua<checked>(r, a, L, boost + start, func, detail::implicit_wrapper<T>(obj));
|
||||||
|
|
||||||
userdataref.push();
|
userdataref.push();
|
||||||
|
@ -7584,7 +7586,7 @@ namespace sol {
|
||||||
struct on_match {
|
struct on_match {
|
||||||
template <typename Fx, std::size_t I, typename... R, typename... Args>
|
template <typename Fx, std::size_t I, typename... R, typename... Args>
|
||||||
int operator()(types<Fx>, index_value<I>, types<R...>, types<Args...>, lua_State* L, int, int, F& fx) {
|
int operator()(types<Fx>, index_value<I>, types<R...>, types<Args...>, lua_State* L, int, int, F& fx) {
|
||||||
auto& f = std::get<I>(fx.set);
|
auto& f = std::get<I>(fx.functions);
|
||||||
return lua_call_wrapper<T, Fx, is_index, is_variable, checked, boost>{}.call(L, f);
|
return lua_call_wrapper<T, Fx, is_index, is_variable, checked, boost>{}.call(L, f);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -7601,7 +7603,7 @@ namespace sol {
|
||||||
struct on_match {
|
struct on_match {
|
||||||
template <typename Fx, std::size_t I, typename... R, typename... Args>
|
template <typename Fx, std::size_t I, typename... R, typename... Args>
|
||||||
int operator()(types<Fx>, index_value<I>, types<R...>, types<Args...>, lua_State* L, int, int, F& fx) {
|
int operator()(types<Fx>, index_value<I>, types<R...>, types<Args...>, lua_State* L, int, int, F& fx) {
|
||||||
auto& f = std::get<I>(fx.set);
|
auto& f = std::get<I>(fx.functions);
|
||||||
return lua_call_wrapper<T, Fx, is_index, is_variable, checked, boost>{}.call(L, f);
|
return lua_call_wrapper<T, Fx, is_index, is_variable, checked, boost>{}.call(L, f);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -7679,7 +7681,7 @@ namespace sol {
|
||||||
struct lua_call_wrapper<T, function_arguments<Sig, P>, is_index, is_variable, checked, boost, C> {
|
struct lua_call_wrapper<T, function_arguments<Sig, P>, is_index, is_variable, checked, boost, C> {
|
||||||
template <typename F>
|
template <typename F>
|
||||||
static int call(lua_State* L, F&& f) {
|
static int call(lua_State* L, F&& f) {
|
||||||
return lua_call_wrapper<T, meta::unqualified_t<P>, is_index, is_variable, stack::stack_detail::default_check_arguments, boost>{}.call(L, std::get<0>(f.params));
|
return lua_call_wrapper<T, meta::unqualified_t<P>, is_index, is_variable, stack::stack_detail::default_check_arguments, boost>{}.call(L, std::get<0>(f.arguments));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -8304,7 +8306,7 @@ namespace sol {
|
||||||
struct pusher<function_arguments<T, Args...>> {
|
struct pusher<function_arguments<T, Args...>> {
|
||||||
template <std::size_t... I, typename FP>
|
template <std::size_t... I, typename FP>
|
||||||
static int push_func(std::index_sequence<I...>, lua_State* L, FP&& fp) {
|
static int push_func(std::index_sequence<I...>, lua_State* L, FP&& fp) {
|
||||||
return stack::push<T>(L, detail::forward_get<I>(fp.params)...);
|
return stack::push<T>(L, detail::forward_get<I>(fp.arguments)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int push(lua_State* L, const function_arguments<T, Args...>& fp) {
|
static int push(lua_State* L, const function_arguments<T, Args...>& fp) {
|
||||||
|
@ -8343,13 +8345,13 @@ namespace sol {
|
||||||
struct pusher<overload_set<Functions...>> {
|
struct pusher<overload_set<Functions...>> {
|
||||||
static int push(lua_State* L, overload_set<Functions...>&& set) {
|
static int push(lua_State* L, overload_set<Functions...>&& set) {
|
||||||
typedef function_detail::overloaded_function<Functions...> F;
|
typedef function_detail::overloaded_function<Functions...> F;
|
||||||
pusher<function_sig<>>{}.set_fx<F>(L, std::move(set.set));
|
pusher<function_sig<>>{}.set_fx<F>(L, std::move(set.functions));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int push(lua_State* L, const overload_set<Functions...>& set) {
|
static int push(lua_State* L, const overload_set<Functions...>& set) {
|
||||||
typedef function_detail::overloaded_function<Functions...> F;
|
typedef function_detail::overloaded_function<Functions...> F;
|
||||||
pusher<function_sig<>>{}.set_fx<F>(L, set.set);
|
pusher<function_sig<>>{}.set_fx<F>(L, set.functions);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -8409,6 +8411,21 @@ namespace sol {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename... Functions>
|
||||||
|
struct pusher<factory_wrapper<Functions...>> {
|
||||||
|
static int push(lua_State* L, const factory_wrapper<Functions...>& fw) {
|
||||||
|
typedef function_detail::overloaded_function<Functions...> F;
|
||||||
|
pusher<function_sig<>>{}.set_fx<F>(L, fw.functions);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int push(lua_State* L, factory_wrapper<Functions...>&& fw) {
|
||||||
|
typedef function_detail::overloaded_function<Functions...> F;
|
||||||
|
pusher<function_sig<>>{}.set_fx<F>(L, std::move(fw.functions));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T, typename... Lists>
|
template <typename T, typename... Lists>
|
||||||
struct pusher<detail::tagged<T, constructor_list<Lists...>>> {
|
struct pusher<detail::tagged<T, constructor_list<Lists...>>> {
|
||||||
static int push(lua_State* L, detail::tagged<T, constructor_list<Lists...>>) {
|
static int push(lua_State* L, detail::tagged<T, constructor_list<Lists...>>) {
|
||||||
|
@ -8419,9 +8436,10 @@ namespace sol {
|
||||||
|
|
||||||
template <typename T, typename... Fxs>
|
template <typename T, typename... Fxs>
|
||||||
struct pusher<detail::tagged<T, constructor_wrapper<Fxs...>>> {
|
struct pusher<detail::tagged<T, constructor_wrapper<Fxs...>>> {
|
||||||
static int push(lua_State* L, constructor_wrapper<Fxs...> c) {
|
template <typename C>
|
||||||
|
static int push(lua_State* L, C&& c) {
|
||||||
lua_CFunction cf = call_detail::call_user<T, false, false, constructor_wrapper<Fxs...>>;
|
lua_CFunction cf = call_detail::call_user<T, false, false, constructor_wrapper<Fxs...>>;
|
||||||
int closures = stack::push<user<T>>(L, std::move(c));
|
int closures = stack::push<user<constructor_wrapper<Fxs...>>>(L, std::forward<C>(c));
|
||||||
return stack::push(L, c_closure(cf, closures));
|
return stack::push(L, c_closure(cf, closures));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -10088,6 +10106,10 @@ namespace sol {
|
||||||
|
|
||||||
template <typename N, typename F, meta::disable<meta::is_callable<meta::unwrap_unqualified_t<F>>> = meta::enabler>
|
template <typename N, typename F, meta::disable<meta::is_callable<meta::unwrap_unqualified_t<F>>> = meta::enabler>
|
||||||
void add_function(lua_State* L, N&& n, F&& f) {
|
void add_function(lua_State* L, N&& n, F&& f) {
|
||||||
|
if (std::is_same<meta::unqualified_t<N>, call_construction>::value) {
|
||||||
|
callconstructfunc = make_object(L, std::forward<F>(f));
|
||||||
|
return;
|
||||||
|
}
|
||||||
registrations.emplace(usertype_detail::make_string(std::forward<N>(n)), make_object(L, std::forward<F>(f)));
|
registrations.emplace(usertype_detail::make_string(std::forward<N>(n)), make_object(L, std::forward<F>(f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10105,17 +10127,22 @@ namespace sol {
|
||||||
|
|
||||||
template <typename N, typename... Fxs>
|
template <typename N, typename... Fxs>
|
||||||
void add(lua_State* L, N&& n, constructor_wrapper<Fxs...> c) {
|
void add(lua_State* L, N&& n, constructor_wrapper<Fxs...> c) {
|
||||||
registrations.emplace(usertype_detail::make_string(std::forward<N>(n)), make_object(L, detail::tagged<T, constructor_wrapper<Fxs...>>{std::move(c)}));
|
object o(L, in_place<detail::tagged<T, constructor_wrapper<Fxs...>>>, std::move(c));
|
||||||
|
if (std::is_same<meta::unqualified_t<N>, call_construction>::value) {
|
||||||
|
callconstructfunc = std::move(o);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
registrations.emplace(usertype_detail::make_string(std::forward<N>(n)), std::move(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename N, typename... Lists>
|
template <typename N, typename... Lists>
|
||||||
void add(lua_State* L, N&& n, constructor_list<Lists...> c) {
|
void add(lua_State* L, N&& n, constructor_list<Lists...> c) {
|
||||||
registrations.emplace(usertype_detail::make_string(std::forward<N>(n)), make_object(L, detail::tagged<T, constructor_list<Lists...>>{std::move(c)}));
|
object o(L, in_place<detail::tagged<T, constructor_list<Lists...>>>, std::move(c));
|
||||||
|
if (std::is_same<meta::unqualified_t<N>, call_construction>::value) {
|
||||||
|
callconstructfunc = std::move(o);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
registrations.emplace(usertype_detail::make_string(std::forward<N>(n)), std::move(o));
|
||||||
template <typename F>
|
|
||||||
void add(lua_State* L, call_construction, F&& f) {
|
|
||||||
callconstructfunc = make_object(L, std::forward<F>(f));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Bases>
|
template <typename... Bases>
|
||||||
|
|
|
@ -383,7 +383,7 @@ namespace sol {
|
||||||
T* obj = reinterpret_cast<T*>(pointerpointer + 1);
|
T* obj = reinterpret_cast<T*>(pointerpointer + 1);
|
||||||
referencepointer = obj;
|
referencepointer = obj;
|
||||||
|
|
||||||
auto& func = std::get<I>(f.set);
|
auto& func = std::get<I>(f.functions);
|
||||||
stack::call_into_lua<checked>(r, a, L, boost + start, func, detail::implicit_wrapper<T>(obj));
|
stack::call_into_lua<checked>(r, a, L, boost + start, func, detail::implicit_wrapper<T>(obj));
|
||||||
|
|
||||||
userdataref.push();
|
userdataref.push();
|
||||||
|
@ -436,7 +436,7 @@ namespace sol {
|
||||||
struct on_match {
|
struct on_match {
|
||||||
template <typename Fx, std::size_t I, typename... R, typename... Args>
|
template <typename Fx, std::size_t I, typename... R, typename... Args>
|
||||||
int operator()(types<Fx>, index_value<I>, types<R...>, types<Args...>, lua_State* L, int, int, F& fx) {
|
int operator()(types<Fx>, index_value<I>, types<R...>, types<Args...>, lua_State* L, int, int, F& fx) {
|
||||||
auto& f = std::get<I>(fx.set);
|
auto& f = std::get<I>(fx.functions);
|
||||||
return lua_call_wrapper<T, Fx, is_index, is_variable, checked, boost>{}.call(L, f);
|
return lua_call_wrapper<T, Fx, is_index, is_variable, checked, boost>{}.call(L, f);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -453,7 +453,7 @@ namespace sol {
|
||||||
struct on_match {
|
struct on_match {
|
||||||
template <typename Fx, std::size_t I, typename... R, typename... Args>
|
template <typename Fx, std::size_t I, typename... R, typename... Args>
|
||||||
int operator()(types<Fx>, index_value<I>, types<R...>, types<Args...>, lua_State* L, int, int, F& fx) {
|
int operator()(types<Fx>, index_value<I>, types<R...>, types<Args...>, lua_State* L, int, int, F& fx) {
|
||||||
auto& f = std::get<I>(fx.set);
|
auto& f = std::get<I>(fx.functions);
|
||||||
return lua_call_wrapper<T, Fx, is_index, is_variable, checked, boost>{}.call(L, f);
|
return lua_call_wrapper<T, Fx, is_index, is_variable, checked, boost>{}.call(L, f);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -531,7 +531,7 @@ namespace sol {
|
||||||
struct lua_call_wrapper<T, function_arguments<Sig, P>, is_index, is_variable, checked, boost, C> {
|
struct lua_call_wrapper<T, function_arguments<Sig, P>, is_index, is_variable, checked, boost, C> {
|
||||||
template <typename F>
|
template <typename F>
|
||||||
static int call(lua_State* L, F&& f) {
|
static int call(lua_State* L, F&& f) {
|
||||||
return lua_call_wrapper<T, meta::unqualified_t<P>, is_index, is_variable, stack::stack_detail::default_check_arguments, boost>{}.call(L, std::get<0>(f.params));
|
return lua_call_wrapper<T, meta::unqualified_t<P>, is_index, is_variable, stack::stack_detail::default_check_arguments, boost>{}.call(L, std::get<0>(f.arguments));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,7 @@ namespace sol {
|
||||||
struct pusher<function_arguments<T, Args...>> {
|
struct pusher<function_arguments<T, Args...>> {
|
||||||
template <std::size_t... I, typename FP>
|
template <std::size_t... I, typename FP>
|
||||||
static int push_func(std::index_sequence<I...>, lua_State* L, FP&& fp) {
|
static int push_func(std::index_sequence<I...>, lua_State* L, FP&& fp) {
|
||||||
return stack::push<T>(L, detail::forward_get<I>(fp.params)...);
|
return stack::push<T>(L, detail::forward_get<I>(fp.arguments)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int push(lua_State* L, const function_arguments<T, Args...>& fp) {
|
static int push(lua_State* L, const function_arguments<T, Args...>& fp) {
|
||||||
|
@ -220,13 +220,13 @@ namespace sol {
|
||||||
struct pusher<overload_set<Functions...>> {
|
struct pusher<overload_set<Functions...>> {
|
||||||
static int push(lua_State* L, overload_set<Functions...>&& set) {
|
static int push(lua_State* L, overload_set<Functions...>&& set) {
|
||||||
typedef function_detail::overloaded_function<Functions...> F;
|
typedef function_detail::overloaded_function<Functions...> F;
|
||||||
pusher<function_sig<>>{}.set_fx<F>(L, std::move(set.set));
|
pusher<function_sig<>>{}.set_fx<F>(L, std::move(set.functions));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int push(lua_State* L, const overload_set<Functions...>& set) {
|
static int push(lua_State* L, const overload_set<Functions...>& set) {
|
||||||
typedef function_detail::overloaded_function<Functions...> F;
|
typedef function_detail::overloaded_function<Functions...> F;
|
||||||
pusher<function_sig<>>{}.set_fx<F>(L, set.set);
|
pusher<function_sig<>>{}.set_fx<F>(L, set.functions);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -286,6 +286,21 @@ namespace sol {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename... Functions>
|
||||||
|
struct pusher<factory_wrapper<Functions...>> {
|
||||||
|
static int push(lua_State* L, const factory_wrapper<Functions...>& fw) {
|
||||||
|
typedef function_detail::overloaded_function<Functions...> F;
|
||||||
|
pusher<function_sig<>>{}.set_fx<F>(L, fw.functions);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int push(lua_State* L, factory_wrapper<Functions...>&& fw) {
|
||||||
|
typedef function_detail::overloaded_function<Functions...> F;
|
||||||
|
pusher<function_sig<>>{}.set_fx<F>(L, std::move(fw.functions));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T, typename... Lists>
|
template <typename T, typename... Lists>
|
||||||
struct pusher<detail::tagged<T, constructor_list<Lists...>>> {
|
struct pusher<detail::tagged<T, constructor_list<Lists...>>> {
|
||||||
static int push(lua_State* L, detail::tagged<T, constructor_list<Lists...>>) {
|
static int push(lua_State* L, detail::tagged<T, constructor_list<Lists...>>) {
|
||||||
|
@ -296,9 +311,10 @@ namespace sol {
|
||||||
|
|
||||||
template <typename T, typename... Fxs>
|
template <typename T, typename... Fxs>
|
||||||
struct pusher<detail::tagged<T, constructor_wrapper<Fxs...>>> {
|
struct pusher<detail::tagged<T, constructor_wrapper<Fxs...>>> {
|
||||||
static int push(lua_State* L, constructor_wrapper<Fxs...> c) {
|
template <typename C>
|
||||||
|
static int push(lua_State* L, C&& c) {
|
||||||
lua_CFunction cf = call_detail::call_user<T, false, false, constructor_wrapper<Fxs...>>;
|
lua_CFunction cf = call_detail::call_user<T, false, false, constructor_wrapper<Fxs...>>;
|
||||||
int closures = stack::push<user<T>>(L, std::move(c));
|
int closures = stack::push<user<constructor_wrapper<Fxs...>>>(L, std::forward<C>(c));
|
||||||
return stack::push(L, c_closure(cf, closures));
|
return stack::push(L, c_closure(cf, closures));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,9 +27,9 @@
|
||||||
namespace sol {
|
namespace sol {
|
||||||
template <typename... Functions>
|
template <typename... Functions>
|
||||||
struct overload_set {
|
struct overload_set {
|
||||||
std::tuple<Functions...> set;
|
std::tuple<Functions...> functions;
|
||||||
template <typename Arg, typename... Args, meta::disable<std::is_same<overload_set, meta::unqualified_t<Arg>>> = meta::enabler>
|
template <typename Arg, typename... Args, meta::disable<std::is_same<overload_set, meta::unqualified_t<Arg>>> = meta::enabler>
|
||||||
overload_set (Arg&& arg, Args&&... args) : set(std::forward<Arg>(arg), std::forward<Args>(args)...) {}
|
overload_set (Arg&& arg, Args&&... args) : functions(std::forward<Arg>(arg), std::forward<Args>(args)...) {}
|
||||||
overload_set(const overload_set&) = default;
|
overload_set(const overload_set&) = default;
|
||||||
overload_set(overload_set&&) = default;
|
overload_set(overload_set&&) = default;
|
||||||
overload_set& operator=(const overload_set&) = default;
|
overload_set& operator=(const overload_set&) = default;
|
||||||
|
|
18
sol/raii.hpp
18
sol/raii.hpp
|
@ -65,9 +65,11 @@ namespace sol {
|
||||||
return std::unique_ptr<T, Dx>(new T(std::forward<Args>(args)...));
|
return std::unique_ptr<T, Dx>(new T(std::forward<Args>(args)...));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename List>
|
template <typename Tag, typename T>
|
||||||
struct tagged {
|
struct tagged {
|
||||||
List l;
|
T value;
|
||||||
|
template <typename Arg, typename... Args, meta::disable<std::is_same<meta::unqualified_t<Arg>, tagged>> = meta::enabler>
|
||||||
|
tagged(Arg&& arg, Args&&... args) : value(std::forward<Arg>(arg), std::forward<Args>(args)...) {}
|
||||||
};
|
};
|
||||||
} // detail
|
} // detail
|
||||||
|
|
||||||
|
@ -87,9 +89,9 @@ namespace sol {
|
||||||
|
|
||||||
template <typename... Functions>
|
template <typename... Functions>
|
||||||
struct constructor_wrapper {
|
struct constructor_wrapper {
|
||||||
std::tuple<Functions...> set;
|
std::tuple<Functions...> functions;
|
||||||
template <typename... Args>
|
template <typename Arg, typename... Args, meta::disable<std::is_same<meta::unqualified_t<Arg>, constructor_wrapper>> = meta::enabler>
|
||||||
constructor_wrapper(Args&&... args) : set(std::forward<Args>(args)...) {}
|
constructor_wrapper(Arg&& arg, Args&&... args) : functions(std::forward<Arg>(arg), std::forward<Args>(args)...) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... Functions>
|
template <typename... Functions>
|
||||||
|
@ -99,9 +101,9 @@ namespace sol {
|
||||||
|
|
||||||
template <typename... Functions>
|
template <typename... Functions>
|
||||||
struct factory_wrapper {
|
struct factory_wrapper {
|
||||||
std::tuple<Functions...> set;
|
std::tuple<Functions...> functions;
|
||||||
template <typename... Args>
|
template <typename Arg, typename... Args, meta::disable<std::is_same<meta::unqualified_t<Arg>, factory_wrapper>> = meta::enabler>
|
||||||
factory_wrapper(Args&&... args) : set(std::forward<Args>(args)...) {}
|
factory_wrapper(Arg&& arg, Args&&... args) : functions(std::forward<Arg>(arg), std::forward<Args>(args)...) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... Functions>
|
template <typename... Functions>
|
||||||
|
|
|
@ -153,6 +153,10 @@ namespace sol {
|
||||||
|
|
||||||
template <typename N, typename F, meta::disable<meta::is_callable<meta::unwrap_unqualified_t<F>>> = meta::enabler>
|
template <typename N, typename F, meta::disable<meta::is_callable<meta::unwrap_unqualified_t<F>>> = meta::enabler>
|
||||||
void add_function(lua_State* L, N&& n, F&& f) {
|
void add_function(lua_State* L, N&& n, F&& f) {
|
||||||
|
if (std::is_same<meta::unqualified_t<N>, call_construction>::value) {
|
||||||
|
callconstructfunc = make_object(L, std::forward<F>(f));
|
||||||
|
return;
|
||||||
|
}
|
||||||
registrations.emplace(usertype_detail::make_string(std::forward<N>(n)), make_object(L, std::forward<F>(f)));
|
registrations.emplace(usertype_detail::make_string(std::forward<N>(n)), make_object(L, std::forward<F>(f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,17 +174,22 @@ namespace sol {
|
||||||
|
|
||||||
template <typename N, typename... Fxs>
|
template <typename N, typename... Fxs>
|
||||||
void add(lua_State* L, N&& n, constructor_wrapper<Fxs...> c) {
|
void add(lua_State* L, N&& n, constructor_wrapper<Fxs...> c) {
|
||||||
registrations.emplace(usertype_detail::make_string(std::forward<N>(n)), make_object(L, detail::tagged<T, constructor_wrapper<Fxs...>>{std::move(c)}));
|
object o(L, in_place<detail::tagged<T, constructor_wrapper<Fxs...>>>, std::move(c));
|
||||||
|
if (std::is_same<meta::unqualified_t<N>, call_construction>::value) {
|
||||||
|
callconstructfunc = std::move(o);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
registrations.emplace(usertype_detail::make_string(std::forward<N>(n)), std::move(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename N, typename... Lists>
|
template <typename N, typename... Lists>
|
||||||
void add(lua_State* L, N&& n, constructor_list<Lists...> c) {
|
void add(lua_State* L, N&& n, constructor_list<Lists...> c) {
|
||||||
registrations.emplace(usertype_detail::make_string(std::forward<N>(n)), make_object(L, detail::tagged<T, constructor_list<Lists...>>{std::move(c)}));
|
object o(L, in_place<detail::tagged<T, constructor_list<Lists...>>>, std::move(c));
|
||||||
|
if (std::is_same<meta::unqualified_t<N>, call_construction>::value) {
|
||||||
|
callconstructfunc = std::move(o);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
registrations.emplace(usertype_detail::make_string(std::forward<N>(n)), std::move(o));
|
||||||
template <typename F>
|
|
||||||
void add(lua_State* L, call_construction, F&& f) {
|
|
||||||
callconstructfunc = make_object(L, std::forward<F>(f));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Bases>
|
template <typename... Bases>
|
||||||
|
|
|
@ -261,18 +261,18 @@ namespace sol {
|
||||||
|
|
||||||
template <typename Sig, typename... Ps>
|
template <typename Sig, typename... Ps>
|
||||||
struct function_arguments {
|
struct function_arguments {
|
||||||
std::tuple<Ps...> params;
|
std::tuple<Ps...> arguments;
|
||||||
template <typename Arg, typename... Args, meta::disable<std::is_same<meta::unqualified_t<Arg>, function_arguments>> = meta::enabler>
|
template <typename Arg, typename... Args, meta::disable<std::is_same<meta::unqualified_t<Arg>, function_arguments>> = meta::enabler>
|
||||||
function_arguments(Arg&& arg, Args&&... args) : params(std::forward<Arg>(arg), std::forward<Args>(args)...) {}
|
function_arguments(Arg&& arg, Args&&... args) : arguments(std::forward<Arg>(arg), std::forward<Args>(args)...) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Sig = function_sig<>, typename... Args>
|
template <typename Sig = function_sig<>, typename... Args>
|
||||||
function_arguments<Sig, std::decay_t<Args>...> as_function(Args&&... args) {
|
auto as_function(Args&&... args) {
|
||||||
return function_arguments<Sig, std::decay_t<Args>...>(std::forward<Args>(args)...);
|
return function_arguments<Sig, std::decay_t<Args>...>(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Sig = function_sig<>, typename... Args>
|
template <typename Sig = function_sig<>, typename... Args>
|
||||||
function_arguments<Sig, Args...> as_function_reference(Args&&... args) {
|
auto as_function_reference(Args&&... args) {
|
||||||
return function_arguments<Sig, Args...>(std::forward<Args>(args)...);
|
return function_arguments<Sig, Args...>(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
TEST_CASE("usertypes/simple-usertypes", "Ensure that simple usertypes properly work here") {
|
TEST_CASE("usertype/simple-usertypes", "Ensure that simple usertypes properly work here") {
|
||||||
struct marker {
|
struct marker {
|
||||||
bool value = false;
|
bool value = false;
|
||||||
};
|
};
|
||||||
|
@ -87,7 +87,7 @@ TEST_CASE("usertypes/simple-usertypes", "Ensure that simple usertypes properly w
|
||||||
REQUIRE(z == 29);
|
REQUIRE(z == 29);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("usertypes/simple-usertypes-constructors", "Ensure that calls with specific arguments work") {
|
TEST_CASE("usertype/simple-usertypes-constructors", "Ensure that calls with specific arguments work") {
|
||||||
struct marker {
|
struct marker {
|
||||||
bool value = false;
|
bool value = false;
|
||||||
};
|
};
|
||||||
|
@ -211,7 +211,7 @@ TEST_CASE("usertype/simple-shared-ptr-regression", "simple usertype metatables s
|
||||||
REQUIRE(destroyed == 1);
|
REQUIRE(destroyed == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("usertypes/simple-vars", "simple usertype vars can bind various values (no ref)") {
|
TEST_CASE("usertype/simple-vars", "simple usertype vars can bind various values (no ref)") {
|
||||||
int muh_variable = 10;
|
int muh_variable = 10;
|
||||||
int through_variable = 25;
|
int through_variable = 25;
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ g2 = test.global2
|
||||||
REQUIRE(g2 == 25);
|
REQUIRE(g2 == 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("simple_usertypes/variable-control", "test to see if usertypes respond to inheritance and variable controls") {
|
TEST_CASE("usertypes/simple-variable-control", "test to see if usertypes respond to inheritance and variable controls") {
|
||||||
class A {
|
class A {
|
||||||
public:
|
public:
|
||||||
virtual void a() { throw std::runtime_error("entered base pure virtual implementation"); };
|
virtual void a() { throw std::runtime_error("entered base pure virtual implementation"); };
|
||||||
|
@ -311,3 +311,59 @@ TEST_CASE("simple_usertypes/variable-control", "test to see if usertypes respond
|
||||||
lua.script("print(sw.b)assert(sw.b == 25)");
|
lua.script("print(sw.b)assert(sw.b == 25)");
|
||||||
lua.script("print(sw.pb)assert(sw.pb == 27)");
|
lua.script("print(sw.pb)assert(sw.pb == 27)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("usertype/simple-factory-constructor-overload-usage", "simple usertypes should probably invoke types") {
|
||||||
|
class A {
|
||||||
|
public:
|
||||||
|
virtual void a() { throw std::runtime_error("entered base pure virtual implementation"); };
|
||||||
|
};
|
||||||
|
|
||||||
|
class B : public A {
|
||||||
|
public:
|
||||||
|
int bvar = 24;
|
||||||
|
virtual void a() override { }
|
||||||
|
void f() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
sol::state lua;
|
||||||
|
lua.open_libraries();
|
||||||
|
sol::constructors<sol::types<>, sol::types<const B&>> c;
|
||||||
|
lua.new_simple_usertype<B>("B",
|
||||||
|
sol::call_constructor, c,
|
||||||
|
"new", sol::factories([]() { return B(); }),
|
||||||
|
"new2", sol::initializers([](B& mem) { new(&mem)B(); }, [](B& mem, int v) { new(&mem)B(); mem.bvar = v; }),
|
||||||
|
"f", sol::as_function(&B::bvar),
|
||||||
|
"g", sol::overload([](B&) { return 2; }, [](B&, int v) { return v; })
|
||||||
|
);
|
||||||
|
|
||||||
|
lua.script("b = B()");
|
||||||
|
lua.script("b2 = B.new()");
|
||||||
|
lua.script("b3 = B.new2()");
|
||||||
|
lua.script("b4 = B.new2(11)");
|
||||||
|
|
||||||
|
lua.script("x = b:f()");
|
||||||
|
lua.script("x2 = b2:f()");
|
||||||
|
lua.script("x3 = b3:f()");
|
||||||
|
lua.script("x4 = b4:f()");
|
||||||
|
int x = lua["x"];
|
||||||
|
int x2 = lua["x2"];
|
||||||
|
int x3 = lua["x3"];
|
||||||
|
int x4 = lua["x4"];
|
||||||
|
REQUIRE(x == 24);
|
||||||
|
REQUIRE(x2 == 24);
|
||||||
|
REQUIRE(x3 == 24);
|
||||||
|
REQUIRE(x4 == 11);
|
||||||
|
|
||||||
|
lua.script("y = b:g()");
|
||||||
|
lua.script("y2 = b2:g(3)");
|
||||||
|
lua.script("y3 = b3:g()");
|
||||||
|
lua.script("y4 = b4:g(3)");
|
||||||
|
int y = lua["y"];
|
||||||
|
int y2 = lua["y2"];
|
||||||
|
int y3 = lua["y3"];
|
||||||
|
int y4 = lua["y4"];
|
||||||
|
REQUIRE(y == 2);
|
||||||
|
REQUIRE(y2 == 3);
|
||||||
|
REQUIRE(y3 == 2);
|
||||||
|
REQUIRE(y4 == 3);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user