aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-29 13:16:55 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-30 13:09:42 +0200
commit46b43389c3f941415598db01cb8b19cc2450b424 (patch)
tree03da12f3b0b5d33cf66dac1790502f8687ee7c9f /sources
parent1e4c98eb237d174ed01ed3df2a0f2467fb5f09e0 (diff)
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 <tismer@stackless.com>
Diffstat (limited to 'sources')
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.cpp9
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.h2
-rw-r--r--sources/shiboken2/generator/shiboken2/shibokengenerator.cpp3
-rw-r--r--sources/shiboken2/tests/libsample/removednamespaces.h2
-rw-r--r--sources/shiboken2/tests/samplebinding/enumfromremovednamespace_test.py3
5 files changed, 18 insertions, 1 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
index 38fb5f152..80ec20b46 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp
@@ -2159,6 +2159,15 @@ void AbstractMetaClass::getEnumsFromInvisibleNamespacesToBeGenerated(AbstractMet
}
}
+void AbstractMetaClass::getFunctionsFromInvisibleNamespacesToBeGenerated(AbstractMetaFunctionList *funcList) const
+{
+ if (isNamespace()) {
+ invisibleNamespaceRecursion([funcList](AbstractMetaClass *c) {
+ funcList->append(c->functions());
+ });
+ }
+}
+
static void addExtraIncludeForType(AbstractMetaClass *metaClass, const AbstractMetaType *type)
{
if (!type)
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.h b/sources/shiboken2/ApiExtractor/abstractmetalang.h
index 91a6138d1..dcc3e58d6 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang.h
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.h
@@ -1432,6 +1432,8 @@ public:
void getEnumsToBeGenerated(AbstractMetaEnumList *enumList) const;
void getEnumsFromInvisibleNamespacesToBeGenerated(AbstractMetaEnumList *enumList) const;
+ void getFunctionsFromInvisibleNamespacesToBeGenerated(AbstractMetaFunctionList *funcList) const;
+
QString fullName() const
{
return package() + QLatin1Char('.') + name();
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) {
diff --git a/sources/shiboken2/tests/libsample/removednamespaces.h b/sources/shiboken2/tests/libsample/removednamespaces.h
index e46bd2c15..47c18c049 100644
--- a/sources/shiboken2/tests/libsample/removednamespaces.h
+++ b/sources/shiboken2/tests/libsample/removednamespaces.h
@@ -65,6 +65,8 @@ namespace RemovedNamespace3
enum { RemovedNamespace3_AnonymousEnum_Value0 };
+ inline int nestedMathSum(int x, int y) { return x + y; }
+
} // namespace RemovedNamespace3
} // namespace UnremovedNamespace
diff --git a/sources/shiboken2/tests/samplebinding/enumfromremovednamespace_test.py b/sources/shiboken2/tests/samplebinding/enumfromremovednamespace_test.py
index 45d4156c4..fc1da5d8a 100644
--- a/sources/shiboken2/tests/samplebinding/enumfromremovednamespace_test.py
+++ b/sources/shiboken2/tests/samplebinding/enumfromremovednamespace_test.py
@@ -74,6 +74,9 @@ class TestEnumFromRemovedNamespace(unittest.TestCase):
sample.UnremovedNamespace.RemovedNamespace3_Enum_Value0
sample.UnremovedNamespace.RemovedNamespace3_AnonymousEnum_Value0
+ def testNestedFunctionFromRemovedNamespace(self):
+ self.assertEqual(sample.UnremovedNamespace.nestedMathSum(1, 2), 3)
+
if __name__ == '__main__':
unittest.main()