diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-04-25 16:19:02 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-06-04 08:25:52 +0200 |
commit | 52e07d564b65ed6ce26955a676c7692ad67686c1 (patch) | |
tree | 04354cdf1d56776e9b52819f4329b70c57e235dc /src/qml/qml/qqmlcompiler_p.h | |
parent | 481447ae664fa2998cb03f93f0c066caa2782bf0 (diff) |
Rework custom parser integration
The custom parser design used to be so that the custom parser operates on the "AST",
creates its own binary representation of the data it needs, stores it in a QByteArray
and gets that at object instantiation time. That meant serializing everything necessary.
With the introduction of the "binary" QML data structure, that process of serialization
becomes obsolete and would require extra work in the custom parsers for example for QQuickStates
to store the translation parameters.
The clean solution is to eliminate this unnecessary serialization process and
instead let the custom parsers do a verification pass at type compile time and
then simply operate directly on the QV4::CompiledData::Bindings at object
instantiation time. That simplifies the code, and allows for support of
translations throughout all list model properties.
Additionally this speeds up the creation of state objects and reduces memory
consumption. Previously a text: qsTr("foo") binding in states would result in
an actual java script binding. After this patch it is merely stored as a string
and translated at object instantiation time.
Change-Id: I7550274513f54abb09a0ab4de51c4c0bcdb23cae
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlcompiler_p.h')
-rw-r--r-- | src/qml/qml/qqmlcompiler_p.h | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/src/qml/qml/qqmlcompiler_p.h b/src/qml/qml/qqmlcompiler_p.h index f3b6f621ce..9f0f80063b 100644 --- a/src/qml/qml/qqmlcompiler_p.h +++ b/src/qml/qml/qqmlcompiler_p.h @@ -136,13 +136,8 @@ public: // index in first hash is component index, hash inside maps from object index in that scope to integer id QHash<int, QHash<int, int> > objectIndexToIdPerComponent; QHash<int, int> objectIndexToIdForRoot; - // hash key is object index - struct CustomParserData { - QByteArray compilationArtifact; // produced by custom parser - QBitArray bindings; // bindings covered by the custom parser - }; - QHash<int, CustomParserData> customParserData; - QVector<int> customParserBindings; // index is binding identifier, value is compiled function index. + // hash key is object index, value is indicies of bindings covered by custom parser + QHash<int, QBitArray> customParserBindings; QHash<int, QBitArray> deferredBindingsPerObject; // index is object index int totalBindingsCount; // Number of bindings used in this type int totalParserStatusCount; // Number of instantiated types that are QQmlParserStatus subclasses @@ -154,9 +149,6 @@ public: bool isInitialized() const { return hasEngine(); } void initialize(QQmlEngine *); - QV4::Function *functionForBindingId(int bindingId) const - { return compilationUnit->runtimeFunctions[customParserBindings[bindingId]]; } - protected: virtual void destroy(); // From QQmlRefCount virtual void clear(); // From QQmlCleanup |