aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-10-16 13:12:31 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-10-23 05:39:55 +0000
commit3aa406eb69290686b6a1693abd33d9abb419ae20 (patch)
treecf53ee3d84f7a3d6deec0deada51e9d39fc633fe /sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
parent7c448f5c27a51a60e27a54b79e298b53312ef2a8 (diff)
shiboken2: AbstractMetaType: use QSharedData[Pointer]
Previously, shiboken2 kept AbstractMetaType by a raw pointer. The data were copied numerous times by AbstractMetaType::copy() when adding the inherited functions to a AbstractMetaClass or specializing templates, sometimes with a bool flag indicating ownership. To get rid of the copies and ownership issues, change the type to be based on QSharedData[Pointer]. It can then be passed around and treated like a C++ value type, with Qt sharing the data when possible behind the scenes. - Extract AbstractMetaType to a separate header/source - Remove unused AbstractMetaType::setInstantiationInCpp() - Remove unused member m_package - Rewrite the comparison of AbstractMetaType which becomes relevant for checking/detaching to do a complete comparison. It was previously unused, intended for a different implementation of view types with special cases. - Rework debug formatting - Invalid meta types are indicated by the "Invalid" usage pattern instead of null pointers Change-Id: Ic4b1feecafb4f0355f39e178c2703b104e45cf6c Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp')
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
index 81b404239..f091860ca 100644
--- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
@@ -88,7 +88,7 @@ static bool shouldSkip(const AbstractMetaFunction* func)
const AbstractMetaArgumentList fargs = f->arguments();
for (int i = 0, max = funcArgs.count(); i < max; ++i) {
- if (funcArgs.at(i)->type()->typeEntry() != fargs.at(i)->type()->typeEntry()) {
+ if (funcArgs.at(i)->type().typeEntry() != fargs.at(i)->type().typeEntry()) {
cloneFound = false;
break;
}
@@ -1529,7 +1529,7 @@ QString QtDocGenerator::fileNameForContext(const GeneratorContext &context) cons
if (!context.forSmartPointer()) {
return metaClass->name() + fileNameSuffix();
}
- const AbstractMetaType *smartPointerType = context.preciseType();
+ const AbstractMetaType &smartPointerType = context.preciseType();
QString fileNameBase = getFileNameBaseForSmartPointer(smartPointerType, metaClass);
return fileNameBase + fileNameSuffix();
}
@@ -1876,7 +1876,7 @@ QString QtDocGenerator::parseArgDocStyle(const AbstractMetaClass* /* cppClass */
defValue.replace(QLatin1String("::"), QLatin1String("."));
if (defValue == QLatin1String("nullptr"))
defValue = none();
- else if (defValue == QLatin1String("0") && arg->type()->isObject())
+ else if (defValue == QLatin1String("0") && arg->type().isObject())
defValue = none();
}
ret += QLatin1Char('=') + defValue;
@@ -2003,13 +2003,14 @@ QString QtDocGenerator::functionSignature(const AbstractMetaClass* cppClass, con
+ QLatin1Char(')');
}
-QString QtDocGenerator::translateToPythonType(const AbstractMetaType* type, const AbstractMetaClass* cppClass)
+QString QtDocGenerator::translateToPythonType(const AbstractMetaType &type,
+ const AbstractMetaClass* cppClass)
{
static const QStringList nativeTypes = {boolT(), floatT(), intT(),
QLatin1String("object"),
QLatin1String("str")
};
- const QString name = type->name();
+ const QString name = type.name();
if (nativeTypes.contains(name))
return name;
@@ -2032,13 +2033,13 @@ QString QtDocGenerator::translateToPythonType(const AbstractMetaType* type, cons
return found.value();
QString strType;
- if (type->isConstant() && name == QLatin1String("char") && type->indirections() == 1) {
+ if (type.isConstant() && name == QLatin1String("char") && type.indirections() == 1) {
strType = QLatin1String("str");
} else if (name.startsWith(unsignedShortT())) {
strType = intT();
} else if (name.startsWith(unsignedT())) { // uint and ulong
strType = intT();
- } else if (type->isContainer()) {
+ } else if (type.isContainer()) {
QString strType = translateType(type, cppClass, Options(ExcludeConst) | ExcludeReference);
strType.remove(QLatin1Char('*'));
strType.remove(QLatin1Char('>'));
@@ -2055,8 +2056,8 @@ QString QtDocGenerator::translateToPythonType(const AbstractMetaType* type, cons
.arg(types[0], types[1]);
}
} else {
- const AbstractMetaClass *k = AbstractMetaClass::findClass(classes(), type->typeEntry());
- strType = k ? k->fullName() : type->name();
+ const AbstractMetaClass *k = AbstractMetaClass::findClass(classes(), type.typeEntry());
+ strType = k ? k->fullName() : type.name();
strType = QStringLiteral(":any:`") + strType + QLatin1Char('`');
}
return strType;