summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlcompiler.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-10-22 03:01:04 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-10-22 03:01:04 (GMT)
commit6425ab5e2392584a0bf6455d426163bf6f257e82 (patch)
treedc7c283f3ae4a9142d070b534ab9d69e728a80e8 /src/declarative/qml/qmlcompiler.cpp
parent42849ecec82fb289fd337fb9dc591bd48ba89b56 (diff)
parent6c9ac788a60fcd2f946787a5297d7c2f71ad1968 (diff)
downloadQt-6425ab5e2392584a0bf6455d426163bf6f257e82.zip
Qt-6425ab5e2392584a0bf6455d426163bf6f257e82.tar.gz
Qt-6425ab5e2392584a0bf6455d426163bf6f257e82.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.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index e2fd7cb..726051e 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -69,6 +69,7 @@
#include <private/qmlexpression_p.h>
#include "qmlmetaproperty_p.h"
#include "qmlrewrite_p.h"
+#include <QtDeclarative/qmlscriptstring.h>
#include "qmlscriptparser_p.h"
@@ -860,6 +861,17 @@ void QmlCompiler::genObject(QmlParser::Object *obj)
void QmlCompiler::genObjectBody(QmlParser::Object *obj)
{
+ typedef QPair<Property *, int> PropPair;
+ foreach(const PropPair &prop, obj->scriptStringProperties) {
+ QmlInstruction ss;
+ ss.type = QmlInstruction::StoreScriptString;
+ ss.storeScriptString.propertyIndex = prop.first->index;
+ ss.storeScriptString.value =
+ output->indexForString(prop.first->values.at(0)->value.asScript());
+ ss.storeScriptString.scope = prop.second;
+ output->bytecode << ss;
+ }
+
bool seenDefer = false;
foreach(Property *prop, obj->valueProperties) {
if (prop->isDeferred) {
@@ -1371,6 +1383,10 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop,
COMPILE_CHECK(buildListProperty(prop, obj, ctxt));
+ } else if (prop->type == qMetaTypeId<QmlScriptString>()) {
+
+ COMPILE_CHECK(buildScriptStringProperty(prop, obj, ctxt));
+
} else {
COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt));
@@ -1823,6 +1839,22 @@ bool QmlCompiler::buildListProperty(QmlParser::Property *prop,
return true;
}
+// Compiles an assignment to a QmlScriptString property
+bool QmlCompiler::buildScriptStringProperty(QmlParser::Property *prop,
+ QmlParser::Object *obj,
+ const BindingContext &ctxt)
+{
+ if (prop->values.count() > 1)
+ COMPILE_EXCEPTION(prop->values.at(1), qApp->translate("QmlCompiler", "Cannot assign multiple values to a script property"));
+
+ if (prop->values.at(0)->object || !prop->values.at(0)->value.isScript())
+ COMPILE_EXCEPTION(prop->values.at(0), qApp->translate("QmlCompiler", "Invalid property assignment: script expected"));
+
+ obj->addScriptStringProperty(prop, ctxt.stack);
+
+ return true;
+}
+
// Compile regular property assignments of the form "property: <value>"
//
// ### The following problems exist