QMetaMethodBuilderPrivate
(QMetaMethod::MethodType _methodType,
const QByteArray& _signature,
- const QByteArray& _returnType = QByteArray(),
+ const QByteArray& _returnType = QByteArray("void"),
QMetaMethod::Access _access = QMetaMethod::Public,
int _revision = 0)
: signature(QMetaObject::normalizedSignature(_signature.constData())),
\a signature and \a returnType. Returns an object that can be
used to adjust the other attributes of the method. The \a signature
and \a returnType will be normalized before they are added to
- the class. If \a returnType is empty, then it indicates that
- the method has \c{void} as its return type.
+ the class.
\sa method(), methodCount(), removeMethod(), indexOfMethod()
*/
{
int index = d->methods.size();
d->methods.append(QMetaMethodBuilderPrivate
- (QMetaMethod::Signal, signature, QByteArray(), QMetaMethod::Protected));
+ (QMetaMethod::Signal, signature, QByteArray("void"), QMetaMethod::Protected));
return QMetaMethodBuilder(this, index);
}
QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QByteArray& signature)
{
int index = d->constructors.size();
- d->constructors.append(QMetaMethodBuilderPrivate(QMetaMethod::Constructor, signature));
+ d->constructors.append(QMetaMethodBuilderPrivate(QMetaMethod::Constructor, signature,
+ /*returnType=*/QByteArray()));
return QMetaMethodBuilder(this, -(index + 1));
}
QTest::newRow("voidSignal")
<< QByteArray("voidSignal()")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>())
<< (QList<QByteArray>())
<< (QList<QByteArray>())
QTest::newRow("voidInvokable")
<< QByteArray("voidInvokable()")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>())
<< (QList<QByteArray>())
<< (QList<QByteArray>())
QTest::newRow("voidSlot")
<< QByteArray("voidSlot()")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>())
<< (QList<QByteArray>())
<< (QList<QByteArray>())
QTest::newRow("voidSignalVoid")
<< QByteArray("voidSignalVoid()")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< QList<int>()
<< QList<QByteArray>()
<< QList<QByteArray>()
QTest::newRow("voidSignalInt")
<< QByteArray("voidSignalInt(int)")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>() << int(QMetaType::Int))
<< (QList<QByteArray>() << QByteArray("int"))
<< (QList<QByteArray>() << QByteArray("voidSignalIntArg"))
QTest::newRow("voidInvokableInt")
<< QByteArray("voidInvokableInt(int)")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>() << int(QMetaType::Int))
<< (QList<QByteArray>() << QByteArray("int"))
<< (QList<QByteArray>() << QByteArray("voidInvokableIntArg"))
QTest::newRow("voidSlotInt")
<< QByteArray("voidSlotInt(int)")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>() << int(QMetaType::Int))
<< (QList<QByteArray>() << QByteArray("int"))
<< (QList<QByteArray>() << QByteArray("voidSlotIntArg"))
QTest::newRow("voidSignalQReal")
<< QByteArray("voidSignalQReal(qreal)")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>() << qMetaTypeId<qreal>())
<< (QList<QByteArray>() << QByteArray("qreal"))
<< (QList<QByteArray>() << QByteArray("voidSignalQRealArg"))
QTest::newRow("voidInvokableQReal")
<< QByteArray("voidInvokableQReal(qreal)")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>() << qMetaTypeId<qreal>())
<< (QList<QByteArray>() << QByteArray("qreal"))
<< (QList<QByteArray>() << QByteArray("voidInvokableQRealArg"))
QTest::newRow("voidSlotQReal")
<< QByteArray("voidSlotQReal(qreal)")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>() << qMetaTypeId<qreal>())
<< (QList<QByteArray>() << QByteArray("qreal"))
<< (QList<QByteArray>() << QByteArray("voidSlotQRealArg"))
QTest::newRow("voidSignalQString")
<< QByteArray("voidSignalQString(QString)")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>() << int(QMetaType::QString))
<< (QList<QByteArray>() << QByteArray("QString"))
<< (QList<QByteArray>() << QByteArray("voidSignalQStringArg"))
QTest::newRow("voidInvokableQString")
<< QByteArray("voidInvokableQString(QString)")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>() << int(QMetaType::QString))
<< (QList<QByteArray>() << QByteArray("QString"))
<< (QList<QByteArray>() << QByteArray("voidInvokableQStringArg"))
QTest::newRow("voidSlotQString")
<< QByteArray("voidSlotQString(QString)")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>() << int(QMetaType::QString))
<< (QList<QByteArray>() << QByteArray("QString"))
<< (QList<QByteArray>() << QByteArray("voidSlotQStringArg"))
QTest::newRow("voidSignalCustomType")
<< QByteArray("voidSignalCustomType(CustomType)")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>() << qMetaTypeId<CustomType>())
<< (QList<QByteArray>() << QByteArray("CustomType"))
<< (QList<QByteArray>() << QByteArray("voidSignalCustomTypeArg"))
QTest::newRow("voidInvokableCustomType")
<< QByteArray("voidInvokableCustomType(CustomType)")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>() << qMetaTypeId<CustomType>())
<< (QList<QByteArray>() << QByteArray("CustomType"))
<< (QList<QByteArray>() << QByteArray("voidInvokableCustomTypeArg"))
QTest::newRow("voidSlotCustomType")
<< QByteArray("voidSlotCustomType(CustomType)")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>() << qMetaTypeId<CustomType>())
<< (QList<QByteArray>() << QByteArray("CustomType"))
<< (QList<QByteArray>() << QByteArray("voidSlotCustomTypeArg"))
QTest::newRow("voidSignalCustomUnregisteredType")
<< QByteArray("voidSignalCustomUnregisteredType(CustomUnregisteredType)")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>() << 0)
<< (QList<QByteArray>() << QByteArray("CustomUnregisteredType"))
<< (QList<QByteArray>() << QByteArray("voidSignalCustomUnregisteredTypeArg"))
QTest::newRow("voidInvokableCustomUnregisteredType")
<< QByteArray("voidInvokableCustomUnregisteredType(CustomUnregisteredType)")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>() << 0)
<< (QList<QByteArray>() << QByteArray("CustomUnregisteredType"))
<< (QList<QByteArray>() << QByteArray("voidInvokableCustomUnregisteredTypeArg"))
QTest::newRow("voidSlotCustomUnregisteredType")
<< QByteArray("voidSlotCustomUnregisteredType(CustomUnregisteredType)")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>() << 0)
<< (QList<QByteArray>() << QByteArray("CustomUnregisteredType"))
<< (QList<QByteArray>() << QByteArray("voidSlotCustomUnregisteredTypeArg"))
QTest::newRow("voidSignalNoParameterNames")
<< QByteArray("voidSignalNoParameterNames(bool,int)")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>() << int(QMetaType::Bool) << int(QMetaType::Int))
<< (QList<QByteArray>() << QByteArray("bool") << QByteArray("int"))
<< (QList<QByteArray>() << QByteArray("") << QByteArray(""))
QTest::newRow("voidInvokableNoParameterNames")
<< QByteArray("voidInvokableNoParameterNames(bool,int)")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>() << int(QMetaType::Bool) << int(QMetaType::Int))
<< (QList<QByteArray>() << QByteArray("bool") << QByteArray("int"))
<< (QList<QByteArray>() << QByteArray("") << QByteArray(""))
QTest::newRow("voidSlotNoParameterNames")
<< QByteArray("voidSlotNoParameterNames(bool,int)")
- << int(QMetaType::Void) << QByteArray("")
+ << int(QMetaType::Void) << QByteArray("void")
<< (QList<int>() << int(QMetaType::Bool) << int(QMetaType::Int))
<< (QList<QByteArray>() << QByteArray("bool") << QByteArray("int"))
<< (QList<QByteArray>() << QByteArray("") << QByteArray(""))
QCOMPARE(method.tag(), "");
QCOMPARE(method.returnType(), returnType);
+ QVERIFY(method.typeName() != 0);
if (QByteArray(method.typeName()) != returnTypeName) {
// QMetaMethod should always produce a semantically equivalent typename
QCOMPARE(QMetaType::type(method.typeName()), QMetaType::type(returnTypeName));
QMetaMethodBuilder method1 = builder.addMethod("foo(const QString&, int)");
QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
QVERIFY(method1.methodType() == QMetaMethod::Method);
- QVERIFY(method1.returnType().isEmpty());
+ QCOMPARE(method1.returnType(), QByteArray("void"));
QCOMPARE(method1.parameterTypes(), QList<QByteArray>() << "QString" << "int");
QVERIFY(method1.parameterNames().isEmpty());
QVERIFY(method1.tag().isEmpty());
QMetaMethodBuilder method1 = builder.addSlot("foo(const QString&, int)");
QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
QVERIFY(method1.methodType() == QMetaMethod::Slot);
- QVERIFY(method1.returnType().isEmpty());
+ QCOMPARE(method1.returnType(), QByteArray("void"));
QCOMPARE(method1.parameterTypes(), QList<QByteArray>() << "QString" << "int");
QVERIFY(method1.parameterNames().isEmpty());
QVERIFY(method1.tag().isEmpty());
QMetaMethodBuilder method2 = builder.addSlot("bar(QString)");
QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
QVERIFY(method2.methodType() == QMetaMethod::Slot);
- QVERIFY(method2.returnType().isEmpty());
+ QCOMPARE(method2.returnType(), QByteArray("void"));
QCOMPARE(method2.parameterTypes(), QList<QByteArray>() << "QString");
QVERIFY(method2.parameterNames().isEmpty());
QVERIFY(method2.tag().isEmpty());
QMetaMethodBuilder method1 = builder.addSignal("foo(const QString&, int)");
QCOMPARE(method1.signature(), QByteArray("foo(QString,int)"));
QVERIFY(method1.methodType() == QMetaMethod::Signal);
- QVERIFY(method1.returnType().isEmpty());
+ QCOMPARE(method1.returnType(), QByteArray("void"));
QCOMPARE(method1.parameterTypes(), QList<QByteArray>() << "QString" << "int");
QVERIFY(method1.parameterNames().isEmpty());
QVERIFY(method1.tag().isEmpty());
QMetaMethodBuilder method2 = builder.addSignal("bar(QString)");
QCOMPARE(method2.signature(), QByteArray("bar(QString)"));
QVERIFY(method2.methodType() == QMetaMethod::Signal);
- QVERIFY(method2.returnType().isEmpty());
+ QCOMPARE(method2.returnType(), QByteArray("void"));
QCOMPARE(method2.parameterTypes(), QList<QByteArray>() << "QString");
QVERIFY(method2.parameterNames().isEmpty());
QVERIFY(method2.tag().isEmpty());