Use the new QMetaMethod API in QtDBus

Use QMetaMethod::name() instead of parsing the signature.
Use QMetaMethod::returnType() instead of resolving the type id
via the type name.

Change-Id: If5d0198c5f1329fd9d9340acd58bd4a36933d960
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Kent Hansen 2012-03-20 19:45:00 +01:00 committed by Qt by Nokia
parent 83e055424a
commit 3e1e0b41a8
4 changed files with 10 additions and 15 deletions

View File

@ -442,11 +442,11 @@ QDBusMessage QDBusAbstractInterface::callWithArgumentList(QDBus::CallMode mode,
// determine if this a sync or async call
mode = QDBus::Block;
const QMetaObject *mo = metaObject();
QByteArray match = m.toLatin1() + '(';
QByteArray match = m.toLatin1();
for (int i = staticMetaObject.methodCount(); i < mo->methodCount(); ++i) {
QMetaMethod mm = mo->method(i);
if (mm.methodSignature().startsWith(match)) {
if (mm.name() == match) {
// found a method with the same name as what we're looking for
// hopefully, nobody is overloading asynchronous and synchronous methods with
// the same name

View File

@ -640,12 +640,10 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags,
continue;
// check name:
QByteArray slotname = mm.methodSignature();
int paren = slotname.indexOf('(');
if (paren != name.length() || !slotname.startsWith(name))
if (mm.name() != name)
continue;
int returnType = QMetaType::type(mm.typeName());
int returnType = mm.returnType();
bool isAsync = qDBusCheckAsyncTag(mm.tag());
bool isScriptable = mm.attributes() & QMetaMethod::Scriptable;
@ -1188,8 +1186,7 @@ void QDBusConnectionPrivate::relaySignal(QObject *obj, const QMetaObject *mo, in
QString interface = qDBusInterfaceFromMetaObject(mo);
QMetaMethod mm = mo->method(signalId);
QByteArray memberName = mm.methodSignature();
memberName.truncate(memberName.indexOf('('));
QByteArray memberName = mm.name();
// check if it's scriptable
bool isScriptable = mm.attributes() & QMetaMethod::Scriptable;

View File

@ -300,7 +300,7 @@ int QDBusInterfacePrivate::metacall(QMetaObject::Call c, int id, void **argv)
const int *outputTypes = metaObject->outputTypesForMethod(id);
int outputTypesCount = *outputTypes++;
if (*mm.typeName()) {
if (mm.returnType() != QMetaType::UnknownType && mm.returnType() != QMetaType::Void) {
// this method has a return type
if (argv[0] && it != args.constEnd())
copyArgument(argv[0], *outputTypes++, *it);

View File

@ -126,8 +126,6 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
// now add methods:
for (int i = methodOffset; i < mo->methodCount(); ++i) {
QMetaMethod mm = mo->method(i);
QByteArray signature = mm.methodSignature();
int paren = signature.indexOf('(');
bool isSignal;
if (mm.methodType() == QMetaMethod::Signal)
@ -147,11 +145,11 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
QString xml = QString::fromLatin1(" <%1 name=\"%2\">\n")
.arg(isSignal ? QLatin1String("signal") : QLatin1String("method"))
.arg(QLatin1String(signature.left(paren)));
.arg(QString::fromLatin1(mm.name()));
// check the return type first
int typeId = QMetaType::type(mm.typeName());
if (typeId) {
int typeId = mm.returnType();
if (typeId != QMetaType::UnknownType && typeId != QMetaType::Void) {
const char *typeName = QDBusMetaType::typeToSignature(typeId);
if (typeName) {
xml += QString::fromLatin1(" <arg type=\"%1\" direction=\"out\"/>\n")
@ -164,7 +162,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
} else
continue;
}
else if (*mm.typeName())
else if (typeId == QMetaType::UnknownType)
continue; // wasn't a valid type
QList<QByteArray> names = mm.parameterNames();