diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-07-02 03:11:43 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-07-02 03:11:43 (GMT) |
commit | 8aba610c22c44bf36eb2e539a06b65753c48bbc2 (patch) | |
tree | a09af5ec3edd87ffcf041fe030135e58d49cb520 /src/declarative/qml/qmlscriptparser.cpp | |
parent | dafd625842e2c66551857810a3660c534962746e (diff) | |
parent | 305de45a8d184738dc07fb7e5c787b9dbb5b3c6b (diff) | |
download | Qt-8aba610c22c44bf36eb2e539a06b65753c48bbc2.zip Qt-8aba610c22c44bf36eb2e539a06b65753c48bbc2.tar.gz Qt-8aba610c22c44bf36eb2e539a06b65753c48bbc2.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 1f31e54..a256978 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) { |