|
|
@ -12,14 +12,6 @@ |
|
|
|
namespace QtMvvm { |
|
|
|
namespace __helpertypes { |
|
|
|
|
|
|
|
#if __cplusplus >= 201703L |
|
|
|
template<typename... T> |
|
|
|
using conjunction = std::conjunction<T...>; |
|
|
|
#else |
|
|
|
template<typename... T> |
|
|
|
using conjunction = std::__and_<T...>; |
|
|
|
#endif |
|
|
|
|
|
|
|
static const QByteArray InjectablePrefix = QByteArrayLiteral("de.skycoder42.qtmvvm.injectable."); |
|
|
|
|
|
|
|
template <typename T> |
|
|
@ -29,7 +21,7 @@ template <typename T> |
|
|
|
struct is_qobj_ptr : public is_qobj<std::remove_pointer_t<T>> {}; |
|
|
|
|
|
|
|
template <typename TInterface, typename TService> |
|
|
|
struct is_valid_interface : public conjunction<std::is_base_of<TInterface, TService>, is_qobj<TService>> {}; |
|
|
|
struct is_valid_interface : public std::integral_constant<bool, std::is_base_of<TInterface, TService>::value && is_qobj<TService>::value> {}; |
|
|
|
|
|
|
|
template <typename TInjectPtr> |
|
|
|
inline QByteArray qobject_iid(std::enable_if_t<is_qobj_ptr<TInjectPtr>::value, void*> = nullptr) { |
|
|
@ -52,7 +44,7 @@ inline QByteArray inject_iid() { |
|
|
|
} |
|
|
|
|
|
|
|
template <typename TFunc, typename T1, typename... TArgs> |
|
|
|
inline Q_CONSTEXPR std::function<QObject*(QObjectList)> pack_function_imp(const TFunc &fn, QByteArrayList &injectables) { |
|
|
|
inline std::function<QObject*(QObjectList)> pack_function_imp(const TFunc &fn, QByteArrayList &injectables) { |
|
|
|
injectables.append(inject_iid<T1>()); |
|
|
|
auto subFn = [fn](const QObjectList ¶ms, int index, TArgs... tArgs) { |
|
|
|
--index; |
|
|
@ -62,7 +54,7 @@ inline Q_CONSTEXPR std::function<QObject*(QObjectList)> pack_function_imp(const |
|
|
|
} |
|
|
|
|
|
|
|
template <typename TFunc> |
|
|
|
inline Q_CONSTEXPR std::function<QObject*(QObjectList)> pack_function_imp(const TFunc &fn, QByteArrayList &injectables) { |
|
|
|
inline std::function<QObject*(QObjectList)> pack_function_imp(const TFunc &fn, QByteArrayList &injectables) { |
|
|
|
Q_UNUSED(injectables) |
|
|
|
return [fn](const QObjectList ¶ms) { |
|
|
|
return fn(params, params.size()); |
|
|
@ -76,7 +68,7 @@ template <typename TClass, typename TRet, typename... TArgs> |
|
|
|
struct fn_info<TRet(TClass::*)(TArgs...) const> |
|
|
|
{ |
|
|
|
template <typename TFunctor> |
|
|
|
static inline Q_CONSTEXPR std::function<QObject*(QObjectList)> pack(const TFunctor &fn, QByteArrayList &injectables) { |
|
|
|
static inline std::function<QObject*(QObjectList)> pack(const TFunctor &fn, QByteArrayList &injectables) { |
|
|
|
auto subFn = [fn](const QObjectList ¶ms, int index, TArgs... args) -> QObject* { |
|
|
|
Q_UNUSED(params) |
|
|
|
Q_ASSERT_X(index == 0, Q_FUNC_INFO, "number of params does not equal recursion depth"); |
|
|
@ -87,7 +79,7 @@ struct fn_info<TRet(TClass::*)(TArgs...) const> |
|
|
|
}; |
|
|
|
|
|
|
|
template <typename TFunc> |
|
|
|
inline Q_CONSTEXPR std::function<QObject*(QObjectList)> pack_function(const TFunc &fn, QByteArrayList &injectables) { |
|
|
|
inline std::function<QObject*(QObjectList)> pack_function(const TFunc &fn, QByteArrayList &injectables) { |
|
|
|
return fn_info<TFunc>::pack(fn, injectables); |
|
|
|
} |
|
|
|
|
|
|
|