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 <ogoffart@woboq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Kent Hansen 2012-02-19 19:34:50 +01:00 committed by Qt by Nokia
parent f83724a0f2
commit 4a0565b443
2 changed files with 30 additions and 18 deletions

View File

@ -1295,25 +1295,10 @@ const char *QMetaMethod::signature() const
*/ */
QList<QByteArray> QMetaMethod::parameterTypes() const QList<QByteArray> QMetaMethod::parameterTypes() const
{ {
QList<QByteArray> list;
if (!mobj) if (!mobj)
return list; return QList<QByteArray>();
const char *signature = mobj->d.stringdata + mobj->d.data[handle]; return QMetaObjectPrivate::parameterTypeNamesFromSignature(
while (*signature && *signature != '(') mobj->d.stringdata + mobj->d.data[handle]);
++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;
} }
/*! /*!
@ -2809,4 +2794,29 @@ int QMetaObjectPrivate::originalClone(const QMetaObject *mobj, int local_method_
return local_method_index; return local_method_index;
} }
/*!
\internal
Returns the parameter type names extracted from the given \a signature.
*/
QList<QByteArray> QMetaObjectPrivate::parameterTypeNamesFromSignature(const char *signature)
{
QList<QByteArray> 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 QT_END_NAMESPACE

View File

@ -134,6 +134,8 @@ struct QMetaObjectPrivate
bool normalizeStringData); bool normalizeStringData);
static int originalClone(const QMetaObject *obj, int local_method_index); static int originalClone(const QMetaObject *obj, int local_method_index);
static QList<QByteArray> parameterTypeNamesFromSignature(const char *signature);
#ifndef QT_NO_QOBJECT #ifndef QT_NO_QOBJECT
//defined in qobject.cpp //defined in qobject.cpp
enum DisconnectType { DisconnectAll, DisconnectOne }; enum DisconnectType { DisconnectAll, DisconnectOne };