From 4a0565b4439b9bb71d0e7a77b15b85611a697f57 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Sun, 19 Feb 2012 19:34:50 +0100 Subject: [PATCH] Move QMetaMethod::parameterTypes() implementation to helper function Because of an upcoming change to the meta-object data format, the ability to extract parameter types from a signature will be needed by meta-object builders (such as QMetaObjectBuilder) soon. Change-Id: I1f21b2be41761a5db2f1a05976fad29eb3aebb03 Reviewed-by: Olivier Goffart Reviewed-by: Thiago Macieira --- src/corelib/kernel/qmetaobject.cpp | 46 ++++++++++++++++++------------ src/corelib/kernel/qmetaobject_p.h | 2 ++ 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 03fc90b620..d53ba707f7 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -1295,25 +1295,10 @@ const char *QMetaMethod::signature() const */ QList QMetaMethod::parameterTypes() const { - QList list; if (!mobj) - return list; - const char *signature = mobj->d.stringdata + mobj->d.data[handle]; - while (*signature && *signature != '(') - ++signature; - while (*signature && *signature != ')' && *++signature != ')') { - const char *begin = signature; - int level = 0; - while (*signature && (level > 0 || *signature != ',') && *signature != ')') { - if (*signature == '<') - ++level; - else if (*signature == '>') - --level; - ++signature; - } - list += QByteArray(begin, signature - begin); - } - return list; + return QList(); + return QMetaObjectPrivate::parameterTypeNamesFromSignature( + mobj->d.stringdata + mobj->d.data[handle]); } /*! @@ -2809,4 +2794,29 @@ int QMetaObjectPrivate::originalClone(const QMetaObject *mobj, int local_method_ return local_method_index; } +/*! + \internal + + Returns the parameter type names extracted from the given \a signature. +*/ +QList QMetaObjectPrivate::parameterTypeNamesFromSignature(const char *signature) +{ + QList list; + while (*signature && *signature != '(') + ++signature; + while (*signature && *signature != ')' && *++signature != ')') { + const char *begin = signature; + int level = 0; + while (*signature && (level > 0 || *signature != ',') && *signature != ')') { + if (*signature == '<') + ++level; + else if (*signature == '>') + --level; + ++signature; + } + list += QByteArray(begin, signature - begin); + } + return list; +} + QT_END_NAMESPACE diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h index d6e49b92d2..59a5c5f280 100644 --- a/src/corelib/kernel/qmetaobject_p.h +++ b/src/corelib/kernel/qmetaobject_p.h @@ -134,6 +134,8 @@ struct QMetaObjectPrivate bool normalizeStringData); static int originalClone(const QMetaObject *obj, int local_method_index); + static QList parameterTypeNamesFromSignature(const char *signature); + #ifndef QT_NO_QOBJECT //defined in qobject.cpp enum DisconnectType { DisconnectAll, DisconnectOne };