aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qqmlcodegenerator.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-01-24 12:01:33 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-27 13:09:40 +0100
commita1ee538395198f998a73f3ef7545392aeb680900 (patch)
tree0a247a19c52dd65d8f14cd221743213670ec8036 /src/qml/compiler/qqmlcodegenerator.cpp
parent9a5568a1972b72b32ae3058903cc7f4d7123b96b (diff)
[new compiler] Fix support for namespaces in attached properties
When doing import QtQml 2.0 as MyQml with MyQml.Component.onComplete: ... We now store "MyQml.Component" as one string as the type name, in order to get resolved correctly. Change-Id: I11a6def88bcb8b98b5fa9548053e27fb58170e62 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qqmlcodegenerator.cpp')
-rw-r--r--src/qml/compiler/qqmlcodegenerator.cpp37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/qml/compiler/qqmlcodegenerator.cpp b/src/qml/compiler/qqmlcodegenerator.cpp
index 2ba13be090..0c63f1e069 100644
--- a/src/qml/compiler/qqmlcodegenerator.cpp
+++ b/src/qml/compiler/qqmlcodegenerator.cpp
@@ -950,20 +950,33 @@ bool QQmlCodeGenerator::setId(AST::Statement *value)
bool QQmlCodeGenerator::resolveQualifiedId(AST::UiQualifiedId **nameToResolve, QmlObject **object)
{
- AST::UiQualifiedId *name = *nameToResolve;
-
- if (name->name == QStringLiteral("id") && name->next)
- COMPILE_EXCEPTION(name->identifierToken, tr( "Invalid use of id property"));
+ AST::UiQualifiedId *qualifiedIdElement = *nameToResolve;
+
+ if (qualifiedIdElement->name == QStringLiteral("id") && qualifiedIdElement->next)
+ COMPILE_EXCEPTION(qualifiedIdElement->identifierToken, tr( "Invalid use of id property"));
+
+ // If it's a namespace, prepend the qualifier and we'll resolve it later to the correct type.
+ QString currentName = qualifiedIdElement->name.toString();
+ if (qualifiedIdElement->next) {
+ foreach (QV4::CompiledData::Import* import, _imports)
+ if (import->qualifierIndex != emptyStringIndex
+ && stringAt(import->qualifierIndex) == currentName) {
+ qualifiedIdElement = qualifiedIdElement->next;
+ currentName += QLatin1Char('.');
+ currentName += qualifiedIdElement->name;
+ break;
+ }
+ }
*object = _object;
- while (name->next) {
+ while (qualifiedIdElement->next) {
Binding *binding = New<Binding>();
- binding->propertyNameIndex = registerString(name->name.toString());
- binding->location.line = name->identifierToken.startLine;
- binding->location.column = name->identifierToken.startColumn;
+ binding->propertyNameIndex = registerString(currentName);
+ binding->location.line = qualifiedIdElement->identifierToken.startLine;
+ binding->location.column = qualifiedIdElement->identifierToken.startColumn;
binding->flags = 0;
- if (name->name.unicode()->isUpper())
+ if (qualifiedIdElement->name.unicode()->isUpper())
binding->type = QV4::CompiledData::Binding::Type_AttachedProperty;
else
binding->type = QV4::CompiledData::Binding::Type_GroupProperty;
@@ -974,9 +987,11 @@ bool QQmlCodeGenerator::resolveQualifiedId(AST::UiQualifiedId **nameToResolve, Q
(*object)->bindings->append(binding);
*object = _objects[objIndex];
- name = name->next;
+ qualifiedIdElement = qualifiedIdElement->next;
+ if (qualifiedIdElement)
+ currentName = qualifiedIdElement->name.toString();
}
- *nameToResolve = name;
+ *nameToResolve = qualifiedIdElement;
return true;
}