From faf7c506a451cef1dc8229a3779eb62796c93e5f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 29 Sep 2020 09:36:12 +0200 Subject: 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 --- .../shiboken2/generator/shiboken2/shibokengenerator.cpp | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'sources/shiboken2/generator/shiboken2/shibokengenerator.cpp') diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp index b2c762115..3606f0af0 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp @@ -334,20 +334,6 @@ bool ShibokenGenerator::shouldWriteVirtualMethodNative(const AbstractMetaFunctio && (func->attributes() & AbstractMetaAttributes::FinalCppMethod) == 0); } -void ShibokenGenerator::lookForEnumsInClassesNotToBeGenerated(AbstractMetaEnumList &enumList, const AbstractMetaClass *metaClass) -{ - Q_ASSERT(metaClass); - // if a scope is not to be generated, collect its enums into the parent scope - if (!NamespaceTypeEntry::isVisibleScope(metaClass->typeEntry())) { - for (AbstractMetaEnum *metaEnum : metaClass->enums()) { - if (!metaEnum->isPrivate() && metaEnum->typeEntry()->generateCode() - && !enumList.contains(metaEnum)) { - enumList.append(metaEnum); - } - } - } -} - QString ShibokenGenerator::wrapperName(const AbstractMetaClass *metaClass) const { Q_ASSERT(shouldGenerateCppWrapper(metaClass)); -- cgit v1.2.3 From 1e4c98eb237d174ed01ed3df2a0f2467fb5f09e0 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 29 Sep 2020 10:07:04 +0200 Subject: shiboken2: Generate functions from invisible top level namespaces as global functions Mainly add those in ShibokenGenerator::getGlobalFunctionGroups() with some adaptions. Task-number: PYSIDE-1075 Change-Id: I6dabac72c204904e76162542b5aa3ea1ac3b56ec Reviewed-by: Christian Tismer --- .../shiboken2/generator/shiboken2/shibokengenerator.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'sources/shiboken2/generator/shiboken2/shibokengenerator.cpp') diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp index 3606f0af0..3fa1eb646 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp @@ -2457,14 +2457,21 @@ static bool isGroupable(const AbstractMetaFunction *func) return true; } -ShibokenGenerator::FunctionGroups ShibokenGenerator::getGlobalFunctionGroups() const +static void insertIntoFunctionGroups(const AbstractMetaFunctionList &lst, + ShibokenGenerator::FunctionGroups *results) { - const AbstractMetaFunctionList &lst = globalFunctions(); - FunctionGroups results; for (AbstractMetaFunction *func : lst) { if (isGroupable(func)) - results[func->name()].append(func); + (*results)[func->name()].append(func); } +} + +ShibokenGenerator::FunctionGroups ShibokenGenerator::getGlobalFunctionGroups() const +{ + FunctionGroups results; + insertIntoFunctionGroups(globalFunctions(), &results); + for (auto nsp : invisibleTopNamespaces()) + insertIntoFunctionGroups(nsp->functions(), &results); return results; } -- cgit v1.2.3 From 46b43389c3f941415598db01cb8b19cc2450b424 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 29 Sep 2020 13:16:55 +0200 Subject: shiboken2: Generate functions from invisible namespaces into their parent namespaces Add them in ShibokenGenerator::getFunctionGroupsImpl() with some helpers. Fixes: PYSIDE-1075 Change-Id: Ie627c6e12f82e40cdb4f306ddac6b682e77124c5 Reviewed-by: Christian Tismer --- sources/shiboken2/generator/shiboken2/shibokengenerator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sources/shiboken2/generator/shiboken2/shibokengenerator.cpp') diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp index 3fa1eb646..4f3ca20c1 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp @@ -2495,7 +2495,8 @@ ShibokenGenerator::FunctionGroups ShibokenGenerator::getFunctionGroups(const Abs ShibokenGenerator::FunctionGroups ShibokenGenerator::getFunctionGroupsImpl(const AbstractMetaClass *scope) { - const AbstractMetaFunctionList &lst = scope->functions(); + AbstractMetaFunctionList lst = scope->functions(); + scope->getFunctionsFromInvisibleNamespacesToBeGenerated(&lst); FunctionGroups results; for (AbstractMetaFunction *func : lst) { -- cgit v1.2.3