summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlscriptparser.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-07-01 13:48:41 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-07-02 00:54:54 (GMT)
commitecd07750a74111ed9ef65a7439ddccc065c5dadc (patch)
tree96422a2eca0a2ad2900027ee34df251a7a96890b /src/declarative/qml/qmlscriptparser.cpp
parent5118020e63f5e634a74082c417362d735a7a2303 (diff)
downloadQt-ecd07750a74111ed9ef65a7439ddccc065c5dadc.zip
Qt-ecd07750a74111ed9ef65a7439ddccc065c5dadc.tar.gz
Qt-ecd07750a74111ed9ef65a7439ddccc065c5dadc.tar.bz2
Add parameterized synthesized signals
Also changed syntax for emitting a signal to be consistent with normal QtScript.
Diffstat (limited to 'src/declarative/qml/qmlscriptparser.cpp')
-rw-r--r--src/declarative/qml/qmlscriptparser.cpp60
1 files changed, 42 insertions, 18 deletions
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp
index f1f1710..880b64b 100644
--- a/src/declarative/qml/qmlscriptparser.cpp
+++ b/src/declarative/qml/qmlscriptparser.cpp
@@ -481,35 +481,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) {