diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-11-27 13:46:58 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-29 19:11:02 +0100 |
commit | 0aadcf8077840068eb182269e9ed9c31ad12f45e (patch) | |
tree | 83eb200fc92ec32916c9ed88a1428cef8b00700d /src/qml/qml/qqmlcompiler_p.h | |
parent | dd1bd3b01b506a05b475514fb2ba7e387f7b17fa (diff) |
Add support pre-compiled bindings for QML custom parsers
For example the x property in
PropertyChanges {
target: foo
x: someItem.x - other.width / 2
}
was compiled at run-time dynamically, which produces slower code (no type
information available) and slows down the type instantiation, because the
compilation happens every time at instantiation time (or later).
With this change, when the custom parser behind PropertyChanges requests a
binding ID for "x", the right hand side will be added to the bindings to
compile, then compiled and later at run-time the QQmlBinding constructor that
takes a QQmlBinding::Identifier can retrieve the correct compiled function from
the QV4::CompiledData::CompilationUnit.
Change-Id: I857fb2d39e82714b225bc9394b9904b795c6662b
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 | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlcompiler_p.h b/src/qml/qml/qqmlcompiler_p.h index 05c877d98b..443a80d95c 100644 --- a/src/qml/qml/qqmlcompiler_p.h +++ b/src/qml/qml/qqmlcompiler_p.h @@ -150,6 +150,7 @@ 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; + QVector<int> customParserBindings; // index is binding identifier, value is compiled function index. bool isComponent(int objectIndex) const { return objectIndexToIdPerComponent.contains(objectIndex); } bool isCompositeType() const { return !datas.at(qmlUnit->indexOfRootObject).isEmpty(); } @@ -231,7 +232,7 @@ namespace QQmlCompilerTypes { QQmlScript::Value *value; int compiledIndex : 16; - int sharedIndex : 16; + int customParserBindingsIndex : 16; BindingContext bindingContext; @@ -340,7 +341,7 @@ public: int evaluateEnum(const QHashedStringRef &scope, const QByteArray& enumValue, bool *ok) const; // for QQmlCustomParser::evaluateEnum const QMetaObject *resolveType(const QString& name) const; // for QQmlCustomParser::resolveType - int bindingIdentifier(const QQmlScript::Variant& value); // for QQmlCustomParser::bindingIndex + int bindingIdentifier(const QString &name, const QQmlScript::Variant& value, const QQmlCompilerTypes::BindingContext &ctxt); // for QQmlCustomParser::bindingIndex private: typedef QQmlCompiledData::Instruction Instruction; |