/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
**
** This file is part of the QtDeclarative module of the Qt Toolkit.
**
**
**
**
+**
** $QT_END_LICENSE$
**
****************************************************************************/
}
QDeclarativeScript::Value::Value()
-: type(Unknown), object(0), bindingReference(0), signalExpressionContextStack(0), nextValue(0)
+: type(Unknown), object(0), bindingReference(0), nextValue(0)
{
}
AST::UiObjectInitializer *initializer)
{
int lastTypeDot = objectType.lastIndexOf(QLatin1Char('.'));
- bool isType = !objectType.isEmpty() &&
- (objectType.at(0).isUpper() ||
- (lastTypeDot >= 0 && objectType.at(lastTypeDot+1).isUpper()));
+
+ // With no preceding qualification, first char is at (-1 + 1) == 0
+ bool isType = !objectType.isEmpty() && objectType.at(lastTypeDot+1).isUpper();
int propertyCount = 0;
for (AST::UiQualifiedId *name = propertyName; name; name = name->next){
if (!isType) {
- if(propertyCount || !currentObject()) {
+ // Is the identifier qualified by a namespace?
+ int namespaceLength = 0;
+ if (lastTypeDot > 0) {
+ const QString qualifier(objectType.left(lastTypeDot));
+
+ for (int ii = 0; ii < _parser->_imports.count(); ++ii) {
+ const QDeclarativeScript::Import &import = _parser->_imports.at(ii);
+ if (import.qualifier == qualifier) {
+ // The qualifier is a namespace - expect a type here
+ namespaceLength = qualifier.length() + 1;
+ break;
+ }
+ }
+ }
+
+ if (propertyCount || !currentObject() || namespaceLength) {
QDeclarativeError error;
error.setDescription(QCoreApplication::translate("QDeclarativeParser","Expected type name"));
error.setLine(typeLocation.startLine);
- error.setColumn(typeLocation.startColumn);
+ error.setColumn(typeLocation.startColumn + namespaceLength);
_parser->_errors << error;
return 0;
}
property->isDefaultProperty = node->isDefaultMember;
property->isReadOnly = node->isReadonlyMember;
property->type = type;
+ property->nameLocation.line = node->identifierToken.startLine;
+ property->nameLocation.column = node->identifierToken.startColumn;
if (type >= Object::DynamicProperty::Custom) {
QDeclarativeScript::TypeReference *typeRef =
_parser->findOrCreateType(memberType.toString());
if (AST::FunctionDeclaration *funDecl = AST::cast<AST::FunctionDeclaration *>(node->sourceElement)) {
Object::DynamicSlot *slot = _parser->_pool.New<Object::DynamicSlot>();
- slot->location = location(funDecl->firstSourceLocation(), funDecl->lastSourceLocation());
+ slot->location = location(funDecl->identifierToken, funDecl->lastSourceLocation());
AST::FormalParameterList *f = funDecl->formals;
while (f) {