diff options
Diffstat (limited to 'sources/shiboken2/generator')
4 files changed, 39 insertions, 20 deletions
diff --git a/sources/shiboken2/generator/generator.cpp b/sources/shiboken2/generator/generator.cpp index fe03d3489..49064a6a5 100644 --- a/sources/shiboken2/generator/generator.cpp +++ b/sources/shiboken2/generator/generator.cpp @@ -219,9 +219,12 @@ void Generator::addInstantiatedContainersAndSmartPointers(const AbstractMetaType const AbstractMetaTypeList &instantiations = type->instantiations(); for (const AbstractMetaType* t : instantiations) addInstantiatedContainersAndSmartPointers(t, context); - if (!type->typeEntry()->isContainer() && !type->typeEntry()->isSmartPointer()) + const auto typeEntry = type->typeEntry(); + const bool isContainer = typeEntry->isContainer(); + if (!isContainer + && !(typeEntry->isSmartPointer() && typeEntry->generateCode())) { return; - bool isContainer = type->typeEntry()->isContainer(); + } if (type->hasTemplateChildren()) { QString piece = isContainer ? QStringLiteral("container") : QStringLiteral("smart pointer"); QString warning = @@ -244,6 +247,13 @@ void Generator::addInstantiatedContainersAndSmartPointers(const AbstractMetaType // Is smart pointer. if (!m_d->instantiatedSmartPointerNames.contains(typeName)) { m_d->instantiatedSmartPointerNames.append(typeName); + if (type->isConstant() || type->referenceType() != NoReference) { + // Strip a "const QSharedPtr<Foo> &" or similar to "QSharedPtr<Foo>" (PYSIDE-1016) + auto fixedType = type->copy(); + fixedType->setReferenceType(NoReference); + fixedType->setConstant(false); + type = fixedType; + } m_d->instantiatedSmartPointers.append(type); } } @@ -912,7 +922,6 @@ QString getClassTargetFullName(const AbstractMetaType *metaType, bool includePac QString getFilteredCppSignatureString(QString signature) { - TypeInfo::stripQualifiers(&signature); // for const refs to smart pointers signature.replace(QLatin1String("::"), QLatin1String("_")); signature.replace(QLatin1Char('<'), QLatin1Char('_')); signature.replace(QLatin1Char('>'), QLatin1Char('_')); diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index 5fbc6ed3e..95f93fd42 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -3686,14 +3686,29 @@ void CppGenerator::writeEnumConverterInitialization(QTextStream& s, const TypeEn } s << INDENT << "Shiboken::Enum::setTypeConverter(" << enumPythonType << ", converter);" << endl; - QStringList cppSignature = enumType->qualifiedCppName().split(QLatin1String("::"), QString::SkipEmptyParts); - while (!cppSignature.isEmpty()) { - QString signature = cppSignature.join(QLatin1String("::")); - s << INDENT << "Shiboken::Conversions::registerConverterName(converter, \""; - if (flags) - s << "QFlags<"; - s << signature << "\");" << endl; - cppSignature.removeFirst(); + + QString signature = enumType->qualifiedCppName(); + // Replace "QFlags<Class::Option>" by "Class::Options" + if (flags && signature.startsWith(QLatin1String("QFlags<")) && signature.endsWith(QLatin1Char('>'))) { + signature.chop(1); + signature.remove(0, 7); + const int lastQualifierPos = signature.lastIndexOf(QLatin1String("::")); + if (lastQualifierPos != -1) { + signature.replace(lastQualifierPos + 2, signature.size() - lastQualifierPos - 2, + flags->flagsName()); + } else { + signature = flags->flagsName(); + } + } + + while (true) { + s << INDENT << "Shiboken::Conversions::registerConverterName(converter, \"" + << signature << "\");\n"; + const int qualifierPos = signature.indexOf(QLatin1String("::")); + if (qualifierPos != -1) + signature.remove(0, qualifierPos + 2); + else + break; } } s << INDENT << '}' << endl; @@ -5806,7 +5821,7 @@ bool CppGenerator::finishGeneration() if (usePySideExtensions()) { // initialize the qApp module. - s << INDENT << "NotifyModuleForQApp(module);" << endl; + s << INDENT << "NotifyModuleForQApp(module, qApp);" << endl; } s << endl; s << "SBK_MODULE_INIT_FUNCTION_END" << endl; diff --git a/sources/shiboken2/generator/shiboken2/headergenerator.cpp b/sources/shiboken2/generator/shiboken2/headergenerator.cpp index 17ebbcde9..a55539d7c 100644 --- a/sources/shiboken2/generator/shiboken2/headergenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/headergenerator.cpp @@ -593,10 +593,8 @@ void HeaderGenerator::writeSbkTypeFunction(QTextStream& s, const AbstractMetaCla void HeaderGenerator::writeSbkTypeFunction(QTextStream &s, const AbstractMetaType *metaType) { - QString signature = metaType->cppSignature(); - TypeInfo::stripQualifiers(&signature); // for const refs to smart pointers - s << "template<> inline PyTypeObject *SbkType< ::" << signature << " >() " - << "{ return reinterpret_cast<PyTypeObject *>(" << cpythonTypeNameExt(metaType) << "); }\n"; + s << "template<> inline PyTypeObject* SbkType< ::" << metaType->cppSignature() << " >() " + << "{ return reinterpret_cast<PyTypeObject*>(" << cpythonTypeNameExt(metaType) << "); }\n"; } void HeaderGenerator::writeInheritedOverloads(QTextStream& s) diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp index 5d599fe95..2b3b20c75 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp @@ -2681,11 +2681,8 @@ QString ShibokenGenerator::getTypeIndexVariableName(const TypeEntry* type) QString ShibokenGenerator::getTypeIndexVariableName(const AbstractMetaType* type) { QString result = QLatin1String("SBK"); - const auto *typeEntry = type->typeEntry(); - if (typeEntry->isContainer() - || typeEntry->isSmartPointer()) { // PYSIDE-1024 + if (type->typeEntry()->isContainer()) result += QLatin1Char('_') + moduleName().toUpper(); - } result += processInstantiationsVariableName(type); appendIndexSuffix(&result); return result; |