aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-01-15 17:29:04 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-20 15:10:00 +0100
commitae0a2ea25714af603babe5aa0de364d1ebae1170 (patch)
tree91a0845dd397af79b30341aae64f6c24f0f43197 /tests
parentf8176d72ac491469ccf0288cbb86c0ccc12fb47b (diff)
[new compiler] Add support for QML list models
List model definitions make heavy use of custom parsers, which requires AST access as well as a general port to the new QQmlCustomParser API. Additional fixes in the custom parser support were needed to pass all tests: * Fix support for AcceptsSignalHandlers and AcceptsAttachedProperties * Don't call setCustomData unless the compiler generated data earlier Change-Id: Ic42f8a890391267c94f63d35f055b60fdbf3c83d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.cpp20
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.h2
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/testtypes.cpp b/tests/auto/qml/qqmllanguage/testtypes.cpp
index 4a4ab3b81a..98a803a594 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.cpp
+++ b/tests/auto/qml/qqmllanguage/testtypes.cpp
@@ -126,6 +126,26 @@ QByteArray CustomBindingParser::compile(const QList<QQmlCustomParserProperty> &p
return result;
}
+QByteArray CustomBindingParser::compile(const QV4::CompiledData::QmlUnit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
+{
+ QByteArray result;
+ QDataStream ds(&result, QIODevice::WriteOnly);
+
+ ds << bindings.count();
+ for (int i = 0; i < bindings.count(); ++i) {
+ const QV4::CompiledData::Binding *binding = bindings.at(i);
+ ds << qmlUnit->header.stringAt(binding->propertyNameIndex);
+
+ Q_ASSERT(binding->type == QV4::CompiledData::Binding::Type_Script);
+ int bindingId = bindingIdentifier(binding);
+ ds << bindingId;
+
+ ds << binding->location.line;
+ }
+
+ return result;
+}
+
void CustomBindingParser::setCustomData(QObject *object, const QByteArray &data)
{
CustomBinding *customBinding = qobject_cast<CustomBinding*>(object);
diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h
index a968d9a25a..1b51042eaa 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.h
+++ b/tests/auto/qml/qqmllanguage/testtypes.h
@@ -719,6 +719,7 @@ class MyCustomParserTypeParser : public QQmlCustomParser
{
public:
QByteArray compile(const QList<QQmlCustomParserProperty> &) { return QByteArray(); }
+ QByteArray compile(const QV4::CompiledData::QmlUnit *, const QList<const QV4::CompiledData::Binding *> &) { return QByteArray(); }
void setCustomData(QObject *, const QByteArray &) {}
};
@@ -1090,6 +1091,7 @@ public:
class CustomBindingParser : public QQmlCustomParser
{
virtual QByteArray compile(const QList<QQmlCustomParserProperty> &properties);
+ virtual QByteArray compile(const QV4::CompiledData::QmlUnit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &bindings);
virtual void setCustomData(QObject *object, const QByteArray &data);
};