|
@ -52,19 +52,19 @@ inline QByteArray inject_iid() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
template <typename TFunc, typename T1, typename... TArgs> |
|
|
template <typename TFunc, typename T1, typename... TArgs> |
|
|
inline Q_CONSTEXPR std::function<QObject*(QVariantList)> pack_function_imp(const TFunc &fn, QByteArrayList &injectables) { |
|
|
inline Q_CONSTEXPR std::function<QObject*(QObjectList)> pack_function_imp(const TFunc &fn, QByteArrayList &injectables) { |
|
|
injectables.append(inject_iid<T1>()); |
|
|
injectables.append(inject_iid<T1>()); |
|
|
auto subFn = [fn](const QVariantList ¶ms, int index, TArgs... tArgs) { |
|
|
auto subFn = [fn](const QObjectList ¶ms, int index, TArgs... tArgs) { |
|
|
--index; |
|
|
--index; |
|
|
return fn(params, index, params[index].template value<T1>(), tArgs...); |
|
|
return fn(params, index, qobject_cast<T1>(params[index]), tArgs...); |
|
|
}; |
|
|
}; |
|
|
return pack_function_imp<decltype(subFn), TArgs...>(subFn, injectables); |
|
|
return pack_function_imp<decltype(subFn), TArgs...>(subFn, injectables); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
template <typename TFunc> |
|
|
template <typename TFunc> |
|
|
inline Q_CONSTEXPR std::function<QObject*(QVariantList)> pack_function_imp(const TFunc &fn, QByteArrayList &injectables) { |
|
|
inline Q_CONSTEXPR std::function<QObject*(QObjectList)> pack_function_imp(const TFunc &fn, QByteArrayList &injectables) { |
|
|
Q_UNUSED(injectables) |
|
|
Q_UNUSED(injectables) |
|
|
return [fn](const QVariantList ¶ms) { |
|
|
return [fn](const QObjectList ¶ms) { |
|
|
return fn(params, params.size()); |
|
|
return fn(params, params.size()); |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
@ -76,8 +76,8 @@ template <typename TClass, typename TRet, typename... TArgs> |
|
|
struct fn_info<TRet(TClass::*)(TArgs...) const> |
|
|
struct fn_info<TRet(TClass::*)(TArgs...) const> |
|
|
{ |
|
|
{ |
|
|
template <typename TFunctor> |
|
|
template <typename TFunctor> |
|
|
static inline Q_CONSTEXPR std::function<QObject*(QVariantList)> pack(const TFunctor &fn, QByteArrayList &injectables) { |
|
|
static inline Q_CONSTEXPR std::function<QObject*(QObjectList)> pack(const TFunctor &fn, QByteArrayList &injectables) { |
|
|
auto subFn = [fn](const QVariantList ¶ms, int index, TArgs... args) -> QObject* { |
|
|
auto subFn = [fn](const QObjectList ¶ms, int index, TArgs... args) -> QObject* { |
|
|
Q_UNUSED(params) |
|
|
Q_UNUSED(params) |
|
|
Q_ASSERT_X(index == 0, Q_FUNC_INFO, "number of params does not equal recursion depth"); |
|
|
Q_ASSERT_X(index == 0, Q_FUNC_INFO, "number of params does not equal recursion depth"); |
|
|
return fn(args...); |
|
|
return fn(args...); |
|
@ -87,7 +87,7 @@ struct fn_info<TRet(TClass::*)(TArgs...) const> |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
template <typename TFunc> |
|
|
template <typename TFunc> |
|
|
inline Q_CONSTEXPR std::function<QObject*(QVariantList)> pack_function(const TFunc &fn, QByteArrayList &injectables) { |
|
|
inline Q_CONSTEXPR std::function<QObject*(QObjectList)> pack_function(const TFunc &fn, QByteArrayList &injectables) { |
|
|
return fn_info<TFunc>::pack(fn, injectables); |
|
|
return fn_info<TFunc>::pack(fn, injectables); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|