aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/ApiExtractor/typedatabase.h
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/ApiExtractor/typedatabase.h')
-rw-r--r--sources/shiboken6/ApiExtractor/typedatabase.h182
1 files changed, 71 insertions, 111 deletions
diff --git a/sources/shiboken6/ApiExtractor/typedatabase.h b/sources/shiboken6/ApiExtractor/typedatabase.h
index 082d833b5..d5adca324 100644
--- a/sources/shiboken6/ApiExtractor/typedatabase.h
+++ b/sources/shiboken6/ApiExtractor/typedatabase.h
@@ -1,64 +1,30 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt for Python.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef TYPEDATABASE_H
#define TYPEDATABASE_H
#include "include.h"
+#include "modifications_typedefs.h"
#include "typedatabase_typedefs.h"
-#include "typesystem_enums.h"
-#include "typesystem_typedefs.h"
#include <QtCore/QRegularExpression>
#include <QtCore/QStringList>
#include <QtCore/QVersionNumber>
-QT_FORWARD_DECLARE_CLASS(QIODevice)
+#include <memory>
-class ComplexTypeEntry;
-class ContainerTypeEntry;
-class FlagsTypeEntry;
-class FunctionTypeEntry;
-class NamespaceTypeEntry;
-class ObjectTypeEntry;
-class TemplateEntry;
-class TypeEntry;
+QT_FORWARD_DECLARE_CLASS(QIODevice)
-struct TypeRejection;
+struct OptionDescription;
+class OptionsParser;
+struct TypeDatabasePrivate;
+struct TypeDatabaseParserContext;
QT_FORWARD_DECLARE_CLASS(QDebug)
int getMaxTypeIndex();
-class ContainerTypeEntry;
-class PrimitiveTypeEntry;
-class TypeSystemTypeEntry;
-
struct VersionRange
{
bool isNull() const
@@ -85,7 +51,9 @@ struct TypeRejection
QRegularExpression className;
QRegularExpression pattern;
- MatchType matchType;
+ MatchType matchType = ExcludeClass;
+ bool generate; // Current type system
+ mutable bool matched = false;
};
#ifndef QT_NO_DEBUG_STREAM
@@ -95,10 +63,14 @@ QDebug operator<<(QDebug d, const TypeRejection &r);
class TypeDatabase
{
TypeDatabase();
- Q_DISABLE_COPY(TypeDatabase)
public:
+ Q_DISABLE_COPY_MOVE(TypeDatabase)
+
~TypeDatabase();
+ static QList<OptionDescription> options();
+ std::shared_ptr<OptionsParser> createOptionsParser();
+
/**
* Return the type system instance.
* \param newInstance This parameter is useful just for unit testing, because singletons causes
@@ -107,44 +79,45 @@ public:
static TypeDatabase *instance(bool newInstance = false);
static QString normalizedSignature(const QString &signature);
+ static QString normalizedAddedFunctionSignature(const QString &signature);
QStringList requiredTargetImports() const;
void addRequiredTargetImport(const QString &moduleName);
- void addTypesystemPath(const QString &typesystem_paths);
-
- void setTypesystemKeywords(const QStringList &keywords) { m_typesystemKeywords = keywords; }
QStringList typesystemKeywords() const;
IncludeList extraIncludes(const QString &className) const;
- const QByteArrayList &systemIncludes() const { return m_systemIncludes; }
- void addSystemInclude(const QString &name);
+ const QStringList &forceProcessSystemIncludes() const;
+ void addForceProcessSystemInclude(const QString &name);
- void addInlineNamespaceLookups(const NamespaceTypeEntry *n);
+ void addInlineNamespaceLookups(const NamespaceTypeEntryCPtr &n);
- PrimitiveTypeEntry *findPrimitiveType(const QString &name) const;
- ComplexTypeEntry *findComplexType(const QString &name) const;
- ObjectTypeEntry *findObjectType(const QString &name) const;
+ PrimitiveTypeEntryPtr findPrimitiveType(const QString &name) const;
+ ComplexTypeEntryPtr findComplexType(const QString &name) const;
+ ObjectTypeEntryPtr findObjectType(const QString &name) const;
NamespaceTypeEntryList findNamespaceTypes(const QString &name) const;
- NamespaceTypeEntry *findNamespaceType(const QString &name, const QString &fileName = QString()) const;
- ContainerTypeEntry *findContainerType(const QString &name) const;
- FunctionTypeEntry *findFunctionType(const QString &name) const;
- const TypeSystemTypeEntry *findTypeSystemType(const QString &name) const;
- const TypeSystemTypeEntry *defaultTypeSystemType() const;
+ NamespaceTypeEntryPtr findNamespaceType(const QString &name, const QString &fileName = QString()) const;
+ ContainerTypeEntryPtr findContainerType(const QString &name) const;
+ FunctionTypeEntryPtr findFunctionType(const QString &name) const;
+ TypeSystemTypeEntryCPtr findTypeSystemType(const QString &name) const;
+ TypeSystemTypeEntryCPtr defaultTypeSystemType() const;
+ QString loadedTypeSystemNames() const;
QString defaultPackageName() const;
- TypeEntry *findType(const QString &name) const;
- TypeEntries findTypes(const QString &name) const;
- TypeEntries findCppTypes(const QString &name) const;
+ TypeEntryPtr findType(const QString &name) const;
+ TypeEntryCList findTypes(const QString &name) const;
+ TypeEntryCList findCppTypes(const QString &name) const;
- const TypeEntryMultiMap &entries() const { return m_entries; }
- const TypedefEntryMap &typedefEntries() const { return m_typedefEntries; }
+ const TypeEntryMultiMap &entries() const;
+ const TypedefEntryMap &typedefEntries() const;
- PrimitiveTypeEntryList primitiveTypes() const;
+ PrimitiveTypeEntryCList primitiveTypes() const;
- ContainerTypeEntryList containerTypes() const;
+ ContainerTypeEntryCList containerTypes() const;
+
+ SmartPointerTypeEntryList smartPointerTypes() const;
void addRejection(const TypeRejection &);
bool isClassRejected(const QString &className, QString *reason = nullptr) const;
@@ -159,19 +132,24 @@ public:
bool isReturnTypeRejected(const QString &className, const QString &typeName,
QString *reason = nullptr) const;
- bool addType(TypeEntry *e, QString *errorMessage = nullptr);
- ConstantValueTypeEntry *addConstantValueTypeEntry(const QString &value,
- const TypeEntry *parent);
- void addTypeSystemType(const TypeSystemTypeEntry *e);
+ bool addType(const TypeEntryPtr &e, QString *errorMessage = nullptr);
+ ConstantValueTypeEntryPtr addConstantValueTypeEntry(const QString &value,
+ const TypeEntryCPtr &parent);
+ void addTypeSystemType(const TypeSystemTypeEntryCPtr &e);
+
+ static ComplexTypeEntryPtr
+ initializeTypeDefEntry(const TypedefEntryPtr &typedefEntry,
+ const ComplexTypeEntryCPtr &source);
- FlagsTypeEntry *findFlagsType(const QString &name) const;
- void addFlagsType(FlagsTypeEntry *fte);
+ FlagsTypeEntryPtr findFlagsType(const QString &name) const;
+ void addFlagsType(const FlagsTypeEntryPtr &fte);
- TemplateEntry *findTemplate(const QString &name) const { return m_templates[name]; }
+ TemplateEntryPtr findTemplate(const QString &name) const;
- void addTemplate(TemplateEntry *t);
+ void addTemplate(const TemplateEntryPtr &t);
+ void addTemplate(const QString &name, const QString &code);
- AddedFunctionList globalUserFunctions() const { return m_globalUserFunctions; }
+ AddedFunctionList globalUserFunctions() const;
void addGlobalUserFunctions(const AddedFunctionList &functions);
@@ -179,69 +157,51 @@ public:
void addGlobalUserFunctionModifications(const FunctionModificationList &functionModifications);
- FunctionModificationList functionModifications(const QString &signature) const;
-
- void setSuppressWarnings(bool on) { m_suppressWarnings = on; }
+ FunctionModificationList
+ globalFunctionModifications(const QStringList &signatures) const;
- bool addSuppressedWarning(const QString &warning, QString *errorMessage);
+ bool addSuppressedWarning(const QString &warning, bool generate, QString *errorMessage);
bool isSuppressedWarning(QStringView s) const;
- static QString globalNamespaceClassName(const TypeEntry *te);
+ static QString globalNamespaceClassName(const TypeEntryCPtr &te);
+ // Top level file parsing
bool parseFile(const QString &filename, bool generate = true);
- bool parseFile(const QString &filename, const QString &currentPath, bool generate);
+ bool parseFile(const std::shared_ptr<TypeDatabaseParserContext> &context,
+ const QString &filename, const QString &currentPath, bool generate);
+ // Top level QIODevice parsing for tests.
bool parseFile(QIODevice *device, bool generate = true);
+ bool parseFile(const std::shared_ptr<TypeDatabaseParserContext> &context,
+ QIODevice *device, bool generate = true);
static bool setApiVersion(const QString &package, const QString &version);
static void clearApiVersions();
static bool checkApiVersion(const QString &package, const VersionRange &vr);
- bool hasDroppedTypeEntries() const { return !m_dropTypeEntries.isEmpty(); }
+ bool hasDroppedTypeEntries() const;
bool shouldDropTypeEntry(const QString &fullTypeName) const;
- void setDropTypeEntries(QStringList dropTypeEntries);
+ void setDropTypeEntries(const QStringList &dropTypeEntries);
QString modifiedTypesystemFilepath(const QString &tsFile, const QString &currentPath = QString()) const;
+ void logUnmatched() const;
+
#ifndef QT_NO_DEBUG_STREAM
void formatDebug(QDebug &d) const;
#endif
+ void formatBuiltinTypes(QDebug debug) const;
+
private:
- TypeEntryMultiMapConstIteratorRange findTypeRange(const QString &name) const;
- template <class Predicate>
- TypeEntries findTypesHelper(const QString &name, Predicate pred) const;
- TypeEntry *resolveTypeDefEntry(TypedefEntry *typedefEntry, QString *errorMessage);
- template <class String>
- bool isSuppressedWarningHelper(const String &s) const;
-
- bool m_suppressWarnings = true;
- TypeEntryMultiMap m_entries; // Contains duplicate entries (cf addInlineNamespaceLookups).
- TypeEntryMap m_flagsEntries;
- TypedefEntryMap m_typedefEntries;
- TemplateEntryMap m_templates;
- QList<QRegularExpression> m_suppressedWarnings;
- QList<const TypeSystemTypeEntry *> m_typeSystemEntries; // maintain order, default is first.
-
- AddedFunctionList m_globalUserFunctions;
- FunctionModificationList m_functionMods;
-
- QStringList m_requiredTargetImports;
-
- QStringList m_typesystemPaths;
- QStringList m_typesystemKeywords;
- QHash<QString, bool> m_parsedTypesystemFiles;
-
- QList<TypeRejection> m_rejections;
-
- QStringList m_dropTypeEntries;
- QByteArrayList m_systemIncludes;
+ TypeDatabasePrivate *d;
};
#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const TypeEntryCPtr &te);
QDebug operator<<(QDebug d, const TypeEntry *te);
QDebug operator<<(QDebug d, const TypeDatabase &db);
#endif