diff options
author | Simon Hausmann <[email protected]> | 2014-03-06 16:19:42 +0100 |
---|---|---|
committer | The Qt Project <[email protected]> | 2014-03-11 18:31:21 +0100 |
commit | 914b72418b7e766026f2679254fcee93fc920866 (patch) | |
tree | 202634bd203c830ddc7eeb7dab1d071ca506b8a3 /src/qml/compiler/qv4compileddata_p.h | |
parent | af7ba8a6194b83fe7380b8d4ae027e2f04e21f17 (diff) |
Add support for resolving translation bindings at compile time
Simple calls to qsTr and qsTrId are detected at type compile time and
reduced to a special Translation and TranslationById binding type, which
avoids allocating a QML binding at type instantiation type just to perform
a translation.
Change-Id: I61e4f2db2a8092b5e6870e174b832d9c20cd62b5
Reviewed-by: Lars Knoll <[email protected]>
Diffstat (limited to 'src/qml/compiler/qv4compileddata_p.h')
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 2d6e767ff3..186363dcde 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -280,6 +280,11 @@ struct Function // Qml data structures +struct Q_QML_EXPORT TranslationData { + quint32 commentIndex; + int number; +}; + struct Q_QML_EXPORT Binding { quint32 propertyNameIndex; @@ -289,6 +294,8 @@ struct Q_QML_EXPORT Binding Type_Boolean, Type_Number, Type_String, + Type_Translation, + Type_TranslationById, Type_Script, Type_Object, Type_AttachedProperty, @@ -312,8 +319,9 @@ struct Q_QML_EXPORT Binding double d; quint32 compiledScriptIndex; // used when Type_Script quint32 objectIndex; + TranslationData translationData; // used when Type_Translation } value; - quint32 stringIndex; // Set for Type_String and Type_Script (the latter because of script strings) + quint32 stringIndex; // Set for Type_String, Type_Translation and Type_Script (the latter because of script strings) Location location; Location valueLocation; @@ -365,6 +373,8 @@ struct Q_QML_EXPORT Binding return false; } + bool evaluatesToString() const { return type == Type_String || type == Type_Translation || type == Type_TranslationById; } + QString valueAsString(const Unit *unit) const; QString valueAsScriptString(const Unit *unit) const; double valueAsNumber() const |