diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-09-01 08:36:05 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-09-21 12:09:19 +0200 |
commit | 919c05013eaf74a51948531fc5e2b70cdb28d3ee (patch) | |
tree | b8eab867fbae9856d7171856129f365ceff7a655 | |
parent | 81bcde91818d3cf36c3f1c95a448a10de8aca4ad (diff) |
shiboken6: Simplify code handling __bool__
It looks like Py_nb_nonzero is also a Python 2 constant.
Complements 890db123f72af6093bac085d0a0e33432fb8d8bb.
Task-number: PYSIDE-2446
Change-Id: Ifa347716ae9c801be1b923828fd5a26689b423e7
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit 1a19663aa7c19260e7e2d2078a45b474dcc98d3a)
Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
-rw-r--r-- | sources/shiboken6/generator/shiboken/cppgenerator.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index 961d410a4..e4aaad78b 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -4897,7 +4897,7 @@ static const QHash<QString, QString> &nbFuncs() {u"__iand__"_s, u"Py_nb_inplace_and"_s}, {u"__ixor__"_s, u"Py_nb_inplace_xor"_s}, {u"__ior__"_s, u"Py_nb_inplace_or"_s}, - {boolT(), u"Py_nb_nonzero"_s} + {u"__bool__"_s, u"Py_nb_bool"_s} }; return result; } @@ -4916,16 +4916,13 @@ void CppGenerator::writeTypeAsNumberDefinition(TextStream &s, const AbstractMeta QString baseName = cpythonBaseName(metaClass); if (hasBoolCast(metaClass)) - nb.insert(boolT(), baseName + u"___nb_bool"_s); + nb.insert(u"__bool__"_s, baseName + u"___nb_bool"_s); for (auto it = nbFuncs().cbegin(), end = nbFuncs().cend(); it != end; ++it) { const QString &nbName = it.key(); const auto nbIt = nb.constFind(nbName); - if (nbIt != nb.constEnd()) { - const QString fixednbName = nbName == boolT() - ? u"Py_nb_bool"_s : it.value(); - s << pyTypeSlotEntry(fixednbName, nbIt.value()); - } + if (nbIt != nb.constEnd()) + s << pyTypeSlotEntry(it.value(), nbIt.value()); } } |