aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-11-09 11:35:42 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-11-10 09:17:46 +0000
commit3464f53cb98cbd70a4e46a5c2f4c59a0c8cb16a0 (patch)
tree5b7f03db1a5a614b5894d163eeb42cff48cb8cc4
parent2f9ad6283b888495a8536cccf6fdad7d85dd78b0 (diff)
shiboken6: Introduce a private class hierarchy for TypeEntry
Move the data members of the TypeEntry classes to private classes, using convenience macros modeled after Qt's Q_D macro. The main motivation here is header hygiene and decoupling; typesystem.h was including a lot of classes. This requires moving some code around: - Move the debug formatting helpers of the TypeEntry classes from typedatabase.cpp to typesystem.cpp. - Move struct TypeRejection to typedatabase.h - Reorder typesystem.cpp in order of declaration. Change-Id: I24fe501d98940afd44caf75057cd6131cfbd6b6e Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp1
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h3
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetaenum.cpp2
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetafunction.cpp1
-rw-r--r--sources/shiboken6/ApiExtractor/abstractmetalang.cpp1
-rw-r--r--sources/shiboken6/ApiExtractor/docparser.cpp1
-rw-r--r--sources/shiboken6/ApiExtractor/doxygenparser.cpp1
-rw-r--r--sources/shiboken6/ApiExtractor/messages.cpp1
-rw-r--r--sources/shiboken6/ApiExtractor/qtdocparser.cpp1
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp1
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp1
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testfunctiontag.cpp1
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testinserttemplate.cpp1
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testmodifydocumentation.cpp1
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testmodifyfunction.cpp1
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testnestedtypes.cpp1
-rw-r--r--sources/shiboken6/ApiExtractor/tests/testrefcounttag.cpp2
-rw-r--r--sources/shiboken6/ApiExtractor/typedatabase.cpp161
-rw-r--r--sources/shiboken6/ApiExtractor/typedatabase.h22
-rw-r--r--sources/shiboken6/ApiExtractor/typesystem.cpp1850
-rw-r--r--sources/shiboken6/ApiExtractor/typesystem.h785
-rw-r--r--sources/shiboken6/ApiExtractor/typesystemparser.cpp3
-rw-r--r--sources/shiboken6/ApiExtractor/typesystemparser.h2
-rw-r--r--sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp1
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp1
-rw-r--r--sources/shiboken6/generator/shiboken/headergenerator.cpp1
-rw-r--r--sources/shiboken6/generator/shiboken/shibokengenerator.cpp1
-rw-r--r--sources/shiboken6/tests/dumpcodemodel/main.cpp1
28 files changed, 1829 insertions, 1020 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp
index 96316b128..9324ac56f 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp
@@ -34,6 +34,7 @@
#include "propertyspec.h"
#include "reporthandler.h"
#include "typedatabase.h"
+#include "typesystem.h"
#include <clangparser/clangbuilder.h>
#include <clangparser/clangutils.h>
diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h b/sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h
index 7792eb0fc..eb6f31c70 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h
+++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h
@@ -33,7 +33,8 @@
#include "parser/codemodel_fwd.h"
#include "abstractmetalang.h"
#include "abstractmetatype.h"
-#include "typesystem.h"
+#include "include.h"
+#include "modifications.h"
#include "typeparser.h"
#include <QSet>
diff --git a/sources/shiboken6/ApiExtractor/abstractmetaenum.cpp b/sources/shiboken6/ApiExtractor/abstractmetaenum.cpp
index 21fa13a29..5075836d3 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetaenum.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetaenum.cpp
@@ -29,6 +29,8 @@
#include "abstractmetaenum.h"
#include "typesystem.h"
+#include <QtCore/QDebug>
+
AbstractMetaEnum::AbstractMetaEnum() :
m_hasQenumsDeclaration(false), m_signed(true)
{
diff --git a/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp b/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp
index f295caa89..795f30bf9 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetafunction.cpp
@@ -30,6 +30,7 @@
#include "abstractmetalang.h"
#include "abstractmetalang_helpers.h"
#include "messages.h"
+#include "modifications.h"
#include "propertyspec.h"
#include "reporthandler.h"
#include "typedatabase.h"
diff --git a/sources/shiboken6/ApiExtractor/abstractmetalang.cpp b/sources/shiboken6/ApiExtractor/abstractmetalang.cpp
index 74075bd4a..16bf03e11 100644
--- a/sources/shiboken6/ApiExtractor/abstractmetalang.cpp
+++ b/sources/shiboken6/ApiExtractor/abstractmetalang.cpp
@@ -31,6 +31,7 @@
#include "abstractmetaenum.h"
#include "abstractmetafunction.h"
#include "abstractmetafield.h"
+#include "modifications.h"
#include "propertyspec.h"
#include "reporthandler.h"
#include "typedatabase.h"
diff --git a/sources/shiboken6/ApiExtractor/docparser.cpp b/sources/shiboken6/ApiExtractor/docparser.cpp
index 295df5040..52afbfb84 100644
--- a/sources/shiboken6/ApiExtractor/docparser.cpp
+++ b/sources/shiboken6/ApiExtractor/docparser.cpp
@@ -31,6 +31,7 @@
#include "abstractmetafunction.h"
#include "abstractmetalang.h"
#include "messages.h"
+#include "modifications.h"
#include "reporthandler.h"
#include "typesystem.h"
#include "xmlutils.h"
diff --git a/sources/shiboken6/ApiExtractor/doxygenparser.cpp b/sources/shiboken6/ApiExtractor/doxygenparser.cpp
index f6ffd3670..b835b7c55 100644
--- a/sources/shiboken6/ApiExtractor/doxygenparser.cpp
+++ b/sources/shiboken6/ApiExtractor/doxygenparser.cpp
@@ -32,6 +32,7 @@
#include "abstractmetafunction.h"
#include "abstractmetaenum.h"
#include "messages.h"
+#include "modifications.h"
#include "propertyspec.h"
#include "reporthandler.h"
#include "typesystem.h"
diff --git a/sources/shiboken6/ApiExtractor/messages.cpp b/sources/shiboken6/ApiExtractor/messages.cpp
index aca801d53..f81f58623 100644
--- a/sources/shiboken6/ApiExtractor/messages.cpp
+++ b/sources/shiboken6/ApiExtractor/messages.cpp
@@ -31,6 +31,7 @@
#include "abstractmetafield.h"
#include "abstractmetafunction.h"
#include "abstractmetalang.h"
+#include "modifications.h"
#include "sourcelocation.h"
#include "typedatabase.h"
#include "typesystem.h"
diff --git a/sources/shiboken6/ApiExtractor/qtdocparser.cpp b/sources/shiboken6/ApiExtractor/qtdocparser.cpp
index 9cc9f15e4..0df8fff4a 100644
--- a/sources/shiboken6/ApiExtractor/qtdocparser.cpp
+++ b/sources/shiboken6/ApiExtractor/qtdocparser.cpp
@@ -31,6 +31,7 @@
#include "abstractmetafield.h"
#include "abstractmetafunction.h"
#include "abstractmetalang.h"
+#include "modifications.h"
#include "messages.h"
#include "propertyspec.h"
#include "reporthandler.h"
diff --git a/sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp b/sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp
index 20ca3ae6f..fde5b3dfb 100644
--- a/sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testaddfunction.cpp
@@ -31,6 +31,7 @@
#include "testutil.h"
#include <abstractmetafunction.h>
#include <abstractmetalang.h>
+#include <modifications.h>
#include <modifications_p.h>
#include <typesystem.h>
diff --git a/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp b/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp
index eed35552e..2978bc34c 100644
--- a/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testcodeinjection.cpp
@@ -32,6 +32,7 @@
#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetalang.h>
+#include <modifications.h>
#include <typesystem.h>
void TestCodeInjections::testReadFile_data()
diff --git a/sources/shiboken6/ApiExtractor/tests/testfunctiontag.cpp b/sources/shiboken6/ApiExtractor/tests/testfunctiontag.cpp
index 6faf2db89..593561869 100644
--- a/sources/shiboken6/ApiExtractor/tests/testfunctiontag.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testfunctiontag.cpp
@@ -30,6 +30,7 @@
#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetafunction.h>
+#include <modifications.h>
#include <typesystem.h>
void TestFunctionTag::testFunctionTagForSpecificSignature()
diff --git a/sources/shiboken6/ApiExtractor/tests/testinserttemplate.cpp b/sources/shiboken6/ApiExtractor/tests/testinserttemplate.cpp
index 13cbaf2d8..fda6614f0 100644
--- a/sources/shiboken6/ApiExtractor/tests/testinserttemplate.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testinserttemplate.cpp
@@ -30,6 +30,7 @@
#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetalang.h>
+#include <modifications.h>
#include <typesystem.h>
void TestInsertTemplate::testInsertTemplateOnClassInjectCode()
diff --git a/sources/shiboken6/ApiExtractor/tests/testmodifydocumentation.cpp b/sources/shiboken6/ApiExtractor/tests/testmodifydocumentation.cpp
index 6acac41d5..59c062f8c 100644
--- a/sources/shiboken6/ApiExtractor/tests/testmodifydocumentation.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testmodifydocumentation.cpp
@@ -33,6 +33,7 @@
#include <QtTest/QTest>
#include "testutil.h"
#include <abstractmetalang.h>
+#include <modifications.h>
#include <typesystem.h>
#include <qtdocparser.h>
diff --git a/sources/shiboken6/ApiExtractor/tests/testmodifyfunction.cpp b/sources/shiboken6/ApiExtractor/tests/testmodifyfunction.cpp
index 99e33b81c..c1a3b3e71 100644
--- a/sources/shiboken6/ApiExtractor/tests/testmodifyfunction.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testmodifyfunction.cpp
@@ -31,6 +31,7 @@
#include "testutil.h"
#include <abstractmetafunction.h>
#include <abstractmetalang.h>
+#include <modifications.h>
#include <typesystem.h>
void TestModifyFunction::testRenameArgument_data()
diff --git a/sources/shiboken6/ApiExtractor/tests/testnestedtypes.cpp b/sources/shiboken6/ApiExtractor/tests/testnestedtypes.cpp
index defdc1b0e..d26cb341c 100644
--- a/sources/shiboken6/ApiExtractor/tests/testnestedtypes.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testnestedtypes.cpp
@@ -31,6 +31,7 @@
#include "testutil.h"
#include <abstractmetafunction.h>
#include <abstractmetalang.h>
+#include <modifications.h>
#include <typesystem.h>
void TestNestedTypes::testNestedTypesModifications()
diff --git a/sources/shiboken6/ApiExtractor/tests/testrefcounttag.cpp b/sources/shiboken6/ApiExtractor/tests/testrefcounttag.cpp
index c13acbaeb..ecf7f3f93 100644
--- a/sources/shiboken6/ApiExtractor/tests/testrefcounttag.cpp
+++ b/sources/shiboken6/ApiExtractor/tests/testrefcounttag.cpp
@@ -31,7 +31,7 @@
#include "testutil.h"
#include <abstractmetafunction.h>
#include <abstractmetalang.h>
-#include <typesystem.h>
+#include <modifications.h>
void TestRefCountTag::testReferenceCountTag()
{
diff --git a/sources/shiboken6/ApiExtractor/typedatabase.cpp b/sources/shiboken6/ApiExtractor/typedatabase.cpp
index 6b56d362e..1560c4183 100644
--- a/sources/shiboken6/ApiExtractor/typedatabase.cpp
+++ b/sources/shiboken6/ApiExtractor/typedatabase.cpp
@@ -763,48 +763,17 @@ static void _computeTypeIndexes()
computeTypeIndexes = false;
}
-// Build the C++ name excluding any inline namespaces
-// ("std::__1::shared_ptr" -> "std::shared_ptr"
-QString TypeEntry::shortName() const
-{
- if (m_cachedShortName.isEmpty()) {
- QVarLengthArray<const TypeEntry *> 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()) {
- foundInlineNamespace = true;
- } else {
- parents.append(p);
- }
- }
- if (foundInlineNamespace) {
- m_cachedShortName.reserve(m_name.size());
- for (int i = parents.size() - 1; i >= 0; --i) {
- m_cachedShortName.append(parents.at(i)->entryName());
- m_cachedShortName.append(QLatin1String("::"));
- }
- m_cachedShortName.append(m_entryName);
- } else {
- m_cachedShortName = m_name;
- }
- }
- return m_cachedShortName;
-}
-
void TypeEntry::setRevision(int r)
{
- if (m_revision != r) {
- m_revision = r;
+ if (setRevisionHelper(r))
computeTypeIndexes = true;
- }
}
int TypeEntry::sbkIndex() const
{
if (computeTypeIndexes)
_computeTypeIndexes();
- return m_sbkIndex;
+ return sbkIndexHelper();
}
int getMaxTypeIndex()
@@ -855,18 +824,6 @@ bool TypeDatabase::checkApiVersion(const QString &package,
#ifndef QT_NO_DEBUG_STREAM
-#define FORMAT_BOOL(name, var) \
- if (var) \
- d << ", [" << name << ']';
-
-#define FORMAT_NONEMPTY_STRING(name, var) \
- if (!var.isEmpty()) \
- d << ", " << name << "=\"" << var << '"';
-
-#define FORMAT_LIST_SIZE(name, var) \
- if (!var.isEmpty()) \
- d << ", " << var.size() << ' ' << name;
-
template <class Container, class Separator>
static void formatList(QDebug &d, const char *name, const Container &c, Separator sep)
{
@@ -881,120 +838,6 @@ static void formatList(QDebug &d, const char *name, const Container &c, Separato
}
}
-void TypeEntry::formatDebug(QDebug &d) const
-{
- const QString cppName = qualifiedCppName();
- d << '"' << m_name << '"';
- if (m_name != cppName)
- d << "\", cppName=\"" << cppName << '"';
- d << ", type=" << m_type << ", codeGeneration="
- << m_codeGeneration << ", target=\"" << targetLangName() << '"';
- FORMAT_NONEMPTY_STRING("package", m_targetLangPackage)
- FORMAT_BOOL("stream", m_stream)
- FORMAT_LIST_SIZE("codeSnips", m_codeSnips)
- FORMAT_NONEMPTY_STRING("conversionRule", m_conversionRule)
- if (m_viewOn)
- d << ", views=" << m_viewOn->name();
- if (!m_version.isNull() && m_version > QVersionNumber(0, 0))
- d << ", version=" << m_version;
- if (m_revision)
- d << ", revision=" << m_revision;
- if (m_sbkIndex)
- d << ", sbkIndex=" << m_sbkIndex;
- if (m_include.isValid())
- d << ", include=" << m_include;
- formatList(d, "extraIncludes", m_extraIncludes, ", ");
-}
-
-void ComplexTypeEntry::formatDebug(QDebug &d) const
-{
- TypeEntry::formatDebug(d);
- FORMAT_BOOL("polymorphicBase", m_polymorphicBase)
- FORMAT_BOOL("genericClass", m_genericClass)
- FORMAT_BOOL("deleteInMainThread", m_deleteInMainThread)
- if (m_typeFlags != 0)
- d << ", typeFlags=" << m_typeFlags;
- d << ", copyableFlag=" << m_copyableFlag
- << ", except=" << int(m_exceptionHandling);
- FORMAT_NONEMPTY_STRING("defaultSuperclass", m_defaultSuperclass)
- FORMAT_NONEMPTY_STRING("polymorphicIdValue", m_polymorphicIdValue)
- FORMAT_NONEMPTY_STRING("targetType", m_targetType)
- FORMAT_NONEMPTY_STRING("hash", m_hashFunction)
- FORMAT_LIST_SIZE("addedFunctions", m_addedFunctions)
- formatList(d, "functionMods", m_functionMods, ", ");
- FORMAT_LIST_SIZE("fieldMods", m_fieldMods)
-}
-
-void TypedefEntry::formatDebug(QDebug &d) const
-{
- ComplexTypeEntry::formatDebug(d);
- d << ", sourceType=\"" << m_sourceType << '"'
- << ", source=" << m_source << ", target=" << m_target;
-}
-
-void EnumTypeEntry::formatDebug(QDebug &d) const
-{
- TypeEntry::formatDebug(d);
- if (m_flags)
- d << ", flags=(" << m_flags << ')';
-}
-
-void NamespaceTypeEntry::formatDebug(QDebug &d) const
-{
- ComplexTypeEntry::formatDebug(d);
- auto pattern = m_filePattern.pattern();
- FORMAT_NONEMPTY_STRING("pattern", pattern)
- d << ",visibility=" << m_visibility;
- if (m_inlineNamespace)
- d << "[inline]";
-}
-
-void ContainerTypeEntry::formatDebug(QDebug &d) const
-{
- ComplexTypeEntry::formatDebug(d);
- d << ", type=" << m_containerKind << ",\"" << typeName() << '"';
-}
-
-void SmartPointerTypeEntry::formatDebug(QDebug &d) const
-{
- ComplexTypeEntry::formatDebug(d);
- if (!m_instantiations.isEmpty()) {
- d << ", instantiations[" << m_instantiations.size() << "]=(";
- for (auto i : m_instantiations)
- d << i->name() << ',';
- d << ')';
- }
-}
-
-QDebug operator<<(QDebug d, const TypeEntry *te)
-{
- QDebugStateSaver saver(d);
- d.noquote();
- d.nospace();
- d << "TypeEntry(";
- if (te)
- te->formatDebug(d);
- else
- d << '0';
- d << ')';
- return d;
-}
-
-QDebug operator<<(QDebug d, const TemplateEntry *te)
-{
- QDebugStateSaver saver(d);
- d.noquote();
- d.nospace();
- d << "TemplateEntry(";
- if (te) {
- d << '"' << te->name() << '"';
- } else {
- d << '0';
- }
- d << ')';
- return d;
-}
-
void TypeDatabase::formatDebug(QDebug &d) const
{
d << "TypeDatabase("
diff --git a/sources/shiboken6/ApiExtractor/typedatabase.h b/sources/shiboken6/ApiExtractor/typedatabase.h
index fff301c6e..6d86196db 100644
--- a/sources/shiboken6/ApiExtractor/typedatabase.h
+++ b/sources/shiboken6/ApiExtractor/typedatabase.h
@@ -72,6 +72,28 @@ struct VersionRange
QVersionNumber until{9999, 9999};
};
+struct TypeRejection
+{
+ enum MatchType
+ {
+ ExcludeClass, // Match className only
+ Function, // Match className and function name
+ Field, // Match className and field name
+ Enum, // Match className and enum name
+ ArgumentType, // Match className and argument type
+ ReturnType, // Match className and return type
+ Invalid
+ };
+
+ QRegularExpression className;
+ QRegularExpression pattern;
+ MatchType matchType = Invalid;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const TypeRejection &r);
+#endif
+
class TypeDatabase
{
TypeDatabase();
diff --git a/sources/shiboken6/ApiExtractor/typesystem.cpp b/sources/shiboken6/ApiExtractor/typesystem.cpp
index a7a042c62..57a7f24d3 100644
--- a/sources/shiboken6/ApiExtractor/typesystem.cpp
+++ b/sources/shiboken6/ApiExtractor/typesystem.cpp
@@ -28,7 +28,10 @@
#include "typesystem.h"
#include "typedatabase.h"
+#include "modifications.h"
#include "messages.h"
+#include "sourcelocation.h"
+
#include <QtCore/QDebug>
#include <QtCore/QRegularExpression>
#include <QtCore/QSet>
@@ -39,314 +42,423 @@ static QString strings_char = QLatin1String("char");
static QString strings_jchar = QLatin1String("jchar");
static QString strings_jobject = QLatin1String("jobject");
-static inline QString callOperator() { return QStringLiteral("operator()"); }
+static QString buildName(const QString &entryName, const TypeEntry *parent)
+{
+ return parent == nullptr || parent->type() == TypeEntry::TypeSystemType
+ ? entryName : parent->name() + QLatin1String("::") + entryName;
+}
-PrimitiveTypeEntry::PrimitiveTypeEntry(const QString &entryName, const QVersionNumber &vr,
- const TypeEntry *parent) :
- TypeEntry(entryName, PrimitiveType, vr, parent),
- m_preferredTargetLangType(true)
+// 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;
}
-QString PrimitiveTypeEntry::targetLangApiName() const
+class TypeEntryPrivate
+{
+public:
+ explicit TypeEntryPrivate(const QString &entryName, TypeEntry::Type t, const QVersionNumber &vr,
+ const TypeEntry *parent);
+ virtual ~TypeEntryPrivate();
+
+ QString shortName() const;
+
+ const TypeEntry *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"
+ CustomFunction m_customConstructor;
+ CustomFunction m_customDestructor;
+ CodeSnipList m_codeSnips;
+ DocModificationList m_docModifications;
+ IncludeList m_extraIncludes;
+ Include m_include;
+ QString m_conversionRule;
+ QVersionNumber m_version;
+ CustomConversion *m_customConversion = nullptr;
+ SourceLocation m_sourceLocation; // XML file
+ TypeEntry::CodeGeneration m_codeGeneration = TypeEntry::GenerateCode;
+ TypeEntry *m_viewOn = nullptr;
+ int m_revision = 0;
+ int m_sbkIndex = 0;
+ TypeEntry::Type m_type;
+ bool m_stream = false;
+};
+
+TypeEntryPrivate::TypeEntryPrivate(const QString &entryName, TypeEntry::Type t, const QVersionNumber &vr,
+ const TypeEntry *parent) :
+ m_parent(parent),
+ m_name(buildName(entryName, parent)),
+ m_entryName(entryName),
+ m_version(vr),
+ m_type(t)
{
- return m_targetLangApiName;
}
-PrimitiveTypeEntry *PrimitiveTypeEntry::basicReferencedTypeEntry() const
+TypeEntryPrivate::~TypeEntryPrivate()
{
- if (!m_referencedTypeEntry)
- return nullptr;
+ delete m_customConversion;
+}
- PrimitiveTypeEntry *baseReferencedTypeEntry = m_referencedTypeEntry->basicReferencedTypeEntry();
- return baseReferencedTypeEntry ? baseReferencedTypeEntry : m_referencedTypeEntry;
+TypeEntry::TypeEntry(const QString &entryName, TypeEntry::Type t, const QVersionNumber &vr,
+ const TypeEntry *parent) :
+ TypeEntry(new TypeEntryPrivate(entryName, t, vr, parent))
+{
}
-TypeEntry *PrimitiveTypeEntry::clone() const
+TypeEntry::TypeEntry(TypeEntryPrivate *d) : m_d(d)
{
- return new PrimitiveTypeEntry(*this);
}
-PrimitiveTypeEntry::PrimitiveTypeEntry(const PrimitiveTypeEntry &) = default;
+TypeEntry::~TypeEntry() = default;
CodeSnipList TypeEntry::codeSnips() const
{
- return m_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;
+}
+
+void TypeEntry::setExtraIncludes(const IncludeList &includes)
+{
+ m_d->m_extraIncludes = includes;
}
void TypeEntry::addExtraInclude(const Include &newInclude)
{
- if (!m_extraIncludes.contains(newInclude))
- m_extraIncludes.append(newInclude);
+ if (!m_d->m_extraIncludes.contains(newInclude))
+ m_d->m_extraIncludes.append(newInclude);
}
-FunctionModificationList ComplexTypeEntry::functionModifications(const QString &signature) const
+Include TypeEntry::include() const
{
- FunctionModificationList lst;
- for (int i = 0; i < m_functionMods.count(); ++i) {
- const FunctionModification &mod = m_functionMods.at(i);
- if (mod.matches(signature))
- lst << mod;
- }
- return lst;
+ return m_d->m_include;
}
-FieldModification ComplexTypeEntry::fieldModification(const QString &name) const
+void TypeEntry::setInclude(const Include &inc)
{
- for (const auto &fieldMod : m_fieldMods) {
- if (fieldMod.name == name)
- return fieldMod;
+ // 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"))) {
+ QString path = inc.name();
+ path.remove(QLatin1String("_impl"));
+ m_d->m_include = Include(inc.type(), path);
+ } else {
+ m_d->m_include = inc;
}
- FieldModification mod;
- mod.name = name;
- mod.modifiers = FieldModification::Readable | FieldModification::Writable;
- return mod;
}
-void ComplexTypeEntry::setDefaultConstructor(const QString& defaultConstructor)
+void TypeEntry::setConversionRule(const QString &conversionRule)
{
- m_defaultConstructor = defaultConstructor;
+ m_d->m_conversionRule = conversionRule;
}
-QString ComplexTypeEntry::defaultConstructor() const
+
+QString TypeEntry::conversionRule() const
{
- return m_defaultConstructor;
+ //skip conversions flag
+ return m_d->m_conversionRule.mid(1);
}
-bool ComplexTypeEntry::hasDefaultConstructor() const
+
+bool TypeEntry::hasConversionRule() const
{
- return !m_defaultConstructor.isEmpty();
+ return !m_d->m_conversionRule.isEmpty();
}
-TypeEntry *ComplexTypeEntry::clone() const
+QVersionNumber TypeEntry::version() const
{
- return new ComplexTypeEntry(*this);
+ return m_d->m_version;
}
-// Take over parameters relevant for typedefs
-void ComplexTypeEntry::useAsTypedef(const ComplexTypeEntry *source)
+bool TypeEntry::hasNativeConversionRule() const
{
- TypeEntry::useAsTypedef(source);
- m_qualifiedCppName = source->m_qualifiedCppName;
- m_targetType = source->m_targetType;
+ return m_d->m_conversionRule.startsWith(QLatin1String(NATIVE_CONVERSION_RULE_FLAG));
}
-ComplexTypeEntry::ComplexTypeEntry(const ComplexTypeEntry &) = default;
+bool TypeEntry::hasTargetConversionRule() const
+{
+ return m_d->m_conversionRule.startsWith(QLatin1String(TARGET_CONVERSION_RULE_FLAG));
+}
-QString ContainerTypeEntry::qualifiedCppName() const
+bool TypeEntry::isCppPrimitive() const
{
- if (m_containerKind == StringListContainer)
- return QLatin1String("QStringList");
- return ComplexTypeEntry::qualifiedCppName();
+ if (!isPrimitive())
+ return false;
+
+ if (m_d->m_type == 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);
}
-TypeEntry *ContainerTypeEntry::clone() const
+TypeEntry::Type TypeEntry::type() const
{
- return new ContainerTypeEntry(*this);
+ return m_d->m_type;
}
-ContainerTypeEntry::ContainerTypeEntry(const ContainerTypeEntry &) = default;
+const TypeEntry *TypeEntry::parent() const
+{
+ return m_d->m_parent;
+}
-QString EnumTypeEntry::targetLangQualifier() const
+void TypeEntry::setParent(const TypeEntry *p)
{
- const QString q = qualifier();
- if (!q.isEmpty()) {
- if (auto te = TypeDatabase::instance()->findType(q))
- return te->targetLangName();
+ m_d->m_parent = p;
+}
+
+bool TypeEntry::isChildOf(const TypeEntry *p) const
+{
+ for (auto e = m_d->m_parent; e; e = e->parent()) {
+ if (e == p)
+ return true;
}
- return q;
+ return false;
}
-QString EnumTypeEntry::qualifier() const
+const TypeSystemTypeEntry *TypeEntry::typeSystemTypeEntry() const
{
- auto parentEntry = parent();
- return parentEntry && parentEntry->type() != TypeEntry::TypeSystemType ?
- parentEntry->name() : QString();
+ for (auto e = this; e; e = e->parent()) {
+ if (e->type() == TypeEntry::TypeSystemType)
+ return static_cast<const TypeSystemTypeEntry *>(e);
+ }
+ return nullptr;
}
-QString EnumTypeEntry::targetLangApiName() const
+const TypeEntry *TypeEntry::targetLangEnclosingEntry() const
{
- return QLatin1String("jint");
+ auto result = m_d->m_parent;
+ while (result && result->type() != TypeEntry::TypeSystemType
+ && !NamespaceTypeEntry::isVisibleScope(result)) {
+ result = result->parent();
+ }
+ return result;
}
-QString FlagsTypeEntry::targetLangApiName() const
+bool TypeEntry::isPrimitive() const
{
- return QLatin1String("jint");
+ return m_d->m_type == PrimitiveType;
}
-TypeEntry *EnumTypeEntry::clone() const
+bool TypeEntry::isEnum() const
{
- return new EnumTypeEntry(*this);
+ return m_d->m_type == EnumType;
}
-EnumTypeEntry::EnumTypeEntry(const EnumTypeEntry &) = default;
+bool TypeEntry::isFlags() const
+{
+ return m_d->m_type == FlagsType;
+}
-TypeEntry *FlagsTypeEntry::clone() const
+bool TypeEntry::isObject() const
{
- return new FlagsTypeEntry(*this);
+ return m_d->m_type == ObjectType;
}
-FlagsTypeEntry::FlagsTypeEntry(const FlagsTypeEntry &) = default;
+bool TypeEntry::isNamespace() const
+{
+ return m_d->m_type == NamespaceType;
+}
-static QString buildName(const QString &entryName, const TypeEntry *parent)
+bool TypeEntry::isContainer() const
{
- return parent == nullptr || parent->type() == TypeEntry::TypeSystemType
- ? entryName : parent->name() + QLatin1String("::") + entryName;
+ return m_d->m_type == ContainerType;
}
-ComplexTypeEntry::ComplexTypeEntry(const QString &entryName, TypeEntry::Type t,
- const QVersionNumber &vr,
- const TypeEntry *parent) :
- TypeEntry(entryName, t, vr, parent),
- m_qualifiedCppName(buildName(entryName, parent)),
- m_polymorphicBase(false),
- m_genericClass(false),
- m_deleteInMainThread(false)
+bool TypeEntry::isSmartPointer() const
{
+ return m_d->m_type == SmartPointerType;
}
-bool ComplexTypeEntry::isComplex() const
+bool TypeEntry::isArray() const
{
- return true;
+ return m_d->m_type == ArrayType;
}
-QString ComplexTypeEntry::targetLangApiName() const
+bool TypeEntry::isTemplateArgument() const
{
- return strings_jobject;
+ return m_d->m_type == TemplateArgumentType;
}
-QString ContainerTypeEntry::typeName() const
+bool TypeEntry::isVoid() const
{
- switch (m_containerKind) {
- case LinkedListContainer:
- return QLatin1String("linked-list");
- case ListContainer:
- return QLatin1String("list");
- case StringListContainer:
- return QLatin1String("string-list");
- case VectorContainer:
- return QLatin1String("vector");
- case StackContainer:
- return QLatin1String("stack");
- case QueueContainer:
- return QLatin1String("queue");
- case SetContainer:
- return QLatin1String("set");
- case MapContainer:
- return QLatin1String("map");
- case MultiMapContainer:
- return QLatin1String("multi-map");
- case HashContainer:
- return QLatin1String("hash");
- case MultiHashContainer:
- return QLatin1String("multi-hash");
- case PairContainer:
- return QLatin1String("pair");
- case NoContainer:
- default:
- return QLatin1String("?");
- }
+ return m_d->m_type == VoidType;
}
-static const QSet<QString> &primitiveCppTypes()
+bool TypeEntry::isVarargs() const
{
- 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;
+ return m_d->m_type == VarargsType;
}
-void TypeEntry::setInclude(const Include &inc)
+bool TypeEntry::isCustom() const
{
- // 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"))) {
- QString path = inc.name();
- path.remove(QLatin1String("_impl"));
- m_include = Include(inc.type(), path);
- } else {
- m_include = inc;
- }
+ return m_d->m_type == CustomType;
}
-bool TypeEntry::isCppPrimitive() const
+bool TypeEntry::isTypeSystem() const
{
- if (!isPrimitive())
- return false;
+ return m_d->m_type == TypeSystemType;
+}
- if (m_type == VoidType)
- return true;
+bool TypeEntry::isFunction() const
+{
+ return m_d->m_type == FunctionType;
+}
- const PrimitiveTypeEntry *referencedType =
- static_cast<const PrimitiveTypeEntry *>(this)->basicReferencedTypeEntry();
- const QString &typeName = referencedType ? referencedType->name() : m_name;
- return typeName.contains(QLatin1Char(' ')) || primitiveCppTypes().contains(typeName);
+bool TypeEntry::isEnumValue() const
+{
+ return m_d->m_type == EnumValue;
}
-TypeEntry::TypeEntry(const QString &entryName, TypeEntry::Type t, const QVersionNumber &vr,
- const TypeEntry *parent) :
- m_parent(parent),
- m_name(buildName(entryName, parent)),
- m_entryName(entryName),
- m_version(vr),
- m_type(t)
+bool TypeEntry::stream() const
{
+ return m_d->m_stream;
}
-TypeEntry::~TypeEntry()
+void TypeEntry::setStream(bool b)
{
- delete m_customConversion;
+ m_d->m_stream = b;
}
-bool TypeEntry::isChildOf(const TypeEntry *p) const
+QString TypeEntry::name() const
{
- for (auto e = m_parent; e; e = e->parent()) {
- if (e == p)
- return true;
- }
- return false;
+ return m_d->m_name;
}
-const TypeSystemTypeEntry *TypeEntry::typeSystemTypeEntry() const
+// Build the C++ name excluding any inline namespaces
+// ("std::__1::shared_ptr" -> "std::shared_ptr"
+QString TypeEntryPrivate::shortName() const
{
- for (auto e = this; e; e = e->parent()) {
- if (e->type() == TypeEntry::TypeSystemType)
- return static_cast<const TypeSystemTypeEntry *>(e);
+ if (m_cachedShortName.isEmpty()) {
+ QVarLengthArray<const TypeEntry *> 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()) {
+ foundInlineNamespace = true;
+ } else {
+ parents.append(p);
+ }
+ }
+ if (foundInlineNamespace) {
+ m_cachedShortName.reserve(m_name.size());
+ for (int i = parents.size() - 1; i >= 0; --i) {
+ m_cachedShortName.append(parents.at(i)->entryName());
+ m_cachedShortName.append(QLatin1String("::"));
+ }
+ m_cachedShortName.append(m_entryName);
+ } else {
+ m_cachedShortName = m_name;
+ }
}
- return nullptr;
+ return m_cachedShortName;
}
-const TypeEntry *TypeEntry::targetLangEnclosingEntry() const
+QString TypeEntry::shortName() const
{
- auto result = m_parent;
- while (result && result->type() != TypeEntry::TypeSystemType
- && !NamespaceTypeEntry::isVisibleScope(result)) {
- result = result->parent();
- }
- return result;
+ return m_d->shortName();
+}
+
+QString TypeEntry::entryName() const
+{
+ return m_d->m_entryName;
+}
+
+TypeEntry::CodeGeneration TypeEntry::codeGeneration() const
+{
+ return m_d->m_codeGeneration;
+}
+
+void TypeEntry::setCodeGeneration(TypeEntry::CodeGeneration cg)
+{
+ m_d->m_codeGeneration = cg;
+}
+
+bool TypeEntry::generateCode() const
+{
+ return m_d->m_codeGeneration == GenerateCode;
+}
+
+int TypeEntry::revision() const
+{
+ return m_d->m_revision;
+}
+
+void TypeEntry::setSbkIndex(int i)
+{
+ m_d->m_sbkIndex = i;
+}
+
+QString TypeEntry::qualifiedCppName() const
+{
+ return m_d->m_name;
+}
+
+QString TypeEntry::targetLangApiName() const
+{
+ return m_d->m_name;
}
QString TypeEntry::targetLangName() const
{
- if (m_cachedTargetLangName.isEmpty())
- m_cachedTargetLangName = buildTargetLangName();
- return m_cachedTargetLangName;
+ if (m_d->m_cachedTargetLangName.isEmpty())
+ m_d->m_cachedTargetLangName = buildTargetLangName();
+ return m_d->m_cachedTargetLangName;
+}
+
+void TypeEntry::setTargetLangName(const QString &n)
+{
+ m_d->m_cachedTargetLangName = n;
}
QString TypeEntry::buildTargetLangName() const
{
- QString result = m_entryName;
+ QString result = m_d->m_entryName;
for (auto p = parent(); p && p->type() != TypeEntry::TypeSystemType; p = p->parent()) {
if (NamespaceTypeEntry::isVisibleScope(p)) {
if (!result.isEmpty())
result.prepend(QLatin1Char('.'));
- QString n = p->m_entryName;
+ QString n = p->m_d->m_entryName;
n.replace(QLatin1String("::"), QLatin1String(".")); // Primitive types may have "std::"
result.prepend(n);
}
@@ -354,25 +466,57 @@ QString TypeEntry::buildTargetLangName() const
return result;
}
+bool TypeEntry::setRevisionHelper(int r)
+{
+ const bool changed = m_d->m_revision != r;
+ m_d->m_revision = r;
+ return changed;
+}
+
+int TypeEntry::sbkIndexHelper() const
+{
+ return m_d->m_sbkIndex;
+}
+
SourceLocation TypeEntry::sourceLocation() const
{
- return m_sourceLocation;
+ return m_d->m_sourceLocation;
}
void TypeEntry::setSourceLocation(const SourceLocation &sourceLocation)
{
- m_sourceLocation = sourceLocation;
+ m_d->m_sourceLocation = sourceLocation;
+}
+
+const TypeEntryPrivate *TypeEntry::d_func() const
+{
+ return m_d.data();
+}
+
+TypeEntryPrivate *TypeEntry::d_func()
+{
+ return m_d.data();
}
QString TypeEntry::targetLangEntryName() const
{
- if (m_cachedTargetLangEntryName.isEmpty()) {
- m_cachedTargetLangEntryName = targetLangName();
- const int lastDot = m_cachedTargetLangEntryName.lastIndexOf(QLatin1Char('.'));
+ if (m_d->m_cachedTargetLangEntryName.isEmpty()) {
+ m_d->m_cachedTargetLangEntryName = targetLangName();
+ const int lastDot = m_d->m_cachedTargetLangEntryName.lastIndexOf(QLatin1Char('.'));
if (lastDot != -1)
- m_cachedTargetLangEntryName.remove(0, lastDot + 1);
+ m_d->m_cachedTargetLangEntryName.remove(0, lastDot + 1);
}
- return m_cachedTargetLangEntryName;
+ return m_d->m_cachedTargetLangEntryName;
+}
+
+QString TypeEntry::targetLangPackage() const
+{
+ return m_d->m_targetLangPackage;
+}
+
+void TypeEntry::setTargetLangPackage(const QString &p)
+{
+ m_d->m_targetLangPackage = p;
}
QString TypeEntry::qualifiedTargetLangName() const
@@ -380,247 +524,1211 @@ 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;
+}
+
+bool TypeEntry::isValue() const
+{
+ return false;
+}
+
+bool TypeEntry::isComplex() const
+{
+ return false;
+}
+
bool TypeEntry::hasCustomConversion() const
{
- return m_customConversion != nullptr;
+ return m_d->m_customConversion != nullptr;
}
void TypeEntry::setCustomConversion(CustomConversion* customConversion)
{
- m_customConversion = customConversion;
+ m_d->m_customConversion = customConversion;
}
CustomConversion* TypeEntry::customConversion() const
{
- return m_customConversion;
+ return m_d->m_customConversion;
+}
+
+TypeEntry *TypeEntry::viewOn() const
+{
+ return m_d->m_viewOn;
+}
+
+void TypeEntry::setViewOn(TypeEntry *v)
+{
+ m_d->m_viewOn = v;
}
TypeEntry *TypeEntry::clone() const
{
- return new TypeEntry(*this);
+ return new TypeEntry(new TypeEntryPrivate(*m_d.data()));
}
// Take over parameters relevant for typedefs
void TypeEntry::useAsTypedef(const TypeEntry *source)
{
// XML Typedefs are in the global namespace for now.
- m_parent = source->typeSystemTypeEntry();
- m_entryName = source->m_entryName;
- m_name = source->m_name;
- m_targetLangPackage = source->m_targetLangPackage;
- m_codeGeneration = source->m_codeGeneration;
- m_version = source->m_version;
+ m_d->m_parent = source->typeSystemTypeEntry();
+ 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_codeGeneration = source->m_d->m_codeGeneration;
+ m_d->m_version = source->m_d->m_version;
}
-TypeEntry::TypeEntry(const TypeEntry &) = default;
-
TypeSystemTypeEntry::TypeSystemTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent) :
TypeEntry(entryName, TypeSystemType, vr, parent)
{
}
-TypeEntry *TypeSystemTypeEntry::clone() const
+TypeSystemTypeEntry::TypeSystemTypeEntry(TypeEntryPrivate *d) :
+ TypeEntry(d)
{
- return new TypeSystemTypeEntry(*this);
}
-TypeSystemTypeEntry::TypeSystemTypeEntry(const TypeSystemTypeEntry &) = default;
+TypeEntry *TypeSystemTypeEntry::clone() const
+{
+ return new TypeSystemTypeEntry(new TypeEntryPrivate(*d_func()));
+}
+// ----------------- VoidTypeEntry
VoidTypeEntry::VoidTypeEntry() :
TypeEntry(QLatin1String("void"), VoidType, QVersionNumber(0, 0), nullptr)
{
}
-TypeEntry *VoidTypeEntry::clone() const
+VoidTypeEntry::VoidTypeEntry(TypeEntryPrivate *d) :
+ TypeEntry(d)
{
- return new VoidTypeEntry(*this);
}
-VoidTypeEntry::VoidTypeEntry(const VoidTypeEntry &) = default;
+TypeEntry *VoidTypeEntry::clone() const
+{
+ return new VoidTypeEntry(new TypeEntryPrivate(*d_func()));
+}
VarargsTypeEntry::VarargsTypeEntry() :
TypeEntry(QLatin1String("..."), VarargsType, QVersionNumber(0, 0), nullptr)
{
}
+// ----------------- VarargsTypeEntry
TypeEntry *VarargsTypeEntry::clone() const
{
- return new VarargsTypeEntry(*this);
+ return new VarargsTypeEntry(new TypeEntryPrivate(*d_func()));
+}
+
+VarargsTypeEntry::VarargsTypeEntry(TypeEntryPrivate *d) :
+ TypeEntry(d)
+{
}
-VarargsTypeEntry::VarargsTypeEntry(const VarargsTypeEntry &) = default;
+// ----------------- TemplateArgumentEntry
+class TemplateArgumentEntryPrivate : public TypeEntryPrivate
+{
+public:
+ using TypeEntryPrivate::TypeEntryPrivate;
+
+ int m_ordinal = 0;
+};
TemplateArgumentEntry::TemplateArgumentEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent) :
- TypeEntry(entryName, TemplateArgumentType, vr, parent)
+ TypeEntry(new TemplateArgumentEntryPrivate(entryName, TemplateArgumentType, vr, parent))
+{
+}
+
+int TemplateArgumentEntry::ordinal() const
+{
+ S_D(const TemplateArgumentEntry);
+ return d->m_ordinal;
+}
+
+void TemplateArgumentEntry::setOrdinal(int o)
{
+ S_D(TemplateArgumentEntry);
+ d->m_ordinal = o;
}
TypeEntry *TemplateArgumentEntry::clone() const
{
- return new TemplateArgumentEntry(*this);
+ S_D(const TemplateArgumentEntry);
+ return new TemplateArgumentEntry(new TemplateArgumentEntryPrivate(*d));
}
-TemplateArgumentEntry::TemplateArgumentEntry(const TemplateArgumentEntry &) = default;
+TemplateArgumentEntry::TemplateArgumentEntry(TemplateArgumentEntryPrivate *d) :
+ TypeEntry(d)
+{
+}
+
+// ----------------- ArrayTypeEntry
+class ArrayTypeEntryPrivate : public TypeEntryPrivate
+{
+public:
+ explicit ArrayTypeEntryPrivate(const TypeEntry *nested_type, const QVersionNumber &vr,
+ const TypeEntry *parent) :
+ TypeEntryPrivate(QLatin1String("Array"), TypeEntry::ArrayType, vr, parent),
+ m_nestedType(nested_type)
+ {
+ }
+
+ const TypeEntry *m_nestedType;
+};
ArrayTypeEntry::ArrayTypeEntry(const TypeEntry *nested_type, const QVersionNumber &vr,
const TypeEntry *parent) :
- TypeEntry(QLatin1String("Array"), ArrayType, vr, parent),
- m_nestedType(nested_type)
+ TypeEntry(new ArrayTypeEntryPrivate(nested_type, vr, parent))
{
- Q_ASSERT(m_nestedType);
+ Q_ASSERT(nested_type);
+}
+
+void ArrayTypeEntry::setNestedTypeEntry(TypeEntry *nested)
+{
+ S_D(ArrayTypeEntry);
+ d->m_nestedType = nested;
+}
+
+const TypeEntry *ArrayTypeEntry::nestedTypeEntry() const
+{
+ S_D(const ArrayTypeEntry);
+ return d->m_nestedType;
}
QString ArrayTypeEntry::buildTargetLangName() const
{
- return m_nestedType->targetLangName() + QLatin1String("[]");
+ S_D(const ArrayTypeEntry);
+ return d->m_nestedType->targetLangName() + QLatin1String("[]");
}
QString ArrayTypeEntry::targetLangApiName() const
{
- return m_nestedType->isPrimitive()
- ? m_nestedType->targetLangApiName() + QLatin1String("Array")
+ S_D(const ArrayTypeEntry);
+ return d->m_nestedType->isPrimitive()
+ ? d->m_nestedType->targetLangApiName() + QLatin1String("Array")
: QLatin1String("jobjectArray");
}
TypeEntry *ArrayTypeEntry::clone() const
{
- return new ArrayTypeEntry(*this);
+ S_D(const ArrayTypeEntry);
+ return new ArrayTypeEntry(new ArrayTypeEntryPrivate(*d));
+}
+
+ArrayTypeEntry::ArrayTypeEntry(ArrayTypeEntryPrivate *d) :
+ TypeEntry(d)
+{
+}
+
+// ----------------- PrimitiveTypeEntry
+class PrimitiveTypeEntryPrivate : public TypeEntryPrivate
+{
+public:
+ PrimitiveTypeEntryPrivate(const QString &entryName, const QVersionNumber &vr,
+ const TypeEntry *parent) :
+ TypeEntryPrivate(entryName, TypeEntry::PrimitiveType, vr, parent),
+ m_preferredTargetLangType(true)
+ {
+ }
+
+ QString m_targetLangApiName;
+ QString m_defaultConstructor;
+ uint m_preferredTargetLangType : 1;
+ PrimitiveTypeEntry* m_referencedTypeEntry = nullptr;
+};
+
+PrimitiveTypeEntry::PrimitiveTypeEntry(const QString &entryName, const QVersionNumber &vr,
+ const TypeEntry *parent) :
+ TypeEntry(new PrimitiveTypeEntryPrivate(entryName, vr, parent))
+{
+}
+
+QString PrimitiveTypeEntry::targetLangApiName() const
+{
+ S_D(const PrimitiveTypeEntry);
+ return d->m_targetLangApiName;
+}
+
+void PrimitiveTypeEntry::setTargetLangApiName(const QString &targetLangApiName)
+{
+ S_D(PrimitiveTypeEntry);
+ d->m_targetLangApiName = targetLangApiName;
+}
+
+QString PrimitiveTypeEntry::defaultConstructor() const
+{
+ S_D(const PrimitiveTypeEntry);
+ return d->m_defaultConstructor;
+}
+
+void PrimitiveTypeEntry::setDefaultConstructor(const QString &defaultConstructor)
+{
+ S_D(PrimitiveTypeEntry);
+ d->m_defaultConstructor = defaultConstructor;
+}
+
+bool PrimitiveTypeEntry::hasDefaultConstructor() const
+{
+ S_D(const PrimitiveTypeEntry);
+ return !d->m_defaultConstructor.isEmpty();
+}
+
+PrimitiveTypeEntry *PrimitiveTypeEntry::referencedTypeEntry() const
+{
+ S_D(const PrimitiveTypeEntry);
+ return d->m_referencedTypeEntry;
+}
+
+void PrimitiveTypeEntry::setReferencedTypeEntry(PrimitiveTypeEntry *referencedTypeEntry)
+{
+ S_D(PrimitiveTypeEntry);
+ d->m_referencedTypeEntry = referencedTypeEntry;
+}
+
+PrimitiveTypeEntry *PrimitiveTypeEntry::basicReferencedTypeEntry() const
+{
+ S_D(const PrimitiveTypeEntry);
+ if (!d->m_referencedTypeEntry)
+ return nullptr;
+
+ PrimitiveTypeEntry *baseReferencedTypeEntry = d->m_referencedTypeEntry->basicReferencedTypeEntry();
+ return baseReferencedTypeEntry ? baseReferencedTypeEntry : d->m_referencedTypeEntry;
+}
+
+bool PrimitiveTypeEntry::preferredTargetLangType() const
+{
+ S_D(const PrimitiveTypeEntry);
+ return d->m_preferredTargetLangType;
+}
+
+void PrimitiveTypeEntry::setPreferredTargetLangType(bool b)
+{
+ S_D(PrimitiveTypeEntry);
+ d->m_preferredTargetLangType = b;
+}
+
+TypeEntry *PrimitiveTypeEntry::clone() const
+{
+ S_D(const PrimitiveTypeEntry);
+ return new PrimitiveTypeEntry(new PrimitiveTypeEntryPrivate(*d));
+}
+
+PrimitiveTypeEntry::PrimitiveTypeEntry(PrimitiveTypeEntryPrivate *d)
+ : TypeEntry(d)
+{
}
-ArrayTypeEntry::ArrayTypeEntry(const ArrayTypeEntry &) = default;
+// ----------------- EnumTypeEntry
+class EnumTypeEntryPrivate : public TypeEntryPrivate
+{
+public:
+ using TypeEntryPrivate::TypeEntryPrivate;
+
+ const EnumValueTypeEntry *m_nullValue = nullptr;
+ QStringList m_rejectedEnums;
+ FlagsTypeEntry *m_flags = nullptr;
+};
EnumTypeEntry::EnumTypeEntry(const QString &entryName,
const QVersionNumber &vr,
const TypeEntry *parent) :
- TypeEntry(entryName, EnumType, vr, parent)
+ TypeEntry(new EnumTypeEntryPrivate(entryName, EnumType, vr, parent))
+{
+}
+
+QString EnumTypeEntry::targetLangQualifier() const
+{
+ const QString q = qualifier();
+ if (!q.isEmpty()) {
+ if (auto te = TypeDatabase::instance()->findType(q))
+ return te->targetLangName();
+ }
+ return q;
+}
+
+QString EnumTypeEntry::qualifier() const
+{
+ auto parentEntry = parent();
+ return parentEntry && parentEntry->type() != TypeEntry::TypeSystemType ?
+ parentEntry->name() : QString();
+}
+
+const EnumValueTypeEntry *EnumTypeEntry::nullValue() const
+{
+ S_D(const EnumTypeEntry);
+ return d->m_nullValue;
+}
+
+void EnumTypeEntry::setNullValue(const EnumValueTypeEntry *n)
+{
+ S_D(EnumTypeEntry);
+ d->m_nullValue = n;
+}
+
+void EnumTypeEntry::setFlags(FlagsTypeEntry *flags)
+{
+ S_D(EnumTypeEntry);
+ d->m_flags = flags;
+}
+
+FlagsTypeEntry *EnumTypeEntry::flags() const
+{
+ S_D(const EnumTypeEntry);
+ return d->m_flags;
+}
+
+bool EnumTypeEntry::isEnumValueRejected(const QString &name) const
+{
+ S_D(const EnumTypeEntry);
+ return d->m_rejectedEnums.contains(name);
+}
+
+void EnumTypeEntry::addEnumValueRejection(const QString &name)
+{
+ S_D(EnumTypeEntry);
+ d->m_rejectedEnums << name;
+}
+
+QStringList EnumTypeEntry::enumValueRejections() const
+{
+ S_D(const EnumTypeEntry);
+ return d->m_rejectedEnums;
+}
+
+QString EnumTypeEntry::targetLangApiName() const
+{
+ return QLatin1String("jint");
+}
+
+TypeEntry *EnumTypeEntry::clone() const
+{
+ S_D(const EnumTypeEntry);
+ return new EnumTypeEntry(new EnumTypeEntryPrivate(*d));
+}
+
+EnumTypeEntry::EnumTypeEntry(EnumTypeEntryPrivate *d) :
+ TypeEntry(d)
{
}
+// ----------------- EnumValueTypeEntryPrivate
+class EnumValueTypeEntryPrivate : public TypeEntryPrivate
+{
+public:
+ EnumValueTypeEntryPrivate(const QString &name, const QString &value,
+ const EnumTypeEntry *enclosingEnum,
+ bool isScopedEnum,
+ const QVersionNumber &vr) :
+ TypeEntryPrivate(name, TypeEntry::EnumValue, vr,
+ isScopedEnum ? enclosingEnum : enclosingEnum->parent()),
+ m_value(value),
+ m_enclosingEnum(enclosingEnum)
+ {
+ }
+
+ QString m_value;
+ const EnumTypeEntry *m_enclosingEnum;
+};
+
EnumValueTypeEntry::EnumValueTypeEntry(const QString &name, const QString &value,
const EnumTypeEntry *enclosingEnum,
bool isScopedEnum,
const QVersionNumber &vr) :
- TypeEntry(name, TypeEntry::EnumValue, vr,
- isScopedEnum ? enclosingEnum : enclosingEnum->parent()),
- m_value(value),
- m_enclosingEnum(enclosingEnum)
+ TypeEntry(new EnumValueTypeEntryPrivate(name, value, enclosingEnum, isScopedEnum, vr))
+{
+}
+
+QString EnumValueTypeEntry::value() const
{
+ S_D(const EnumValueTypeEntry);
+ return d->m_value;
+}
+
+const EnumTypeEntry *EnumValueTypeEntry::enclosingEnum() const
+{
+ S_D(const EnumValueTypeEntry);
+ return d->m_enclosingEnum;
}
TypeEntry *EnumValueTypeEntry::clone() const
{
- return new EnumValueTypeEntry(*this);
+ S_D(const EnumValueTypeEntry);
+ return new EnumValueTypeEntry(new EnumValueTypeEntryPrivate(*d));
}
-EnumValueTypeEntry::EnumValueTypeEntry(const EnumValueTypeEntry &) = default;
+EnumValueTypeEntry::EnumValueTypeEntry(EnumValueTypeEntryPrivate *d) :
+ TypeEntry(d)
+{
+}
+
+// ----------------- FlagsTypeEntry
+class FlagsTypeEntryPrivate : public TypeEntryPrivate
+{
+public:
+ using TypeEntryPrivate::TypeEntryPrivate;
+
+ QString m_originalName;
+ QString m_flagsName;
+ EnumTypeEntry *m_enum = nullptr;
+};
FlagsTypeEntry::FlagsTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent) :
- TypeEntry(entryName, FlagsType, vr, parent)
+ TypeEntry(new FlagsTypeEntryPrivate(entryName, FlagsType, vr, parent))
{
}
QString FlagsTypeEntry::buildTargetLangName() const
{
- QString on = m_originalName;
+ S_D(const FlagsTypeEntry);
+ QString on = d->m_originalName;
on.replace(QLatin1String("::"), QLatin1String("."));
return on;
}
+FlagsTypeEntry::FlagsTypeEntry(FlagsTypeEntryPrivate *d) :
+ TypeEntry(d)
+{
+}
+
+QString FlagsTypeEntry::targetLangApiName() const
+{
+ return QLatin1String("jint");
+}
+
+QString FlagsTypeEntry::originalName() const
+{
+ S_D(const FlagsTypeEntry);
+ return d->m_originalName;
+}
+
+void FlagsTypeEntry::setOriginalName(const QString &s)
+{
+ S_D(FlagsTypeEntry);
+ d->m_originalName = s;
+}
+
+QString FlagsTypeEntry::flagsName() const
+{
+ S_D(const FlagsTypeEntry);
+ return d->m_flagsName;
+}
+
+void FlagsTypeEntry::setFlagsName(const QString &name)
+{
+ S_D(FlagsTypeEntry);
+ d->m_flagsName = name;
+}
+
+EnumTypeEntry *FlagsTypeEntry::originator() const
+{
+ S_D(const FlagsTypeEntry);
+ return d->m_enum;
+}
+
+void FlagsTypeEntry::setOriginator(EnumTypeEntry *e)
+{
+ S_D(FlagsTypeEntry);
+ d->m_enum = e;
+}
+
+TypeEntry *FlagsTypeEntry::clone() const
+{
+ S_D(const FlagsTypeEntry);
+ return new FlagsTypeEntry(new FlagsTypeEntryPrivate(*d));
+}
+
+// ----------------- ConstantValueTypeEntry
ConstantValueTypeEntry::ConstantValueTypeEntry(const QString& name,
const TypeEntry *parent) :
TypeEntry(name, ConstantValueType, QVersionNumber(0, 0), parent)
{
}
+ConstantValueTypeEntry::ConstantValueTypeEntry(TypeEntryPrivate *d) :
+ TypeEntry(d)
+{
+}
+
+// ----------------- ComplexTypeEntry
+class ComplexTypeEntryPrivate : public TypeEntryPrivate
+{
+public:
+ ComplexTypeEntryPrivate(const QString &entryName, TypeEntry::Type t,
+ const QVersionNumber &vr,
+ const TypeEntry *parent) :
+ TypeEntryPrivate(entryName, t, vr, parent),
+ m_qualifiedCppName(buildName(entryName, parent)),
+ m_polymorphicBase(false),
+ m_genericClass(false),
+ m_deleteInMainThread(false)
+ {
+ }
+
+ AddedFunctionList m_addedFunctions;
+ FunctionModificationList m_functionMods;
+ FieldModificationList m_fieldMods;
+ QList<TypeSystemProperty> m_properties;
+ QString m_defaultConstructor;
+ QString m_defaultSuperclass;
+ QString m_qualifiedCppName;
+
+ uint m_polymorphicBase : 1;
+ uint m_genericClass : 1;
+ uint m_deleteInMainThread : 1;
+
+ QString m_polymorphicIdValue;
+ QString m_targetType;
+ ComplexTypeEntry::TypeFlags m_typeFlags;
+ ComplexTypeEntry::CopyableFlag m_copyableFlag = ComplexTypeEntry::Unknown;
+ QString m_hashFunction;
+
+ const ComplexTypeEntry* m_baseContainerType = nullptr;
+ // For class functions
+ TypeSystem::ExceptionHandling m_exceptionHandling = TypeSystem::ExceptionHandling::Unspecified;
+ TypeSystem::AllowThread m_allowThread = TypeSystem::AllowThread::Unspecified;
+};
+
+ComplexTypeEntry::ComplexTypeEntry(const QString &entryName, TypeEntry::Type t,
+ const QVersionNumber &vr,
+ const TypeEntry *parent) :
+ TypeEntry(new ComplexTypeEntryPrivate(entryName, t, vr, parent))
+{
+}
+
+bool ComplexTypeEntry::isComplex() const
+{
+ return true;
+}
+
+QString ComplexTypeEntry::targetLangApiName() const
+{
+ return strings_jobject;
+}
+
+void ComplexTypeEntry::setTypeFlags(TypeFlags flags)
+{
+ S_D(ComplexTypeEntry);
+ d->m_typeFlags = flags;
+}
+
+ComplexTypeEntry::TypeFlags ComplexTypeEntry::typeFlags() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_typeFlags;
+}
+
+FunctionModificationList ComplexTypeEntry::functionModifications() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_functionMods;
+}
+
+void ComplexTypeEntry::setFunctionModifications(const FunctionModificationList &functionModifications)
+{
+ S_D(ComplexTypeEntry);
+ d->m_functionMods = functionModifications;
+}
+
+void ComplexTypeEntry::addFunctionModification(const FunctionModification &functionModification)
+{
+ S_D(ComplexTypeEntry);
+ d->m_functionMods << functionModification;
+}
+
+FunctionModificationList ComplexTypeEntry::functionModifications(const QString &signature) 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))
+ lst << mod;
+ }
+ return lst;
+}
+
+AddedFunctionList ComplexTypeEntry::addedFunctions() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_addedFunctions;
+}
+
+void ComplexTypeEntry::setAddedFunctions(const AddedFunctionList &addedFunctions)
+{
+ S_D(ComplexTypeEntry);
+ d->m_addedFunctions = addedFunctions;
+}
+
+void ComplexTypeEntry::addNewFunction(const AddedFunctionPtr &addedFunction)
+{
+ S_D(ComplexTypeEntry);
+ d->m_addedFunctions << addedFunction;
+}
+
+FieldModification ComplexTypeEntry::fieldModification(const QString &name) const
+{
+ S_D(const ComplexTypeEntry);
+ for (const auto &fieldMod : d->m_fieldMods) {
+ if (fieldMod.name == name)
+ return fieldMod;
+ }
+ FieldModification mod;
+ mod.name = name;
+ mod.modifiers = FieldModification::Readable | FieldModification::Writable;
+ return mod;
+}
+
+void ComplexTypeEntry::setFieldModifications(const FieldModificationList &mods)
+{
+ S_D(ComplexTypeEntry);
+ d->m_fieldMods = mods;
+}
+
+FieldModificationList ComplexTypeEntry::fieldModifications() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_fieldMods;
+}
+
+const QList<TypeSystemProperty> &ComplexTypeEntry::properties() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_properties;
+}
+
+void ComplexTypeEntry::addProperty(const TypeSystemProperty &p)
+{
+ S_D(ComplexTypeEntry);
+ d->m_properties.append(p);
+}
+
+QString ComplexTypeEntry::defaultSuperclass() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_defaultSuperclass;
+}
+
+void ComplexTypeEntry::setDefaultSuperclass(const QString &sc)
+{
+ S_D(ComplexTypeEntry);
+ d->m_defaultSuperclass = sc;
+}
+
+QString ComplexTypeEntry::qualifiedCppName() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_qualifiedCppName;
+}
+
+void ComplexTypeEntry::setIsPolymorphicBase(bool on)
+{
+ S_D(ComplexTypeEntry);
+ d->m_polymorphicBase = on;
+}
+
+bool ComplexTypeEntry::isPolymorphicBase() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_polymorphicBase;
+}
+
+void ComplexTypeEntry::setPolymorphicIdValue(const QString &value)
+{
+ S_D(ComplexTypeEntry);
+ d->m_polymorphicIdValue = value;
+}
+
+QString ComplexTypeEntry::polymorphicIdValue() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_polymorphicIdValue;
+}
+
+QString ComplexTypeEntry::targetType() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_targetType;
+}
+
+void ComplexTypeEntry::setTargetType(const QString &code)
+{
+ S_D(ComplexTypeEntry);
+ d->m_targetType = code;
+}
+
+bool ComplexTypeEntry::isGenericClass() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_genericClass;
+}
+
+void ComplexTypeEntry::setGenericClass(bool isGeneric)
+{
+ S_D(ComplexTypeEntry);
+ d->m_genericClass = isGeneric;
+}
+
+bool ComplexTypeEntry::deleteInMainThread() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_deleteInMainThread;
+}
+
+void ComplexTypeEntry::setDeleteInMainThread(bool dmt)
+{
+ S_D(ComplexTypeEntry);
+ d->m_deleteInMainThread = dmt;
+}
+
+ComplexTypeEntry::CopyableFlag ComplexTypeEntry::copyable() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_copyableFlag;
+}
+
+void ComplexTypeEntry::setCopyable(ComplexTypeEntry::CopyableFlag flag)
+{
+ S_D(ComplexTypeEntry);
+ d->m_copyableFlag = flag;
+}
+
+QString ComplexTypeEntry::hashFunction() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_hashFunction;
+}
+
+void ComplexTypeEntry::setHashFunction(const QString &hashFunction)
+{
+ S_D(ComplexTypeEntry);
+ d->m_hashFunction = hashFunction;
+}
+
+void ComplexTypeEntry::setBaseContainerType(const ComplexTypeEntry *baseContainer)
+{
+ S_D(ComplexTypeEntry);
+ d->m_baseContainerType = baseContainer;
+}
+
+const ComplexTypeEntry *ComplexTypeEntry::baseContainerType() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_baseContainerType;
+}
+
+TypeSystem::ExceptionHandling ComplexTypeEntry::exceptionHandling() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_exceptionHandling;
+}
+
+void ComplexTypeEntry::setExceptionHandling(TypeSystem::ExceptionHandling e)
+{
+ S_D(ComplexTypeEntry);
+ d->m_exceptionHandling = e;
+}
+
+TypeSystem::AllowThread ComplexTypeEntry::allowThread() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_allowThread;
+}
+
+void ComplexTypeEntry::setAllowThread(TypeSystem::AllowThread allowThread)
+{
+ S_D(ComplexTypeEntry);
+ d->m_allowThread = allowThread;
+}
+
+void ComplexTypeEntry::setDefaultConstructor(const QString& defaultConstructor)
+{
+ S_D(ComplexTypeEntry);
+ d->m_defaultConstructor = defaultConstructor;
+}
+
+QString ComplexTypeEntry::defaultConstructor() const
+{
+ S_D(const ComplexTypeEntry);
+ return d->m_defaultConstructor;
+}
+
+bool ComplexTypeEntry::hasDefaultConstructor() const
+{
+ S_D(const ComplexTypeEntry);
+ return !d->m_defaultConstructor.isEmpty();
+}
+
+TypeEntry *ComplexTypeEntry::clone() const
+{
+ S_D(const ComplexTypeEntry);
+ return new ComplexTypeEntry(new ComplexTypeEntryPrivate(*d));
+}
+
+// Take over parameters relevant for typedefs
+void ComplexTypeEntry::useAsTypedef(const ComplexTypeEntry *source)
+{
+ S_D(ComplexTypeEntry);
+ TypeEntry::useAsTypedef(source);
+ d->m_qualifiedCppName = source->qualifiedCppName();
+ d->m_targetType = source->targetType();
+}
+
+ComplexTypeEntry::ComplexTypeEntry(ComplexTypeEntryPrivate *d) :
+ TypeEntry(d)
+{
+}
+
TypeEntry *ConstantValueTypeEntry::clone() const
{
- return new ConstantValueTypeEntry(*this);
+ return new ConstantValueTypeEntry(new TypeEntryPrivate(*d_func()));
}
-ConstantValueTypeEntry::ConstantValueTypeEntry(const ConstantValueTypeEntry &) = default;
+// ----------------- TypedefEntry
/* A typedef entry allows for specifying template specializations in the
* typesystem XML file. */
+class TypedefEntryPrivate : public ComplexTypeEntryPrivate
+{
+public:
+ TypedefEntryPrivate(const QString &entryName,
+ const QString &sourceType,
+ const QVersionNumber &vr,
+ const TypeEntry *parent) :
+ ComplexTypeEntryPrivate(entryName, TypeEntry::TypedefType,
+ vr, parent),
+ m_sourceType(sourceType)
+ {
+ }
+
+ QString m_sourceType;
+ ComplexTypeEntry *m_source = nullptr;
+ ComplexTypeEntry *m_target = nullptr;
+};
+
TypedefEntry::TypedefEntry(const QString &entryName, const QString &sourceType,
const QVersionNumber &vr, const TypeEntry *parent) :
- ComplexTypeEntry(entryName, TypedefType, vr, parent),
- m_sourceType(sourceType)
+ ComplexTypeEntry(new TypedefEntryPrivate(entryName, sourceType, vr, parent))
+{
+}
+
+QString TypedefEntry::sourceType() const
+{
+ S_D(const TypedefEntry);
+ return d->m_sourceType;
+}
+
+void TypedefEntry::setSourceType(const QString &s)
{
+ S_D(TypedefEntry);
+ d->m_sourceType =s;
}
TypeEntry *TypedefEntry::clone() const
{
- return new TypedefEntry(*this);
+ S_D(const TypedefEntry);
+ return new TypedefEntry(new TypedefEntryPrivate(*d));
}
-TypedefEntry::TypedefEntry(const TypedefEntry &) = default;
+ComplexTypeEntry *TypedefEntry::source() const
+{
+ S_D(const TypedefEntry);
+ return d->m_source;
+}
+
+void TypedefEntry::setSource(ComplexTypeEntry *source)
+{
+ S_D(TypedefEntry);
+ d->m_source = source;
+}
+
+ComplexTypeEntry *TypedefEntry::target() const
+{
+ S_D(const TypedefEntry);
+ return d->m_target;
+}
+
+void TypedefEntry::setTarget(ComplexTypeEntry *target)
+{
+ S_D(TypedefEntry);
+ d->m_target = target;
+}
+
+TypedefEntry::TypedefEntry(TypedefEntryPrivate *d) :
+ ComplexTypeEntry(d)
+{
+}
+
+// ----------------- ContainerTypeEntry
+class ContainerTypeEntryPrivate : public ComplexTypeEntryPrivate
+{
+public:
+ ContainerTypeEntryPrivate(const QString &entryName,
+ ContainerTypeEntry::ContainerKind containerKind,
+ const QVersionNumber &vr,
+ const TypeEntry *parent) :
+ ComplexTypeEntryPrivate(entryName, TypeEntry::ContainerType, vr, parent),
+ m_containerKind(containerKind)
+ {
+ }
+
+ ContainerTypeEntry::ContainerKind m_containerKind;
+};
ContainerTypeEntry::ContainerTypeEntry(const QString &entryName, ContainerKind containerKind,
const QVersionNumber &vr,
const TypeEntry *parent) :
- ComplexTypeEntry(entryName, ContainerType, vr, parent),
- m_containerKind(containerKind)
+ ComplexTypeEntry(new ContainerTypeEntryPrivate(entryName, containerKind, vr, parent))
{
setCodeGeneration(GenerateForSubclass);
}
+ContainerTypeEntry::ContainerKind ContainerTypeEntry::containerKind() const
+{
+ S_D(const ContainerTypeEntry);
+ return d->m_containerKind;
+}
+
+QString ContainerTypeEntry::qualifiedCppName() const
+{
+ S_D(const ContainerTypeEntry);
+ if (d->m_containerKind == StringListContainer)
+ return QLatin1String("QStringList");
+ return ComplexTypeEntry::qualifiedCppName();
+}
+
+TypeEntry *ContainerTypeEntry::clone() const
+{
+ S_D(const ContainerTypeEntry);
+ return new ContainerTypeEntry(new ContainerTypeEntryPrivate(*d));
+}
+
+ContainerTypeEntry::ContainerTypeEntry(ContainerTypeEntryPrivate *d) :
+ ComplexTypeEntry(d)
+{
+}
+
+QString ContainerTypeEntry::typeName() const
+{
+ S_D(const ContainerTypeEntry);
+ switch (d->m_containerKind) {
+ case LinkedListContainer:
+ return QLatin1String("linked-list");
+ case ListContainer:
+ return QLatin1String("list");
+ case StringListContainer:
+ return QLatin1String("string-list");
+ case VectorContainer:
+ return QLatin1String("vector");
+ case StackContainer:
+ return QLatin1String("stack");
+ case QueueContainer:
+ return QLatin1String("queue");
+ case SetContainer:
+ return QLatin1String("set");
+ case MapContainer:
+ return QLatin1String("map");
+ case MultiMapContainer:
+ return QLatin1String("multi-map");
+ case HashContainer:
+ return QLatin1String("hash");
+ case MultiHashContainer:
+ return QLatin1String("multi-hash");
+ case PairContainer:
+ return QLatin1String("pair");
+ case NoContainer:
+ default:
+ break;
+ }
+ return QLatin1String("?");
+}
+
+// ----------------- SmartPointerTypeEntry
+class SmartPointerTypeEntryPrivate : public ComplexTypeEntryPrivate
+{
+public:
+ SmartPointerTypeEntryPrivate(const QString &entryName,
+ const QString &getterName,
+ const QString &smartPointerType,
+ const QString &refCountMethodName,
+ const QVersionNumber &vr, const TypeEntry *parent) :
+ ComplexTypeEntryPrivate(entryName, TypeEntry::SmartPointerType, vr, parent),
+ m_getterName(getterName),
+ m_smartPointerType(smartPointerType),
+ m_refCountMethodName(refCountMethodName)
+ {
+ }
+
+ QString m_getterName;
+ QString m_smartPointerType;
+ QString m_refCountMethodName;
+ SmartPointerTypeEntry::Instantiations m_instantiations;
+};
+
SmartPointerTypeEntry::SmartPointerTypeEntry(const QString &entryName,
const QString &getterName,
const QString &smartPointerType,
const QString &refCountMethodName,
const QVersionNumber &vr, const TypeEntry *parent) :
- ComplexTypeEntry(entryName, SmartPointerType, vr, parent),
- m_getterName(getterName),
- m_smartPointerType(smartPointerType),
- m_refCountMethodName(refCountMethodName)
+ ComplexTypeEntry(new SmartPointerTypeEntryPrivate(entryName, getterName, smartPointerType,
+ refCountMethodName, vr, parent))
{
}
+QString SmartPointerTypeEntry::getter() const
+{
+ S_D(const SmartPointerTypeEntry);
+ return d->m_getterName;
+}
+
+QString SmartPointerTypeEntry::refCountMethodName() const
+{
+ S_D(const SmartPointerTypeEntry);
+ return d->m_refCountMethodName;
+}
+
TypeEntry *SmartPointerTypeEntry::clone() const
{
- return new SmartPointerTypeEntry(*this);
+ S_D(const SmartPointerTypeEntry);
+ return new SmartPointerTypeEntry(new SmartPointerTypeEntryPrivate(*d));
+}
+
+SmartPointerTypeEntry::Instantiations SmartPointerTypeEntry::instantiations() const
+{
+ S_D(const SmartPointerTypeEntry);
+ return d->m_instantiations;
}
-SmartPointerTypeEntry::SmartPointerTypeEntry(const SmartPointerTypeEntry &) = default;
+void SmartPointerTypeEntry::setInstantiations(const Instantiations &i)
+{
+ S_D(SmartPointerTypeEntry);
+ d->m_instantiations = i;
+}
+
+SmartPointerTypeEntry::SmartPointerTypeEntry(SmartPointerTypeEntryPrivate *d) :
+ ComplexTypeEntry(d)
+{
+}
bool SmartPointerTypeEntry::matchesInstantiation(const TypeEntry *e) const
{
- return m_instantiations.isEmpty() || m_instantiations.contains(e);
+ S_D(const SmartPointerTypeEntry);
+ return d->m_instantiations.isEmpty() || d->m_instantiations.contains(e);
}
+// ----------------- NamespaceTypeEntry
+class NamespaceTypeEntryPrivate : public ComplexTypeEntryPrivate
+{
+public:
+ using ComplexTypeEntryPrivate::ComplexTypeEntryPrivate;
+
+ QRegularExpression m_filePattern;
+ const NamespaceTypeEntry *m_extends = nullptr;
+ TypeSystem::Visibility m_visibility = TypeSystem::Visibility::Auto;
+ bool m_hasPattern = false;
+ bool m_inlineNamespace = false;
+ bool m_generateUsing = true; // Whether to generate "using namespace" into wrapper
+};
+
NamespaceTypeEntry::NamespaceTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent) :
- ComplexTypeEntry(entryName, NamespaceType, vr, parent)
+ ComplexTypeEntry(new NamespaceTypeEntryPrivate(entryName, NamespaceType, vr, parent))
{
}
TypeEntry *NamespaceTypeEntry::clone() const
{
- return new NamespaceTypeEntry(*this);
+ S_D(const NamespaceTypeEntry);
+ return new NamespaceTypeEntry(new NamespaceTypeEntryPrivate(*d));
+}
+
+const NamespaceTypeEntry *NamespaceTypeEntry::extends() const
+{
+ S_D(const NamespaceTypeEntry);
+ return d->m_extends;
+}
+
+void NamespaceTypeEntry::setExtends(const NamespaceTypeEntry *e)
+{
+ S_D(NamespaceTypeEntry);
+ d->m_extends = e;
+}
+
+const QRegularExpression &NamespaceTypeEntry::filePattern() const
+{
+ S_D(const NamespaceTypeEntry);
+ return d->m_filePattern;
}
void NamespaceTypeEntry::setFilePattern(const QRegularExpression &r)
{
- m_filePattern = r;
- m_hasPattern = !m_filePattern.pattern().isEmpty();
- if (m_hasPattern)
- m_filePattern.optimize();
+ S_D(NamespaceTypeEntry);
+ d->m_filePattern = r;
+ d->m_hasPattern = !d->m_filePattern.pattern().isEmpty();
+ if (d->m_hasPattern)
+ d->m_filePattern.optimize();
}
-NamespaceTypeEntry::NamespaceTypeEntry(const NamespaceTypeEntry &) = default;
+bool NamespaceTypeEntry::hasPattern() const
+{
+ S_D(const NamespaceTypeEntry);
+ return d->m_hasPattern;
+}
+
+NamespaceTypeEntry::NamespaceTypeEntry(NamespaceTypeEntryPrivate *d) :
+ ComplexTypeEntry(d)
+{
+}
bool NamespaceTypeEntry::matchesFile(const QString &needle) const
{
- return m_filePattern.match(needle).hasMatch();
+ S_D(const NamespaceTypeEntry);
+ return d->m_filePattern.match(needle).hasMatch();
}
bool NamespaceTypeEntry::isVisible() const
{
- return m_visibility == TypeSystem::Visibility::Visible
- || (m_visibility == TypeSystem::Visibility::Auto && !m_inlineNamespace);
+ S_D(const NamespaceTypeEntry);
+ return d->m_visibility == TypeSystem::Visibility::Visible
+ || (d->m_visibility == TypeSystem::Visibility::Auto && !d->m_inlineNamespace);
+}
+
+void NamespaceTypeEntry::setVisibility(TypeSystem::Visibility v)
+{
+ S_D(NamespaceTypeEntry);
+ d->m_visibility = v;
+}
+
+bool NamespaceTypeEntry::isInlineNamespace() const
+{
+ S_D(const NamespaceTypeEntry);
+ return d->m_inlineNamespace;
+}
+
+void NamespaceTypeEntry::setInlineNamespace(bool i)
+{
+ S_D(NamespaceTypeEntry);
+ d->m_inlineNamespace = i;
}
bool NamespaceTypeEntry::isVisibleScope(const TypeEntry *e)
@@ -629,6 +1737,19 @@ bool NamespaceTypeEntry::isVisibleScope(const TypeEntry *e)
|| static_cast<const NamespaceTypeEntry *>(e)->isVisible();
}
+bool NamespaceTypeEntry::generateUsing() const
+{
+ S_D(const NamespaceTypeEntry);
+ return d->m_generateUsing;
+}
+
+void NamespaceTypeEntry::setGenerateUsing(bool generateUsing)
+{
+ S_D(NamespaceTypeEntry);
+ d->m_generateUsing = generateUsing;
+}
+
+// ----------------- ValueTypeEntry
ValueTypeEntry::ValueTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent) :
ComplexTypeEntry(entryName, BasicValueType, vr, parent)
@@ -642,10 +1763,14 @@ bool ValueTypeEntry::isValue() const
TypeEntry *ValueTypeEntry::clone() const
{
- return new ValueTypeEntry(*this);
+ S_D(const ComplexTypeEntry);
+ return new ValueTypeEntry(new ComplexTypeEntryPrivate(*d));
}
-ValueTypeEntry::ValueTypeEntry(const ValueTypeEntry &) = default;
+ValueTypeEntry::ValueTypeEntry(ComplexTypeEntryPrivate *d) :
+ ComplexTypeEntry(d)
+{
+}
ValueTypeEntry::ValueTypeEntry(const QString &entryName, Type t, const QVersionNumber &vr,
const TypeEntry *parent) :
@@ -653,6 +1778,7 @@ ValueTypeEntry::ValueTypeEntry(const QString &entryName, Type t, const QVersionN
{
}
+// ----------------- CustomConversion
struct CustomConversion::CustomConversionPrivate
{
CustomConversionPrivate(const TypeEntry* ownerType)
@@ -787,21 +1913,58 @@ void CustomConversion::TargetToNativeConversion::setConversion(const QString& co
m_d->conversion = conversion;
}
+// ----------------- FunctionTypeEntry
+class FunctionTypeEntryPrivate : public TypeEntryPrivate
+{
+public:
+ FunctionTypeEntryPrivate(const QString &entryName, const QString &signature,
+ const QVersionNumber &vr,
+ const TypeEntry *parent) :
+ TypeEntryPrivate(entryName, TypeEntry::FunctionType, vr, parent),
+ m_signatures(signature)
+ {
+ }
+
+ QStringList m_signatures;
+};
+
FunctionTypeEntry::FunctionTypeEntry(const QString &entryName, const QString &signature,
const QVersionNumber &vr,
const TypeEntry *parent) :
- TypeEntry(entryName, FunctionType, vr, parent)
+ TypeEntry(new FunctionTypeEntryPrivate(entryName, signature, vr, parent))
+{
+}
+
+void FunctionTypeEntry::addSignature(const QString &signature)
+{
+ S_D(FunctionTypeEntry);
+ d->m_signatures << signature;
+}
+
+const QStringList &FunctionTypeEntry::signatures() const
+{
+ S_D(const FunctionTypeEntry);
+ return d->m_signatures;
+}
+
+bool FunctionTypeEntry::hasSignature(const QString &signature) const
{
- addSignature(signature);
+ S_D(const FunctionTypeEntry);
+ return d->m_signatures.contains(signature);
}
TypeEntry *FunctionTypeEntry::clone() const
{
- return new FunctionTypeEntry(*this);
+ S_D(const FunctionTypeEntry);
+ return new FunctionTypeEntry(new FunctionTypeEntryPrivate(*d));
}
-FunctionTypeEntry::FunctionTypeEntry(const FunctionTypeEntry &) = default;
+FunctionTypeEntry::FunctionTypeEntry(FunctionTypeEntryPrivate *d) :
+ TypeEntry(d)
+{
+}
+// ----------------- ObjectTypeEntry
ObjectTypeEntry::ObjectTypeEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent)
: ComplexTypeEntry(entryName, ObjectType, vr, parent)
@@ -810,7 +1973,166 @@ ObjectTypeEntry::ObjectTypeEntry(const QString &entryName, const QVersionNumber
TypeEntry *ObjectTypeEntry::clone() const
{
- return new ObjectTypeEntry(*this);
+ S_D(const ComplexTypeEntry);
+ return new ObjectTypeEntry(new ComplexTypeEntryPrivate(*d));
+}
+
+ObjectTypeEntry::ObjectTypeEntry(ComplexTypeEntryPrivate *d) :
+ ComplexTypeEntry(d)
+{
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+
+#define FORMAT_BOOL(name, var) \
+ if (var) \
+ debug << ", [" << name << ']';
+
+#define FORMAT_NONEMPTY_STRING(name, var) \
+ if (!var.isEmpty()) \
+ debug << ", " << name << "=\"" << var << '"';
+
+#define FORMAT_LIST_SIZE(name, var) \
+ 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 << ')';
+ }
}
-ObjectTypeEntry::ObjectTypeEntry(const ObjectTypeEntry &) = default;
+void TypeEntry::formatDebug(QDebug &debug) const
+{
+ const QString cppName = qualifiedCppName();
+ debug << '"' << m_d->m_name << '"';
+ if (m_d->m_name != cppName)
+ debug << "\", cppName=\"" << cppName << '"';
+ debug << ", type=" << m_d->m_type << ", codeGeneration="
+ << m_d->m_codeGeneration << ", 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("conversionRule", m_d->m_conversionRule)
+ 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))
+ debug << ", version=" << m_d->m_version;
+ if (m_d->m_revision)
+ debug << ", revision=" << m_d->m_revision;
+ if (m_d->m_sbkIndex)
+ debug << ", sbkIndex=" << m_d->m_sbkIndex;
+ if (m_d->m_include.isValid())
+ debug << ", include=" << m_d->m_include;
+ formatList(debug, "extraIncludes", m_d->m_extraIncludes, ", ");
+}
+
+void ComplexTypeEntry::formatDebug(QDebug &debug) const
+{
+ S_D(const ComplexTypeEntry);
+
+ TypeEntry::formatDebug(debug);
+ FORMAT_BOOL("polymorphicBase", d->m_polymorphicBase)
+ FORMAT_BOOL("genericClass", d->m_genericClass)
+ FORMAT_BOOL("deleteInMainThread", d->m_deleteInMainThread)
+ if (d->m_typeFlags != 0)
+ debug << ", typeFlags=" << d->m_typeFlags;
+ debug << ", copyableFlag=" << d->m_copyableFlag
+ << ", except=" << int(d->m_exceptionHandling);
+ FORMAT_NONEMPTY_STRING("defaultSuperclass", d->m_defaultSuperclass)
+ FORMAT_NONEMPTY_STRING("polymorphicIdValue", d->m_polymorphicIdValue)
+ FORMAT_NONEMPTY_STRING("targetType", d->m_targetType)
+ FORMAT_NONEMPTY_STRING("hash", d->m_hashFunction)
+ FORMAT_LIST_SIZE("addedFunctions", d->m_addedFunctions)
+ formatList(debug, "functionMods", d->m_functionMods, ", ");
+ FORMAT_LIST_SIZE("fieldMods", d->m_fieldMods)
+}
+
+void TypedefEntry::formatDebug(QDebug &debug) const
+{
+ S_D(const TypedefEntry);
+
+ ComplexTypeEntry::formatDebug(debug);
+ debug << ", sourceType=\"" << d->m_sourceType << '"'
+ << ", source=" << d->m_source << ", target=" << d->m_target;
+}
+
+void EnumTypeEntry::formatDebug(QDebug &debug) const
+{
+ S_D(const EnumTypeEntry);
+
+ TypeEntry::formatDebug(debug);
+ if (d->m_flags)
+ debug << ", flags=(" << d->m_flags << ')';
+}
+
+void NamespaceTypeEntry::formatDebug(QDebug &debug) const
+{
+ S_D(const NamespaceTypeEntry);
+
+ ComplexTypeEntry::formatDebug(debug);
+ auto pattern = d->m_filePattern.pattern();
+ FORMAT_NONEMPTY_STRING("pattern", pattern)
+ debug << ",visibility=" << d->m_visibility;
+ if (d->m_inlineNamespace)
+ debug << "[inline]";
+}
+
+void ContainerTypeEntry::formatDebug(QDebug &debug) const
+{
+ S_D(const ContainerTypeEntry);
+
+ ComplexTypeEntry::formatDebug(debug);
+ debug << ", type=" << d->m_containerKind << ",\"" << typeName() << '"';
+}
+
+void SmartPointerTypeEntry::formatDebug(QDebug &debug) const
+{
+ S_D(const SmartPointerTypeEntry);
+
+ ComplexTypeEntry::formatDebug(debug);
+ if (!d->m_instantiations.isEmpty()) {
+ debug << ", instantiations[" << d->m_instantiations.size() << "]=(";
+ for (auto i : d->m_instantiations)
+ debug << i->name() << ',';
+ debug << ')';
+ }
+}
+
+QDebug operator<<(QDebug d, const TypeEntry *te)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "TypeEntry(";
+ if (te)
+ te->formatDebug(d);
+ else
+ d << '0';
+ d << ')';
+ return d;
+}
+
+QDebug operator<<(QDebug d, const TemplateEntry *te)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "TemplateEntry(";
+ if (te) {
+ d << '"' << te->name() << '"';
+ } else {
+ d << '0';
+ }
+ d << ')';
+ return d;
+}
+#endif // QT_NO_DEBUG_STREAM
diff --git a/sources/shiboken6/ApiExtractor/typesystem.h b/sources/shiboken6/ApiExtractor/typesystem.h
index 561969542..5484f0af5 100644
--- a/sources/shiboken6/ApiExtractor/typesystem.h
+++ b/sources/shiboken6/ApiExtractor/typesystem.h
@@ -1,4 +1,4 @@
-/****************************************************************************
+/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
@@ -31,30 +31,42 @@
#include "typesystem_enums.h"
#include "typesystem_typedefs.h"
-#include "modifications.h"
#include "include.h"
-#include "sourcelocation.h"
-#include <QtCore/QHash>
-#include <QtCore/qobjectdefs.h>
-#include <QtCore/QRegularExpression>
-#include <QtCore/QString>
#include <QtCore/QStringList>
-#include <QtCore/QMap>
-#include <QtCore/QVector>
-#include <QtCore/QVersionNumber>
+#include <QtCore/QScopedPointer>
//Used to identify the conversion rule to avoid break API
extern const char *TARGET_CONVERSION_RULE_FLAG;
extern const char *NATIVE_CONVERSION_RULE_FLAG;
+class CustomFunction;
class CustomConversion;
+class EnumValueTypeEntry;
class FlagsTypeEntry;
+class SourceLocation;
class TypeSystemTypeEntry;
+class TypeEntryPrivate;
+class TemplateArgumentEntryPrivate;
+class ArrayTypeEntryPrivate;
+class PrimitiveTypeEntryPrivate;
+class EnumTypeEntryPrivate;
+class EnumValueTypeEntryPrivate;
+class FlagsTypeEntryPrivate;
+class ComplexTypeEntryPrivate;
+class TypedefEntryPrivate;
+class ContainerTypeEntryPrivate;
+class SmartPointerTypeEntryPrivate;
+class NamespaceTypeEntryPrivate;
+class FunctionTypeEntryPrivate;
+struct TargetToNativeConversionPrivate;
+
QT_BEGIN_NAMESPACE
class QDebug;
+class QRegularExpression;
class QTextStream;
+class QVersionNumber;
QT_END_NAMESPACE
struct TypeSystemProperty
@@ -75,9 +87,7 @@ class TypeEntry
{
Q_GADGET
public:
- TypeEntry &operator=(const TypeEntry &) = delete;
- TypeEntry &operator=(TypeEntry &&) = delete;
- TypeEntry(TypeEntry &&) = delete;
+ Q_DISABLE_COPY_MOVE(TypeEntry)
enum Type {
PrimitiveType,
@@ -111,127 +121,59 @@ public:
explicit TypeEntry(const QString &entryName, Type t, const QVersionNumber &vr,
const TypeEntry *parent);
-
virtual ~TypeEntry();
- Type type() const
- {
- return m_type;
- }
+ Type type() const;
- const TypeEntry *parent() const { return m_parent; }
- void setParent(const TypeEntry *p) { m_parent = p; }
+ const TypeEntry *parent() const;
+ void setParent(const TypeEntry *p);
bool isChildOf(const TypeEntry *p) const;
const TypeSystemTypeEntry *typeSystemTypeEntry() const;
// cf AbstractMetaClass::targetLangEnclosingClass()
const TypeEntry *targetLangEnclosingEntry() const;
- bool isPrimitive() const
- {
- return m_type == PrimitiveType;
- }
- bool isEnum() const
- {
- return m_type == EnumType;
- }
- bool isFlags() const
- {
- return m_type == FlagsType;
- }
- bool isObject() const
- {
- return m_type == ObjectType;
- }
- bool isNamespace() const
- {
- return m_type == NamespaceType;
- }
- bool isContainer() const
- {
- return m_type == ContainerType;
- }
- bool isSmartPointer() const
- {
- return m_type == SmartPointerType;
- }
- bool isArray() const
- {
- return m_type == ArrayType;
- }
- bool isTemplateArgument() const
- {
- return m_type == TemplateArgumentType;
- }
- bool isVoid() const
- {
- return m_type == VoidType;
- }
- bool isVarargs() const
- {
- return m_type == VarargsType;
- }
- bool isCustom() const
- {
- return m_type == CustomType;
- }
- bool isTypeSystem() const
- {
- return m_type == TypeSystemType;
- }
- bool isFunction() const
- {
- return m_type == FunctionType;
- }
- bool isEnumValue() const
- {
- return m_type == EnumValue;
- }
-
- bool stream() const
- {
- return m_stream;
- }
-
- void setStream(bool b)
- {
- m_stream = b;
- }
+ bool isPrimitive() const;
+ bool isEnum() const;
+ bool isFlags() const;
+ bool isObject() const;
+ bool isNamespace() const;
+ bool isContainer() const;
+ bool isSmartPointer() const;
+ bool isArray() const;
+ bool isTemplateArgument() const;
+ bool isVoid() const;
+ bool isVarargs() const;
+ bool isCustom() const;
+ bool isTypeSystem() const;
+ bool isFunction() const;
+ bool isEnumValue() const;
+
+ bool stream() const;
+ void setStream(bool b);
// The type's name in C++, fully qualified
- QString name() const { return m_name; }
+ QString name() const;
// C++ excluding inline namespaces
QString shortName() const;
// Name as specified in XML
- QString entryName() const { return m_entryName; }
+ QString entryName() const;
- CodeGeneration codeGeneration() const
- {
- return m_codeGeneration;
- }
- void setCodeGeneration(CodeGeneration cg)
- {
- m_codeGeneration = cg;
- }
+ CodeGeneration codeGeneration() const;
+ void setCodeGeneration(CodeGeneration cg);
// Returns true if code must be generated for this entry,
// it will return false in case of types coming from typesystems
// included for reference only.
// NOTE: 'GenerateForSubclass' means 'generate="no"'
// on 'load-typesystem' tag
- inline bool generateCode() const
- {
- return m_codeGeneration == GenerateCode;
- }
+ bool generateCode() const;
- int revision() const { return m_revision; }
+ int revision() const;
void setRevision(int r); // see typedatabase.cpp
- int sbkIndex() const;
- void setSbkIndex(int i) { m_sbkIndex = i; }
+ int sbkIndex() const; // see typedatabase.cpp
+ void setSbkIndex(int i);
- virtual QString qualifiedCppName() const
- {
- return m_name;
- }
+ virtual QString qualifiedCppName() const;
/**
* Its type's name in target language API
@@ -242,120 +184,59 @@ public:
* /return string representing the target language API name
* for this type entry
*/
- virtual QString targetLangApiName() const
- {
- return m_name;
- }
+ virtual QString targetLangApiName() const;
// The type's name in TargetLang
QString targetLangName() const; // "Foo.Bar"
- void setTargetLangName(const QString &n) { m_cachedTargetLangName = n; }
+ void setTargetLangName(const QString &n);
QString targetLangEntryName() const; // "Bar"
// The package
- QString targetLangPackage() const { return m_targetLangPackage; }
- void setTargetLangPackage(const QString &p) { m_targetLangPackage = p; }
+ QString targetLangPackage() const;
+ void setTargetLangPackage(const QString &p);
QString qualifiedTargetLangName() const;
- void setCustomConstructor(const CustomFunction &func)
- {
- m_customConstructor = func;
- }
- CustomFunction customConstructor() const
- {
- return m_customConstructor;
- }
+ void setCustomConstructor(const CustomFunction &func);
+ CustomFunction customConstructor() const;
- void setCustomDestructor(const CustomFunction &func)
- {
- m_customDestructor = func;
- }
- CustomFunction customDestructor() const
- {
- return m_customDestructor;
- }
+ void setCustomDestructor(const CustomFunction &func);
+ CustomFunction customDestructor() const;
- virtual bool isValue() const
- {
- return false;
- }
- virtual bool isComplex() const
- {
- return false;
- }
+ virtual bool isValue() const;
+ virtual bool isComplex() const;
CodeSnipList codeSnips() const;
- void setCodeSnips(const CodeSnipList &codeSnips)
- {
- m_codeSnips = codeSnips;
- }
- void addCodeSnip(const CodeSnip &codeSnip)
- {
- m_codeSnips << codeSnip;
- }
+ void setCodeSnips(const CodeSnipList &codeSnips);
+ void addCodeSnip(const CodeSnip &codeSnip);
- void setDocModification(const DocModificationList& docMods)
- {
- m_docModifications << docMods;
- }
- DocModificationList docModifications() const
- {
- return m_docModifications;
- }
+ void setDocModification(const DocModificationList& docMods);
+ DocModificationList docModifications() const;
- const IncludeList &extraIncludes() const
- {
- return m_extraIncludes;
- }
- void setExtraIncludes(const IncludeList &includes)
- {
- m_extraIncludes = includes;
- }
+ const IncludeList &extraIncludes() const;
+ void setExtraIncludes(const IncludeList &includes);
void addExtraInclude(const Include &newInclude);
- Include include() const
- {
- return m_include;
- }
+ Include include() const;
void setInclude(const Include &inc);
// Replace conversionRule arg to CodeSnip in future version
/// Set the type convertion rule
- void setConversionRule(const QString& conversionRule)
- {
- m_conversionRule = conversionRule;
- }
+ void setConversionRule(const QString& conversionRule);
/// Returns the type convertion rule
- QString conversionRule() const
- {
- //skip conversions flag
- return m_conversionRule.mid(1);
- }
+ QString conversionRule() const;
/// Returns true if there are any conversiton rule for this type, false otherwise.
- bool hasConversionRule() const
- {
- return !m_conversionRule.isEmpty();
- }
+ bool hasConversionRule() const;
- QVersionNumber version() const
- {
- return m_version;
- }
+ QVersionNumber version() const;
/// TODO-CONVERTER: mark as deprecated
- bool hasNativeConversionRule() const
- {
- return m_conversionRule.startsWith(QLatin1String(NATIVE_CONVERSION_RULE_FLAG));
- }
+ bool hasNativeConversionRule() const;
/// TODO-CONVERTER: mark as deprecated
- bool hasTargetConversionRule() const
- {
- return m_conversionRule.startsWith(QLatin1String(TARGET_CONVERSION_RULE_FLAG));
- }
+ bool hasTargetConversionRule() const;
bool isCppPrimitive() const;
@@ -366,8 +247,8 @@ public:
// View on: Type to use for function argument conversion, fex
// std::string_view -> std::string for foo(std::string_view).
// cf AbstractMetaType::viewOn()
- TypeEntry *viewOn() const { return m_viewOn; }
- void setViewOn(TypeEntry *v) { m_viewOn = v; }
+ TypeEntry *viewOn() const;
+ void setViewOn(TypeEntry *v);
virtual TypeEntry *clone() const;
@@ -381,34 +262,17 @@ public:
#endif
protected:
- TypeEntry(const TypeEntry &);
+ explicit TypeEntry(TypeEntryPrivate *d);
+
+ const TypeEntryPrivate *d_func() const;
+ TypeEntryPrivate *d_func();
virtual QString buildTargetLangName() const;
private:
- const TypeEntry *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"
- CustomFunction m_customConstructor;
- CustomFunction m_customDestructor;
- CodeSnipList m_codeSnips;
- DocModificationList m_docModifications;
- IncludeList m_extraIncludes;
- Include m_include;
- QString m_conversionRule;
- QVersionNumber m_version;
- CustomConversion *m_customConversion = nullptr;
- SourceLocation m_sourceLocation; // XML file
- CodeGeneration m_codeGeneration = GenerateCode;
- TypeEntry *m_viewOn = nullptr;
- int m_revision = 0;
- int m_sbkIndex = 0;
- Type m_type;
- bool m_stream = false;
+ bool setRevisionHelper(int r);
+ int sbkIndexHelper() const;
+ QScopedPointer<TypeEntryPrivate> m_d;
};
class TypeSystemTypeEntry : public TypeEntry
@@ -420,7 +284,7 @@ public:
TypeEntry *clone() const override;
protected:
- TypeSystemTypeEntry(const TypeSystemTypeEntry &);
+ explicit TypeSystemTypeEntry(TypeEntryPrivate *d);
};
class VoidTypeEntry : public TypeEntry
@@ -431,7 +295,7 @@ public:
TypeEntry *clone() const override;
protected:
- VoidTypeEntry(const VoidTypeEntry &);
+ explicit VoidTypeEntry(TypeEntryPrivate *d);
};
class VarargsTypeEntry : public TypeEntry
@@ -442,7 +306,7 @@ public:
TypeEntry *clone() const override;
protected:
- VarargsTypeEntry(const VarargsTypeEntry &);
+ explicit VarargsTypeEntry(TypeEntryPrivate *d);
};
class TemplateArgumentEntry : public TypeEntry
@@ -451,22 +315,13 @@ public:
explicit TemplateArgumentEntry(const QString &entryName, const QVersionNumber &vr,
const TypeEntry *parent);
- int ordinal() const
- {
- return m_ordinal;
- }
- void setOrdinal(int o)
- {
- m_ordinal = o;
- }
+ int ordinal() const;
+ void setOrdinal(int o);
TypeEntry *clone() const override;
protected:
- TemplateArgumentEntry(const TemplateArgumentEntry &);
-
-private:
- int m_ordinal = 0;
+ explicit TemplateArgumentEntry(TemplateArgumentEntryPrivate *d);
};
class ArrayTypeEntry : public TypeEntry
@@ -475,29 +330,19 @@ public:
explicit ArrayTypeEntry(const TypeEntry *nested_type, const QVersionNumber &vr,
const TypeEntry *parent);
- void setNestedTypeEntry(TypeEntry *nested)
- {
- m_nestedType = nested;
- }
- const TypeEntry *nestedTypeEntry() const
- {
- return m_nestedType;
- }
+ void setNestedTypeEntry(TypeEntry *nested);
+ const TypeEntry *nestedTypeEntry() const;
QString targetLangApiName() const override;
TypeEntry *clone() const override;
protected:
- ArrayTypeEntry(const ArrayTypeEntry &);
+ explicit ArrayTypeEntry(ArrayTypeEntryPrivate *d);
QString buildTargetLangName() const override;
-
-private:
- const TypeEntry *m_nestedType;
};
-
class PrimitiveTypeEntry : public TypeEntry
{
public:
@@ -505,23 +350,11 @@ public:
const TypeEntry *parent);
QString targetLangApiName() const override;
- void setTargetLangApiName(const QString &targetLangApiName)
- {
- m_targetLangApiName = targetLangApiName;
- }
+ void setTargetLangApiName(const QString &targetLangApiName);
- QString defaultConstructor() const
- {
- return m_defaultConstructor;
- }
- void setDefaultConstructor(const QString& defaultConstructor)
- {
- m_defaultConstructor = defaultConstructor;
- }
- bool hasDefaultConstructor() const
- {
- return !m_defaultConstructor.isEmpty();
- }
+ QString defaultConstructor() const;
+ void setDefaultConstructor(const QString& defaultConstructor);
+ bool hasDefaultConstructor() const;
/**
* The PrimitiveTypeEntry pointed by this type entry if it
@@ -529,16 +362,13 @@ public:
* /return the type referenced by the typedef, or a null pointer
* if the current object is not an typedef
*/
- PrimitiveTypeEntry* referencedTypeEntry() const { return m_referencedTypeEntry; }
+ PrimitiveTypeEntry *referencedTypeEntry() const;
/**
* Defines type referenced by this entry.
* /param referencedTypeEntry type referenced by this entry
*/
- void setReferencedTypeEntry(PrimitiveTypeEntry* referencedTypeEntry)
- {
- m_referencedTypeEntry = referencedTypeEntry;
- }
+ void setReferencedTypeEntry(PrimitiveTypeEntry* referencedTypeEntry);
/**
* Finds the most basic primitive type that the typedef represents,
@@ -548,29 +378,15 @@ public:
*/
PrimitiveTypeEntry* basicReferencedTypeEntry() const;
- bool preferredTargetLangType() const
- {
- return m_preferredTargetLangType;
- }
- void setPreferredTargetLangType(bool b)
- {
- m_preferredTargetLangType = b;
- }
+ bool preferredTargetLangType() const;
+ void setPreferredTargetLangType(bool b);
TypeEntry *clone() const override;
protected:
- PrimitiveTypeEntry(const PrimitiveTypeEntry &);
-
-private:
- QString m_targetLangApiName;
- QString m_defaultConstructor;
- uint m_preferredTargetLangType : 1;
- PrimitiveTypeEntry* m_referencedTypeEntry = nullptr;
+ explicit PrimitiveTypeEntry(PrimitiveTypeEntryPrivate *d);
};
-class EnumValueTypeEntry;
-
class EnumTypeEntry : public TypeEntry
{
public:
@@ -584,44 +400,22 @@ public:
QString qualifier() const;
- const EnumValueTypeEntry *nullValue() const { return m_nullValue; }
- void setNullValue(const EnumValueTypeEntry *n) { m_nullValue = n; }
+ const EnumValueTypeEntry *nullValue() const;
+ void setNullValue(const EnumValueTypeEntry *n);
- void setFlags(FlagsTypeEntry *flags)
- {
- m_flags = flags;
- }
- FlagsTypeEntry *flags() const
- {
- return m_flags;
- }
+ void setFlags(FlagsTypeEntry *flags);
+ FlagsTypeEntry *flags() const;
- bool isEnumValueRejected(const QString &name) const
- {
- return m_rejectedEnums.contains(name);
- }
- void addEnumValueRejection(const QString &name)
- {
- m_rejectedEnums << name;
- }
- QStringList enumValueRejections() const
- {
- return m_rejectedEnums;
- }
+ bool isEnumValueRejected(const QString &name) const;
+ void addEnumValueRejection(const QString &name);
+ QStringList enumValueRejections() const;
TypeEntry *clone() const override;
#ifndef QT_NO_DEBUG_STREAM
void formatDebug(QDebug &d) const override;
#endif
protected:
- EnumTypeEntry(const EnumTypeEntry &);
-
-private:
- const EnumValueTypeEntry *m_nullValue = nullptr;
-
- QStringList m_rejectedEnums;
-
- FlagsTypeEntry *m_flags = nullptr;
+ explicit EnumTypeEntry(EnumTypeEntryPrivate *d);
};
// EnumValueTypeEntry is used for resolving integer type templates
@@ -634,17 +428,13 @@ public:
const EnumTypeEntry* enclosingEnum,
bool isScopedEnum, const QVersionNumber &vr);
- QString value() const { return m_value; }
- const EnumTypeEntry* enclosingEnum() const { return m_enclosingEnum; }
+ QString value() const;
+ const EnumTypeEntry* enclosingEnum() const;
TypeEntry *clone() const override;
protected:
- EnumValueTypeEntry(const EnumValueTypeEntry &);
-
-private:
- QString m_value;
- const EnumTypeEntry* m_enclosingEnum;
+ explicit EnumValueTypeEntry(EnumValueTypeEntryPrivate *d);
};
class FlagsTypeEntry : public TypeEntry
@@ -655,44 +445,21 @@ public:
QString targetLangApiName() const override;
- QString originalName() const
- {
- return m_originalName;
- }
- void setOriginalName(const QString &s)
- {
- m_originalName = s;
- }
+ QString originalName() const;
+ void setOriginalName(const QString &s);
- QString flagsName() const
- {
- return m_flagsName;
- }
- void setFlagsName(const QString &name)
- {
- m_flagsName = name;
- }
+ QString flagsName() const;
+ void setFlagsName(const QString &name);
- EnumTypeEntry *originator() const
- {
- return m_enum;
- }
- void setOriginator(EnumTypeEntry *e)
- {
- m_enum = e;
- }
+ EnumTypeEntry *originator() const;
+ void setOriginator(EnumTypeEntry *e);
TypeEntry *clone() const override;
protected:
- FlagsTypeEntry(const FlagsTypeEntry &);
+ explicit FlagsTypeEntry(FlagsTypeEntryPrivate *d);
QString buildTargetLangName() const override;
-
-private:
- QString m_originalName;
- QString m_flagsName;
- EnumTypeEntry *m_enum = nullptr;
};
// For primitive values, typically to provide a dummy type for
@@ -706,7 +473,7 @@ public:
TypeEntry *clone() const override;
protected:
- ConstantValueTypeEntry(const ConstantValueTypeEntry &);
+ explicit ConstantValueTypeEntry(TypeEntryPrivate *d);
};
class ComplexTypeEntry : public TypeEntry
@@ -731,143 +498,60 @@ public:
QString targetLangApiName() const override;
- void setTypeFlags(TypeFlags flags)
- {
- m_typeFlags = flags;
- }
-
- TypeFlags typeFlags() const
- {
- return m_typeFlags;
- }
+ TypeFlags typeFlags() const;
+ void setTypeFlags(TypeFlags flags);
- FunctionModificationList functionModifications() const
- {
- return m_functionMods;
- }
- void setFunctionModifications(const FunctionModificationList &functionModifications)
- {
- m_functionMods = functionModifications;
- }
- void addFunctionModification(const FunctionModification &functionModification)
- {
- m_functionMods << functionModification;
- }
+ FunctionModificationList functionModifications() const;
+ void setFunctionModifications(const FunctionModificationList &functionModifications);
+ void addFunctionModification(const FunctionModification &functionModification);
FunctionModificationList functionModifications(const QString &signature) const;
- AddedFunctionList addedFunctions() const
- {
- return m_addedFunctions;
- }
- void setAddedFunctions(const AddedFunctionList &addedFunctions)
- {
- m_addedFunctions = addedFunctions;
- }
- void addNewFunction(const AddedFunctionPtr &addedFunction)
- {
- m_addedFunctions << addedFunction;
- }
+ AddedFunctionList addedFunctions() const;
+ void setAddedFunctions(const AddedFunctionList &addedFunctions);
+ void addNewFunction(const AddedFunctionPtr &addedFunction);
FieldModification fieldModification(const QString &name) const;
- void setFieldModifications(const FieldModificationList &mods)
- {
- m_fieldMods = mods;
- }
- FieldModificationList fieldModifications() const
- {
- return m_fieldMods;
- }
+ void setFieldModifications(const FieldModificationList &mods);
+ FieldModificationList fieldModifications() const;
- const QList<TypeSystemProperty> &properties() const { return m_properties; }
- void addProperty(const TypeSystemProperty &p) { m_properties.append(p); }
-
- QString defaultSuperclass() const
- {
- return m_defaultSuperclass;
- }
- void setDefaultSuperclass(const QString &sc)
- {
- m_defaultSuperclass = sc;
- }
+ const QList<TypeSystemProperty> &properties() const;
+ void addProperty(const TypeSystemProperty &p);
- QString qualifiedCppName() const override
- {
- return m_qualifiedCppName;
- }
+ QString defaultSuperclass() const;
+ void setDefaultSuperclass(const QString &sc);
+ QString qualifiedCppName() const override;
- void setIsPolymorphicBase(bool on)
- {
- m_polymorphicBase = on;
- }
- bool isPolymorphicBase() const
- {
- return m_polymorphicBase;
- }
+ void setIsPolymorphicBase(bool on);
+ bool isPolymorphicBase() const;
- void setPolymorphicIdValue(const QString &value)
- {
- m_polymorphicIdValue = value;
- }
- QString polymorphicIdValue() const
- {
- return m_polymorphicIdValue;
- }
+ void setPolymorphicIdValue(const QString &value);
+ QString polymorphicIdValue() const;
- QString targetType() const
- {
- return m_targetType;
- }
- void setTargetType(const QString &code)
- {
- m_targetType = code;
- }
+ QString targetType() const;
+ void setTargetType(const QString &code);
- bool isGenericClass() const
- {
- return m_genericClass;
- }
- void setGenericClass(bool isGeneric)
- {
- m_genericClass = isGeneric;
- }
+ bool isGenericClass() const;
+ void setGenericClass(bool isGeneric);
- bool deleteInMainThread() const { return m_deleteInMainThread; }
- void setDeleteInMainThread(bool d) { m_deleteInMainThread = d; }
+ bool deleteInMainThread() const;
+ void setDeleteInMainThread(bool d);
- CopyableFlag copyable() const
- {
- return m_copyableFlag;
- }
- void setCopyable(CopyableFlag flag)
- {
- m_copyableFlag = flag;
- }
+ CopyableFlag copyable() const;
+ void setCopyable(CopyableFlag flag);
- QString hashFunction() const
- {
- return m_hashFunction;
- }
- void setHashFunction(const QString &hashFunction)
- {
- m_hashFunction = hashFunction;
- }
+ QString hashFunction() const;
+ void setHashFunction(const QString &hashFunction);
- void setBaseContainerType(const ComplexTypeEntry *baseContainer)
- {
- m_baseContainerType = baseContainer;
- }
+ void setBaseContainerType(const ComplexTypeEntry *baseContainer);
- const ComplexTypeEntry* baseContainerType() const
- {
- return m_baseContainerType;
- }
+ const ComplexTypeEntry *baseContainerType() const;
- TypeSystem::ExceptionHandling exceptionHandling() const { return m_exceptionHandling; }
- void setExceptionHandling(TypeSystem::ExceptionHandling e) { m_exceptionHandling = e; }
+ TypeSystem::ExceptionHandling exceptionHandling() const;
+ void setExceptionHandling(TypeSystem::ExceptionHandling e);
- TypeSystem::AllowThread allowThread() const { return m_allowThread; }
- void setAllowThread(TypeSystem::AllowThread allowThread) { m_allowThread = allowThread; }
+ TypeSystem::AllowThread allowThread() const;
+ void setAllowThread(TypeSystem::AllowThread allowThread);
QString defaultConstructor() const;
void setDefaultConstructor(const QString& defaultConstructor);
@@ -878,34 +562,10 @@ public:
void useAsTypedef(const ComplexTypeEntry *source);
#ifndef QT_NO_DEBUG_STREAM
- void formatDebug(QDebug &d) const override;
+ void formatDebug(QDebug &debug) const override;
#endif
protected:
- ComplexTypeEntry(const ComplexTypeEntry &);
-
-private:
- AddedFunctionList m_addedFunctions;
- FunctionModificationList m_functionMods;
- FieldModificationList m_fieldMods;
- QList<TypeSystemProperty> m_properties;
- QString m_defaultConstructor;
- QString m_defaultSuperclass;
- QString m_qualifiedCppName;
-
- uint m_polymorphicBase : 1;
- uint m_genericClass : 1;
- uint m_deleteInMainThread : 1;
-
- QString m_polymorphicIdValue;
- QString m_targetType;
- TypeFlags m_typeFlags;
- CopyableFlag m_copyableFlag = Unknown;
- QString m_hashFunction;
-
- const ComplexTypeEntry* m_baseContainerType = nullptr;
- // For class functions
- TypeSystem::ExceptionHandling m_exceptionHandling = TypeSystem::ExceptionHandling::Unspecified;
- TypeSystem::AllowThread m_allowThread = TypeSystem::AllowThread::Unspecified;
+ explicit ComplexTypeEntry(ComplexTypeEntryPrivate *d);
};
Q_DECLARE_OPERATORS_FOR_FLAGS(ComplexTypeEntry::TypeFlags)
@@ -918,27 +578,22 @@ public:
const QVersionNumber &vr,
const TypeEntry *parent);
- QString sourceType() const { return m_sourceType; }
- void setSourceType(const QString &s) { m_sourceType =s; }
+ QString sourceType() const;
+ void setSourceType(const QString &s);
TypeEntry *clone() const override;
- ComplexTypeEntry *source() const { return m_source; }
- void setSource(ComplexTypeEntry *source) { m_source = source; }
+ ComplexTypeEntry *source() const;
+ void setSource(ComplexTypeEntry *source);
- ComplexTypeEntry *target() const { return m_target; }
- void setTarget(ComplexTypeEntry *target) { m_target = target; }
+ ComplexTypeEntry *target() const;
+ void setTarget(ComplexTypeEntry *target);
#ifndef QT_NO_DEBUG_STREAM
void formatDebug(QDebug &d) const override;
#endif
protected:
- TypedefEntry(const TypedefEntry &);
-
-private:
- QString m_sourceType;
- ComplexTypeEntry *m_source = nullptr;
- ComplexTypeEntry *m_target = nullptr;
+ explicit TypedefEntry(TypedefEntryPrivate *d);
};
class ContainerTypeEntry : public ComplexTypeEntry
@@ -965,10 +620,7 @@ public:
explicit ContainerTypeEntry(const QString &entryName, ContainerKind containerKind,
const QVersionNumber &vr, const TypeEntry *parent);
- ContainerKind containerKind() const
- {
- return m_containerKind;
- }
+ ContainerKind containerKind() const;
QString typeName() const;
QString qualifiedCppName() const override;
@@ -979,10 +631,7 @@ public:
void formatDebug(QDebug &d) const override;
#endif
protected:
- ContainerTypeEntry(const ContainerTypeEntry &);
-
-private:
- ContainerKind m_containerKind;
+ explicit ContainerTypeEntry(ContainerTypeEntryPrivate *d);
};
class SmartPointerTypeEntry : public ComplexTypeEntry
@@ -997,33 +646,21 @@ public:
const QVersionNumber &vr,
const TypeEntry *parent);
- QString getter() const
- {
- return m_getterName;
- }
+ QString getter() const;
- QString refCountMethodName() const
- {
- return m_refCountMethodName;
- }
+ QString refCountMethodName() const;
TypeEntry *clone() const override;
- Instantiations instantiations() const { return m_instantiations; }
- void setInstantiations(const Instantiations &i) { m_instantiations = i; }
+ Instantiations instantiations() const;
+ void setInstantiations(const Instantiations &i);
bool matchesInstantiation(const TypeEntry *e) const;
#ifndef QT_NO_DEBUG_STREAM
void formatDebug(QDebug &d) const override;
#endif
protected:
- SmartPointerTypeEntry(const SmartPointerTypeEntry &);
-
-private:
- QString m_getterName;
- QString m_smartPointerType;
- QString m_refCountMethodName;
- Instantiations m_instantiations;
+ SmartPointerTypeEntry(SmartPointerTypeEntryPrivate *d);
};
class NamespaceTypeEntry : public ComplexTypeEntry
@@ -1034,22 +671,22 @@ public:
TypeEntry *clone() const override;
- const NamespaceTypeEntry *extends() const { return m_extends; }
- void setExtends(const NamespaceTypeEntry *e) { m_extends = e; }
+ const NamespaceTypeEntry *extends() const;
+ void setExtends(const NamespaceTypeEntry *e);
- const QRegularExpression &filePattern() const { return m_filePattern; } // restrict files
+ const QRegularExpression &filePattern() const; // restrict files
void setFilePattern(const QRegularExpression &r);
- bool hasPattern() const { return m_hasPattern; }
+ bool hasPattern() const;
bool matchesFile(const QString &needle) const;
bool isVisible() const;
- void setVisibility(TypeSystem::Visibility v) { m_visibility = v; }
+ void setVisibility(TypeSystem::Visibility v);
// C++ 11 inline namespace, from code model
- bool isInlineNamespace() const { return m_inlineNamespace; }
- void setInlineNamespace(bool i) { m_inlineNamespace = i; }
+ bool isInlineNamespace() const;
+ void setInlineNamespace(bool i);
static bool isVisibleScope(const TypeEntry *e);
@@ -1057,19 +694,12 @@ public:
void formatDebug(QDebug &d) const override;
#endif
- bool generateUsing() const { return m_generateUsing; }
- void setGenerateUsing(bool generateUsing) { m_generateUsing = generateUsing; }
+ // Whether to generate "using namespace" into wrapper
+ bool generateUsing() const;
+ void setGenerateUsing(bool generateUsing);
protected:
- NamespaceTypeEntry(const NamespaceTypeEntry &);
-
-private:
- QRegularExpression m_filePattern;
- const NamespaceTypeEntry *m_extends = nullptr;
- TypeSystem::Visibility m_visibility = TypeSystem::Visibility::Auto;
- bool m_hasPattern = false;
- bool m_inlineNamespace = false;
- bool m_generateUsing = true; // Whether to generate "using namespace" into wrapper
+ explicit NamespaceTypeEntry(NamespaceTypeEntryPrivate *d);
};
class ValueTypeEntry : public ComplexTypeEntry
@@ -1085,7 +715,7 @@ public:
protected:
explicit ValueTypeEntry(const QString &entryName, Type t, const QVersionNumber &vr,
const TypeEntry *parent);
- ValueTypeEntry(const ValueTypeEntry &);
+ explicit ValueTypeEntry(ComplexTypeEntryPrivate *d);
};
class FunctionTypeEntry : public TypeEntry
@@ -1094,28 +724,15 @@ public:
explicit FunctionTypeEntry(const QString& name, const QString& signature,
const QVersionNumber &vr,
const TypeEntry *parent);
- void addSignature(const QString& signature)
- {
- m_signatures << signature;
- }
- QStringList signatures() const
- {
- return m_signatures;
- }
-
- bool hasSignature(const QString& signature) const
- {
- return m_signatures.contains(signature);
- }
+ const QStringList &signatures() const;
+ bool hasSignature(const QString& signature) const;
+ void addSignature(const QString& signature);
TypeEntry *clone() const override;
protected:
- FunctionTypeEntry(const FunctionTypeEntry &);
-
-private:
- QStringList m_signatures;
+ explicit FunctionTypeEntry(FunctionTypeEntryPrivate *d);
};
class ObjectTypeEntry : public ComplexTypeEntry
@@ -1127,31 +744,9 @@ public:
TypeEntry *clone() const override;
protected:
- ObjectTypeEntry(const ObjectTypeEntry &);
+ explicit ObjectTypeEntry(ComplexTypeEntryPrivate *d);
};
-struct TypeRejection
-{
- enum MatchType
- {
- ExcludeClass, // Match className only
- Function, // Match className and function name
- Field, // Match className and field name
- Enum, // Match className and enum name
- ArgumentType, // Match className and argument type
- ReturnType, // Match className and return type
- Invalid
- };
-
- QRegularExpression className;
- QRegularExpression pattern;
- MatchType matchType = Invalid;
-};
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug d, const TypeRejection &r);
-#endif
-
class CustomConversion
{
public:
diff --git a/sources/shiboken6/ApiExtractor/typesystemparser.cpp b/sources/shiboken6/ApiExtractor/typesystemparser.cpp
index bb0cffdc0..04ecb4c93 100644
--- a/sources/shiboken6/ApiExtractor/typesystemparser.cpp
+++ b/sources/shiboken6/ApiExtractor/typesystemparser.cpp
@@ -30,6 +30,8 @@
#include "typedatabase.h"
#include "messages.h"
#include "reporthandler.h"
+#include "sourcelocation.h"
+
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
@@ -37,6 +39,7 @@
#include <QtCore/QSet>
#include <QtCore/QStringView>
#include <QtCore/QStringAlgorithms>
+#include <QtCore/QVersionNumber>
#include <QtCore/QXmlStreamAttributes>
#include <QtCore/QXmlStreamReader>
#include <QtCore/QXmlStreamEntityResolver>
diff --git a/sources/shiboken6/ApiExtractor/typesystemparser.h b/sources/shiboken6/ApiExtractor/typesystemparser.h
index 681ed7ae6..d85825552 100644
--- a/sources/shiboken6/ApiExtractor/typesystemparser.h
+++ b/sources/shiboken6/ApiExtractor/typesystemparser.h
@@ -29,11 +29,13 @@
#define TYPESYSTEMPARSER_H
#include "typesystem.h"
+#include "modifications.h"
#include <QtCore/QStack>
#include <QtCore/QHash>
#include <QtCore/QScopedPointer>
+QT_FORWARD_DECLARE_CLASS(QVersionNumber)
QT_FORWARD_DECLARE_CLASS(QXmlStreamAttributes)
QT_FORWARD_DECLARE_CLASS(QXmlStreamReader)
diff --git a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp
index 00d366394..7feaf5e1f 100644
--- a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp
@@ -33,6 +33,7 @@
#include <abstractmetafunction.h>
#include <abstractmetalang.h>
#include <messages.h>
+#include <modifications.h>
#include <propertyspec.h>
#include <reporthandler.h>
#include <typesystem.h>
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index 28994d073..bd0bef574 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -37,6 +37,7 @@
#include <abstractmetafunction.h>
#include <abstractmetalang.h>
#include <messages.h>
+#include <modifications.h>
#include <propertyspec.h>
#include <reporthandler.h>
#include <typedatabase.h>
diff --git a/sources/shiboken6/generator/shiboken/headergenerator.cpp b/sources/shiboken6/generator/shiboken/headergenerator.cpp
index 4456c9c7c..3d707318c 100644
--- a/sources/shiboken6/generator/shiboken/headergenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/headergenerator.cpp
@@ -31,6 +31,7 @@
#include <abstractmetafield.h>
#include <abstractmetafunction.h>
#include <abstractmetalang.h>
+#include <modifications.h>
#include <typedatabase.h>
#include <reporthandler.h>
#include <fileout.h>
diff --git a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp
index 8a2058443..d9733386f 100644
--- a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp
@@ -33,6 +33,7 @@
#include <abstractmetafunction.h>
#include <abstractmetalang.h>
#include <messages.h>
+#include <modifications.h>
#include "overloaddata.h"
#include "propertyspec.h"
#include <reporthandler.h>
diff --git a/sources/shiboken6/tests/dumpcodemodel/main.cpp b/sources/shiboken6/tests/dumpcodemodel/main.cpp
index 37c964fc0..872692651 100644
--- a/sources/shiboken6/tests/dumpcodemodel/main.cpp
+++ b/sources/shiboken6/tests/dumpcodemodel/main.cpp
@@ -37,6 +37,7 @@
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFile>
+#include <QtCore/QVersionNumber>
#include <QtCore/QXmlStreamWriter>
#include <iostream>