nixpkgs/pkgs/development/python-modules/pyside2/shiboken2-clang-Write-scope-resolution-for-all-parameters.patch
Mitchell Pleune b65dfc3161 Update pyside2/shiboken2 and sip4 to Python 3.12
These are both Python QT 5 modules, which have issues with Python 3.12
that are fixed in never versions, yet many packages depend on them.

Sip4 was as simple as installing and switching over to setuptools (to
replace the now removed distutils).

pyside/shiboken was much more involved. I ended up pulling the required
patches from the Ubuntu release repositories. The existing patch to fix
clang's include headers needed an update as well, but was still
required.

There is some unsightly find-and-replace going on to replace distutils
with setuptools. This is because, although setuptools now creates the
"distutils" import module, it has to be itself imported first before
that can happen. I Used this widespread find-and-replace as it does
function properly, and should be extremly flexable for future versions
(no needing to update patches on each release).
2024-08-07 11:06:13 -04:00

63 lines
2.6 KiB
Diff

From: Friedemann Kleint <Friedemann.Kleint@qt.io>
Date: Thu, 27 Apr 2023 12:18:39 +0200
Subject: shiboken2/clang: Write scope resolution for all parameters of native
wrappers
Make sure types are correct for cases like:
- QtDBusHelper::QDBusReply::QDBusReply(::QDBusReply<void>)
- Qt3DInput*Event constructors taking the equivalent QtGui classes
(Qt3DInput::QMouseEvent(::QMouseEvent *);
[ChangeLog][shiboken6] Support for parameters/function return
types with scope resolution has been improved.
Fixes: PYSIDE-2288
Pick-to: 6.5 5.15
Change-Id: Id29758fceb88188f4cd834fbd5a7cc0ab511fb1a
Reviewed-by: Christian Tismer <tismer@stackless.com>
(cherry picked from commit dd863857436bbeeba4c0a1077f5ad16653296277)
---
sources/shiboken2/generator/generator.cpp | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/sources/shiboken2/generator/generator.cpp b/sources/shiboken2/generator/generator.cpp
index 6028282..6147b8a 100644
--- a/sources/shiboken2/generator/generator.cpp
+++ b/sources/shiboken2/generator/generator.cpp
@@ -899,21 +899,23 @@ QString Generator::translateType(const AbstractMetaType *cType,
if (index >= (s.size() - (constLen + 1))) // (VarType const) or (VarType const[*|&])
s = s.remove(index, constLen);
}
- } else if (options & Generator::ExcludeConst || options & Generator::ExcludeReference) {
+ } else {
AbstractMetaType *copyType = cType->copy();
+ if (options & Generator::ExcludeConst || options & Generator::ExcludeReference) {
+ if (options & Generator::ExcludeConst)
+ copyType->setConstant(false);
- if (options & Generator::ExcludeConst)
- copyType->setConstant(false);
-
- if (options & Generator::ExcludeReference)
- copyType->setReferenceType(NoReference);
-
+ if (options & Generator::ExcludeReference)
+ copyType->setReferenceType(NoReference);
+ }
s = copyType->cppSignature();
- if (!copyType->typeEntry()->isVoid() && !copyType->typeEntry()->isCppPrimitive())
- s.prepend(QLatin1String("::"));
+ const auto te = copyType->typeEntry();
+ if (!te->isVoid() && !te->isCppPrimitive()) { // Add scope resolution
+ const auto pos = s.indexOf(te->qualifiedCppName()); // Skip const/volatile
+ Q_ASSERT(pos >= 0);
+ s.insert(pos, QLatin1String("::"));
+ }
delete copyType;
- } else {
- s = cType->cppSignature();
}
}