aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/abstractmetabuilder_helpers.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Move the shiboken-generator source aroundFriedemann Kleint2025-11-241-202/+0
| | | | | | | | | THIS COMMIT WAS GENERATED BY A SCRIPT Task-number: PYSIDE-962 Task-number: PYSIDE-1587 Change-Id: I58b05c3d05606efb6303193f2d7f907a0ab5741b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken6: Fix static analysis warningsFriedemann Kleint2024-06-241-4/+4
| | | | | | | | | | | | | | | | | | - Initialize variables - Use auto * - Use const references to prevent copies - Remove const from function returns - Remove repeated return types - Fix else after return/throw - Make functions const/static where appropriate - Add missing override - Fix some invocations of static methods - Fix some int types (qsizetype) to avoid lossy conversions - Minor cleanups - Remove some macros Change-Id: I414b8451703b136f135383289de49e743e84fb3a Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Fix passing static class fields as enum default valuesFriedemann Kleint2023-05-101-1/+6
| | | | | | | | | | | | | | | | Occurs in Qt 6.6: class QNativeIpcKey { enum class Type { SystemV = 0x51, PosixRealtime = 0x100, Windows }; static constexpr Type DefaultTypeForOs = Type::Windows ... QNativeIpcKey(Type type = DefaultTypeForOs) }; Pick-to: 6.5 Change-Id: Icf9abdd9ebe24eb4e1d145e65b27496545e327ef Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Port from QSharedPointer to std::shared_ptrFriedemann Kleint2023-01-051-2/+2
| | | | | | | Task-number: QTBUG-109570 Change-Id: Iabdafb0a5ab211e32c1bbf7face78fd5102a49b9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Use smart pointers for AbstractMetaClass instancesFriedemann Kleint2022-12-061-3/+3
| | | | | Change-Id: I101ca8ceea6ffa63ca8bd03e2e9adf7531cb8f80 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Purge remaining uses of old Qt string literalsFriedemann Kleint2022-11-221-4/+6
| | | | | | | | | | Amends a3e882b06eda8f9a63cf3834a99640034775269b. Pick-to: 6.4 Task-number: QTBUG-98434 Change-Id: I23ad60d6e4201aa2d8dbf3fa8892d3df3c56c5fc Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Use smart pointers for the TypeEntry classesFriedemann Kleint2022-11-171-5/+5
| | | | | | | | | | TypeEntry instances were previously stored and passed as raw pointers, which made it difficult to track ownership, particularly when synthesized classes were added. Change it to use QSharedPointer. Change-Id: I3612efbc5d467ebeac9aa5dda86c7439bbd03ddd Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-271-27/+2
| | | | | | | | | | | 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. Task-number: QTBUG-67283 Change-Id: I065150015bdb84a3096b5b39c061cf0a20ab637d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Split the typesystem headerFriedemann Kleint2022-05-171-1/+2
| | | | | | | | It was growing too large to be maintainable. Change-Id: I7d646fa92a08dd598d673c81668210c1b188b635 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Remove ShibokenGenerator::guessScopeForDefaultValue()Friedemann Kleint2021-11-051-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move resolving of class fields and enum values as argument default values into AbstractMetaBuilder. Handling of static class field constants was spread between AbstractMetaBuilderPrivate::fixDefaultValue() and ShibokenGenerator::guessScopeForDefaultValue(). The former was handling it for arguments of non-primitive type only and not completely expanding namespaces. The latter was handling it for arguments of primitive types, too, but also added some code for non-static fields, which cannot be used as default arguments in C++. ShibokenGenerator::guessScopeForDefaultValue() was handling enum values for primitive and values, excluding macros by regex, but otherwise not checking if the term is really an enum value. Rewrite the code in AbstractMetaBuilderPrivate::fixDefaultValue() without regexes for clarity, let it check fields and enum values correctly via code model and fully expand namespaces. Add tests. Adapt the signature module to the now fully qualified signatures. [ChangeLog][shiboken6] When qualifying function argument default values for the generated code, shiboken no longer considers each identifier it cannot otherwise find as an enum value and no longer adds the class scope to it. This may require manually adding some replace-default-expression modifications. Task-number: PYSIDE-1691 Pick-to: 6.2 Change-Id: Id4cd2ca1f91db8c1663d7fc31e4b4ef72a5690f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Implement enum search by value in code modelFriedemann Kleint2021-11-051-19/+0
| | | | | | | | | | | | | | | | | | | | | | | | Replace (currently unused) AbstractMetaBuilder::searchForEnumScope() by _ScopeModelItem::findEnumByValue() returning an enum and the fully qualified name. This function is intended for resolving enum values used as default values for functions taking int where the underlying enum is not known. As opposed to old code, all parts of a (partially) qualified name are checked for a match to ensure no mismatches of equally named values. Another advantage is that also enum values that are not in the type system are found. The function returns the fully qualified name (also including the enum name for non-class type enums). Task-number: PYSIDE-1691 Pick-to: 6.2 Change-Id: I89ebfdf8435470c626cfdee4fc0d0738cc3fc195 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Do not try to qualify Qt namespace constants in default argumentsFriedemann Kleint2021-11-021-0/+1
| | | | | | | | | | Amends 6c2c4c00bc38bc9dc7b3c2f82fa8b12053902e71. Task-number: PYSIDE-1691 Pick-to: 6.2 Change-Id: I6c8d09d098d3767eb8a518cfcf582a25c715e4a1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Extend checks when not to fix a default valueFriedemann Kleint2021-10-251-4/+21
| | | | | | | | | | | | | | | | | | | Exclude numeric constants, boolean literals, initializer lists and similar to prevent scope lookups for them. Remove the conversion of integers to boolean literals from AbstractMetaBuilderPrivate::fixDefaultValue(), since the type name was misspelt ("boolean" instead of "bool") and bool constructs from integers anyways. Rename helper isNumericConstantt() to isIntegerConstant() for clarity. Amends 2efc3669d07f77a08e334cf37913017523b8099b. Task-number: PYSIDE-1691 Pick-to: 6.2 Change-Id: If74858ed0a4f16653d73220f33c4a98254dc5173 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Improve fixing of enum default values of function argumentsFriedemann Kleint2021-10-211-0/+200
shiboken needs to fully qualify default arguments of functions so that they can be used outside the respective's class scope. This happens in AbstractMetaBuilderPrivate::fixDefaultValue() and ShibokenGenerator::guessScopeForDefaultValue(). This was confusing particularly for enums and flags, where AbstractMetaBuilderPrivate::fixDefaultValue() was doing a simple expansion and further cases were handled in ShibokenGenerator::guessScopeForDefaultFlagsValue(). To improve this and get it tested, move the enum/flags code completely over to AbstractMetaBuilder, restructure it, rewrite the helpers in terms of QStringView and make it a bit smarter: - Check for hex numbers as well. - No longer add a cast when constructing QFlags from a number(saves the need to observe the protected hack). - Expand expressions "A | B" as was before and additionally within a type cast "Options(A | B)". - Add a test. Task-number: PYSIDE-1691 Pick-to: 6.2 Change-Id: I198995508e8ed01710a44708c425c31308908445 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>