aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/samplebinding
Commit message (Collapse)AuthorAgeFilesLines
* Remove unnecessary use of 'object' in class constructionremoteobjectsdevCristián Maureira-Fredes2024-12-185-5/+5
| | | | | | | | | | | Considering we are not compatible with Python 2 anymore, we can drop the 'object' explicit inheritance in the class declaration. Pick-to: 6.8 Change-Id: Iac3a95aa9721c3ff1a755f457c0936ca157a8470 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* type hints: Fix the heuristic for ambiguous signature removalChristian Tismer2024-12-051-3/+3
| | | | | | | | | | | | | | | | | By turning over to positional-only parameters, some signatures should be preferred to remove over others. QMessage.warning had two signatures that became equal when ignoring the names. Use the version which has more default values in that case. Some forgotten return types were added. Change-Id: I200f10eb5742a595fafc3106a8e5fbc9a932c75b Pick-to: 6.8 Task-number: PYSIDE-2846 Fixes: PYSIDE-2939 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* type hints: Use positional parameters according to PEP 570Christian Tismer2024-11-211-1/+1
| | | | | | | | | | | This change would have been very simple (basically one constant) if there were not mypy which needed more effort to stay correct. Change-Id: I464b0522f9d174c5a302f85caf2fcbe202dcaed2 Pick-to: 6.8 Fixes: PYSIDE-2624 Task-number: PYSIDE-2846 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* limited api: Remove PyBytes_AS_STRING and PyBytes_GET_SIZECristián Maureira-Fredes2024-11-081-6/+6
| | | | | | | | | Remove old macros usages for the Limited API compatibility, and doing some refactorings to their usages. Change-Id: I10d675a1831d26b3fc878151e3a6ec40c5caddb1 Pick-to: 6.8 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* limited api: Remove PyTuple_GET_ITEM, PyTuple_SET_ITEM, and PyTuple_GET_SIZE ↵Cristián Maureira-Fredes2024-11-081-25/+25
| | | | | | | | | | | macros Removing old macros for compatibility with the limited api, and refactoring some of their usages Change-Id: I33954199d2ef9884c64b963863b97aed851c440f Pick-to: 6.8 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* limited api: Remove PyList_GET_ITEM, PyList_SET_ITEM and PyList_GET_SIZE macrosCristián Maureira-Fredes2024-11-081-3/+3
| | | | | | | | | Removing old compatibility macros for the initial limited api implementation. Change-Id: Iced149450bd9bda18e43ac0acea0061cdcdb211e Pick-to: 6.8 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* limited api: replace PySequence_Fast_GET_SIZE by PySequence_SizeCristián Maureira-Fredes2024-11-081-6/+6
| | | | | | | | | | | | | | | | PySequence_Fast_GET_SIZE is defined as: (PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o)) and when using the Limited API we re-define the _GET_SIZE macro to be the _Size function, and considering this is our standard use case, the macro could be replaced directly by the function. Replacing also some cases were int was used instead of Py_ssize_t when using PySequence_Size. Pick-to: 6.8 Change-Id: I31aecd571a1d8ea82a3441f0b9e16ee19f026b05 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* limited api: replace PySequence_Fast_GET_ITEM by PySequence_GetItemCristián Maureira-Fredes2024-11-081-18/+29
| | | | | | | | | | | | | | | | | PySequence_Fast_GET_ITEM is defined as: (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i)) and when using the Limited API we re-define the _GET_ITEM macro to be the _GetItem function, and considering this is our standard use case, the macro could be replaced directly by the function. However, the function returns a new reference, so we need to manually drecrease a reference after the usage, to avoid reference counting issues. Change-Id: If361e80b9e40b033e009ad46b2b9430e5b4c8eaa Pick-to: 6.8 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* type hints: Fix some systematic problemsChristian Tismer2024-09-061-8/+8
| | | | | | | | | | | | | | __str__ and __repr__ are simply fixed by returning str instead of PyObject. __reduce__ actually has return type "str | tuple[Any, ...]", but using str here too fits the purpose. Errors before: 533 Errors after: 450 Change-Id: I6dd3527d3f5f3f035e667d0ca3c8f123e94e844f Task-number: PYSIDE-2846 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken: Support compiler options for disabling optimizationsChristian Tismer2024-08-011-0/+4
| | | | | | | | | | | | | | | | | | | The fullname field has been removed, and the signature structures can be optionally compressed. Add a build option for switching these and future compiler features off. Combinable flags: --unoptimize=fullname --unoptimize=compression --unoptimize=folding (to be implemented) or just --unoptimize=all Task-number: PYSIDE-2701 Change-Id: I605dc810542ce99f99d9a6b6432e5feae09273b4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Python-3.10: Allow the new syntax for Python 3.9Christian Tismer2024-06-20127-0/+127
| | | | | | | | Add a future statement to all Python source files. Task-number: PYSIDE-2786 Change-Id: Icd6688c7795a9e16fdcaa829686d57792df27690 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
* shiboken6: Generate Python override code for added virtualsFriedemann Kleint2024-04-222-0/+24
| | | | | | | | | | | | 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>
* Fix handling of longs exceeding long long max in float conversionFriedemann Kleint2024-03-261-0/+8
| | | | | | | | | Use PyLong_AsDouble(). Pick-to: 6.7 6.6 6.5 6.2 Fixes: PYSIDE-2652 Change-Id: I97787ba9dd6cb348e45b43228cad4a87afe54a7b Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
* LazyInit: Move the get arguments into a static structureChristian Tismer2024-03-131-2/+2
| | | | | | | | | | | | | | | | | | | | The central get function is used very often. Since the string constants are repeated many times and there seems to be no constant folding, it is better to re-arrange the structure a bit to avoid code bloat. By moving the get arguments into a struct, we avoid all repetitions of string constants and minimize the runtime overhead. The structure is now fully backward compatible and works with unchanged scriptableapplication. Task-number: PYSIDE-2404 Change-Id: Ie7c788ef75cc3d58366532c5f14ab013ebd792b5 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken tests/samplebinding: Fix flake8 warningsFriedemann Kleint2024-03-13124-370/+604
| | | | | | | | | - Remove * imports - Remove a hidden test that was non-functional Pick-to: 6.6 6.5 Change-Id: I34c98ef81d0ebe11b0813670149c00cfcff4eb28 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Improve messages when skipping fields and functionsFriedemann Kleint2024-01-231-2/+2
| | | | | | | | Store the source location in the clang parser so that it appears in the message. Also add the access level. Change-Id: I9a9ca414a41a3fa4584dd55d580aa01bb252f9c7 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken tests: Fix up class SimpleFileFriedemann Kleint2023-10-101-2/+2
| | | | | | | | | | | | Make it a proper object type with a unique pointer. Use the new std::filesystem API to retrieve size and check for existence instead of opening and winding. Pick-to: 6.6 Fixes: PYSIDE-2479 Change-Id: I07e64a2b002195c7b6bce3526ef3ec6ea30a555e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken tests: Fix special functions for class ObjectTypeHolderFriedemann Kleint2023-10-101-1/+1
| | | | | | | | | | | Remove the unused CT default parameter value ObjectType::defaultInstance() which would have led to deletion of a stack object. Turn it into a <object-type> and disable copy/move. Pick-to: 6.6 Task-number: PYSIDE-2479 Change-Id: I010f8d27664a37999742c47e6e446e702853344c Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken tests: Fix test for user added constructorsFriedemann Kleint2023-10-103-8/+25
| | | | | | | | | | | | The test injected code to manipulate the overload number of the overload decisor and change values based on that which lead to unpleasant surprises when adding copy and move constructors. Spell it out to do some basic string parsing instead. Pick-to: 6.6 Task-number: PYSIDE-2479 Change-Id: I7a6fb9c8c22532a20711b4854f5c9b3b0d81d213 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* Support running PySide on Python 3.12Christian Tismer2023-10-091-1/+1
| | | | | | | | | | | | | | | | | | Builtin types no longer have tp_dict set. We need to use PyType_GetDict, instead. This works without Limited API at the moment. With some great cheating, this works with Limited API, too. We emulate PyType_GetDict by tp_dict if that is not 0. Otherwise we create an empty dict. Some small changes to Exception handling and longer warm-up in leaking tests were found, too. Pick-to: 6.6 6.5 6.2 Task-number: PYSIDE-2230 Change-Id: I8a56de6208ec00979255b39b5784dfc9b4b92def Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken6: Add __int__, __float__Friedemann Kleint2023-09-051-0/+5
| | | | | | | | | | | | [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>
* shiboken6: Add __abs__, __pow__Friedemann Kleint2023-09-053-0/+32
| | | | | | | | | | | | Add mapping for non-operator functions that serve as special nb slots. [ChangeLog][shiboken6] It is now possible to add the special functions __abs__ and __pow__, enabling the use of abs() and pow() for numerical types. Task-number: PYSIDE-2446 Change-Id: Iff4b88ad927273df5688c7350c0f45bb7618f05b Reviewed-by: Christian Tismer <tismer@stackless.com>
* Add some test for number protocol functionsFriedemann Kleint2023-08-315-0/+78
| | | | | | | | | | | Add a basic complex number based on std::complex with some number protocols (note the name Complex is already taken by a primitive type in libsample). Pick-to: 6.5 Task-number: PYSIDE-2446 Change-Id: Ie1427761c0048f57a02bc8d59c3181567ce3a199 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* Fix overflows when passing int to functions taking floatsFriedemann Kleint2023-08-211-0/+11
| | | | | | | | | | As a drive-by, introduce a new test class for primitive types. Pick-to: 6.5 6.2 Fixes: PYSIDE-2417 Change-Id: I22d4f04e4d0f95c9220aa9241195bc1747f83d9e Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* Clean up some unused suppression warningsFriedemann Kleint2023-08-011-17/+3
| | | | | | Pick-to: 6.5 Change-Id: I261ec7ec933e21658d357ad1ffbeb4de5b84d13f Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* Add experimental support for rvalue referencesFriedemann Kleint2023-08-012-0/+23
| | | | | | | | | | | | | | | | 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>
* PyEnum: Remove the now unreachable test cases for old enumsChristian Tismer2023-06-196-117/+6
| | | | | | | Task-number: PYSIDE-1735 Change-Id: I51e68c50872f1d1254218ae7556ba607f73c4ea9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* PyEnum: Update docs and rename the optionChristian Tismer2023-06-166-17/+17
| | | | | | | | | | | | | The new Enum implementation can no longer be switched off. Individual features can still be deselected with the environment variable PYSIDE6_OPTION_PYTHON_ENUM which had the name PYSIDE63_OPTION_PYTHON_ENUM before. This change is meant for PySide 6.6 . Task-number: PYSIDE-1735 Change-Id: Iae5b7a9d42a0d7b005dbba20201a80713ef79be9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Implement multiple inheritance correctly, compatible versionChristian Tismer2023-03-211-5/+10
| | | | | | | | | | | | | | | | PySide does not implement multiple inheritance. Please see "About Multiple Inheritance in Python" at the issue. This patch just supports the `__init__` call. A more consequent implementation will follow that supports multiple inheritance with every method. [ChangeLog][pyside6] Cooperative multiple inheritance is now implemented for all __init__ methods. Fixes: PYSIDE-1564 Change-Id: I8df805d22c2052c3a9747420a86341f64e29a5ad Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken6: Handle returning primitive types by pointerFriedemann Kleint2023-03-142-0/+5
| | | | | | | | | | | | | | | This manifests in QtDataVisualization's const QBarDataArray *QBarDataProxy::array() const where QBarDataArray is handled as a primitive type. This required adapting a code snippet which was relying on the argument QString* being treated as QString. Task-number: PYSIDE-2206 Change-Id: Ib05f01d7b54e103cf5bb71be86ffa9b5067ca3fb Reviewed-by: Christian Tismer <tismer@stackless.com>
* Add license headers to cmake filesFriedemann Kleint2023-02-161-0/+3
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Task-number: QTBUG-105718 Task-number: QTBUG-88621 Change-Id: I98bd2e80f182d8bf7aef6b633f37a428e2dac69b Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* signature: Evict the __signature__ attribute, long live signature!Christian Tismer2022-12-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The __signature__ attribute was used since 2017 with success. With Python 3.10, there was an incompatibility introduced by the rlcompleter module. This was detected quite late, because there is no exception thrown in normal line completion. Using the rlcompleter module directly, the error can be seen. The problem is not the attribute itself, but PySide's need to support *multi-signature*. The signature objects are either regular compatible Signature objects, or in the multi-case, *lists* thereof. Since PyPy was implemented, the internal use of the __signature__ attribute was replaced by a get_signature() call. The attribute was never documented in the public until recently in the developer docs. We therefor can assume that removal of the attribute will cause no problems. [ChangeLog][PySide6] The non-standard __signature__ attribute of functions and classes was removed in favor of get_signature(). No Pick-to because this is meant for 6.5 Change-Id: Iaa8bb08a33db66868d949593e527b753bf989681 Fixes: PYSIDE-2101 Task-number: PYSIDE-510 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken6/test: Rename typedef HANDLE in libsampleFriedemann Kleint2022-12-161-2/+2
| | | | | | | | | It clashes with the Windows HANDLE typedef in CMake UNITY_BUILD (jumbo) builds. Task-number: PYSIDE-2155 Change-Id: Ic5d6654651ead85aa08e2375510fe644cbf6dc3e Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Add .pyproject files for the testsFriedemann Kleint2022-11-111-0/+131
| | | | | | | | Makes navigation with Qt Creator easier. Change-Id: I40c6bc641faddcdbd265d6e886c2f3bd3b271be5 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6 tests: Fix warning about unused variablesFriedemann Kleint2022-11-111-1/+1
| | | | | | | Pick-to: 6.4 Change-Id: Ibca923deadadc868edace34a4e310b77be000291 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* CMake: Execute shiboken with appropriate PATH on WindowsAlexandru Croitor2022-11-091-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously one had to add the Qt bin dir and libclang.dll dir to PATH manually to ensure shiboken successfully runs when building Qt for Python using CMake without setup.py. This should not be necessary though, because the build system knows where Qt is (usually via the --qtpaths option) and where libclang is (via LLVM_INSTALL_DIR and friends). Introduce a CMake function that generates a batch shell script wrapper for a given tool. The wrapper will have PATH set to the Qt bin dir and libclang dir. Generate such a wrapper for shiboken and use it everywhere we call shiboken to generate bindings. The wrapper is only created on Windows. All mentions of Shiboken6::shiboken in custom commands now need to be wrapped in $<TARGET_FILE> because automatic target path conversion only happens if the target appears as the first argument to a custom command, and that is not the case anymore with the wrapper script being at the front. As a drive-by, the indentation of custom commands is now adjusted for easier readability and to conform with the indentation used in the Qt build system. Pick-to: 6.4 Fixes: PYSIDE-1844 Change-Id: I287adeedf234d0272c2963e96ae2aa5c4c0f0c83 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Add --lean-header optionFriedemann Kleint2022-11-031-0/+1
| | | | | | | | | | | | | | | | | | | | | Add an option that causes shiboken to generate forward declarations instead of includes where possible into the module header. This works since SbkType<> template specializations work with forward declarations. Includes are only required for certain classes (with enums, inner classes). [ChangeLog][shiboken6] An option --lean-header to generate forward declarations instead of includes into the module header has been added. This considerably reduces the dependencies but may require additional includes to be specified for injected code. Pick-to: 6.4 Fixes: PYSIDE-2099 Change-Id: I01f639e4ccce5ca25016dc2d52562abcc489a5ab Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* shiboken6: Add tests for inline namespacesFriedemann Kleint2022-10-213-0/+11
| | | | | | | Task-number: PYSIDE-990 Change-Id: I4b8d75de9ed4cb15f4784828d64713246964ed21 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* shiboken6: Handle value types with deleted default constructorsFriedemann Kleint2022-10-142-0/+2
| | | | | | | | | | | | | | | Do not set flag AbstractMetaClass::HasRejectedConstructor for those classes since it has a slightly different meaning (rejected due to unknown type). AbstractMetaClass::determineValueTypeWithCopyConstructorOnly() will then correctly detect them. Manifests in QCanBusDeviceInfo. Change-Id: I57637d57ebdaba0a022b6012c08f75c858d9ed36 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Remove printing of typesFriedemann Kleint2022-10-121-1/+1
| | | | | | | | | | Remove a leftover from 8d1514a95f27199b9a8dc850752bb645bda1bb3e. Pick-to: 6.4 Change-Id: I365238e3eebf1a627f47a996beddb649cb9d6f7c Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Fix indirections of enums/flag argumentsFriedemann Kleint2022-10-051-0/+2
| | | | | | | | | | | | | | | | | | | | | | | The information about how arguments are converted (pointer indirections, etc.) was in CppGenerator::writePythonToCppTypeConversion() and partially duplicated in AbstractMetaType::shouldDereferenceArgument(), leading to discrepancies in the indirections generated for the function calls. To fix this, introduce a struct GeneratorArgument with type, conversion mode, indirections and a few flags storing this information and use that everywhere, replacing AbstractMetaType::shouldDereferenceArgument(). Pass the argument indirections obtained from writePythonToCppTypeConversion() via writeArgumentConversion() as a list into writeMethodCall(). Add a test for passing enums by pointer. Fixes: PYSIDE-2065 Change-Id: I495c2bc04ebc0162648d74b75e321609ecd00963 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Add an option to print primitive type entriesFriedemann Kleint2022-10-051-1/+1
| | | | | | | | | | This is useful for checking type resolution. Complements 92943cbb530edb4fd8b7292b3b0ea964d7a6fdde. Task-number: PYSIDE-2065 Change-Id: Ia1427787221ac90cf7f923b3eac4972ee206677e Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Fix warnings about unused parameters in generated codeFriedemann Kleint2022-09-261-0/+4
| | | | | Change-Id: I00fb5202fb136192b74ab598bbab9837b205a62a Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Always use the modified pyi return type of functions for signaturesFriedemann Kleint2022-08-081-1/+1
| | | | | | | | | | | | Some void-functions are modified to return something, this was missing in the signature. Add a few missing mappings revealed by this. Task-number: PYSIDE-2013 Task-number: PYSIDE-2017 Change-Id: If49549b3f605209cd86ff56b8b4cf8a5bbd5e302 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Propagate exceptions through return value ownership modificationsFriedemann Kleint2022-08-022-5/+25
| | | | | | | | | | | The code for modifying return value ownership clears errors set by PyErr_SetString(). To work around this, store the error type and the message in variables and set the error at the end of the code block. Fixes: PYSIDE-1995 Change-Id: I45816197117a3b409fd549e89d57f7b9f0eac458 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* PyEnum: Simplify the test-cases with the new forgiveness modeChristian Tismer2022-07-143-22/+14
| | | | | | | | | | | | | | | | | | | | | | With the new forgiveness, all the "normal" uses of old enums are working with the new enums, too. What does not work are range violations and inheritance of enums from other enums. Also, the implemented trick does not work for enums which do not belong to a class. The induced bugs are easy to find, because they should normally break at import time. [ChangeLog][PySide6] The new forgiveness mode of Python enums allows to use old enum code, most of the time. Much changed test code was reverted. Change-Id: I9c081831309f1b2358fe86e6107b0f4d78fd48cf Pick-to: 6.3 Task-number: PYSIDE-1735 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Shiboken: Rewrite the signature initializationChristian Tismer2022-07-074-4/+0
| | | | | | | | | | | | | | | [ChangeLog][shiboken6] The initialization of the signature module was moved into Shiboken and rearranged. This was necessary for the new backward-compatible PyEnum module. This change makes even sense if the PyEnum forgiveness should not work in 3.11 because it is a real cleanup. Change-Id: I5de54584154fb43648617adcac823f42049be57b Pick-to: 6.3 Task-number: PYSIDE-1735 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Implement the spaceship comparison operator of C++ 20Friedemann Kleint2022-06-213-1/+18
| | | | | | | | Synthesize all comparison operators if one is found in the code model. Task-number: QTBUG-103757 Change-Id: I78fbcd93bc4cd172266f9dd0dbb2ebcf3a8bb7f2 Reviewed-by: Christian Tismer <tismer@stackless.com>
* PyEnum: Remove the old duplication of Enums in the enclosing scopeChristian Tismer2022-06-214-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When implementing Python enums, the behavior of old Qt enums was copied: Every enum was also inserted into the enclosing scope. This patch removes that for two reasons: - it is inconsequent to keep an old quirk when we have all enums renewed so much - It is more consistent compared to our competitor - it is a prerequisite to implement efficient lazy initialization PROBLEM: Many constants (about 110) are no longer recognized, for instance `Qt.AlignLeft` should be `Qt.AlignmentFlag.AlignLeft`. The question is if that can be fixed easily in C++, or if the file mapping.py should get ~100 new fixes? SOLUTION: We allow the old enums, but tell nobody that they continue to work. They also are not advertized in the PYI files. [ChangeLog][PySide6] The duplication of enum values into the enclosing scope, allowing to write Qt.AlignLeft instead of Qt.Alignment.AlignLeft, is still implemented but no longer advertized in PYI files or line completion. Task-number: PYSIDE-1735 Change-Id: I79a90d08f2a5a3a069fa551e60d609ecad718239 Pick-to: 6.3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken6: Introduce an attribute for parent ownership heuristicsFriedemann Kleint2022-05-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The parent ownership heuristics cause some unintended ownership transfers to be generated that can cause crashes. However, completely removing them would mean to have to explicitly specify it in each QObject-derived class constructor. To improve this, introduce an attribute to restrict the heuristics to classes to which this is applicable. For compatibility, the attribute is only honored in shiboken 6 if some class in the type system explicitly specifies it. For shiboken 7, it will be mandatory. [ChangeLog][shiboken6] An type system attribute for restricting the parent ownership heuristics to relevant classes has been introduced. The workaround 0e62c4db50472f8b581022c86a6be651158d0cd0 can then be reverted. Task-number: PYSIDE-1939 Change-Id: I0fb01e9842aecbccaa686ce71b2163b20a97cbf7 Reviewed-by: Christian Tismer <tismer@stackless.com>