at master 2.7 kB view raw
1From: Friedemann Kleint <Friedemann.Kleint@qt.io> 2Date: Thu, 27 Apr 2023 12:18:39 +0200 3Subject: shiboken2/clang: Write scope resolution for all parameters of native 4 wrappers 5 6Make sure types are correct for cases like: 7 8- QtDBusHelper::QDBusReply::QDBusReply(::QDBusReply<void>) 9- Qt3DInput*Event constructors taking the equivalent QtGui classes 10 (Qt3DInput::QMouseEvent(::QMouseEvent *); 11 12[ChangeLog][shiboken6] Support for parameters/function return 13types with scope resolution has been improved. 14 15Fixes: PYSIDE-2288 16Pick-to: 6.5 5.15 17Change-Id: Id29758fceb88188f4cd834fbd5a7cc0ab511fb1a 18Reviewed-by: Christian Tismer <tismer@stackless.com> 19(cherry picked from commit dd863857436bbeeba4c0a1077f5ad16653296277) 20--- 21 sources/shiboken2/generator/generator.cpp | 24 +++++++++++++----------- 22 1 file changed, 13 insertions(+), 11 deletions(-) 23 24diff --git a/sources/shiboken2/generator/generator.cpp b/sources/shiboken2/generator/generator.cpp 25index 6028282..6147b8a 100644 26--- a/sources/shiboken2/generator/generator.cpp 27+++ b/sources/shiboken2/generator/generator.cpp 28@@ -899,21 +899,23 @@ QString Generator::translateType(const AbstractMetaType *cType, 29 if (index >= (s.size() - (constLen + 1))) // (VarType const) or (VarType const[*|&]) 30 s = s.remove(index, constLen); 31 } 32- } else if (options & Generator::ExcludeConst || options & Generator::ExcludeReference) { 33+ } else { 34 AbstractMetaType *copyType = cType->copy(); 35+ if (options & Generator::ExcludeConst || options & Generator::ExcludeReference) { 36+ if (options & Generator::ExcludeConst) 37+ copyType->setConstant(false); 38 39- if (options & Generator::ExcludeConst) 40- copyType->setConstant(false); 41- 42- if (options & Generator::ExcludeReference) 43- copyType->setReferenceType(NoReference); 44- 45+ if (options & Generator::ExcludeReference) 46+ copyType->setReferenceType(NoReference); 47+ } 48 s = copyType->cppSignature(); 49- if (!copyType->typeEntry()->isVoid() && !copyType->typeEntry()->isCppPrimitive()) 50- s.prepend(QLatin1String("::")); 51+ const auto te = copyType->typeEntry(); 52+ if (!te->isVoid() && !te->isCppPrimitive()) { // Add scope resolution 53+ const auto pos = s.indexOf(te->qualifiedCppName()); // Skip const/volatile 54+ Q_ASSERT(pos >= 0); 55+ s.insert(pos, QLatin1String("::")); 56+ } 57 delete copyType; 58- } else { 59- s = cType->cppSignature(); 60 } 61 } 62