summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2009-04-17 17:32:32 (GMT)
committerRoberto Raggi <roberto.raggi@nokia.com>2009-04-24 07:52:34 (GMT)
commitab83f16fd07300342d786f48a82b4d81f77f670d (patch)
tree9b109f8e2188aabcfa03f8d7f98e8e1ed63aa7fb /src/declarative/qml
parentb080c837c4c63b1cd0fdea9ae483cad824aef0d1 (diff)
downloadQt-ab83f16fd07300342d786f48a82b4d81f77f670d.zip
Qt-ab83f16fd07300342d786f48a82b4d81f77f670d.tar.gz
Qt-ab83f16fd07300342d786f48a82b4d81f77f670d.tar.bz2
support both *.qml and *.whatever with autodetection. Some debug output, some fixes. Some stuff works now, biggest omission is UiObjectBinding to get the more complex examples working.
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qmlcompiler.cpp2
-rw-r--r--src/declarative/qml/qmlcomponent.cpp25
-rw-r--r--src/declarative/qml/qmlcomponent_p.h1
-rw-r--r--src/declarative/qml/qmlparser.cpp2
-rw-r--r--src/declarative/qml/qmlscriptparser.cpp35
5 files changed, 59 insertions, 6 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index e1a88bb..dd42581 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -747,6 +747,8 @@ bool QmlCompiler::compileSignal(Property *prop, Object *obj)
if(isBinding(script))
COMPILE_EXCEPTION("Cannot assign binding to signal property");
+ qDebug() << "and here we go...";
+
int idx = output->indexForString(script);
int pr = output->indexForByteArray(prop->name);
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index 590f23f..4a3f9b0 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -61,6 +61,17 @@
QT_BEGIN_NAMESPACE
class QByteArray;
+bool QmlComponentPrivate::isXml(const QByteArray &ba)
+{
+ for (int i = 0; i < ba.size(); ++i) {
+ char c = ba.at(i);
+ if (c == ' ' || c == '\n' || c == '\r' || c == '\t')
+ continue;
+ return (c == '<');
+ }
+ return true;
+}
+
/*!
\class QmlComponent
\brief The QmlComponent class encapsulates a QML component description.
@@ -334,6 +345,20 @@ void QmlComponent::loadUrl(const QUrl &url)
d->fromTypeData(data);
+<<<<<<< HEAD:src/declarative/qml/qmlcomponent.cpp
+=======
+ // Compile data
+ QmlCompiler compiler;
+ if(!compiler.compile(d->engine, parser, d->cc)) {
+ qWarning().nospace()
+#ifdef QML_VERBOSEERRORS_ENABLED
+ << "QmlComponent: "
+#endif
+ << compiler.errorDescription().toLatin1().constData() << " @"
+ << d->name.toLatin1().constData() << ":"
+ << compiler.errorLine();
+ }
+>>>>>>> support both *.qml and *.whatever with autodetection. Some debug output, some fixes.:src/declarative/qml/qmlcomponent.cpp
}
emit statusChanged(status());
diff --git a/src/declarative/qml/qmlcomponent_p.h b/src/declarative/qml/qmlcomponent_p.h
index 8074775..bb5f7bb 100644
--- a/src/declarative/qml/qmlcomponent_p.h
+++ b/src/declarative/qml/qmlcomponent_p.h
@@ -81,6 +81,7 @@ public:
QmlEngine *engine;
void clear();
+ static bool isXml(const QByteArray &);
};
#endif // QMLCOMPONENT_P_H
diff --git a/src/declarative/qml/qmlparser.cpp b/src/declarative/qml/qmlparser.cpp
index 54db32e..6c71a97 100644
--- a/src/declarative/qml/qmlparser.cpp
+++ b/src/declarative/qml/qmlparser.cpp
@@ -57,6 +57,7 @@
#include <private/qmlvmemetaobject_p.h>
#include "private/qmlxmlparser_p.h"
#include <private/qmlcompiler_p.h>
+#include <QtDebug>
QT_BEGIN_NAMESPACE
@@ -151,6 +152,7 @@ Object *QmlParser::Property::getValue()
void QmlParser::Property::addValue(Value *v)
{
+ qDebug() << "Property" << name << "addValue" << v->primitive;
values << v;
}
diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp
index c74f4cb..9f4ff05 100644
--- a/src/declarative/qml/qmlscriptparser.cpp
+++ b/src/declarative/qml/qmlscriptparser.cpp
@@ -221,12 +221,38 @@ bool ProcessAST::visit(AST::UiScriptBinding *node)
QTextStream out(&primitive);
PrettyPretty pp(out);
+ Property *prop = currentProperty();
+
if (node->statement->kind == AST::Node::Kind_ExpressionStatement) {
AST::ExpressionStatement *stmt = static_cast<AST::ExpressionStatement *>(node->statement);
- if (stmt->expression && stmt->expression->kind == AST::Node::Kind_IdentifierExpression)
+ if(prop->name.length() >= 3 && prop->name.startsWith("on") &&
+ ('A' <= prop->name.at(2) && 'Z' >= prop->name.at(2))) {
+ pp(stmt->expression);
+
+ // here comes a cruel hack until we support functions properly with arguments for signal properties
+ if (primitive.startsWith(QLatin1String("function("))) {
+ int brace = 0;
+ for (;brace < primitive.size(); ++brace)
+ if (primitive.at(brace) == QLatin1Char('{'))
+ break;
+ primitive = primitive.mid(brace + 1, primitive.size() - brace - 2);
+ }
+ //end of hack
+
+ } else if (prop->name == "id" && stmt->expression && stmt->expression->kind == AST::Node::Kind_IdentifierExpression) {
primitive = static_cast<AST::IdentifierExpression *>(stmt->expression)->name->asString();
- else {
+ } else if (stmt->expression->kind == AST::Node::Kind_StringLiteral) {
+ // hack: emulate weird XML feature that string literals are not quoted.
+ //This needs to be fixed in the qmlcompiler once xml goes away.
+ primitive = static_cast<AST::StringLiteral *>(stmt->expression)->value->asString();
+ } else if (stmt->expression->kind == AST::Node::Kind_TrueLiteral
+ || stmt->expression->kind == AST::Node::Kind_FalseLiteral
+ || stmt->expression->kind == AST::Node::Kind_NumericLiteral
+ ) {
+ pp(stmt->expression);
+ } else {
+ // create a binding
out << "{";
pp(stmt->expression);
out << "}";
@@ -236,13 +262,10 @@ bool ProcessAST::visit(AST::UiScriptBinding *node)
}
-
-
- const State s = state();
Value *v = new Value;
v->primitive = primitive;
v->line = line;
- s.property->addValue(v);
+ prop->addValue(v);
for(int ii = str.count() - 1; ii >= 0; --ii)
_stateStack.pop();