aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/data
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/data')
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/Action.qml7
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/B.qml5
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/BaseConstraint.qml9
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt279
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/CppMethodListReturnType.qml12
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/Dummy2.qml18
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/EditConstraint.qml6
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/GetOptionalLookupOnQJSValueNonStrict.qml7
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/GetOptionalLookupShadowed.qml19
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/NotificationItem.qml7
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/NotificationsUtils.js3
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/Panel.qml2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/Planner.qml50
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/ProgressBar/ProgressBar.ui.qml2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/ProgressBar/Root.qml2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/ProgressBar/TimelineAnimation.qml2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/Satisfaction.qml10
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/ShadowedObjectName.qml6
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/ShadowedObjectNameDerived.qml6
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/StoreMetaEnum.qml12
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/Variable.qml22
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/ambiguous.h2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/ambiguousAs.qml15
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/arrayCtor.qml11
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/asCast.qml10
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/basicBlocksWithBackJump.qml33
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/basicBlocksWithBackJump_infinite.qml13
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/basicDTZ.qml40
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/birthdayparty.cpp19
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/birthdayparty.h8
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/boolCoercions.qml45
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/boolPointerMerge.qml15
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/childobject.qml13
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/compareOriginals.qml39
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/comparisonTypes.qml54
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/consoleTrace.qml8
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/conversionInDeadCode.qml32
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/conversions2.qml2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/convertPrimitiveToVar.qml18
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/convertQJSPrimitiveValueToIntegral.h34
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/convertQJSPrimitiveValueToIntegral.qml13
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/convertToOriginalReadAcumulatorForUnaryOperators.qml13
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/cppbaseclass.h2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/dateConstruction.qml20
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/dateConversions.qml10
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/dialogButtonBox.qml8
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/dummyobjekt.h29
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/dynamicmeta.h41
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/enforceSignature.qml11
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/enumConversion.qml5
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/enumFromBadSingleton.qml6
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/enumMarkedAsFlag.qml6
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/enumProblems.qml5
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/enumProperty.h71
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/enumproblems.h68
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/equalityQUrl.qml16
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/equalityTestsWithNullOrUndefined.qml14
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/exceptionFromInner.qml10
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/extra/extra.qml6
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/extra2/extra.qml6
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/failures.qml60
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/fallbackresettable.qml23
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/fileDialog.qml2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/flagEnum.qml6
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/gadgetwithenum.h38
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/getOptionalLookup.h42
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/getOptionalLookup.qml34
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/idAccess.qml5
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/ignoredFunctionReturn.qml14
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/indirectlyShadowable.qml39
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/intToEnum.qml7
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/interactive.qml2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/internalConversion.qml16
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/invisible.h36
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/iteration.qml20
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/jsArrayMethods.qml28
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/jsArrayMethodsUntyped.qml17
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/jsArrayMethodsWithParams.qml26
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/jsArrayMethodsWithParamsUntyped.qml18
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/listConversion.qml17
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/listOfInvisible.qml6
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/listToString.qml25
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/listprovider.h24
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/math.qml1
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/mathMinMax.qml59
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/mathStaticProperties.qml17
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/mergedObjectRead.qml14
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/mergedObjectWrite.qml15
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/methodOnListLookup.qml16
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/methods.qml2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/multiforeign.h2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/multipleCtors.qml13
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/nullAccessInsideSignalHandler.qml33
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/nullComparison.qml11
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/nullishCoalescing.qml37
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/numbersInJsPrimitive.qml42
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/objectLookupOnListElement.qml34
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/objectWithStringListMethod.qml7
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h53
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/optionalComparison.qml77
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/person.cpp20
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/person.h44
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/qtbug113150.qml13
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/readEnumFromInstance.qml16
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/readonlyListProperty.qml17
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/reduceWithNullThis.qml18
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/renameAdjust.qml19
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/resettable.h39
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/resettable.qml23
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/returnAfterReject.qml15
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/scopeIdLookup.qml20
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/scopedEnum.qml19
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/sequenceToIterable.h56
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/sequenceToIterable.qml20
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/setLookupConversion.qml17
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/setLookupOriginalScope.qml17
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/shadowedAsCasts.qml31
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/shadowedMethod.qml35
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/shadowedPrimitiveCmpEqNull.qml16
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/shared/Slider.qml2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/signalsWithLists.qml18
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/state.h2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/structuredValueType.qml8
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/theme.cpp2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/theme.h2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/thisObject.qml11
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/timelinetheme.cpp2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/timelinetheme.h2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/topLevelComponent.qml14
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/trigraphs.qml5
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/tst_qmlcppcodegen_verify.cpp47
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/undefinedToDouble.qml6
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/urlString.qml7
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/valueTypeCast.qml43
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/valueTypeCopy.qml2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/valueTypeDefault.qml34
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/valueTypeReference.qml2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/variantMap.qml27
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/variantMapLookup.h17
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/variantMapLookup.qml11
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/variantReturn.qml15
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/variantreturn.h63
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/voidConversion.qml10
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/weathermoduleurl.h61
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/withlength.h28
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/wrapwithvariant.h2
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/writableVariantMap.h31
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/writeVariantMap.qml10
-rw-r--r--tests/auto/qml/qmlcppcodegen/data/writeback.qml43
149 files changed, 3114 insertions, 63 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/data/Action.qml b/tests/auto/qml/qmlcppcodegen/data/Action.qml
new file mode 100644
index 0000000000..99b86fb31c
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/Action.qml
@@ -0,0 +1,7 @@
+import QtQuick
+import QtQuick.Controls as QQC2
+import QtQuick.Templates as T
+
+QQC2.Action {
+ property bool visible: true
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/B.qml b/tests/auto/qml/qmlcppcodegen/data/B.qml
new file mode 100644
index 0000000000..97e895ecad
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/B.qml
@@ -0,0 +1,5 @@
+import QtQml
+
+QtObject {
+ property rect r
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/BaseConstraint.qml b/tests/auto/qml/qmlcppcodegen/data/BaseConstraint.qml
new file mode 100644
index 0000000000..2615778f6a
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/BaseConstraint.qml
@@ -0,0 +1,9 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ property int satisfaction: Satisfaction.NONE
+ property QtObject output
+
+ function inputsKnown(mark: int) : bool { return true }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
index 0737d77005..7f2e6ad967 100644
--- a/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
+++ b/tests/auto/qml/qmlcppcodegen/data/CMakeLists.txt
@@ -4,41 +4,61 @@
set(cpp_sources
ambiguous.h
birthdayparty.cpp birthdayparty.h
+ convertQJSPrimitiveValueToIntegral.h
cppbaseclass.h
druggeljug.h
+ dummyobjekt.h
dynamicmeta.h
enumproblems.h
enumProperty.h
+ getOptionalLookup.h
gadgetwithenum.h
invisible.h
+ listprovider.h
multiforeign.h
objectwithmethod.h
person.cpp person.h
+ resettable.h
+ sequenceToIterable.h
sequencetypeexample.cpp sequencetypeexample.h
state.h
theme.cpp theme.h
timelinetheme.cpp timelinetheme.h
+ variantMapLookup.h
+ variantreturn.h
+ weathermoduleurl.h
wrapwithvariant.h
withlength.h
)
set(qml_files
AccessModelMethodsFromOutside.qml
+ Action.qml
ArraySequenceLengthInterop.qml
+ B.qml
BadType.qml
+ BaseConstraint.qml
BaseMember.qml
BindingExpression.qml
+ CxxTypeFromDir.qml
+ CxxTypeFromImplicit.qml
Cycle1.qml
Cycle2.qml
Cycle3.qml
- CxxTypeFromDir.qml
- CxxTypeFromImplicit.qml
+ CppMethodListReturnType.qml
Dummy.qml
+ Dummy2.qml
+ EditConstraint.qml
Enums.qml
Foozle.qml
+ GetOptionalLookupOnQJSValueNonStrict.qml
+ GetOptionalLookupShadowed.qml
Loopy.qml
+ NotificationItem.qml
+ NotificationsUtils.js
OkType.qml
Panel.qml
+ Planner.qml
ProgressBar/Keyframe.qml
ProgressBar/KeyframeGroup.qml
ProgressBar/ProgressBar.ui.qml
@@ -46,98 +66,145 @@ set(qml_files
ProgressBar/Timeline.qml
ProgressBar/TimelineAnimation.qml
RootWithoutId.qml
+ Satisfaction.qml
SelectionRectangle.qml
+ ShadowedObjectName.qml
+ ShadowedObjectNameDerived.qml
+ StoreMetaEnum.qml
Test.qml
TestCase.qml
+ Variable.qml
WindowDerived.qml
aliasLookup.qml
ambiguous1/Ambiguous.qml
ambiguous2/Ambiguous.qml
+ ambiguousAs.qml
ambiguousSignals.qml
anchorsFill.qml
argumentConversion.qml
array.qml
+ arrayCtor.qml
asCast.qml
attachedBaseEnum.qml
badSequence.qml
+ basicBlocksWithBackJump.qml
+ basicBlocksWithBackJump_infinite.qml
+ basicDTZ.qml
bindToValueType.qml
blockComments.qml
+ boolCoercions.qml
+ boolPointerMerge.qml
boundComponents.qml
callContextPropertyLookupResult.qml
callWithSpread.qml
childobject.qml
colorAsVariant.qml
colorString.qml
- consoleObject.qml
+ compareOriginals.qml
+ comparisonTypes.qml
componentReturnType.qml
compositeTypeMethod.qml
compositesingleton.qml
+ consoleObject.qml
+ consoleTrace.qml
construct.qml
contextParam.qml
conversionDecrement.qml
+ conversionInDeadCode.qml
conversions.qml
conversions2.qml
+ convertPrimitiveToVar.qml
+ convertQJSPrimitiveValueToIntegral.qml
+ convertToOriginalReadAcumulatorForUnaryOperators.qml
curlygrouped.qml
cycleHead.qml
+ dateConstruction.qml
dateConversions.qml
deadShoeSize.qml
deadStoreLoop.qml
dialog.qml
+ dialogButtonBox.qml
dynamicscene.qml
+ enforceSignature.qml
enumConversion.qml
+ enumFromBadSingleton.qml
enumInvalid.qml
enumLookup.qml
+ enumMarkedAsFlag.qml
enumProblems.qml
enumScope.qml
enumsInOtherObject.qml
enumsUser.qml
equalityQObjects.qml
+ equalityQUrl.qml
+ equalityTestsWithNullOrUndefined.qml
equalityVarAndNonStorable.qml
equalsUndefined.qml
+ exceptionFromInner.qml
excessiveParameters.qml
extendedTypes.qml
+ extra/extra.qml
failures.qml
fallbacklookups.qml
+ fallbackresettable.qml
fileDialog.qml
+ flagEnum.qml
fromBoolValue.qml
- functionLookup.qml
funcWithParams.qml
+ functionLookup.qml
functionReturningVoid.qml
functionTakingVar.qml
+ getOptionalLookup.qml
globals.qml
- hidden/Main.qml
- hidden/Style.qml
idAccess.qml
+ ignoredFunctionReturn.qml
immediateQuit.qml
imports/QmlBench/Globals.qml
importsFromImportPath.qml
+ indirectlyShadowable.qml
infinities.qml
infinitiesToInt.qml
- invisibleBase.qml
- invisibleTypes.qml
- invisibleListElementType.qml
intEnumCompare.qml
intOverflow.qml
+ intToEnum.qml
interactive.qml
interceptor.qml
+ internalConversion.qml
+ invisibleBase.qml
+ invisibleListElementType.qml
+ invisibleTypes.qml
isnan.qml
+ iteration.qml
javaScriptArgument.qml
+ jsArrayMethods.qml
+ jsArrayMethodsUntyped.qml
+ jsArrayMethodsWithParams.qml
+ jsArrayMethodsWithParamsUntyped.qml
jsMathObject.qml
jsimport.qml
jsmoduleimport.qml
layouts.qml
- library.js
letAndConst.qml
+ library.js
listAsArgument.qml
+ listConversion.qml
listIndices.qml
+ listOfInvisible.qml
listPropertyAsModel.qml
+ listToString.qml
listlength.qml
math.qml
+ mathMinMax.qml
mathOperations.qml
+ mathStaticProperties.qml
+ mergedObjectRead.qml
+ mergedObjectWrite.qml
+ methodOnListLookup.qml
methods.qml
modulePrefix.qml
moveRegVoid.qml
multiforeign.qml
+ multipleCtors.qml
namespaceWithEnum.qml
noBindingLoop.qml
noQQmlData.qml
@@ -146,9 +213,14 @@ set(qml_files
notEqualsInt.qml
notNotString.qml
nullAccess.qml
+ nullAccessInsideSignalHandler.qml
nullComparison.qml
+ nullishCoalescing.qml
numbersInJsPrimitive.qml
objectInVar.qml
+ objectLookupOnListElement.qml
+ objectWithStringListMethod.qml
+ optionalComparison.qml
outOfBounds.qml
overriddenMember.qml
ownProperty.qml
@@ -157,48 +229,76 @@ set(qml_files
popContextAfterRet.qml
prefixedMetaType.qml
pressAndHoldButton.qml
- registerelimination.qml
+ qtbug113150.qml
+ reduceWithNullThis.qml
+ readEnumFromInstance.qml
+ readonlyListProperty.qml
registerPropagation.qml
+ registerelimination.qml
+ renameAdjust.qml
+ resettable.qml
+ returnAfterReject.qml
revisions.qml
+ scopeIdLookup.qml
scopeVsObject.qml
+ scopedEnum.qml
script.js
script.mjs
+ sequenceToIterable.qml
+ setLookupConversion.qml
+ setLookupOriginalScope.qml
+ shadowedAsCasts.qml
+ shadowedMethod.qml
+ shadowedPrimitiveCmpEqNull.qml
shared/Slider.qml
shifts.qml
signal.qml
signalHandler.qml
signalIndexMismatch.qml
+ signalsWithLists.qml
signatureIgnored.qml
specificParent.qml
storeElementSideEffects.qml
stringArg.qml
stringLength.qml
stringToByteArray.qml
+ structuredValueType.qml
testlogger.js
text.qml
themerbad.qml
themergood.qml
+ thisObject.qml
throwObjectName.qml
toString.qml
+ topLevelComponent.qml
translation.qml
+ trigraphs.qml
trivialSignalHandler.qml
typePropagationLoop.qml
typePropertyClash.qml
typedArray.qml
undefinedResets.qml
+ undefinedToDouble.qml
unknownAttached.qml
unknownParameter.qml
unstoredUndefined.qml
unusedAttached.qml
urlString.qml
usingCxxTypesFromFileImports.qml
+ valueTypeCast.qml
valueTypeCopy.qml
+ valueTypeDefault.qml
valueTypeLists.qml
valueTypeProperty.qml
valueTypeReference.qml
+ variantMap.qml
+ variantMapLookup.qml
+ variantReturn.qml
variantlist.qml
versionmismatch.qml
+ voidConversion.qml
voidfunction.qml
+ writeback.qml
dummy_imports.qml
)
@@ -214,21 +314,88 @@ set_source_files_properties("shared/Slider.qml"
set_source_files_properties("hidden/Style.qml"
PROPERTIES QT_QML_SINGLETON_TYPE TRUE)
+qt_policy(SET QTP0001 NEW)
+
+# Add the module for the hidden files before setting QTP0004, so that we don't add a qmldir in
+# "hidden". That would defeat the purpose.
+
+qt_add_library(codegen_test_hidden STATIC)
+qt_autogen_tools_initial_setup(codegen_test_hidden)
+
+set_target_properties(codegen_test_hidden PROPERTIES
+ # We really want qmlcachegen here, even if qmlsc is available
+ QT_QMLCACHEGEN_EXECUTABLE qmlcachegen
+ QT_QMLCACHEGEN_ARGUMENTS --validate-basic-blocks
+)
+
+target_compile_definitions(codegen_test_hidden PUBLIC
+ -DGENERATED_CPP_FOLDER="${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache"
+)
+
+qt_policy(SET QTP0004 OLD)
+qt6_add_qml_module(codegen_test_hidden
+ URI HiddenTestTypes
+ QML_FILES
+ hidden/Main.qml
+ hidden/Style.qml
+ OUTPUT_DIRECTORY HiddenTestTypes
+ __QT_INTERNAL_DISAMBIGUATE_QMLDIR_RESOURCE
+)
+
+add_dependencies(codegen_test_hidden Qt::Quick)
+
+qt_autogen_tools_initial_setup(codegen_test_hiddenplugin)
+
+qt_policy(SET QTP0004 NEW)
+
+qt_add_library(codegen_test_stringbuilder STATIC)
+qt_autogen_tools_initial_setup(codegen_test_stringbuilder)
+
+set_target_properties(codegen_test_stringbuilder PROPERTIES
+ # We really want qmlcachegen here, even if qmlsc is available
+ QT_QMLCACHEGEN_EXECUTABLE qmlcachegen
+ QT_QMLCACHEGEN_ARGUMENTS --validate-basic-blocks
+)
+
+target_compile_definitions(codegen_test_stringbuilder PRIVATE
+ -DGENERATED_CPP_FOLDER="${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache"
+ QT_USE_QSTRINGBUILDER
+)
+
+qt6_add_qml_module(codegen_test_stringbuilder
+ URI StringBuilderTestTypes
+ SOURCES
+ writableVariantMap.h
+ QML_FILES
+ writeVariantMap.qml
+ OUTPUT_DIRECTORY stringbuilderTestTypes
+ __QT_INTERNAL_DISAMBIGUATE_QMLDIR_RESOURCE
+)
+
+qt_autogen_tools_initial_setup(codegen_test_stringbuilderplugin)
+
qt_add_library(codegen_test_module STATIC)
qt_autogen_tools_initial_setup(codegen_test_module)
set_target_properties(codegen_test_module PROPERTIES
# We really want qmlcachegen here, even if qmlsc is available
QT_QMLCACHEGEN_EXECUTABLE qmlcachegen
+ QT_QMLCACHEGEN_ARGUMENTS --validate-basic-blocks
+)
+
+
+
+target_compile_definitions(codegen_test_module PUBLIC
+ -DGENERATED_CPP_FOLDER="${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache"
)
qt6_add_qml_module(codegen_test_module
VERSION 1.5
URI TestTypes
IMPORT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/imports/"
- AUTO_RESOURCE_PREFIX
DEPENDENCIES
QtQuick
+ QtQuick.Controls
QtQuick.Templates
QtQuick.Shapes
SOURCES
@@ -238,8 +405,96 @@ qt6_add_qml_module(codegen_test_module
RESOURCES
${resource_files}
OUTPUT_DIRECTORY TestTypes # Make sure tst_qmlcachegen doesn't see our output
+ __QT_INTERNAL_DISAMBIGUATE_QMLDIR_RESOURCE
)
+if(${CMAKE_VERSION} GREATER_EQUAL "3.19.0")
+ qt_target_qml_sources(codegen_test_module
+ QML_FILES extra2/extra.qml
+ )
+else()
+ target_compile_definitions(codegen_test_module PUBLIC
+ -DVERY_OLD_CMAKE=1
+ )
+endif()
+
add_dependencies(codegen_test_module Qt::Quick Qt::QuickTemplates2 Qt::QuickShapesPrivate)
qt_autogen_tools_initial_setup(codegen_test_moduleplugin)
+
+
+qt_add_library(codegen_test_module_verify STATIC)
+qt_autogen_tools_initial_setup(codegen_test_module_verify)
+
+set_target_properties(codegen_test_module_verify PROPERTIES
+ # We really want qmlcachegen here, even if qmlsc is available
+ QT_QMLCACHEGEN_EXECUTABLE qmlcachegen
+ QT_QMLCACHEGEN_ARGUMENTS --validate-basic-blocks
+)
+
+
+qt6_add_qml_module(codegen_test_module_verify
+ VERSION 1.5
+ URI TestTypes
+ IMPORT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/imports/"
+ DEPENDENCIES
+ QtQuick
+ QtQuick.Controls
+ QtQuick.Templates
+ QtQuick.Shapes
+ SOURCES
+ ${cpp_sources}
+ QML_FILES
+ ${qml_files}
+ RESOURCES
+ ${resource_files}
+ OUTPUT_DIRECTORY verify/TestTypes # Make sure tst_qmlcachegen doesn't see our output
+ TARGET_PATH verify/TestTypes # Different target path to avoid resource file name clashes
+ __QT_INTERNAL_DISAMBIGUATE_QMLDIR_RESOURCE
+)
+
+add_dependencies(codegen_test_module_verify Qt::Quick Qt::QuickTemplates2 Qt::QuickShapesPrivate)
+
+qt_autogen_tools_initial_setup(codegen_test_module_verifyplugin)
+
+
+qt_internal_add_test(tst_qmlcppcodegen_verify
+ SOURCES
+ tst_qmlcppcodegen_verify.cpp
+)
+
+add_dependencies(tst_qmlcppcodegen_verify codegen_test_module codegen_test_module_verify)
+
+set(a_files "")
+set(b_files "")
+
+foreach(qml_file IN LISTS qml_files)
+ string(REGEX REPLACE "\\.(js|mjs|qml)$" "_\\1" compiled_file ${qml_file})
+ string(REGEX REPLACE "[$#?]+" "_" compiled_file ${compiled_file})
+
+ list(APPEND
+ a_files
+ "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache/codegen_test_module_${compiled_file}.cpp")
+
+ list(APPEND
+ b_files
+ "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache/codegen_test_module_verify_${compiled_file}.cpp")
+endforeach()
+
+qt_add_resources(tst_qmlcppcodegen_verify "a"
+ PREFIX
+ "/a"
+ FILES
+ ${a_files}
+ BASE
+ "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache/"
+)
+
+qt_add_resources(tst_qmlcppcodegen_verify "b"
+ PREFIX
+ "/b"
+ FILES
+ ${b_files}
+ BASE
+ "${CMAKE_CURRENT_BINARY_DIR}/.rcc/qmlcache/"
+)
diff --git a/tests/auto/qml/qmlcppcodegen/data/CppMethodListReturnType.qml b/tests/auto/qml/qmlcppcodegen/data/CppMethodListReturnType.qml
new file mode 100644
index 0000000000..9c3ce4e877
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/CppMethodListReturnType.qml
@@ -0,0 +1,12 @@
+pragma Strict
+
+import QtQuick
+import TestTypes
+
+Item {
+ ListProvider {
+ id: listProvider
+ }
+
+ property var list: listProvider.intList()
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/Dummy2.qml b/tests/auto/qml/qmlcppcodegen/data/Dummy2.qml
new file mode 100644
index 0000000000..a3bbef1888
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/Dummy2.qml
@@ -0,0 +1,18 @@
+// Copyright (C) 2020 The Qt Company Ltd.
+
+import QtQml
+
+QtObject {
+ property int value
+ property Dummy2 child
+ property int dummyEnum
+
+ signal triggered()
+ signal signalWithArg(int one, bool two)
+ property real onValue
+ property real offValue
+
+ function someFunction(a: int, b: bool, c: Dummy2, d: real, e: int) : int { return 42 }
+ property string strProp
+ function concat(a: string, b: string) : string { return a + b }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/EditConstraint.qml b/tests/auto/qml/qmlcppcodegen/data/EditConstraint.qml
new file mode 100644
index 0000000000..ce278fbdf9
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/EditConstraint.qml
@@ -0,0 +1,6 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ property Variable myOutput
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/GetOptionalLookupOnQJSValueNonStrict.qml b/tests/auto/qml/qmlcppcodegen/data/GetOptionalLookupOnQJSValueNonStrict.qml
new file mode 100644
index 0000000000..5a89e996b4
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/GetOptionalLookupOnQJSValueNonStrict.qml
@@ -0,0 +1,7 @@
+import QtQml
+import TestTypes
+
+QtObject {
+ property Action action: Action { }
+ property bool b: action?.visible
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/GetOptionalLookupShadowed.qml b/tests/auto/qml/qmlcppcodegen/data/GetOptionalLookupShadowed.qml
new file mode 100644
index 0000000000..eacefc3017
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/GetOptionalLookupShadowed.qml
@@ -0,0 +1,19 @@
+pragma Strict
+
+import QtQml
+import QtQuick
+
+QtObject {
+ id: root
+
+ component Base : QtObject {
+ property int i: 1
+ }
+
+ component Derived : Base {
+ property string i: "a"
+ }
+
+ property Base base: Derived { }
+ property var res: root.base?.i
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/NotificationItem.qml b/tests/auto/qml/qmlcppcodegen/data/NotificationItem.qml
new file mode 100644
index 0000000000..fba4df6453
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/NotificationItem.qml
@@ -0,0 +1,7 @@
+import QtQml
+import TestTypes as MobileShell
+
+QtObject {
+ id: notificationItem
+ objectName: MobileShell.NotificationsUtils.determineNotificationHeadingText(notificationItem)
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/NotificationsUtils.js b/tests/auto/qml/qmlcppcodegen/data/NotificationsUtils.js
new file mode 100644
index 0000000000..079270e1b9
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/NotificationsUtils.js
@@ -0,0 +1,3 @@
+function determineNotificationHeadingText(notificationItem) {
+ return "heading";
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/Panel.qml b/tests/auto/qml/qmlcppcodegen/data/Panel.qml
index 84e926b8d2..7f589d23e8 100644
--- a/tests/auto/qml/qmlcppcodegen/data/Panel.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/Panel.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick 2.0
diff --git a/tests/auto/qml/qmlcppcodegen/data/Planner.qml b/tests/auto/qml/qmlcppcodegen/data/Planner.qml
new file mode 100644
index 0000000000..ddb2fff053
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/Planner.qml
@@ -0,0 +1,50 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ id: planner
+ property Variable last: Variable { value: 10 }
+
+ function newMark() : int {
+ return 5;
+ }
+
+ function addPropagate(i: int) : bool {
+ return false;
+ }
+
+ function typeErasedRemoveOne(v: QtObject) { removeOne(v as Variable) }
+
+ // Work with various shadowable members and return values.
+ function removeOne(v: Variable) {
+ let vDeterminedBy = v.determinedBy;
+ for (let i = 0, length = v.length(); i < length; ++i) {
+ let next = v.constraint(i) as BaseConstraint;
+ if (next.satisfaction === Satisfaction.NONE)
+ objectName += "n"
+ else if (next !== vDeterminedBy)
+ objectName += "d"
+ else
+ objectName += "x"
+ }
+ }
+
+ function typeErasedRun(c: QtObject) { run(c as BaseConstraint) }
+
+ function run(initial: BaseConstraint) {
+ let mark = planner.newMark();
+ let c = initial;
+
+ let output = c.output as Variable;
+ if (output.mark !== mark && c.inputsKnown(mark)) {
+ output.mark = mark;
+ }
+ }
+
+ function verify(i: int) {
+ if (last.value !== i)
+ console.error("failed", last.value, i);
+ else
+ console.log("success")
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/ProgressBar/ProgressBar.ui.qml b/tests/auto/qml/qmlcppcodegen/data/ProgressBar/ProgressBar.ui.qml
index 21a3832366..a44af04a50 100644
--- a/tests/auto/qml/qmlcppcodegen/data/ProgressBar/ProgressBar.ui.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/ProgressBar/ProgressBar.ui.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2019 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick 2.9
import QtQuick.Window 2.3
diff --git a/tests/auto/qml/qmlcppcodegen/data/ProgressBar/Root.qml b/tests/auto/qml/qmlcppcodegen/data/ProgressBar/Root.qml
index 707f0d9be9..43ff1b62b1 100644
--- a/tests/auto/qml/qmlcppcodegen/data/ProgressBar/Root.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/ProgressBar/Root.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2019 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick 2.9
diff --git a/tests/auto/qml/qmlcppcodegen/data/ProgressBar/TimelineAnimation.qml b/tests/auto/qml/qmlcppcodegen/data/ProgressBar/TimelineAnimation.qml
index b97e8956bf..75ad2245f2 100644
--- a/tests/auto/qml/qmlcppcodegen/data/ProgressBar/TimelineAnimation.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/ProgressBar/TimelineAnimation.qml
@@ -2,5 +2,5 @@ import QtQuick
NumberAnimation {
property bool pingPong
- signal finished()
+ signal finishedEvil()
}
diff --git a/tests/auto/qml/qmlcppcodegen/data/Satisfaction.qml b/tests/auto/qml/qmlcppcodegen/data/Satisfaction.qml
new file mode 100644
index 0000000000..74968c65ea
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/Satisfaction.qml
@@ -0,0 +1,10 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ enum Value {
+ NONE = 0,
+ FORWARD = 1,
+ BACKWARD = 2
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/ShadowedObjectName.qml b/tests/auto/qml/qmlcppcodegen/data/ShadowedObjectName.qml
new file mode 100644
index 0000000000..f079f4a94e
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/ShadowedObjectName.qml
@@ -0,0 +1,6 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ property int objectName: 12
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/ShadowedObjectNameDerived.qml b/tests/auto/qml/qmlcppcodegen/data/ShadowedObjectNameDerived.qml
new file mode 100644
index 0000000000..f988cd6bc9
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/ShadowedObjectNameDerived.qml
@@ -0,0 +1,6 @@
+pragma Strict
+import QtQml
+
+ShadowedObjectName {
+ property double objectName: 17.4
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/StoreMetaEnum.qml b/tests/auto/qml/qmlcppcodegen/data/StoreMetaEnum.qml
new file mode 100644
index 0000000000..eb3da15a3a
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/StoreMetaEnum.qml
@@ -0,0 +1,12 @@
+import QtQml
+
+QtObject {
+ enum Foo {
+ Bar,
+ Baz
+ }
+
+ property var eF: StoreMetaEnum.Foo
+ property int bar: eF.Bar
+ property int baz: eF.Baz
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/Variable.qml b/tests/auto/qml/qmlcppcodegen/data/Variable.qml
new file mode 100644
index 0000000000..f5af97757f
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/Variable.qml
@@ -0,0 +1,22 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ id: variable
+ property int value: 0
+ property int mark: 0
+ property BaseConstraint determinedBy: null
+ property list<BaseConstraint> constraints: [
+ BaseConstraint {
+ satisfaction: variable.value == 0 ? Satisfaction.NONE : Satisfaction.FORWARD
+ }
+ ]
+
+ function length(): int {
+ return constraints.length
+ }
+
+ function constraint(i: int) : BaseConstraint {
+ return constraints[i];
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/ambiguous.h b/tests/auto/qml/qmlcppcodegen/data/ambiguous.h
index 5ea20dbcd1..8f964d593c 100644
--- a/tests/auto/qml/qmlcppcodegen/data/ambiguous.h
+++ b/tests/auto/qml/qmlcppcodegen/data/ambiguous.h
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef AMBIGUOUS_H
#define AMBIGUOUS_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/ambiguousAs.qml b/tests/auto/qml/qmlcppcodegen/data/ambiguousAs.qml
new file mode 100644
index 0000000000..2b7cbd593d
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/ambiguousAs.qml
@@ -0,0 +1,15 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ id: self
+ property bool useSelf: true
+ property QtObject other: {
+ var a;
+ if (useSelf)
+ a = self
+ else
+ a = 15
+ return a as QtObject
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/arrayCtor.qml b/tests/auto/qml/qmlcppcodegen/data/arrayCtor.qml
new file mode 100644
index 0000000000..9886a14cb1
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/arrayCtor.qml
@@ -0,0 +1,11 @@
+pragma Strict
+import QML
+
+QtObject {
+ property list<int> defaultCtor: new Array()
+ property list<int> oneArgCtor: new Array(5)
+ property list<int> multiArgCtor: new Array(2, 3, 3, 4)
+ property list<bool> arrayTrue: new Array(true)
+ property list<bool> arrayFalse: new Array(false)
+ property list<real> arrayNegative: new Array(-14)
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/asCast.qml b/tests/auto/qml/qmlcppcodegen/data/asCast.qml
index 1befc08d0a..cb8155ca6c 100644
--- a/tests/auto/qml/qmlcppcodegen/data/asCast.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/asCast.qml
@@ -28,4 +28,14 @@ Item {
property QtObject dummyAsItem: dummy as Item
property QtObject dummyAsRectangle: dummy as Rectangle
property QtObject dummyAsDummy: dummy as Dummy
+
+ property QtObject nullAsObject: null as QtObject
+ property QtObject nullAsItem: null as Item
+ property QtObject nullAsRectangle: null as Rectangle
+ property QtObject nullAsDummy: null as Dummy
+
+ property QtObject undefinedAsObject: undefined as QtObject
+ property QtObject undefinedAsItem: undefined as Item
+ property QtObject undefinedAsRectangle: undefined as Rectangle
+ property QtObject undefinedAsDummy: undefined as Dummy
}
diff --git a/tests/auto/qml/qmlcppcodegen/data/basicBlocksWithBackJump.qml b/tests/auto/qml/qmlcppcodegen/data/basicBlocksWithBackJump.qml
new file mode 100644
index 0000000000..5b254fe494
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/basicBlocksWithBackJump.qml
@@ -0,0 +1,33 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ function t1() {
+ let i = 0
+ let foo = false
+ if (true) {
+ for (i = 0; i < 42 ; ++i) {}
+ } else {
+ console.log(foo)
+ }
+ }
+
+ function t2() {
+ let foo = false
+ if (false) {
+ while(Math.random() < 0.5) {}
+ } else {
+ console.log(foo)
+ }
+ }
+
+ function t3() {
+ let foo = false
+ if (Math.random() < 0.5) {
+ console.log(foo)
+ } else {
+ while(Math.random() < 0.5) {}
+ console.log(foo)
+ }
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/basicBlocksWithBackJump_infinite.qml b/tests/auto/qml/qmlcppcodegen/data/basicBlocksWithBackJump_infinite.qml
new file mode 100644
index 0000000000..997ff68736
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/basicBlocksWithBackJump_infinite.qml
@@ -0,0 +1,13 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ function infinite() {
+ let foo = false
+ if (true) {
+ while (true) {}
+ } else {
+ console.log(foo)
+ }
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/basicDTZ.qml b/tests/auto/qml/qmlcppcodegen/data/basicDTZ.qml
new file mode 100644
index 0000000000..bc9506a533
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/basicDTZ.qml
@@ -0,0 +1,40 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ id: win
+ property real width: 640
+ property real height: 480
+ property string title: "none"
+
+ function t1(): void {
+ const w = win.width
+ const h = win.height
+
+ if (w > 0 && h > 0) {
+ const wByH = h / 3.0 * 4.0
+ }
+ }
+
+ function t2(): void {
+ let i = 42
+ win.title = "Foo " + i
+
+ for (let j = 0; j < 10; j++) {
+ win.title = "Bar " + j
+ }
+
+ for (let k = 0; k < i; k++) {
+ win.title = "Baz " + k
+ }
+ }
+
+ function t3(): void {
+ let v1 = 1
+ let v2 = 2
+
+ if (true) {
+ v1 = v2
+ }
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/birthdayparty.cpp b/tests/auto/qml/qmlcppcodegen/data/birthdayparty.cpp
index 048459f03a..10a2c90b38 100644
--- a/tests/auto/qml/qmlcppcodegen/data/birthdayparty.cpp
+++ b/tests/auto/qml/qmlcppcodegen/data/birthdayparty.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "birthdayparty.h"
@@ -36,6 +36,23 @@ Person *BirthdayParty::guest(int index) const
return m_guests.at(index);
}
+QStringList BirthdayParty::guestNames() const
+{
+ QStringList names;
+ for (Person *guest: m_guests)
+ names.append(guest->name());
+ return names;
+}
+
+QVariantList BirthdayParty::stuffs() const
+{
+ return QVariantList({
+ QVariant::fromValue(objectName()),
+ QVariant::fromValue(m_guests.size()),
+ QVariant::fromValue(m_host)
+ });
+}
+
void BirthdayParty::invite(const QString &name)
{
auto *person = new Person(this);
diff --git a/tests/auto/qml/qmlcppcodegen/data/birthdayparty.h b/tests/auto/qml/qmlcppcodegen/data/birthdayparty.h
index a6871c39b1..8dd640c67f 100644
--- a/tests/auto/qml/qmlcppcodegen/data/birthdayparty.h
+++ b/tests/auto/qml/qmlcppcodegen/data/birthdayparty.h
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef BIRTHDAYPARTY_H
#define BIRTHDAYPARTY_H
@@ -52,7 +52,6 @@ private:
};
struct Foozle {
- Q_GADGET
int foo = 1;
};
@@ -61,6 +60,8 @@ class BirthdayParty : public QObject
Q_OBJECT
Q_PROPERTY(Person *host READ host WRITE setHost NOTIFY hostChanged FINAL)
Q_PROPERTY(QQmlListProperty<Person> guests READ guests)
+ Q_PROPERTY(QStringList guestNames READ guestNames FINAL)
+ Q_PROPERTY(QVariantList stuffs READ stuffs FINAL)
QML_ELEMENT
QML_ATTACHED(BirthdayPartyAttached)
QML_EXTENDED(BirthDayPartyExtended)
@@ -74,6 +75,9 @@ public:
int guestCount() const;
Person *guest(int) const;
+ QStringList guestNames() const;
+ QVariantList stuffs() const;
+
Q_INVOKABLE void invite(const QString &name);
static BirthdayPartyAttached *qmlAttachedProperties(QObject *object);
diff --git a/tests/auto/qml/qmlcppcodegen/data/boolCoercions.qml b/tests/auto/qml/qmlcppcodegen/data/boolCoercions.qml
new file mode 100644
index 0000000000..6b8ebb3f38
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/boolCoercions.qml
@@ -0,0 +1,45 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ property rect a
+ property bool t1: a
+
+ property int c: 1
+ property bool t2: c
+
+ property url e: "qrc:/ab/c.txt"
+ property bool t3: e
+
+ property string f: "a"
+ property bool t4: f
+
+ property var j: 1
+ property bool t5: j
+
+ id: k
+ property bool t6: k
+
+ property date l
+ property bool t7: l
+
+ property url m
+ property bool t8: m
+
+
+
+ property int b: 0
+ property bool f1: b
+
+ property QtObject d: null
+ property bool f2: d
+
+ property string g
+ property bool f3: g
+
+ property var h: undefined
+ property bool f4: h
+
+ property var i: null
+ property bool f5: i
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/boolPointerMerge.qml b/tests/auto/qml/qmlcppcodegen/data/boolPointerMerge.qml
new file mode 100644
index 0000000000..b2d4d7c5d0
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/boolPointerMerge.qml
@@ -0,0 +1,15 @@
+pragma Strict
+import TestTypes
+import QtQuick
+
+Loader {
+ id: self
+ source: "BaseMember.qml"
+ property int ppp: -99
+
+ onItemChanged: {
+ var base = item as BaseMember;
+ if (base)
+ base.ppp = ppp
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/childobject.qml b/tests/auto/qml/qmlcppcodegen/data/childobject.qml
index 3775ee16bc..76ad8fbbb2 100644
--- a/tests/auto/qml/qmlcppcodegen/data/childobject.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/childobject.qml
@@ -4,6 +4,19 @@ import TestTypes
QtObject {
property ObjectWithMethod child: ObjectWithMethod {
objectName: "kraut"
+
+ function doString() { overloaded("string"); }
+ function doNumber() { overloaded(5.2); }
+ function doArray() { overloaded({a: 2, b: 3, c: 3}); }
+
+ function doString2() { overloaded2("string"); }
+ function doNumber2() { overloaded2(5.2); }
+
+ // Artificially pass an extra argument to avoid choosing the "string" overload.
+ // Unfortunately this is still order-dependent on the metaobject level.
+ function doArray2() { overloaded2({a: 2, b: 3, c: 3}, 1); }
+
+ function doFoo() { foo(this); }
}
objectName: child.objectName
property int doneThing: child.doThing()
diff --git a/tests/auto/qml/qmlcppcodegen/data/compareOriginals.qml b/tests/auto/qml/qmlcppcodegen/data/compareOriginals.qml
new file mode 100644
index 0000000000..3d40ffee62
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/compareOriginals.qml
@@ -0,0 +1,39 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ component Variable: QtObject {
+ property int value: 4
+ }
+
+ property Variable first: Variable {}
+ property Variable last: Variable {
+ id: last
+ }
+
+ property int compareOriginals: {
+ var matches = 0;
+ for (var i = 0; i < 6; i++) {
+ first.value = i; // do a shadowed assignment
+ if (last.value != i)
+ ++matches
+ }
+ return matches;
+ }
+
+ property bool optionalThis: {
+ var a
+ if (2 == 2)
+ a = this
+ else
+ a = undefined
+
+ var b
+ if (2 == 2)
+ b = this
+ else
+ b = undefined
+
+ return a === b
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/comparisonTypes.qml b/tests/auto/qml/qmlcppcodegen/data/comparisonTypes.qml
new file mode 100644
index 0000000000..423cd55ed4
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/comparisonTypes.qml
@@ -0,0 +1,54 @@
+import QtQml
+
+QtObject {
+ component Variable: QtObject {
+ property int value: 4
+ }
+
+ component VariableShadow: Variable {
+ property string value: "1"
+ }
+
+ property Variable last: VariableShadow {}
+
+ function find(n: int) : int {
+ var found = 0
+ for (var i = 0; i < n; i++) {
+ if (last.value == i)
+ ++found
+ }
+ return found;
+ }
+
+ function findStrict(n: int) : int {
+ var found = 0
+ for (var i = 0; i < n; i++) {
+ if (last.value === i)
+ ++found
+ }
+ return found;
+ }
+
+ function findNot(n: int) : int {
+ var found = 0
+ for (var i = 0; i < n; i++) {
+ if (last.value != i)
+ ++found
+ }
+ return found;
+ }
+
+ function findNotStrict(n: int) : int {
+ var found = 0
+ for (var i = 0; i < n; i++) {
+ if (last.value !== i)
+ ++found
+ }
+ return found;
+ }
+
+ property int found: find(3)
+ property int foundStrict: findStrict(10)
+ property int foundNot: findNot(3)
+ property int foundNotStrict: findNotStrict(10)
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/consoleTrace.qml b/tests/auto/qml/qmlcppcodegen/data/consoleTrace.qml
new file mode 100644
index 0000000000..a80af89ddd
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/consoleTrace.qml
@@ -0,0 +1,8 @@
+import QtQml
+
+QtObject {
+ function a() { b() }
+ function b() { c() }
+ function c() { console.trace() }
+ Component.onCompleted: a()
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/conversionInDeadCode.qml b/tests/auto/qml/qmlcppcodegen/data/conversionInDeadCode.qml
new file mode 100644
index 0000000000..b2e7b40c00
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/conversionInDeadCode.qml
@@ -0,0 +1,32 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ // This does not look like dead code, but each access to 'result' generates a
+ // DeadTemoralZoneCheck instruction that we ignore when compiling to C++
+ // after checking statically that 'result' is alive throughout the function.
+ // Therefore, this function is a torture test for the dead code elimination.
+ function calc(a: int, b: int) : int {
+ let result = a;
+ if (b < 0) {
+ if (b < -1)
+ result -= b;
+ if (b < -2)
+ result /= b;
+ } else {
+ if (b > 1)
+ result *= b;
+ if (b > 2)
+ result += b;
+ }
+ return result;
+ }
+
+ property int a: calc(10, -3);
+ property int b: calc(10, -2);
+ property int c: calc(10, -1);
+ property int d: calc(10, 0);
+ property int e: calc(10, 1);
+ property int f: calc(10, 2);
+ property int g: calc(10, 3);
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/conversions2.qml b/tests/auto/qml/qmlcppcodegen/data/conversions2.qml
index c3a9414ae2..d0d1fc9b8f 100644
--- a/tests/auto/qml/qmlcppcodegen/data/conversions2.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/conversions2.qml
@@ -94,6 +94,8 @@ Item {
}
function qtest_signalHandlerName(sn) {
+ // Warning: to not test for signal handlers like this in actual code.
+ // Use the helper methods in QQmlSignalNames instead.
if (sn.substr(0, 2) === "on" && sn[2] === sn[2].toUpperCase())
return sn
return "on" + sn.substr(0, 1).toUpperCase() + sn.substr(1)
diff --git a/tests/auto/qml/qmlcppcodegen/data/convertPrimitiveToVar.qml b/tests/auto/qml/qmlcppcodegen/data/convertPrimitiveToVar.qml
new file mode 100644
index 0000000000..f7c2cc4058
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/convertPrimitiveToVar.qml
@@ -0,0 +1,18 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ id: foo
+
+ property int offsetValue
+
+ function send(data : variant) {
+ }
+
+ Component.onCompleted: () => {
+ let deltaOffset = 42
+ deltaOffset -= 1
+ foo.offsetValue = deltaOffset
+ foo.send({offset: deltaOffset})
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/convertQJSPrimitiveValueToIntegral.h b/tests/auto/qml/qmlcppcodegen/data/convertQJSPrimitiveValueToIntegral.h
new file mode 100644
index 0000000000..459dd62374
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/convertQJSPrimitiveValueToIntegral.h
@@ -0,0 +1,34 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef CONVERTQJSPRIMITIVEVALUETOINTEGRAL_H
+#define CONVERTQJSPRIMITIVEVALUETOINTEGRAL_H
+
+#include <QtCore/qobject.h>
+#include <QtQml/qqml.h>
+
+class Moo485 : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+
+ Q_PROPERTY(int uid READ uid CONSTANT FINAL)
+
+public:
+ explicit Moo485(QObject *parent = nullptr) : QObject(parent) { }
+ int uid() const { return 4711; }
+};
+
+class Foo485 : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+
+ Q_PROPERTY(quint16 uid MEMBER m_uid FINAL)
+
+public:
+ explicit Foo485(QObject *parent = nullptr) : QObject(parent) { }
+ quint16 m_uid = 0;
+};
+
+#endif // CONVERTQJSPRIMITIVEVALUETOINTEGRAL_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/convertQJSPrimitiveValueToIntegral.qml b/tests/auto/qml/qmlcppcodegen/data/convertQJSPrimitiveValueToIntegral.qml
new file mode 100644
index 0000000000..6a15d6f775
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/convertQJSPrimitiveValueToIntegral.qml
@@ -0,0 +1,13 @@
+import QtQuick
+import TestTypes
+
+
+Item {
+ id: root
+
+ property Moo485 moo
+
+ readonly property Foo485 foo: Foo485 {
+ uid: root.moo.uid ?? 0xFFFF
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/convertToOriginalReadAcumulatorForUnaryOperators.qml b/tests/auto/qml/qmlcppcodegen/data/convertToOriginalReadAcumulatorForUnaryOperators.qml
new file mode 100644
index 0000000000..6eb14bba57
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/convertToOriginalReadAcumulatorForUnaryOperators.qml
@@ -0,0 +1,13 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ id: self
+ property int i: 0
+ property Planner planner: null
+
+ function satisfy(mark: int) {
+ planner.addPropagate(mark);
+ i = +mark;
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/cppbaseclass.h b/tests/auto/qml/qmlcppcodegen/data/cppbaseclass.h
index eecc3d968e..812415ae24 100644
--- a/tests/auto/qml/qmlcppcodegen/data/cppbaseclass.h
+++ b/tests/auto/qml/qmlcppcodegen/data/cppbaseclass.h
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef CPPBASECLASS_H
#define CPPBASECLASS_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/dateConstruction.qml b/tests/auto/qml/qmlcppcodegen/data/dateConstruction.qml
new file mode 100644
index 0000000000..fc8a34da71
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/dateConstruction.qml
@@ -0,0 +1,20 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ property date now: new Date()
+ property date now2: new Date(now)
+ property date fromString: new Date("1995-12-17T03:24:00")
+ property date fromNumber: new Date(777)
+ property date fromPrimitive: new Date(objectName.length === 0 ? 57 : "1997-02-13T13:04:12")
+ property date from2: new Date(1996, 1)
+ property date from3: new Date(1996, 2, 3)
+ property date from4: new Date(1996, 3, 4, 5)
+ property date from5: new Date(1996, 4, 5, 6, 7)
+ property date from6: new Date(1996, 5, 6, 7, 8, 9)
+ property date from7: new Date(1996, 6, 7, 8, 9, 10, 11)
+ property date from8: new Date(1996, 7, 8, 9, 10, 11, 12, 13)
+
+ property date withUnderflow: new Date(-4, -5, -6, -7, -8, -9, -10)
+ property date invalid: new Date("foo", "bar")
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/dateConversions.qml b/tests/auto/qml/qmlcppcodegen/data/dateConversions.qml
index 38a34f7487..5c0a426466 100644
--- a/tests/auto/qml/qmlcppcodegen/data/dateConversions.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/dateConversions.qml
@@ -9,12 +9,17 @@ QtObject {
property string dateString: date
property string timeString: time
+ property real dateNumber: date
+ property real timeNumber: time
+
function shuffle() {
Druggeljug.myDate = date;
Druggeljug.myTime = time;
dateString = Druggeljug.myDate;
timeString = Druggeljug.myTime;
+ dateNumber = Druggeljug.myDate;
+ timeNumber = Druggeljug.myTime;
}
function fool() {
@@ -22,4 +27,9 @@ QtObject {
Druggeljug.myTime = Druggeljug.myDate;
Druggeljug.myDate = tmp;
}
+
+ function invalidate() {
+ date = new Date("foo", "bar");
+ time = new Date("bar", "foo");
+ }
}
diff --git a/tests/auto/qml/qmlcppcodegen/data/dialogButtonBox.qml b/tests/auto/qml/qmlcppcodegen/data/dialogButtonBox.qml
new file mode 100644
index 0000000000..b30e0124c8
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/dialogButtonBox.qml
@@ -0,0 +1,8 @@
+pragma Strict
+import QtQuick.Controls.Basic
+
+ApplicationWindow {
+ footer: DialogButtonBox {
+ standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/dummyobjekt.h b/tests/auto/qml/qmlcppcodegen/data/dummyobjekt.h
new file mode 100644
index 0000000000..ace319f91f
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/dummyobjekt.h
@@ -0,0 +1,29 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef DUMMYOBJEKT_H
+#define DUMMYOBJEKT_H
+
+#include <QtCore/qobject.h>
+#include <QtQml/qqml.h>
+
+#if QT_DEPRECATED_SINCE(6, 4)
+class DummyObjekt : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ QML_SINGLETON
+
+public:
+ enum Test {
+ TestA = 1,
+ TestB
+ };
+ Q_ENUM(Test)
+
+ // Deliberately not default constructible
+ explicit DummyObjekt(QObject *parent) : QObject(parent) {}
+};
+#endif
+
+#endif // DUMMYOBJEKT_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/dynamicmeta.h b/tests/auto/qml/qmlcppcodegen/data/dynamicmeta.h
index 64c2850bda..d8358b6a9c 100644
--- a/tests/auto/qml/qmlcppcodegen/data/dynamicmeta.h
+++ b/tests/auto/qml/qmlcppcodegen/data/dynamicmeta.h
@@ -1,38 +1,48 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef DYNAMICMETA_H
#define DYNAMICMETA_H
#include <private/qobject_p.h>
+#include <private/qmetaobjectbuilder_p.h>
#include <QtQmlIntegration/qqmlintegration.h>
-struct FreeDeleter {
- void operator()(QMetaObject *meta) { free(meta); }
-};
-
template<typename T>
class MetaObjectData : public QDynamicMetaObjectData
{
Q_DISABLE_COPY_MOVE(MetaObjectData)
public:
- MetaObjectData() = default;
- ~MetaObjectData() = default;
+ MetaObjectData()
+ {
+ QMetaObjectBuilder builder;
+ builder.setSuperClass(&T::staticMetaObject);
+ builder.setFlags(builder.flags() | DynamicMetaObject);
+ metaObject = builder.toMetaObject();
+ };
+
+ ~MetaObjectData() {
+ free(metaObject);
+ };
QMetaObject *toDynamicMetaObject(QObject *) override
{
- return const_cast<QMetaObject *>(&T::staticMetaObject);
+ return metaObject;
}
int metaCall(QObject *o, QMetaObject::Call call, int idx, void **argv) override
{
return o->qt_metacall(call, idx, argv);
}
+
+ QMetaObject *metaObject = nullptr;
};
class DynamicMeta : public QObject
{
Q_OBJECT
Q_PROPERTY(int foo READ foo WRITE setFoo NOTIFY fooChanged FINAL)
+ Q_PROPERTY(qreal value READ value WRITE setValue RESET resetValue NOTIFY valueChanged FINAL)
+ Q_PROPERTY(qreal shadowable READ shadowable CONSTANT)
QML_ELEMENT
public:
@@ -54,11 +64,26 @@ public:
Q_INVOKABLE int bar(int baz) { return baz + 12; }
+ qreal value() const { return m_value; }
+ qreal shadowable() const { return 25; }
+
+public slots:
+ void resetValue() { setValue(0); }
+ void setValue(qreal value)
+ {
+ if (m_value == value)
+ return;
+ m_value = value;
+ emit valueChanged();
+ }
+
Q_SIGNALS:
void fooChanged();
+ void valueChanged();
private:
int m_foo = 0;
+ qreal m_value = 0;
};
class DynamicMetaSingleton : public DynamicMeta
diff --git a/tests/auto/qml/qmlcppcodegen/data/enforceSignature.qml b/tests/auto/qml/qmlcppcodegen/data/enforceSignature.qml
new file mode 100644
index 0000000000..571a000199
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/enforceSignature.qml
@@ -0,0 +1,11 @@
+import QtQml
+
+QtObject {
+ id: mainItem
+
+ function arg(item: Binding) : QtObject { return item }
+ function ret(item: QtObject) : Binding { return item }
+
+ property QtObject a: arg(mainItem);
+ property QtObject b: ret(mainItem);
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/enumConversion.qml b/tests/auto/qml/qmlcppcodegen/data/enumConversion.qml
index fee2c50e15..61ddd2162d 100644
--- a/tests/auto/qml/qmlcppcodegen/data/enumConversion.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/enumConversion.qml
@@ -1,7 +1,12 @@
+pragma Strict
import TestTypes
MyType {
id: root
+
+ property alias status: root.a
+
property int test: myEnumType.type
property bool test_1: myEnumType.type
+ objectName: root.status + "m"
}
diff --git a/tests/auto/qml/qmlcppcodegen/data/enumFromBadSingleton.qml b/tests/auto/qml/qmlcppcodegen/data/enumFromBadSingleton.qml
new file mode 100644
index 0000000000..3176fde315
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/enumFromBadSingleton.qml
@@ -0,0 +1,6 @@
+import QtQml
+import TestTypes
+
+QtObject {
+ objectName: "Dummy: " + DummyObjekt.TestA
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/enumMarkedAsFlag.qml b/tests/auto/qml/qmlcppcodegen/data/enumMarkedAsFlag.qml
new file mode 100644
index 0000000000..2ef37cbdf0
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/enumMarkedAsFlag.qml
@@ -0,0 +1,6 @@
+import QML
+import TestTypes
+
+QtObject {
+ property int flagValue: ControlFlags.Both
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/enumProblems.qml b/tests/auto/qml/qmlcppcodegen/data/enumProblems.qml
index f9a4eb144b..6a57b0e64a 100644
--- a/tests/auto/qml/qmlcppcodegen/data/enumProblems.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/enumProblems.qml
@@ -11,4 +11,9 @@ QtObject {
readonly property FooThing fighter: root.f.get(Foo.Fighter)
readonly property FooThing bar: root.f.get(Foo.Component)
}
+
+ property int a: FooFactory.B
+ property int b: f.t8
+ property int c: FooFactory.D
+ property int d: f.t16
}
diff --git a/tests/auto/qml/qmlcppcodegen/data/enumProperty.h b/tests/auto/qml/qmlcppcodegen/data/enumProperty.h
index 8c13e860a3..8d6405a059 100644
--- a/tests/auto/qml/qmlcppcodegen/data/enumProperty.h
+++ b/tests/auto/qml/qmlcppcodegen/data/enumProperty.h
@@ -15,20 +15,87 @@ public:
Tri = 0x04,
};
Q_ENUM(MyEnum)
- Q_PROPERTY(MyEnum type READ type)
+ Q_PROPERTY(MyEnum type READ type CONSTANT)
MyEnum type() const { return MyEnum::Tri; }
};
class MyType : public QObject
{
Q_OBJECT
- Q_PROPERTY(MyEnumType myEnumType READ myEnumType)
+ Q_PROPERTY(MyEnumType myEnumType READ myEnumType CONSTANT)
+ Q_PROPERTY(A a READ a WRITE setA NOTIFY aChanged FINAL)
QML_ELEMENT
public:
+ enum A { B, C, D };
+ Q_ENUM(A)
+
MyEnumType myEnumType() const { return m_type; }
+ A a() const { return m_a; }
+ void setA(A newA)
+ {
+ if (m_a == newA)
+ return;
+ m_a = newA;
+ emit aChanged();
+ }
+
+ Q_INVOKABLE int method(quint16, const QString &) { return 24; }
+ Q_INVOKABLE int method(quint16, MyType::A a) { return int(a); }
+
+Q_SIGNALS:
+ void aChanged();
+
private:
MyEnumType m_type;
+ A m_a = B;
+};
+
+class CommunicationPermission
+{
+ Q_GADGET
+public:
+ enum CommunicationMode : quint8 {
+ Access = 0x01,
+ Advertise = 0x02,
+ Default = Access | Advertise,
+ };
+ Q_DECLARE_FLAGS(CommunicationModes, CommunicationMode)
+ Q_FLAG(CommunicationModes)
+
+ void setCommunicationModes(CommunicationModes modes) { m_modes = modes; }
+ CommunicationModes communicationModes() const { return m_modes; }
+
+private:
+ CommunicationModes m_modes;
+};
+
+struct QQmlCommunicationPermission : public QObject
+{
+ Q_OBJECT
+ QML_NAMED_ELEMENT(CommunicationPermission)
+ QML_EXTENDED_NAMESPACE(CommunicationPermission)
+ Q_PROPERTY(CommunicationPermission::CommunicationModes communicationModes READ communicationModes WRITE setCommunicationmodes NOTIFY communicationModesChanged)
+
+public:
+ CommunicationPermission::CommunicationModes communicationModes() const
+ {
+ return m_permission.communicationModes();
+ }
+
+ void setCommunicationmodes(const CommunicationPermission::CommunicationModes &newCommunicationModes)
+ {
+ if (communicationModes() == newCommunicationModes)
+ return;
+ m_permission.setCommunicationModes(newCommunicationModes);
+ emit communicationModesChanged();
+ }
+
+signals:
+ void communicationModesChanged();
+
+private:
+ CommunicationPermission m_permission;
};
#endif // ENUMPROPERTY_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/enumproblems.h b/tests/auto/qml/qmlcppcodegen/data/enumproblems.h
index 08a00acf7e..36f97bec5a 100644
--- a/tests/auto/qml/qmlcppcodegen/data/enumproblems.h
+++ b/tests/auto/qml/qmlcppcodegen/data/enumproblems.h
@@ -1,10 +1,11 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef ENUMPROBLEMS_H
#define ENUMPROBLEMS_H
#include <QObject>
+#include <QtCore/qflags.h>
#include <QtQml/qqml.h>
#include <QtQml/qqmlregistration.h>
@@ -45,9 +46,74 @@ class FooThingWrapper {
class FooFactory : public QObject {
Q_OBJECT
QML_ELEMENT
+ Q_PROPERTY(T8 t8 READ t8 CONSTANT FINAL)
+ Q_PROPERTY(T16 t16 READ t16 CONSTANT FINAL)
public:
+ enum T8: qint8 {
+ A, B, C
+ };
+ Q_ENUM(T8)
+
+ enum T16: qint16 {
+ D = 500, E, F
+ };
+ Q_ENUM(T16)
+
+ T8 t8() const { return C; }
+ T16 t16() const { return E; }
+
Q_INVOKABLE Foo* get(Foo::Type type) const { return new Foo(type); }
};
+class ControlFlags : public QObject {
+ Q_OBJECT
+ QML_ELEMENT
+ QML_UNCREATABLE("Flag Container Class")
+public:
+
+ enum Option {
+ ControlA = 0x1,
+ ControlB = 0x2,
+ Both = ControlA | ControlB
+ };
+
+ Q_DECLARE_FLAGS(Options, Option)
+ Q_FLAG(Option)
+};
+
+class ScopedEnum : public QObject {
+ Q_OBJECT
+ QML_NAMED_ELEMENT(Data)
+ Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
+
+public:
+ enum class DType {
+ A = 27, B
+ };
+ Q_ENUM(DType)
+
+ enum EType {
+ C = 7, D
+ };
+ Q_ENUM(EType)
+};
+
+class UnscopedEnum : public QObject {
+ Q_OBJECT
+ QML_NAMED_ELEMENT(Data2)
+ Q_CLASSINFO("RegisterEnumClassesUnscoped", "true")
+
+public:
+ enum class DType {
+ A = 26, B
+ };
+ Q_ENUM(DType)
+
+ enum EType {
+ C = 6, D
+ };
+ Q_ENUM(EType)
+};
+
#endif // ENUMPROBLEMS_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/equalityQUrl.qml b/tests/auto/qml/qmlcppcodegen/data/equalityQUrl.qml
new file mode 100644
index 0000000000..55ac68592c
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/equalityQUrl.qml
@@ -0,0 +1,16 @@
+pragma Strict
+import QtQuick
+
+Item {
+ property url emptyUrl: ""
+ property url sourceUrl: "some/path/file.png"
+
+ property bool emptyUrlStrict: emptyUrl === Qt.resolvedUrl("")
+ property bool emptyUrlWeak: emptyUrl == Qt.resolvedUrl("")
+
+ property bool sourceUrlStrict: sourceUrl === Qt.url("some/path/file.png");
+ property bool sourceUrlWeak: sourceUrl == Qt.url("some/path/file.png");
+
+ property bool sourceIsNotEmptyStrict: sourceUrl !== emptyUrl
+ property bool sourceIsNotEmptyWeak: sourceUrl != emptyUrl
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/equalityTestsWithNullOrUndefined.qml b/tests/auto/qml/qmlcppcodegen/data/equalityTestsWithNullOrUndefined.qml
new file mode 100644
index 0000000000..cd0c433ea9
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/equalityTestsWithNullOrUndefined.qml
@@ -0,0 +1,14 @@
+pragma Strict
+
+import QtQml
+import QtQuick
+
+Window {
+ property var foo
+ Component.onCompleted: {
+ console.log(foo !== null)
+ console.log(foo === null)
+ console.log(foo !== undefined)
+ console.log(foo === undefined)
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/exceptionFromInner.qml b/tests/auto/qml/qmlcppcodegen/data/exceptionFromInner.qml
new file mode 100644
index 0000000000..13855356f2
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/exceptionFromInner.qml
@@ -0,0 +1,10 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ property QtObject theNull: null
+
+ function doFail() : string { return theNull.objectName }
+ function delegateFail() : string { doFail() }
+ function disbelieveFail() : string { delegateFail() }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/extra/extra.qml b/tests/auto/qml/qmlcppcodegen/data/extra/extra.qml
new file mode 100644
index 0000000000..e8f51984b8
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/extra/extra.qml
@@ -0,0 +1,6 @@
+pragma Strict
+import QtQml
+
+B {
+ r: ({x: 4, y: 6, width: 8, height: 10})
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/extra2/extra.qml b/tests/auto/qml/qmlcppcodegen/data/extra2/extra.qml
new file mode 100644
index 0000000000..e8f51984b8
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/extra2/extra.qml
@@ -0,0 +1,6 @@
+pragma Strict
+import QtQml
+
+B {
+ r: ({x: 4, y: 6, width: 8, height: 10})
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/failures.qml b/tests/auto/qml/qmlcppcodegen/data/failures.qml
index f90fb44fe1..3b0e4908ab 100644
--- a/tests/auto/qml/qmlcppcodegen/data/failures.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/failures.qml
@@ -9,6 +9,7 @@ QtObject {
property string attachedForNasty: Nasty.objectName
property Nasty nasty: Nasty {
+ id: theNasty
objectName: Component.objectName
}
@@ -30,18 +31,10 @@ QtObject {
Component.onCompleted: doesNotExist()
- property string aString: self + "a"
-
property BirthdayParty party: BirthdayParty {
onPartyStarted: (foozle) => { objectName = foozle }
}
- signal foo()
- signal bar()
-
- // Cannot assign potential undefined
- onFoo: objectName = self.bar()
-
property int enumFromGadget1: GadgetWithEnum.CONNECTED + 1
property int enumFromGadget2: TT2.GadgetWithEnum.CONNECTED + 1
@@ -62,4 +55,55 @@ QtObject {
let a;
return a;
}
+
+ function getText(myArr: list<string>): string {
+ myArr.shiftss()
+ }
+
+ function readTracks(metadataList : list<badType>): int {
+ return metadataList.length
+ }
+
+ function dtzFail() : int {
+ for (var a = 10; a < 20; ++a) {
+ switch (a) {
+ case 11:
+ let b = 5;
+ break;
+ case 10:
+ console.log(b);
+ break;
+ }
+ }
+ return a;
+ }
+
+ // TODO: Drop these once we can manipulate QVariant-wrapped lists.
+ property list<withLength> withLengths
+ property int l: withLengths.length
+ property withLength w: withLengths[10]
+
+ property unconstructibleWithLength uwl: 12 + 1
+
+ // Cannot generate code for getters
+ property rect r3: ({ get x() { return 42; }, y: 4 })
+
+ property int nonIterable: {
+ var result = 1;
+ for (var a in Component)
+ ++result;
+ return result;
+ }
+
+ property alias selfself: self
+ property alias nastyBad: theNasty.bad
+ function writeToUnknown() : int {
+ self.selfself.nastyBad = undefined;
+ return 5;
+ }
+
+ readonly property int someNumber: 10
+ function writeToReadonly() { someNumber = 20 }
+
+ property var silly: [,0]
}
diff --git a/tests/auto/qml/qmlcppcodegen/data/fallbackresettable.qml b/tests/auto/qml/qmlcppcodegen/data/fallbackresettable.qml
new file mode 100644
index 0000000000..44b55e245a
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/fallbackresettable.qml
@@ -0,0 +1,23 @@
+pragma Strict
+import QtQml
+import TestTypes
+
+DynamicMeta {
+ id: self
+ value: 999
+
+ property double notResettable: 10
+ property double notResettable2: { return undefined }
+
+ property DynamicMeta shadowing: DynamicMeta {
+ property var shadowable: undefined
+ }
+
+ function doReset() { self.value = undefined }
+ function doReset2() { self.value = shadowing.shadowable }
+ function doNotReset() { self.notResettable = undefined }
+
+ signal aaa()
+ signal bbb()
+ onAaa: objectName = self.bbb()
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/fileDialog.qml b/tests/auto/qml/qmlcppcodegen/data/fileDialog.qml
index b8bd466717..6634982de2 100644
--- a/tests/auto/qml/qmlcppcodegen/data/fileDialog.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/fileDialog.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick
import QtQuick.Controls
diff --git a/tests/auto/qml/qmlcppcodegen/data/flagEnum.qml b/tests/auto/qml/qmlcppcodegen/data/flagEnum.qml
new file mode 100644
index 0000000000..3ea5cf98db
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/flagEnum.qml
@@ -0,0 +1,6 @@
+pragma Strict
+import TestTypes
+
+CommunicationPermission {
+ communicationModes: CommunicationPermission.Access
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/gadgetwithenum.h b/tests/auto/qml/qmlcppcodegen/data/gadgetwithenum.h
index 839e026b77..3c81cd2e7f 100644
--- a/tests/auto/qml/qmlcppcodegen/data/gadgetwithenum.h
+++ b/tests/auto/qml/qmlcppcodegen/data/gadgetwithenum.h
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef GADGETWITHENUM_H
#define GADGETWITHENUM_H
@@ -26,4 +26,40 @@ namespace GadgetWithEnumWrapper {
QML_NAMED_ELEMENT(NamespaceWithEnum)
};
+struct Gadget
+{
+ Q_GADGET
+ QML_VALUE_TYPE(gadget)
+
+public:
+ enum class Prop1 { High, low, VeryHigh, VeryLow };
+ Q_ENUM(Prop1)
+
+ enum class Prop2 { VeryHigh, High, low, VeryLow };
+ Q_ENUM(Prop2)
+};
+
+class Backend : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ QML_SINGLETON
+ Q_PROPERTY(prop priority READ priority FINAL CONSTANT)
+ Q_PROPERTY(Gadget gadget READ gadget FINAL CONSTANT)
+ Q_CLASSINFO("RegisterEnumsFromRelatedTypes", "false")
+
+public:
+ enum prop { High, low, VeryHigh, VeryLow };
+ Q_ENUM(prop)
+
+ explicit Backend(QObject *parent = nullptr) : QObject(parent) {}
+
+ prop priority() const { return m_priority; }
+ Gadget gadget() const { return m_gadget; }
+
+private:
+ prop m_priority = low;
+ Gadget m_gadget;
+};
+
#endif // GADGETWITHENUM_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/getOptionalLookup.h b/tests/auto/qml/qmlcppcodegen/data/getOptionalLookup.h
new file mode 100644
index 0000000000..e8a24cd707
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/getOptionalLookup.h
@@ -0,0 +1,42 @@
+#ifndef GETOPTIONALLOOKUP_H
+#define GETOPTIONALLOOKUP_H
+
+#include <QObject>
+#include <QQmlEngine>
+
+class GOL_Object : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+
+ Q_PROPERTY(int i READ i CONSTANT FINAL)
+ Q_PROPERTY(QString s READ s CONSTANT FINAL)
+ Q_PROPERTY(GOL_Object *childA READ childA WRITE setChildA NOTIFY childAChanged FINAL)
+ Q_PROPERTY(Enum e READ e CONSTANT FINAL)
+
+public:
+ GOL_Object(QObject *parent = nullptr) : QObject(parent) { }
+
+ int i() const { return m_i; }
+ void setI(int i) { m_i = i; }
+
+ QString s() const { return m_s; }
+ void setS(QString s) { m_s = s; }
+
+ GOL_Object *childA() const { return m_childA; }
+ void setChildA(GOL_Object *a) { m_childA = a; }
+
+ enum Enum { V1, V2 };
+ Q_ENUM(Enum)
+ Enum e() const { return Enum::V2; }
+
+signals:
+ void childAChanged();
+
+private:
+ int m_i = 5;
+ QString m_s = "6";
+ GOL_Object *m_childA = nullptr;
+};
+
+#endif // GETOPTIONALLOOKUP_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/getOptionalLookup.qml b/tests/auto/qml/qmlcppcodegen/data/getOptionalLookup.qml
new file mode 100644
index 0000000000..ee360d7142
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/getOptionalLookup.qml
@@ -0,0 +1,34 @@
+pragma Strict
+pragma ValueTypeBehavior: Addressable
+
+import QtQuick
+
+GOL_Object {
+ id: root
+
+ property rect r: Qt.rect(0, 0, 20, 50)
+ property point p: Qt.point(0, -10)
+ property var v: Qt.point(5, 5)
+ property var u: undefined
+
+ property int to1: root?.i
+ property string to2: root?.s
+ property GOL_Object to3: root?.childA
+ property var to4: root.childA?.i
+ property var to5: (undefined as GOL_Object)?.childA
+ property int to6: (root as GOL_Object)?.s.length
+
+ property int tv1: root.r?.bottom
+ property int tv2: root.p?.y
+
+ property int te1: root?.e
+ property int te2: GOL_Object?.V2
+ property bool te3: root?.e === GOL_Object?.V1
+ property bool te4: root?.e === GOL_Object?.V2
+
+ property int tc1: root?.p.y
+ property int tc2: root.r?.x
+
+ property var tc4: root?.childA?.s
+ property var tc5: root.childA?.s
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/idAccess.qml b/tests/auto/qml/qmlcppcodegen/data/idAccess.qml
index 2090926872..6ca1f7f66b 100644
--- a/tests/auto/qml/qmlcppcodegen/data/idAccess.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/idAccess.qml
@@ -1,3 +1,4 @@
+pragma Strict
import QtQuick
Item {
@@ -11,5 +12,9 @@ Item {
Text {
id: ttt
+ onTextChanged: {
+ root.objectName = "dead"
+ ttt.objectName = "context"
+ }
}
}
diff --git a/tests/auto/qml/qmlcppcodegen/data/ignoredFunctionReturn.qml b/tests/auto/qml/qmlcppcodegen/data/ignoredFunctionReturn.qml
new file mode 100644
index 0000000000..640e2bc22a
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/ignoredFunctionReturn.qml
@@ -0,0 +1,14 @@
+import QtQuick
+
+Item {
+ id: root
+
+ Component {
+ id: comp
+ Rectangle {
+ color: "blue"
+ }
+ }
+
+ Component.onCompleted: comp.createObject(root, {"width": 200, "height": 200})
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/indirectlyShadowable.qml b/tests/auto/qml/qmlcppcodegen/data/indirectlyShadowable.qml
new file mode 100644
index 0000000000..de31527e5b
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/indirectlyShadowable.qml
@@ -0,0 +1,39 @@
+import QtQml
+
+QtObject {
+ id: self
+ objectName: "self"
+
+ component Inner : QtObject {
+ property QtObject shadowable: QtObject {
+ objectName: "shadowable"
+ }
+ }
+
+ component Outer : QtObject {
+ property Inner inner: Inner {}
+ }
+
+ component Evil : Outer {
+ property string inner: "evil"
+ }
+
+ property Outer outer: Outer {}
+ property Outer evil: Evil {}
+
+ property QtObject notShadowable: QtObject {
+ objectName: "notShadowable"
+ }
+
+ function getInnerShadowable() {
+ notShadowable = outer.inner.shadowable;
+ }
+
+ function setInnerShadowable() {
+ outer.inner.shadowable = self;
+ }
+
+ function turnEvil() {
+ outer = evil;
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/intToEnum.qml b/tests/auto/qml/qmlcppcodegen/data/intToEnum.qml
new file mode 100644
index 0000000000..e255f4e8f4
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/intToEnum.qml
@@ -0,0 +1,7 @@
+pragma Strict
+import TestTypes
+
+MyType {
+ a: myEnumType.type === 4 ? 2 : 1
+ property int b: method("12", "hh")
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/interactive.qml b/tests/auto/qml/qmlcppcodegen/data/interactive.qml
index e857df96e7..be5e5f0d40 100644
--- a/tests/auto/qml/qmlcppcodegen/data/interactive.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/interactive.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
pragma Strict
import QtQuick 2.9
diff --git a/tests/auto/qml/qmlcppcodegen/data/internalConversion.qml b/tests/auto/qml/qmlcppcodegen/data/internalConversion.qml
new file mode 100644
index 0000000000..7304b7a6b9
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/internalConversion.qml
@@ -0,0 +1,16 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ property QtObject offset: QtObject {
+ id: a
+ property string mark
+ }
+
+ function markInputs(mark: string) {
+ offset.objectName = mark;
+ a.mark = mark;
+ }
+
+ Component.onCompleted: markInputs("hello")
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/invisible.h b/tests/auto/qml/qmlcppcodegen/data/invisible.h
index a385ee975f..4f4ebb87ad 100644
--- a/tests/auto/qml/qmlcppcodegen/data/invisible.h
+++ b/tests/auto/qml/qmlcppcodegen/data/invisible.h
@@ -1,11 +1,12 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef INVISIBLE_H
#define INVISIBLE_H
#include <QtCore/qobject.h>
#include <QtQmlIntegration/qqmlintegration.h>
+#include <QtQml/qqmllist.h>
class Invisible : public QObject
{
@@ -45,6 +46,39 @@ class DerivedFromInvisible : public Invisible
{
Q_OBJECT
QML_ELEMENT
+ Q_PROPERTY(double implicitWidth MEMBER m_implicitWidth NOTIFY implicitWidthChanged FINAL)
+public:
+ DerivedFromInvisible(QObject *parent = nullptr) : Invisible(parent) {}
+
+signals:
+ void implicitWidthChanged();
+
+private:
+ double m_implicitWidth = 27;
+};
+
+class WithListPropertyOfDerivedFromInvisible : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ Q_PROPERTY(QQmlListProperty<DerivedFromInvisible> children READ children NOTIFY childrenChanged FINAL)
+
+public:
+ WithListPropertyOfDerivedFromInvisible(QObject *parent = nullptr) : QObject(parent)
+ {
+ m_children.append(new DerivedFromInvisible(this));
+ }
+
+ QQmlListProperty<DerivedFromInvisible> children()
+ {
+ return QQmlListProperty<DerivedFromInvisible>(this, &m_children);
+ }
+
+signals:
+ void childrenChanged();
+
+private:
+ QList<DerivedFromInvisible *> m_children;
};
#endif // INVISIBLE_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/iteration.qml b/tests/auto/qml/qmlcppcodegen/data/iteration.qml
new file mode 100644
index 0000000000..8632eefa1b
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/iteration.qml
@@ -0,0 +1,20 @@
+pragma Strict
+
+import QtQml
+
+QtObject {
+ property list<int> ints: [3, 4, 5]
+ property list<QtObject> objects: [
+ QtObject { objectName: "a" },
+ QtObject { objectName: "b" },
+ QtObject { objectName: "c" }
+ ]
+
+ Component.onCompleted: {
+ for (var a in objects) {
+ objectName += objects[a].objectName;
+ for (var b in ints)
+ objectName += ints[b];
+ }
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/jsArrayMethods.qml b/tests/auto/qml/qmlcppcodegen/data/jsArrayMethods.qml
new file mode 100644
index 0000000000..ff372bca45
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/jsArrayMethods.qml
@@ -0,0 +1,28 @@
+pragma Strict
+import QML
+
+QtObject {
+ id: self
+
+ property QtObject l1: QtObject { objectName: "klaus" }
+ property QtObject l2: QtObject { function toString(): string { return "teil" } }
+ property QtObject l3: QtObject { }
+
+ function jsArray() : list<var> { return [l1, l2, l3, l1, l2, l3] }
+ property list<QtObject> listProperty: [l1, l2, l3, l1, l2, l3]
+
+ property string jsArrayToString: jsArray().toString()
+ property string listPropertyToString: listProperty.toString()
+
+ property bool listPropertyIncludes: listProperty.includes(l3)
+ property bool jsArrayIncludes: jsArray().includes(l3)
+
+ property string listPropertyJoin: listProperty.join()
+ property string jsArrayJoin: jsArray().join()
+
+ property int listPropertyIndexOf: listProperty.indexOf(l2)
+ property int jsArrayIndexOf: jsArray().indexOf(l2)
+
+ property int listPropertyLastIndexOf: listProperty.lastIndexOf(l3)
+ property int jsArrayLastIndexOf: jsArray().lastIndexOf(l3)
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/jsArrayMethodsUntyped.qml b/tests/auto/qml/qmlcppcodegen/data/jsArrayMethodsUntyped.qml
new file mode 100644
index 0000000000..7426c692fe
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/jsArrayMethodsUntyped.qml
@@ -0,0 +1,17 @@
+import QML
+
+QtObject {
+ id: self
+
+ property QtObject l1
+ property QtObject l2
+ property QtObject l3
+
+ function jsArray() { return [l1, l2, l3, l1, l2, l3] }
+
+ property string jsArrayToString: jsArray().toString()
+ property bool jsArrayIncludes: jsArray().includes(l3)
+ property string jsArrayJoin: jsArray().join()
+ property int jsArrayIndexOf: jsArray().indexOf(l2)
+ property int jsArrayLastIndexOf: jsArray().lastIndexOf(l3)
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/jsArrayMethodsWithParams.qml b/tests/auto/qml/qmlcppcodegen/data/jsArrayMethodsWithParams.qml
new file mode 100644
index 0000000000..293e7cbda5
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/jsArrayMethodsWithParams.qml
@@ -0,0 +1,26 @@
+pragma Strict
+import QML
+
+QtObject {
+ id: self
+
+ required property int i
+ required property int j
+ required property int k
+
+ property QtObject l1: QtObject { objectName: "klaus" }
+ property QtObject l2: QtObject { function toString(): string { return "teil" } }
+ property QtObject l3: QtObject { }
+
+ function jsArray() : list<var> { return [l1, l2, l3, l1, l2, l3] }
+ property list<QtObject> listProperty: [l1, l2, l3, l1, l2, l3]
+
+ property list<QtObject> listPropertySlice: listProperty.slice(i, j)
+ property list<var> jsArraySlice: jsArray().slice(i, j)
+
+ property int listPropertyIndexOf: listProperty.indexOf(l2, i)
+ property int jsArrayIndexOf: jsArray().indexOf(l2, i)
+
+ property int listPropertyLastIndexOf: listProperty.lastIndexOf(l3, i)
+ property int jsArrayLastIndexOf: jsArray().lastIndexOf(l3, i)
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/jsArrayMethodsWithParamsUntyped.qml b/tests/auto/qml/qmlcppcodegen/data/jsArrayMethodsWithParamsUntyped.qml
new file mode 100644
index 0000000000..9e928bd6f6
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/jsArrayMethodsWithParamsUntyped.qml
@@ -0,0 +1,18 @@
+import QML
+
+QtObject {
+ id: self
+
+ required property int i
+ required property int j
+ required property int k
+
+ property QtObject l1
+ property QtObject l2
+ property QtObject l3
+
+ function jsArray() { return [l1, l2, l3, l1, l2, l3] }
+ property var jsArraySlice: jsArray().slice(i, j)
+ property int jsArrayIndexOf: jsArray().indexOf(l2, i)
+ property int jsArrayLastIndexOf: jsArray().lastIndexOf(l3, i)
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/listConversion.qml b/tests/auto/qml/qmlcppcodegen/data/listConversion.qml
new file mode 100644
index 0000000000..ca86d9a1d6
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/listConversion.qml
@@ -0,0 +1,17 @@
+pragma Strict
+import QtQml
+import TestTypes
+
+BirthdayParty {
+ id: self
+
+ guests: [
+ Person { name: "Horst 1" },
+ Person { name: "Horst 2" },
+ Person { name: "Horst 3" }
+ ]
+
+ property list<QtObject> o: self.guests
+ property list<string> s: self.guestNames
+ property list<var> v: self.stuffs
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/listOfInvisible.qml b/tests/auto/qml/qmlcppcodegen/data/listOfInvisible.qml
new file mode 100644
index 0000000000..f3698d78ab
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/listOfInvisible.qml
@@ -0,0 +1,6 @@
+pragma Strict
+import TestTypes
+
+WithListPropertyOfDerivedFromInvisible {
+ property real width: children[0].implicitWidth
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/listToString.qml b/tests/auto/qml/qmlcppcodegen/data/listToString.qml
new file mode 100644
index 0000000000..e9e4b85956
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/listToString.qml
@@ -0,0 +1,25 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ property list<string> stringList: ["one", "two"]
+ property list<int> intList: [1, 2]
+ property list<QtObject> objectList: [this, this]
+
+ Component.onCompleted: {
+ console.log(stringList)
+ console.log(stringList + "")
+
+ console.log(intList)
+ console.log(intList + "")
+
+ console.log(objectList)
+ console.log(objectList + "")
+
+ console.log(["a", "b"]);
+
+ // TODO: Cannot do this, yet, because we cannot coerce a list to string on the fly.
+ // We need to store it as list first.
+ // console.log(["a", "b"] + "");
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/listprovider.h b/tests/auto/qml/qmlcppcodegen/data/listprovider.h
new file mode 100644
index 0000000000..076944b586
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/listprovider.h
@@ -0,0 +1,24 @@
+#ifndef QLISTPROVIDER_H
+#define QLISTPROVIDER_H
+
+#include <QObject>
+#include <QQmlEngine>
+
+class QListProvider : public QObject
+{
+ Q_OBJECT
+ QML_NAMED_ELEMENT(ListProvider)
+
+public:
+ explicit QListProvider(QObject *parent = nullptr) : QObject(parent) { }
+
+ Q_INVOKABLE QList<int> intList() const
+ {
+ QList<int> list;
+ for (int i = 0; i < 3; ++i)
+ list.append(i);
+ return list;
+ }
+};
+
+#endif // QLISTPROVIDER_H
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
}
diff --git a/tests/auto/qml/qmlcppcodegen/data/mathMinMax.qml b/tests/auto/qml/qmlcppcodegen/data/mathMinMax.qml
new file mode 100644
index 0000000000..654b699918
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/mathMinMax.qml
@@ -0,0 +1,59 @@
+pragma Strict
+import QtQml
+import QtQuick
+
+Rectangle {
+ Component.onCompleted: {
+ // Math.max()
+ console.log(Math.max(1, 1));
+ console.log(Math.max(1, 2));
+ console.log(Math.max(2, 1));
+ console.log(Math.max(0, 0));
+ console.log(Math.max(-1, 0));
+ console.log(Math.max(0, -1));
+ console.log(Math.max(-1, -1));
+
+ console.log(Math.max(0, 0, 0));
+ console.log(Math.max(0, 0, 1, 0, 0, 0));
+ console.log(Math.max(-2, -1, 0, 1, 2));
+ console.log(Math.max(2, 1, 0, -1, -2));
+ console.log(Math.max(9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0));
+
+ console.log(Math.max(0.0, 0.0, 0.0))
+ console.log(Math.max(-0.001, 0.001, 0.002))
+ console.log(Math.max(5.4, 1, 0.002))
+ console.log(Math.max(null, 0, -1, 8E-2, NaN, undefined, true, false, Infinity))
+ console.log(Math.max(0, -1, 8E-2, true, false, Infinity))
+ console.log(Math.max(0, -1, 8E-2, true, false))
+ console.log(Math.max(0, -1, 8E-2, false))
+ console.log(Math.max(0, -1, 8E-2, true, false, Infinity))
+ console.log(Math.max(-1, -8, null))
+ console.log(Math.max(undefined, 20, 70))
+
+ // Math.min()
+ console.log(Math.min(1, 1));
+ console.log(Math.min(1, +2));
+ console.log(Math.min(2, 1));
+ console.log(Math.min(0, 0));
+ console.log(Math.min(-1, 0));
+ console.log(Math.min(0, -1));
+ console.log(Math.min(-1, -1));
+
+ console.log(Math.min(0, 0, 0));
+ console.log(Math.min(0, 0, 1, 0, 0, 0));
+ console.log(Math.min(-2, -1, 0, 1, 2));
+ console.log(Math.min(2, 1, 0, -1, -2));
+ console.log(Math.min(9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0));
+
+ console.log(Math.min(0.0, 0.0, 0.0))
+ console.log(Math.min(-0.001, 0.001, 0.002))
+ console.log(Math.min(5.4, 1, 0.002))
+ console.log(Math.min(null, 0, -1, 8E-2, NaN, undefined, true, false, Infinity))
+ console.log(Math.min(0, -1, 8E-2, true, false, Infinity))
+ console.log(Math.min(0, -1, 8E-2, true, false))
+ console.log(Math.min(0, -1, 8E-2, false))
+ console.log(Math.min(0, -1, 8E-2, true, false, Infinity))
+ console.log(Math.min(-1, -8, null))
+ console.log(Math.min(undefined, 20, 70))
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/mathStaticProperties.qml b/tests/auto/qml/qmlcppcodegen/data/mathStaticProperties.qml
new file mode 100644
index 0000000000..fad74a28bd
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/mathStaticProperties.qml
@@ -0,0 +1,17 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+pragma Strict
+
+import QML
+
+QtObject {
+ property double e: Math.E
+ property double ln10: Math.LN10
+ property double ln2: Math.LN2
+ property double log10e: Math.LOG10E
+ property double log2e: Math.LOG2E
+ property double pi: Math.PI
+ property double sqrt1_2: Math.SQRT1_2
+ property double sqrt2: Math.SQRT2
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/mergedObjectRead.qml b/tests/auto/qml/qmlcppcodegen/data/mergedObjectRead.qml
new file mode 100644
index 0000000000..161e21e643
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/mergedObjectRead.qml
@@ -0,0 +1,14 @@
+pragma Strict
+import QtQuick
+
+Item {
+ objectName: "a"
+
+ function f(arg: Item) : string {
+ // Read arg as QtObject and Item, merged into QtObject.
+ console.log(arg)
+ return arg.x
+ }
+
+ Component.onCompleted: objectName = f(null)
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/mergedObjectWrite.qml b/tests/auto/qml/qmlcppcodegen/data/mergedObjectWrite.qml
new file mode 100644
index 0000000000..5f4bb4ff87
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/mergedObjectWrite.qml
@@ -0,0 +1,15 @@
+pragma Strict
+import QtQuick
+
+Item {
+ objectName: "a"
+
+ function f(arg: Item) : string {
+ // Write arg as Item, read it as QtObject.
+ arg.x = 5
+ console.log(arg)
+ return arg.objectName
+ }
+
+ Component.onCompleted: objectName = f(null)
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/methodOnListLookup.qml b/tests/auto/qml/qmlcppcodegen/data/methodOnListLookup.qml
new file mode 100644
index 0000000000..b6b7179438
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/methodOnListLookup.qml
@@ -0,0 +1,16 @@
+pragma Strict
+import QtQml
+import TestTypes
+
+QtObject {
+ objectName: people[0].getName()
+ property list<Person> people: [
+ Person {
+ name: "no one"
+ }
+ ]
+
+ function boom() : string {
+ return people[1].getName()
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/methods.qml b/tests/auto/qml/qmlcppcodegen/data/methods.qml
index 3abd14c9c1..c045c2249b 100644
--- a/tests/auto/qml/qmlcppcodegen/data/methods.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/methods.qml
@@ -35,6 +35,8 @@ BirthdayParty {
}
function stuff(sn) {
+ // Warning: to not test for signal handlers like this in actual code.
+ // Use the helper methods in QQmlSignalNames instead.
if (sn.substr(0, 2) === "on" && sn[2] === sn[2].toUpperCase())
return sn
return "on" + sn.substr(0, 1).toUpperCase() + sn.substr(1)
diff --git a/tests/auto/qml/qmlcppcodegen/data/multiforeign.h b/tests/auto/qml/qmlcppcodegen/data/multiforeign.h
index 290b6370f5..6c46d5ad86 100644
--- a/tests/auto/qml/qmlcppcodegen/data/multiforeign.h
+++ b/tests/auto/qml/qmlcppcodegen/data/multiforeign.h
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef MULTIFOREIGN_H
#define MULTIFOREIGN_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/multipleCtors.qml b/tests/auto/qml/qmlcppcodegen/data/multipleCtors.qml
new file mode 100644
index 0000000000..61dfdb7ca5
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/multipleCtors.qml
@@ -0,0 +1,13 @@
+pragma Strict
+
+import TestTypes
+import QtQml
+
+QtObject {
+ property rect r: Qt.rect(1, 2, 3, 4)
+ property point p: Qt.point(5, 6);
+
+ property withLength wr: r
+ property withLength wp: p
+ property withLength wi: 17
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/nullAccessInsideSignalHandler.qml b/tests/auto/qml/qmlcppcodegen/data/nullAccessInsideSignalHandler.qml
new file mode 100644
index 0000000000..8fe47b7296
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/nullAccessInsideSignalHandler.qml
@@ -0,0 +1,33 @@
+import QtQuick
+
+Item {
+ id: root
+ visible: true
+
+ property var speaker
+ signal say_hello()
+
+ Component{
+ id: speakerComp
+ Text {
+ text: "HELLO"
+ function say_hello() {
+ console.log(text)
+ }
+ }
+ }
+
+ Timer {
+ interval: 1; running: true; repeat: false
+ onTriggered: root.say_hello();
+ }
+
+ Component.onCompleted:
+ {
+ root.speaker = speakerComp.createObject(root);
+
+ root.say_hello.connect(root.speaker.say_hello);
+
+ root.speaker.destroy();
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/nullComparison.qml b/tests/auto/qml/qmlcppcodegen/data/nullComparison.qml
index 1f9af7169b..53b3697c9b 100644
--- a/tests/auto/qml/qmlcppcodegen/data/nullComparison.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/nullComparison.qml
@@ -6,6 +6,7 @@ QtObject {
property int w: 1
property int x: 1
property int y: 1
+ property int z: 1
Component.onCompleted: {
var g = null;
if (g !== null) {
@@ -22,5 +23,15 @@ QtObject {
if (h === undefined) {
y = 5;
}
+
+ var o = this;
+ if (o != null)
+ z += 7;
+ if (o == null)
+ z += 6;
+ if (g == null)
+ z += 10;
+ if (g != null)
+ z += 20;
}
}
diff --git a/tests/auto/qml/qmlcppcodegen/data/nullishCoalescing.qml b/tests/auto/qml/qmlcppcodegen/data/nullishCoalescing.qml
new file mode 100644
index 0000000000..f84f93c5d2
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/nullishCoalescing.qml
@@ -0,0 +1,37 @@
+pragma Strict
+pragma ValueTypeBehavior: Addressable
+
+import QtQuick
+
+GOL_Object {
+ id: root
+
+ property int p1: 5 ?? -1
+ property string p2: "6" ?? "-1"
+
+ property var p3: undefined ?? undefined
+ property var p4: undefined ?? null
+ property var p5: undefined ?? -1
+ property var p6: undefined ?? "-1"
+
+ property var p7: null ?? undefined
+ property var p8: null ?? null
+ property var p9: null ?? -1
+ property var p10: null ?? "-1"
+
+ property int p11: GOL_Object.V2 ?? "-1"
+
+ property int p12: 1 ?? 2 ?? 3
+ property int p13: "1" ?? "2" ?? "3"
+ property var p14: undefined ?? "2" ?? undefined
+ property var p15: undefined ?? undefined ?? 1
+
+ property var p16
+ property var p17
+
+ Component.onCompleted: {
+ p16 = (root.childA as GOL_Object)?.i ?? -1
+ root.childA = root
+ p17 = (root.childA as GOL_Object)?.i ?? -1
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/numbersInJsPrimitive.qml b/tests/auto/qml/qmlcppcodegen/data/numbersInJsPrimitive.qml
index f12d3f5ea2..ec848429e8 100644
--- a/tests/auto/qml/qmlcppcodegen/data/numbersInJsPrimitive.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/numbersInJsPrimitive.qml
@@ -4,23 +4,57 @@ import TestTypes
QtObject {
function writeValues() {
+ Druggeljug.myInt8 = 35
+ Druggeljug.myUint8 = 36
+ Druggeljug.myInt16 = 37
+ Druggeljug.myUint16 = 38
Druggeljug.myInt = 39
Druggeljug.myUint = 40
Druggeljug.myInt32 = 41
Druggeljug.myUint32 = 42
}
+ function negateValues() {
+ Druggeljug.myInt8 = -Druggeljug.myInt8;
+ Druggeljug.myUint8 = -Druggeljug.myUint8;
+ Druggeljug.myInt16 = -Druggeljug.myInt16;
+ Druggeljug.myUint16 = -Druggeljug.myUint16;
+ Druggeljug.myInt = -Druggeljug.myInt;
+ Druggeljug.myUint = -Druggeljug.myUint;
+ Druggeljug.myInt32 = -Druggeljug.myInt32;
+ Druggeljug.myUint32 = -Druggeljug.myUint32;
+ }
+
+ function shuffleValues() {
+ Druggeljug.myInt8 = Druggeljug.myUint8;
+ Druggeljug.myUint8 = Druggeljug.myInt16;
+ Druggeljug.myInt16 = Druggeljug.myUint16;
+ Druggeljug.myUint16 = Druggeljug.myInt;
+ Druggeljug.myInt = Druggeljug.myUint;
+ Druggeljug.myUint = Druggeljug.myInt32;
+ Druggeljug.myInt32 = Druggeljug.myUint32;
+ Druggeljug.myUint32 = Druggeljug.myInt8;
+ }
+
function readValueAsString(i: int) : string {
switch (i) {
- case 0: return Druggeljug.myInt;
- case 1: return Druggeljug.myUint;
- case 2: return Druggeljug.myInt32;
- case 3: return Druggeljug.myUint32;
+ case 0: return Druggeljug.myInt8;
+ case 1: return Druggeljug.myUint8;
+ case 2: return Druggeljug.myInt16;
+ case 3: return Druggeljug.myUint16;
+ case 4: return Druggeljug.myInt;
+ case 5: return Druggeljug.myUint;
+ case 6: return Druggeljug.myInt32;
+ case 7: return Druggeljug.myUint32;
default: return "";
}
}
function storeValues() {
+ Druggeljug.storeMyInt8(1330)
+ Druggeljug.storeMyUint8(1331)
+ Druggeljug.storeMyInt16(1332)
+ Druggeljug.storeMyUint16(1333)
Druggeljug.storeMyInt(1334)
Druggeljug.storeMyUint(1335)
Druggeljug.storeMyInt32(1336)
diff --git a/tests/auto/qml/qmlcppcodegen/data/objectLookupOnListElement.qml b/tests/auto/qml/qmlcppcodegen/data/objectLookupOnListElement.qml
new file mode 100644
index 0000000000..4804921b02
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/objectLookupOnListElement.qml
@@ -0,0 +1,34 @@
+pragma Strict
+import QtQuick
+
+Item {
+ id: stack
+
+ property int current: 0
+
+ onCurrentChanged: setZOrders()
+ Component.onCompleted: setZOrders()
+
+ function setZOrders() {
+ for (var i = 0; i < Math.max(stack.children.length, 3); ++i) {
+ stack.children[i].z = (i == current ? 1 : 0)
+ stack.children[i].enabled = (i == current)
+ }
+ }
+
+ function zOrders() : list<int> {
+ return [
+ stack.children[0].z,
+ stack.children[1].z,
+ stack.children[2].z
+ ]
+ }
+
+ function clearChildren() {
+ children.length = 0;
+ }
+
+ Item {}
+ Item {}
+ Item {}
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/objectWithStringListMethod.qml b/tests/auto/qml/qmlcppcodegen/data/objectWithStringListMethod.qml
new file mode 100644
index 0000000000..14f84c57d0
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/objectWithStringListMethod.qml
@@ -0,0 +1,7 @@
+import QtQml
+import TestTypes
+
+QtObject {
+ readonly property ObjectWithStringListMethod foo: ObjectFactory.getFoo()
+ Component.onCompleted: console.log(foo ? foo.names().length : "-")
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h b/tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h
index 348862985f..f43a0d5531 100644
--- a/tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h
+++ b/tests/auto/qml/qmlcppcodegen/data/objectwithmethod.h
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef OBJECTWITHMETOD_H
#define OBJECTWITHMETOD_H
@@ -7,6 +7,7 @@
#include <QtCore/qobject.h>
#include <QtCore/qproperty.h>
#include <QtQml/qqml.h>
+#include <QtQml/private/qv4engine_p.h>
// Make objectName available. It doesn't exist on the builtin QtObject type
struct QObjectForeignForObjectName {
@@ -27,6 +28,20 @@ public:
Q_INVOKABLE int doThing() const { return theThing; }
QProperty<int> theThing;
QBindable<int> theThingBindable() { return QBindable<int>(&theThing); }
+
+ // The meta methods are populated back to front.
+ // The V4Function flag should not bleed into the others in either case.
+
+ Q_INVOKABLE void overloaded(QQmlV4FunctionPtr) { setObjectName(QStringLiteral("javaScript")); }
+ Q_INVOKABLE void overloaded(double) { setObjectName(QStringLiteral("double")); }
+ Q_INVOKABLE void overloaded(const QString &) { setObjectName(QStringLiteral("string")); }
+
+ Q_INVOKABLE void foo(const QString &bla) { setObjectName(bla); }
+ Q_INVOKABLE void foo(ObjectWithMethod *) { setObjectName(QStringLiteral("ObjectWithMethod")); }
+
+ Q_INVOKABLE void overloaded2(double) { setObjectName(QStringLiteral("double")); }
+ Q_INVOKABLE void overloaded2(const QString &) { setObjectName(QStringLiteral("string")); }
+ Q_INVOKABLE void overloaded2(QQmlV4FunctionPtr) { setObjectName(QStringLiteral("javaScript")); }
};
class OverriddenObjectName : public ObjectWithMethod
@@ -56,4 +71,40 @@ private:
QProperty<QString> m_objectName;
};
+class ObjectWithStringListMethod : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+
+public:
+ explicit ObjectWithStringListMethod(QObject *parent = nullptr) : QObject(parent)
+ {
+ m_names.append("One");
+ m_names.append("Two");
+ }
+
+ Q_INVOKABLE QStringList names() const { return m_names; }
+
+private:
+ QStringList m_names;
+};
+
+class ObjectFactory : public QObject {
+ Q_OBJECT
+ QML_ELEMENT
+ QML_SINGLETON
+
+public:
+ explicit ObjectFactory(QObject *parent = nullptr) : QObject(parent) {}
+ Q_INVOKABLE ObjectWithStringListMethod *getFoo()
+ {
+ if (!m_foo)
+ m_foo = new ObjectWithStringListMethod(this);
+ return m_foo;
+ }
+
+private:
+ ObjectWithStringListMethod *m_foo = nullptr;
+};
+
#endif // OBJECTWITHMETHOD_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/optionalComparison.qml b/tests/auto/qml/qmlcppcodegen/data/optionalComparison.qml
new file mode 100644
index 0000000000..4dbc541721
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/optionalComparison.qml
@@ -0,0 +1,77 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ property list<QtObject> elms: [this, null, null]
+
+ property int found: find(this)
+ property int foundNot: findNot(this)
+ property int foundStrict: findStrict(this)
+ property int foundStrictNot: findStrictNot(this)
+
+ function find(elm : QtObject) : int {
+ let found = 0;
+ for (var i = 0; i < elms.length; i++) {
+ var value = elms[i];
+ if (value == elm)
+ ++found;
+ }
+ return found;
+ }
+
+ function findNot(elm : QtObject) : int {
+ let found = 0;
+ for (var i = 0; i < elms.length; i++) {
+ var value = elms[i];
+ if (value != elm)
+ ++found;
+ }
+ return found;
+ }
+
+ function findStrict(elm : QtObject) : int {
+ let found = 0;
+ for (var i = 0; i < elms.length; i++) {
+ var value = elms[i];
+ if (value === elm)
+ ++found;
+ }
+ return found;
+ }
+
+ function findStrictNot(elm : QtObject) : int {
+ let found = 0;
+ for (var i = 0; i < elms.length; i++) {
+ var value = elms[i];
+ if (value !== elm)
+ ++found;
+ }
+ return found;
+ }
+
+ property bool optionalNull: {
+ let a // Produces a QJsPrimitiveValue we can compare to null below
+ if (objectName.length === 0)
+ a = null
+ else
+ a = undefined
+
+ return a === null
+ }
+
+ property int undefinedEqualsUndefined: {
+ var matches = 0;
+
+ // Overrun the array so that we get some undefined !== undefined.
+ for (var i = 0; i < 4; i++) {
+ var val1 = elms[i]
+ for (var j = 0; j < 4; j++) {
+ var val2 = elms[j]
+ if (!(val1 !== val2))
+ ++matches
+ }
+ }
+
+ return matches;
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/person.cpp b/tests/auto/qml/qmlcppcodegen/data/person.cpp
index 4dcd6fd56f..946dfbcdaa 100644
--- a/tests/auto/qml/qmlcppcodegen/data/person.cpp
+++ b/tests/auto/qml/qmlcppcodegen/data/person.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "person.h"
@@ -98,3 +98,21 @@ void Person::setCousins(const QList<Person *> &newCousins)
m_cousins = newCousins;
emit cousinsChanged();
}
+
+QRectF Person::area() const
+{
+ return m_area;
+}
+
+void Person::setArea(const QRectF &newArea)
+{
+ if (m_area.valueBypassingBindings() == newArea)
+ return;
+ m_area = newArea;
+ emit areaChanged();
+}
+
+QBindable<QRectF> Person::areaBindable()
+{
+ return QBindable<QRectF>(&m_area);
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/person.h b/tests/auto/qml/qmlcppcodegen/data/person.h
index fba4a9e9a5..c46aa757a7 100644
--- a/tests/auto/qml/qmlcppcodegen/data/person.h
+++ b/tests/auto/qml/qmlcppcodegen/data/person.h
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef PERSON_H
#define PERSON_H
@@ -8,6 +8,35 @@
#include <QtQml/qqml.h>
#include <QtQml/qqmlengine.h>
#include <QtCore/qproperty.h>
+#include <QtCore/qrect.h>
+
+struct Inner
+{
+ Q_GADGET
+ QML_VALUE_TYPE(inner)
+ QML_STRUCTURED_VALUE
+ Q_PROPERTY(int i MEMBER i)
+
+private:
+ friend bool operator==(const Inner &lhs, const Inner &rhs) { return lhs.i == rhs.i; }
+ friend bool operator!=(const Inner &lhs, const Inner &rhs) { return !(lhs == rhs); }
+
+ int i = 11;
+};
+
+struct Outer
+{
+ Q_GADGET
+ QML_VALUE_TYPE(outer)
+ QML_STRUCTURED_VALUE
+ Q_PROPERTY(Inner inner MEMBER inner)
+
+private:
+ friend bool operator==(const Outer &lhs, const Outer &rhs) { return lhs.inner == rhs.inner; }
+ friend bool operator!=(const Outer &lhs, const Outer &rhs) { return !(lhs == rhs); }
+
+ Inner inner;
+};
// Intentionally opaque type
class Barzle : public QObject {};
@@ -22,6 +51,8 @@ class Person : public QObject
Q_PROPERTY(QList<Barzle *> barzles READ barzles WRITE setBarzles NOTIFY barzlesChanged FINAL)
Q_PROPERTY(QList<Person *> cousins READ cousins WRITE setCousins NOTIFY cousinsChanged FINAL)
Q_PROPERTY(QByteArray data READ data WRITE setData NOTIFY dataChanged FINAL)
+ Q_PROPERTY(QRectF area READ area WRITE setArea NOTIFY areaChanged) // not FINAL
+ Q_PROPERTY(QRectF area2 READ area WRITE setArea NOTIFY areaChanged BINDABLE areaBindable FINAL)
QML_ELEMENT
public:
Person(QObject *parent = nullptr);
@@ -52,6 +83,12 @@ public:
QList<Person *> cousins() const;
void setCousins(const QList<Person *> &newCousins);
+ QRectF area() const;
+ void setArea(const QRectF &newArea);
+ QBindable<QRectF> areaBindable();
+
+ Q_INVOKABLE QString getName() const { return m_name; }
+
signals:
void nameChanged();
void shoeSizeChanged();
@@ -62,6 +99,10 @@ signals:
void ambiguous(int a = 9);
void cousinsChanged();
+ void objectListHappened(const QList<QObject *> &);
+ void variantListHappened(const QList<QVariant> &);
+
+ void areaChanged();
private:
QString m_name;
@@ -70,6 +111,7 @@ private:
QList<Barzle *> m_barzles;
QList<Person *> m_cousins;
QProperty<QByteArray> m_data;
+ QProperty<QRectF> m_area;
};
class BarzleListRegistration
diff --git a/tests/auto/qml/qmlcppcodegen/data/qtbug113150.qml b/tests/auto/qml/qmlcppcodegen/data/qtbug113150.qml
new file mode 100644
index 0000000000..c7103eaf05
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/qtbug113150.qml
@@ -0,0 +1,13 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+pragma Strict
+
+import QtQuick
+
+Window {
+ // If static properties of the Math global object are not directly
+ // supported, a warning should be issued in turn failing the build
+ // due to `pragma Strict`.
+ width: 200 * Math.PI
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/readEnumFromInstance.qml b/tests/auto/qml/qmlcppcodegen/data/readEnumFromInstance.qml
new file mode 100644
index 0000000000..d0176e6b15
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/readEnumFromInstance.qml
@@ -0,0 +1,16 @@
+import QtQml
+import TestTypes
+
+QtObject {
+ id: root
+
+ property int priority: Backend.gadget.VeryHigh
+ property int prop2: Backend.priority
+
+ property bool priorityIsVeryHigh: root.priority == Backend.VeryHigh
+
+ function cyclePriority() : int {
+ root.priority = Backend.gadget.High;
+ return root.priority;
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/readonlyListProperty.qml b/tests/auto/qml/qmlcppcodegen/data/readonlyListProperty.qml
new file mode 100644
index 0000000000..149638283b
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/readonlyListProperty.qml
@@ -0,0 +1,17 @@
+import QtQml
+
+QtObject {
+ id: testObj
+
+ // "readonly" means the identity of the list cannot be changed.
+ // Its contents can be changed.
+ readonly default property list<QtObject> theList
+
+ Component.onCompleted: {
+ for (var i = 0; i < 4; i++)
+ testObj.theList.push(testObj)
+ }
+
+ property int l: theList.length
+}
+
diff --git a/tests/auto/qml/qmlcppcodegen/data/reduceWithNullThis.qml b/tests/auto/qml/qmlcppcodegen/data/reduceWithNullThis.qml
new file mode 100644
index 0000000000..c6fda8c739
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/reduceWithNullThis.qml
@@ -0,0 +1,18 @@
+import QtQml
+
+QtObject {
+ id: mainItem
+ property int topPadding: 12
+ property int bottomPadding: 12
+
+ property int preferredHeight: mainItem.children.reduce(maximumImplicitHeightReducer, 0) + topPadding + bottomPadding
+ function maximumImplicitHeightReducer(accumulator: real, item: Binding): real {
+ return Math.max(accumulator, (item.objectName + "b").length);
+ }
+
+ property int preferredHeight2: mainItem.children.reduce((accumulator, item) => {
+ return Math.max(accumulator, (item.objectName + "b").length);
+ }, 0) + topPadding + bottomPadding
+
+ property list<Binding> children: [ Binding { objectName: "aaa" } ]
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/renameAdjust.qml b/tests/auto/qml/qmlcppcodegen/data/renameAdjust.qml
new file mode 100644
index 0000000000..9352163ba7
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/renameAdjust.qml
@@ -0,0 +1,19 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ id: last
+ property int value: 10
+
+ function verify(i: int) {
+ if (last.value !== i)
+ console.error("failed", last.value, i);
+ else
+ console.log("success")
+ }
+
+ Component.onCompleted: {
+ verify(10)
+ verify(11)
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/resettable.h b/tests/auto/qml/qmlcppcodegen/data/resettable.h
new file mode 100644
index 0000000000..755c8de237
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/resettable.h
@@ -0,0 +1,39 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef RESETTABLE_H
+#define RESETTABLE_H
+
+#include <QtCore/qobject.h>
+#include <QtQml/qqml.h>
+
+class ResettableProperty : public QObject
+{
+ Q_OBJECT
+ QML_NAMED_ELEMENT(Resettable)
+ Q_PROPERTY(qreal value READ value WRITE setValue RESET resetValue NOTIFY valueChanged FINAL)
+ Q_PROPERTY(qreal shadowable READ shadowable CONSTANT)
+
+public:
+ explicit ResettableProperty(QObject *parent = nullptr) : QObject(parent) {}
+ qreal value() const { return m_value; }
+ qreal shadowable() const { return 25; }
+
+public slots:
+ void resetValue() { setValue(0); }
+ void setValue(qreal value)
+ {
+ if (m_value == value)
+ return;
+ m_value = value;
+ emit valueChanged();
+ }
+
+signals:
+ void valueChanged();
+
+private:
+ qreal m_value = 0;
+};
+
+#endif // RESETTABLE_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/resettable.qml b/tests/auto/qml/qmlcppcodegen/data/resettable.qml
new file mode 100644
index 0000000000..561655032d
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/resettable.qml
@@ -0,0 +1,23 @@
+pragma Strict
+import QtQml
+import TestTypes
+
+Resettable {
+ id: self
+ value: 999
+
+ property double notResettable: 10
+ property double notResettable2: { return undefined }
+
+ property Resettable shadowing: Resettable {
+ property var shadowable: undefined
+ }
+
+ function doReset() { self.value = undefined }
+ function doReset2() { self.value = shadowing.shadowable }
+ function doNotReset() { self.notResettable = undefined }
+
+ signal aaa()
+ signal bbb()
+ onAaa: objectName = self.bbb()
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/returnAfterReject.qml b/tests/auto/qml/qmlcppcodegen/data/returnAfterReject.qml
new file mode 100644
index 0000000000..e0b85eb270
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/returnAfterReject.qml
@@ -0,0 +1,15 @@
+import QtQml
+
+QtObject {
+ id: remaining
+
+ property int bar: 0
+
+ Component.onCompleted: {
+ let remainingTime = 123
+ if (remainingTime < 0) {
+ remainingTime += 24 * 60 * 60
+ }
+ remaining.bar = isNaN(remainingTime) ? 0 : remainingTime
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/scopeIdLookup.qml b/tests/auto/qml/qmlcppcodegen/data/scopeIdLookup.qml
new file mode 100644
index 0000000000..e23f180598
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/scopeIdLookup.qml
@@ -0,0 +1,20 @@
+pragma ComponentBehavior: Bound
+
+import QtQml
+
+QtObject {
+ id: root
+
+ property QtObject b: QtObject {
+ id: bar
+ objectName: "outer"
+ }
+
+ property Instantiator i: Instantiator {
+ model: 1
+ delegate: QtObject {
+ property QtObject bar: QtObject { objectName: "inner" }
+ Component.onCompleted: root.objectName = bar.objectName
+ }
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/scopedEnum.qml b/tests/auto/qml/qmlcppcodegen/data/scopedEnum.qml
new file mode 100644
index 0000000000..8b9f161b06
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/scopedEnum.qml
@@ -0,0 +1,19 @@
+import QtQml
+import TestTypes
+
+QtObject {
+ property int good: Data.DType.A
+ property int bad: Data.A
+
+ property int wrong: Data.EType.C
+ property int right: Data.C
+
+ property int notgood: Data2.DType.A
+ property int notbad: Data2.A
+
+ property int notwrong: Data2.EType.C
+ property int notright: Data2.C
+
+ property int passable: Enums.AppState.Blue
+ property int wild: Enums.Green
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/sequenceToIterable.h b/tests/auto/qml/qmlcppcodegen/data/sequenceToIterable.h
new file mode 100644
index 0000000000..76c72fff36
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/sequenceToIterable.h
@@ -0,0 +1,56 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef SEQUENCETOITERABLE_H
+#define SEQUENCETOITERABLE_H
+
+#include <QtCore/qobject.h>
+#include <QtQml/qqml.h>
+
+class Entry : public QObject {
+ Q_OBJECT
+
+public:
+ explicit Entry(const QString &name, QObject *parent = nullptr)
+ : QObject(parent), m_name(name)
+ {
+ setObjectName(name);
+ }
+
+private:
+ QString m_name;
+};
+
+class EntryWrapper {
+ Q_GADGET
+ QML_FOREIGN(Entry)
+ QML_NAMED_ELEMENT(Entry)
+ QML_UNCREATABLE("These are my Entry objects")
+};
+
+class EntryListRegistration
+{
+ Q_GADGET
+ QML_FOREIGN(QList<Entry*>)
+ QML_ANONYMOUS
+ QML_SEQUENTIAL_CONTAINER(Entry*)
+};
+
+class EntrySource : public QObject {
+ Q_OBJECT
+ QML_ELEMENT
+ QML_SINGLETON
+
+public:
+ explicit EntrySource(QObject* parent = nullptr) : QObject(parent) {
+ for (int i = 0; i < 10; i++) {
+ m_entries.push_back(new Entry(QString("Item %1").arg(i), this));
+ }
+ }
+ Q_INVOKABLE QList<Entry*> getEntries() const { return m_entries; }
+
+private:
+ QList<Entry*> m_entries;
+};
+
+#endif // SEQUENCETOITERABLE_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/sequenceToIterable.qml b/tests/auto/qml/qmlcppcodegen/data/sequenceToIterable.qml
new file mode 100644
index 0000000000..23e2645128
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/sequenceToIterable.qml
@@ -0,0 +1,20 @@
+pragma Strict
+import QtQuick
+import TestTypes
+
+Item {
+ Component.onCompleted: () => {
+ repeater.model = EntrySource.getEntries()
+ }
+
+ Repeater {
+ id: repeater
+ Item {
+ required property int index
+ required property QtObject modelData
+ objectName: modelData + ": " + index
+ }
+ }
+
+ property int c: children.length
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/setLookupConversion.qml b/tests/auto/qml/qmlcppcodegen/data/setLookupConversion.qml
new file mode 100644
index 0000000000..404ee8653b
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/setLookupConversion.qml
@@ -0,0 +1,17 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ id: first
+ property int value
+
+ objectName: a.objectName
+ property QtObject a: QtObject {}
+ function t() { a.objectName = "a" }
+
+ Component.onCompleted: {
+ for (let i = 0; i < 10; ++i) {
+ first.value = i;
+ }
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/setLookupOriginalScope.qml b/tests/auto/qml/qmlcppcodegen/data/setLookupOriginalScope.qml
new file mode 100644
index 0000000000..9975bfdfa4
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/setLookupOriginalScope.qml
@@ -0,0 +1,17 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ property Component newEditConstraint: EditConstraint {}
+ property Variable variable: Variable {}
+ property EditConstraint edit
+
+ function trigger() {
+ change(variable, 55);
+ }
+
+ function change(v: Variable, newValue: int) {
+ edit = newEditConstraint.createObject(null, {myOutput: v}) as EditConstraint;
+ v.value = newValue;
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/shadowedAsCasts.qml b/tests/auto/qml/qmlcppcodegen/data/shadowedAsCasts.qml
new file mode 100644
index 0000000000..ccb50f4934
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/shadowedAsCasts.qml
@@ -0,0 +1,31 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ property ShadowedObjectName shadowed1: ShadowedObjectName {}
+ property ShadowedObjectName shadowed2: ShadowedObjectName {}
+ property QtObject shadowed3: ShadowedObjectNameDerived {}
+
+ function returnShadowed2() : QtObject { return shadowed2 }
+
+ function a(mark: int) {
+ // as-cast can be optimized out if we're clever.
+ (shadowed1 as QtObject).objectName = mark;
+ }
+
+ function b(mark: int) {
+ // method return values can contain shadowed properties!
+ returnShadowed2().objectName = mark;
+ }
+
+ function c(mark: int) {
+ // Has to do an actual as-cast, but results in ShadowedObjectNameDerived!
+ (shadowed3 as ShadowedObjectName).objectName = mark;
+ }
+
+ Component.onCompleted: {
+ a(43);
+ b(42);
+ c(41);
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/shadowedMethod.qml b/tests/auto/qml/qmlcppcodegen/data/shadowedMethod.qml
new file mode 100644
index 0000000000..590fb40b17
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/shadowedMethod.qml
@@ -0,0 +1,35 @@
+pragma Strict
+import QtQuick
+
+Item {
+ component B: Item {
+ function contains(point: point) : string {
+ return "b"
+ }
+ }
+
+
+ component C: Item {
+ function contains(point: point) : string {
+ return "c"
+ }
+ }
+
+ property Item a: Item {}
+ property B b: B {}
+ property C c: C {}
+
+ function doThing() : var { return a.contains(Qt.point(0, 0)) }
+
+ property var athing;
+ property var bthing;
+ property var cthing;
+
+ Component.onCompleted: {
+ athing = doThing();
+ a = b;
+ bthing = doThing();
+ a = c;
+ cthing = doThing();
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/shadowedPrimitiveCmpEqNull.qml b/tests/auto/qml/qmlcppcodegen/data/shadowedPrimitiveCmpEqNull.qml
new file mode 100644
index 0000000000..0e130b9afc
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/shadowedPrimitiveCmpEqNull.qml
@@ -0,0 +1,16 @@
+import QtQuick
+
+QtObject {
+ id: win
+
+ component Foo: QtObject {
+ property int progress: 0
+ }
+
+ property int progress: 0
+ readonly property Foo configuring: Foo {}
+
+ Component.onCompleted: {
+ win.configuring.progress = win?.progress ?? 0
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/shared/Slider.qml b/tests/auto/qml/qmlcppcodegen/data/shared/Slider.qml
index 58a567f4db..3a0349966d 100644
--- a/tests/auto/qml/qmlcppcodegen/data/shared/Slider.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/shared/Slider.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick 2.12
diff --git a/tests/auto/qml/qmlcppcodegen/data/signalsWithLists.qml b/tests/auto/qml/qmlcppcodegen/data/signalsWithLists.qml
new file mode 100644
index 0000000000..9a07b206d4
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/signalsWithLists.qml
@@ -0,0 +1,18 @@
+pragma Strict
+import QtQml
+import TestTypes
+
+Person {
+ property list<var> varlist: [1, "foo", this, undefined, true]
+ property list<QtObject> objlist: [this, null, this]
+
+ function sendSignals() {
+ variantListHappened(varlist);
+ objectListHappened(objlist);
+ }
+
+ property int happening: 0
+
+ onObjectListHappened: (objects) => { happening += objects.length }
+ onVariantListHappened: (variants) => { happening += variants.length }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/state.h b/tests/auto/qml/qmlcppcodegen/data/state.h
index 1afcebc4ea..708e681781 100644
--- a/tests/auto/qml/qmlcppcodegen/data/state.h
+++ b/tests/auto/qml/qmlcppcodegen/data/state.h
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef STATE_H
#define STATE_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/structuredValueType.qml b/tests/auto/qml/qmlcppcodegen/data/structuredValueType.qml
new file mode 100644
index 0000000000..158dff2d0b
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/structuredValueType.qml
@@ -0,0 +1,8 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ property rect r: ({x: 1, y: 2, width: 3, height: 4})
+ property rect r2: { var x = 42; return {x}; }
+ property weatherModelUrl w: ({ strings: ["one", "two", "three"] })
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/theme.cpp b/tests/auto/qml/qmlcppcodegen/data/theme.cpp
index c8a2612753..10302645c0 100644
--- a/tests/auto/qml/qmlcppcodegen/data/theme.cpp
+++ b/tests/auto/qml/qmlcppcodegen/data/theme.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "theme.h"
diff --git a/tests/auto/qml/qmlcppcodegen/data/theme.h b/tests/auto/qml/qmlcppcodegen/data/theme.h
index f70a3b440e..3e56ec1f9f 100644
--- a/tests/auto/qml/qmlcppcodegen/data/theme.h
+++ b/tests/auto/qml/qmlcppcodegen/data/theme.h
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef THEME_H
#define THEME_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/thisObject.qml b/tests/auto/qml/qmlcppcodegen/data/thisObject.qml
new file mode 100644
index 0000000000..50664eced2
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/thisObject.qml
@@ -0,0 +1,11 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ property QtObject warned
+
+ function f(arg: QtObject) { warned = arg }
+ function warn() { f(this) }
+
+ Component.onCompleted: warn()
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/timelinetheme.cpp b/tests/auto/qml/qmlcppcodegen/data/timelinetheme.cpp
index 1853d2dc12..04e1797c7c 100644
--- a/tests/auto/qml/qmlcppcodegen/data/timelinetheme.cpp
+++ b/tests/auto/qml/qmlcppcodegen/data/timelinetheme.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include "timelinetheme.h"
diff --git a/tests/auto/qml/qmlcppcodegen/data/timelinetheme.h b/tests/auto/qml/qmlcppcodegen/data/timelinetheme.h
index 335e43b570..3e7da77cc9 100644
--- a/tests/auto/qml/qmlcppcodegen/data/timelinetheme.h
+++ b/tests/auto/qml/qmlcppcodegen/data/timelinetheme.h
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef TIMELINETHEME_H
#define TIMELINETHEME_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/topLevelComponent.qml b/tests/auto/qml/qmlcppcodegen/data/topLevelComponent.qml
new file mode 100644
index 0000000000..a73e28f642
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/topLevelComponent.qml
@@ -0,0 +1,14 @@
+pragma Strict
+import QtQml
+
+Component {
+ QtObject {
+ id: root
+
+ function myOpen() {
+ root.objectName = "foo"
+ }
+
+ Component.onCompleted: myOpen()
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/trigraphs.qml b/tests/auto/qml/qmlcppcodegen/data/trigraphs.qml
new file mode 100644
index 0000000000..e7bf5ccec9
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/trigraphs.qml
@@ -0,0 +1,5 @@
+import QtQml
+
+QtObject {
+ objectName: "??= ??/ ??' ??( ??) ??! ??< ??> ??-"
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/tst_qmlcppcodegen_verify.cpp b/tests/auto/qml/qmlcppcodegen/data/tst_qmlcppcodegen_verify.cpp
new file mode 100644
index 0000000000..02629ad7f6
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/tst_qmlcppcodegen_verify.cpp
@@ -0,0 +1,47 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+
+#include <QtTest>
+#include <QtCore/qobject.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qbytearray.h>
+
+class tst_QmlCppCodegenVerify : public QObject
+{
+ Q_OBJECT
+private slots:
+ void verifyGeneratedSources_data();
+ void verifyGeneratedSources();
+};
+
+void tst_QmlCppCodegenVerify::verifyGeneratedSources_data()
+{
+ QTest::addColumn<QString>("file");
+
+ QDir a(":/a");
+ const QStringList entries = a.entryList(QDir::Files);
+ for (const QString &entry : entries)
+ QTest::addRow("%s", entry.toUtf8().constData()) << entry;
+}
+
+void tst_QmlCppCodegenVerify::verifyGeneratedSources()
+{
+ QFETCH(QString, file);
+ QFile a(":/a/" + file);
+ QFile b(":/b/" + file.replace("codegen_test_module", "codegen_test_module_verify"));
+
+ QVERIFY(a.open(QIODevice::ReadOnly));
+ QVERIFY(b.open(QIODevice::ReadOnly));
+
+ const QByteArray aData = a.readAll();
+ const QByteArray bData = b.readAll()
+ .replace("verify/TestTypes", "TestTypes")
+ .replace("verify_TestTypes", "TestTypes");
+
+ QCOMPARE(aData, bData);
+}
+
+QTEST_MAIN(tst_QmlCppCodegenVerify)
+
+#include "tst_qmlcppcodegen_verify.moc"
diff --git a/tests/auto/qml/qmlcppcodegen/data/undefinedToDouble.qml b/tests/auto/qml/qmlcppcodegen/data/undefinedToDouble.qml
new file mode 100644
index 0000000000..e76443a2e0
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/undefinedToDouble.qml
@@ -0,0 +1,6 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ property double d: Math.max(undefined, 40)
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/urlString.qml b/tests/auto/qml/qmlcppcodegen/data/urlString.qml
index 511c54532c..a83855ebdb 100644
--- a/tests/auto/qml/qmlcppcodegen/data/urlString.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/urlString.qml
@@ -9,5 +9,12 @@ QtObject {
Component.onCompleted: {
c = "http://dddddd.com";
self.d = "http://aaaaaa.com";
+ myUrlChanged(c)
+ }
+
+ signal myUrlChanged(urlParam: url)
+
+ onMyUrlChanged: (urlParam) => {
+ objectName = urlParam;
}
}
diff --git a/tests/auto/qml/qmlcppcodegen/data/valueTypeCast.qml b/tests/auto/qml/qmlcppcodegen/data/valueTypeCast.qml
new file mode 100644
index 0000000000..a775773dda
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/valueTypeCast.qml
@@ -0,0 +1,43 @@
+pragma ValueTypeBehavior: Addressable
+import QtQml
+
+QtObject {
+ id: root
+ property rect r: Qt.rect(10, 20, 3, 4)
+ property var v: r
+ property real x: (v as rect).x
+
+ function f(input: bool) : var {
+ if (input)
+ return 0
+ return Qt.point(2, 2)
+ }
+
+ property var vv: Qt.point(5, 5)
+ property var uu: undefined
+
+ property int tv3: (root.vv as point)?.x
+ property var tv4: (root.uu as rect)?.x
+ property int tc3: (root?.vv as point)?.y
+ property var tc6: (root?.uu as rect)?.height
+ property var tc7: (f(true) as point)?.x
+ property var tc8: (f(false) as point)?.x
+
+ property string greeting1
+ property string greeting2
+
+ readonly property string defaultGreeting: "Default Greeting"
+ property QtObject o: QtObject {
+ id: o
+ property var customGreeting
+ function greet() : string {
+ return (o.customGreeting as string) ?? root.defaultGreeting
+ }
+ }
+
+ Component.onCompleted: {
+ root.greeting1 = o.greet()
+ o.customGreeting = "Custom Greeting"
+ root.greeting2 = o.greet()
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/valueTypeCopy.qml b/tests/auto/qml/qmlcppcodegen/data/valueTypeCopy.qml
index cca634753d..d33133bb6b 100644
--- a/tests/auto/qml/qmlcppcodegen/data/valueTypeCopy.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/valueTypeCopy.qml
@@ -1,4 +1,4 @@
-pragma ValueTypeBehavior: Copy
+pragma ValueTypeBehavior: Copy, Addressable
import QtQml
QtObject {
diff --git a/tests/auto/qml/qmlcppcodegen/data/valueTypeDefault.qml b/tests/auto/qml/qmlcppcodegen/data/valueTypeDefault.qml
new file mode 100644
index 0000000000..42a55e832d
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/valueTypeDefault.qml
@@ -0,0 +1,34 @@
+import QtQml
+
+
+QtObject {
+ id: root
+
+ property list<double> numbers: {
+ var result = [];
+ for (var i = 0; i < 10; ++i)
+ result[i] = i;
+ return result;
+ }
+
+ property rect r: ({x: 1, y: 2, width: 3, height: 4})
+
+ function evil() : double {
+ var numbers = root.numbers;
+ root.numbers = [];
+ var a = 0;
+ for (var j = 0; j < 10; ++j) {
+ a += numbers[j];
+ }
+ return a;
+ }
+
+ function fvil() : double {
+ var r = root.r;
+ root.r = {x: 5, y: 6, width: 7, height: 8};
+ return r.x;
+ }
+
+ property double e: evil()
+ property double f: fvil()
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/valueTypeReference.qml b/tests/auto/qml/qmlcppcodegen/data/valueTypeReference.qml
index 568f39820c..a87f88ecf9 100644
--- a/tests/auto/qml/qmlcppcodegen/data/valueTypeReference.qml
+++ b/tests/auto/qml/qmlcppcodegen/data/valueTypeReference.qml
@@ -1,4 +1,4 @@
-pragma ValueTypeBehavior: Reference
+pragma ValueTypeBehavior: Reference, Inaddressable
import QtQml
QtObject {
diff --git a/tests/auto/qml/qmlcppcodegen/data/variantMap.qml b/tests/auto/qml/qmlcppcodegen/data/variantMap.qml
new file mode 100644
index 0000000000..d7147ec5fc
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/variantMap.qml
@@ -0,0 +1,27 @@
+pragma Strict
+import QtQml
+
+QtObject {
+ property Component shadowable: QtObject {}
+ property B b: B { id: theB }
+ property rect r: theB.r
+ property var v: { "1": null, "25": undefined, "19": "19" }
+
+ property Component c: Component {
+ id: unshadowable
+ QtObject {}
+ }
+
+ // We need this extra function in order to coerce the result of the shadowable
+ // method call back to QtObject
+ function createShadowable() : QtObject {
+ return shadowable.createObject(this, {objectName: "a"})
+ }
+
+ objectName: {
+ return createShadowable().objectName
+ + " " + unshadowable.createObject(this, {objectName: "b"}).objectName
+ }
+
+ Component.onCompleted: b.r = { x: 12, y: 13, width: 14, height: 15 }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.h b/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.h
new file mode 100644
index 0000000000..61d38228b0
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.h
@@ -0,0 +1,17 @@
+#pragma once
+#include <QObject>
+#include <QVariantMap>
+#include <QtQml/qqmlregistration.h>
+
+class VariantMapLookupFoo : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ Q_PROPERTY(QVariantMap data READ data CONSTANT)
+
+public:
+ VariantMapLookupFoo(QObject *parent = nullptr) : QObject(parent) { }
+
+private:
+ QVariantMap data() const { return { { "value", 42 } }; }
+};
diff --git a/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.qml b/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.qml
new file mode 100644
index 0000000000..4e56cb9448
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/variantMapLookup.qml
@@ -0,0 +1,11 @@
+pragma Strict
+import TestTypes
+import QtQuick
+
+Item {
+ property int i: moo.data.value
+
+ VariantMapLookupFoo {
+ id: moo
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/variantReturn.qml b/tests/auto/qml/qmlcppcodegen/data/variantReturn.qml
new file mode 100644
index 0000000000..cca26265c9
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/variantReturn.qml
@@ -0,0 +1,15 @@
+pragma Strict
+import QtQml
+import TestTypes
+
+QtObject {
+ property DirectBindable a: DirectBindable {
+ id: aId
+ x: WeatherModelUrlUtils.url(1)
+ }
+
+ property IndirectBindable b: IndirectBindable {
+ id: bId
+ y: aId.x
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/variantreturn.h b/tests/auto/qml/qmlcppcodegen/data/variantreturn.h
new file mode 100644
index 0000000000..87718aaef3
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/variantreturn.h
@@ -0,0 +1,63 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef VARIANTERETURN_H
+#define VARIANTERETURN_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qproperty.h>
+#include <QtQml/qqmlregistration.h>
+
+#include "weathermoduleurl.h"
+
+class DirectBindable : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ Q_PROPERTY(WeatherModelUrl x READ x WRITE setX NOTIFY xChanged BINDABLE bindableX)
+
+public:
+ explicit DirectBindable(QObject *parent = nullptr) : QObject(parent) {}
+
+ WeatherModelUrl x() const { return m_x.value(); }
+ void setX(const WeatherModelUrl& newX) { m_x.setValue(newX);}
+ QBindable<WeatherModelUrl> bindableX() { return QBindable<WeatherModelUrl>(&m_x); }
+
+Q_SIGNALS:
+ void xChanged();
+
+private:
+ Q_OBJECT_BINDABLE_PROPERTY(DirectBindable, WeatherModelUrl, m_x, &DirectBindable::xChanged)
+};
+
+class IndirectBindable : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ Q_PROPERTY(WeatherModelUrl y READ y WRITE setY NOTIFY yChanged BINDABLE bindableY)
+ Q_PROPERTY(int z READ z NOTIFY zChanged)
+
+public:
+ explicit IndirectBindable(QObject *parent = nullptr) : QObject(parent) {
+ m_z.setBinding([this]()->int {
+ return m_y.value().timeIndex() * 2;
+ });
+ }
+
+ WeatherModelUrl y() const { return m_y.value(); }
+ void setY(const WeatherModelUrl& newY) { m_y.setValue(newY); }
+ QBindable<WeatherModelUrl> bindableY() { return QBindable<WeatherModelUrl>(&m_y); }
+
+ int z() const { return m_z.value(); }
+ QBindable<int> bindableZ() const { return QBindable<int>(&m_z); }
+
+Q_SIGNALS:
+ void yChanged();
+ void zChanged();
+
+private:
+ Q_OBJECT_BINDABLE_PROPERTY(IndirectBindable, WeatherModelUrl, m_y, &IndirectBindable::yChanged)
+ Q_OBJECT_BINDABLE_PROPERTY(IndirectBindable, int, m_z, &IndirectBindable::zChanged)
+};
+
+#endif // VARIANTRETURN_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/voidConversion.qml b/tests/auto/qml/qmlcppcodegen/data/voidConversion.qml
new file mode 100644
index 0000000000..f5826d9e48
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/voidConversion.qml
@@ -0,0 +1,10 @@
+import QtQml
+
+QtObject {
+ id: item
+ property point p: Qt.point(20, 10)
+
+ Component.onCompleted: {
+ item.p = undefined
+ }
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/weathermoduleurl.h b/tests/auto/qml/qmlcppcodegen/data/weathermoduleurl.h
new file mode 100644
index 0000000000..998118dc5b
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/weathermoduleurl.h
@@ -0,0 +1,61 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#ifndef WEATHERMODELURL_H
+#define WEATHERMODELURL_H
+
+#include <QtQml/qqmlregistration.h>
+#include <QtCore/qobject.h>
+
+class WeatherModelUrl
+{
+ Q_GADGET
+ QML_STRUCTURED_VALUE
+ QML_VALUE_TYPE(weatherModelUrl)
+ Q_PROPERTY(qsizetype timeIndex READ timeIndex CONSTANT)
+ Q_PROPERTY(QStringList strings READ strings WRITE setStrings)
+
+public:
+ WeatherModelUrl() : m_timeIndex(-1) {}
+ WeatherModelUrl(qsizetype timeIdx) : m_timeIndex(timeIdx) {}
+
+ qsizetype timeIndex() const { return m_timeIndex; }
+
+ QStringList strings() const { return m_strings; }
+ void setStrings(const QStringList &newStrings)
+ {
+ if (m_strings != newStrings)
+ m_strings = newStrings;
+ }
+
+private:
+ friend bool operator==(const WeatherModelUrl &a, const WeatherModelUrl &b)
+ {
+ return a.m_timeIndex == b.m_timeIndex;
+ }
+
+ friend bool operator!=(const WeatherModelUrl &a, const WeatherModelUrl &b)
+ {
+ return !(a == b);
+ }
+
+ qsizetype m_timeIndex;
+ QStringList m_strings;
+};
+
+class WeatherModelUrlUtils : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ QML_SINGLETON
+
+public:
+ WeatherModelUrlUtils(QObject *parent = nullptr) : QObject(parent) {}
+
+ Q_INVOKABLE static WeatherModelUrl url(int timeIdx)
+ {
+ return WeatherModelUrl(timeIdx);
+ }
+};
+
+#endif // WEATHERMODELURL_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/withlength.h b/tests/auto/qml/qmlcppcodegen/data/withlength.h
index ba95522c53..26c6307f2b 100644
--- a/tests/auto/qml/qmlcppcodegen/data/withlength.h
+++ b/tests/auto/qml/qmlcppcodegen/data/withlength.h
@@ -1,11 +1,13 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef WITHLENGTH_H
#define WITHLENGTH_H
#include <QtCore/qobject.h>
-#include <QtQmlIntegration/qqmlintegration.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qrect.h>
+#include <QtQml/qqml.h>
struct ValueTypeWithLength
{
@@ -18,6 +20,8 @@ struct ValueTypeWithLength
public:
ValueTypeWithLength() = default;
Q_INVOKABLE ValueTypeWithLength(int length) : m_length(length) {}
+ Q_INVOKABLE ValueTypeWithLength(QPointF point) : m_length(point.manhattanLength()) {}
+ Q_INVOKABLE ValueTypeWithLength(QRectF rect) : m_length(rect.width()) {}
Q_INVOKABLE QString toString() const { return QStringLiteral("no"); }
int length() const { return m_length; }
@@ -26,4 +30,24 @@ private:
int m_length = 19;
};
+struct InnerWithLength {
+ int m_length;
+};
+
+struct UnconstructibleWithLength
+{
+ Q_GADGET
+ QML_VALUE_TYPE(unconstructibleWithLength)
+
+ QML_FOREIGN(InnerWithLength)
+ QML_EXTENDED(UnconstructibleWithLength)
+
+public:
+ UnconstructibleWithLength() = default;
+ Q_INVOKABLE UnconstructibleWithLength(int length) : v{length} {}
+
+private:
+ InnerWithLength v;
+};
+
#endif // WITHLENGTH_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/wrapwithvariant.h b/tests/auto/qml/qmlcppcodegen/data/wrapwithvariant.h
index dce78fa9c9..7de49f095a 100644
--- a/tests/auto/qml/qmlcppcodegen/data/wrapwithvariant.h
+++ b/tests/auto/qml/qmlcppcodegen/data/wrapwithvariant.h
@@ -1,5 +1,5 @@
// Copyright (C) 2022 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef WRAPWITHVARIANT_H
#define WRAPWITHVARIANT_H
diff --git a/tests/auto/qml/qmlcppcodegen/data/writableVariantMap.h b/tests/auto/qml/qmlcppcodegen/data/writableVariantMap.h
new file mode 100644
index 0000000000..3c0fedd28b
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/writableVariantMap.h
@@ -0,0 +1,31 @@
+#pragma once
+#include <QObject>
+#include <QVariantMap>
+#include <QtQml/qqmlregistration.h>
+
+class WritableVariantMap : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ Q_PROPERTY(QVariantMap data READ data WRITE setData NOTIFY dataChanged)
+
+public:
+ WritableVariantMap(QObject *parent = nullptr) : QObject(parent) { }
+
+ QVariantMap data() const { return m_data; }
+ void setData(const QVariantMap &data)
+ {
+ if (m_data != data) {
+ m_data = data;
+ emit dataChanged();
+ }
+ }
+
+signals:
+ void dataChanged();
+
+private:
+ QVariantMap m_data;
+};
+
+
diff --git a/tests/auto/qml/qmlcppcodegen/data/writeVariantMap.qml b/tests/auto/qml/qmlcppcodegen/data/writeVariantMap.qml
new file mode 100644
index 0000000000..536e53b408
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/writeVariantMap.qml
@@ -0,0 +1,10 @@
+pragma Strict
+import StringBuilderTestTypes
+
+WritableVariantMap {
+ id: dragSource
+ property string modelData: "Drag Me"
+ data: ({
+ "text/plain": "%" + dragSource.modelData + "%"
+ })
+}
diff --git a/tests/auto/qml/qmlcppcodegen/data/writeback.qml b/tests/auto/qml/qmlcppcodegen/data/writeback.qml
new file mode 100644
index 0000000000..359f00efb7
--- /dev/null
+++ b/tests/auto/qml/qmlcppcodegen/data/writeback.qml
@@ -0,0 +1,43 @@
+pragma Strict
+
+import TestTypes
+import QtQml
+
+Person {
+ id: self
+
+ area {
+ width: 19
+ height: 199
+ }
+
+ property list<int> ints: [4, 3, 2, 1]
+
+ property outer recursive
+ property Person shadowable: Person {
+ id: notShadowable
+ area.width: self.area.width
+ area2.height: self.area2.height
+ }
+
+ Component.onCompleted: {
+ area.width = 16
+ area2.height = 17
+
+ self.area.x = 4
+ self.area2.y = 5
+
+ // You cannot do this on the shadowable Person because
+ // shadowable.area may not actually be a QRectF anymore.
+ notShadowable.area.x = 40
+ notShadowable.area2.y = 50
+
+ self.recursive.inner.i = 99;
+
+ self.ints[0] = 12;
+ ints[1] = 22;
+ ints[6] = 33;
+ }
+
+ property int inner: recursive.inner.i
+}