aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Move the shiboken-generator source aroundFriedemann Kleint2025-11-241-1729/+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: Port to Qt include styleFriedemann Kleint2025-03-271-2/+2
| | | | | | | | | 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: Match "const" for unresolved signatures with legacy handlingFriedemann Kleint2025-03-191-9/+11
| | | | | | | | | | | | | | | | | | Change 50d0c3c94ff66c104de269f09c08109eb9d0eb3a enabled specifying unresolved signatures for function modifications, but the helper function did not consider "const". This caused rejection and modification signatures with trailing "const" to not match. To fix this while keeping the legacy behavior, change AbstractMetaFunction::unresolvedSignature() to use a string list and add a const signature besides the non-const one. On this occasion, also use the raw signatures before QMetaObject::normalizedSignature() for modification matching. Pick-to: 6.9 Change-Id: I99f9d99a4378ef6e63b94fc8fc52e9211f9a6853 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Introduce convenience API AbstractMetaType::basicPrimitiveName()Friedemann Kleint2025-03-191-3/+2
| | | | | | | | It removes the need to resolve it via TypeEntry. Pick-to: 6.9 Change-Id: I20230078a8d87d4be3af21127fac111c5c04eec9 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Add a way of removing redundant overloads that differ in one ↵Friedemann Kleint2025-03-031-10/+21
| | | | | | | | | | | | | | | | | parameter When retrieving the function groups, check if there overloads that differ in one parameter and remove them based on rules specified in the type system. For example, when QByteArray::number(qint64) and QByteArray::number(int) exist, it does not make sense to generate an overload for int with parameter checking. [ChangeLog][shiboken6] It is now possible to specify rules to remove redundant overloads that differ in one parameter. Task-number: PYSIDE-2701 Change-Id: I8e1ccbccfe7b5ad76486dc197e8d9c36f1809fbe Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Remove unused flags from AbstractMetaFunction::compareTo()Friedemann Kleint2025-02-241-52/+14
| | | | | | | | | | | | Remove dead code that had no effect and the Comparison flags that belonged to it. Change function return type and argument type comparison to use the exact type to detect differences in the calling convention. Task-number: PYSIDE-2701 Change-Id: I70d8c2b998f4e361abe82828568d410a47544e33 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Handle further class special functionsFriedemann Kleint2025-02-111-0/+1
| | | | | | | | | | | | | | | | - Obtain (copy) assignment operators from libclang and introduce another function type for assignments from other types, which do not impact copy-constructibility. - Handle deleted assignment/move assignment. - Add function query operators. - Disable adding of implicit copy constructor when assignment/move is present. Testing follows in a subsequent patch. Task-number: PYSIDE-3004 Change-Id: I11451bada3f970fb76e80b8ee76e1406441bb9db Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Consider all base classes when finding a modificationFriedemann Kleint2025-02-061-10/+20
| | | | | | | | | | | | | | | | | | This enables removing a duplicate modification for QGraphicsWidget::getContentsMargins() which is inherited from class QGraphicsLayout, QGraphicsLayoutItem (2nd base class) and activates other base modifications for QGraphicsObject-derived classes. Also add a flag indicating whether the modification is inherited from a base class or directly specified for later use in size reduction. [ChangeLog][shiboken6] Modifications from base classes in multiple inheritance will now be correctly applied. Task-number: PYSIDE-2701 Change-Id: I190764a673fb6b7ad44aea5ed90ff64c57eda324 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Fix some clang-tidy warningsFriedemann Kleint2025-02-031-3/+3
| | | | | | | | | | | | - Fix invocation of static functions - Use std::any, range-based for where applicable - Use std::make_shared instead of new - Replace QByteArrayLiteral() by literal - Use const-ref to avoid copies Pick-to: 6.8 Change-Id: Iec864bd6eee8fb06f5afd122084a9e0f551ff8f1 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Split code paths for determining global/member function modificationsFriedemann Kleint2025-01-291-12/+27
| | | | | | | | | Also rename AbstractMetaFunction::findClassModifications() to AbstractMetaFunction::findMemberModifications(). Task-number: PYSIDE-2701 Change-Id: I3a2698ba4a9f5c61cb07d284d1db5827a4ba79b9 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Add information about overriding functions to AbstractMetaFunctionFriedemann Kleint2025-01-291-0/+11
| | | | | | | | | Introduce a pointer to overridden function to AbstractMetaFunction and add a flag for a covariant return. Task-number: PYSIDE-2701 Change-Id: Ie19f2447a6d6f027ffec98c417a6276326b4f8a3 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Documentation: Use function parameter names from WebXML/qdoc when they are ↵Friedemann Kleint2024-11-211-0/+5
| | | | | | | | | | | | missing In some cases, the Qt headers do not have parameter names. Use the ones from the WebXML documents in that case. Pick-to: 6.8 Task-numer: PYSIDE-1106 Change-Id: I719a4fb09b9fbef9fc734036e3f53c02376a5d5f Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Improve formatting of function signaturesFriedemann Kleint2024-08-011-1/+2
| | | | | | | | | | Do not add space before parameter names in case of pointers/references, for example: "foo(const QString & name)". This mainly affects error messages and comments in generated code. Pick-to: 6.7 Change-Id: I1c00d9b731206e1a24b3d25689851276596121be Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Fix clang-tidy warning about using std::any_of instead of loopsFriedemann Kleint2024-06-241-29/+33
| | | | | Change-Id: Ic85973e29870456bf422a3ac75fd9d68524ad886 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Fix static analysis warningsFriedemann Kleint2024-06-241-6/+7
| | | | | | | | | | | | | | | | | | - 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: Generate Python override code for added virtualsFriedemann Kleint2024-04-221-0/+5
| | | | | | | | | | | | Introduce "Python override" as a special type of user-added function which will cause a function calling a Python override into the native wrapper. This can then be called from a virtual that has a signature which cannot be handled in Python. Fixes: PYSIDE-2602 Pick-to: 6.7 Change-Id: I5fc44ebe3f585078e87d3230d5e6f4faa67a4ee1 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Extract common C++ function attributesFriedemann Kleint2024-04-171-13/+33
| | | | | | | | | | | | | | | | Extract attributes common to C++ functions from AbstractMetaFunction's attributes to a flags type in codemodel_enums.h for re-use in AbstractMetaFunction, FunctionModelItem and AddedFunction. A lot of boolean setters and getters can then be removed and the flags easily transferred from code model to the meta language code. Task-number: PYSIDE-2602 Pick-to: 6.7 Change-Id: I9da1bb0d70051cd6bb3113290e8ccedfe4d13908 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Remove function attribute FinalInTargetLangFriedemann Kleint2024-04-171-1/+1
| | | | | | | | | | | | | | | | | The attribute does not have any impact on the generated code; it merely causes some warnings to be printed when fixing the class functions for rare cases. AbstractMetaFunction::isModifiedFinal() determines the generation of virtual functions instead. The function query flags FinalInTargetLangFunctions and VirtualInTargetLangFunctions can be removed as well. They were both used in AbstractMetaClass::functionsInTargetLang() which is used by the documentation generator only. Pick-to: 6.7 Task-number: PYSIDE-2602 Change-Id: Ib0f0de41008b655a84637ab28f1046aa3e098b76 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Indicate default parameters in the generated overload decisor codeFriedemann Kleint2024-01-251-3/+5
| | | | | | | | Add a '='. Pick-to: 6.6 Change-Id: Id2ce7fd618a32e74dd1de3b933754db15907c3e2 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6/Metabuilder: Prepare for documenting global functionsFriedemann Kleint2023-12-121-0/+11
| | | | | | | | | | Ensure global functions are associated with a package. Add a member to added functions and a convenience function for retrieving. Task-number: PYSIDE-1106 Task-number: PYSIDE-2543 Change-Id: I7563bbdf93d690b0c814e16f1e76cc696cb6fc5c Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Remove some further uses of QStringLiteralFriedemann Kleint2023-11-291-3/+3
| | | | | | Task-number: PYSIDE-2537 Change-Id: Ie71b17eec385b31842d6693b3492db565d479fd0 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Port the MetaClass::find*() helpers to QAnyStringViewFriedemann Kleint2023-11-271-1/+1
| | | | | | Task-number: PYSIDE-2537 Change-Id: I7d9c160b4b8c46854b11722c05510da766dcc3f5 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Add __int__, __float__Friedemann Kleint2023-09-051-0/+3
| | | | | | | | | | | | [ChangeLog][shiboken6] operator int() and/or operator double() on classes are now used to provide the __int__ and/or __float__ special functions enabling the use of int() and float() for numerical types. Fixes: PYSIDE-2446 Change-Id: Iabb6392b5754d6e31d44209cfdd27d38c5055b2c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* Handle more attributes in add-function/declare-function/function elementsFriedemann Kleint2023-08-011-5/+2
| | | | | | | | | | | | | | | | | | | | | | Factor out functions to handle the attributes from modify-function and use them for <add-function>/<declare-function> and <function>. This makes it possible to specify the "allow-thread", "exception-handling" and "snake-case" for <declare-function> and <function> as well. The snake-case handling is removed from FunctionTypeEntry and handled via modifications. As a drive-by, fix docs on "exception-handling". [ChangeLog][shiboken6] The attributes "allow-thread", "exception-handling" and "snake-case" can now be specified on <declare-function> and <function>. Change-Id: I081ab4dfd922de563ac7b8c75d0c36609c43e0cd Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* Add experimental support for rvalue referencesFriedemann Kleint2023-08-011-1/+4
| | | | | | | | | | | | | | | | Enable functions taking rvalue references if they are user-defined in some way. Enabling by default is not done since there are cases in which several overloads exist (QSqlQueryModel::setQuery(QSqlQuery)). In these cases, they should not be part of the candidate list. [ChangeLog][shiboken6] Experimental support for rvalue references has been added. Task-number: PYSIDE-2394 Task-number: PYSIDE-1790 Change-Id: Ie2eb60ef19ddac321126b64cd0c35913bd805b48 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* Disable generation of bindings for protected methods with disabled wrapperFriedemann Kleint2023-07-251-0/+7
| | | | | | | | | | | | | | For example, no binding should be generated for protected QAbstractHttpServer::handleRequest() for which the wrapper has been disabled. Amends 1d044f467070a040713c9566a8a8de3a56c571e7. Pick-to: 6.5 Task-number: PYSIDE-1202 Task-number: PYSIDE-2402 Change-Id: I6501c81da503a9121c28c5f7e1444708da7d0f0f Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Make it possible to override a C++ deprecation attributeFriedemann Kleint2023-07-251-7/+16
| | | | | | | Pick-to: 6.5 Task-number: PYSIDE-2394 Change-Id: Ib5af48820eafdd9767a30317bea6526f9cb799ea Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Prepare for handling opaque containers for spansFriedemann Kleint2023-03-171-4/+10
| | | | | | | | | Allow opaque container modifications for functions returning a span by value. Task-number: PYSIDE-2174 Change-Id: I7906b6e7e49e5b22d18037f14821fe73b055419e Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Port from QSharedPointer to std::shared_ptrFriedemann Kleint2023-01-051-8/+8
| | | | | | | 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-28/+28
| | | | | Change-Id: I101ca8ceea6ffa63ca8bd03e2e9adf7531cb8f80 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Use smart pointers for the TypeEntry classesFriedemann Kleint2022-11-171-5/+4
| | | | | | | | | | 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>
* shiboken6: Make some TypeEntry query functions free functionsFriedemann Kleint2022-11-171-3/+3
| | | | | | | | | | | Some query functions like TypeEntry::typeSystemTypeEntry() search in the hierarchy, starting with "this". This cannot be ported to smart pointers, so the functions are changed to be free functions where the first element has to be passed in. Change-Id: I3122b648ad499a2236577f6a101e8637a2f87d55 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Fix coding style regarding pointers (Type* v -> Type *v)Friedemann Kleint2022-11-141-1/+1
| | | | | | | | | As a drive-by, introduce some auto and streamline the code. Pick-to: 6.4 Change-Id: If84a3721a50b2e00b473ba78cba184f1a35d326b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Implement the modify-function/final attributeFriedemann Kleint2022-10-141-0/+11
| | | | | | | | | It disables generating the code for overriding a function in Python. This is useful when the result type is not constructible (for example, QCanBusDevice::deviceInfo()). Change-Id: Iadda1db5563034e7ec58f16314059ca9b08a4cd5 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Port some loop variables to qsizetypeFriedemann Kleint2022-10-131-5/+5
| | | | | | | | Where possible, used range-based for. Otherwise, use qsizetype for loop variables. Change-Id: I4773bee8468ce73722656ec73845369b7d40d4cd Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Match function modifications by unresolved signature as wellFriedemann Kleint2022-09-301-4/+27
| | | | | | | | | | | | | Store the unresolved signature from the code model as an additional field in AbstractMetaFunction. Add a function modificationSignatures() to return a list of signatures to be matched against the modifications. [ChangeLog][shiboken6] The signatures for function modifications now also allow for specifying unresolved types. Change-Id: I258c4ff2ddf87542098568ee01ca4f444afd05ce Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Clean up includesFriedemann Kleint2022-09-211-1/+1
| | | | | | | | | Remove unused includes from headers; add includes to sources where needed. Change-Id: I05efd95a9340eaf42cc5d606e2aef97acdaf83c7 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* shiboken6: Fix documentation injection for added functions with parameter namesFriedemann Kleint2022-09-061-0/+6
| | | | | | | | | | | Documentation modifications were matched by function signatures, which failed for added function signatures with parameter names (@). To fix this, store documentation modifications in AddedFunction similar to what is done for normal modifications. Task-number: PYSIDE-2025 Change-Id: I0b3a8c2a066c028da6feb394905510892e85e47d Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Split AddedFunction from modificationsFriedemann Kleint2022-09-051-1/+2
| | | | | | Task-number: PYSIDE-2025 Change-Id: I34b6692e4e61dd6c03207ef60a794fee01bf675e Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Introduce a convenience function for argument conversion rulesFriedemann Kleint2022-06-291-0/+5
| | | | | | | | This simplifies the code. Task-number: PYSIDE-454 Change-Id: I725d407508315eca20ff93383d0f689d512a20d5 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Fix mapping of arguments when writing virtual methodsFriedemann Kleint2022-06-271-0/+12
| | | | | | | | | | When generating the code for virtual methods, removed argument were not properly taken into account. Add a mapping method for this to AbstractMetaFunction. Change-Id: I6caf6bd676256affa7c9b85b36bec74a1c642be2 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Disable return value heuristics for parent accessorsFriedemann Kleint2022-05-311-2/+7
| | | | | | | | Extract a helper AbstractMetaFunction::maybeAccessor() for this purpose. Change-Id: I790561b699524c51836100d9248640a63e810ffd Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Fix deprecation handlingFriedemann Kleint2022-05-271-0/+2
| | | | | | | | | | | | | | | | | There was AbstractMetaFunction::Attribute:::Deprecated (meaning deprecation detected by code annotation) and AbstractMetaFunction::isDeprecated() (meaning modified to deprecated in type system), which were used inconsistently. Modify AbstractMetaFunction::isDeprecated() to detect either and use it everywhere. Remove the warning generation from writeFunctionCalls() so that the warning is only generated by writeSingleFunctionCall(). Move the deprecation warning into libshiboken. Task-number: PYSIDE-661 Change-Id: I9cb6814c790d12858d51671e8f43e1c4a1885887 Reviewed-by: Christian Tismer <tismer@stackless.com>
* 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: Extract class CodeSnip into separate filesFriedemann Kleint2022-05-171-0/+1
| | | | | | Change-Id: Iff46540cdb764d4caa2efad26cc5e28347cef54f Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Split the typesystem headerFriedemann Kleint2022-05-171-1/+4
| | | | | | | | 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: Add an attribute for explicitly defining the functions to be ↵Friedemann Kleint2022-05-111-1/+22
| | | | | | | | | | | generated [ChangeLog][shiboken6] It is now possible to specify a list of functions to be generated instead of removing undesired functions. Fixes: PYSIDE-1764 Change-Id: I16f40eb99b0f4da0afb3b100ac24bb5e877dfb30 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Remove deprecated QLatin1StringFriedemann Kleint2022-04-251-17/+21
| | | | | | | | | | Introduce a compatibility header to provide the 6.4 API to 6.3 to reduce merge conflicts. Task-number: QTBUG-98434 Pick-to: 6.3 6.2 Change-Id: Iab3f9f894019b4135afa96b930325966348210d0 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Refactor AbstractMetaClass::findFunction[s]() to use QStringViewFriedemann Kleint2022-04-251-1/+1
| | | | | | | | | UTF-16 string literals can then be passed as search strings. Pick-to: 6.3 6.2 Task-number: QTBUG-98434 Change-Id: Id3ce2934840ec56b3e2c4e070ed47321a264afa9 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Migrate from QLatin1String to UTF-16 string literalsFriedemann Kleint2022-04-251-2/+2
| | | | | | | | | | Use the QStringView overloads of the comparison functions in order to minimize merge conflicts after the deprecation of QLatin1String in 6.4. Task-number: QTBUG-98434 Pick-to: 6.3 6.2 Change-Id: Ia0df398ab8f3e61a0b629971ccbec2273a78499b Reviewed-by: Christian Tismer <tismer@stackless.com>