aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qmltc
Commit message (Collapse)AuthorAgeFilesLines
* Fix qqmlcpptypehelpers_p.h header guard nameMarc Mutz2025-06-241-3/+3
| | | | | | | | | | The _P was missing... Amends ee9e3a10d967874eddc5400b2b7aa36950140b9b. Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I316460d0cb831f1cf8b7394eb7795aafa7017993 Reviewed-by: Sami Shalayel <[email protected]>
* Remove the use of Q_QML_PRIVATE_EXPORTAlexey Edelev2024-01-113-3/+3
| | | | | | Task-number: QTBUG-117983 Change-Id: I5790f01d614cd70c7fcc9bd817ec6ace3f3e3730 Reviewed-by: Ulf Hermann <[email protected]>
* QML: code tidies: use the 4-arg connect overloadGiuseppe D'Angelo2023-10-281-2/+3
| | | | | | | | | The 3-arg connect is error-prone and makes the lifetime of the connection unclear. Change-Id: I15447e02bbc167e805db10350eb4887b10f2a745 Reviewed-by: Ahmad Samir <[email protected]> Reviewed-by: Ulf Hermann <[email protected]>
* QtQml: Clean up lazy-loading of parts of QQmlTypePrivateUlf Hermann2023-07-111-1/+0
| | | | | | | | | | | | | | | | | The meta objects and the enums are lazily loaded semi-independently from each other. Their data structures take up a lot of space. We only want to incur that cost if they are actually needed. Furthermore, the lazy-loading needs to be thread-safe. The easiest way to make a thread safe lazy loading structure is via a mutable atomic pointer to an immutable object. Refactor QQmlTypePrivate to do just that. This reduces the memory usage of the base structure by about 50%, cuts down on the locking required to set up the extra aspects, and generally makes the code more readable. Change-Id: I815338d3e4de02b2f535ab2fee748bba47719efc Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
* QQmlType: Re-organize QQmlTypePrivate to reduce memory usageUlf Hermann2023-07-061-16/+16
| | | | | | | | | | | | The iid is only used for interfaces, and re-ordering the members saves some padding. Also, avoid extra indirection where possible. QUrl is only one pointer to begin with, just like QMetaSequence. We can store them directly in the union. Finally, rename the extraData members so that we can easily recognize them. Change-Id: Ia9c524ea65f8137b264a7dfd9459369c90ce1670 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
* qmltc: fix handlers for c++-signalsSami Shalayel2022-12-071-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow qmltc to generate handlers for c++-defined signals with const parameters by changing the safeguard to avoid type mismatch between slots and signals. First, remove the qOverload in the generated QObject::connect call to be able the connect slots and signals with different types (namely, pass by const references and pass by value should be interchangeable but is not allowed by qOverload). Second, save in QQmlJSMetaParameter when types are passed by pointer. Like this, qqmljsimportvisitor can check if a value type is indeed passed by value or const reference in a C++ signal. The same for reference types that need to be passed by (const and non-const) pointer. Print a message when an type is passed by argument in an incompatible way instead of letting qmltc generate uncompilable code, which makes the compiler print out cryptical messages. Third, add a qqmlcpptypehelpers template that decides if value types should be passed by value or reference, by letting the c++ compiler check if sizeof(T) > 3*sizeof(void*). Fixes: QTBUG-107625 Fixes: QTBUG-107622 Change-Id: I1a00532df591d10f74c1fd00dff5b7fccf40cb22 Reviewed-by: Ulf Hermann <[email protected]>
* Create Translation Bindings without CompiledData::BindingSami Shalayel2022-08-152-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To add translation bindings to qmltc, the methods used to create translation bindings need to be adapted to work without QV4::CompiledData::Binding as it is not available from qmltc. Instead, information already available from the QQmlJSScope should be used, along with a newly introduced helper class QQmlTranslation. Details: Add a QQmlTranslation class that represents a call to qsTr, qsTrId etc that knows how to translate itself (without needing any ExecutableCompilationUnit or Binding). It encapsulates the information needed to create a translation binding. ExecutableCompilationUnit::bindingValueAsString refactored so its functionality can be used without Binding. Instead, it uses only the translationId, see ExecutableCompilationUnit::translateFromId and ExecutableCompilationUnit::translateFrom. Refactored QQmlTranslationBinding to work with QQmlTranslation instead of CompiledData::Binding. Same for QQmlCppBinding::createTranslationBindingForBindable, QQmlTranslationPropertyBinding::create and QQmlCppBinding::createTranslationBindingForNonBindable. Changed TranslationBindingInformation to work without CompiledData::Binding, and also removed static unused QString ProxyTranslator::originStringFromInformation( const TranslationBindingInformation &translationBindingInformation) as I could not find out what this origin string is. Same for the translation debugging in qmldb_preview. Added QmltcCodeGenerator::generate_createTranslationBindingOnProperty. Added #if to avoid compilation error for standalone DOM compilation due to the new QQmlTranslation class. Task-number: QTBUG-105345 Change-Id: Iccd94d5cba4eaf63901233451fec48051c855c2a Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
* Fix QQmlTypePrivate memory leak in qmltc-generated types with extensionsAndrei Golubev2022-06-152-8/+7
| | | | | | | | | | | | | | | | | Apparently registering the QQmlTypePrivate for a meta-object is not good enough. Somehow clang's ASan failed to discover a memory leak but gcc's ASan did not. After carefully exercising the code and a bit of debugging, turns out we indeed not release manually created QQmlTypePrivate objects. Do release the QQmlTypePrivate correctly now In the process of doing so, remove now-redundant QMetaObject function parameter Amends 26179e693717535eeff2e7b2a6ee99dc02dcd8f9 Pick-to: 6.4 Change-Id: Ia0c808cd8a09cf996672bca9953108facfdf5d4e Reviewed-by: Ulf Hermann <[email protected]>
* Use SPDX license identifiersLucie Gérard2022-06-116-228/+12
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <[email protected]>
* Address extension types in qmltcAndrei Golubev2022-06-022-1/+120
| | | | | | | | | | | | | | | | | | | | | Whenever working with properties (reading, writing, aliasing, etc.) of the type that has extensions, prefer the same-named properties from extension objects over type-owned properties (this is the internal QML mechanism) To achieve that, we need to query the extension object: * for Q_GADGETs use a dummy model of assuming we can cast the object to the extension type and use that * for Q_OBJECTs use a qmlExtendedObject() with additional logic of figuring out which extension should be picked in each specific case Create QQmlProxyMetaObject via a custom dynamic meta object API for qmltc-compiled objects that are derived from base types with extensions Task-number: QTBUG-91956 Change-Id: I5e783768ae2abdb9dddf894de7e79960244352bd Reviewed-by: Ulf Hermann <[email protected]>
* qmltc: Migrate to new object creation/querying mechanismAndrei Golubev2022-03-301-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | Serves two things: a) Provides faster/more correct object creation model (long-term) b) Eliminates (more of) prototype's code generation (short-term) The whole object querying now works implicitly through the std::array<QObject *> that QQmltcObjectCreationBase provides. The creation logic is still rather recursive with regards to QML base types processing - unfortunately, we cannot simplify this part now as qmltc requires deeper introspection into the imported types (this in turn requires fiddling with QQmlJSTypeReader and QDeferredFactory<QQmlJSScope>::create()) Since we now use the new object creation pattern, prototype/codegenerator no longer needs high-level compilation methods. So replace prototype's code accordingly with qmltccompiler bits. We can also de-duplicate enum and property compilation (aliases are not touched for simplification) from prototype. Methods and bindings have to rely on prototype and QmlIR at present, their compilation is moved more-or-less unchanged Task-number: QTBUG-84368 Change-Id: I584ceb8f2e3c9f3f79530b02d1c88a4f6c2d06c9 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Ulf Hermann <[email protected]>
* Make sure all private headers include at least one otherThiago Macieira2022-03-101-0/+1
| | | | | | | | | | See script in qtbase/util/includeprivate for the rules. Since these files are being touched anyway, I also ran the updatecopyright.pl script too. Change-Id: Ib056b47dde3341ef9a52ffff13ef677e471674b6 Reviewed-by: Mitch Curtis <[email protected]>
* Fix warnings from gcc 11.2 about ignoring [[maybe_unused]]Edward Welbourne2021-12-181-1/+2
| | | | | | | | | | | | | | QQmltcObjectCreationHelper::m_size was declared [[maybe_unused]] because it's only used in assertions; but this means the compiler can see, in a debug build, that it is used, so the [[maybe_unused]] is ignored; which means a build gets spammed with warnings about the attempt to suppress an unused member warning. Replace the [[maybe_unused]] on the declaration with a Q_UNUSED(m_size) in the constructor body. Change-Id: I747059d091384b4b90069be30bc8d5ffa6dbc7d7 Reviewed-by: Thiago Macieira <[email protected]> Reviewed-by: Andrei Golubev <[email protected]>
* Use qmltc compiler prototype as a fallback implementationAndrei Golubev2021-12-174-0/+373
| | | | | | | | | | Task-number: QTBUG-91927 Task-number: QTBUG-96041 Task-number: QTBUG-84368 Pick-to: 6.3 Change-Id: I47320b5f3ed8efff6fb234778df5fae5be5b64f2 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
* Enhance QQmltcObjectCreationHelper::set() with an assertAndrei Golubev2021-11-231-1/+2
| | | | | | | | | | | | We don't really want to accidentally reset the pointer value after it has been set. So put an assert that should signal there's a bug in qmltc somewhere To actually make assert pass, initialize the pointer array as otherwise some random garbage will be there by default Change-Id: Ie93a41ab0e3d10d496c7d6651fa6e38796ceba1a Reviewed-by: Fabian Kosmale <[email protected]>
* qmltc: Introduce object creation infrastructureAndrei Golubev2021-11-151-0/+136
The so-far strategy is the following: * allocate a linear storage for the QObject pointers using QQmltcObjectCreationBase (to reference the to-be-created objects) * "type-erase" the QQmltcObjectCreationBase into QQmltcObjectCreationHelper (so now we don't need to know the template specialization across different QML documents): non-document roots' ctors can accept QQmltcObjectCreationHelper as an input parameter * use QQmltcObjectCreationHelper to set object pointers into the storage when creating all the objects (also from other QML documents) * use QQmltcObjectCreationHelper later to retrieve necessary objects during creation finalization Provide basic implementation for the first and second bullets straight away This model seems to allow to hide the details of QQmltcObjectCreationBase interaction within the QML top-level document root (the type that we instantiate in the user code), which is very convenient Task-number: QTBUG-84368 Change-Id: I04cf64c54e48f169acfd4337cf93a58a05336b3b Reviewed-by: Ulf Hermann <[email protected]>