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:
parent
f83724a0f2
commit
4a0565b443
@ -1295,25 +1295,10 @@ const char *QMetaMethod::signature() const
|
||||
*/
|
||||
QList<QByteArray> QMetaMethod::parameterTypes() const
|
||||
{
|
||||
QList<QByteArray> 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<QByteArray>();
|
||||
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<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
|
||||
|
@ -134,6 +134,8 @@ struct QMetaObjectPrivate
|
||||
bool normalizeStringData);
|
||||
static int originalClone(const QMetaObject *obj, int local_method_index);
|
||||
|
||||
static QList<QByteArray> parameterTypeNamesFromSignature(const char *signature);
|
||||
|
||||
#ifndef QT_NO_QOBJECT
|
||||
//defined in qobject.cpp
|
||||
enum DisconnectType { DisconnectAll, DisconnectOne };
|
||||
|
Loading…
Reference in New Issue
Block a user