aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/data/math.qml
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-02-16 10:54:34 +0100
committerUlf Hermann <ulf.hermann@qt.io>2023-03-03 12:02:00 +0100
commit05f56d7c78754855c643470ad4e8dfd35c96f927 (patch)
treefe23c5afec83efd75f06046bc0fdb7b7da465999 /tests/auto/qml/qmlcppcodegen/data/math.qml
parente625e39845ccecda871659a8ff39ac081f4aee82 (diff)
QML: Allow as-casting to value types
If the "Addressable" option to ValueTypeBehavior is set, you can use the "as" operator to cast a previously unknown type into either undefined or the given type. We can use this in qmlcachegen to generate efficient code for further operations on the same type. In the generated C++ it in fact only works for GetLookup because: a, We generally don't do SetLookup on value types, yet. b, We generally don't call methods on value types, yet. c, We cannot store a union of undefined and a sequence type, yet. However, getting properties of value types is the most important application of the new casts so this is well worth it. As a side effect we can also look up things in potentially undefined results of other operations now. For example list lookups. Task-number: QTBUG-94807 Change-Id: Ifdf34f1f3f67b7a0a8953b9ed0e947b74638a28c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/data/math.qml')
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/math.qml1
1 files changed, 1 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/math.qml b/tests/auto/qml/qmlcppcodegen/data/math.qml
index cc6cd3741a..ad6303e682 100644
--- a/tests/auto/qml/qmlcppcodegen/data/math.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/math.qml
@@ -3,4 +3,5 @@ import QML
QtObject {
property int a: Math.max(5, 7, 9, -111)
property var b: 50 / 22
+ property real c: Math.PI * 2
}