diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-11-14 10:50:57 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-11-17 18:14:28 +0100 |
commit | cf4f1a7488ba3202b44081eade36debf1d665e8f (patch) | |
tree | 15c65874973b87de4e96ec08f80c3ab0a264ae8b /sources/shiboken6/generator/shiboken/cppgenerator.cpp | |
parent | e9a406d871a74242555f4b75715fe36950e6788c (diff) |
shiboken6: Make some TypeEntry query functions free functions
Some query functions like TypeEntry::typeSystemTypeEntry() search in
the hierarchy, starting with "this". This cannot be ported to smart
pointers, so the functions are changed to be free functions where the
first element has to be passed in.
Change-Id: I3122b648ad499a2236577f6a101e8637a2f87d55
Reviewed-by: Christian Tismer <tismer@stackless.com>
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/shiboken6/generator/shiboken/cppgenerator.cpp')
-rw-r--r-- | sources/shiboken6/generator/shiboken/cppgenerator.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index ce4f8a74c..fbe7f183e 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -1295,7 +1295,7 @@ QPair<QString, QChar> CppGenerator::virtualMethodNativeArg(const AbstractMetaFun auto *argTypeEntry = type.typeEntry(); // Check for primitive types convertible by Py_BuildValue() if (argTypeEntry->isPrimitive() && !type.isCString()) { - const auto *pte = argTypeEntry->asPrimitive()->basicReferencedTypeEntry(); + const auto *pte = basicReferencedTypeEntry(argTypeEntry->asPrimitive()); auto it = formatUnits().constFind(pte->name()); if (it != formatUnits().constEnd()) return {arg.name(), it.value()}; @@ -2828,7 +2828,7 @@ void CppGenerator::writeTypeCheck(TextStream &s, const AbstractMetaType &argType if (!argType.typeEntry()->isCustom()) { typeCheck = u'(' + pythonToCppConverterForArgumentName(argumentName) + u" = "_s + typeCheck + u"))"_s; - if (!isNumber && argType.typeEntry()->isCppPrimitive()) { + if (!isNumber && isCppPrimitive(argType.typeEntry())) { typeCheck.prepend(cpythonCheckFunction(argType) + u'(' + argumentName + u") && "_s); } @@ -5393,7 +5393,7 @@ static ComparisonOperatorList smartPointeeComparisons(const GeneratorContext &co { Q_ASSERT(context.forSmartPointer()); auto *te = context.preciseType().instantiations().constFirst().typeEntry(); - if (te->isExtendedCppPrimitive()) { // Primitive pointee types have all + if (isExtendedCppPrimitive(te)) { // Primitive pointee types have all return {AbstractMetaFunction::OperatorEqual, AbstractMetaFunction::OperatorNotEqual, AbstractMetaFunction::OperatorLess, @@ -6623,7 +6623,7 @@ bool CppGenerator::finishGeneration() if (shouldGenerate(te)) { writeInitFunc(s_classInitDecl, s_classPythonDefines, getSimpleClassInitFunctionName(cls), - te->targetLangEnclosingEntry()); + targetLangEnclosingEntry(te)); if (cls->hasStaticFields()) { s_classInitDecl << "void " << getSimpleClassStaticFieldsInitFunctionName(cls) << "();\n"; @@ -6638,7 +6638,7 @@ bool CppGenerator::finishGeneration() auto *enclosingClass = context.metaClass()->enclosingClass(); auto *enclosingTypeEntry = enclosingClass != nullptr ? enclosingClass->typeEntry() - : smp.type.typeEntry()->targetLangEnclosingEntry(); + : targetLangEnclosingEntry(smp.type.typeEntry()); writeInitFunc(s_classInitDecl, s_classPythonDefines, getInitFunctionName(context), enclosingTypeEntry); @@ -6946,11 +6946,11 @@ bool CppGenerator::finishGeneration() s << "// Register primitive types converters.\n"; const PrimitiveTypeEntryCList &primitiveTypeList = primitiveTypes(); for (const PrimitiveTypeEntry *pte : primitiveTypeList) { - if (!pte->generateCode() || !pte->isCppPrimitive()) + if (!pte->generateCode() || !isCppPrimitive(pte)) continue; if (!pte->referencesType()) continue; - const TypeEntry *referencedType = pte->basicReferencedTypeEntry(); + const auto *referencedType = basicReferencedTypeEntry(pte); QString converter = converterObject(referencedType); QStringList cppSignature = pte->qualifiedCppName().split(u"::"_s, Qt::SkipEmptyParts); while (!cppSignature.isEmpty()) { |