aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-12-22 11:32:13 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-12-23 19:05:29 +0100
commitcd4a21c79510007dc8c28ce3671f332c9ec77fac (patch)
tree37467491fff70223396c2731d01b3a4aafefd25c
parentf5f2340f1c4e84d848f7b86152041f846fc6dcd5 (diff)
shiboken6: De-virtualize TypeEntry::targetLangApiName()
It is only used for the "target" attribute of PrimitiveTypeEntry, all other overridden methods return some Java-ish name. Make it a settable property and remove the overridden methods. Change-Id: I34dd3c7a2cb3ea4f6968dc8c8d1a70aad9fbf5ed Reviewed-by: Christian Tismer <tismer@stackless.com> (cherry picked from commit 7819758c3e259b59786abdcdb4051ce2024ede3a) Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--sources/shiboken6/ApiExtractor/typesystem.cpp45
-rw-r--r--sources/shiboken6/ApiExtractor/typesystem.h29
2 files changed, 16 insertions, 58 deletions
diff --git a/sources/shiboken6/ApiExtractor/typesystem.cpp b/sources/shiboken6/ApiExtractor/typesystem.cpp
index 0a1f4b888..407d63b0c 100644
--- a/sources/shiboken6/ApiExtractor/typesystem.cpp
+++ b/sources/shiboken6/ApiExtractor/typesystem.cpp
@@ -71,6 +71,7 @@ public:
const TypeEntry *m_parent;
QString m_name; // C++ fully qualified
+ QString m_targetLangApiName;
mutable QString m_cachedShortName; // C++ excluding inline namespaces
QString m_entryName;
QString m_targetLangPackage;
@@ -430,7 +431,13 @@ QString TypeEntry::qualifiedCppName() const
QString TypeEntry::targetLangApiName() const
{
- return m_d->m_name;
+ return m_d->m_targetLangApiName.isEmpty()
+ ? m_d->m_name : m_d->m_targetLangApiName;
+}
+
+void TypeEntry::setTargetLangApiName(const QString &t)
+{
+ m_d->m_targetLangApiName = t;
}
QString TypeEntry::targetLangName() const
@@ -778,14 +785,6 @@ QString ArrayTypeEntry::buildTargetLangName() const
return d->m_nestedType->targetLangName() + QLatin1String("[]");
}
-QString ArrayTypeEntry::targetLangApiName() const
-{
- S_D(const ArrayTypeEntry);
- return d->m_nestedType->isPrimitive()
- ? d->m_nestedType->targetLangApiName() + QLatin1String("Array")
- : QLatin1String("jobjectArray");
-}
-
TypeEntry *ArrayTypeEntry::clone() const
{
S_D(const ArrayTypeEntry);
@@ -808,7 +807,6 @@ public:
{
}
- QString m_targetLangApiName;
QString m_defaultConstructor;
uint m_preferredTargetLangType : 1;
PrimitiveTypeEntry* m_referencedTypeEntry = nullptr;
@@ -820,18 +818,6 @@ PrimitiveTypeEntry::PrimitiveTypeEntry(const QString &entryName, const QVersionN
{
}
-QString PrimitiveTypeEntry::targetLangApiName() const
-{
- S_D(const PrimitiveTypeEntry);
- return d->m_targetLangApiName;
-}
-
-void PrimitiveTypeEntry::setTargetLangApiName(const QString &targetLangApiName)
-{
- S_D(PrimitiveTypeEntry);
- d->m_targetLangApiName = targetLangApiName;
-}
-
QString PrimitiveTypeEntry::defaultConstructor() const
{
S_D(const PrimitiveTypeEntry);
@@ -972,11 +958,6 @@ QStringList EnumTypeEntry::enumValueRejections() const
return d->m_rejectedEnums;
}
-QString EnumTypeEntry::targetLangApiName() const
-{
- return QLatin1String("jint");
-}
-
TypeEntry *EnumTypeEntry::clone() const
{
S_D(const EnumTypeEntry);
@@ -1068,11 +1049,6 @@ FlagsTypeEntry::FlagsTypeEntry(FlagsTypeEntryPrivate *d) :
{
}
-QString FlagsTypeEntry::targetLangApiName() const
-{
- return QLatin1String("jint");
-}
-
QString FlagsTypeEntry::originalName() const
{
S_D(const FlagsTypeEntry);
@@ -1179,11 +1155,6 @@ bool ComplexTypeEntry::isComplex() const
return true;
}
-QString ComplexTypeEntry::targetLangApiName() const
-{
- return QStringLiteral("jobject");
-}
-
void ComplexTypeEntry::setTypeFlags(TypeFlags flags)
{
S_D(ComplexTypeEntry);
diff --git a/sources/shiboken6/ApiExtractor/typesystem.h b/sources/shiboken6/ApiExtractor/typesystem.h
index a823814f7..93e5e4117 100644
--- a/sources/shiboken6/ApiExtractor/typesystem.h
+++ b/sources/shiboken6/ApiExtractor/typesystem.h
@@ -175,16 +175,14 @@ public:
virtual QString qualifiedCppName() const;
- /**
- * Its type's name in target language API
- * The target language API name represents how this type is
- * referred on low level code for the target language.
- * Examples: for Java this would be a JNI name, for Python
- * it should represent the CPython type name.
- * /return string representing the target language API name
- * for this type entry
- */
- virtual QString targetLangApiName() const;
+ /// Its type's name in target language API.
+ /// The target language API name represents how this type is referred on
+ /// low level code for the target language. Examples: for Java this would
+ /// be a JNI name, for Python it should represent the CPython type name.
+ /// \return string representing the target language API name
+ /// Currently used only for PrimitiveTypeEntry (attribute "target").
+ QString targetLangApiName() const;
+ void setTargetLangApiName(const QString &t);
// The type's name in TargetLang
QString targetLangName() const; // "Foo.Bar"
@@ -349,8 +347,6 @@ public:
void setNestedTypeEntry(TypeEntry *nested);
const TypeEntry *nestedTypeEntry() const;
- QString targetLangApiName() const override;
-
TypeEntry *clone() const override;
protected:
@@ -365,9 +361,6 @@ public:
explicit PrimitiveTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent);
- QString targetLangApiName() const override;
- void setTargetLangApiName(const QString &targetLangApiName);
-
QString defaultConstructor() const;
void setDefaultConstructor(const QString& defaultConstructor);
bool hasDefaultConstructor() const;
@@ -412,8 +405,6 @@ public:
QString targetLangQualifier() const;
- QString targetLangApiName() const override;
-
QString qualifier() const;
const EnumValueTypeEntry *nullValue() const;
@@ -459,8 +450,6 @@ public:
explicit FlagsTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent);
- QString targetLangApiName() const override;
-
QString originalName() const;
void setOriginalName(const QString &s);
@@ -512,8 +501,6 @@ public:
bool isComplex() const override;
- QString targetLangApiName() const override;
-
TypeFlags typeFlags() const;
void setTypeFlags(TypeFlags flags);