aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/minimalbinding
Commit message (Collapse)AuthorAgeFilesLines
* shiboken tests/minimalbinding: Fix flake8 warningsFriedemann Kleint2024-03-136-40/+59
| | | | | | | | | | | - Remove * imports - Streamline some conditions and code Pick-to: 6.6 6.5 Change-Id: Ifd8d836adc2f306fb8b442b715e0495bae3ccb08 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Fix default parameters for containers without indirectionsFriedemann Kleint2023-09-061-2/+8
| | | | | | | | | | | | e48b696ffab552785d38d72dff6c9dda796c9628 disabled default parameters for containers since indirections of the argument type can cause clashes. Enable it for the case of no indirections. Fixes: PYSIDE-2454 Pick-to: 6.5 Change-Id: Ie23b2e90244d7fe9e52e31c8314d51293fdbd8fa Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* shiboken6: Test opaque container for spanFriedemann Kleint2023-03-202-1/+23
| | | | | | | Task-number: PYSIDE-2174 Change-Id: I812bef400ef2a006eb6aaca749d8961dc3aa7330 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Test non-fixed spansFriedemann Kleint2023-03-171-0/+2
| | | | | | | Task-number: PYSIDE-2174 Change-Id: I91756983c187e56168a9afa5931785fc8e8bf27b Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* shiboken6: Add support for std::spanFriedemann Kleint2023-03-074-0/+35
| | | | | | | | | | | | | Convert std::span to a Python list. For the conversion from Python to C++, make it a view on a vector. A special type is introduced since a different implementation is needed for opaque containers. Task-number: PYSIDE-2174 Change-Id: I17a7385282a7d373dc73d5ac63a5d3363d61d130 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* 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>
* shiboken6/libminimal: Add std::array (C++ 11)Friedemann Kleint2023-01-112-0/+18
| | | | | | | | | [ChangeLog][shiboken6] Support for std::array has been added. Task-number: PYSIDE-1605 Task-number: PYSIDE-2174 Change-Id: I5192dfe1fa88d794856169638bb97abfc916bcf5 Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6/libminimal: Add a test for std::vectorFriedemann Kleint2023-01-115-0/+46
| | | | | | | Start a containeruser class and test for simple, sequential containers. Change-Id: I4a88787442c3c899523e9da51474916ca1312897 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* shiboken6: Add element for opaque containersFriedemann Kleint2023-01-111-14/+1
| | | | | | | | | | | Add an element enabling adding opaque containers to existing container-type entries (including builtins). Task-number: PYSIDE-1605 Task-number: PYSIDE-2174 Change-Id: I1b4a94331b264dc5e9503ab795edf882dfaa070f Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Add .pyproject files for the testsFriedemann Kleint2022-11-111-0/+9
| | | | | | | | Makes navigation with Qt Creator easier. Change-Id: I40c6bc641faddcdbd265d6e886c2f3bd3b271be5 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>
* Shiboken: Rewrite the signature initializationChristian Tismer2022-07-071-1/+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>
* Use SPDX license identifiersLucie Gérard2022-05-277-210/+14
| | | | | | | | | | | 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: Handle pointers to containersFriedemann Kleint2022-03-101-2/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Opaque containers were disabled for functions taking a pointer to a container since the number of indirections generated was incorrect. Functions taking a pointer to a container where no opaque container exists caused a crash since shiboken generated a value conversion to an uninitialized pointer. Change e4c2272dc60e1ff5e2d0933238fe4508af5f7f60 fixed the number of indirections used for arguments. With this, enable opaque containers also for functions taking a pointer. Use the same code path also for the case of a function taking a container by pointer since it provides a local variable to store the value. As a drive by, this also allows for a virtual function reimplemented in Python to return an opaque container. Change writePythonToCppTypeConversion() to return the number of indirections in case of return types. Remove flag CppGenerator::PythonToCppTypeConversionFlag. [ChangeLog][shiboken6] Code generation for functions taking a pointer to a container has been fixed. Pick-to: 6.2 Task-number: PYSIDE-1605 Task-number: PYSIDE-1790 Change-Id: Ifa0bafb1316d7edfe1efc2183459b1ee6924f5a1 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com>
* Cleanup and Augment Built-in Containers UsagesShyamnath Premnadh2022-02-031-26/+0
| | | | | | | | | | | | | | Since patch 380007 the std containers std::list/std::vector/std::pair/ std::map/std::unordered_map are built-in. They don't have to be explicitly mentioned using <container-type /> in typesystem files unless they are opaque containers. This patch is a general cleanup where <container-type /> is removed in typesystem files for std containers. The documentation has also been updated mentioning the built-in property for std containers. Change-Id: I4ae99bc6e231937f95039541e6c4b118351f2b84 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken6: Add predefined templates for standard container type conversionFriedemann Kleint2021-11-081-14/+2
| | | | | | | | | | | | | | | | | | | | | | | Add some predefined XML templates with common conversions for various container types (STL and Qt) and PyLong. Remove the primitive type QModelIndexList since QModelIndexList is just a typedef. As a drive-by: - Fix a bug in cppmultihash_to_pymap_conversion which would not handle multiple keys correctly (insert several times due to iterator kit not moved past the range). - Simplify the pySequenceToCppContainer conversion by using PyIter_Next(). [ChangeLog][shiboken6] Pre-defined XML templates for standard container type conversion have been added. Task-number: PYSIDE-1666 Change-Id: Ic2e36a75f26853651718e27e0788a37519393322 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* CMake: Use namespaced shiboken6 target in custom commandsAlexandru Croitor2021-10-271-2/+2
| | | | | | | | | | To ensure the tests can be built against an imported shiboken6 target (one found via find_package), and not only using a target which is built as part of the current project. Pick-to: 6.2 Change-Id: I20aa7b9e461370ea489a43b118330fe023e4b631 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* shiboken6: Implement opaque containers for getters returning a const referenceFriedemann Kleint2021-10-212-0/+10
| | | | | | | | | | | | | Add a bool m_const member to the container helper template that indicates a const container. Error out of the modification functions if that is set. Create an additional creation function for the const case. A const opaque containers is then of same Python type as the non-const version, requiring no further type checks. Pick-to: 6.2 Task-number: PYSIDE-1605 Change-Id: I45faeb0d68e6144a9dfbe25497694b8acdd98c09 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* shiboken6: Implement opaque containers for getters (non-const)Friedemann Kleint2021-10-212-0/+11
| | | | | | | | | | | | | | | Extract helpers from the opaque containers generation for fields and use them for function returns if the type is modified accordingly. [ChangeLog][shiboken6] Getters returning containers by reference can now be modified to return an opaque container by modifying the return type accordingly. Pick-to: 6.2 Task-number: PYSIDE-1605 Change-Id: Ieaf5eb92d248d3a23e511222e5f61823e85540c0 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Remove some C++ primitive types from the typesystem filesFriedemann Kleint2021-10-011-2/+0
| | | | | | | | | | | Remove the basic C++ primitive types from the typesystem files. Leave the Qt typedef'ed types in place as otherwise the function modifications would no longer match. Task-number: PYSIDE-1660 Change-Id: Ic64634633640a4b358221fc9f64180df94af02de Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Tismer <tismer@stackless.com>
* shiboken6: Add opaque containers for C++ sequence containersFriedemann Kleint2021-09-242-3/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a class that directly wraps a C++ sequence container, allow for modifying them. For all instantiated containers, generate a special (sequence) type that wraps the C++ container directly. For example, it will be accessible as a QList_int. This is achieved via providing a template for a type private that relies on a conversion traits template for conversion. Only the conversion traits specialization code needs to be generated. Use cases: - Allowing for modifying Fields of such container types (non-owning) - Pass it into functions taking such containers instead of converting back and forth from a PyList (constructed in Python, owning) [ChangeLog][shiboken6] Support for opaque C++ sequence scontainers has been added, allowing to pass a wrapped C++ container directly instead of converting it back and forth from Python sequences. Task-number: PYSIDE-1605 Change-Id: I49d378eb1a0151730d817d5bdd4b71a7c3b5cdda Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* Write conversions as typing.Union[]Friedemann Kleint2021-03-291-1/+1
| | | | | | | | | | | | | | Extract all implicit conversions and write them as typing.Union[]. The optional_replacer was fixed, build_brace_pattern needed a separator to be able to continue. Missing mappings are added. Task-number: PYSIDE-1520 Change-Id: I2d8e4e7b8f1586036cc3ec9cf469a27e693e7312 Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Modernize sequence conversionsFriedemann Kleint2021-03-021-7/+8
| | | | | | | | | | - Use correct size types - Use const iterators - Avoid repeated invocation of end()/size() Task-number: PYSIDE-1438 Change-Id: I7d30a5c87d0867400134be96ee61ff1ab6129435 Reviewed-by: Christian Tismer <tismer@stackless.com>
* Switch from os.path to pathlib.Path, systematic test changesChristian Tismer2021-02-086-6/+12
| | | | | | | | | | | | | | | | | | This patch does the systematic changes on all tests. Note that there was a bug in principle: os.path was used without importing os.path This worked through the way how the os module initializes itself, but you always will find the explicit import in the python library. But the problem is going away anyway after the transition to pathlib.Path :) Change-Id: I95144d7f9bb07a38376c3aa428df663f2e64bcb7 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* move "shiboken6/shiboken6" to "shiboken6/Shiboken"Christian Tismer2021-02-061-1/+1
| | | | | | | | | | | | | | | | | | | | | Modifying the paths to work in the new way is a quite ambitious task. But doing so improves the overall project structure and makes imports unambiguous. This patch should not be applied alone but with move "shiboken6/shiboken6" to "shiboken6/Shiboken" temp The reworked version of this patch no longer has different structures in `build` and `install`. Tested with Python 3.6, 3.7, 3.8, 3.9 debug build Python 3.6 debug install Python 3.9 release install Task-number: PYSIDE-1497 Change-Id: Id9d816dd825907f9359651e7e2f69f54e1ba46c9 Reviewed-by: Christian Tismer <tismer@stackless.com>
* python3: remove all obsolete "from __future__" import statementsChristian Tismer2020-11-091-2/+0
| | | | | | | | | | | Note that not all future statements can be removed: PEP 563 for instance deals with from __future__ import annotations Task-number: PYSIDE-904 Change-Id: Ia387ec87f3c68ca64d13e8e80191eda900f58638 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Rename shiboken2 to shiboken6Friedemann Kleint2020-10-2810-0/+1056
Adapt CMake files, build scripts, tests and examples. Task-number: PYSIDE-904 Change-Id: I4cb5ee4c8df539546014b08202a7b1e98ed3ff07 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>