mirror of
https://github.com/ThePhD/sol2.git
synced 2024-03-22 13:10:44 +08:00
Better names for the functors in preparation for working with whole classes of them. This is going to be tough...
This commit is contained in:
parent
b1504ad1b3
commit
63a4dafce5
|
@ -172,13 +172,13 @@ struct lua_func {
|
|||
};
|
||||
|
||||
template<typename TFx>
|
||||
struct lambda_lua_func : public lua_func {
|
||||
struct functor_lua_func : public lua_func {
|
||||
typedef decltype(&TFx::operator()) fx_t;
|
||||
typedef function_traits<fx_t> fx_traits;
|
||||
TFx fx;
|
||||
|
||||
template<typename... FxArgs>
|
||||
lambda_lua_func(FxArgs&&... fxargs): fx(std::forward<FxArgs>(fxargs)...) {}
|
||||
functor_lua_func(FxArgs&&... fxargs): fx(std::forward<FxArgs>(fxargs)...) {}
|
||||
|
||||
virtual int operator()(lua_State* L) override {
|
||||
return (*this)(tuple_types<typename fx_traits::return_type>(), typename fx_traits::args_type(), L);
|
||||
|
@ -205,13 +205,13 @@ struct lambda_lua_func : public lua_func {
|
|||
};
|
||||
|
||||
template<typename TFx, typename T = TFx, bool is_member_pointer = std::is_member_function_pointer<TFx>::value>
|
||||
struct explicit_lua_func : public lua_func {
|
||||
struct function_lua_func : public lua_func {
|
||||
typedef typename std::remove_pointer<typename std::decay<TFx>::type>::type fx_t;
|
||||
typedef function_traits<fx_t> fx_traits;
|
||||
TFx fx;
|
||||
|
||||
template<typename... FxArgs>
|
||||
explicit_lua_func(FxArgs&&... fxargs): fx(std::forward<FxArgs>(fxargs)...) {}
|
||||
function_lua_func(FxArgs&&... fxargs): fx(std::forward<FxArgs>(fxargs)...) {}
|
||||
|
||||
template<typename... Args>
|
||||
int operator()(types<void>, types<Args...> t, lua_State* L) {
|
||||
|
@ -238,7 +238,7 @@ struct explicit_lua_func : public lua_func {
|
|||
};
|
||||
|
||||
template<typename TFx, typename T>
|
||||
struct explicit_lua_func<TFx, T, true> : public lua_func {
|
||||
struct function_lua_func<TFx, T, true> : public lua_func {
|
||||
typedef typename std::remove_pointer<typename std::decay<TFx>::type>::type fx_t;
|
||||
typedef function_traits<fx_t> fx_traits;
|
||||
struct lambda {
|
||||
|
@ -255,7 +255,7 @@ struct explicit_lua_func<TFx, T, true> : public lua_func {
|
|||
} fx;
|
||||
|
||||
template<typename... FxArgs>
|
||||
explicit_lua_func(T m, FxArgs&&... fxargs): fx(std::move(m), std::forward<FxArgs>(fxargs)...) {}
|
||||
function_lua_func(T m, FxArgs&&... fxargs): fx(std::move(m), std::forward<FxArgs>(fxargs)...) {}
|
||||
|
||||
template<typename... Args>
|
||||
int operator()(types<void>, types<Args...> t, lua_State* L) {
|
||||
|
|
|
@ -153,7 +153,7 @@ private:
|
|||
template<typename T, typename TFx>
|
||||
table& set_isconvertible_fx(std::false_type, T&& key, TFx&& fx) {
|
||||
typedef typename std::remove_pointer<Decay<TFx>>::type clean_fx;
|
||||
std::unique_ptr<lua_func> sptr(new lambda_lua_func<clean_fx>(std::forward<TFx>(fx)));
|
||||
std::unique_ptr<lua_func> sptr(new functor_lua_func<clean_fx>(std::forward<TFx>(fx)));
|
||||
return set_fx(std::forward<T>(key), std::move(sptr));
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ private:
|
|||
template<typename T, typename TFx, typename TObj>
|
||||
table& set_lvalue_fx(std::false_type, T&& key, TFx&& fx, TObj&& obj) {
|
||||
typedef typename std::remove_pointer<Decay<TFx>>::type clean_fx;
|
||||
std::unique_ptr<lua_func> sptr(new explicit_lua_func<clean_fx, TObj>(std::forward<TObj>(obj), std::forward<TFx>(fx)));
|
||||
std::unique_ptr<lua_func> sptr(new function_lua_func<clean_fx, TObj>(std::forward<TObj>(obj), std::forward<TFx>(fx)));
|
||||
return set_fx(std::forward<T>(key), std::move(sptr));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user