aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator/shiboken2
Commit message (Collapse)AuthorAgeFilesLines
* shiboken2: Remove version suffix from generators directoryFriedemann Kleint2020-10-279-12375/+0
| | | | | | | | It does not make sense to move it around in each major version. Task-number: PYSIDE-904 Change-Id: If83b1dcaf04ed5a76f35073aa63c7ef6b456936a Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken2: AbstractMetaArgument: use QSharedData[Pointer]Friedemann Kleint2020-10-276-168/+177
| | | | | | | | | | | | | | | | | | | | Similar to AbstractMetaType, AbstractMetaArgument was previously kept as a raw pointer. The data were copied numerous times by AbstractMetaArgument::copy() when adding the inherited functions to a AbstractMetaClass. Similar to what was done for AbstractMetaType in 6cad0686101b252cfdbd1a6768a2b02c39aa1d8a, change the type to be based on QSharedData[Pointer]. It can then be passed around and treated like a C++ value type, with Qt sharing the data when possible behind the scenes. * Remove inheritance from AbstractMetaVariable by moving the fields over. * Remove the unused field m_originalName. Change-Id: Ic9e476ca71e163de131fbecc267d0a4e336cb0b9 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken2: Improve error messages about cyclic dependenciesFriedemann Kleint2020-10-271-4/+10
| | | | | | | | | | Return a struct instead of a plain list from Graph::topologicalSort() which contains the offending indexes and output the elements in case of failure. Task-number: PYSIDE-1202 Change-Id: Ib7f70c78be0e84272f31d802677c7fc333aa32f4 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken2: AbstractMetaType: use QSharedData[Pointer]Friedemann Kleint2020-10-238-453/+461
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously, shiboken2 kept AbstractMetaType by a raw pointer. The data were copied numerous times by AbstractMetaType::copy() when adding the inherited functions to a AbstractMetaClass or specializing templates, sometimes with a bool flag indicating ownership. To get rid of the copies and ownership issues, change the type to be based on QSharedData[Pointer]. It can then be passed around and treated like a C++ value type, with Qt sharing the data when possible behind the scenes. - Extract AbstractMetaType to a separate header/source - Remove unused AbstractMetaType::setInstantiationInCpp() - Remove unused member m_package - Rewrite the comparison of AbstractMetaType which becomes relevant for checking/detaching to do a complete comparison. It was previously unused, intended for a different implementation of view types with special cases. - Rework debug formatting - Invalid meta types are indicated by the "Invalid" usage pattern instead of null pointers Change-Id: Ic4b1feecafb4f0355f39e178c2703b104e45cf6c Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-10-223-4/+100
|\ | | | | | | Change-Id: I68ec1e4b80fcc8c395eacb7d5046fdd8e00535e0
| * Update SmartPointers conversionsRenato Araujo Oliveira Filho2020-10-213-4/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | * Updated test to accept base types derived using std::shared_ptr; * Generate new coode to be able to convert smart pointers into shared pointers of base class. Functions that accepts SharedPointer<A> as argument should be able to accept SharedPointer<B> if B is derived from A. Task-number: PYSIDE-1397 Change-Id: I7e5235980daaf4651dad3ab1c880373f1c64e134 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-10-211-11/+30
|\| | | | | | | Change-Id: I8831b840fa7816b8919ecbaab17b41822a0a6012
| * Fix SmartPointer conversion name registerRenato Araujo Oliveira Filho2020-10-211-11/+30
| | | | | | | | | | | | | | Register the correct name for smart pointers. Change-Id: If12701901319b0578602ff5b5ab8eecad820d969 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-10-144-52/+40
|\| | | | | | | Change-Id: I46f5d2dc758d0e1f23377c91ba7496793461771e
| * shiboken2: Some RefactoringsFriedemann Kleint2020-10-143-18/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | - AbstractMetaType: Pass TypeEntry to constructor - AbstractMetaType: Return instantiations() by const ref - AbstractMetaClass: Make baseTemplateInstantiations a member instead of a global hash. Simplify the code accordingly. Task-number: PYSIDE-1202 Change-Id: I1a18aa4ff97481af8cb13e8732fe3952c48edb29 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
| * shiboken2: Use an AbstractMetaType for "void"Friedemann Kleint2020-10-134-34/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, nullptr for an AbstractMetaType meant "void", particularly for function return types. The problem with this is that it causes unexpected crashes when dealing with template types like QFuture<void> due to one of the instantiations of the AbstractMetaType being nullptr. Use an AbstractMetaType based on the existing "void" type entry for this. Task-number: PYSIDE-1202 Change-Id: Ib06035cc7903480fd509f7e927d9114c55d51b62 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-10-083-12/+28
|\| | | | | | | Change-Id: I30aaad19852c50b1222222ba66171f9c98ecb7c8
| * shiboken2: Recurse to generated base class for baseFriedemann Kleint2020-10-081-2/+9
| | | | | | | | | | | | | | | | | | Skip base classes whose generation was disabled by reject or generate='no'. This can happen for typedef entries. Task-number: PYSIDE-1202 Change-Id: Ie6fac2408a6aa7b3303b4f06e744a2d2405e2a30 Reviewed-by: Christian Tismer <tismer@stackless.com>
| * shiboken2: Rearrange values of enum TypeEntry::CodeGenerationFriedemann Kleint2020-10-081-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TypeEntry::CodeGeneration::GenerateCpp was unused. Consequently, the GenerateAll mask is not needed, either. Replace GenerateCpp and GenerateTargetLang by a generic GenerateCode value. Introduce a new GenerationDisabled value to be able to distinguish a generate='no' XML attribute from a plain rejection. Fix many invalid usages of bool generateCode() testing against the flag value. Use the enum instead of uint for the code generation field. Task-number: PYSIDE-1202 Change-Id: I0aec5bd1ebfb9a50b80d5a187372c4271490e1b3 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
| * shiboken2: Generate extra includes into wrapper headerFriedemann Kleint2020-10-082-7/+17
| | | | | | | | | | | | | | | | | | | | For wrapper types, generate the class-related extra includes into the wrapper header since they might be required for it (for example, instantiation type of a typedef typesystem entry). Task-number: PYSIDE-1202 Change-Id: I9f57bdfe54d6273e4a1ffa9570e3352959dea480 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | shiboken2: Simplify the export of the generated module init functionFriedemann Kleint2020-10-071-7/+6
| | | | | | | | | | | | | | Remove the version-dependent #ifdef. Change-Id: I15907500ab95d9e48d90a57893197c9b4f18a037 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-10-062-20/+16
|\| | | | | | | Change-Id: I89aa3d4c4a3fa274e2c5ccd8b5facb9531137e80
| * shiboken2: Simplify the export of the generated module init functionFriedemann Kleint2020-10-061-8/+0
| | | | | | | | | | | | | | | | Replace the macro generated into the code by the one introduced by 430d02db24b95a56ae0acc6a9df6a0effe49da0d. Change-Id: I8e713ff25c180a22569a3ba589d04dca43fdc804 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
| * Generate flags operator methods for QFlags on hidden top level namespaceRenato Araujo Oliveira Filho2020-10-062-12/+16
| | | | | | | | | | | | | | | | | | | | Factor out method to write the operator functions and call it for the module wrapper, too. Fixes: PYSIDE-1326 Change-Id: I5b6faf19d253d5828474dec36b454aa20753123c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-10-061-2/+3
|\| | | | | | | Change-Id: I7b4ff138799ee81940c36e68a105cb42bb38a3ff
| * Move the annotations for parsing Qt-based headers to shiboken2Friedemann Kleint2020-10-021-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is one of the lesser known things that any project generating bindings for Qt-based code needs to include pyside2_global.h in order for signals, slots and properties to be recognized, since the annotation macro definitions are in this file. Move the definitions over to shiboken2 to remove the need to include it. [ChangeLog][shiboken2] Projects generating bindings for Qt-based code no longer need to include pyside2_global.h. Change-Id: I531bb7444561ccfc352f3be09ecdf854f9f7dd3d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-10-014-61/+47
|\| | | | | | | Change-Id: Idaf124ad5e1d6a41d52918cecba47499be5e7324
| * Fix up the generated flag operator methodsFriedemann Kleint2020-09-301-11/+11
| | | | | | | | | | | | | | | | Remove space and use reinterpret_cast. Task-number: PYSIDE-1326 Change-Id: I1adfc545c97278eb7da01aec550cb6e2e15945ba Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
| * shiboken2: Generate functions from invisible namespaces into their parent ↵Friedemann Kleint2020-09-301-1/+2
| | | | | | | | | | | | | | | | | | | | | | namespaces Add them in ShibokenGenerator::getFunctionGroupsImpl() with some helpers. Fixes: PYSIDE-1075 Change-Id: Ie627c6e12f82e40cdb4f306ddac6b682e77124c5 Reviewed-by: Christian Tismer <tismer@stackless.com>
| * shiboken2: Generate functions from invisible top level namespaces as global ↵Friedemann Kleint2020-09-302-6/+19
| | | | | | | | | | | | | | | | | | | | | | functions Mainly add those in ShibokenGenerator::getGlobalFunctionGroups() with some adaptions. Task-number: PYSIDE-1075 Change-Id: I6dabac72c204904e76162542b5aa3ea1ac3b56ec Reviewed-by: Christian Tismer <tismer@stackless.com>
| * shiboken2: Refactor handling of invisible top level namespacesFriedemann Kleint2020-09-303-30/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To avoid having to add a ShibokenGenerator::lookForFunctionsInClassesNotToBeGenerated() to fix the function issue, replace ShibokenGenerator::lookForEnumsInClassesNotToBeGenerated() by several helper functions: - Add a list of top level invisible namespace to the generators - Add functions to retrieve enumerations of nested invisible namespaces to AbstractMetaClass with recursion helpers. Task-number: PYSIDE-1075 Change-Id: I421113770e622611caeb221498b872d0a6ba1aeb Reviewed-by: Christian Tismer <tismer@stackless.com>
| * shiboken2: Refactor global enum handling in HeaderGeneratorFriedemann Kleint2020-09-301-16/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Generate the sbk-index values for enums in writeTypeIndexValueLines(AbstractMetaClass *) for invisible namespaces as well instead of adding them to the global enum list. Remove checks for private/protected on global enums as they originate from namespaces. This removes one usage of ShibokenGenerator::lookForFunctionsInClassesNotToBeGenerated() which will be removed in a consecutive change. Task-number: PYSIDE-1075 Change-Id: I9ee7aba20802e9794f371006f9fdbd7ab8d67cab Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Add QStringView/QByteArrayViewFriedemann Kleint2020-09-301-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | View types as function parameters cannot be converted in the standard way shiboken does it: QStringView cppArg0; pythonToCpp(pyArg, &cppArg0); since they reference some other data. Introduce a new "viewOn" member to type system entry for them. It causes the function arguments to be replaced by their viewed-on types (stringview->string) via metatype. Add a test in libsample and a test for QUuid::fromString(QStringView). Test returning QStringView via QRegularExpressionMatch::capturedView(). Task-number: QTBUG-84319 Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Task-number: PYSIDE-487 Change-Id: Iddb4ea268a54928d290e29012e2738772fae83f0 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-09-303-118/+76
|\| | | | | | | Change-Id: I13721e13d2fab13945385fe529afe4ab431e0532
| * shiboken2: Correctly generate final classes with protected methods without ↵Friedemann Kleint2020-09-291-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | protected hack Add a missing check for final class. Amends 170756fa1e5de0ce7ba33521f1eb168d70ad276d. Fixes: PYSIDE-1388 Change-Id: I6b7cd5c9a769838287ac7165bdc2d5ad63b289a1 Reviewed-by: Renato Araujo Oliveira Filho <renato.araujo@kdab.com> Reviewed-by: Christian Tismer <tismer@stackless.com>
| * shiboken2: Add convenience for indenterFriedemann Kleint2020-09-291-105/+64
| | | | | | | | | | | | | | | | | | Add functions that indent/outdent for usage in a stream statement. Streamline the code accordingly, removing unneeded braces in one case. Change-Id: Iac4a16919eebdb667bbc302b0f937cc03a01c724 Reviewed-by: Christian Tismer <tismer@stackless.com>
| * shiboken2: Change AbstractMetaClass::enums() to return const refFriedemann Kleint2020-09-293-8/+4
| | | | | | | | | | | | | | | | This allows for removing a few temporary variables and/or qAsConst(). Task-number: PYSIDE-1075 Change-Id: Ib48070950ac682ec66e19af3dc8c0be5bfdffcee Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-09-294-49/+183
|\| | | | | | | Change-Id: Ie6da3938b82f5ebe96dd12bd65a3ccc4180d2fba
| * shiboken2: MetaBuilder/ApiExtractor/Generator: Return class/enum/function ↵Friedemann Kleint2020-09-282-6/+3
| | | | | | | | | | | | | | | | | | | | lists by const ref This allows for removing a few temporary variables and/or qAsConst(). Task-number: PYSIDE-1075 Change-Id: I0fe3544f0ce4d3a8d56de9c93e300972e0844177 Reviewed-by: Christian Tismer <tismer@stackless.com>
| * shiboken2: Generate properties as fieldsFriedemann Kleint2020-09-284-28/+162
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Add an XML attribute specifying whether code is to be generated to the XML properties. - Split the generator functions for field setters and getters apart so that they can be used for generating property setters and getters. - Generate code for all properties from XML when the PySide extension is not used, otherwise only for those with the attribute set. Task-number: PYSIDE-1019 Change-Id: Iab2ba38b90038edc667a233c23c7113fdc6fb438 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
| * shiboken2: Fix formatting of field getter codeFriedemann Kleint2020-09-241-3/+8
| | | | | | | | | | | | | | | | Properly indent and join the else if statement. Task-number: PYSIDE-1019 Change-Id: I8d5dc6c84e19b97b55f1ba29094da1e31dc7ca1c Reviewed-by: Christian Tismer <tismer@stackless.com>
| * Signature: Revert SbkSpecial_Type_Ready to PyType_ReadyChristian Tismer2020-09-241-12/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The early signature module tried to minimize the visible changes to the code base. It replaced the `PyType_Ready` call by a special version which did other things as well. We replace that special call by a more intuitive function `InitSignatureStrings` that does exactly that and nothing more. The functionality of the module is unchanged. Change-Id: Ic2f9cd29b0352f0a24daa55b01420c77d103c0b2 Task-number: PYSIDE-510 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-09-241-4/+6
|\| | | | | | | Change-Id: I7e4c7f9378706438715362b1e2da9a3cd2794562
| * shiboken2: Fix excessively long lines in generated codeFriedemann Kleint2020-09-231-4/+5
| | | | | | | | | | | | | | | | | | Introduce line breaks. As a drive by, remove unneeded self-assignment. Task-number: PYSIDE-1388 Change-Id: Ia9c7cd66814621f02625e3140724483d6b71f1c7 Reviewed-by: Christian Tismer <tismer@stackless.com>
| * shiboken2: Move class PropertySpec into its own source fileFriedemann Kleint2020-09-221-0/+1
| | | | | | | | | | | | | | | | Move the class and the parser function into its own source file. Task-number: PYSIDE-1019 Change-Id: If403f799f6b8da769fd8b47dd958a7430d061ad8 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-09-222-1/+22
|\| | | | | | | Change-Id: Id0fc76666bbdb254a833eeb6909a0874b2611bf3
| * shiboken2: Allow specifying the sequence of overloadsFriedemann Kleint2020-09-212-1/+22
| | | | | | | | | | | | | | | | | | | | | | Add an attribute to specify a number by which the functions will be sorted. This deactivates the default sorting which tries to avoid implicit conversions. Fixes: PYSIDE-1366 Change-Id: I9a891e21f86152b2fdfda9a48d685f19aa936508 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-09-211-2/+3
|\| | | | | | | Change-Id: Ia31df23a16575f9ecefe13ec85fb70197d103278
| * shiboken2: Add attribute for generating "using namespace"Friedemann Kleint2020-09-181-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | Make it possible to turn off the generation of using namespace. This is required in Qt 6 to avoid a clash between Qt3DCore::QBuffer and QBuffer used in __repr__. Task-number: PYSIDE-1339 Task-number: PYSIDE-904 Change-Id: Iaaf3e67f0ffaae86e2de82b9a1b8fe7d00c74e6b Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-09-172-1/+71
|\| | | | | | | Change-Id: I8aa48d07067c45c888c73af87314f6a88c2a6e14
| * Remove dependency of the QtQml module header on pysideqmlregistertype.hFriedemann Kleint2020-09-161-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | Make it possible to inject code into module headers by specifying "declaration" on type system code snippets. Use that to insert the struct definition into pyside2_qtqml_python.h and remove the include. Add the required includes via code injection into the wrapper and extra includes for the types. Fixes: PYSIDE-1381 Change-Id: I8dfda4c33d66f56e8fb516e1b174cc43664ca318 Reviewed-by: Christian Tismer <tismer@stackless.com>
| * feature_select: Implement True PropertiesChristian Tismer2020-09-161-1/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This feature is now almost fully implemented. TODO: Static properties like `QtWidgets.QApplication.platformName` are skipped for now. They need support by the meta class. Maybe this is a reason to use QtCore.Property instead of vanilla Python property and improve it. With the new infrastructure, we can also consider to add properties which have no equivalent in the Qt implementation. A prominent example is "central_widget". Change-Id: Ia0e32e41de8ab72e3bba74878e61bcbac6da50ea Task-number: PYSIDE-1019 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-09-164-58/+101
|\| | | | | | | Change-Id: I114a003e36bbe9eb7452f13c1515e3419648e228
| * shiboken2: Refactor primitive type lists in overload decisorFriedemann Kleint2020-09-114-58/+101
| | | | | | | | | | | | | | | | | | | | Add a separate header with the type names and use that. Add the missing long long on this occasion. Task-number: PYSIDE-1372 Change-Id: Id3c35c6b2c4e7eebfe1d25b555ab62468cb89f1d Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Merge remote-tracking branch 'origin/5.15' into devFriedemann Kleint2020-09-101-0/+2
|\| | | | | | | Change-Id: I8a627fd459c3f9601d078a00d3d77c8b3fe04304