diff options
-rw-r--r-- | sources/shiboken2/generator/generator.cpp | 6 | ||||
-rw-r--r-- | sources/shiboken2/generator/shiboken2/cppgenerator.cpp | 10 | ||||
-rw-r--r-- | sources/shiboken2/tests/libsmart/smart_obj.h | 2 |
3 files changed, 14 insertions, 4 deletions
diff --git a/sources/shiboken2/generator/generator.cpp b/sources/shiboken2/generator/generator.cpp index 585102b01..3cc625488 100644 --- a/sources/shiboken2/generator/generator.cpp +++ b/sources/shiboken2/generator/generator.cpp @@ -692,6 +692,9 @@ DefaultValue Generator::minimalConstructor(const AbstractMetaType *type) const if (Generator::isPointer(type)) return DefaultValue(DefaultValue::Pointer, QLatin1String("::") + type->typeEntry()->qualifiedCppName()); + if (type->typeEntry()->isSmartPointer()) + return minimalConstructor(type->typeEntry()); + if (type->typeEntry()->isComplex()) { auto cType = static_cast<const ComplexTypeEntry *>(type->typeEntry()); if (cType->hasDefaultConstructor()) @@ -746,6 +749,9 @@ DefaultValue Generator::minimalConstructor(const TypeEntry *type) const : DefaultValue(DefaultValue::Custom, ctor); } + if (type->isSmartPointer()) + return DefaultValue(DefaultValue::DefaultConstructor, type->qualifiedCppName()); + if (type->isComplex()) return minimalConstructor(AbstractMetaClass::findClass(classes(), type)); diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index e0fe88775..8b7ecfd4a 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -746,11 +746,14 @@ QString CppGenerator::getVirtualFunctionReturnTypeName(const AbstractMetaFunctio return QLatin1Char('"') + func->typeReplaced(0) + QLatin1Char('"'); // SbkType would return null when the type is a container. - if (func->type()->typeEntry()->isContainer()) { + auto typeEntry = func->type()->typeEntry(); + if (typeEntry->isContainer()) { return QLatin1Char('"') - + reinterpret_cast<const ContainerTypeEntry *>(func->type()->typeEntry())->typeName() + + reinterpret_cast<const ContainerTypeEntry *>(typeEntry)->typeName() + QLatin1Char('"'); } + if (typeEntry->isSmartPointer()) + return QLatin1Char('"') + typeEntry->qualifiedCppName() + QLatin1Char('"'); if (avoidProtectedHack()) { const AbstractMetaEnum *metaEnum = findAbstractMetaEnum(func->type()); @@ -761,7 +764,8 @@ QString CppGenerator::getVirtualFunctionReturnTypeName(const AbstractMetaFunctio if (func->type()->isPrimitive()) return QLatin1Char('"') + func->type()->name() + QLatin1Char('"'); - return QString::fromLatin1("reinterpret_cast<PyTypeObject *>(Shiboken::SbkType< %1 >())->tp_name").arg(func->type()->typeEntry()->qualifiedCppName()); + return QLatin1String("reinterpret_cast<PyTypeObject *>(Shiboken::SbkType< ") + + typeEntry->qualifiedCppName() + QLatin1String(" >())->tp_name"); } void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFunction *func) diff --git a/sources/shiboken2/tests/libsmart/smart_obj.h b/sources/shiboken2/tests/libsmart/smart_obj.h index e5709a071..8fe45993f 100644 --- a/sources/shiboken2/tests/libsmart/smart_obj.h +++ b/sources/shiboken2/tests/libsmart/smart_obj.h @@ -48,7 +48,7 @@ public: Integer takeInteger(Integer val); SharedPtr<Obj> giveSharedPtrToObj(); std::vector<SharedPtr<Obj> > giveSharedPtrToObjList(int size); - SharedPtr<Integer> giveSharedPtrToInteger(); + virtual SharedPtr<Integer> giveSharedPtrToInteger(); // virtual for PYSIDE-1188 SharedPtr<const Integer> giveSharedPtrToConstInteger(); int takeSharedPtrToConstInteger(SharedPtr<const Integer> pInt); SharedPtr<Smart::Integer2> giveSharedPtrToInteger2(); |