Remove the code for QObject::connect for non-C++11 compilers
It's required now in Qt 5.7 (at least the required features of rvalue references and variadic templates) Change-Id: I87e17314d8b24ae983b1fffd145364c52f9bb6c3 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>bb10
parent
84bd6a83a0
commit
7b8a553a13
|
|
@ -299,7 +299,6 @@ public:
|
|||
connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot,
|
||||
Qt::ConnectionType type = Qt::AutoConnection)
|
||||
{
|
||||
#if defined (Q_COMPILER_VARIADIC_TEMPLATES)
|
||||
typedef QtPrivate::FunctionPointer<Func1> SignalType;
|
||||
const int FunctorArgumentCount = QtPrivate::ComputeFunctorArgumentCount<Func2 , typename SignalType::Arguments>::Value;
|
||||
|
||||
|
|
@ -307,28 +306,6 @@ public:
|
|||
"Signal and slot arguments are not compatible.");
|
||||
const int SlotArgumentCount = (FunctorArgumentCount >= 0) ? FunctorArgumentCount : 0;
|
||||
typedef typename QtPrivate::FunctorReturnType<Func2, typename QtPrivate::List_Left<typename SignalType::Arguments, SlotArgumentCount>::Value>::Value SlotReturnType;
|
||||
#else
|
||||
// Without variadic template, we don't detect the best overload of operator(). We just
|
||||
// assume there is only one simple operator() and connect to &Func2::operator()
|
||||
|
||||
/* If you get an error such as:
|
||||
couldn't deduce template parameter 'Func2Operator'
|
||||
or
|
||||
cannot resolve address of overloaded function
|
||||
It means the functor does not have a single operator().
|
||||
Functors with overloaded or templated operator() are only supported if the compiler supports
|
||||
C++11 variadic templates
|
||||
*/
|
||||
typedef QtPrivate::FunctionPointer<decltype(&Func2::operator())> SlotType ;
|
||||
typedef QtPrivate::FunctionPointer<Func1> SignalType;
|
||||
typedef typename SlotType::ReturnType SlotReturnType;
|
||||
const int SlotArgumentCount = SlotType::ArgumentCount;
|
||||
|
||||
Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= SlotArgumentCount,
|
||||
"The slot requires more arguments than the signal provides.");
|
||||
Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
|
||||
"Signal and slot arguments are not compatible.");
|
||||
#endif
|
||||
|
||||
Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<SlotReturnType, typename SignalType::ReturnType>::value),
|
||||
"Return type of the slot is not compatible with the return type of the signal.");
|
||||
|
|
|
|||
|
|
@ -62,34 +62,6 @@ namespace QtPrivate {
|
|||
If one of the type is not declared, the function return 0 and the signal
|
||||
cannot be used in queued connection.
|
||||
*/
|
||||
#ifndef Q_COMPILER_VARIADIC_TEMPLATES
|
||||
template <typename ArgList> struct TypesAreDeclaredMetaType { enum { Value = false }; };
|
||||
template <> struct TypesAreDeclaredMetaType<void> { enum { Value = true }; };
|
||||
template <typename Arg, typename Tail> struct TypesAreDeclaredMetaType<List<Arg, Tail> > { enum { Value = QMetaTypeId2<Arg>::Defined && TypesAreDeclaredMetaType<Tail>::Value }; };
|
||||
|
||||
template <typename ArgList, bool Declared = TypesAreDeclaredMetaType<ArgList>::Value > struct ConnectionTypes
|
||||
{ static const int *types() { return 0; } };
|
||||
template <> struct ConnectionTypes<void, true>
|
||||
{ static const int *types() { static const int t[1] = { 0 }; return t; } };
|
||||
template <typename Arg1> struct ConnectionTypes<List<Arg1, void>, true>
|
||||
{ static const int *types() { static const int t[2] = { QtPrivate::QMetaTypeIdHelper<Arg1>::qt_metatype_id(), 0 }; return t; } };
|
||||
template <typename Arg1, typename Arg2> struct ConnectionTypes<List<Arg1, List<Arg2, void> >, true>
|
||||
{ static const int *types() { static const int t[3] = { QtPrivate::QMetaTypeIdHelper<Arg1>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg2>::qt_metatype_id(), 0 }; return t; } };
|
||||
template <typename Arg1, typename Arg2, typename Arg3> struct ConnectionTypes<List<Arg1, List<Arg2, List<Arg3, void> > >, true>
|
||||
{ static const int *types() { static const int t[4] = { QtPrivate::QMetaTypeIdHelper<Arg1>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg2>::qt_metatype_id(),
|
||||
QtPrivate::QMetaTypeIdHelper<Arg3>::qt_metatype_id(), 0 }; return t; } };
|
||||
template <typename Arg1, typename Arg2, typename Arg3, typename Arg4> struct ConnectionTypes<List<Arg1, List<Arg2, List<Arg3, List<Arg4, void> > > >, true>
|
||||
{ static const int *types() { static const int t[5] = { QtPrivate::QMetaTypeIdHelper<Arg1>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg2>::qt_metatype_id(),
|
||||
QtPrivate::QMetaTypeIdHelper<Arg3>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg4>::qt_metatype_id(), 0 }; return t; } };
|
||||
template <typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> struct ConnectionTypes<List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, void> > > > >, true>
|
||||
{ static const int *types() { static const int t[6] = { QtPrivate::QMetaTypeIdHelper<Arg1>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg2>::qt_metatype_id(),
|
||||
QtPrivate::QMetaTypeIdHelper<Arg3>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg4>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg5>::qt_metatype_id(), 0 }; return t; } };
|
||||
template <typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5, typename Arg6>
|
||||
struct ConnectionTypes<List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, List<Arg6, void> > > > > >, true>
|
||||
{ static const int *types() { static const int t[7] = { QtPrivate::QMetaTypeIdHelper<Arg1>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg2>::qt_metatype_id(),
|
||||
QtPrivate::QMetaTypeIdHelper<Arg3>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg4>::qt_metatype_id(), QtPrivate::QMetaTypeIdHelper<Arg5>::qt_metatype_id(),
|
||||
QtPrivate::QMetaTypeIdHelper<Arg6>::qt_metatype_id(), 0 }; return t; } };
|
||||
#else
|
||||
template <typename ArgList> struct TypesAreDeclaredMetaType { enum { Value = false }; };
|
||||
template <> struct TypesAreDeclaredMetaType<List<>> { enum { Value = true }; };
|
||||
template <typename Arg, typename... Tail> struct TypesAreDeclaredMetaType<List<Arg, Tail...> >
|
||||
|
|
@ -101,7 +73,6 @@ namespace QtPrivate {
|
|||
{ static const int *types() { return Q_NULLPTR; } };
|
||||
template <typename... Args> struct ConnectionTypes<List<Args...>, true>
|
||||
{ static const int *types() { static const int t[sizeof...(Args) + 1] = { (QtPrivate::QMetaTypeIdHelper<Args>::qt_metatype_id())..., 0 }; return t; } };
|
||||
#endif
|
||||
|
||||
// internal base class (interface) containing functions required to call a slot managed by a pointer to function.
|
||||
class QSlotObjectBase {
|
||||
|
|
|
|||
|
|
@ -65,11 +65,6 @@ namespace QtPrivate {
|
|||
List_Left<L,N> take a list and a number as a parameter and returns (via the Value typedef,
|
||||
the list composed of the first N element of the list
|
||||
*/
|
||||
#ifndef Q_COMPILER_VARIADIC_TEMPLATES
|
||||
template <typename Head, typename Tail> struct List { typedef Head Car; typedef Tail Cdr; };
|
||||
template <typename L, int N> struct List_Left { typedef List<typename L::Car, typename List_Left<typename L::Cdr, N - 1>::Value > Value; };
|
||||
template <typename L> struct List_Left<L,0> { typedef void Value; };
|
||||
#else
|
||||
// With variadic template, lists are represented using a variadic template argument instead of the lisp way
|
||||
template <typename...> struct List {};
|
||||
template <typename Head, typename... Tail> struct List<Head, Tail...> { typedef Head Car; typedef List<Tail...> Cdr; };
|
||||
|
|
@ -79,7 +74,6 @@ namespace QtPrivate {
|
|||
typedef typename List_Append<List<typename L::Car>,typename List_Left<typename L::Cdr, N - 1>::Value>::Value Value;
|
||||
};
|
||||
template <typename L> struct List_Left<L, 0> { typedef List<> Value; };
|
||||
#endif
|
||||
// List_Select<L,N> returns (via typedef Value) the Nth element of the list L
|
||||
template <typename L, int N> struct List_Select { typedef typename List_Select<typename L::Cdr, N - 1>::Value Value; };
|
||||
template <typename L> struct List_Select<L,0> { typedef typename L::Car Value; };
|
||||
|
|
@ -100,13 +94,11 @@ namespace QtPrivate {
|
|||
if (container.data)
|
||||
*reinterpret_cast<U*>(container.data) = value;
|
||||
}
|
||||
#ifdef Q_COMPILER_RVALUE_REFS
|
||||
template<typename T, typename U>
|
||||
void operator,(T &&value, const ApplyReturnValue<U> &container) {
|
||||
if (container.data)
|
||||
*reinterpret_cast<U*>(container.data) = value;
|
||||
}
|
||||
#endif
|
||||
template<typename T>
|
||||
void operator,(T, const ApplyReturnValue<void> &) {}
|
||||
|
||||
|
|
@ -127,364 +119,6 @@ namespace QtPrivate {
|
|||
The Functor<Func,N> struct is the helper to call a functor of N argument.
|
||||
its call function is the same as the FunctionPointer::call function.
|
||||
*/
|
||||
#ifndef Q_COMPILER_VARIADIC_TEMPLATES
|
||||
template<typename Func> struct FunctionPointer { enum {ArgumentCount = -1, IsPointerToMemberFunction = false}; };
|
||||
//Pointers to member functions
|
||||
template<class Obj, typename Ret> struct FunctionPointer<Ret (Obj::*) ()>
|
||||
{
|
||||
typedef Obj Object;
|
||||
typedef void Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (Obj::*Function) ();
|
||||
enum {ArgumentCount = 0, IsPointerToMemberFunction = true};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, Obj *o, void **arg) { (o->*f)(), ApplyReturnValue<R>(arg[0]); }
|
||||
};
|
||||
template<class Obj, typename Ret, typename Arg1> struct FunctionPointer<Ret (Obj::*) (Arg1)>
|
||||
{
|
||||
typedef Obj Object;
|
||||
typedef List<Arg1, void> Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (Obj::*Function) (Arg1);
|
||||
enum {ArgumentCount = 1, IsPointerToMemberFunction = true};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, Obj *o, void **arg) {
|
||||
(o->*f)((*reinterpret_cast<typename RemoveRef<typename Args::Car>::Type *>(arg[1]))), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
template<class Obj, typename Ret, typename Arg1, typename Arg2> struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2)>
|
||||
{
|
||||
typedef Obj Object;
|
||||
typedef List<Arg1, List<Arg2, void> > Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (Obj::*Function) (Arg1, Arg2);
|
||||
enum {ArgumentCount = 2, IsPointerToMemberFunction = true};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, Obj *o, void **arg) {
|
||||
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
template<class Obj, typename Ret, typename Arg1, typename Arg2, typename Arg3> struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2, Arg3)>
|
||||
{
|
||||
typedef Obj Object;
|
||||
typedef List<Arg1, List<Arg2, List<Arg3, void> > > Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3);
|
||||
enum {ArgumentCount = 3, IsPointerToMemberFunction = true};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, Obj *o, void **arg) {
|
||||
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
template<class Obj, typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4> struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2, Arg3, Arg4)>
|
||||
{
|
||||
typedef Obj Object;
|
||||
typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, void> > > > Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3, Arg4);
|
||||
enum {ArgumentCount = 4, IsPointerToMemberFunction = true};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, Obj *o, void **arg) {
|
||||
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
template<class Obj, typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2, Arg3, Arg4, Arg5)>
|
||||
{
|
||||
typedef Obj Object;
|
||||
typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, void> > > > > Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3, Arg4, Arg5);
|
||||
enum {ArgumentCount = 5, IsPointerToMemberFunction = true};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, Obj *o, void **arg) {
|
||||
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
template<class Obj, typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5, typename Arg6>
|
||||
struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)>
|
||||
{
|
||||
typedef Obj Object;
|
||||
typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, List<Arg6, void> > > > > > Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6);
|
||||
enum {ArgumentCount = 6, IsPointerToMemberFunction = true};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, Obj *o, void **arg) {
|
||||
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 5>::Value>::Type *>(arg[6])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
|
||||
//Pointers to const member functions
|
||||
template<class Obj, typename Ret> struct FunctionPointer<Ret (Obj::*) () const>
|
||||
{
|
||||
typedef Obj Object;
|
||||
typedef void Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (Obj::*Function) () const;
|
||||
enum {ArgumentCount = 0, IsPointerToMemberFunction = true};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, Obj *o, void **arg) { (o->*f)(), ApplyReturnValue<R>(arg[0]); }
|
||||
};
|
||||
template<class Obj, typename Ret, typename Arg1> struct FunctionPointer<Ret (Obj::*) (Arg1) const>
|
||||
{
|
||||
typedef Obj Object;
|
||||
typedef List<Arg1, void> Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (Obj::*Function) (Arg1) const;
|
||||
enum {ArgumentCount = 1, IsPointerToMemberFunction = true};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, Obj *o, void **arg) {
|
||||
(o->*f)((*reinterpret_cast<typename RemoveRef<typename Args::Car>::Type *>(arg[1]))), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
template<class Obj, typename Ret, typename Arg1, typename Arg2> struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2) const>
|
||||
{
|
||||
typedef Obj Object;
|
||||
typedef List<Arg1, List<Arg2, void> > Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (Obj::*Function) (Arg1, Arg2) const;
|
||||
enum {ArgumentCount = 2, IsPointerToMemberFunction = true};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, Obj *o, void **arg) {
|
||||
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
template<class Obj, typename Ret, typename Arg1, typename Arg2, typename Arg3> struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2, Arg3) const>
|
||||
{
|
||||
typedef Obj Object;
|
||||
typedef List<Arg1, List<Arg2, List<Arg3, void> > > Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3) const;
|
||||
enum {ArgumentCount = 3, IsPointerToMemberFunction = true};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, Obj *o, void **arg) {
|
||||
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
template<class Obj, typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4> struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2, Arg3, Arg4) const>
|
||||
{
|
||||
typedef Obj Object;
|
||||
typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, void> > > > Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3, Arg4) const;
|
||||
enum {ArgumentCount = 4, IsPointerToMemberFunction = true};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, Obj *o, void **arg) {
|
||||
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
template<class Obj, typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2, Arg3, Arg4, Arg5) const>
|
||||
{
|
||||
typedef Obj Object;
|
||||
typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, void> > > > > Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3, Arg4, Arg5) const;
|
||||
enum {ArgumentCount = 5, IsPointerToMemberFunction = true};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, Obj *o, void **arg) {
|
||||
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
template<class Obj, typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5, typename Arg6>
|
||||
struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) const>
|
||||
{
|
||||
typedef Obj Object;
|
||||
typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, List<Arg6, void> > > > > > Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) const;
|
||||
enum {ArgumentCount = 6, IsPointerToMemberFunction = true};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, Obj *o, void **arg) {
|
||||
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 5>::Value>::Type *>(arg[6])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
|
||||
//Static functions
|
||||
template<typename Ret> struct FunctionPointer<Ret (*) ()>
|
||||
{
|
||||
typedef void Arguments;
|
||||
typedef Ret (*Function) ();
|
||||
typedef Ret ReturnType;
|
||||
enum {ArgumentCount = 0, IsPointerToMemberFunction = false};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, void *, void **arg) { f(), ApplyReturnValue<R>(arg[0]); }
|
||||
};
|
||||
template<typename Ret, typename Arg1> struct FunctionPointer<Ret (*) (Arg1)>
|
||||
{
|
||||
typedef List<Arg1, void> Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (*Function) (Arg1);
|
||||
enum {ArgumentCount = 1, IsPointerToMemberFunction = false};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, void *, void **arg)
|
||||
{ f(*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1])), ApplyReturnValue<R>(arg[0]); }
|
||||
};
|
||||
template<typename Ret, typename Arg1, typename Arg2> struct FunctionPointer<Ret (*) (Arg1, Arg2)>
|
||||
{
|
||||
typedef List<Arg1, List<Arg2, void> > Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (*Function) (Arg1, Arg2);
|
||||
enum {ArgumentCount = 2, IsPointerToMemberFunction = false};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, void *, void **arg) {
|
||||
f(*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2])), ApplyReturnValue<R>(arg[0]); }
|
||||
};
|
||||
template<typename Ret, typename Arg1, typename Arg2, typename Arg3> struct FunctionPointer<Ret (*) (Arg1, Arg2, Arg3)>
|
||||
{
|
||||
typedef List<Arg1, List<Arg2, List<Arg3, void> > > Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (*Function) (Arg1, Arg2, Arg3);
|
||||
enum {ArgumentCount = 3, IsPointerToMemberFunction = false};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, void *, void **arg) {
|
||||
f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
template<typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4> struct FunctionPointer<Ret (*) (Arg1, Arg2, Arg3, Arg4)>
|
||||
{
|
||||
typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, void> > > > Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (*Function) (Arg1, Arg2, Arg3, Arg4);
|
||||
enum {ArgumentCount = 4, IsPointerToMemberFunction = false};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, void *, void **arg) {
|
||||
f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
template<typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5> struct FunctionPointer<Ret (*) (Arg1, Arg2, Arg3, Arg4, Arg5)>
|
||||
{
|
||||
typedef List<Arg1, List<Arg2, List<Arg3,
|
||||
List<Arg4, List<Arg5, void > > > > > Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (*Function) (Arg1, Arg2, Arg3, Arg4, Arg5);
|
||||
enum {ArgumentCount = 5, IsPointerToMemberFunction = false};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, void *, void **arg) {
|
||||
f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
template<typename Ret, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5, typename Arg6> struct FunctionPointer<Ret (*) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)>
|
||||
{
|
||||
typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, List<Arg6, void> > > > > > Arguments;
|
||||
typedef Ret ReturnType;
|
||||
typedef Ret (*Function) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6);
|
||||
enum {ArgumentCount = 6, IsPointerToMemberFunction = false};
|
||||
template <typename Args, typename R>
|
||||
static void call(Function f, void *, void **arg) {
|
||||
f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 5>::Value>::Type *>(arg[6])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
|
||||
//Functors
|
||||
template<typename F, int N> struct Functor;
|
||||
template<typename Function> struct Functor<Function, 0>
|
||||
{
|
||||
template <typename Args, typename R>
|
||||
static void call(Function &f, void *, void **arg) { f(), ApplyReturnValue<R>(arg[0]); }
|
||||
};
|
||||
template<typename Function> struct Functor<Function, 1>
|
||||
{
|
||||
template <typename Args, typename R>
|
||||
static void call(Function &f, void *, void **arg) {
|
||||
f(*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
template<typename Function> struct Functor<Function, 2>
|
||||
{
|
||||
template <typename Args, typename R>
|
||||
static void call(Function &f, void *, void **arg) {
|
||||
f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
template<typename Function> struct Functor<Function, 3>
|
||||
{
|
||||
template <typename Args, typename R>
|
||||
static void call(Function &f, void *, void **arg) {
|
||||
f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
template<typename Function> struct Functor<Function, 4>
|
||||
{
|
||||
template <typename Args, typename R>
|
||||
static void call(Function &f, void *, void **arg) {
|
||||
f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
template<typename Function> struct Functor<Function, 5>
|
||||
{
|
||||
template <typename Args, typename R>
|
||||
static void call(Function &f, void *, void **arg) {
|
||||
f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
template<typename Function> struct Functor<Function, 6>
|
||||
{
|
||||
template <typename Args, typename R>
|
||||
static void call(Function &f, void *, void **arg) {
|
||||
f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 1>::Value>::Type *>(arg[2]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 2>::Value>::Type *>(arg[3]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 3>::Value>::Type *>(arg[4]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 4>::Value>::Type *>(arg[5]),
|
||||
*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 5>::Value>::Type *>(arg[6])), ApplyReturnValue<R>(arg[0]);
|
||||
}
|
||||
};
|
||||
#else
|
||||
template <int...> struct IndexesList {};
|
||||
template <typename IndexList, int Right> struct IndexesAppend;
|
||||
template <int... Left, int Right> struct IndexesAppend<IndexesList<Left...>, Right>
|
||||
|
|
@ -558,7 +192,6 @@ namespace QtPrivate {
|
|||
FunctorCall<typename Indexes<N>::Value, SignalArgs, R, Function>::call(f, arg);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
Logic that check if the arguments of the slot matches the argument of the signal.
|
||||
|
|
@ -578,16 +211,6 @@ namespace QtPrivate {
|
|||
template<typename A> struct AreArgumentsCompatible<A, void> { enum { value = true }; };
|
||||
template<> struct AreArgumentsCompatible<void, void> { enum { value = true }; };
|
||||
|
||||
#ifndef Q_COMPILER_VARIADIC_TEMPLATES
|
||||
template <typename List1, typename List2> struct CheckCompatibleArguments { enum { value = false }; };
|
||||
template <> struct CheckCompatibleArguments<void, void> { enum { value = true }; };
|
||||
template <typename List1> struct CheckCompatibleArguments<List1, void> { enum { value = true }; };
|
||||
template <typename Arg1, typename Arg2, typename Tail1, typename Tail2> struct CheckCompatibleArguments<List<Arg1, Tail1>, List<Arg2, Tail2> >
|
||||
{
|
||||
enum { value = AreArgumentsCompatible<typename RemoveConstRef<Arg1>::Type, typename RemoveConstRef<Arg2>::Type>::value
|
||||
&& CheckCompatibleArguments<Tail1, Tail2>::value };
|
||||
};
|
||||
#else
|
||||
template <typename List1, typename List2> struct CheckCompatibleArguments { enum { value = false }; };
|
||||
template <> struct CheckCompatibleArguments<List<>, List<>> { enum { value = true }; };
|
||||
template <typename List1> struct CheckCompatibleArguments<List1, List<>> { enum { value = true }; };
|
||||
|
|
@ -597,9 +220,7 @@ namespace QtPrivate {
|
|||
enum { value = AreArgumentsCompatible<typename RemoveConstRef<Arg1>::Type, typename RemoveConstRef<Arg2>::Type>::value
|
||||
&& CheckCompatibleArguments<List<Tail1...>, List<Tail2...>>::value };
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(Q_COMPILER_VARIADIC_TEMPLATES)
|
||||
/*
|
||||
Find the maximum number of arguments a functor object can take and be still compatible with
|
||||
the arguments from the signal.
|
||||
|
|
@ -631,8 +252,6 @@ namespace QtPrivate {
|
|||
template <typename D> static D dummy();
|
||||
typedef decltype(dummy<Functor>().operator()((dummy<ArgList>())...)) Value;
|
||||
};
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
Loading…
Reference in New Issue