diff options
Diffstat (limited to 'src/corelib/kernel/qmetaobject.cpp')
-rw-r--r-- | src/corelib/kernel/qmetaobject.cpp | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index fad47eee13..3883613d49 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -154,20 +154,29 @@ QT_BEGIN_NAMESPACE static inline const QMetaObjectPrivate *priv(const uint* data) { return reinterpret_cast<const QMetaObjectPrivate*>(data); } +static inline const char *rawStringData(const QMetaObject *mo, int index) +{ + Q_ASSERT(priv(mo->d.data)->revision >= 7); + uint offset = mo->d.stringdata[2*index]; + return reinterpret_cast<const char *>(mo->d.stringdata) + offset; +} + static inline const QByteArray stringData(const QMetaObject *mo, int index) { Q_ASSERT(priv(mo->d.data)->revision >= 7); - const QByteArrayDataPtr data = { const_cast<QByteArrayData*>(&mo->d.stringdata[index]) }; - Q_ASSERT(data.ptr->ref.isStatic()); - Q_ASSERT(data.ptr->alloc == 0); - Q_ASSERT(data.ptr->capacityReserved == 0); - Q_ASSERT(data.ptr->size >= 0); - return data; + uint offset = mo->d.stringdata[2*index]; + uint length = mo->d.stringdata[2*index + 1]; + const char *string = reinterpret_cast<const char *>(mo->d.stringdata) + offset; + return QByteArray::fromRawData(string, length); } -static inline const char *rawStringData(const QMetaObject *mo, int index) +static inline const char *rawTypeNameFromTypeInfo(const QMetaObject *mo, uint typeInfo) { - return stringData(mo, index).data(); + if (typeInfo & IsUnresolvedType) { + return rawStringData(mo, typeInfo & TypeNameIndexMask); + } else { + return QMetaType::typeName(typeInfo); + } } static inline QByteArray typeNameFromTypeInfo(const QMetaObject *mo, uint typeInfo) @@ -181,16 +190,11 @@ static inline QByteArray typeNameFromTypeInfo(const QMetaObject *mo, uint typeIn } } -static inline const char *rawTypeNameFromTypeInfo(const QMetaObject *mo, uint typeInfo) -{ - return typeNameFromTypeInfo(mo, typeInfo).constData(); -} - static inline int typeFromTypeInfo(const QMetaObject *mo, uint typeInfo) { if (!(typeInfo & IsUnresolvedType)) return typeInfo; - return QMetaType::type(stringData(mo, typeInfo & TypeNameIndexMask)); + return QMetaType::type(rawStringData(mo, typeInfo & TypeNameIndexMask)); } class QMetaMethodPrivate : public QMetaMethod @@ -577,7 +581,7 @@ static bool methodMatch(const QMetaObject *m, int handle, if (int(m->d.data[handle + 1]) != argc) return false; - if (stringData(m, m->d.data[handle]) != name) + if (rawStringData(m, m->d.data[handle]) != name) return false; int paramsIndex = m->d.data[handle + 2] + 1; @@ -682,7 +686,9 @@ static void argumentTypesFromString(const char *str, const char *end, --level; ++str; } - types += QArgumentType(QByteArray(begin, str - begin)); + QByteArray argType(begin, str - begin); + argType.replace("QList<", "QVector<"); + types += QArgumentType(std::move(argType)); } } @@ -1161,7 +1167,7 @@ QMetaProperty QMetaObject::property(int index) const const QMetaObject *scope = nullptr; if (qstrcmp(scope_name, "Qt") == 0) - scope = &QObject::staticQtMetaObject; + scope = &Qt::staticMetaObject; else scope = QMetaObject_findMetaObject(this, scope_name); if (scope) @@ -3655,6 +3661,21 @@ const char* QMetaClassInfo::value() const } /*! + \class QMethodRawArguments + \internal + + A wrapper class for the void ** arguments array used by the meta + object system. If a slot uses a single argument of this type, + the meta object system will pass the raw arguments array directly + to the slot and set the arguments count in the slot description to + zero, so that any signal can connect to it. + + This is used internally to implement signal relay functionality in + our state machine and dbus. +*/ + + +/*! \macro QGenericArgument Q_ARG(Type, const Type &value) \relates QMetaObject |