aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/typesystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/ApiExtractor/typesystem.cpp')
-rw-r--r--sources/shiboken6/ApiExtractor/typesystem.cpp921
1 files changed, 517 insertions, 404 deletions
diff --git a/sources/shiboken6/ApiExtractor/typesystem.cpp b/sources/shiboken6/ApiExtractor/typesystem.cpp
index f0a4a9027..99d42b668 100644
--- a/sources/shiboken6/ApiExtractor/typesystem.cpp
+++ b/sources/shiboken6/ApiExtractor/typesystem.cpp
@@ -5,14 +5,16 @@
#include "arraytypeentry.h"
#include "codesnip.h"
#include "complextypeentry.h"
+#include "configurabletypeentry.h"
#include "constantvaluetypeentry.h"
#include "containertypeentry.h"
-#include "customconversion.h"
#include "customtypenentry.h"
+#include "debughelpers_p.h"
#include "enumtypeentry.h"
#include "enumvaluetypeentry.h"
#include "flagstypeentry.h"
#include "functiontypeentry.h"
+#include "include.h"
#include "namespacetypeentry.h"
#include "objecttypeentry.h"
#include "primitivetypeentry.h"
@@ -27,7 +29,6 @@
#include "abstractmetatype.h"
#include "typedatabase.h"
#include "modifications.h"
-#include "messages.h"
#include "sourcelocation.h"
#include "qtcompat.h"
@@ -39,7 +40,7 @@
using namespace Qt::StringLiterals;
-static QString buildName(const QString &entryName, const TypeEntry *parent)
+static QString buildName(const QString &entryName, const TypeEntryCPtr &parent)
{
return parent == nullptr || parent->type() == TypeEntry::TypeSystemType
? entryName : parent->name() + u"::"_s + entryName;
@@ -51,31 +52,31 @@ static QString buildName(const QString &entryName, const TypeEntry *parent)
class TypeEntryPrivate
{
public:
+ TypeEntryPrivate(const TypeEntryPrivate &) = default; // Enable copy for cloning.
+ TypeEntryPrivate &operator=(const TypeEntryPrivate &) = delete;
+ TypeEntryPrivate(TypeEntryPrivate &&) = delete;
+ TypeEntryPrivate &operator=(TypeEntryPrivate &&) = delete;
+
explicit TypeEntryPrivate(const QString &entryName, TypeEntry::Type t, const QVersionNumber &vr,
- const TypeEntry *parent);
- virtual ~TypeEntryPrivate();
+ const TypeEntryCPtr &parent);
+ virtual ~TypeEntryPrivate() = default;
QString shortName() const;
- const TypeEntry *m_parent;
+ TypeEntryCPtr m_parent;
QString m_name; // C++ fully qualified
mutable QString m_cachedShortName; // C++ excluding inline namespaces
QString m_entryName;
QString m_targetLangPackage;
mutable QString m_cachedTargetLangName; // "Foo.Bar"
mutable QString m_cachedTargetLangEntryName; // "Bar"
- CodeSnipList m_codeSnips;
- DocModificationList m_docModifications;
IncludeList m_extraIncludes;
- IncludeList m_argumentIncludes;
Include m_include;
- QString m_targetConversionRule;
QVersionNumber m_version;
- CustomConversion *m_customConversion = nullptr;
SourceLocation m_sourceLocation; // XML file
TypeEntry::CodeGeneration m_codeGeneration = TypeEntry::GenerateCode;
- TypeEntry *m_viewOn = nullptr;
- CustomTypeEntry *m_targetLangApiType = nullptr;
+ TypeEntryPtr m_viewOn;
+ CustomTypeEntryPtr m_targetLangApiType;
int m_revision = 0;
int m_sbkIndex = 0;
TypeEntry::Type m_type;
@@ -85,7 +86,7 @@ public:
};
TypeEntryPrivate::TypeEntryPrivate(const QString &entryName, TypeEntry::Type t, const QVersionNumber &vr,
- const TypeEntry *parent) :
+ const TypeEntryCPtr &parent) :
m_parent(parent),
m_name(buildName(entryName, parent)),
m_entryName(entryName),
@@ -94,13 +95,8 @@ TypeEntryPrivate::TypeEntryPrivate(const QString &entryName, TypeEntry::Type t,
{
}
-TypeEntryPrivate::~TypeEntryPrivate()
-{
- delete m_customConversion;
-}
-
TypeEntry::TypeEntry(const QString &entryName, TypeEntry::Type t, const QVersionNumber &vr,
- const TypeEntry *parent) :
+ const TypeEntryCPtr &parent) :
TypeEntry(new TypeEntryPrivate(entryName, t, vr, parent))
{
}
@@ -111,36 +107,6 @@ TypeEntry::TypeEntry(TypeEntryPrivate *d) : m_d(d)
TypeEntry::~TypeEntry() = default;
-const CodeSnipList &TypeEntry::codeSnips() const
-{
- return m_d->m_codeSnips;
-}
-
-CodeSnipList &TypeEntry::codeSnips()
-{
- return m_d->m_codeSnips;
-}
-
-void TypeEntry::setCodeSnips(const CodeSnipList &codeSnips)
-{
- m_d->m_codeSnips = codeSnips;
-}
-
-void TypeEntry::addCodeSnip(const CodeSnip &codeSnip)
-{
- m_d->m_codeSnips << codeSnip;
-}
-
-void TypeEntry::setDocModification(const DocModificationList &docMods)
-{
- m_d->m_docModifications << docMods;
-}
-
-DocModificationList TypeEntry::docModifications() const
-{
- return m_d->m_docModifications;
-}
-
const IncludeList &TypeEntry::extraIncludes() const
{
return m_d->m_extraIncludes;
@@ -157,17 +123,6 @@ void TypeEntry::addExtraInclude(const Include &newInclude)
m_d->m_extraIncludes.append(newInclude);
}
-const IncludeList &TypeEntry::argumentIncludes() const
-{
- return m_d->m_argumentIncludes;
-}
-
-void TypeEntry::addArgumentInclude(const Include &newInclude)
-{
- if (!m_d->m_argumentIncludes.contains(newInclude))
- m_d->m_argumentIncludes.append(newInclude);
-}
-
Include TypeEntry::include() const
{
return m_d->m_include;
@@ -187,36 +142,20 @@ void TypeEntry::setInclude(const Include &inc)
}
}
-void TypeEntry::setTargetConversionRule(const QString &conversionRule)
-{
- m_d->m_targetConversionRule = conversionRule;
-}
-
-QString TypeEntry::targetConversionRule() const
-{
- return m_d->m_targetConversionRule;
-}
-
QVersionNumber TypeEntry::version() const
{
return m_d->m_version;
}
-bool TypeEntry::hasTargetConversionRule() const
+bool isCppPrimitive(const TypeEntryCPtr &e)
{
- return !m_d->m_targetConversionRule.isEmpty();
-}
-
-bool TypeEntry::isCppPrimitive() const
-{
- if (!isPrimitive())
+ if (!e->isPrimitive())
return false;
- if (m_d->m_type == VoidType)
+ if (e->type() == TypeEntry::VoidType)
return true;
- const PrimitiveTypeEntry *referencedType =
- static_cast<const PrimitiveTypeEntry *>(this)->basicReferencedTypeEntry();
+ PrimitiveTypeEntryCPtr referencedType = basicReferencedTypeEntry(e);
const QString &typeName = referencedType->name();
return AbstractMetaType::cppPrimitiveTypes().contains(typeName);
}
@@ -226,17 +165,17 @@ TypeEntry::Type TypeEntry::type() const
return m_d->m_type;
}
-const TypeEntry *TypeEntry::parent() const
+TypeEntryCPtr TypeEntry::parent() const
{
return m_d->m_parent;
}
-void TypeEntry::setParent(const TypeEntry *p)
+void TypeEntry::setParent(const TypeEntryCPtr &p)
{
m_d->m_parent = p;
}
-bool TypeEntry::isChildOf(const TypeEntry *p) const
+bool TypeEntry::isChildOf(const TypeEntryCPtr &p) const
{
for (auto e = m_d->m_parent; e; e = e->parent()) {
if (e == p)
@@ -245,18 +184,18 @@ bool TypeEntry::isChildOf(const TypeEntry *p) const
return false;
}
-const TypeSystemTypeEntry *TypeEntry::typeSystemTypeEntry() const
+TypeSystemTypeEntryCPtr typeSystemTypeEntry(TypeEntryCPtr e)
{
- for (auto e = this; e; e = e->parent()) {
+ for (; e; e = e->parent()) {
if (e->type() == TypeEntry::TypeSystemType)
- return static_cast<const TypeSystemTypeEntry *>(e);
+ return std::static_pointer_cast<const TypeSystemTypeEntry>(e);
}
- return nullptr;
+ return {};
}
-const TypeEntry *TypeEntry::targetLangEnclosingEntry() const
+TypeEntryCPtr targetLangEnclosingEntry(const TypeEntryCPtr &e)
{
- auto result = m_d->m_parent;
+ auto result = e->parent();
while (result && result->type() != TypeEntry::TypeSystemType
&& !NamespaceTypeEntry::isVisibleScope(result)) {
result = result->parent();
@@ -387,11 +326,11 @@ QString TypeEntry::name() const
QString TypeEntryPrivate::shortName() const
{
if (m_cachedShortName.isEmpty()) {
- QVarLengthArray<const TypeEntry *> parents;
+ QVarLengthArray<TypeEntryCPtr > parents;
bool foundInlineNamespace = false;
for (auto p = m_parent; p != nullptr && p->type() != TypeEntry::TypeSystemType; p = p->parent()) {
if (p->type() == TypeEntry::NamespaceType
- && static_cast<const NamespaceTypeEntry *>(p)->isInlineNamespace()) {
+ && std::static_pointer_cast<const NamespaceTypeEntry>(p)->isInlineNamespace()) {
foundInlineNamespace = true;
} else {
parents.append(p);
@@ -399,7 +338,7 @@ QString TypeEntryPrivate::shortName() const
}
if (foundInlineNamespace) {
m_cachedShortName.reserve(m_name.size());
- for (int i = parents.size() - 1; i >= 0; --i) {
+ for (auto i = parents.size() - 1; i >= 0; --i) {
m_cachedShortName.append(parents.at(i)->entryName());
m_cachedShortName.append(u"::"_s);
}
@@ -456,7 +395,7 @@ QString TypeEntry::qualifiedCppName() const
return m_d->m_name;
}
-const CustomTypeEntry *TypeEntry::targetLangApiType() const
+CustomTypeEntryCPtr TypeEntry::targetLangApiType() const
{
return m_d->m_targetLangApiType;
}
@@ -466,7 +405,7 @@ bool TypeEntry::hasTargetLangApiType() const
return m_d->m_targetLangApiType != nullptr;
}
-void TypeEntry::setTargetLangApiType(CustomTypeEntry *cte)
+void TypeEntry::setTargetLangApiType(const CustomTypeEntryPtr &cte)
{
m_d->m_targetLangApiType = cte;
}
@@ -526,18 +465,12 @@ void TypeEntry::setSourceLocation(const SourceLocation &sourceLocation)
m_d->m_sourceLocation = sourceLocation;
}
-const PrimitiveTypeEntry *TypeEntry::asPrimitive() const
+bool isUserPrimitive(const TypeEntryCPtr &e)
{
- Q_ASSERT(m_d->m_type == PrimitiveType);
- return static_cast<const PrimitiveTypeEntry *>(this);
-}
-
-bool TypeEntry::isUserPrimitive() const
-{
- if (!isPrimitive())
+ if (!e->isPrimitive())
return false;
- const auto *type = asPrimitive()->basicReferencedTypeEntry();
- return !type->isCppPrimitive()
+ const auto type = basicReferencedTypeEntry(e);
+ return !isCppPrimitive(type)
&& type->qualifiedCppName() != u"std::string";
}
@@ -546,21 +479,21 @@ bool TypeEntry::isWrapperType() const
return isObject() || isValue() || isSmartPointer();
}
-bool TypeEntry::isCppIntegralPrimitive() const
+bool isCppIntegralPrimitive(const TypeEntryCPtr &e)
{
- if (!isCppPrimitive())
+ if (!isCppPrimitive(e))
return false;
- const auto *type = asPrimitive()->basicReferencedTypeEntry();
+ const auto type = basicReferencedTypeEntry(e);
return AbstractMetaType::cppIntegralTypes().contains(type->qualifiedCppName());
}
-bool TypeEntry::isExtendedCppPrimitive() const
+bool isExtendedCppPrimitive(const TypeEntryCPtr &e)
{
- if (isCppPrimitive())
+ if (isCppPrimitive(e))
return true;
- if (!isPrimitive())
+ if (!e->isPrimitive())
return false;
- const auto *type = asPrimitive()->basicReferencedTypeEntry();
+ const auto type = basicReferencedTypeEntry(e);
const QString &name = type->qualifiedCppName();
return name == u"std::string" || name == u"std::wstring";
}
@@ -611,27 +544,12 @@ bool TypeEntry::isComplex() const
return false;
}
-bool TypeEntry::hasCustomConversion() const
-{
- return m_d->m_customConversion != nullptr;
-}
-
-void TypeEntry::setCustomConversion(CustomConversion* customConversion)
-{
- m_d->m_customConversion = customConversion;
-}
-
-CustomConversion* TypeEntry::customConversion() const
-{
- return m_d->m_customConversion;
-}
-
-TypeEntry *TypeEntry::viewOn() const
+TypeEntryPtr TypeEntry::viewOn() const
{
return m_d->m_viewOn;
}
-void TypeEntry::setViewOn(TypeEntry *v)
+void TypeEntry::setViewOn(const TypeEntryPtr &v)
{
m_d->m_viewOn = v;
}
@@ -642,10 +560,10 @@ TypeEntry *TypeEntry::clone() const
}
// Take over parameters relevant for typedefs
-void TypeEntry::useAsTypedef(const TypeEntry *source)
+void TypeEntry::useAsTypedef(const TypeEntryCPtr &source)
{
// XML Typedefs are in the global namespace for now.
- m_d->m_parent = source->typeSystemTypeEntry();
+ m_d->m_parent = typeSystemTypeEntry(source);
m_d->m_entryName = source->m_d->m_entryName;
m_d->m_name = source->m_d->m_name;
m_d->m_targetLangPackage = source->m_d->m_targetLangPackage;
@@ -665,7 +583,7 @@ public:
};
CustomTypeEntry::CustomTypeEntry(const QString &entryName, const QVersionNumber &vr,
- const TypeEntry *parent) :
+ const TypeEntryCPtr &parent) :
TypeEntry(new CustomTypeEntryPrivate(entryName, CustomType, vr, parent))
{
}
@@ -746,11 +664,15 @@ class TypeSystemTypeEntryPrivate : public TypeEntryPrivate
public:
using TypeEntryPrivate::TypeEntryPrivate;
+ CodeSnipList m_codeSnips;
TypeSystem::SnakeCase m_snakeCase = TypeSystem::SnakeCase::Disabled;
+ QString m_subModuleOf;
+ QString m_namespaceBegin;
+ QString m_namespaceEnd;
};
TypeSystemTypeEntry::TypeSystemTypeEntry(const QString &entryName, const QVersionNumber &vr,
- const TypeEntry *parent) :
+ const TypeEntryCPtr &parent) :
TypeEntry(new TypeSystemTypeEntryPrivate(entryName, TypeSystemType, vr, parent))
{
}
@@ -766,6 +688,60 @@ TypeEntry *TypeSystemTypeEntry::clone() const
return new TypeSystemTypeEntry(new TypeSystemTypeEntryPrivate(*d));
}
+const CodeSnipList &TypeSystemTypeEntry::codeSnips() const
+{
+ S_D(const TypeSystemTypeEntry);
+ return d->m_codeSnips;
+}
+
+CodeSnipList &TypeSystemTypeEntry::codeSnips()
+{
+ S_D(TypeSystemTypeEntry);
+ return d->m_codeSnips;
+}
+
+void TypeSystemTypeEntry::addCodeSnip(const CodeSnip &codeSnip)
+{
+ S_D(TypeSystemTypeEntry);
+ d->m_codeSnips.append(codeSnip);
+}
+
+QString TypeSystemTypeEntry::subModuleOf() const
+{
+ S_D(const TypeSystemTypeEntry);
+ return d->m_subModuleOf;
+}
+
+void TypeSystemTypeEntry::setSubModule(const QString &s)
+{
+ S_D(TypeSystemTypeEntry);
+ d->m_subModuleOf = s;
+}
+
+const QString &TypeSystemTypeEntry::namespaceBegin() const
+{
+ S_D(const TypeSystemTypeEntry);
+ return d->m_namespaceBegin;
+}
+
+void TypeSystemTypeEntry::setNamespaceBegin(const QString &p)
+{
+ S_D(TypeSystemTypeEntry);
+ d->m_namespaceBegin = p;
+}
+
+const QString &TypeSystemTypeEntry::namespaceEnd() const
+{
+ S_D(const TypeSystemTypeEntry);
+ return d->m_namespaceEnd;
+}
+
+void TypeSystemTypeEntry::setNamespaceEnd(const QString &n)
+{
+ S_D(TypeSystemTypeEntry);
+ d->m_namespaceEnd = n;
+}
+
TypeSystem::SnakeCase TypeSystemTypeEntry::snakeCase() const
{
S_D(const TypeSystemTypeEntry);
@@ -820,7 +796,7 @@ public:
};
TemplateArgumentEntry::TemplateArgumentEntry(const QString &entryName, const QVersionNumber &vr,
- const TypeEntry *parent) :
+ const TypeEntryCPtr &parent) :
TypeEntry(new TemplateArgumentEntryPrivate(entryName, TemplateArgumentType, vr, parent))
{
}
@@ -852,30 +828,30 @@ TemplateArgumentEntry::TemplateArgumentEntry(TemplateArgumentEntryPrivate *d) :
class ArrayTypeEntryPrivate : public TypeEntryPrivate
{
public:
- explicit ArrayTypeEntryPrivate(const TypeEntry *nested_type, const QVersionNumber &vr,
- const TypeEntry *parent) :
+ explicit ArrayTypeEntryPrivate(const TypeEntryCPtr &nested_type, const QVersionNumber &vr,
+ const TypeEntryCPtr &parent) :
TypeEntryPrivate(u"Array"_s, TypeEntry::ArrayType, vr, parent),
m_nestedType(nested_type)
{
}
- const TypeEntry *m_nestedType;
+ TypeEntryCPtr m_nestedType;
};
-ArrayTypeEntry::ArrayTypeEntry(const TypeEntry *nested_type, const QVersionNumber &vr,
- const TypeEntry *parent) :
+ArrayTypeEntry::ArrayTypeEntry(const TypeEntryCPtr &nested_type, const QVersionNumber &vr,
+ const TypeEntryCPtr &parent) :
TypeEntry(new ArrayTypeEntryPrivate(nested_type, vr, parent))
{
Q_ASSERT(nested_type);
}
-void ArrayTypeEntry::setNestedTypeEntry(TypeEntry *nested)
+void ArrayTypeEntry::setNestedTypeEntry(const TypeEntryPtr &nested)
{
S_D(ArrayTypeEntry);
d->m_nestedType = nested;
}
-const TypeEntry *ArrayTypeEntry::nestedTypeEntry() const
+TypeEntryCPtr ArrayTypeEntry::nestedTypeEntry() const
{
S_D(const ArrayTypeEntry);
return d->m_nestedType;
@@ -903,19 +879,20 @@ class PrimitiveTypeEntryPrivate : public TypeEntryPrivate
{
public:
PrimitiveTypeEntryPrivate(const QString &entryName, const QVersionNumber &vr,
- const TypeEntry *parent) :
+ const TypeEntryCPtr &parent) :
TypeEntryPrivate(entryName, TypeEntry::PrimitiveType, vr, parent),
m_preferredTargetLangType(true)
{
}
QString m_defaultConstructor;
+ CustomConversionPtr m_customConversion;
+ PrimitiveTypeEntryPtr m_referencedTypeEntry;
uint m_preferredTargetLangType : 1;
- PrimitiveTypeEntry* m_referencedTypeEntry = nullptr;
};
PrimitiveTypeEntry::PrimitiveTypeEntry(const QString &entryName, const QVersionNumber &vr,
- const TypeEntry *parent) :
+ const TypeEntryCPtr &parent) :
TypeEntry(new PrimitiveTypeEntryPrivate(entryName, vr, parent))
{
}
@@ -938,29 +915,35 @@ bool PrimitiveTypeEntry::hasDefaultConstructor() const
return !d->m_defaultConstructor.isEmpty();
}
-PrimitiveTypeEntry *PrimitiveTypeEntry::referencedTypeEntry() const
+PrimitiveTypeEntryPtr PrimitiveTypeEntry::referencedTypeEntry() const
{
S_D(const PrimitiveTypeEntry);
return d->m_referencedTypeEntry;
}
-void PrimitiveTypeEntry::setReferencedTypeEntry(PrimitiveTypeEntry *referencedTypeEntry)
+void PrimitiveTypeEntry::setReferencedTypeEntry(PrimitiveTypeEntryPtr referencedTypeEntry)
{
S_D(PrimitiveTypeEntry);
d->m_referencedTypeEntry = referencedTypeEntry;
}
-const PrimitiveTypeEntry *PrimitiveTypeEntry::basicReferencedTypeEntry() const
+PrimitiveTypeEntryCPtr basicReferencedTypeEntry(const PrimitiveTypeEntryCPtr &e)
{
- auto *result = this;
- while (auto *referenced = result->referencedTypeEntry())
+ auto result = e;
+ while (auto referenced = result->referencedTypeEntry())
result = referenced;
return result;
}
-const PrimitiveTypeEntry *PrimitiveTypeEntry::basicReferencedNonBuiltinTypeEntry() const
+PrimitiveTypeEntryCPtr basicReferencedTypeEntry(const TypeEntryCPtr &e)
{
- auto *result = this;
+ Q_ASSERT(e->isPrimitive());
+ return basicReferencedTypeEntry(std::static_pointer_cast<const PrimitiveTypeEntry>(e));
+}
+
+PrimitiveTypeEntryCPtr basicReferencedNonBuiltinTypeEntry(const PrimitiveTypeEntryCPtr &e)
+{
+ auto result = e;
for (; result->referencedTypeEntry() ; result = result->referencedTypeEntry()) {
if (!result->isBuiltIn())
break;
@@ -986,6 +969,24 @@ void PrimitiveTypeEntry::setPreferredTargetLangType(bool b)
d->m_preferredTargetLangType = b;
}
+bool PrimitiveTypeEntry::hasCustomConversion() const
+{
+ S_D(const PrimitiveTypeEntry);
+ return bool(d->m_customConversion);
+}
+
+void PrimitiveTypeEntry::setCustomConversion(const CustomConversionPtr &customConversion)
+{
+ S_D(PrimitiveTypeEntry);
+ d->m_customConversion = customConversion;
+}
+
+CustomConversionPtr PrimitiveTypeEntry::customConversion() const
+{
+ S_D(const PrimitiveTypeEntry);
+ return d->m_customConversion;
+}
+
TypeEntry *PrimitiveTypeEntry::clone() const
{
S_D(const PrimitiveTypeEntry);
@@ -997,24 +998,87 @@ PrimitiveTypeEntry::PrimitiveTypeEntry(PrimitiveTypeEntryPrivate *d)
{
}
-// ----------------- EnumTypeEntry
-class EnumTypeEntryPrivate : public TypeEntryPrivate
+// ----------------- ConfigurableTypeEntry
+
+class ConfigurableTypeEntryPrivate : public TypeEntryPrivate
{
public:
using TypeEntryPrivate::TypeEntryPrivate;
- const EnumValueTypeEntry *m_nullValue = nullptr;
+ QString m_configCondition;
+};
+
+ConfigurableTypeEntry::ConfigurableTypeEntry(const QString &entryName, Type t,
+ const QVersionNumber &vr,
+ const TypeEntryCPtr &parent) :
+ TypeEntry(new ConfigurableTypeEntryPrivate(entryName, t, vr, parent))
+{
+}
+
+ConfigurableTypeEntry::ConfigurableTypeEntry(ConfigurableTypeEntryPrivate *d) :
+ TypeEntry(d)
+{
+}
+
+TypeEntry *ConfigurableTypeEntry::clone() const
+{
+ S_D(const ConfigurableTypeEntry);
+ return new ConfigurableTypeEntry(new ConfigurableTypeEntryPrivate(*d));
+}
+
+QString ConfigurableTypeEntry::configCondition() const
+{
+ S_D(const ConfigurableTypeEntry);
+ return d->m_configCondition;
+}
+
+void ConfigurableTypeEntry::setConfigCondition(const QString &c)
+{
+ S_D(ConfigurableTypeEntry);
+ d->m_configCondition = c;
+ if (!d->m_configCondition.startsWith(u'#'))
+ d->m_configCondition.prepend(u"#if ");
+}
+
+bool ConfigurableTypeEntry::hasConfigCondition() const
+{
+ S_D(const ConfigurableTypeEntry);
+ return !d->m_configCondition.isEmpty();
+}
+
+// ----------------- EnumTypeEntry
+class EnumTypeEntryPrivate : public ConfigurableTypeEntryPrivate
+{
+public:
+ using ConfigurableTypeEntryPrivate::ConfigurableTypeEntryPrivate;
+
+ EnumValueTypeEntryCPtr m_nullValue;
QStringList m_rejectedEnums;
- FlagsTypeEntry *m_flags = nullptr;
+ FlagsTypeEntryPtr m_flags;
+ QString m_cppType;
+ QString m_docFile;
+ TypeSystem::PythonEnumType m_pythonEnumType = TypeSystem::PythonEnumType::Unspecified;
};
EnumTypeEntry::EnumTypeEntry(const QString &entryName,
const QVersionNumber &vr,
- const TypeEntry *parent) :
- TypeEntry(new EnumTypeEntryPrivate(entryName, EnumType, vr, parent))
+ const TypeEntryCPtr &parent) :
+ ConfigurableTypeEntry(new EnumTypeEntryPrivate(entryName, EnumType, vr, parent))
{
}
+TypeSystem::PythonEnumType EnumTypeEntry::pythonEnumType() const
+{
+ S_D(const EnumTypeEntry);
+ return d->m_pythonEnumType;
+}
+
+void EnumTypeEntry::setPythonEnumType(TypeSystem::PythonEnumType t)
+{
+ S_D(EnumTypeEntry);
+ d->m_pythonEnumType = t;
+}
+
QString EnumTypeEntry::targetLangQualifier() const
{
const QString q = qualifier();
@@ -1032,30 +1096,42 @@ QString EnumTypeEntry::qualifier() const
parentEntry->name() : QString();
}
-const EnumValueTypeEntry *EnumTypeEntry::nullValue() const
+EnumValueTypeEntryCPtr EnumTypeEntry::nullValue() const
{
S_D(const EnumTypeEntry);
return d->m_nullValue;
}
-void EnumTypeEntry::setNullValue(const EnumValueTypeEntry *n)
+void EnumTypeEntry::setNullValue(const EnumValueTypeEntryCPtr &n)
{
S_D(EnumTypeEntry);
d->m_nullValue = n;
}
-void EnumTypeEntry::setFlags(FlagsTypeEntry *flags)
+void EnumTypeEntry::setFlags(const FlagsTypeEntryPtr &flags)
{
S_D(EnumTypeEntry);
d->m_flags = flags;
}
-FlagsTypeEntry *EnumTypeEntry::flags() const
+FlagsTypeEntryPtr EnumTypeEntry::flags() const
{
S_D(const EnumTypeEntry);
return d->m_flags;
}
+QString EnumTypeEntry::cppType() const
+{
+ S_D(const EnumTypeEntry);
+ return d->m_cppType;
+}
+
+void EnumTypeEntry::setCppType(const QString &t)
+{
+ S_D(EnumTypeEntry);
+ d->m_cppType = t;
+}
+
bool EnumTypeEntry::isEnumValueRejected(const QString &name) const
{
S_D(const EnumTypeEntry);
@@ -1074,6 +1150,18 @@ QStringList EnumTypeEntry::enumValueRejections() const
return d->m_rejectedEnums;
}
+QString EnumTypeEntry::docFile() const
+{
+ S_D(const EnumTypeEntry);
+ return d->m_docFile;
+}
+
+void EnumTypeEntry::setDocFile(const QString &df)
+{
+ S_D(EnumTypeEntry);
+ d->m_docFile = df;
+}
+
TypeEntry *EnumTypeEntry::clone() const
{
S_D(const EnumTypeEntry);
@@ -1081,7 +1169,7 @@ TypeEntry *EnumTypeEntry::clone() const
}
EnumTypeEntry::EnumTypeEntry(EnumTypeEntryPrivate *d) :
- TypeEntry(d)
+ ConfigurableTypeEntry(d)
{
}
@@ -1090,7 +1178,7 @@ class EnumValueTypeEntryPrivate : public TypeEntryPrivate
{
public:
EnumValueTypeEntryPrivate(const QString &name, const QString &value,
- const EnumTypeEntry *enclosingEnum,
+ const EnumTypeEntryCPtr &enclosingEnum,
bool isScopedEnum,
const QVersionNumber &vr) :
TypeEntryPrivate(name, TypeEntry::EnumValue, vr,
@@ -1101,11 +1189,11 @@ public:
}
QString m_value;
- const EnumTypeEntry *m_enclosingEnum;
+ EnumTypeEntryCPtr m_enclosingEnum;
};
EnumValueTypeEntry::EnumValueTypeEntry(const QString &name, const QString &value,
- const EnumTypeEntry *enclosingEnum,
+ const EnumTypeEntryCPtr &enclosingEnum,
bool isScopedEnum,
const QVersionNumber &vr) :
TypeEntry(new EnumValueTypeEntryPrivate(name, value, enclosingEnum, isScopedEnum, vr))
@@ -1118,7 +1206,7 @@ QString EnumValueTypeEntry::value() const
return d->m_value;
}
-const EnumTypeEntry *EnumValueTypeEntry::enclosingEnum() const
+EnumTypeEntryCPtr EnumValueTypeEntry::enclosingEnum() const
{
S_D(const EnumValueTypeEntry);
return d->m_enclosingEnum;
@@ -1143,11 +1231,11 @@ public:
QString m_originalName;
QString m_flagsName;
- EnumTypeEntry *m_enum = nullptr;
+ EnumTypeEntryPtr m_enum;
};
FlagsTypeEntry::FlagsTypeEntry(const QString &entryName, const QVersionNumber &vr,
- const TypeEntry *parent) :
+ const TypeEntryCPtr &parent) :
TypeEntry(new FlagsTypeEntryPrivate(entryName, FlagsType, vr, parent))
{
}
@@ -1189,13 +1277,13 @@ void FlagsTypeEntry::setFlagsName(const QString &name)
d->m_flagsName = name;
}
-EnumTypeEntry *FlagsTypeEntry::originator() const
+EnumTypeEntryPtr FlagsTypeEntry::originator() const
{
S_D(const FlagsTypeEntry);
return d->m_enum;
}
-void FlagsTypeEntry::setOriginator(EnumTypeEntry *e)
+void FlagsTypeEntry::setOriginator(const EnumTypeEntryPtr &e)
{
S_D(FlagsTypeEntry);
d->m_enum = e;
@@ -1209,7 +1297,7 @@ TypeEntry *FlagsTypeEntry::clone() const
// ----------------- ConstantValueTypeEntry
ConstantValueTypeEntry::ConstantValueTypeEntry(const QString& name,
- const TypeEntry *parent) :
+ const TypeEntryCPtr &parent) :
TypeEntry(name, ConstantValueType, QVersionNumber(0, 0), parent)
{
}
@@ -1220,13 +1308,13 @@ ConstantValueTypeEntry::ConstantValueTypeEntry(TypeEntryPrivate *d) :
}
// ----------------- ComplexTypeEntry
-class ComplexTypeEntryPrivate : public TypeEntryPrivate
+class ComplexTypeEntryPrivate : public ConfigurableTypeEntryPrivate
{
public:
ComplexTypeEntryPrivate(const QString &entryName, TypeEntry::Type t,
const QVersionNumber &vr,
- const TypeEntry *parent) :
- TypeEntryPrivate(entryName, t, vr, parent),
+ const TypeEntryCPtr &parent) :
+ ConfigurableTypeEntryPrivate(entryName, t, vr, parent),
m_qualifiedCppName(buildName(entryName, parent)),
m_polymorphicBase(false),
m_genericClass(false),
@@ -1236,6 +1324,10 @@ public:
AddedFunctionList m_addedFunctions;
FunctionModificationList m_functionMods;
+ CodeSnipList m_codeSnips;
+ DocModificationList m_docModifications;
+ DocModificationList m_functionDocModifications;
+ IncludeList m_argumentIncludes;
QSet<QString> m_generateFunctions;
FieldModificationList m_fieldMods;
QList<TypeSystemProperty> m_properties;
@@ -1255,7 +1347,7 @@ public:
ComplexTypeEntry::CopyableFlag m_copyableFlag = ComplexTypeEntry::Unknown;
QString m_hashFunction;
- const ComplexTypeEntry* m_baseContainerType = nullptr;
+ ComplexTypeEntryCPtr m_baseContainerType;
// For class functions
TypeSystem::ExceptionHandling m_exceptionHandling = TypeSystem::ExceptionHandling::Unspecified;
TypeSystem::AllowThread m_allowThread = TypeSystem::AllowThread::Unspecified;
@@ -1270,8 +1362,8 @@ public:
ComplexTypeEntry::ComplexTypeEntry(const QString &entryName, TypeEntry::Type t,
const QVersionNumber &vr,
- const TypeEntry *parent) :
- TypeEntry(new ComplexTypeEntryPrivate(entryName, t, vr, parent))
+ const TypeEntryCPtr &parent) :
+ ConfigurableTypeEntry(new ComplexTypeEntryPrivate(entryName, t, vr, parent))
{
}
@@ -1334,17 +1426,77 @@ void ComplexTypeEntry::addFunctionModification(const FunctionModification &funct
d->m_functionMods << functionModification;
}
-FunctionModificationList ComplexTypeEntry::functionModifications(const QString &signature) const
+FunctionModificationList
+ ComplexTypeEntry::functionModifications(const QStringList &signatures) const
{
S_D(const ComplexTypeEntry);
FunctionModificationList lst;
for (const auto &mod : std::as_const(d->m_functionMods)) {
- if (mod.matches(signature))
+ if (mod.matches(signatures))
lst << mod;
}
return lst;
}
+const CodeSnipList &ComplexTypeEntry::codeSnips() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_codeSnips;
+}
+
+CodeSnipList &ComplexTypeEntry::codeSnips()
+{
+ S_D(ComplexTypeEntry);
+ return d->m_codeSnips;
+}
+
+void ComplexTypeEntry::setCodeSnips(const CodeSnipList &codeSnips)
+{
+ S_D(ComplexTypeEntry);
+ d->m_codeSnips = codeSnips;
+}
+
+void ComplexTypeEntry::addCodeSnip(const CodeSnip &codeSnip)
+{
+ S_D(ComplexTypeEntry);
+ d->m_codeSnips << codeSnip;
+}
+
+void ComplexTypeEntry::setDocModification(const DocModificationList &docMods)
+{
+ S_D(ComplexTypeEntry);
+ for (const auto &m : docMods) {
+ if (m.signature().isEmpty())
+ d->m_docModifications << m;
+ else
+ d->m_functionDocModifications << m;
+ }
+}
+
+DocModificationList ComplexTypeEntry::docModifications() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_docModifications;
+}
+
+DocModificationList ComplexTypeEntry::functionDocModifications() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_functionDocModifications;
+}
+
+const IncludeList &ComplexTypeEntry::argumentIncludes() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_argumentIncludes;
+}
+
+void ComplexTypeEntry::addArgumentInclude(const Include &newInclude)
+{
+ S_D(ComplexTypeEntry);
+ IncludeGroup::appendInclude(newInclude, &d->m_argumentIncludes);
+}
+
AddedFunctionList ComplexTypeEntry::addedFunctions() const
{
S_D(const ComplexTypeEntry);
@@ -1537,13 +1689,13 @@ void ComplexTypeEntry::setHashFunction(const QString &hashFunction)
d->m_hashFunction = hashFunction;
}
-void ComplexTypeEntry::setBaseContainerType(const ComplexTypeEntry *baseContainer)
+void ComplexTypeEntry::setBaseContainerType(const ComplexTypeEntryCPtr &baseContainer)
{
S_D(ComplexTypeEntry);
d->m_baseContainerType = baseContainer;
}
-const ComplexTypeEntry *ComplexTypeEntry::baseContainerType() const
+ComplexTypeEntryCPtr ComplexTypeEntry::baseContainerType() const
{
S_D(const ComplexTypeEntry);
return d->m_baseContainerType;
@@ -1635,16 +1787,17 @@ TypeEntry *ComplexTypeEntry::clone() const
}
// Take over parameters relevant for typedefs
-void ComplexTypeEntry::useAsTypedef(const ComplexTypeEntry *source)
+void ComplexTypeEntry::useAsTypedef(const ComplexTypeEntryCPtr &source)
{
S_D(ComplexTypeEntry);
TypeEntry::useAsTypedef(source);
d->m_qualifiedCppName = source->qualifiedCppName();
d->m_targetType = source->targetType();
+ d->m_typeFlags.setFlag(ComplexTypeEntry::Typedef);
}
ComplexTypeEntry::ComplexTypeEntry(ComplexTypeEntryPrivate *d) :
- TypeEntry(d)
+ ConfigurableTypeEntry(d)
{
}
@@ -1663,7 +1816,7 @@ public:
TypedefEntryPrivate(const QString &entryName,
const QString &sourceType,
const QVersionNumber &vr,
- const TypeEntry *parent) :
+ const TypeEntryCPtr &parent) :
ComplexTypeEntryPrivate(entryName, TypeEntry::TypedefType,
vr, parent),
m_sourceType(sourceType)
@@ -1671,12 +1824,12 @@ public:
}
QString m_sourceType;
- const ComplexTypeEntry *m_source = nullptr;
- ComplexTypeEntry *m_target = nullptr;
+ ComplexTypeEntryCPtr m_source;
+ ComplexTypeEntryPtr m_target;
};
TypedefEntry::TypedefEntry(const QString &entryName, const QString &sourceType,
- const QVersionNumber &vr, const TypeEntry *parent) :
+ const QVersionNumber &vr, const TypeEntryCPtr &parent) :
ComplexTypeEntry(new TypedefEntryPrivate(entryName, sourceType, vr, parent))
{
}
@@ -1699,25 +1852,25 @@ TypeEntry *TypedefEntry::clone() const
return new TypedefEntry(new TypedefEntryPrivate(*d));
}
-const ComplexTypeEntry *TypedefEntry::source() const
+ComplexTypeEntryCPtr TypedefEntry::source() const
{
S_D(const TypedefEntry);
return d->m_source;
}
-void TypedefEntry::setSource(const ComplexTypeEntry *source)
+void TypedefEntry::setSource(const ComplexTypeEntryCPtr &source)
{
S_D(TypedefEntry);
d->m_source = source;
}
-ComplexTypeEntry *TypedefEntry::target() const
+ComplexTypeEntryPtr TypedefEntry::target() const
{
S_D(const TypedefEntry);
return d->m_target;
}
-void TypedefEntry::setTarget(ComplexTypeEntry *target)
+void TypedefEntry::setTarget(ComplexTypeEntryPtr target)
{
S_D(TypedefEntry);
d->m_target = target;
@@ -1732,33 +1885,44 @@ TypedefEntry::TypedefEntry(TypedefEntryPrivate *d) :
class ContainerTypeEntryPrivate : public ComplexTypeEntryPrivate
{
public:
- using OpaqueContainer = ContainerTypeEntry::OpaqueContainer;
- using OpaqueContainers = ContainerTypeEntry::OpaqueContainers;
-
ContainerTypeEntryPrivate(const QString &entryName,
ContainerTypeEntry::ContainerKind containerKind,
const QVersionNumber &vr,
- const TypeEntry *parent) :
+ const TypeEntryCPtr &parent) :
ComplexTypeEntryPrivate(entryName, TypeEntry::ContainerType, vr, parent),
m_containerKind(containerKind)
{
}
- OpaqueContainers::const_iterator findOpaqueContainer(const QString &instantiation) const
+ OpaqueContainers::const_iterator findOpaqueContainer(const QStringList &instantiations) const
{
return std::find_if(m_opaqueContainers.cbegin(), m_opaqueContainers.cend(),
- [&instantiation](const OpaqueContainer &r) {
- return r.instantiation == instantiation;
+ [&instantiations](const OpaqueContainer &r) {
+ return r.instantiations == instantiations;
});
}
OpaqueContainers m_opaqueContainers;
+ CustomConversionPtr m_customConversion;
ContainerTypeEntry::ContainerKind m_containerKind;
};
+QString OpaqueContainer::templateParameters() const
+{
+ QString result;
+ result += u'<';
+ for (qsizetype i = 0, size = instantiations.size(); i < size; ++i) {
+ if (i)
+ result += u',';
+ result += instantiations.at(i);
+ }
+ result += u'>';
+ return result;
+}
+
ContainerTypeEntry::ContainerTypeEntry(const QString &entryName, ContainerKind containerKind,
const QVersionNumber &vr,
- const TypeEntry *parent) :
+ const TypeEntryCPtr &parent) :
ComplexTypeEntry(new ContainerTypeEntryPrivate(entryName, containerKind, vr, parent))
{
setCodeGeneration(GenerateForSubclass);
@@ -1770,36 +1934,67 @@ ContainerTypeEntry::ContainerKind ContainerTypeEntry::containerKind() const
return d->m_containerKind;
}
-const ContainerTypeEntry::OpaqueContainers &ContainerTypeEntry::opaqueContainers() const
+qsizetype ContainerTypeEntry::templateParameterCount() const
+{
+ S_D(const ContainerTypeEntry);
+ qsizetype result = 1;
+ switch (d->m_containerKind) {
+ case MapContainer:
+ case MultiMapContainer:
+ case PairContainer:
+ case SpanContainer:
+ result = 2;
+ break;
+ case ListContainer:
+ case SetContainer:
+ break;
+ }
+ return result;
+}
+
+const OpaqueContainers &ContainerTypeEntry::opaqueContainers() const
{
S_D(const ContainerTypeEntry);
return d->m_opaqueContainers;
}
-void ContainerTypeEntry::addOpaqueContainer(OpaqueContainer r)
+void ContainerTypeEntry::appendOpaqueContainers(const OpaqueContainers &l)
{
S_D(ContainerTypeEntry);
- // Fix to match AbstractMetaType::signature() which is used for matching
- // "Foo*" -> "Foo *"
- const auto asteriskPos = r.instantiation.indexOf(u'*');
- if (asteriskPos > 0 && !r.instantiation.at(asteriskPos - 1).isSpace())
- r.instantiation.insert(asteriskPos, u' ');
- d->m_opaqueContainers.append(r);
+ d->m_opaqueContainers.append(l);
}
-bool ContainerTypeEntry::generateOpaqueContainer(const QString &instantiation) const
+bool ContainerTypeEntry::generateOpaqueContainer(const QStringList &instantiations) const
{
S_D(const ContainerTypeEntry);
- return d->findOpaqueContainer(instantiation) != d->m_opaqueContainers.cend();
+ return d->findOpaqueContainer(instantiations) != d->m_opaqueContainers.cend();
}
-QString ContainerTypeEntry::opaqueContainerName(const QString &instantiation) const
+QString ContainerTypeEntry::opaqueContainerName(const QStringList &instantiations) const
{
S_D(const ContainerTypeEntry);
- const auto it = d->findOpaqueContainer(instantiation);
+ const auto it = d->findOpaqueContainer(instantiations);
return it != d->m_opaqueContainers.cend() ? it->name : QString{};
}
+bool ContainerTypeEntry::hasCustomConversion() const
+{
+ S_D(const ContainerTypeEntry);
+ return bool(d->m_customConversion);
+}
+
+void ContainerTypeEntry::setCustomConversion(const CustomConversionPtr &customConversion)
+{
+ S_D(ContainerTypeEntry);
+ d->m_customConversion = customConversion;
+}
+
+CustomConversionPtr ContainerTypeEntry::customConversion() const
+{
+ S_D(const ContainerTypeEntry);
+ return d->m_customConversion;
+}
+
TypeEntry *ContainerTypeEntry::clone() const
{
S_D(const ContainerTypeEntry);
@@ -1819,7 +2014,7 @@ public:
const QString &getterName,
TypeSystem::SmartPointerType type,
const QString &refCountMethodName,
- const QVersionNumber &vr, const TypeEntry *parent) :
+ const QVersionNumber &vr, const TypeEntryCPtr &parent) :
ComplexTypeEntryPrivate(entryName, TypeEntry::SmartPointerType, vr, parent),
m_getterName(getterName),
m_refCountMethodName(refCountMethodName),
@@ -1827,6 +2022,8 @@ public:
{
}
+ qsizetype instantiationIndex(const TypeEntryCPtr &t) const;
+
QString m_getterName;
QString m_refCountMethodName;
QString m_valueCheckMethod;
@@ -1836,11 +2033,21 @@ public:
TypeSystem::SmartPointerType m_smartPointerType;
};
+qsizetype SmartPointerTypeEntryPrivate::instantiationIndex(const TypeEntryCPtr &t) const
+{
+ for (qsizetype i = 0, size = m_instantiations.size(); i < size; ++i) {
+ if (m_instantiations.at(i).typeEntry == t)
+ return i;
+ }
+ return -1;
+}
+
SmartPointerTypeEntry::SmartPointerTypeEntry(const QString &entryName,
const QString &getterName,
TypeSystem::SmartPointerType smartPointerType,
const QString &refCountMethodName,
- const QVersionNumber &vr, const TypeEntry *parent) :
+ const QVersionNumber &vr,
+ const TypeEntryCPtr &parent) :
ComplexTypeEntry(new SmartPointerTypeEntryPrivate(entryName, getterName, smartPointerType,
refCountMethodName, vr, parent))
{
@@ -1906,7 +2113,7 @@ TypeEntry *SmartPointerTypeEntry::clone() const
return new SmartPointerTypeEntry(new SmartPointerTypeEntryPrivate(*d));
}
-SmartPointerTypeEntry::Instantiations SmartPointerTypeEntry::instantiations() const
+const SmartPointerTypeEntry::Instantiations &SmartPointerTypeEntry::instantiations() const
{
S_D(const SmartPointerTypeEntry);
return d->m_instantiations;
@@ -1923,10 +2130,11 @@ SmartPointerTypeEntry::SmartPointerTypeEntry(SmartPointerTypeEntryPrivate *d) :
{
}
-bool SmartPointerTypeEntry::matchesInstantiation(const TypeEntry *e) const
+bool SmartPointerTypeEntry::matchesInstantiation(const TypeEntryCPtr &e) const
{
S_D(const SmartPointerTypeEntry);
- return d->m_instantiations.isEmpty() || d->m_instantiations.contains(e);
+ // No instantiations specified, or match
+ return d->m_instantiations.isEmpty() || d->instantiationIndex(e) != -1;
}
static QString fixSmartPointerName(QString name)
@@ -1938,18 +2146,14 @@ static QString fixSmartPointerName(QString name)
return name;
}
-QString SmartPointerTypeEntry::getTargetFullName(const AbstractMetaType &metaType,
- bool includePackageName)
+QString SmartPointerTypeEntry::getTargetName(const AbstractMetaType &metaType) const
{
- QString result;
- if (includePackageName)
- result += metaType.package() + u'.';
- result += fixSmartPointerName(metaType.cppSignature());
- return result;
-}
+ S_D(const SmartPointerTypeEntry);
+ auto instantiatedTe = metaType.instantiations().constFirst().typeEntry();
+ const auto index = d->instantiationIndex(instantiatedTe);
+ if (index != -1 && !d->m_instantiations.at(index).name.isEmpty())
+ return d->m_instantiations.at(index).name;
-QString SmartPointerTypeEntry::getTargetName(const AbstractMetaType &metaType)
-{
QString name = metaType.cppSignature();
const auto templatePos = name.indexOf(u'<');
if (templatePos != -1) { // "std::shared_ptr<A::B>" -> "shared_ptr<A::B>"
@@ -1967,7 +2171,7 @@ public:
using ComplexTypeEntryPrivate::ComplexTypeEntryPrivate;
QRegularExpression m_filePattern;
- const NamespaceTypeEntry *m_extends = nullptr;
+ NamespaceTypeEntryCPtr m_extends;
TypeSystem::Visibility m_visibility = TypeSystem::Visibility::Auto;
bool m_hasPattern = false;
bool m_inlineNamespace = false;
@@ -1975,7 +2179,7 @@ public:
};
NamespaceTypeEntry::NamespaceTypeEntry(const QString &entryName, const QVersionNumber &vr,
- const TypeEntry *parent) :
+ const TypeEntryCPtr &parent) :
ComplexTypeEntry(new NamespaceTypeEntryPrivate(entryName, NamespaceType, vr, parent))
{
}
@@ -1986,13 +2190,13 @@ TypeEntry *NamespaceTypeEntry::clone() const
return new NamespaceTypeEntry(new NamespaceTypeEntryPrivate(*d));
}
-const NamespaceTypeEntry *NamespaceTypeEntry::extends() const
+NamespaceTypeEntryCPtr NamespaceTypeEntry::extends() const
{
S_D(const NamespaceTypeEntry);
return d->m_extends;
}
-void NamespaceTypeEntry::setExtends(const NamespaceTypeEntry *e)
+void NamespaceTypeEntry::setExtends(const NamespaceTypeEntryCPtr &e)
{
S_D(NamespaceTypeEntry);
d->m_extends = e;
@@ -2055,6 +2259,11 @@ void NamespaceTypeEntry::setInlineNamespace(bool i)
d->m_inlineNamespace = i;
}
+bool NamespaceTypeEntry::isVisibleScope(const TypeEntryCPtr &e)
+{
+ return isVisibleScope(e.get());
+}
+
bool NamespaceTypeEntry::isVisibleScope(const TypeEntry *e)
{
return e->type() != TypeEntry::NamespaceType
@@ -2074,180 +2283,78 @@ void NamespaceTypeEntry::setGenerateUsing(bool generateUsing)
}
// ----------------- ValueTypeEntry
-ValueTypeEntry::ValueTypeEntry(const QString &entryName, const QVersionNumber &vr,
- const TypeEntry *parent) :
- ComplexTypeEntry(entryName, BasicValueType, vr, parent)
-{
-}
-bool ValueTypeEntry::isValue() const
+class ValueTypeEntryPrivate : public ComplexTypeEntryPrivate
{
- return true;
-}
-
-TypeEntry *ValueTypeEntry::clone() const
-{
- S_D(const ComplexTypeEntry);
- return new ValueTypeEntry(new ComplexTypeEntryPrivate(*d));
-}
-
-ValueTypeEntry::ValueTypeEntry(ComplexTypeEntryPrivate *d) :
- ComplexTypeEntry(d)
-{
-}
-
-ValueTypeEntry::ValueTypeEntry(const QString &entryName, Type t, const QVersionNumber &vr,
- const TypeEntry *parent) :
- ComplexTypeEntry(entryName, t, vr, parent)
-{
-}
-
-// ----------------- CustomConversion
-struct CustomConversion::CustomConversionPrivate
-{
- CustomConversionPrivate(const TypeEntry* ownerType)
- : ownerType(ownerType), replaceOriginalTargetToNativeConversions(false)
- {
- }
- const TypeEntry* ownerType;
- QString nativeToTargetConversion;
- bool replaceOriginalTargetToNativeConversions;
- TargetToNativeConversions targetToNativeConversions;
-};
+public:
+ using ComplexTypeEntryPrivate::ComplexTypeEntryPrivate;
-struct CustomConversion::TargetToNativeConversion::TargetToNativeConversionPrivate
-{
- TargetToNativeConversionPrivate()
- : sourceType(nullptr)
- {
- }
- const TypeEntry* sourceType;
- QString sourceTypeName;
- QString sourceTypeCheck;
- QString conversion;
+ QString m_targetConversionRule;
+ CustomConversionPtr m_customConversion;
};
-CustomConversion::CustomConversion(TypeEntry* ownerType)
-{
- m_d = new CustomConversionPrivate(ownerType);
- if (ownerType)
- ownerType->setCustomConversion(this);
-}
-
-CustomConversion::~CustomConversion()
-{
- qDeleteAll(m_d->targetToNativeConversions);
- delete m_d;
-}
-
-const TypeEntry* CustomConversion::ownerType() const
-{
- return m_d->ownerType;
-}
-
-QString CustomConversion::nativeToTargetConversion() const
-{
- return m_d->nativeToTargetConversion;
-}
-
-void CustomConversion::setNativeToTargetConversion(const QString& nativeToTargetConversion)
-{
- m_d->nativeToTargetConversion = nativeToTargetConversion;
-}
-
-bool CustomConversion::replaceOriginalTargetToNativeConversions() const
-{
- return m_d->replaceOriginalTargetToNativeConversions;
-}
-
-void CustomConversion::setReplaceOriginalTargetToNativeConversions(bool replaceOriginalTargetToNativeConversions)
-{
- m_d->replaceOriginalTargetToNativeConversions = replaceOriginalTargetToNativeConversions;
-}
-
-bool CustomConversion::hasTargetToNativeConversions() const
-{
- return !(m_d->targetToNativeConversions.isEmpty());
-}
-
-CustomConversion::TargetToNativeConversions& CustomConversion::targetToNativeConversions()
+ValueTypeEntry::ValueTypeEntry(const QString &entryName, const QVersionNumber &vr,
+ const TypeEntryCPtr &parent) :
+ ComplexTypeEntry(new ValueTypeEntryPrivate(entryName, BasicValueType, vr, parent))
{
- return m_d->targetToNativeConversions;
}
-const CustomConversion::TargetToNativeConversions& CustomConversion::targetToNativeConversions() const
+bool ValueTypeEntry::hasCustomConversion() const
{
- return m_d->targetToNativeConversions;
+ S_D(const ValueTypeEntry);
+ return bool(d->m_customConversion);
}
-void CustomConversion::addTargetToNativeConversion(const QString& sourceTypeName,
- const QString& sourceTypeCheck,
- const QString& conversion)
+void ValueTypeEntry::setCustomConversion(const CustomConversionPtr &customConversion)
{
- m_d->targetToNativeConversions.append(new TargetToNativeConversion(sourceTypeName, sourceTypeCheck, conversion));
+ S_D(ValueTypeEntry);
+ d->m_customConversion = customConversion;
}
-CustomConversion::TargetToNativeConversion::TargetToNativeConversion(const QString& sourceTypeName,
- const QString& sourceTypeCheck,
- const QString& conversion)
+CustomConversionPtr ValueTypeEntry::customConversion() const
{
- m_d = new TargetToNativeConversionPrivate;
- m_d->sourceTypeName = sourceTypeName;
- m_d->sourceTypeCheck = sourceTypeCheck;
- m_d->conversion = conversion;
+ S_D(const ValueTypeEntry);
+ return d->m_customConversion;
}
-CustomConversion::TargetToNativeConversion::~TargetToNativeConversion()
+void ValueTypeEntry::setTargetConversionRule(const QString &conversionRule)
{
- delete m_d;
+ S_D(ValueTypeEntry);
+ d->m_targetConversionRule = conversionRule;
}
-const TypeEntry* CustomConversion::TargetToNativeConversion::sourceType() const
+QString ValueTypeEntry::targetConversionRule() const
{
- return m_d->sourceType;
+ S_D(const ValueTypeEntry);
+ return d->m_targetConversionRule;
}
-void CustomConversion::TargetToNativeConversion::setSourceType(const TypeEntry* sourceType)
+bool ValueTypeEntry::hasTargetConversionRule() const
{
- m_d->sourceType = sourceType;
+ S_D(const ValueTypeEntry);
+ return !d->m_targetConversionRule.isEmpty();
}
-bool CustomConversion::TargetToNativeConversion::isCustomType() const
+bool ValueTypeEntry::isValue() const
{
- return !(m_d->sourceType);
+ return true;
}
-QString CustomConversion::TargetToNativeConversion::sourceTypeName() const
+TypeEntry *ValueTypeEntry::clone() const
{
- return m_d->sourceTypeName;
+ S_D(const ValueTypeEntry);
+ return new ValueTypeEntry(new ValueTypeEntryPrivate(*d));
}
-QString CustomConversion::TargetToNativeConversion::sourceTypeCheck() const
-{
- if (!m_d->sourceTypeCheck.isEmpty())
- return m_d->sourceTypeCheck;
-
- if (m_d->sourceType != nullptr && m_d->sourceType->isCustom()) {
- const auto *cte = static_cast<const CustomTypeEntry *>(m_d->sourceType);
- if (cte->hasCheckFunction()) {
- QString result = cte->checkFunction();
- if (result != u"true") // For PyObject, which is always true
- result += u"(%in)"_s;
- return result;
- }
- }
-
- return {};
-}
-
-QString CustomConversion::TargetToNativeConversion::conversion() const
+ValueTypeEntry::ValueTypeEntry(ComplexTypeEntryPrivate *d) :
+ ComplexTypeEntry(d)
{
- return m_d->conversion;
}
-void CustomConversion::TargetToNativeConversion::setConversion(const QString& conversion)
+ValueTypeEntry::ValueTypeEntry(const QString &entryName, Type t, const QVersionNumber &vr,
+ const TypeEntryCPtr &parent) :
+ ComplexTypeEntry(entryName, t, vr, parent)
{
- m_d->conversion = conversion;
}
// ----------------- FunctionTypeEntry
@@ -2256,19 +2363,19 @@ class FunctionTypeEntryPrivate : public TypeEntryPrivate
public:
FunctionTypeEntryPrivate(const QString &entryName, const QString &signature,
const QVersionNumber &vr,
- const TypeEntry *parent) :
+ const TypeEntryCPtr &parent) :
TypeEntryPrivate(entryName, TypeEntry::FunctionType, vr, parent),
m_signatures(signature)
{
}
QStringList m_signatures;
- TypeSystem::SnakeCase m_snakeCase = TypeSystem::SnakeCase::Unspecified;
+ QString m_docFile;
};
FunctionTypeEntry::FunctionTypeEntry(const QString &entryName, const QString &signature,
const QVersionNumber &vr,
- const TypeEntry *parent) :
+ const TypeEntryCPtr &parent) :
TypeEntry(new FunctionTypeEntryPrivate(entryName, signature, vr, parent))
{
}
@@ -2291,16 +2398,16 @@ bool FunctionTypeEntry::hasSignature(const QString &signature) const
return d->m_signatures.contains(signature);
}
-TypeSystem::SnakeCase FunctionTypeEntry::snakeCase() const
+QString FunctionTypeEntry::docFile() const
{
S_D(const FunctionTypeEntry);
- return d->m_snakeCase;
+ return d->m_docFile;
}
-void FunctionTypeEntry::setSnakeCase(TypeSystem::SnakeCase sc)
+void FunctionTypeEntry::setDocFile(const QString &df)
{
S_D(FunctionTypeEntry);
- d->m_snakeCase = sc;
+ d->m_docFile = df;
}
TypeEntry *FunctionTypeEntry::clone() const
@@ -2316,7 +2423,7 @@ FunctionTypeEntry::FunctionTypeEntry(FunctionTypeEntryPrivate *d) :
// ----------------- ObjectTypeEntry
ObjectTypeEntry::ObjectTypeEntry(const QString &entryName, const QVersionNumber &vr,
- const TypeEntry *parent)
+ const TypeEntryCPtr &parent)
: ComplexTypeEntry(entryName, ObjectType, vr, parent)
{
}
@@ -2346,20 +2453,6 @@ ObjectTypeEntry::ObjectTypeEntry(ComplexTypeEntryPrivate *d) :
if (!var.isEmpty()) \
debug << ", " << var.size() << ' ' << name;
-template <class Container, class Separator>
-static void formatList(QDebug &d, const char *name, const Container &c, Separator sep)
-{
- if (const int size = c.size()) {
- d << ", " << name << '[' << size << "]=(";
- for (int i = 0; i < size; ++i) {
- if (i)
- d << sep;
- d << c.at(i);
- }
- d << ')';
- }
-}
-
void TypeEntry::formatDebug(QDebug &debug) const
{
const QString cppName = qualifiedCppName();
@@ -2374,8 +2467,6 @@ void TypeEntry::formatDebug(QDebug &debug) const
FORMAT_NONEMPTY_STRING("package", m_d->m_targetLangPackage)
FORMAT_BOOL("stream", m_d->m_stream)
FORMAT_BOOL("built-in", m_d->m_builtin)
- FORMAT_LIST_SIZE("codeSnips", m_d->m_codeSnips)
- FORMAT_NONEMPTY_STRING("targetConversionRule", m_d->m_targetConversionRule)
if (m_d->m_viewOn)
debug << ", views=" << m_d->m_viewOn->name();
if (!m_d->m_version.isNull() && m_d->m_version > QVersionNumber(0, 0))
@@ -2394,9 +2485,9 @@ void TypeEntry::formatDebug(QDebug &debug) const
void PrimitiveTypeEntry::formatDebug(QDebug &debug) const
{
TypeEntry::formatDebug(debug);
- if (auto *e = referencedTypeEntry()) {
+ if (auto e = referencedTypeEntry()) {
debug << ", references";
- for (; e != nullptr; e = e->referencedTypeEntry())
+ for (; e ; e = e->referencedTypeEntry())
debug << ":\"" << e->qualifiedCppName() <<'"';
}
}
@@ -2420,6 +2511,7 @@ void ComplexTypeEntry::formatDebug(QDebug &debug) const
FORMAT_NONEMPTY_STRING("hash", d->m_hashFunction)
FORMAT_LIST_SIZE("addedFunctions", d->m_addedFunctions)
formatList(debug, "functionMods", d->m_functionMods, ", ");
+ FORMAT_LIST_SIZE("codeSnips", d->m_codeSnips)
FORMAT_LIST_SIZE("fieldMods", d->m_fieldMods)
}
@@ -2443,8 +2535,7 @@ void FunctionTypeEntry::formatDebug(QDebug &debug) const
S_D(const FunctionTypeEntry);
TypeEntry::formatDebug(debug);
- debug << "signatures=" << d->m_signatures
- << ", snakeCase=" << int(d->m_snakeCase);
+ debug << "signatures=" << d->m_signatures;
}
void TypedefEntry::formatDebug(QDebug &debug) const
@@ -2461,6 +2552,8 @@ void EnumTypeEntry::formatDebug(QDebug &debug) const
S_D(const EnumTypeEntry);
TypeEntry::formatDebug(debug);
+ if (d->m_pythonEnumType != TypeSystem::PythonEnumType::Unspecified)
+ debug << ", python-type=" << int(d->m_pythonEnumType);
if (d->m_flags)
debug << ", flags=(" << d->m_flags << ')';
}
@@ -2477,18 +2570,23 @@ void NamespaceTypeEntry::formatDebug(QDebug &debug) const
debug << "[inline]";
}
+QDebug operator<<(QDebug d, const OpaqueContainer &oc)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "OpaqueContainer(\"" << oc.name << "\": " << oc.templateParameters() << ')';
+ return d;
+}
+
void ContainerTypeEntry::formatDebug(QDebug &debug) const
{
S_D(const ContainerTypeEntry);
ComplexTypeEntry::formatDebug(debug);
debug << ", type=" << d->m_containerKind << '"';
- if (!d->m_opaqueContainers.isEmpty()) {
- debug << ", opaque-containers=[";
- for (const auto &r : d->m_opaqueContainers)
- debug << r.instantiation << "->" << r.name << ',';
- debug << ']';
- }
+ if (!d->m_opaqueContainers.isEmpty())
+ debug << ", opaque-containers=[" << d->m_opaqueContainers << ']';
}
void SmartPointerTypeEntry::formatDebug(QDebug &debug) const
@@ -2499,8 +2597,11 @@ void SmartPointerTypeEntry::formatDebug(QDebug &debug) const
if (!d->m_instantiations.isEmpty()) {
debug << "type=" << d->m_type << ", instantiations["
<< d->m_instantiations.size() << "]=(";
- for (auto i : d->m_instantiations)
- debug << i->name() << ',';
+ for (const auto &i : d->m_instantiations) {
+ debug << i.typeEntry->name() << ',';
+ if (!i.name.isEmpty())
+ debug << "=\"" << i.name << '"';
+ }
debug << ')';
}
}
@@ -2519,6 +2620,12 @@ QDebug operator<<(QDebug d, const TypeEntry *te)
return d;
}
+QDebug operator<<(QDebug d, const TypeEntryCPtr &te)
+{
+ d << te.get();
+ return d;
+}
+
QDebug operator<<(QDebug d, const TemplateEntry *te)
{
QDebugStateSaver saver(d);
@@ -2533,4 +2640,10 @@ QDebug operator<<(QDebug d, const TemplateEntry *te)
d << ')';
return d;
}
+
+QDebug operator<<(QDebug d, const TemplateEntryCPtr &te)
+{
+ d << te.get();
+ return d;
+}
#endif // QT_NO_DEBUG_STREAM