diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2009-07-02 02:41:09 (GMT) |
---|---|---|
committer | Yann Bodson <yann.bodson@nokia.com> | 2009-07-02 02:41:09 (GMT) |
commit | 305de45a8d184738dc07fb7e5c787b9dbb5b3c6b (patch) | |
tree | 69895c47e21836612460bf4d60ed3a6ac33b8ef7 /src/declarative/qml/qmlscriptparser.cpp | |
parent | cf8871a52244884943c2d798dbe93fb181728bcd (diff) | |
parent | 49c339cfebdab26e6239335a45ca9f3e852f254b (diff) | |
download | Qt-305de45a8d184738dc07fb7e5c787b9dbb5b3c6b.zip Qt-305de45a8d184738dc07fb7e5c787b9dbb5b3c6b.tar.gz Qt-305de45a8d184738dc07fb7e5c787b9dbb5b3c6b.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/qml/qmlscriptparser.cpp')
-rw-r--r-- | src/declarative/qml/qmlscriptparser.cpp | 60 |
1 files changed, 42 insertions, 18 deletions
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index b957499..7475943 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -479,35 +479,59 @@ bool ProcessAST::visit(AST::UiImport *node) bool ProcessAST::visit(AST::UiPublicMember *node) { + const struct TypeNameToType { + const char *name; + Object::DynamicProperty::Type type; + const char *qtName; + } propTypeNameToTypes[] = { + { "int", Object::DynamicProperty::Int, "int" }, + { "bool", Object::DynamicProperty::Bool, "bool" }, + { "double", Object::DynamicProperty::Real, "double" }, + { "real", Object::DynamicProperty::Real, "qreal" }, + { "string", Object::DynamicProperty::String, "QString" }, + { "url", Object::DynamicProperty::Url, "QUrl" }, + { "color", Object::DynamicProperty::Color, "QColor" }, + { "date", Object::DynamicProperty::Date, "QDate" }, + { "var", Object::DynamicProperty::Variant, "QVariant" }, + { "variant", Object::DynamicProperty::Variant, "QVariant" } + }; + const int propTypeNameToTypesCount = sizeof(propTypeNameToTypes) / + sizeof(propTypeNameToTypes[0]); + if(node->type == AST::UiPublicMember::Signal) { const QString name = node->name->asString(); Object::DynamicSignal signal; signal.name = name.toUtf8(); + AST::UiParameterList *p = node->parameters; + while (p) { + const QString memberType = p->type->asString(); + const char *qtType = 0; + for(int ii = 0; !qtType && ii < propTypeNameToTypesCount; ++ii) { + if(QLatin1String(propTypeNameToTypes[ii].name) == memberType) + qtType = propTypeNameToTypes[ii].qtName; + } + + if (!qtType) { + QmlError error; + error.setDescription(QCoreApplication::translate("QmlParser","Expected parameter type")); + error.setLine(node->typeToken.startLine); + error.setColumn(node->typeToken.startColumn); + _parser->_errors << error; + return false; + } + + signal.parameterTypes << qtType; + signal.parameterNames << p->name->asString().toUtf8(); + p = p->finish(); + } + _stateStack.top().object->dynamicSignals << signal; } else { const QString memberType = node->memberType->asString(); const QString name = node->name->asString(); - const struct TypeNameToType { - const char *name; - Object::DynamicProperty::Type type; - } propTypeNameToTypes[] = { - { "int", Object::DynamicProperty::Int }, - { "bool", Object::DynamicProperty::Bool }, - { "double", Object::DynamicProperty::Real }, - { "real", Object::DynamicProperty::Real }, - { "string", Object::DynamicProperty::String }, - { "url", Object::DynamicProperty::Url }, - { "color", Object::DynamicProperty::Color }, - { "date", Object::DynamicProperty::Date }, - { "var", Object::DynamicProperty::Variant }, - { "variant", Object::DynamicProperty::Variant } - }; - const int propTypeNameToTypesCount = sizeof(propTypeNameToTypes) / - sizeof(propTypeNameToTypes[0]); - bool typeFound = false; Object::DynamicProperty::Type type; for(int ii = 0; !typeFound && ii < propTypeNameToTypesCount; ++ii) { |