forked from qt-creator/qt-creator
ExtensionSystem: Use variadic template and fold expression
Change-Id: Id5a5bc195029398a9ca2e813929234470caf4286 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -55,36 +55,11 @@ template <class Result>
|
|||||||
class Invoker : public InvokerBase
|
class Invoker : public InvokerBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Invoker(QObject *target, const char *slot)
|
template <typename ...Args>
|
||||||
{
|
Invoker(QObject *target, const char *slot, const Args &...args)
|
||||||
InvokerBase::invoke(target, slot);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T0>
|
|
||||||
Invoker(QObject *target, const char *slot, const T0 &t0)
|
|
||||||
{
|
{
|
||||||
setReturnValue(result);
|
setReturnValue(result);
|
||||||
addArgument(t0);
|
(addArgument(args), ...);
|
||||||
InvokerBase::invoke(target, slot);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T0, class T1>
|
|
||||||
Invoker(QObject *target, const char *slot, const T0 &t0, const T1 &t1)
|
|
||||||
{
|
|
||||||
setReturnValue(result);
|
|
||||||
addArgument(t0);
|
|
||||||
addArgument(t1);
|
|
||||||
InvokerBase::invoke(target, slot);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T0, class T1, class T2>
|
|
||||||
Invoker(QObject *target, const char *slot, const T0 &t0,
|
|
||||||
const T1 &t1, const T2 &t2)
|
|
||||||
{
|
|
||||||
setReturnValue(result);
|
|
||||||
addArgument(t0);
|
|
||||||
addArgument(t1);
|
|
||||||
addArgument(t2);
|
|
||||||
InvokerBase::invoke(target, slot);
|
InvokerBase::invoke(target, slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,33 +72,10 @@ private:
|
|||||||
template<> class Invoker<void> : public InvokerBase
|
template<> class Invoker<void> : public InvokerBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Invoker(QObject *target, const char *slot)
|
template <typename ...Args>
|
||||||
|
Invoker(QObject *target, const char *slot, const Args &...args)
|
||||||
{
|
{
|
||||||
InvokerBase::invoke(target, slot);
|
(addArgument(args), ...);
|
||||||
}
|
|
||||||
|
|
||||||
template <class T0>
|
|
||||||
Invoker(QObject *target, const char *slot, const T0 &t0)
|
|
||||||
{
|
|
||||||
addArgument(t0);
|
|
||||||
InvokerBase::invoke(target, slot);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T0, class T1>
|
|
||||||
Invoker(QObject *target, const char *slot, const T0 &t0, const T1 &t1)
|
|
||||||
{
|
|
||||||
addArgument(t0);
|
|
||||||
addArgument(t1);
|
|
||||||
InvokerBase::invoke(target, slot);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T0, class T1, class T2>
|
|
||||||
Invoker(QObject *target, const char *slot, const T0 &t0,
|
|
||||||
const T1 &t1, const T2 &t2)
|
|
||||||
{
|
|
||||||
addArgument(t0);
|
|
||||||
addArgument(t1);
|
|
||||||
addArgument(t2);
|
|
||||||
InvokerBase::invoke(target, slot);
|
InvokerBase::invoke(target, slot);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -145,38 +97,11 @@ inline void invokeHelper<void>(InvokerBase &in, QObject *target, const char *slo
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<class Result>
|
template<class Result, typename ...Args>
|
||||||
Result invoke(QObject *target, const char *slot)
|
Result invoke(QObject *target, const char *slot, const Args &...args)
|
||||||
{
|
{
|
||||||
InvokerBase in;
|
InvokerBase in;
|
||||||
return invokeHelper<Result>(in, target, slot);
|
(in.addArgument(args), ...);
|
||||||
}
|
|
||||||
|
|
||||||
template<class Result, class T0>
|
|
||||||
Result invoke(QObject *target, const char *slot, const T0 &t0)
|
|
||||||
{
|
|
||||||
InvokerBase in;
|
|
||||||
in.addArgument(t0);
|
|
||||||
return invokeHelper<Result>(in, target, slot);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Result, class T0, class T1>
|
|
||||||
Result invoke(QObject *target, const char *slot, const T0 &t0, const T1 &t1)
|
|
||||||
{
|
|
||||||
InvokerBase in;
|
|
||||||
in.addArgument(t0);
|
|
||||||
in.addArgument(t1);
|
|
||||||
return invokeHelper<Result>(in, target, slot);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Result, class T0, class T1, class T2>
|
|
||||||
Result invoke(QObject *target, const char *slot,
|
|
||||||
const T0 &t0, const T1 &t1, const T2 &t2)
|
|
||||||
{
|
|
||||||
InvokerBase in;
|
|
||||||
in.addArgument(t0);
|
|
||||||
in.addArgument(t1);
|
|
||||||
in.addArgument(t2);
|
|
||||||
return invokeHelper<Result>(in, target, slot);
|
return invokeHelper<Result>(in, target, slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user