diff options
Diffstat (limited to 'src/qml/qml/qqmlpropertycache_p.h')
-rw-r--r-- | src/qml/qml/qqmlpropertycache_p.h | 54 |
1 files changed, 40 insertions, 14 deletions
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h index 64be1cb206..6cdb82bd46 100644 --- a/src/qml/qml/qqmlpropertycache_p.h +++ b/src/qml/qml/qqmlpropertycache_p.h @@ -288,8 +288,8 @@ public: inline bool operator==(const QQmlPropertyRawData &); - static Flags flagsForProperty(const QMetaProperty &, QQmlEngine *engine = 0); - void load(const QMetaProperty &, QQmlEngine *engine = 0); + static Flags flagsForProperty(const QMetaProperty &); + void load(const QMetaProperty &); void load(const QMetaMethod &); QString name(QObject *) const; QString name(const QMetaObject *) const; @@ -349,12 +349,26 @@ private: bool notFullyResolved() const { return _flags.notFullyResolved; } }; +struct QQmlEnumValue +{ + QQmlEnumValue() : value(-1) {} + QQmlEnumValue(const QString &n, int v) : namedValue(n), value(v) {} + QString namedValue; + int value; +}; + +struct QQmlEnumData +{ + QString name; + QVector<QQmlEnumValue> values; +}; + class QQmlPropertyCacheMethodArguments; -class Q_QML_PRIVATE_EXPORT QQmlPropertyCache : public QQmlRefCount, public QQmlCleanup +class Q_QML_PRIVATE_EXPORT QQmlPropertyCache : public QQmlRefCount { public: - QQmlPropertyCache(QV4::ExecutionEngine *); - QQmlPropertyCache(QV4::ExecutionEngine *, const QMetaObject *); + QQmlPropertyCache(); + QQmlPropertyCache(const QMetaObject *); virtual ~QQmlPropertyCache(); void update(const QMetaObject *); @@ -374,13 +388,14 @@ public: QQmlPropertyRawData::Flags signalFlags = QQmlPropertyData::Flags()); QQmlPropertyCache *copyAndReserve(int propertyCount, - int methodCount, int signalCount); + int methodCount, int signalCount, int enumCount); void appendProperty(const QString &, QQmlPropertyRawData::Flags flags, int coreIndex, int propType, int notifyIndex); void appendSignal(const QString &, QQmlPropertyRawData::Flags, int coreIndex, const int *types = 0, const QList<QByteArray> &names = QList<QByteArray>()); void appendMethod(const QString &, QQmlPropertyData::Flags flags, int coreIndex, const QList<QByteArray> &names = QList<QByteArray>()); + void appendEnum(const QString &, const QVector<QQmlEnumValue> &); const QMetaObject *metaObject() const; const QMetaObject *createMetaObject(); @@ -395,6 +410,7 @@ public: QQmlPropertyData *property(int) const; QQmlPropertyData *method(int) const; QQmlPropertyData *signal(int index) const; + QQmlEnumData *qmlEnum(int) const; int methodIndexToSignalIndex(int) const; QString defaultPropertyName() const; @@ -434,6 +450,7 @@ public: inline int methodOffset() const; inline int signalCount() const; inline int signalOffset() const; + inline int qmlEnumCount() const; static bool isDynamicMetaObject(const QMetaObject *); @@ -445,11 +462,6 @@ public: static bool addToHash(QCryptographicHash &hash, const QMetaObject &mo); QByteArray checksum(bool *ok); - -protected: - void destroy() override; - void clear() override; - private: friend class QQmlEnginePrivate; friend class QQmlCompiler; @@ -457,6 +469,7 @@ private: template <typename T> friend class QQmlPropertyCacheAliasCreator; friend class QQmlComponentAndAliasResolver; friend class QQmlMetaObject; + friend struct QQmlMetaTypeData; inline QQmlPropertyCache *copy(int reserve); @@ -493,9 +506,6 @@ private: _hasPropertyOverrides |= isOverride; } -public: - QV4::ExecutionEngine *engine; - private: QQmlPropertyCache *_parent; int propertyIndexCacheStart; @@ -507,6 +517,7 @@ private: IndexCache signalHandlerIndexCache; StringCache stringCache; AllowedRevisionCache allowedRevisionCache; + QVector<QQmlEnumData> enumCache; bool _hasPropertyOverrides : 1; bool _ownMetaObject : 1; @@ -519,6 +530,8 @@ private: QByteArray _checksum; }; +typedef QQmlRefPointer<QQmlPropertyCache> QQmlPropertyCachePtr; + // QQmlMetaObject serves as a wrapper around either QMetaObject or QQmlPropertyCache. // This is necessary as we delay creation of QMetaObject for synthesized QObjects, but // we don't want to needlessly generate QQmlPropertyCaches every time we encounter a @@ -747,6 +760,14 @@ inline QQmlPropertyData *QQmlPropertyCache::signal(int index) const return ensureResolved(rv); } +inline QQmlEnumData *QQmlPropertyCache::qmlEnum(int index) const +{ + if (index < 0 || index >= enumCache.count()) + return 0; + + return const_cast<QQmlEnumData *>(&enumCache.at(index)); +} + inline int QQmlPropertyCache::methodIndexToSignalIndex(int index) const { if (index < 0 || index >= (methodIndexCacheStart + methodIndexCache.count())) @@ -817,6 +838,11 @@ int QQmlPropertyCache::signalOffset() const return signalHandlerIndexCacheStart; } +int QQmlPropertyCache::qmlEnumCount() const +{ + return enumCache.count(); +} + bool QQmlPropertyCache::callJSFactoryMethod(QObject *object, void **args) const { if (_jsFactoryMethodIndex != -1) { |