aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/abstractmetabuilder.h
Commit message (Collapse)AuthorAgeFilesLines
* Move the shiboken-generator source aroundFriedemann Kleint2025-11-241-153/+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 clazy warnings about too-large underlying types of enumerationsFriedemann Kleint2025-10-021-2/+2
| | | | | | | Use the types suggested by clang-tidy. Change-Id: I0bc80d00e75305423caa4254b1383979e89128ec Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Port to Qt include styleFriedemann Kleint2025-03-271-1/+1
| | | | | | | | | Replace the Qt forwarding headers by the .h files. This brings down the dependency list by approx 6%. Pick-to: 6.9 Change-Id: Iaa57400fd20600b940119a6016041b885a68d207 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Reduce warnings about rejected functions/fieldsFriedemann Kleint2025-02-281-0/+1
| | | | | | | | | | | | | For rejected functions, print the warnings only for abstract functions, which can cause a compilation error. For fields, add the warning about mismatched type to the log file instead of printing it. [ChangeLog][shiboken6] Warnings about rejected functions/fields have been removed or redirected to the log files. Pick-to: 6.8 Change-Id: Iaf1b9cc419867153c2f241a054a7f4d91fc6bbb3 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Fix type names of smart pointers in namespaces in the cppApi arrayFriedemann Kleint2024-06-041-4/+3
| | | | | | | | | | | | | | | | | | | | | Set the correct parent entry on the smart pointer instantiation type entry. This allows for removing a special case in the source generator and namespaces will be correctly reflected. It is also the prerequisite for a follow-up change making it possible to use global namespaces for smart pointers in namespaces. Also remove the setting of the enclosing class and the associated flag InheritTemplateFlag::SetEnclosingClass from AbstractMetaBuilderPrivate::inheritTemplate(). Instead, always set the enclosing class in ApiExtractorPrivate::addInstantiatedSmartPointer() instead, depending on the type of the parent entry. Task-number: PYSIDE-2404 Task-number: PYSIDE-2768 Pick-to: 6.7 Change-Id: I921e255c2ceaeb9eaf84e5ac1c4953bcf7d09b57 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Register typedefs of container typesFriedemann Kleint2024-03-181-0/+1
| | | | | | | | | | | | | | | | | | For signals like QRemoteObjectRegistry.remoteObjectAdded(QRemoteObjectSourceLocation) where using QRemoteObjectSourceLocation = std::pair<QString,QRemoteObjectSourceLocationInfo> one needed to specify the fully qualified C++ name in @Slot() for the metaobject system to work and the shiboken converter to be found. Record the typedefs and register the container converters under the typedef name, too. Fixes: PYSIDE-2633 Change-Id: Ifc62f096277949a507957a0466adb47d082695c7 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* shiboken6: Fix special functionsFriedemann Kleint2023-10-051-0/+2
| | | | | | | Pick-to: 6.6 Task-number: PYSIDE-2479 Change-Id: I858b53e45cf73d1fa8d695530e529aed7aa8e79b Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Log rejected operatorsFriedemann Kleint2023-05-111-0/+1
| | | | | | | | | Add a new section to the rejected functions section for operator where no base class can be found. Pick-to: 6.5 Change-Id: Id8af7a1c73e49854d33f85d95c26710d4c8f026c Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Refactor reject logicFriedemann Kleint2023-05-111-1/+0
| | | | | | | | | | | | | | Introduce a struct with type signature, sortkey and reason for rejected entries instead of using a QMap. This allows for sorting rejected functions by function signature excluding return type such that members of a class show up in a group. Remove unused enum value "ApiIncompatible". Pick-to: 6.5 Change-Id: I0ea29c8163c6eba2abba843355f9a9940e416d7c Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Fix passing static class fields as enum default valuesFriedemann Kleint2023-05-101-1/+2
| | | | | | | | | | | | | | | | 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/clang: Suppress class scope look up for parameters with scope ↵Friedemann Kleint2023-04-281-1/+2
| | | | | | | | | | | | resolution Add a flag to AbstractMetaBuilderPrivate::findTypeEntriesHelper() to suppress the class scope look in case scope resolution. Task-number: PYSIDE-2288 Pick-to: 6.5 5.15 Change-Id: I04a4810d03845fb48393c5efed3641220bd12d87 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6/clang: Fix clashes between type name and enumeration valuesFriedemann Kleint2023-04-251-1/+2
| | | | | | | | | | | Remove all constant and enum value type entries found in the type lookup unless it is looking for template arguments; where it may be a non-type template argument. Task-number: PYSIDE-2288 Pick-to: 6.5 5.15 Change-Id: If0609ce0d0223f551ed6dee1d1e0ea3ef49d6917 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Use smart pointers for AbstractMetaClass instancesFriedemann Kleint2022-12-061-8/+8
| | | | | Change-Id: I101ca8ceea6ffa63ca8bd03e2e9adf7531cb8f80 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Use smart pointers for the TypeEntry classesFriedemann Kleint2022-11-171-2/+3
| | | | | | | | | | 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: Skip Q_ENUM helper functions when PySide extensions are enabledFriedemann Kleint2022-05-181-0/+2
| | | | | | | | | | | | | | | | | | The helper functions qt_getEnumMetaObject() and qt_getEnumName() defined by Q_ENUM had to be rejected in the typesystem files in each namespace. Pass the ApiExtractor flags to the meta builder to cleanly detect all Qt special functions and automatically reject them when PySide extensions are enabled. [ChangeLog][shiboken6] The Q_ENUM helper functions qt_getEnumMetaObject() and qt_getEnumName() are now automatically rejected when PySide extensions are enabled. Fixes: PYSIDE-1932 Pick-to: 6.3 Change-Id: Iceb5f0c3175ecaef657ae71adf6a5b8bf48af740 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Move ownership of the metabuilder classes into ApiExtractorResultFriedemann Kleint2022-04-301-0/+3
| | | | | | | | | | | | | | | | | | ApiExtractorResult kept flat pointer lists of the metabuilder classes which were owned by AbstractMetaBuilder. This meant ApiExtractor/AbstractMetaBuilder had to be kept around while the generators were run. After some failed attempts to use a QSharedPointer for the metabuilder classes to fix the ownership, introduce a QExplicitlySharedDataPointer keeping a class ApiExtractorResultData which maintains ownership of the classes. ApiExtractorResult can then be used independent of ApiExtractor/AbstractMetaBuilder. Pick-to: 6.3 Change-Id: I6f9326d6349ac5c32fd1c7dc8103e961bc353898 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix include conventionsFriedemann Kleint2022-04-221-1/+1
| | | | | | | | | Reorder includes such that local includes are first, followed by Qt and C/C++ system includes. Pick-to: 6.3 6.2 Change-Id: Ib801d34de7242befce4be429bfb099ccabe1f987 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Extract utility to inherit template classesFriedemann Kleint2022-04-191-0/+7
| | | | | | Task-number: PYSIDE-454 Change-Id: If71f984422c8d3cf98b33b36999a4b26b9ad4165 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Refactor smartpointer getter creationFriedemann Kleint2022-03-221-0/+20
| | | | | | | | | | | | | | | The code generating the smart pointer getter performed the template specialization to the instantiated type using parsing types from string. Since there is code doing template specialization for member functions in AbstractMetaBuilder, split it into usable functions and make them accessible via ApiExtractor. Use them it to do the specialization for the getter method. Task-number: PYSIDE-454 Change-Id: I95a1b9cd69f3d27e7b95873b6b7209fb36c6a506 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Pass more generator options to the api extractorFriedemann Kleint2022-01-171-0/+2
| | | | | | | | | | | Introduce flags representing generator options and pass AvoidProtectedHack besides UsePySideExtensions. Move AvoidProtectedHack to the Generator base class for this purpose. Pick-to: 6.2 Change-Id: I170b5ace30057c4074d73afce3f88d086eb54775 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Implement enum search by value in code modelFriedemann Kleint2021-11-051-2/+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: Introduce a test mode for the code modelFriedemann Kleint2021-11-031-0/+1
| | | | | | | | | | | | Add a flag that causes the AbstractMetaBuilder to not clear the code model after a run for testing purposes. As drive-by, clear out the code model scope, fully releasing the code model after building. Task-number: PYSIDE-1691 Pick-to: 6.2 Change-Id: I883805f0ee1866ff8864811d9e29d17b181096bd Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Extend checks when not to fix a default valueFriedemann Kleint2021-10-251-0/+2
| | | | | | | | | | | | | | | | | | | 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: Add a test for fixing of default values in AbstractMetaBuilderFriedemann Kleint2021-10-251-0/+3
| | | | | | | | | | Extract it to AbstractMetaBuilder and add a test similar to the enum test added by 5888236a23f277e1f795052d5ed93a0430d834a4. Task-number: PYSIDE-1691 Pick-to: 6.2 Change-Id: I636c1ec82486f84da9ccd4bf941054ec47d41290 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Improve fixing of enum default values of function argumentsFriedemann Kleint2021-10-211-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* shiboken6: Add option to use global headersFriedemann Kleint2021-05-101-0/+2
| | | | | | | | | | | | | shiboken6 historically expected a global header consisting of #include directives for the desired headers which was excluded from the generated code. Make it possible to use class headers directly with a command line option. Pick-to: 6.1 6.1.0 Task-number: PYSIDE-1338 Change-Id: I4543be888136736deb2612abc27dfc04e177e469 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Enable setting clang optionsFriedemann Kleint2021-01-201-0/+1
| | | | | | | | | | | Add command line options --clang-option, --clang-options to be able to pass options. Allow for a complete replacement of the built-in compiler support options by specifying '-' as the first option. Task-number: PYSIDE-1477 Change-Id: Ibcb107e5d0c4dedb56ab07e83af4203f0f682850 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Introduce class ApiExtractorResultFriedemann Kleint2020-12-221-1/+1
| | | | | | | | | | | | | | Separate the generators from ApiExtractor by introducing a class ApiExtractorResult storing the results of an ApiExtractor run. Move some query functions there. With that, some generator functions can already be made static by passing the ApiExtractorResult and OverloadData can be decoupled from the generator. Pick-to: 6.0 Change-Id: Iaba3ebff4aecb722eec4a606423738260983d905 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Do not sort classes unnecessarilyFriedemann Kleint2020-12-201-8/+0
| | | | | | | | | | | | | | | | | | | The list of classes was first sorted topologically, then alphabetically in the AbstractMetaBuilder and finally again topologically in the CppGenerator with an additional dependency QObiect/QMetaObject. Move the sort functionality taking the QObiect/QMetaObject dependency into account from the generator to the AbstractMetaBuilder. Move all sorting functionality to helper sortLists(). The classesTopologicalSorted() helper is then no longer needed by the generators and can be removed from the ApiExtractor. Pick-to: 6.0 Change-Id: I03c799118296393bdd0f3de84427b50ab29153b0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Refactor base class retrievalFriedemann Kleint2020-12-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | AbstractMetaClass has a list of base class names and a list of AbstractMetaClass* base instances. AbstractMetaBuilder populates the instance list from the names in setupInheritance() and sets a flag. In a few places in AbstractMetaBuilder, the base class instances are needed before this has been completed. For this purpose, the helper AbstractMetaBuilder::getBaseClasses() is needed. Replace the set of classes m_setupInheritanceDone by a flag on AbstractMetaClass. This allows for adding an assert to AbstractMetaClass::baseClasses() ensuring setupInheritance() has been called and taking a shortcut in AbstractMetaBuilder::getBaseClasses(). In addition, classesTopologicalSorted() can use AbstractMetaClass::baseClasses() instead of searching with AbstractMetaBuilder::getBaseClasses() and can thus be made static. Pick-to: 6.0 Change-Id: Iaf8209b6f6534ad91a96970a56c1e86cce054922 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Add support for a snake case typesystem attributeFriedemann Kleint2020-12-071-0/+6
| | | | | | | | | | | | | Add a snake case attribute to type system, complex type entry, function type entry as well as to function and field modifications. Add a function definitionNames() to AbstractMetaFunction/Field returning the names under which the function/field will be registered. Change the code writing the registration accordingly. Fixes: PYSIDE-1441 Change-Id: I178390bb80fa25aad9f8a56e99e4cc70064178eb Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Store AbstractMetaFunction using a QSharedPointerFriedemann Kleint2020-11-301-1/+1
| | | | | | | | | | | | | | | | | | Store the list functions (global / class member) as a QList<QSharedPointer<const AbstractMetaFunction> instead of a raw pointer list. This makes passing around function lists easier and solves the memory leaks caused by mixing cloned and unmodified functions while collecting the overload lists in the generators. - Change the function signatures accordingly - Add a qSharedPointerConstCast() for non-const access. - Restructure the traversing of added functions in the AbstractMetaBuilder - Remove some unused typedefs and functions unearthed by the change Change-Id: I08a6c5243750e3eb3813bc3f7172899ad2b13e22 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Use std::optional for returning AbstractMetaTypeFriedemann Kleint2020-11-141-9/+6
| | | | | | | | | Remove its invalid state. Remove a few checks that apparently originated from the old code where AbstractMetaType * = 0 meant void. Change-Id: Ifc938c011f07f4b5316f708f6cce1e98bcaa8125 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Port AbstractMetaEnum/Value to use QSharedDataPointerFriedemann Kleint2020-11-111-1/+3
| | | | | | | | Change the client code to store it by value. For the various find() and traverseEnum() functions, use a std::optional to replace the pointer. Change-Id: Ie4e671bf95e569741fa3c9a399bfe239ceac0dec Reviewed-by: Christian Tismer <tismer@stackless.com>
* Rename shiboken2 to shiboken6Friedemann Kleint2020-10-281-0/+125
Adapt CMake files, build scripts, tests and examples. Task-number: PYSIDE-904 Change-Id: I4cb5ee4c8df539546014b08202a7b1e98ed3ff07 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>