diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-03-19 19:08:27 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-03-22 15:27:19 +0100 |
commit | 5bea8c440e5d64106102ad5a202220c016bb3964 (patch) | |
tree | 4fd80e661f51caad0d308746d6b17f4e843a5b86 | |
parent | a10efb90f048764527c1d26bc0362c6db8f4234e (diff) |
shiboken6: Fix comparison operators in namespaces
Change qtbase/e7fd9a9f4ab1fcc017174d6d7760c731857b89fc introduced some
mixed flag operators in Qt which caused compile errors. They should be
ignored by traverseOperatorFunction() since they cannot be attributed
to any class, but traverseOperatorFunction() was only called for the
global namespace. Fix by calling it for operator functions in
namespaces as well.
Task-number: QTBUG-99948
Pick-to: 6.2
Change-Id: I57419563f10f1a0d33aea027a166119f969bca5d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
5 files changed, 41 insertions, 1 deletions
diff --git a/sources/pyside6/PySide6/Qt3DRender/typesystem_3drender.xml b/sources/pyside6/PySide6/Qt3DRender/typesystem_3drender.xml index b7eb7b9c8..9f847e647 100644 --- a/sources/pyside6/PySide6/Qt3DRender/typesystem_3drender.xml +++ b/sources/pyside6/PySide6/Qt3DRender/typesystem_3drender.xml @@ -118,6 +118,11 @@ <object-type name="QGraphicsApiFilter"> <enum-type name="Api"/> <enum-type name="OpenGLProfile"/> + <!-- only Q_AUTOTEST_EXPORT --> + <modify-function signature="operator==(Qt3DRender::QGraphicsApiFilter,Qt3DRender::QGraphicsApiFilter)" + remove="all"/> + <modify-function signature="operator!=(Qt3DRender::QGraphicsApiFilter,Qt3DRender::QGraphicsApiFilter)" + remove="all"/> </object-type> <object-type name="QLayer"/> <object-type name="QLayerFilter"> diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp index 56df06bb6..4ff86583a 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp @@ -1301,8 +1301,11 @@ AbstractMetaFunctionRawPtrList AbstractMetaFunctionRawPtrList result; const FunctionList &scopeFunctionList = scopeItem->functions(); result.reserve(scopeFunctionList.size()); + const bool isNamespace = currentClass->isNamespace(); for (const FunctionModelItem &function : scopeFunctionList) { - if (AbstractMetaFunction *metaFunction = traverseFunction(function, currentClass)) { + if (isNamespace && function->isOperator()) { + traverseOperatorFunction(function, currentClass); + } else if (auto *metaFunction = traverseFunction(function, currentClass)) { result.append(metaFunction); } else if (function->functionType() == CodeModel::Constructor) { auto arguments = function->arguments(); diff --git a/sources/shiboken6/ApiExtractor/parser/codemodel.cpp b/sources/shiboken6/ApiExtractor/parser/codemodel.cpp index c8978ba8d..c275db2b6 100644 --- a/sources/shiboken6/ApiExtractor/parser/codemodel.cpp +++ b/sources/shiboken6/ApiExtractor/parser/codemodel.cpp @@ -941,6 +941,31 @@ bool _FunctionModelItem::isNoExcept() const return m_exceptionSpecification == ExceptionSpecification::NoExcept; } +bool _FunctionModelItem::isOperator() const +{ + bool result = false; + switch (m_functionType) { + case CodeModel::CallOperator: + case CodeModel::ConversionOperator: + case CodeModel::DereferenceOperator: + case CodeModel::ReferenceOperator: + case CodeModel::ArrowOperator: + case CodeModel::ArithmeticOperator: + case CodeModel::IncrementOperator: + case CodeModel::DecrementOperator: + case CodeModel::BitwiseOperator: + case CodeModel::LogicalOperator: + case CodeModel::ShiftOperator: + case CodeModel::SubscriptOperator: + case CodeModel::ComparisonOperator: + result = true; + break; + default: + break; + } + return result; +} + ExceptionSpecification _FunctionModelItem::exceptionSpecification() const { return m_exceptionSpecification; diff --git a/sources/shiboken6/ApiExtractor/parser/codemodel.h b/sources/shiboken6/ApiExtractor/parser/codemodel.h index 69e30287b..50380da8b 100644 --- a/sources/shiboken6/ApiExtractor/parser/codemodel.h +++ b/sources/shiboken6/ApiExtractor/parser/codemodel.h @@ -544,6 +544,8 @@ public: bool isNoExcept() const; + bool isOperator() const; + ExceptionSpecification exceptionSpecification() const; void setExceptionSpecification(ExceptionSpecification e); diff --git a/sources/shiboken6/tests/samplebinding/sample_test.py b/sources/shiboken6/tests/samplebinding/sample_test.py index ec97658c8..660a3cd3d 100644 --- a/sources/shiboken6/tests/samplebinding/sample_test.py +++ b/sources/shiboken6/tests/samplebinding/sample_test.py @@ -80,6 +80,11 @@ class ModuleTest(unittest.TestCase): self.assertEqual(sample.countVarargs(1, 2), 1) self.assertEqual(sample.countVarargs(1, 2, 3, 'a', 'b', 4, (5, 6)), 6) + def testSampleComparisonOpInNamespace(self): + s1 = sample.sample.sample(10) + s2 = sample.sample.sample(10) + self.assertEqual(s1, s2) + def testConstant(self): self.assertEqual(sample.sample.INT_CONSTANT, 42) |