aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6
diff options
context:
space:
mode:
authorFriedemann Kleint <[email protected]>2025-03-18 15:05:32 +0100
committerFriedemann Kleint <[email protected]>2025-03-19 15:59:43 +0100
commit46d6165ff78e5b9ec377bd9f29eeff4b304c08f6 (patch)
treeafb653a753d50b875d766c0d774c58b2ee2d6b1b /sources/shiboken6
parent24de09d518dabe11cb45ff2dc36e8d180e8f31ab (diff)
shiboken6: Introduce convenience API AbstractMetaType::basicPrimitiveName()
It removes the need to resolve it via TypeEntry. Pick-to: 6.9 Change-Id: I20230078a8d87d4be3af21127fac111c5c04eec9 Reviewed-by: Christian Tismer <[email protected]>
Diffstat (limited to 'sources/shiboken6')
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetafunction.cpp5
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetatype.cpp7
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetatype.h2
-rw-r--r--sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp2
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp3
-rw-r--r--sources/shiboken6/generator/shiboken/overloaddata.cpp18
-rw-r--r--sources/shiboken6/generator/shiboken/shibokengenerator.cpp3
7 files changed, 21 insertions, 19 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp b/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp
index d127a544e..0891498ba 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp
@@ -226,9 +226,8 @@ void AbstractMetaFunction::setExplicit(bool isExplicit)
bool AbstractMetaFunction::returnsBool() const
{
- if (d->m_type.typeUsagePattern() != AbstractMetaType::PrimitivePattern)
- return false;
- return basicReferencedTypeEntry(d->m_type.typeEntry())->name() == u"bool";
+ return d->m_type.typeUsagePattern() == AbstractMetaType::PrimitivePattern
+ && d->m_type.basicPrimitiveName() == "bool"_L1;
}
bool AbstractMetaFunction::isOperatorBool() const
diff --git a/sources/shiboken6/ApiExtractor/abstractmetatype.cpp b/sources/shiboken6/ApiExtractor/abstractmetatype.cpp
index ae76e713c..5e0273e09 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetatype.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetatype.cpp
@@ -10,6 +10,7 @@
#include "enumtypeentry.h"
#include "flagstypeentry.h"
#include "cpptypeentry.h"
+#include "primitivetypeentry.h"
#include "qtcompat.h"
#include "typeinfo.h"
@@ -196,6 +197,12 @@ QString AbstractMetaType::name() const
return d->m_typeEntry->targetLangEntryName();
}
+QString AbstractMetaType::basicPrimitiveName() const
+{
+ return d->m_typeEntry->isPrimitive()
+ ? basicReferencedTypeEntry(d->m_typeEntry)->name() : name();
+}
+
QString AbstractMetaType::fullName() const
{
return d->m_typeEntry->qualifiedTargetLangName();
diff --git a/sources/shiboken6/ApiExtractor/abstractmetatype.h b/sources/shiboken6/ApiExtractor/abstractmetatype.h
index 1a94879ba..449b9ec69 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetatype.h
+++ b/sources/shiboken6/ApiExtractor/abstractmetatype.h
@@ -58,6 +58,8 @@ public:
QString package() const;
QString name() const;
+ /// For a C++ primitive type, resolve the name ("quint32"->"unsigned int")
+ QString basicPrimitiveName() const;
QString fullName() const;
void setTypeUsagePattern(TypeUsagePattern pattern);
diff --git a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp
index aa969d3e6..0ff1f1d8c 100644
--- a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp
@@ -843,7 +843,7 @@ QString QtDocGenerator::translateToPythonType(const AbstractMetaType &type,
return name;
if (type.typeUsagePattern() == AbstractMetaType::PrimitivePattern) {
- const auto &basicName = basicReferencedTypeEntry(type.typeEntry())->name();
+ const auto &basicName = type.basicPrimitiveName();
if (AbstractMetaType::cppSignedIntTypes().contains(basicName)
|| AbstractMetaType::cppUnsignedIntTypes().contains(basicName)) {
return intT;
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index 2d467e7b9..860f6d546 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -1192,8 +1192,7 @@ std::pair<QString, QChar> CppGenerator::virtualMethodNativeArg(const AbstractMet
auto argTypeEntry = type.typeEntry();
// Check for primitive types convertible by Py_BuildValue()
if (argTypeEntry->isPrimitive() && !type.isCString()) {
- const auto pte = basicReferencedTypeEntry(argTypeEntry);
- auto it = formatUnits().constFind(pte->name());
+ auto it = formatUnits().constFind(type.basicPrimitiveName());
if (it != formatUnits().constEnd())
return {arg.name(), it.value()};
}
diff --git a/sources/shiboken6/generator/shiboken/overloaddata.cpp b/sources/shiboken6/generator/shiboken/overloaddata.cpp
index a9e652c6d..6f3637c29 100644
--- a/sources/shiboken6/generator/shiboken/overloaddata.cpp
+++ b/sources/shiboken6/generator/shiboken/overloaddata.cpp
@@ -31,17 +31,11 @@ using namespace Qt::StringLiterals;
static QString getTypeName(const AbstractMetaType &type)
{
TypeEntryCPtr typeEntry = type.typeEntry();
- if (typeEntry->isPrimitive())
- typeEntry = basicReferencedTypeEntry(typeEntry);
- QString typeName = typeEntry->name();
+ QString typeName = type.basicPrimitiveName();
if (typeEntry->isContainer()) {
QStringList types;
- for (const auto &cType : type.instantiations()) {
- TypeEntryCPtr typeEntry = cType.typeEntry();
- if (typeEntry->isPrimitive())
- typeEntry = basicReferencedTypeEntry(typeEntry);
- types << typeEntry->name();
- }
+ for (const auto &cType : type.instantiations())
+ types << cType.basicPrimitiveName();
typeName += u'<' + types.join(u',') + u" >"_s;
}
return typeName;
@@ -182,7 +176,8 @@ void OverloadDataRootNode::sortNextOverloads(const ApiExtractorResult &api)
// and being PointF implicitly convertible from Point, an list<T> instantiation with T
// as Point must come before the PointF instantiation, or else list<Point> will never
// be called. In the case of primitive types, list<double> must come before list<int>.
- if (instantiation.isPrimitive() && (signedIntegerPrimitives.contains(instantiation.name()))) {
+ if (instantiation.isPrimitive()
+ && signedIntegerPrimitives.contains(instantiation.basicPrimitiveName())) {
for (const QString &primitive : std::as_const(nonIntegerPrimitives))
graph.addNode(getImplicitConversionTypeName(ov->argType(), instantiation, nullptr, primitive));
} else {
@@ -262,7 +257,8 @@ void OverloadDataRootNode::sortNextOverloads(const ApiExtractorResult &api)
if (!graph.containsEdge(targetTypeEntryName, convertible)) // Avoid cyclic dependency.
graph.addEdge(convertible, targetTypeEntryName);
- if (instantiation.isPrimitive() && (signedIntegerPrimitives.contains(instantiation.name()))) {
+ if (instantiation.isPrimitive()
+ && signedIntegerPrimitives.contains(instantiation.basicPrimitiveName())) {
for (const QString &primitive : std::as_const(nonIntegerPrimitives)) {
QString convertibleTypeName =
getImplicitConversionTypeName(ov->argType(), instantiation, nullptr, primitive);
diff --git a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp
index fbc3c6ae0..5f59c3eda 100644
--- a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp
@@ -2296,8 +2296,7 @@ static AbstractMetaFunctionCList filterFunctions(const OverloadRemovalRules &rem
auto amt = f->arguments().at(argNo).type();
if (!amt.passByValue() && !amt.passByConstRef()) // Only simple types so far
return result;
- types.append(amt.isPrimitive()
- ? basicReferencedTypeEntry(amt.typeEntry())->name() : amt.name());
+ types.append(amt.basicPrimitiveName());
}
// Apply rules and compile list of redundant functions