From 49b10375dc9b5602bc83dbc4329c1e4c3881d226 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 28 Apr 2010 13:18:56 +1000 Subject: Small cleanups --- src/declarative/qml/qdeclarativeparser_p.h | 3 - src/declarative/qml/qdeclarativescriptparser.cpp | 75 ++++++------------------ 2 files changed, 19 insertions(+), 59 deletions(-) diff --git a/src/declarative/qml/qdeclarativeparser_p.h b/src/declarative/qml/qdeclarativeparser_p.h index 0870cfb..25777f5 100644 --- a/src/declarative/qml/qdeclarativeparser_p.h +++ b/src/declarative/qml/qdeclarativeparser_p.h @@ -188,9 +188,6 @@ namespace QDeclarativeParser QList lineNumbers; QList pragmas; }; -#if 0 - QList scripts; -#endif // The bytes to cast instances by to get to the QDeclarativeParserStatus // interface. -1 indicates the type doesn't support this interface. diff --git a/src/declarative/qml/qdeclarativescriptparser.cpp b/src/declarative/qml/qdeclarativescriptparser.cpp index 8b96733..219d759 100644 --- a/src/declarative/qml/qdeclarativescriptparser.cpp +++ b/src/declarative/qml/qdeclarativescriptparser.cpp @@ -104,17 +104,13 @@ public: void operator()(const QString &code, AST::Node *node); protected: + Object *defineObjectBinding(AST::UiQualifiedId *propertyName, bool onAssignment, - AST::UiQualifiedId *objectTypeName, + const QString &objectType, + AST::SourceLocation typeLocation, LocationSpan location, AST::UiObjectInitializer *initializer = 0); - Object *defineObjectBinding_helper(AST::UiQualifiedId *propertyName, bool onAssignment, - const QString &objectType, - AST::SourceLocation typeLocation, - LocationSpan location, - AST::UiObjectInitializer *initializer = 0); - QDeclarativeParser::Variant getVariant(AST::ExpressionNode *expr); LocationSpan location(AST::SourceLocation start, AST::SourceLocation end); @@ -240,12 +236,12 @@ QString ProcessAST::asString(AST::UiQualifiedId *node) const } Object * -ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName, - bool onAssignment, - const QString &objectType, - AST::SourceLocation typeLocation, - LocationSpan location, - AST::UiObjectInitializer *initializer) +ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName, + bool onAssignment, + const QString &objectType, + AST::SourceLocation typeLocation, + LocationSpan location, + AST::UiObjectInitializer *initializer) { int lastTypeDot = objectType.lastIndexOf(QLatin1Char('.')); bool isType = !objectType.isEmpty() && @@ -355,41 +351,6 @@ ProcessAST::defineObjectBinding_helper(AST::UiQualifiedId *propertyName, } } -Object *ProcessAST::defineObjectBinding(AST::UiQualifiedId *qualifiedId, bool onAssignment, - AST::UiQualifiedId *objectTypeName, - LocationSpan location, - AST::UiObjectInitializer *initializer) -{ - const QString objectType = asString(objectTypeName); - const AST::SourceLocation typeLocation = objectTypeName->identifierToken; - - if (objectType == QLatin1String("Script")) { - - AST::UiObjectMemberList *it = initializer->members; - for (; it; it = it->next) { - AST::UiScriptBinding *scriptBinding = AST::cast(it->member); - if (! scriptBinding) - continue; - - QString propertyName = asString(scriptBinding->qualifiedId); - if (propertyName == QLatin1String("source")) { - if (AST::ExpressionStatement *stmt = AST::cast(scriptBinding->statement)) { - QDeclarativeParser::Variant string = getVariant(stmt->expression); - if (string.isStringList()) { - QStringList urls = string.asStringList(); - // We need to add this as a resource - for (int ii = 0; ii < urls.count(); ++ii) - _parser->_refUrls << QUrl(urls.at(ii)); - } - } - } - } - - } - - return defineObjectBinding_helper(qualifiedId, onAssignment, objectType, typeLocation, location, initializer); -} - LocationSpan ProcessAST::location(AST::UiQualifiedId *id) { return location(id->identifierToken, id->identifierToken); @@ -664,10 +625,11 @@ bool ProcessAST::visit(AST::UiObjectDefinition *node) LocationSpan l = location(node->firstSourceLocation(), node->lastSourceLocation()); - defineObjectBinding(/*propertyName = */ 0, false, - node->qualifiedTypeNameId, - l, - node->initializer); + const QString objectType = asString(node->qualifiedTypeNameId); + const AST::SourceLocation typeLocation = node->qualifiedTypeNameId->identifierToken; + + defineObjectBinding(/*propertyName = */ 0, false, objectType, + typeLocation, l, node->initializer); return false; } @@ -679,10 +641,11 @@ bool ProcessAST::visit(AST::UiObjectBinding *node) LocationSpan l = location(node->qualifiedTypeNameId->identifierToken, node->initializer->rbraceToken); - defineObjectBinding(node->qualifiedId, node->hasOnToken, - node->qualifiedTypeNameId, - l, - node->initializer); + const QString objectType = asString(node->qualifiedTypeNameId); + const AST::SourceLocation typeLocation = node->qualifiedTypeNameId->identifierToken; + + defineObjectBinding(node->qualifiedId, node->hasOnToken, objectType, + typeLocation, l, node->initializer); return false; } -- cgit v0.12