Add QMetaMethodBuilder::parameterTypes() function
This function matches QMetaMethod::parameterTypes(). The implementation of QMetaMethod::parameterTypes() was moved to a helper function in QMetaObjectPrivate, so that it can be shared with QMetaMethodBuilder. Change-Id: I4361713996dc4ea31a79c2fc74c813ee5e9c3069 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com>bb10
parent
2632f76b42
commit
69e3e54486
|
|
@ -136,6 +136,11 @@ public:
|
|||
{
|
||||
attributes = ((attributes & ~AccessMask) | (int)value);
|
||||
}
|
||||
|
||||
QList<QByteArray> parameterTypes() const
|
||||
{
|
||||
return QMetaObjectPrivate::parameterTypeNamesFromSignature(signature);
|
||||
}
|
||||
};
|
||||
|
||||
class QMetaPropertyBuilderPrivate
|
||||
|
|
@ -1936,7 +1941,7 @@ QByteArray QMetaMethodBuilder::returnType() const
|
|||
is empty, then the method's return type is \c{void}. The \a value
|
||||
will be normalized before it is added to the method.
|
||||
|
||||
\sa returnType(), signature()
|
||||
\sa returnType(), parameterTypes(), signature()
|
||||
*/
|
||||
void QMetaMethodBuilder::setReturnType(const QByteArray& value)
|
||||
{
|
||||
|
|
@ -1945,6 +1950,20 @@ void QMetaMethodBuilder::setReturnType(const QByteArray& value)
|
|||
d->returnType = QMetaObject::normalizedType(value);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the list of parameter types for this method.
|
||||
|
||||
\sa returnType(), parameterNames()
|
||||
*/
|
||||
QList<QByteArray> QMetaMethodBuilder::parameterTypes() const
|
||||
{
|
||||
QMetaMethodBuilderPrivate *d = d_func();
|
||||
if (d)
|
||||
return d->parameterTypes();
|
||||
else
|
||||
return QList<QByteArray>();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the list of parameter names for this method.
|
||||
|
||||
|
|
|
|||
|
|
@ -203,6 +203,7 @@ public:
|
|||
QByteArray returnType() const;
|
||||
void setReturnType(const QByteArray& value);
|
||||
|
||||
QList<QByteArray> parameterTypes() const;
|
||||
QList<QByteArray> parameterNames() const;
|
||||
void setParameterNames(const QList<QByteArray>& value);
|
||||
|
||||
|
|
|
|||
|
|
@ -217,6 +217,7 @@ void tst_QMetaObjectBuilder::method()
|
|||
QCOMPARE(nullMethod.signature(), QByteArray());
|
||||
QVERIFY(nullMethod.methodType() == QMetaMethod::Method);
|
||||
QVERIFY(nullMethod.returnType().isEmpty());
|
||||
QVERIFY(nullMethod.parameterTypes().isEmpty());
|
||||
QVERIFY(nullMethod.parameterNames().isEmpty());
|
||||
QVERIFY(nullMethod.tag().isEmpty());
|
||||
QVERIFY(nullMethod.access() == QMetaMethod::Public);
|
||||
|
|
@ -229,6 +230,7 @@ void tst_QMetaObjectBuilder::method()
|
|||
QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
|
||||
QVERIFY(method1.methodType() == QMetaMethod::Method);
|
||||
QVERIFY(method1.returnType().isEmpty());
|
||||
QCOMPARE(method1.parameterTypes(), QList<QByteArray>() << "QString" << "int");
|
||||
QVERIFY(method1.parameterNames().isEmpty());
|
||||
QVERIFY(method1.tag().isEmpty());
|
||||
QVERIFY(method1.access() == QMetaMethod::Public);
|
||||
|
|
@ -242,6 +244,7 @@ void tst_QMetaObjectBuilder::method()
|
|||
QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
|
||||
QVERIFY(method2.methodType() == QMetaMethod::Method);
|
||||
QCOMPARE(method2.returnType(), QByteArray("int"));
|
||||
QCOMPARE(method2.parameterTypes(), QList<QByteArray>() << "QString");
|
||||
QVERIFY(method2.parameterNames().isEmpty());
|
||||
QVERIFY(method2.tag().isEmpty());
|
||||
QVERIFY(method2.access() == QMetaMethod::Public);
|
||||
|
|
@ -267,6 +270,7 @@ void tst_QMetaObjectBuilder::method()
|
|||
QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
|
||||
QVERIFY(method1.methodType() == QMetaMethod::Method);
|
||||
QCOMPARE(method1.returnType(), QByteArray("int"));
|
||||
QCOMPARE(method1.parameterTypes(), QList<QByteArray>() << "QString" << "int");
|
||||
QCOMPARE(method1.parameterNames(), QList<QByteArray>() << "a" << "b");
|
||||
QCOMPARE(method1.tag(), QByteArray("tag"));
|
||||
QVERIFY(method1.access() == QMetaMethod::Private);
|
||||
|
|
@ -276,6 +280,7 @@ void tst_QMetaObjectBuilder::method()
|
|||
QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
|
||||
QVERIFY(method2.methodType() == QMetaMethod::Method);
|
||||
QCOMPARE(method2.returnType(), QByteArray("int"));
|
||||
QCOMPARE(method2.parameterTypes(), QList<QByteArray>() << "QString");
|
||||
QVERIFY(method2.parameterNames().isEmpty());
|
||||
QVERIFY(method2.tag().isEmpty());
|
||||
QVERIFY(method2.access() == QMetaMethod::Public);
|
||||
|
|
@ -296,6 +301,7 @@ void tst_QMetaObjectBuilder::method()
|
|||
QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
|
||||
QVERIFY(method1.methodType() == QMetaMethod::Method);
|
||||
QCOMPARE(method1.returnType(), QByteArray("int"));
|
||||
QCOMPARE(method1.parameterTypes(), QList<QByteArray>() << "QString" << "int");
|
||||
QCOMPARE(method1.parameterNames(), QList<QByteArray>() << "a" << "b");
|
||||
QCOMPARE(method1.tag(), QByteArray("tag"));
|
||||
QVERIFY(method1.access() == QMetaMethod::Private);
|
||||
|
|
@ -305,6 +311,7 @@ void tst_QMetaObjectBuilder::method()
|
|||
QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
|
||||
QVERIFY(method2.methodType() == QMetaMethod::Method);
|
||||
QCOMPARE(method2.returnType(), QByteArray("QString"));
|
||||
QCOMPARE(method2.parameterTypes(), QList<QByteArray>() << "QString");
|
||||
QCOMPARE(method2.parameterNames(), QList<QByteArray>() << "c");
|
||||
QCOMPARE(method2.tag(), QByteArray("Q_FOO"));
|
||||
QVERIFY(method2.access() == QMetaMethod::Protected);
|
||||
|
|
@ -320,6 +327,7 @@ void tst_QMetaObjectBuilder::method()
|
|||
QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
|
||||
QVERIFY(method2.methodType() == QMetaMethod::Method);
|
||||
QCOMPARE(method2.returnType(), QByteArray("QString"));
|
||||
QCOMPARE(method2.parameterTypes(), QList<QByteArray>() << "QString");
|
||||
QCOMPARE(method2.parameterNames(), QList<QByteArray>() << "c");
|
||||
QCOMPARE(method2.tag(), QByteArray("Q_FOO"));
|
||||
QVERIFY(method2.access() == QMetaMethod::Protected);
|
||||
|
|
@ -347,6 +355,7 @@ void tst_QMetaObjectBuilder::slot()
|
|||
QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
|
||||
QVERIFY(method1.methodType() == QMetaMethod::Slot);
|
||||
QVERIFY(method1.returnType().isEmpty());
|
||||
QCOMPARE(method1.parameterTypes(), QList<QByteArray>() << "QString" << "int");
|
||||
QVERIFY(method1.parameterNames().isEmpty());
|
||||
QVERIFY(method1.tag().isEmpty());
|
||||
QVERIFY(method1.access() == QMetaMethod::Public);
|
||||
|
|
@ -359,6 +368,7 @@ void tst_QMetaObjectBuilder::slot()
|
|||
QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
|
||||
QVERIFY(method2.methodType() == QMetaMethod::Slot);
|
||||
QVERIFY(method2.returnType().isEmpty());
|
||||
QCOMPARE(method2.parameterTypes(), QList<QByteArray>() << "QString");
|
||||
QVERIFY(method2.parameterNames().isEmpty());
|
||||
QVERIFY(method2.tag().isEmpty());
|
||||
QVERIFY(method2.access() == QMetaMethod::Public);
|
||||
|
|
@ -384,6 +394,7 @@ void tst_QMetaObjectBuilder::signal()
|
|||
QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
|
||||
QVERIFY(method1.methodType() == QMetaMethod::Signal);
|
||||
QVERIFY(method1.returnType().isEmpty());
|
||||
QCOMPARE(method1.parameterTypes(), QList<QByteArray>() << "QString" << "int");
|
||||
QVERIFY(method1.parameterNames().isEmpty());
|
||||
QVERIFY(method1.tag().isEmpty());
|
||||
QVERIFY(method1.access() == QMetaMethod::Protected);
|
||||
|
|
@ -396,6 +407,7 @@ void tst_QMetaObjectBuilder::signal()
|
|||
QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
|
||||
QVERIFY(method2.methodType() == QMetaMethod::Signal);
|
||||
QVERIFY(method2.returnType().isEmpty());
|
||||
QCOMPARE(method2.parameterTypes(), QList<QByteArray>() << "QString");
|
||||
QVERIFY(method2.parameterNames().isEmpty());
|
||||
QVERIFY(method2.tag().isEmpty());
|
||||
QVERIFY(method2.access() == QMetaMethod::Protected);
|
||||
|
|
@ -421,6 +433,7 @@ void tst_QMetaObjectBuilder::constructor()
|
|||
QCOMPARE(ctor1.signature(), QByteArray("foo(QString,int)"));
|
||||
QVERIFY(ctor1.methodType() == QMetaMethod::Constructor);
|
||||
QVERIFY(ctor1.returnType().isEmpty());
|
||||
QCOMPARE(ctor1.parameterTypes(), QList<QByteArray>() << "QString" << "int");
|
||||
QVERIFY(ctor1.parameterNames().isEmpty());
|
||||
QVERIFY(ctor1.tag().isEmpty());
|
||||
QVERIFY(ctor1.access() == QMetaMethod::Public);
|
||||
|
|
@ -433,6 +446,7 @@ void tst_QMetaObjectBuilder::constructor()
|
|||
QCOMPARE(ctor2.signature(), QByteArray("bar(QString)"));
|
||||
QVERIFY(ctor2.methodType() == QMetaMethod::Constructor);
|
||||
QVERIFY(ctor2.returnType().isEmpty());
|
||||
QCOMPARE(ctor2.parameterTypes(), QList<QByteArray>() << "QString");
|
||||
QVERIFY(ctor2.parameterNames().isEmpty());
|
||||
QVERIFY(ctor2.tag().isEmpty());
|
||||
QVERIFY(ctor2.access() == QMetaMethod::Public);
|
||||
|
|
@ -458,6 +472,7 @@ void tst_QMetaObjectBuilder::constructor()
|
|||
QCOMPARE(ctor1.signature(), QByteArray("foo(QString,int)"));
|
||||
QVERIFY(ctor1.methodType() == QMetaMethod::Constructor);
|
||||
QCOMPARE(ctor1.returnType(), QByteArray("int"));
|
||||
QCOMPARE(ctor1.parameterTypes(), QList<QByteArray>() << "QString" << "int");
|
||||
QCOMPARE(ctor1.parameterNames(), QList<QByteArray>() << "a" << "b");
|
||||
QCOMPARE(ctor1.tag(), QByteArray("tag"));
|
||||
QVERIFY(ctor1.access() == QMetaMethod::Private);
|
||||
|
|
@ -466,6 +481,7 @@ void tst_QMetaObjectBuilder::constructor()
|
|||
QCOMPARE(ctor2.signature(), QByteArray("bar(QString)"));
|
||||
QVERIFY(ctor2.methodType() == QMetaMethod::Constructor);
|
||||
QVERIFY(ctor2.returnType().isEmpty());
|
||||
QCOMPARE(ctor2.parameterTypes(), QList<QByteArray>() << "QString");
|
||||
QVERIFY(ctor2.parameterNames().isEmpty());
|
||||
QVERIFY(ctor2.tag().isEmpty());
|
||||
QVERIFY(ctor2.access() == QMetaMethod::Public);
|
||||
|
|
@ -484,6 +500,7 @@ void tst_QMetaObjectBuilder::constructor()
|
|||
QCOMPARE(ctor1.signature(), QByteArray("foo(QString,int)"));
|
||||
QVERIFY(ctor1.methodType() == QMetaMethod::Constructor);
|
||||
QCOMPARE(ctor1.returnType(), QByteArray("int"));
|
||||
QCOMPARE(ctor1.parameterTypes(), QList<QByteArray>() << "QString" << "int");
|
||||
QCOMPARE(ctor1.parameterNames(), QList<QByteArray>() << "a" << "b");
|
||||
QCOMPARE(ctor1.tag(), QByteArray("tag"));
|
||||
QVERIFY(ctor1.access() == QMetaMethod::Private);
|
||||
|
|
@ -492,6 +509,7 @@ void tst_QMetaObjectBuilder::constructor()
|
|||
QCOMPARE(ctor2.signature(), QByteArray("bar(QString)"));
|
||||
QVERIFY(ctor2.methodType() == QMetaMethod::Constructor);
|
||||
QCOMPARE(ctor2.returnType(), QByteArray("QString"));
|
||||
QCOMPARE(ctor2.parameterTypes(), QList<QByteArray>() << "QString");
|
||||
QCOMPARE(ctor2.parameterNames(), QList<QByteArray>() << "c");
|
||||
QCOMPARE(ctor2.tag(), QByteArray("Q_FOO"));
|
||||
QVERIFY(ctor2.access() == QMetaMethod::Protected);
|
||||
|
|
@ -506,6 +524,7 @@ void tst_QMetaObjectBuilder::constructor()
|
|||
QCOMPARE(ctor2.signature(), QByteArray("bar(QString)"));
|
||||
QVERIFY(ctor2.methodType() == QMetaMethod::Constructor);
|
||||
QCOMPARE(ctor2.returnType(), QByteArray("QString"));
|
||||
QCOMPARE(ctor2.parameterTypes(), QList<QByteArray>() << "QString");
|
||||
QCOMPARE(ctor2.parameterNames(), QList<QByteArray>() << "c");
|
||||
QCOMPARE(ctor2.tag(), QByteArray("Q_FOO"));
|
||||
QVERIFY(ctor2.access() == QMetaMethod::Protected);
|
||||
|
|
@ -525,6 +544,7 @@ void tst_QMetaObjectBuilder::constructor()
|
|||
QCOMPARE(prototypeConstructor.signature(), QByteArray("SomethingOfEverything()"));
|
||||
QVERIFY(prototypeConstructor.methodType() == QMetaMethod::Constructor);
|
||||
QCOMPARE(prototypeConstructor.returnType(), QByteArray());
|
||||
QVERIFY(prototypeConstructor.parameterTypes().isEmpty());
|
||||
QVERIFY(prototypeConstructor.access() == QMetaMethod::Public);
|
||||
QCOMPARE(prototypeConstructor.index(), 1);
|
||||
|
||||
|
|
@ -1167,6 +1187,9 @@ static bool sameMethod(const QMetaMethod& method1, const QMetaMethod& method2)
|
|||
if (QByteArray(method1.typeName()) != QByteArray(method2.typeName()))
|
||||
return false;
|
||||
|
||||
if (method1.parameterTypes() != method2.parameterTypes())
|
||||
return false;
|
||||
|
||||
if (method1.parameterNames() != method2.parameterNames())
|
||||
return false;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue