multi_return<> name to return_type<> .

Makes more sense, as the return does not always have to be multiple types.
(Indeed, it is specialized for 1 and 0 cases).
This commit is contained in:
ThePhD 2014-05-08 13:08:21 -04:00
parent be839bdcd2
commit d7ea4718c8
6 changed files with 15 additions and 15 deletions

View File

@ -68,12 +68,12 @@ public:
}
template<typename... Ret, typename... Args>
typename multi_return<Ret...>::type operator()(types<Ret...>, Args&&... args) {
typename return_type<Ret...>::type operator()(types<Ret...>, Args&&... args) {
return call<Ret...>(std::forward<Args>(args)...);
}
template<typename... Ret, typename... Args>
typename multi_return<Ret...>::type call(Args&&... args) {
typename return_type<Ret...>::type call(Args&&... args) {
push();
stack::push_args(state(), std::forward<Args>(args)...);
return invoke(types<Ret...>(), sizeof...(Args));

View File

@ -45,7 +45,7 @@ struct static_function {
template<typename... Ret, typename... Args>
static int typed_call(types<Ret...>, types<Args...> t, function_type* fx, lua_State* L) {
typedef typename multi_return<Ret...>::type return_type;
typedef typename return_type<Ret...>::type return_type;
return_type r = stack::pop_call(L, fx, t);
stack::push(L, std::move(r));
return sizeof...(Ret);
@ -82,7 +82,7 @@ struct static_member_function {
template<typename... Ret, typename... Args>
static int typed_call(types<Ret...>, types<Args...>, T& item, function_type& ifx, lua_State* L) {
typedef typename multi_return<Ret...>::type return_type;
typedef typename return_type<Ret...>::type return_type;
auto fx = [&item, &ifx](Args&&... args) -> return_type { return (item.*ifx)(std::forward<Args>(args)...); };
return_type r = stack::pop_call(L, fx, types<Args...>());
stack::push(L, std::move(r));
@ -173,7 +173,7 @@ struct functor_function : public base_function {
template<typename... Ret, typename... Args>
int operator()(types<Ret...>, types<Args...> t, lua_State* L) {
typedef typename multi_return<Ret...>::type return_type;
typedef typename return_type<Ret...>::type return_type;
return_type r = stack::pop_call(L, fx, t);
stack::push(L, r);
return sizeof...(Ret);
@ -217,7 +217,7 @@ struct member_function : public base_function {
template<typename... Ret, typename... Args>
int operator()(types<Ret...>, types<Args...> t, lua_State* L) {
typedef typename multi_return<Ret...>::type return_type;
typedef typename return_type<Ret...>::type return_type;
return_type r = stack::pop_call(L, fx, t);
stack::push(L, std::move(r));
return sizeof...(Ret);
@ -269,7 +269,7 @@ struct userdata_function : public base_function {
template<typename... Ret, typename... Args>
int operator()(types<Ret...>, types<Args...> t, lua_State* L) {
typedef typename multi_return<Ret...>::type return_type;
typedef typename return_type<Ret...>::type return_type;
return_type r = stack::pop_call(L, fx, t);
stack::push(L, std::move(r));
return sizeof...(Ret);

View File

@ -101,7 +101,7 @@ public:
}
template<typename... Ret, typename... Args>
typename multi_return<Ret...>::type call(Args&&... args) {
typename return_type<Ret...>::type call(Args&&... args) {
return tbl.get<function>(key)(types<Ret...>(), std::forward<Args>(args)...);
}
};

View File

@ -129,7 +129,7 @@ public:
}
template<typename... Args, typename... Keys>
typename multi_return<Args...>::type get(Keys&&... keys) const {
typename return_type<Args...>::type get(Keys&&... keys) const {
return global.get(types<Args...>(), std::forward<Keys>(keys)...);
}

View File

@ -66,7 +66,7 @@ class table : public reference {
}
template<typename Tup, typename... Ret, std::size_t... I>
typename multi_return<Ret...>::type tuple_get(types<Ret...> t, indices<I...>, Tup&& tup) const {
typename return_type<Ret...>::type tuple_get(types<Ret...> t, indices<I...>, Tup&& tup) const {
return std::make_tuple(element_get<I>(t, std::forward<Tup>(tup))...);
}
@ -76,7 +76,7 @@ class table : public reference {
}
template<typename... Ret, typename... Keys>
typename multi_return<Ret...>::type get(types<Ret...> t, Keys&&... keys) const {
typename return_type<Ret...>::type get(types<Ret...> t, Keys&&... keys) const {
static_assert(sizeof...(Keys) == sizeof...(Ret), "Must have same number of keys as return values");
return tuple_get(t, t, std::make_tuple(std::forward<Keys>(keys)...));
}
@ -87,7 +87,7 @@ public:
}
template<typename... Ret, typename... Keys>
typename multi_return<Ret...>::type get(Keys&&... keys) const {
typename return_type<Ret...>::type get(Keys&&... keys) const {
return get(types<Ret...>(), std::forward<Keys>(keys)...);
}

View File

@ -39,17 +39,17 @@ template<typename T>
using Decay = typename std::decay<T>::type;
template<typename... Args>
struct multi_return {
struct return_type {
typedef std::tuple<Args...> type;
};
template<typename T>
struct multi_return<T> {
struct return_type<T> {
typedef T type;
};
template<>
struct multi_return<> : types<>{
struct return_type<> : types<>{
typedef void type;
};