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.cpp1309
1 files changed, 873 insertions, 436 deletions
diff --git a/sources/shiboken6/ApiExtractor/typesystem.cpp b/sources/shiboken6/ApiExtractor/typesystem.cpp
index d445febfa..99d42b668 100644
--- a/sources/shiboken6/ApiExtractor/typesystem.cpp
+++ b/sources/shiboken6/ApiExtractor/typesystem.cpp
@@ -1,103 +1,92 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt for Python.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "typesystem.h"
+#include "arraytypeentry.h"
+#include "codesnip.h"
+#include "complextypeentry.h"
+#include "configurabletypeentry.h"
+#include "constantvaluetypeentry.h"
+#include "containertypeentry.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"
+#include "pythontypeentry.h"
+#include "smartpointertypeentry.h"
+#include "templateargumententry.h"
+#include "typedefentry.h"
+#include "typesystemtypeentry.h"
+#include "valuetypeentry.h"
+#include "varargstypeentry.h"
+#include "voidtypeentry.h"
+#include "abstractmetatype.h"
#include "typedatabase.h"
#include "modifications.h"
-#include "messages.h"
#include "sourcelocation.h"
+#include "qtcompat.h"
+
#include <QtCore/QDebug>
#include <QtCore/QRegularExpression>
#include <QtCore/QSet>
+#include <QtCore/QVarLengthArray>
+
+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() + QLatin1String("::") + entryName;
+ ? entryName : parent->name() + u"::"_s + entryName;
}
// Access private class as 'd', cf macro Q_D()
#define S_D(Class) auto d = static_cast<Class##Private *>(d_func())
-static const QSet<QString> &primitiveCppTypes()
-{
- static QSet<QString> result;
- if (result.isEmpty()) {
- static const char *cppTypes[] = {
- "bool", "char", "double", "float", "int",
- "long", "long long", "short",
- "wchar_t"
- };
- for (const char *cppType : cppTypes)
- result.insert(QLatin1String(cppType));
- }
- return result;
-}
-
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
- QString m_targetLangApiName;
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"
- CustomFunction m_customConstructor;
- CustomFunction m_customDestructor;
- CodeSnipList m_codeSnips;
- DocModificationList m_docModifications;
IncludeList m_extraIncludes;
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;
+ TypeEntryPtr m_viewOn;
+ CustomTypeEntryPtr m_targetLangApiType;
int m_revision = 0;
int m_sbkIndex = 0;
TypeEntry::Type m_type;
bool m_stream = false;
bool m_private = false;
+ bool m_builtin = false;
};
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),
@@ -106,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))
{
}
@@ -123,31 +107,6 @@ TypeEntry::TypeEntry(TypeEntryPrivate *d) : m_d(d)
TypeEntry::~TypeEntry() = default;
-CodeSnipList TypeEntry::codeSnips() const
-{
- 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;
@@ -174,47 +133,31 @@ void TypeEntry::setInclude(const Include &inc)
// This is a workaround for preventing double inclusion of the QSharedPointer implementation
// header, which does not use header guards. In the previous parser this was not a problem
// because the Q_QDOC define was set, and the implementation header was never included.
- if (inc.name().endsWith(QLatin1String("qsharedpointer_impl.h"))) {
+ if (inc.name().endsWith(u"qsharedpointer_impl.h")) {
QString path = inc.name();
- path.remove(QLatin1String("_impl"));
+ path.remove(u"_impl"_s);
m_d->m_include = Include(inc.type(), path);
} else {
m_d->m_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
-{
- return !m_d->m_targetConversionRule.isEmpty();
-}
-
-bool TypeEntry::isCppPrimitive() const
+bool isCppPrimitive(const TypeEntryCPtr &e)
{
- 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();
- const QString &typeName = referencedType ? referencedType->name() : m_d->m_name;
- return typeName.contains(QLatin1Char(' ')) || primitiveCppTypes().contains(typeName);
+ PrimitiveTypeEntryCPtr referencedType = basicReferencedTypeEntry(e);
+ const QString &typeName = referencedType->name();
+ return AbstractMetaType::cppPrimitiveTypes().contains(typeName);
}
TypeEntry::Type TypeEntry::type() const
@@ -222,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)
@@ -241,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();
@@ -295,6 +238,14 @@ bool TypeEntry::isSmartPointer() const
return m_d->m_type == SmartPointerType;
}
+bool TypeEntry::isUniquePointer() const
+{
+ if (m_d->m_type != SmartPointerType)
+ return false;
+ auto *ste = static_cast<const SmartPointerTypeEntry *>(this);
+ return ste->smartPointerType() == TypeSystem::SmartPointerType::Unique;
+}
+
bool TypeEntry::isArray() const
{
return m_d->m_type == ArrayType;
@@ -317,7 +268,7 @@ bool TypeEntry::isVarargs() const
bool TypeEntry::isCustom() const
{
- return m_d->m_type == CustomType;
+ return m_d->m_type == CustomType || m_d->m_type == PythonType;
}
bool TypeEntry::isTypeSystem() const
@@ -345,6 +296,16 @@ void TypeEntry::setStream(bool b)
m_d->m_stream = b;
}
+bool TypeEntry::isBuiltIn() const
+{
+ return m_d->m_builtin;
+}
+
+void TypeEntry::setBuiltIn(bool b)
+{
+ m_d->m_builtin = b;
+}
+
bool TypeEntry::isPrivate() const
{
return m_d->m_private;
@@ -365,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);
@@ -377,9 +338,9 @@ 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(QLatin1String("::"));
+ m_cachedShortName.append(u"::"_s);
}
m_cachedShortName.append(m_entryName);
} else {
@@ -414,6 +375,11 @@ bool TypeEntry::generateCode() const
return m_d->m_codeGeneration == GenerateCode;
}
+bool TypeEntry::shouldGenerate() const
+{
+ return generateCode() && NamespaceTypeEntry::isVisibleScope(this);
+}
+
int TypeEntry::revision() const
{
return m_d->m_revision;
@@ -429,15 +395,25 @@ QString TypeEntry::qualifiedCppName() const
return m_d->m_name;
}
-QString TypeEntry::targetLangApiName() const
+CustomTypeEntryCPtr TypeEntry::targetLangApiType() const
{
- return m_d->m_targetLangApiName.isEmpty()
- ? m_d->m_name : m_d->m_targetLangApiName;
+ return m_d->m_targetLangApiType;
}
-void TypeEntry::setTargetLangApiName(const QString &t)
+bool TypeEntry::hasTargetLangApiType() const
{
- m_d->m_targetLangApiName = t;
+ return m_d->m_targetLangApiType != nullptr;
+}
+
+void TypeEntry::setTargetLangApiType(const CustomTypeEntryPtr &cte)
+{
+ m_d->m_targetLangApiType = cte;
+}
+
+QString TypeEntry::targetLangApiName() const
+{
+ return m_d->m_targetLangApiType != nullptr
+ ? m_d->m_targetLangApiType->name() : m_d->m_name;
}
QString TypeEntry::targetLangName() const
@@ -458,9 +434,9 @@ QString TypeEntry::buildTargetLangName() const
for (auto p = parent(); p && p->type() != TypeEntry::TypeSystemType; p = p->parent()) {
if (NamespaceTypeEntry::isVisibleScope(p)) {
if (!result.isEmpty())
- result.prepend(QLatin1Char('.'));
+ result.prepend(u'.');
QString n = p->m_d->m_entryName;
- n.replace(QLatin1String("::"), QLatin1String(".")); // Primitive types may have "std::"
+ n.replace(u"::"_s, u"."_s); // Primitive types may have "std::"
result.prepend(n);
}
}
@@ -489,15 +465,13 @@ void TypeEntry::setSourceLocation(const SourceLocation &sourceLocation)
m_d->m_sourceLocation = sourceLocation;
}
-bool TypeEntry::isUserPrimitive() const
+bool isUserPrimitive(const TypeEntryCPtr &e)
{
- if (!isPrimitive())
+ if (!e->isPrimitive())
return false;
- const auto *trueType = static_cast<const PrimitiveTypeEntry *>(this);
- if (trueType->basicReferencedTypeEntry())
- trueType = trueType->basicReferencedTypeEntry();
- return trueType->isPrimitive() && !trueType->isCppPrimitive()
- && trueType->qualifiedCppName() != u"std::string";
+ const auto type = basicReferencedTypeEntry(e);
+ return !isCppPrimitive(type)
+ && type->qualifiedCppName() != u"std::string";
}
bool TypeEntry::isWrapperType() const
@@ -505,29 +479,23 @@ 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 *trueType = static_cast<const PrimitiveTypeEntry *>(this);
- if (trueType->basicReferencedTypeEntry())
- trueType = trueType->basicReferencedTypeEntry();
- QString typeName = trueType->qualifiedCppName();
- return !typeName.contains(u"double")
- && !typeName.contains(u"float")
- && !typeName.contains(u"wchar");
+ 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 *trueType = static_cast<const PrimitiveTypeEntry *>(this);
- if (trueType->basicReferencedTypeEntry())
- trueType = trueType->basicReferencedTypeEntry();
- return trueType->qualifiedCppName() == u"std::string";
+ const auto type = basicReferencedTypeEntry(e);
+ const QString &name = type->qualifiedCppName();
+ return name == u"std::string" || name == u"std::wstring";
}
const TypeEntryPrivate *TypeEntry::d_func() const
@@ -544,7 +512,7 @@ QString TypeEntry::targetLangEntryName() const
{
if (m_d->m_cachedTargetLangEntryName.isEmpty()) {
m_d->m_cachedTargetLangEntryName = targetLangName();
- const int lastDot = m_d->m_cachedTargetLangEntryName.lastIndexOf(QLatin1Char('.'));
+ const int lastDot = m_d->m_cachedTargetLangEntryName.lastIndexOf(u'.');
if (lastDot != -1)
m_d->m_cachedTargetLangEntryName.remove(0, lastDot + 1);
}
@@ -563,27 +531,7 @@ void TypeEntry::setTargetLangPackage(const QString &p)
QString TypeEntry::qualifiedTargetLangName() const
{
- return targetLangPackage() + QLatin1Char('.') + targetLangName();
-}
-
-void TypeEntry::setCustomConstructor(const CustomFunction &func)
-{
- m_d->m_customConstructor = func;
-}
-
-CustomFunction TypeEntry::customConstructor() const
-{
- return m_d->m_customConstructor;
-}
-
-void TypeEntry::setCustomDestructor(const CustomFunction &func)
-{
- m_d->m_customDestructor = func;
-}
-
-CustomFunction TypeEntry::customDestructor() const
-{
- return m_d->m_customDestructor;
+ return targetLangPackage() + u'.' + targetLangName();
}
bool TypeEntry::isValue() const
@@ -596,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;
}
@@ -627,13 +560,15 @@ 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;
+ m_d->m_cachedTargetLangName.clear(); // Clear cached names.
+ m_d->m_cachedTargetLangEntryName.clear();
m_d->m_codeGeneration = source->m_d->m_codeGeneration;
m_d->m_version = source->m_d->m_version;
}
@@ -648,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))
{
}
@@ -664,6 +599,12 @@ TypeEntry *CustomTypeEntry::clone() const
return new CustomTypeEntry(new CustomTypeEntryPrivate(*d));
}
+bool CustomTypeEntry::hasCheckFunction() const
+{
+ S_D(const CustomTypeEntry);
+ return !d->m_checkFunction.isEmpty();
+}
+
QString CustomTypeEntry::checkFunction() const
{
S_D(const CustomTypeEntry);
@@ -676,17 +617,62 @@ void CustomTypeEntry::setCheckFunction(const QString &f)
d->m_checkFunction = f;
}
+// ----------------- PythonTypeEntry
+class PythonTypeEntryPrivate : public CustomTypeEntryPrivate
+{
+public:
+ using CustomTypeEntryPrivate::CustomTypeEntryPrivate;
+ explicit PythonTypeEntryPrivate(const QString &entryName,
+ const QString &checkFunction,
+ TypeSystem::CPythonType type) :
+ CustomTypeEntryPrivate(entryName, TypeEntry::PythonType, {}, {}),
+ m_cPythonType(type)
+ {
+ m_checkFunction = checkFunction;
+ }
+
+ TypeSystem::CPythonType m_cPythonType;
+};
+
+PythonTypeEntry::PythonTypeEntry(const QString &entryName,
+ const QString &checkFunction,
+ TypeSystem::CPythonType type) :
+ CustomTypeEntry(new PythonTypeEntryPrivate(entryName, checkFunction, type))
+{
+}
+
+TypeEntry *PythonTypeEntry::clone() const
+{
+ S_D(const PythonTypeEntry);
+ return new PythonTypeEntry(new PythonTypeEntryPrivate(*d));
+}
+
+TypeSystem::CPythonType PythonTypeEntry::cPythonType() const
+{
+ S_D(const PythonTypeEntry);
+ return d->m_cPythonType;
+}
+
+PythonTypeEntry::PythonTypeEntry(TypeEntryPrivate *d) :
+ CustomTypeEntry(d)
+{
+}
+
// ----------------- TypeSystemTypeEntry
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))
{
}
@@ -702,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);
@@ -716,7 +756,7 @@ void TypeSystemTypeEntry::setSnakeCase(TypeSystem::SnakeCase sc)
// ----------------- VoidTypeEntry
VoidTypeEntry::VoidTypeEntry() :
- TypeEntry(QLatin1String("void"), VoidType, QVersionNumber(0, 0), nullptr)
+ TypeEntry(u"void"_s, VoidType, QVersionNumber(0, 0), nullptr)
{
}
@@ -731,7 +771,7 @@ TypeEntry *VoidTypeEntry::clone() const
}
VarargsTypeEntry::VarargsTypeEntry() :
- TypeEntry(QLatin1String("..."), VarargsType, QVersionNumber(0, 0), nullptr)
+ TypeEntry(u"..."_s, VarargsType, QVersionNumber(0, 0), nullptr)
{
}
@@ -756,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))
{
}
@@ -788,30 +828,30 @@ TemplateArgumentEntry::TemplateArgumentEntry(TemplateArgumentEntryPrivate *d) :
class ArrayTypeEntryPrivate : public TypeEntryPrivate
{
public:
- explicit ArrayTypeEntryPrivate(const TypeEntry *nested_type, const QVersionNumber &vr,
- const TypeEntry *parent) :
- TypeEntryPrivate(QLatin1String("Array"), TypeEntry::ArrayType, vr, 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;
@@ -820,7 +860,7 @@ const TypeEntry *ArrayTypeEntry::nestedTypeEntry() const
QString ArrayTypeEntry::buildTargetLangName() const
{
S_D(const ArrayTypeEntry);
- return d->m_nestedType->targetLangName() + QLatin1String("[]");
+ return d->m_nestedType->targetLangName() + u"[]"_s;
}
TypeEntry *ArrayTypeEntry::clone() const
@@ -839,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))
{
}
@@ -874,26 +915,46 @@ 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;
}
-PrimitiveTypeEntry *PrimitiveTypeEntry::basicReferencedTypeEntry() const
+PrimitiveTypeEntryCPtr basicReferencedTypeEntry(const PrimitiveTypeEntryCPtr &e)
{
- S_D(const PrimitiveTypeEntry);
- if (!d->m_referencedTypeEntry)
- return nullptr;
+ auto result = e;
+ while (auto referenced = result->referencedTypeEntry())
+ result = referenced;
+ return result;
+}
- PrimitiveTypeEntry *baseReferencedTypeEntry = d->m_referencedTypeEntry->basicReferencedTypeEntry();
- return baseReferencedTypeEntry ? baseReferencedTypeEntry : d->m_referencedTypeEntry;
+PrimitiveTypeEntryCPtr basicReferencedTypeEntry(const TypeEntryCPtr &e)
+{
+ 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;
+ }
+ return result;
+}
+
+bool PrimitiveTypeEntry::referencesType() const
+{
+ S_D(const PrimitiveTypeEntry);
+ return d->m_referencedTypeEntry != nullptr;
}
bool PrimitiveTypeEntry::preferredTargetLangType() const
@@ -908,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);
@@ -919,22 +998,85 @@ 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
@@ -954,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);
@@ -996,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);
@@ -1003,7 +1169,7 @@ TypeEntry *EnumTypeEntry::clone() const
}
EnumTypeEntry::EnumTypeEntry(EnumTypeEntryPrivate *d) :
- TypeEntry(d)
+ ConfigurableTypeEntry(d)
{
}
@@ -1012,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,
@@ -1023,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))
@@ -1040,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;
@@ -1065,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))
{
}
@@ -1078,7 +1244,7 @@ QString FlagsTypeEntry::buildTargetLangName() const
{
S_D(const FlagsTypeEntry);
QString on = d->m_originalName;
- on.replace(QLatin1String("::"), QLatin1String("."));
+ on.replace(u"::"_s, u"."_s);
return on;
}
@@ -1111,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;
@@ -1131,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)
{
}
@@ -1142,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),
@@ -1158,8 +1324,14 @@ 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;
+ QList<TypeSystemPyMethodDefEntry> m_PyMethodDefEntrys;
QString m_defaultConstructor;
QString m_defaultSuperclass;
QString m_qualifiedCppName;
@@ -1169,24 +1341,29 @@ public:
uint m_deleteInMainThread : 1;
QString m_polymorphicIdValue;
+ QString m_polymorphicNameFunction;
QString m_targetType;
ComplexTypeEntry::TypeFlags m_typeFlags;
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;
TypeSystem::SnakeCase m_snakeCase = TypeSystem::SnakeCase::Unspecified;
TypeSystem::BoolCast m_operatorBoolMode = TypeSystem::BoolCast::Unspecified;
TypeSystem::BoolCast m_isNullMode = TypeSystem::BoolCast::Unspecified;
+ TypeSystem::QtMetaTypeRegistration m_qtMetaTypeRegistration =
+ TypeSystem::QtMetaTypeRegistration::Unspecified;
+ // Determined by AbstractMetaBuilder from the code model.
+ bool m_isValueTypeWithCopyConstructorOnly = false;
};
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))
{
}
@@ -1249,18 +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 (int i = 0; i < d->m_functionMods.count(); ++i) {
- const FunctionModification &mod = d->m_functionMods.at(i);
- if (mod.matches(signature))
+ for (const auto &mod : std::as_const(d->m_functionMods)) {
+ 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);
@@ -1279,6 +1515,30 @@ void ComplexTypeEntry::addNewFunction(const AddedFunctionPtr &addedFunction)
d->m_addedFunctions << addedFunction;
}
+const QList<TypeSystemPyMethodDefEntry> &ComplexTypeEntry::addedPyMethodDefEntrys() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_PyMethodDefEntrys;
+}
+
+void ComplexTypeEntry::addPyMethodDef(const TypeSystemPyMethodDefEntry &p)
+{
+ S_D(ComplexTypeEntry);
+ d->m_PyMethodDefEntrys.append(p);
+}
+
+const QSet<QString> &ComplexTypeEntry::generateFunctions() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_generateFunctions;
+}
+
+void ComplexTypeEntry::setGenerateFunctions(const QSet<QString> &f)
+{
+ S_D(ComplexTypeEntry);
+ d->m_generateFunctions = f;
+}
+
void ComplexTypeEntry::setFieldModifications(const FieldModificationList &mods)
{
S_D(ComplexTypeEntry);
@@ -1345,6 +1605,18 @@ QString ComplexTypeEntry::polymorphicIdValue() const
return d->m_polymorphicIdValue;
}
+QString ComplexTypeEntry::polymorphicNameFunction() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_polymorphicNameFunction;
+}
+
+void ComplexTypeEntry::setPolymorphicNameFunction(const QString &n)
+{
+ S_D(ComplexTypeEntry);
+ d->m_polymorphicNameFunction = n;
+}
+
QString ComplexTypeEntry::targetType() const
{
S_D(const ComplexTypeEntry);
@@ -1393,6 +1665,18 @@ void ComplexTypeEntry::setCopyable(ComplexTypeEntry::CopyableFlag flag)
d->m_copyableFlag = flag;
}
+TypeSystem::QtMetaTypeRegistration ComplexTypeEntry::qtMetaTypeRegistration() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_qtMetaTypeRegistration;
+}
+
+void ComplexTypeEntry::setQtMetaTypeRegistration(TypeSystem::QtMetaTypeRegistration r)
+{
+ S_D(ComplexTypeEntry);
+ d->m_qtMetaTypeRegistration = r;
+}
+
QString ComplexTypeEntry::hashFunction() const
{
S_D(const ComplexTypeEntry);
@@ -1405,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;
@@ -1471,6 +1755,31 @@ void ComplexTypeEntry::setSnakeCase(TypeSystem::SnakeCase sc)
d->m_snakeCase = sc;
}
+bool ComplexTypeEntry::isValueTypeWithCopyConstructorOnly() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_isValueTypeWithCopyConstructorOnly;
+}
+
+void ComplexTypeEntry::setValueTypeWithCopyConstructorOnly(bool v)
+{
+ S_D(ComplexTypeEntry);
+ d->m_isValueTypeWithCopyConstructorOnly = v;
+}
+
+// FIXME PYSIDE 7: Remove this and make "true" the default
+static bool parentManagementEnabled = false;
+
+bool ComplexTypeEntry::isParentManagementEnabled()
+{
+ return parentManagementEnabled;
+}
+
+void ComplexTypeEntry::setParentManagementEnabled(bool e)
+{
+ parentManagementEnabled = e;
+}
+
TypeEntry *ComplexTypeEntry::clone() const
{
S_D(const ComplexTypeEntry);
@@ -1478,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)
{
}
@@ -1506,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)
@@ -1514,12 +1824,12 @@ public:
}
QString m_sourceType;
- 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))
{
}
@@ -1542,25 +1852,25 @@ TypeEntry *TypedefEntry::clone() const
return new TypedefEntry(new TypedefEntryPrivate(*d));
}
-ComplexTypeEntry *TypedefEntry::source() const
+ComplexTypeEntryCPtr TypedefEntry::source() const
{
S_D(const TypedefEntry);
return d->m_source;
}
-void TypedefEntry::setSource(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;
@@ -1578,18 +1888,41 @@ public:
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 QStringList &instantiations) const
+ {
+ return std::find_if(m_opaqueContainers.cbegin(), m_opaqueContainers.cend(),
+ [&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);
@@ -1601,6 +1934,67 @@ ContainerTypeEntry::ContainerKind ContainerTypeEntry::containerKind() const
return d->m_containerKind;
}
+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::appendOpaqueContainers(const OpaqueContainers &l)
+{
+ S_D(ContainerTypeEntry);
+ d->m_opaqueContainers.append(l);
+}
+
+bool ContainerTypeEntry::generateOpaqueContainer(const QStringList &instantiations) const
+{
+ S_D(const ContainerTypeEntry);
+ return d->findOpaqueContainer(instantiations) != d->m_opaqueContainers.cend();
+}
+
+QString ContainerTypeEntry::opaqueContainerName(const QStringList &instantiations) const
+{
+ S_D(const ContainerTypeEntry);
+ 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);
@@ -1618,32 +2012,53 @@ class SmartPointerTypeEntryPrivate : public ComplexTypeEntryPrivate
public:
SmartPointerTypeEntryPrivate(const QString &entryName,
const QString &getterName,
- const QString &smartPointerType,
+ 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_smartPointerType(smartPointerType),
- m_refCountMethodName(refCountMethodName)
+ m_refCountMethodName(refCountMethodName),
+ m_smartPointerType(type)
{
}
+ qsizetype instantiationIndex(const TypeEntryCPtr &t) const;
+
QString m_getterName;
- QString m_smartPointerType;
QString m_refCountMethodName;
+ QString m_valueCheckMethod;
+ QString m_nullCheckMethod;
+ QString m_resetMethod;
SmartPointerTypeEntry::Instantiations m_instantiations;
+ 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,
- const QString &smartPointerType,
+ 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))
{
}
+TypeSystem::SmartPointerType SmartPointerTypeEntry::smartPointerType() const
+{
+ S_D(const SmartPointerTypeEntry);
+ return d->m_smartPointerType;
+}
+
QString SmartPointerTypeEntry::getter() const
{
S_D(const SmartPointerTypeEntry);
@@ -1656,13 +2071,49 @@ QString SmartPointerTypeEntry::refCountMethodName() const
return d->m_refCountMethodName;
}
+QString SmartPointerTypeEntry::valueCheckMethod() const
+{
+ S_D(const SmartPointerTypeEntry);
+ return d->m_valueCheckMethod;
+}
+
+void SmartPointerTypeEntry::setValueCheckMethod(const QString &m)
+{
+ S_D(SmartPointerTypeEntry);
+ d->m_valueCheckMethod = m;
+}
+
+QString SmartPointerTypeEntry::nullCheckMethod() const
+{
+ S_D(const SmartPointerTypeEntry);
+ return d->m_nullCheckMethod;
+}
+
+void SmartPointerTypeEntry::setNullCheckMethod(const QString &f)
+{
+ S_D(SmartPointerTypeEntry);
+ d->m_nullCheckMethod = f;
+}
+
+QString SmartPointerTypeEntry::resetMethod() const
+{
+ S_D(const SmartPointerTypeEntry);
+ return d->m_resetMethod;
+}
+
+void SmartPointerTypeEntry::setResetMethod(const QString &f)
+{
+ S_D(SmartPointerTypeEntry);
+ d->m_resetMethod = f;
+}
+
TypeEntry *SmartPointerTypeEntry::clone() const
{
S_D(const SmartPointerTypeEntry);
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;
@@ -1679,10 +2130,38 @@ SmartPointerTypeEntry::SmartPointerTypeEntry(SmartPointerTypeEntryPrivate *d) :
{
}
-bool SmartPointerTypeEntry::matchesInstantiation(const TypeEntry *e) const
+bool SmartPointerTypeEntry::matchesInstantiation(const TypeEntryCPtr &e) const
+{
+ S_D(const SmartPointerTypeEntry);
+ // No instantiations specified, or match
+ return d->m_instantiations.isEmpty() || d->instantiationIndex(e) != -1;
+}
+
+static QString fixSmartPointerName(QString name)
+{
+ name.replace(u"::"_s, u"_"_s);
+ name.replace(u'<', u'_');
+ name.remove(u'>');
+ name.remove(u' ');
+ return name;
+}
+
+QString SmartPointerTypeEntry::getTargetName(const AbstractMetaType &metaType) const
{
S_D(const SmartPointerTypeEntry);
- return d->m_instantiations.isEmpty() || d->m_instantiations.contains(e);
+ 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 name = metaType.cppSignature();
+ const auto templatePos = name.indexOf(u'<');
+ if (templatePos != -1) { // "std::shared_ptr<A::B>" -> "shared_ptr<A::B>"
+ const auto colonPos = name.lastIndexOf(u"::"_s, templatePos);
+ if (colonPos != -1)
+ name.remove(0, colonPos + 2);
+ }
+ return fixSmartPointerName(name);
}
// ----------------- NamespaceTypeEntry
@@ -1692,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;
@@ -1700,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))
{
}
@@ -1711,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;
@@ -1780,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
@@ -1799,167 +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
-{
- 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
+class ValueTypeEntryPrivate : public ComplexTypeEntryPrivate
{
- 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()
-{
- return m_d->targetToNativeConversions;
-}
-
-const CustomConversion::TargetToNativeConversions& CustomConversion::targetToNativeConversions() const
+ValueTypeEntry::ValueTypeEntry(const QString &entryName, const QVersionNumber &vr,
+ const TypeEntryCPtr &parent) :
+ ComplexTypeEntry(new ValueTypeEntryPrivate(entryName, BasicValueType, vr, parent))
{
- return m_d->targetToNativeConversions;
}
-void CustomConversion::addTargetToNativeConversion(const QString& sourceTypeName,
- const QString& sourceTypeCheck,
- const QString& conversion)
+bool ValueTypeEntry::hasCustomConversion() const
{
- m_d->targetToNativeConversions.append(new TargetToNativeConversion(sourceTypeName, sourceTypeCheck, conversion));
+ S_D(const ValueTypeEntry);
+ return bool(d->m_customConversion);
}
-CustomConversion::TargetToNativeConversion::TargetToNativeConversion(const QString& sourceTypeName,
- const QString& sourceTypeCheck,
- const QString& conversion)
+void ValueTypeEntry::setCustomConversion(const CustomConversionPtr &customConversion)
{
- m_d = new TargetToNativeConversionPrivate;
- m_d->sourceTypeName = sourceTypeName;
- m_d->sourceTypeCheck = sourceTypeCheck;
- m_d->conversion = conversion;
+ S_D(ValueTypeEntry);
+ d->m_customConversion = customConversion;
}
-CustomConversion::TargetToNativeConversion::~TargetToNativeConversion()
+CustomConversionPtr ValueTypeEntry::customConversion() const
{
- delete m_d;
+ S_D(const ValueTypeEntry);
+ return d->m_customConversion;
}
-const TypeEntry* CustomConversion::TargetToNativeConversion::sourceType() const
+void ValueTypeEntry::setTargetConversionRule(const QString &conversionRule)
{
- return m_d->sourceType;
+ S_D(ValueTypeEntry);
+ d->m_targetConversionRule = conversionRule;
}
-void CustomConversion::TargetToNativeConversion::setSourceType(const TypeEntry* sourceType)
+QString ValueTypeEntry::targetConversionRule() const
{
- m_d->sourceType = sourceType;
+ S_D(const ValueTypeEntry);
+ return d->m_targetConversionRule;
}
-bool CustomConversion::TargetToNativeConversion::isCustomType() const
+bool ValueTypeEntry::hasTargetConversionRule() const
{
- return !(m_d->sourceType);
+ S_D(const ValueTypeEntry);
+ return !d->m_targetConversionRule.isEmpty();
}
-QString CustomConversion::TargetToNativeConversion::sourceTypeName() const
+bool ValueTypeEntry::isValue() const
{
- return m_d->sourceTypeName;
+ return true;
}
-QString CustomConversion::TargetToNativeConversion::sourceTypeCheck() const
+TypeEntry *ValueTypeEntry::clone() const
{
- return m_d->sourceTypeCheck;
+ S_D(const ValueTypeEntry);
+ return new ValueTypeEntry(new ValueTypeEntryPrivate(*d));
}
-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
@@ -1968,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))
{
}
@@ -2003,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
@@ -2028,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)
{
}
@@ -2058,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();
@@ -2079,11 +2460,13 @@ void TypeEntry::formatDebug(QDebug &debug) const
if (m_d->m_name != cppName)
debug << "\", cppName=\"" << cppName << '"';
debug << ", type=" << m_d->m_type << ", codeGeneration="
- << m_d->m_codeGeneration << ", target=\"" << targetLangName() << '"';
+ << m_d->m_codeGeneration;
+ const QString &targetName = targetLangName();
+ if (m_d->m_name != targetName)
+ debug << ", target=\"" << targetLangName() << '"';
FORMAT_NONEMPTY_STRING("package", m_d->m_targetLangPackage)
FORMAT_BOOL("stream", m_d->m_stream)
- FORMAT_LIST_SIZE("codeSnips", m_d->m_codeSnips)
- FORMAT_NONEMPTY_STRING("targetConversionRule", m_d->m_targetConversionRule)
+ FORMAT_BOOL("built-in", m_d->m_builtin)
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))
@@ -2099,6 +2482,16 @@ void TypeEntry::formatDebug(QDebug &debug) const
formatList(debug, "extraIncludes", m_d->m_extraIncludes, ", ");
}
+void PrimitiveTypeEntry::formatDebug(QDebug &debug) const
+{
+ TypeEntry::formatDebug(debug);
+ if (auto e = referencedTypeEntry()) {
+ debug << ", references";
+ for (; e ; e = e->referencedTypeEntry())
+ debug << ":\"" << e->qualifiedCppName() <<'"';
+ }
+}
+
void ComplexTypeEntry::formatDebug(QDebug &debug) const
{
S_D(const ComplexTypeEntry);
@@ -2118,16 +2511,31 @@ 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)
}
+void CustomTypeEntry::formatDebug(QDebug &debug) const
+{
+ S_D(const CustomTypeEntry);
+ TypeEntry::formatDebug(debug);
+ debug << ", checkFunction=" << d->m_checkFunction;
+}
+
+void PythonTypeEntry::formatDebug(QDebug &debug) const
+{
+ S_D(const PythonTypeEntry);
+
+ CustomTypeEntry::formatDebug(debug);
+ debug << ", type=" << int(d->m_cPythonType);
+}
+
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
@@ -2144,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 << ')';
}
@@ -2160,12 +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=[" << d->m_opaqueContainers << ']';
}
void SmartPointerTypeEntry::formatDebug(QDebug &debug) const
@@ -2174,9 +2595,13 @@ void SmartPointerTypeEntry::formatDebug(QDebug &debug) const
ComplexTypeEntry::formatDebug(debug);
if (!d->m_instantiations.isEmpty()) {
- debug << ", instantiations[" << d->m_instantiations.size() << "]=(";
- for (auto i : d->m_instantiations)
- debug << i->name() << ',';
+ debug << "type=" << d->m_type << ", instantiations["
+ << d->m_instantiations.size() << "]=(";
+ for (const auto &i : d->m_instantiations) {
+ debug << i.typeEntry->name() << ',';
+ if (!i.name.isEmpty())
+ debug << "=\"" << i.name << '"';
+ }
debug << ')';
}
}
@@ -2195,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);
@@ -2209,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