aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-07-01 10:56:17 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-07-01 16:19:00 +0200
commit6d81913ed1189a5c7b1e26d2456f05e8e8684914 (patch)
tree64bda894e2ce5411771351f7e9ba7f8c3c9ebbeb
parentd98d47e5bc7d04fe80966cf9396cf2fdc2414a1a (diff)
shiboken6: Simplify smart pointer types when searching instantiations
When the code model first sees a "foo(const SmartPtr &)" instead of "foo(SmartPtr)", compilation would break since const, & propagate into the generated type name. Simplify types as is done for containers as well. Task-number: PYSIDE-454 Pick-to: 6.3 6.2 Change-Id: I1d9f75aceb983f8e9c4a28314db94b8d83b1c1ca Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r--sources/shiboken6/ApiExtractor/apiextractor.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/sources/shiboken6/ApiExtractor/apiextractor.cpp b/sources/shiboken6/ApiExtractor/apiextractor.cpp
index d28136ace..d18758fe8 100644
--- a/sources/shiboken6/ApiExtractor/apiextractor.cpp
+++ b/sources/shiboken6/ApiExtractor/apiextractor.cpp
@@ -414,6 +414,15 @@ static inline const TypeEntry *pointeeTypeEntry(const AbstractMetaType &smartPtr
return smartPtrType.instantiations().constFirst().typeEntry();
}
+static AbstractMetaType simplifiedType(AbstractMetaType type)
+{
+ type.setIndirections(0);
+ type.setConstant(false);
+ type.setReferenceType(NoReference);
+ type.decideUsagePattern();
+ return type;
+}
+
void
ApiExtractorPrivate::addInstantiatedContainersAndSmartPointers(InstantiationCollectContext &context,
const AbstractMetaType &type,
@@ -443,12 +452,7 @@ ApiExtractorPrivate::addInstantiatedContainersAndSmartPointers(InstantiationColl
const QString typeName = getSimplifiedContainerTypeName(type);
if (!context.instantiatedContainersNames.contains(typeName)) {
context.instantiatedContainersNames.append(typeName);
- auto simplifiedType = type;
- simplifiedType.setIndirections(0);
- simplifiedType.setConstant(false);
- simplifiedType.setReferenceType(NoReference);
- simplifiedType.decideUsagePattern();
- context.instantiatedContainers.append(simplifiedType);
+ context.instantiatedContainers.append(simplifiedType(type));
}
return;
}
@@ -496,14 +500,14 @@ void ApiExtractorPrivate::addInstantiatedSmartPointer(InstantiationCollectContex
const AbstractMetaType &type)
{
InstantiatedSmartPointer smp;
- smp.type = type;
+ smp.type = simplifiedType(type);
smp.smartPointer = AbstractMetaClass::findClass(m_builder->smartPointers(),
type.typeEntry());
Q_ASSERT(smp.smartPointer);
const auto &instantiatedType = type.instantiations().constFirst();
auto *ste = static_cast<const SmartPointerTypeEntry *>(smp.smartPointer->typeEntry());
- auto *typedefEntry = new TypedefEntry(SmartPointerTypeEntry::getTargetName(type),
+ auto *typedefEntry = new TypedefEntry(SmartPointerTypeEntry::getTargetName(smp.type),
ste->name(), ste->version(), ste->parent());
typedefEntry->setTargetLangPackage(ste->targetLangPackage());
auto *instantiationEntry = TypeDatabase::initializeTypeDefEntry(typedefEntry, ste);