aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmltc/prototype/codegenerator.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Improve the structure of the output generated by qmltcAndrei Golubev2022-01-311-1/+11
| | | | | | | | | | | | | | | Make an effort to separate user-visible APIs from internal code relevant to qmltc In the process of doing it, make tst_qmltc_examples::helloWorld() test less brittle by using QMap instead of QHash when dumping C++ member functions of the type. QHash does not guarantee that the keys are ordered while QMap does (via operator "<") Change-Id: I1495e1755d3fd77950acb3820ad2b9c5e3cdee33 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 0ad51325c7432c8a8da38580d26721455252e64f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmltc: Do not generate bindables and setters for QQmlListPropertyUlf Hermann2022-01-181-8/+12
| | | | | | | | | Assigning to a QQmlListProperty does not do what you think it does. Change-Id: Ie6ac3208d552d8f40d9f2f4d7fb33c1cd64e4b79 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit 134f305b7f96e1a127261bbfac9bdb1f3a22e546) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmltc: Support Component rootsAndrei Golubev2022-01-031-50/+116
| | | | | | | | | | | | | | | | | | | | | | | | | It is a very special case that doesn't undergo a normal compilation but instead just uses QQmlObjectCreator::createComponent() logic. As QQmlObjectCreator::createComponent() returns a new QQmlComponent, we can't use it within the qmltc-generated type's ctor. Instead, just fake the same flow by incorporating the code into the qmltc type setting As a drive-by, fix the code to work correctly with Component roots. This should now pretty much cover all the mystical logic of QQmlComponentAndAliasResolver and, with tests, we can safely simplify the qmltc code generator bits later without introducing bugs Enhance tst_qqmlcomponent::componentTypes test to highlight that property Component p: ComponentDerivedType {} is not marked with QV4::CompiledData::Object::IsComponent flag at all and thus considered to be an ordinary object binding, unlike property Component p: NotComponentDerivedType {} Change-Id: I4ec41952d15f9659d316e44dab4050aa4908327c Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io> (cherry picked from commit 39aee682bf388e191a409485cbbe2e01996bc163) Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: Support different property change handlersAndrei Golubev2021-12-241-24/+51
| | | | | | | | | | | | | | | | | qmltc must be able to compile property change handlers: - for bindable properties (with no notify) - for notifiable properties (with no bindable) - for both bindable and notifiable properties (preferring notify signal) Test the aforementioned cases and some signal handling cases along the way Task-number: QTBUG-84368 Change-Id: I2cd2d0ad6407889942c806e03831dec4c7ce265a Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io> (cherry picked from commit 71084db1df9453aa9c657b91f2dab6766a56903b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmltc: Remove non-compiled CodeGenerator::compileProperty()Andrei Golubev2021-12-241-86/+0
| | | | | | | | | | | This got missed in-between porting the prototype code to qtdeclarative Amends e7ce5abf24f04d1b071343f07ca28b6a5d9ad4b9 Change-Id: Id722b819f80b4925508bd71bd2f347a4915e330c Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io> (cherry picked from commit 14dda2f1a8169cad4a695e123f006f97d99ce5dd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmltc: Use special name for a special url-returning generated functionAndrei Golubev2021-12-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can in fact get ambiguity problem (which for some reason only results in an unused-function warning with clang 10) which practically results in UB in the user code relying on qmltc output (due to C++ compiler choosing the wrong function to call) Consider the following: // MyType.qml Component { QtObject{} } is compiled (by qmltc) into // mytype.h class MyType : public QQmlComponent {}; // mytype.cpp static const QUrl &url() { /* return this doc url */ } // ^ warning: unused-function MyType::MyType(/* ... */) { // ... auto compilationUnitUrl = url(); // oops! QQmlComponent::url() is used } Change-Id: Ic754ce90b66e3f371a89e2d3395ca7d6b022c694 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io> (cherry picked from commit 4355faedee5bb35854019cddfba516b61bd239e3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmltc: Drop duplicate "QQmlContextData::" in context set generationAndrei Golubev2021-12-241-2/+1
| | | | | | | | | | qmltc generates QQmlContextData::QQmlContextData::DocumentRoot so one "QQmlContextData::" is not needed Change-Id: Ice2bb1c221996f04d8107f6f6caec7f52aad3735 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io> (cherry picked from commit ea829498f4ca70d974058eb6eaa2e9cbcdf93198) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Unify common logic around QQmlJSScope and friendsAndrei Golubev2021-12-231-19/+18
| | | | | | | | | We have many things duplicated all over the place Change-Id: If929a5d683153781f6db630312240bf9c24ec777 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io> (cherry picked from commit 1d1ad6cbc79ab5eb3fad5cb604f5d4f5da8f35cd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmltc: Be aware of Component-wrapped typesAndrei Golubev2021-12-181-20/+41
| | | | | | | | | | | | | | | | | | | | | | While implicit components (the ones bound to Component-based property) are covered, cases like `Component { Text{} }` are not, so fix that Revisit the logic in the QmlIR / QQmlJSScope passes and code generator as part of this This might be a fairly used pattern in QML so no reason not to address this right away, especially given that we have most of the infrastructure in place already While at it, bring over extra tests that some other (non-merged) commit introduced. These give good coverage for missing cases and also exercise the feature supported here Task-number: QTBUG-84368 Change-Id: I8f5c74fc79380566475b1139d4cc5560fac123e3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 362b4bf3d6df1e1799a163d3e6d7ee39f75ad080) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* qmltc: Make special functions protectedAndrei Golubev2021-12-171-9/+27
| | | | | | | | | | | | | Special functions are only invoked internally by the qmltc-generated code. There is no reason in making them public as the compiler should know which exact type would use another type (and so can generate meaningful friend declarations) Task-number: QTBUG-84368 Change-Id: I887ca8db7f916dba042f0ccbf19085aa438bf82d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 9cf864654f9154be52a7279a341948eabacfb397) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Use qmltc compiler prototype as a fallback implementationAndrei Golubev2021-12-171-0/+1857
Task-number: QTBUG-91927 Task-number: QTBUG-96041 Task-number: QTBUG-84368 Change-Id: I47320b5f3ed8efff6fb234778df5fae5be5b64f2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit e7ce5abf24f04d1b071343f07ca28b6a5d9ad4b9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>