diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-11-01 10:35:06 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-11-10 16:13:01 +0100 |
commit | 216319f83d33b0287a14a9de5512859946e11626 (patch) | |
tree | 97722861fb1999de180a1026d98190e1e734d23a | |
parent | 8e74bfa9558476007c59abc52eb776af3c1626c7 (diff) |
shiboken6: Introduce a test mode for the code model
Add a flag that causes the AbstractMetaBuilder to not clear the
code model after a run for testing purposes.
As drive-by, clear out the code model scope, fully releasing
the code model after building.
Task-number: PYSIDE-1691
Change-Id: I883805f0ee1866ff8864811d9e29d17b181096bd
Reviewed-by: Christian Tismer <tismer@stackless.com>
(cherry picked from commit 29d41de05abcfc1dbe3eb2125ab518655aecb326)
-rw-r--r-- | sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp | 15 | ||||
-rw-r--r-- | sources/shiboken6/ApiExtractor/abstractmetabuilder.h | 1 | ||||
-rw-r--r-- | sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h | 1 |
3 files changed, 14 insertions, 3 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp index e4527c518..b46b60fee 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp @@ -74,6 +74,7 @@ static void fixArgumentIndexes(AbstractMetaArgumentList *list) } bool AbstractMetaBuilderPrivate::m_useGlobalHeader = false; +bool AbstractMetaBuilderPrivate::m_codeModelTestMode = false; AbstractMetaBuilderPrivate::AbstractMetaBuilderPrivate() : m_logDirectory(QLatin1String(".") + QDir::separator()) @@ -645,9 +646,12 @@ void AbstractMetaBuilderPrivate::traverseDom(const FileModelItem &dom) throw Exception(errorMessage); } - m_itemToClass.clear(); - m_classToItem.clear(); - m_typeSystemTypeDefs.clear(); + if (!m_codeModelTestMode) { + m_itemToClass.clear(); + m_classToItem.clear(); + m_typeSystemTypeDefs.clear(); + m_scopes.clear(); + } ReportHandler::endProgress(); } @@ -2528,6 +2532,11 @@ QString AbstractMetaBuilder::fixEnumDefault(const AbstractMetaType &type, return d->fixEnumDefault(type, expr); } +void AbstractMetaBuilder::setCodeModelTestMode(bool b) +{ + AbstractMetaBuilderPrivate::m_codeModelTestMode = b; +} + // see TestResolveType::testFixDefaultArguments() QString AbstractMetaBuilderPrivate::fixDefaultValue(QString expr, const AbstractMetaType &type, const AbstractMetaClass *implementingClass) const diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.h b/sources/shiboken6/ApiExtractor/abstractmetabuilder.h index a49b9139c..c3e427965 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.h +++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.h @@ -117,6 +117,7 @@ public: const AbstractMetaClass *) const; QString fixEnumDefault(const AbstractMetaType &type, const QString &expr) const; + static void setCodeModelTestMode(bool b); #ifndef QT_NO_DEBUG_STREAM void formatDebug(QDebug &d) const; diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h b/sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h index 06203ba5a..cb835e201 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h +++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder_p.h @@ -220,6 +220,7 @@ public: QList<TypeClassEntry> m_typeSystemTypeDefs; // look up metatype->class for type system typedefs bool m_skipDeprecated = false; static bool m_useGlobalHeader; + static bool m_codeModelTestMode; }; #endif // ABSTRACTMETBUILDER_P_H |