diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-08-05 08:40:42 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-08-08 21:30:04 +0200 |
| commit | 1c7f5faabdfc3729a629e3c57f4ee77b63fb858d (patch) | |
| tree | 4f8ff577db891dacac5dfc3f2e9c06f9b03eeac1 | |
| parent | ccf0935984e43b76e7b09e2a33d00b961548c50b (diff) | |
shiboken6: Always use the modified pyi return type of functions for signatures
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>
4 files changed, 12 insertions, 10 deletions
diff --git a/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml b/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml index a300f517c..c55afe590 100644 --- a/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml +++ b/sources/pyside6/PySide6/QtGui/typesystem_gui_common.xml @@ -2373,7 +2373,7 @@ <remove-argument/> </modify-argument> <modify-argument index="return"> - <replace-type modified-type="PyTupleObject*"/> + <replace-type modified-type="Tuple"/> </modify-argument> <inject-code class="target" position="beginning" file="../glue/qtgui.cpp" snippet="qmatrix4x4-copydatato"/> </modify-function> @@ -2636,7 +2636,7 @@ <inject-code file="../glue/qtgui.cpp" snippet="qguiapplication-exec"/> </add-function> <modify-function signature="setOverrideCursor(const QCursor&)"> - <modify-argument index="return"> + <modify-argument index="return" pyi-type="PyObject"> <replace-type modified-type="QtGuiHelper::QOverrideCursorGuard*"/> </modify-argument> <inject-code class="target" position="end" file="../glue/qtgui.cpp" diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index a1e30dd21..8ce6189b8 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -5485,12 +5485,13 @@ void CppGenerator::writeSignatureInfo(TextStream &s, const OverloadData &overloa if (multiple) s << idx-- << ':'; s << funcName << '(' << args.join(u',') << ')'; - if (!f->isVoid()) { - QString t = f->pyiTypeReplaced(0); - if (t.isEmpty()) - t = f->type().pythonSignature(); - s << "->" << t; - } + + QString returnType = f->pyiTypeReplaced(0); // pyi or modified type + if (returnType.isEmpty() && !f->isVoid()) + returnType = f->type().pythonSignature(); + if (!returnType.isEmpty()) + s << "->" << returnType; + s << '\n'; } } diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py index 2118d7e39..204f1a3d4 100644 --- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py +++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/mapping.py @@ -238,6 +238,7 @@ type_map.update({ "uint32_t": int, "uint64_t": int, "uint8_t": int, + "Union": typing.Union, "quintptr": int, "qulonglong": int, "QVariant": Variant, @@ -440,7 +441,7 @@ def init_smart(): # The PySide Part def init_PySide6_QtCore(): from PySide6.QtCore import Qt, QUrl, QDir, QKeyCombination - from PySide6.QtCore import QRect, QSize, QPoint, QLocale, QByteArray + from PySide6.QtCore import QRect, QRectF, QSize, QPoint, QLocale, QByteArray from PySide6.QtCore import QMarginsF # 5.9 from PySide6.QtCore import SignalInstance try: diff --git a/sources/shiboken6/tests/samplebinding/typesystem_sample.xml b/sources/shiboken6/tests/samplebinding/typesystem_sample.xml index c49f5810b..799d04cf5 100644 --- a/sources/shiboken6/tests/samplebinding/typesystem_sample.xml +++ b/sources/shiboken6/tests/samplebinding/typesystem_sample.xml @@ -1385,7 +1385,7 @@ } </template> <modify-function signature="getMargins(int*,int*,int*,int*)const"> - <modify-argument index="0"> + <modify-argument index="return" pyi-type="Tuple[int, int, int, int]"> <replace-type modified-type="PyObject" /> </modify-argument> <modify-argument index="1"> |
