aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-29 09:36:12 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-30 13:08:58 +0200
commitfaf7c506a451cef1dc8229a3779eb62796c93e5f (patch)
treea7064dd88244a74bca9c467f6f4c1e6bda599bcb /sources/shiboken2/ApiExtractor/abstractmetalang.cpp
parent433fbf103e96ba62eedcd563d5a8c71f4e5cd5a0 (diff)
shiboken2: Refactor handling of invisible top level namespaces
To avoid having to add a ShibokenGenerator::lookForFunctionsInClassesNotToBeGenerated() to fix the function issue, replace ShibokenGenerator::lookForEnumsInClassesNotToBeGenerated() by several helper functions: - Add a list of top level invisible namespace to the generators - Add functions to retrieve enumerations of nested invisible namespaces to AbstractMetaClass with recursion helpers. Task-number: PYSIDE-1075 Change-Id: I421113770e622611caeb221498b872d0a6ba1aeb Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/abstractmetalang.cpp')
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
index 2c693c70e..29c2f153d 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
@@ -1637,6 +1637,14 @@ bool AbstractMetaClass::isNamespace() const
return m_typeEntry->isNamespace();
}
+// Is an invisible namespaces whose functions/enums
+// should be mapped to the global space.
+bool AbstractMetaClass::isInvisibleNamespace() const
+{
+ return m_typeEntry->isNamespace() && m_typeEntry->generateCode()
+ && !NamespaceTypeEntry::isVisibleScope(m_typeEntry);
+}
+
static bool qObjectPredicate(const AbstractMetaClass *c)
{
return c->qualifiedCppName() == QLatin1String("QObject");
@@ -2128,6 +2136,22 @@ AbstractMetaEnumValue *AbstractMetaClass::findEnumValue(const QString &enumValue
return nullptr;
}
+void AbstractMetaClass::getEnumsToBeGenerated(AbstractMetaEnumList *enumList) const
+{
+ for (AbstractMetaEnum *metaEnum : m_enums) {
+ if (!metaEnum->isPrivate() && metaEnum->typeEntry()->generateCode())
+ enumList->append(metaEnum);
+ }
+}
+
+void AbstractMetaClass::getEnumsFromInvisibleNamespacesToBeGenerated(AbstractMetaEnumList *enumList) const
+{
+ if (isNamespace()) {
+ invisibleNamespaceRecursion([enumList](AbstractMetaClass *c) {
+ c->getEnumsToBeGenerated(enumList);
+ });
+ }
+}
static void addExtraIncludeForType(AbstractMetaClass *metaClass, const AbstractMetaType *type)
{