diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-09-17 17:27:07 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-20 14:27:10 +0200 |
commit | 8d441936d2e8ab8c39a66831a658c192b80ca597 (patch) | |
tree | 61d71c983c685551d403c5b9b91b0e9075c40fc1 /src/qml/qml/qqmlobjectcreator_p.h | |
parent | c5a8d5b331352e9a1a0a4be7571add641b22238c (diff) |
[new compiler] Initial support for components
We use a dedicated pass through the objects in QV4::CompiledData::QmlUnit to determine
which objects are QQmlComponents. We remember their object indices as well as to which
component other objects belong to (if any).
Change-Id: I97929c57e2ccb2fd380d612002d128359c4bc253
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlobjectcreator_p.h')
-rw-r--r-- | src/qml/qml/qqmlobjectcreator_p.h | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/src/qml/qml/qqmlobjectcreator_p.h b/src/qml/qml/qqmlobjectcreator_p.h index eb7a6233c5..e0aefaf81d 100644 --- a/src/qml/qml/qqmlobjectcreator_p.h +++ b/src/qml/qml/qqmlobjectcreator_p.h @@ -80,24 +80,44 @@ protected: QHash<int, QQmlCompiledData::TypeReference> *resolvedTypes; }; +class QQmlAnonymousComponentResolver : public QQmlCompilePass +{ + Q_DECLARE_TR_FUNCTIONS(QQmlAnonymousComponentResolver) +public: + QQmlAnonymousComponentResolver(const QUrl &url, const QV4::CompiledData::QmlUnit *qmlUnit, + const QHash<int, QQmlCompiledData::TypeReference> &resolvedTypes, + const QList<QQmlPropertyCache *> &propertyCaches); + + bool resolve(); + + QVector<int> componentRoots; + QHash<int, int> objectIndexToComponentIndex; + +protected: + bool recordComponentSubTree(int objectIndex); + + int _componentIndex; + QSet<int> _ids; + + const QHash<int, QQmlCompiledData::TypeReference> resolvedTypes; + const QList<QQmlPropertyCache *> propertyCaches; +}; + class QmlObjectCreator : public QQmlCompilePass { Q_DECLARE_TR_FUNCTIONS(QmlObjectCreator) public: - QmlObjectCreator(QQmlContextData *contextData, const QV4::CompiledData::QmlUnit *qmlUnit, const QV4::CompiledData::CompilationUnit *jsUnit, - const QHash<int, QQmlCompiledData::TypeReference> &resolvedTypes, const QList<QQmlPropertyCache *> &propertyCaches, const QList<QByteArray> &vmeMetaObjectData, - const QHash<int, int> &objectIndexToId); - - QObject *create(QObject *parent = 0) - { return create(qmlUnit->indexOfRootObject, parent); } - QObject *create(int index, QObject *parent = 0); + QmlObjectCreator(QQmlContextData *contextData, QQmlCompiledData *compiledData); + QObject *create(int subComponentIndex, QObject *parent = 0); void finalize(); QQmlComponentAttached *componentAttached; QList<QQmlEnginePrivate::FinalizeCallback> finalizeCallbacks; private: + QObject *createInstance(int index, QObject *parent = 0); + bool populateInstance(int index, QObject *instance, QQmlRefPointer<QQmlPropertyCache> cache); void setupBindings(); @@ -107,12 +127,14 @@ private: QQmlEngine *engine; const QV4::CompiledData::CompilationUnit *jsUnit; + QQmlContextData *parentContext; QQmlContextData *context; const QHash<int, QQmlCompiledData::TypeReference> resolvedTypes; const QList<QQmlPropertyCache *> propertyCaches; const QList<QByteArray> vmeMetaObjectData; - const QHash<int, int> &objectIndexToId; + QHash<int, int> objectIndexToId; QLinkedList<QVector<QQmlAbstractBinding*> > allCreatedBindings; + QQmlCompiledData *compiledData; QObject *_qobject; const QV4::CompiledData::Object *_compiledObject; |