summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlcompiler.cpp
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-10-11 22:48:10 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-10-11 22:48:10 (GMT)
commit76b29d542e13184da81129ea3f7373ffd71ceedc (patch)
treec18a7af8ae2f70d6fcda5b74cd00161241596beb /src/declarative/qml/qmlcompiler.cpp
parentac507b4752dcd065038130d224910a6dc64f8f37 (diff)
parent76448b41bb9c6212d2534f0597f9973c881c77bd (diff)
downloadQt-76b29d542e13184da81129ea3f7373ffd71ceedc.zip
Qt-76b29d542e13184da81129ea3f7373ffd71ceedc.tar.gz
Qt-76b29d542e13184da81129ea3f7373ffd71ceedc.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/declarative/qml/qmlcompiler.cpp')
-rw-r--r--src/declarative/qml/qmlcompiler.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 71f86d9..6fad513 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -833,6 +833,8 @@ void QmlCompiler::genObject(QmlParser::Object *obj)
QmlInstruction script;
script.type = QmlInstruction::StoreScript;
script.line = -1; // ###
+ script.storeScript.fileName = output->indexForString(obj->scriptBlocksFile.at(ii));
+ script.storeScript.lineNumber = obj->scriptBlocksLineNumber.at(ii);
script.storeScript.value = output->indexForString(obj->scriptBlocks.at(ii));
output->bytecode << script;
}
@@ -1054,6 +1056,8 @@ bool QmlCompiler::buildComponent(QmlParser::Object *obj,
bool QmlCompiler::buildScript(QmlParser::Object *obj, QmlParser::Object *script)
{
QString scriptCode;
+ QString sourceUrl;
+ int lineNumber = 1;
if (script->properties.count() == 1 &&
script->properties.begin().key() == QByteArray("source")) {
@@ -1066,8 +1070,7 @@ bool QmlCompiler::buildScript(QmlParser::Object *obj, QmlParser::Object *script)
source->values.at(0)->object || !source->values.at(0)->value.isString())
COMPILE_EXCEPTION(source, "Invalid Script source value");
- QString sourceUrl =
- output->url.resolved(QUrl(source->values.at(0)->value.asString())).toString();
+ sourceUrl = output->url.resolved(QUrl(source->values.at(0)->value.asString())).toString();
for (int ii = 0; ii < unit->resources.count(); ++ii) {
if (unit->resources.at(ii)->url == sourceUrl) {
@@ -1079,10 +1082,14 @@ bool QmlCompiler::buildScript(QmlParser::Object *obj, QmlParser::Object *script)
} else if (!script->properties.isEmpty()) {
COMPILE_EXCEPTION(*script->properties.begin(), "Properties cannot be set on Script block");
} else if (script->defaultProperty) {
+ sourceUrl = output->url.toString();
+
QmlParser::Location currentLocation;
for (int ii = 0; ii < script->defaultProperty->values.count(); ++ii) {
Value *v = script->defaultProperty->values.at(ii);
+ if (lineNumber == 1)
+ lineNumber = v->location.start.line;
if (v->object || !v->value.isString())
COMPILE_EXCEPTION(v, "Invalid Script block");
@@ -1105,8 +1112,11 @@ bool QmlCompiler::buildScript(QmlParser::Object *obj, QmlParser::Object *script)
}
}
- if (!scriptCode.isEmpty())
+ if (!scriptCode.isEmpty()) {
obj->scriptBlocks.append(scriptCode);
+ obj->scriptBlocksFile.append(sourceUrl);
+ obj->scriptBlocksLineNumber.append(lineNumber);
+ }
return true;
}
@@ -2272,10 +2282,13 @@ bool QmlCompiler::compileAlias(QMetaObjectBuilder &builder,
data.append((const char *)&idObject->idIndex, sizeof(idObject->idIndex));
data.append((const char *)&propIdx, sizeof(propIdx));
+ const char *typeName = aliasProperty.typeName();
+ if (aliasProperty.isEnumType())
+ typeName = "int"; // Avoid introducing a dependency on the aliased metaobject
+
builder.addSignal(prop.name + "Changed()");
QMetaPropertyBuilder propBuilder =
- builder.addProperty(prop.name, aliasProperty.typeName(),
- builder.methodCount() - 1);
+ builder.addProperty(prop.name, typeName, builder.methodCount() - 1);
propBuilder.setScriptable(true);
return true;
}
@@ -2351,7 +2364,7 @@ void QmlCompiler::genBindingAssignment(QmlParser::Value *binding,
store.assignBinding.value = output->indexForByteArray(ref.compiledData);
store.assignBinding.context = ref.bindingContext.stack;
store.assignBinding.owner = ref.bindingContext.owner;
- store.line = prop->location.end.line;
+ store.line = binding->location.start.line;
Q_ASSERT(ref.bindingContext.owner == 0 ||
(ref.bindingContext.owner != 0 && valueTypeProperty));