aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator/shiboken2
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.13' into devFriedemann Kleint2019-07-038-949/+950
|\ | | | | | | Change-Id: I389468b76913ac3c8113ab89833c756a7a72e54f
| * shiboken: Fix various clang warningsFriedemann Kleint2019-06-253-23/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Avoid copying complex types by using const ref - Use isEmpty() to check for container emptyness - Use range-based for - Use Q_DISABLE_COPY in 'public:' area - Fix spelling error - Use '= default' for trivial constructors/destructors - Remove non-null checks before deletion - Fix misleading indentation - Fix else after return - Simplify boolean expressions - Fix unused parameters, streamline code Change-Id: I8c6cadd8653e220ba8e5bdb4dd55524d13a81768 Reviewed-by: Christian Tismer <tismer@stackless.com>
| * shiboken: Replace 'typedef' by 'using'Friedemann Kleint2019-06-254-19/+15
| | | | | | | | | | | | | | | | Apply Fixits by Qt Creator with some amendments. Remove iterator types by using auto instead. Change-Id: I8a75323da6ae5cdcc6b67af8be9376408953986b Reviewed-by: Christian Tismer <tismer@stackless.com>
| * shiboken: Introduce autoFriedemann Kleint2019-06-253-12/+12
| | | | | | | | | | | | | | Apply Fixits by Qt Creator with some amendments. Change-Id: Ib2be1012ef7e8a2ad0e6cd130371bf1e941c4264 Reviewed-by: Christian Tismer <tismer@stackless.com>
| * shiboken: Introduce nullptrFriedemann Kleint2019-06-255-20/+20
| | | | | | | | | | | | | | Apply Fixits by Qt Creator with some amendments. Change-Id: Ie8300ddb834adb8b649324562f2c912a4e8cf4ce Reviewed-by: Christian Tismer <tismer@stackless.com>
| * Cleanup pointer whitespace everywhereChristian Tismer2019-06-248-891/+891
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Among other files to fix, basewrapper.(cpp|h) was full of uncommon pointer whitespace. After fixing that, I could not resist and fixed also libshiboken, generators, and after acceptance also PySide. Most of the time, this regex worked fine (\w\w+)([*&]+)[ ]*(?![&*]*[/=]) replaced with \1 \2 but everything was checked by hand. I did not touch the shiboken tests which are quite hairy. It turned out that inserting a space between a variable and asterisk causes a crash of shiboken, if the same line contains "CONVERTTOCPP". This was temporarily fixed by adding another space after it. Example.. sources/pyside2/PySide2/glue/qtcore.cpp line 977 QByteArray * cppSelf = %CONVERTTOCPP[QByteArray *](obj); //XXX /|\ omitting this space crashes shiboken! cppgenerator.cpp was special, since it was modified to _generate_ correct pointer whitespace. This caused a few testcases to fail, which had to be adjusted, again. This was difficult since some internal names must end on "*" and generated code normally not. Removing the last errors involved binary search on path sets... Apply C++ 11 fixits to the changed code, where applicable. Done-with: Friedemann.Kleint@qt.io Task-number: PYSIDE-1037 Change-Id: I4ac070f52c5efb296c05d581c9d46e6f397a6c81 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Merge remote-tracking branch 'origin/5.13' into devFriedemann Kleint2019-06-193-17/+27
|\| | | | | | | Change-Id: I5aa8f69849db51c61d058b7f0197b883b7d2d4e2
| * Fix type name for lookup of QFlags<> convertersFriedemann Kleint2019-06-181-8/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For enum/flags registration, the converters were registered under invalid names like: Shiboken::Conversions::registerConverterName(converter, "QFlags<QFlags<QUrl::ComponentFormattingOption>"); Shiboken::Conversions::registerConverterName(converter, "QFlags<ComponentFormattingOption>"); In addition, QFlags<> is not used for type names in Python. Use the flags name as specified in the typesystem instead: Shiboken::Conversions::registerConverterName(converter, "QUrl::ComponentFormattingOptions"); Shiboken::Conversions::registerConverterName(converter, "ComponentFormattingOptions"); Change-Id: I79525643850bf4296516dfb9576f75b51adf6414 Fixes: PYSIDE-1029 Reviewed-by: Christian Tismer <tismer@stackless.com>
| * Support the qApp macro in "scriptable application"Christian Tismer2019-06-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Renamed from "Fix scriptable application to support the qApp macro" because qApp was improved instead of scriptable application. The qApp macro needed some extra effort to support the qApp "macro" which is only defined in the Python wrappers. I took some generated code, created a QApplication instance in Python and used then reduced generated code to get at the object and adjust the refcount. This solution was then rejected, because I can do better, and in fact, scriptable application now has a correct qApp macro too, without any change to scriptable application. The central idea was to look into the module init function at import time and to see if a Q*Application already exists. I was not aware of that import. Many thanks for the rejection! :-) Update.. -------- After many attempts to make the qApp variable correctly behave like always, I recognized that pre-existing Q*Application instances have no wrappers or constructors at all! With that, it is not possible to create a sophisticated qApp macro as a singleton variable in the desired way. Fortunately, this is also not necessary, because a C++ Q*Application cannot be deleted from Python, and there is no point in supporting more that a simple variable. So in case of a pre-existing instance, the qApp variable now gets redirected to that instance. A small test was added to application_test.py that is triggered by an import. A weird effect when "qApp" was typed interactively before calling "QApplication()" was fixed, too. Change-Id: Ic69dd6a21c964838a90f63e316d299b62a54d612 Fixes: PYSIDE-571 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
| * Revert "shiboken: Disambiguate indexes of smart pointer types"Friedemann Kleint2019-06-131-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | This is not the proper fix for the issue. The index of the declaring module needs to be used for this to work. This reverts commit d2d0e397309a1b18eaff9ddee0940007f0e1c4bf. Task-number: PYSIDE-1024 Change-Id: Idc0e859ebda1626b5e841aa96be54317a5f3d0d0 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
| * shiboken: Fix handling shared pointers passed by const-ref, take 2Friedemann Kleint2019-06-131-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With fd126b28e1d9b02ea16c813bc392461bdb05bd1d, broken wrapper code would still be generated for "const_QSharedPointer_QSize___&" depending on whether the const-ref or plain value type was encountered first when parsing. Fix the problem by stripping the qualifiers from the metatype added to GeneratorPrivate::m_instantiatedSmartPointers partially reverting fd126b28e1d9b02ea16c813bc392461bdb05bd1d. Change-Id: Ie6691e045b7d65baa3a0bc72dd8637f09eeaf111 Fixes: PYSIDE-1016 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Merge remote-tracking branch 'origin/5.13' into devFriedemann Kleint2019-06-072-3/+9
|\| | | | | | | Change-Id: I920a77a3a8c79bba0fd7e5e4f990facf4081ca08
| * shiboken: Disambiguate indexes of smart pointer typesFriedemann Kleint2019-06-061-1/+4
| | | | | | | | | | | | | | | | | | | | Add the module name like it is done for namespaces and containers. Task-number: PYSIDE-1024 Change-Id: Iba8589bfe360763bc186e5129d0ba480b2fb58ae Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
| * shiboken: Fix generation of init functions and types for const-refs of smart ↵Friedemann Kleint2019-06-061-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | pointers Add a convenience to strip all qualifiers and use that. This at least fixes the naming (for example, getInitFunctionName returning "const_QSharedPointer_QSize___&"), the init function for the type itself is missing, though. Task-number: PYSIDE-1016 Change-Id: Id61b3c879199fc061e2846007951e3e9c82b85c4 Reviewed-by: Christian Tismer <tismer@stackless.com>
* | Merge remote-tracking branch 'origin/5.13' into devFriedemann Kleint2019-05-242-5/+17
|\| | | | | | | Change-Id: I38964a8efc7905afd879cd2a96e75149d5942c8a
| * shiboken: Make it possible to extend namespacesFriedemann Kleint2019-05-222-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Qt has some modules, where functions and classes are added to namespaces of other modules. For example, QtGui adds the free functions mightBeRichText() and convertFromPlainText() to the "Qt" namespace and Qt3DQuick adds a namespace "Quick" to the namespace "Qt3DCore" started in Qt3DCore. Shiboken was unable to handle this since the name of the index constant was derived from the namespace name and would thus clash. Also, all code model items from the base module would be re-generated into the extended namespace. To fix this: - No longer join namespace code model items in clang builder. - Search for pre-existing namespaces in traverseNamespace() before creating a new one, continuing populating it. - Add a "files" attribute taking a regular expression to match header names to the namespace type entry, making it possible to restrict code model items by files when extending namespaces (as otherwise, all base items are again added). - Add "extends" attribute specifying the package name of the namespace to extend, which will be used as base type in CPython. - Disambiguate the SBK indexes of namespaces and the init_ functions by adding the module name. Change-Id: Ib552e878911942fa4d52d2bb0c6695e5b2c4c341 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* | Fix deprecation warnings about deprecated container conversionsFriedemann Kleint2019-05-222-2/+2
|/ | | | | | | | Fix warnings introduced by qtbase/92f984273262531f909ede17a324f546fe502b5c. Change-Id: Ic46e5c93f8dd1910742fbd0578602cca4461643b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* shiboken: Fix some spelling errors in function namesFriedemann Kleint2019-05-041-2/+2
| | | | | | | | getMultipleIheritanceFunction() -> getMultipleInheritanceFunction() copyMultimpleheritance() -> copyMultipleInheritance() Change-Id: If15b1ec12b6037ac8cff9941e09a281bc219fa20 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Refactor code generating multiple inheritanceFriedemann Kleint2019-05-033-34/+20
| | | | | | | | | - Remove the check function hasMultipleInheritanceInAncestry(), which is nearly identical to getMultipleInheritingClass(). - Modernize the generated code to use C++ casts, uintptr_t and streamline Change-Id: I68f52c2cbf1a589fd31c9c73919365176c56932e Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken/Generators: Cache class information lists per classFriedemann Kleint2019-04-303-30/+89
| | | | | | | | | | | | | | | | | | The function ShibokenGenerator::getFunctionGroups(class) is called many times for each function during code generation and causes a slowdown for the OpenGL version function classes, which have 1000 member functions. Split away getGlobalFunctionGroups() for the case scope=0 and introduce a global-static cache for class information that is more involved to determine for use by the various generators. Speeds up the generation of the QtGui module including the OpenGL version functions from 420s to 90s. Task-number: PYSIDE-955 Change-Id: I6b6aa35ef2197aa9cddbf339db9eb0220932f361 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Refactor progress message output handlingFriedemann Kleint2019-04-302-0/+6
| | | | | | | | | | | | In class ReportHandler, replace the step counting by a simple pair of startProgress()/endProgress() functions that check for warnings and print the appropriate terminator. Module name and timestamp are now also printed. Add a few more messages and give proper names to the generators. Change-Id: I92b4ef2854b824fbba3d371417edc1f88561a2cb Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Remove CMake dead codeAlexandru Croitor2019-04-231-28/+0
| | | | | Change-Id: Icb2d3702972a2dc49ee296b2111811ff75b162fc Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Ensure that signature strings never overflow againChristian Tismer2019-04-161-10/+10
| | | | | | | | | | | | | | | | | | | | The signature module used to use large strings with the signatures of all functions in a class. This can lead to an overflow in MSVC, because the maximum string length funnily still is 32K unicode characters. This patch solves that by using a single string per function. Instead of a huge string, a list of strings is passed to each class. To prevent any runtime increase, the string list creation is deferred until the actual usage. At initialization time only a ssize_t holding the structure address is passed. As a result, the signature module should be even slightly faster. Task-number: PYSIDE-955 Change-Id: I99faf942a3cca03456928b8aec5e8a4b9924b8b2 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Cleanup And Simplify the Signature Related CodeChristian Tismer2019-04-163-11/+13
| | | | | | Task-number: PYSIDE-510 Change-Id: I73c441b56a19a0ac836e3598ff6fc8c9ba4d1cd2 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Remove some special handling for QObject'sFriedemann Kleint2019-04-103-4/+2
| | | | | | | | | | | | For types, QObjects are equivalent to objects, there is no need to differentiate. Remove the code trying to find whether a type is a QObject. Only AbstractMetaClass needs to know whether it inherits QObject. Add a simple check recursing down the base classes. Change-Id: I2365b451c8873f044b06c09b58aff29e2db3c5b7 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Search for classes by type entry instead of nameFriedemann Kleint2019-04-031-2/+2
| | | | | | | | | Searching by name is more efficient and has problems when extending namespaces. Search by type entry instead where possible. Change-Id: I131329a6648bb7f0a02cba08a5fbbc0531e0c51f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Further refactorings related to the package nameFriedemann Kleint2019-04-022-3/+2
| | | | | | | | | | | | Let Generator::packageName() return the default package name of the type data base instead of storing it in a member variable. Instead, use a member variable for the module name which is derived from it, since it is queried many times. Use the default type system entry instead of searching for it via package name. Change-Id: I171330b3d73d2e3ceac239e4c1c6f130e9f5ee7b Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Refactor AbstractMetaBuilder::classesTopologicalSorted()Friedemann Kleint2019-04-011-6/+7
| | | | | | | | | | | | | | | | | | Change the function parameter to be a list always, making the logic of the inner classes clearer. In the implementation, use a of QHash<AbstractMetaClass*, int> instead of hashing by name, which makes it possible to disambiguate namespaces extended in modules. This also allows for a drastic simplification of the code trying to determine the dependency given by parameter default values. Instead of trying to match by name, correctly qualifying it, the matching can be done by TypeEntry pointers. Change-Id: Ia17bf6e109576bac029fb016e5e11309777d0735 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Replace QLinkedList by a QVector in the Graph classFriedemann Kleint2019-04-011-1/+1
| | | | | Change-Id: I4d76a29699867e9d4ff6138cc40fae9b1f519121 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Refactor code declaring and calling the type init functionsFriedemann Kleint2019-03-282-15/+22
| | | | | | | | Introduce a function for determining the init function name and simplify the code writing the module wrapper. Change-Id: I818f7a23902f1c9c1ce3cdad3d37dc18403006dd Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Shiboken: Add "noexcept" to wrapper when wrapped function is noexceptVolker Aßmann2019-03-231-0/+3
| | | | | | | | | | | | | The clangparser was already recording the exception specifier for wrapped functions, but the code generator did not transfer the type specifier to the wrapper function. With modern compilers this leads to compile errors as the exception specifier is now part of the type. Noexcept is now added whenever the clangparser determines the source function is noexcept. Change-Id: I1f68981d997fcf4f007569c6d682e3dcf68eca60 Fixes: PYSIDE-977 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken: Fix a warning introduced by g++ 8 in the generated codeFriedemann Kleint2019-03-211-2/+4
| | | | | | | | | | | | PySide2/QtWidgets/PySide2/QtWidgets/qgraphicsscenehoverevent_wrapper.cpp:95:12: warning: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying 28 bytes from a string of the same length [-Wstringop-truncation] Use the correct length and use memcpy(). Change-Id: I0830cd9b499f2f49a1f3334c2407f877e79738d4 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* shiboken: Make the indentor helper class more flexibleFriedemann Kleint2019-03-132-10/+9
| | | | | | | | | | | Move it to a separate header and turn it into a non-type template with a tabWidth parameter to make it possible to use it with arbitrary tab widths. Turn it into a non-type template taking the tab width. Change-Id: Ib2b6a7379ce66d1a22e73b4cb6a4a9a9b457014d Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Amend The Python 3.5 FixChristian Tismer2019-03-011-1/+1
| | | | | | | | | | | | After the bug found in PYSIDE-928, the contextlib problem of Python 3.5 also vanished. What remains is the crash on shutdown which is caused by module 'testbinding'. Task-number: PYSIDE-953 Change-Id: I07f18fa468fdb0758ee4e4b7663c3a42bec42822 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix conversions of list of smart pointers to pythonRenato Araujo Oliveira Filho2019-02-261-1/+1
| | | | | | | | | While converting smart pointers do not initialize the object with default/minimal constructor. Change-Id: Ie9400d8487accc0c90b0f0b31b855038ae698b5c Task-Id: PYSIDE-947 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Prevent Python 3.5 From Crashing The BuildChristian Tismer2019-02-261-0/+2
| | | | | | | | | | | | | | | | | | | Python 3.5 has a bug that crashes the build. See the description in the issue tracker. The cure is to use a more recent contextlib.py and to avoid a PySide cleanup function that creates the crash. The problem is not solved for Python 3.5, and it is not clear if the testbinding module has a hidden bug, too. But this fix seems to be good enough for the moment. We should decide if we are going to fix Python 3.5 or abandon it altogether. Change-Id: Iacf2237de1f34d2b3cd1d68f1fb5833bdca3fdc2 Fixes: PYSIDE-953 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix smart pointers with namespaceRenato Araujo Oliveira Filho2019-02-211-1/+1
| | | | | | | | | Use the cppName when looking for metatype while generating smart pointer getter function Change-Id: Ib3a632dd7f667a6bf7c487cfb673f0e55cbddde9 Fixes: PYSIDE-948 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken: Suppress warnings about deprecated code in QtFriedemann Kleint2019-02-111-0/+3
| | | | | | | | Always generate QT_WARNING_DISABLE_DEPRECATED into Qt wrappers, silencing any deprecation warnings. Change-Id: I621ee357e6eddaee52dbb8ea12fe6dee8b588bec Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Replace QString::null/isNull() by QString()/isEmpty()Friedemann Kleint2019-02-062-5/+5
| | | | | | | | | | | | | | Fix warnings appearing in Qt 5.13: sources/shiboken2/generator/shiboken2/shibokengenerator.cpp:873:25: warning: ‘QString::null’ is deprecated: use QString() [-Wdeprecated-declarations] sources/shiboken2/generator/shiboken2/shibokengenerator.cpp:873:25: warning: ‘QString::null’ is deprecated: use QString() [-Wdeprecated-declarations] sources/shiboken2/generator/shiboken2/shibokengenerator.cpp:880:25: warning: ‘QString::null’ is deprecated: use QString() [-Wdeprecated-declarations] sources/shiboken2/generator/shiboken2/shibokengenerator.cpp:880:25: warning: ‘QString::null’ is deprecated: use QString() [-Wdeprecated-declarations] sources/shiboken2/generator/shiboken2/cppgenerator.cpp:5060:34: warning: ‘QString::null’ is deprecated: use QString() [-Wdeprecated-declarations] sources/shiboken2/generator/shiboken2/cppgenerator.cpp:5060:34: warning: ‘QString::null’ is deprecated: use QString() [-Wdeprecated-declarations] Change-Id: I7c938df64babf824b58bf5c785b281a88d5111db Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Replace the deprecated Qt algorithms by their std:: equivalentsFriedemann Kleint2019-02-051-3/+7
| | | | | | | | | | | | | | Fix warnings occurring in 5.13: sources/shiboken2/ApiExtractor/abstractmetalang.cpp:1431:66: warning: ‘void qSort(RandomAccessIterator, RandomAccessIterator, LessThan) [with RandomAccessIterator = AbstractMetaFunction**; LessThan = bool (*)(AbstractMetaFunction*, AbstractMetaFunction*)]’ is deprecated: Use std::sort [-Wdeprecated-declarations] sources/shiboken2/generator/shiboken2/cppgenerator.cpp:358:43: warning: ‘void qSort(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = Include*]’ is deprecated: Use std::sort [-Wdeprecated-declarations] sources/shiboken2/generator/shiboken2/cppgenerator.cpp:1683:55: warning: ‘void qSort(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = QList<QString>::iterator]’ is deprecated: Use std::sort [-Wdeprecated-declarations] sources/shiboken2/generator/shiboken2/cppgenerator.cpp:5500:53: warning: ‘void qSort(RandomAccessIterator, RandomAccessIterator) [with RandomAccessIterator = Include*]’ is deprecated: Use std::sort [-Wdeprecated-declarations] sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp:1585:65: warning: ‘void qSort(RandomAccessIterator, RandomAccessIterator, LessThan) [with RandomAccessIterator = AbstractMetaFunction**; LessThan = bool (*)(const AbstractMetaFunction*, const AbstractMetaFunction*)]’ is deprecated: Use std::sort [-Wdeprecated-declarations] sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp:1681:24: warning: ‘void qSort(Container&) [with Container = QStringList]’ is deprecated: Use std::sort [-Wdeprecated-declarations] sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp:2054:25: warning: ‘void qSort(Container&) [with Container = QStringList]’ is deprecated: Use std::sort [-Wdeprecated-declarations] Change-Id: If6940941ac31327597ce362a31b27773f4d5b94c Reviewed-by: Christian Tismer <tismer@stackless.com>
* Type Hints: Handle Container Types CorrectlyChristian Tismer2019-02-051-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An error was reported that we had a bug in this .pyi line: def parseErrors(self) -> PySide2.QtScxml.QScxmlError: ... which actually had to be a list like def parseErrors(self) -> typing.List[PySide2.QtScxml.QScxmlError]: ... A deeper look revealed that we had very many other examples, also in the argument lists, were we did not handle containers properly. (For example, 90 times in QtCore!) This is a leftover from the type error messages which were generated in C++, and never really understood. This is now a clean rewrite of the C++ part to expose all information and an extension of the Python parser that systematically uses the container types from the typing module. The implementation became a bit more complex because of Python 2: We need to provide our own copy of the public typing module, because it is not safe to assume that this module can be loaded. Importing it from support.signature gave a problem because we now need to find the names of instances to produce List[...], which needed to be implemented in the loader. Implemented the "Pair" type now as a native generic type. This is more correct than the former implementation and shorter in the .pyi files. Additionally, an own definition of "Char" was provided for brevity. This was not important to implement and could also be done with "int", but it is helpful for the future to know how to implement own types (and it was fun). Task-number: PYSIDE-921 Task-number: PYSIDE-795 Change-Id: I0e565b38d7b4fff39dd606950f9f8d97c45acbf5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Unify The Function Formatting In Generated CodeChristian Tismer2019-02-031-1/+1
| | | | | | | | | | | | | | | | | | | PySide functions are quite uniquely formatted: - There comes some header - Then an opening brace to the very left - Then body text - Then a closing brace. This structure is very quickly parsable with a single regular expression, except: There is a single case where the structure is different. We remove that to save complexity in evaluation tools. Task-number: PYSIDE-803 Change-Id: If868eb4b6a6e0d62ed2f944aeb9227a3bc459458 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken: Add option to skip deprecated functionsFriedemann Kleint2019-01-311-0/+6
| | | | | | | | | | | | | Pass the "deprecated" annotation from Clang into the meta language and reject functions based on it when the the command line option --skip-deprecated is set. By default, have Python output a deprecation warning when a deprecated function is called (which is visible when passing -Wd). Task-number: PYSIDE-487 Change-Id: Ic28d82963fde11f258b2559b562d3f24017fe98d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* shiboken: Make constructor checks more fine-grainedFriedemann Kleint2019-01-301-5/+19
| | | | | | | | | | | | | | | | ShibokenGenerator::isValueTypeWithCopyConstructorOnly() returned false for QWebEngineHistoryItem since the check for AbstractMetaAttributes::HasRejectedConstructor triggered on WebEngineHistoryItem(QWebEngineHistoryItemPrivate *priv), causing the function to bail out. To prevent this, add a new AbstractMetaAttributes::HasRejectedDefaultConstructor attribute and use that in isValueTypeWithCopyConstructorOnly(). Task-number: PYSIDE-906 Change-Id: I4fee83b89f0a4c44e7e8d69e118ed7f2b03ceee1 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* shiboken: Generate unused variable cast for variable numArgsFriedemann Kleint2019-01-301-0/+1
| | | | | | | | | Fix warning: qsignalblocker_wrapper.cpp:110:9: warning: unused variable ‘numArgs’ [-Wunused-variable] int numArgs = PyTuple_GET_SIZE(args); Change-Id: Iad56d7b5218851df2ddf5cd68bfbddc8efcf83e0 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* shiboken: Fix security warning in formatting error messageFriedemann Kleint2019-01-151-2/+2
| | | | | | | cppgenerator.cpp:2698:107: warning: format not a string literal and no format arguments [-Wformat-security] Change-Id: I41d976749023bda142b680930f2d54d00687eb47 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* shiboken: Reduce C-style casts in generated codeFriedemann Kleint2019-01-141-47/+70
| | | | | Change-Id: I9539c1a4e24e915d5b356afafbd902266d493b5a Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken: Refactor formatting of the PyType_Slot array in writeClassDefinition()Friedemann Kleint2019-01-132-31/+55
| | | | | | | | | | Change the tp_func handling such that "" means nullptr and introduce a formatter class for the entries to use nullptr and change the C-style casts to reinterpret_cast. Change-Id: I36a1a218d003035f23ab9f8d31c7a993379e23c2 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Improve check when a QFlag<Enum> is foundCristian Maureira-Fredes2019-01-111-2/+11
| | | | | | | | | | | | | | | | | | | | | | For the case of the method `addAxis` in the QPolarChart class, the generated code evaluates first the inherited method: QChart::addAxis(QtCharts::QAbstractAxis*,QFlags<Qt::AlignmentFlag>) instead of the same class method: QPolarChart::addAxis(QtCharts::QAbstractAxis*,QtCharts::QPolarChart::PolarOrientation) The condition to check if an argument was a `QFlags<Qt::AlignmentFlag>`, was just `PyNumber_Check(...)`, which was too broad, and then any Enum would pass that condition. The change was to include an additional condition to check the type of the EnumType that was passed as argument. Change-Id: I2eebb6f05c097d170a6d61633698444f03f20b02 Fixes: PYSIDE-898 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken: Use more nullptr or {} in generated codeFriedemann Kleint2019-01-111-27/+32
| | | | | Change-Id: I96e3bff8a48f0bd5ea98c33a22ff12c31b01357d Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>