aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/generator/shiboken/cppgenerator.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-09-11 14:34:10 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-09-20 12:45:03 +0200
commitc04a2492fe54776a58d72f34282a05e5f9e1158d (patch)
treeaeeaf28de7a322d839e276e872207e9c603ab579 /sources/shiboken6/generator/shiboken/cppgenerator.cpp
parentb550babdf405dc513199713384a010b66126ebd6 (diff)
shiboken6: Move the finding of bool casts into the class cache
Finding the right function for implementing nb_bool is a lengthy function; move it into the static class cache for access by the header and source generators. Change-Id: I1c7a32ffe115f612b84a6091487e51ba5b7f1247 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> (cherry picked from commit f4d3b539e8938225faebdade31009116d737bd8c) Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'sources/shiboken6/generator/shiboken/cppgenerator.cpp')
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp42
1 files changed, 0 insertions, 42 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index 71f8576cd..dac4ab994 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -197,48 +197,6 @@ QString CppGenerator::fileNameForContext(const GeneratorContext &context) const
return fileNameForContextHelper(context, u"_wrapper.cpp"_s);
}
-CppGenerator::BoolCastFunctionOptional
- CppGenerator::boolCast(const AbstractMetaClassCPtr &metaClass) const
-{
- const auto te = metaClass->typeEntry();
- if (te->isSmartPointer()) {
- auto ste = std::static_pointer_cast<const SmartPointerTypeEntry>(te);
-
- auto valueCheckMethod = ste->valueCheckMethod();
- if (!valueCheckMethod.isEmpty()) {
- const auto func = metaClass->findFunction(valueCheckMethod);
- if (!func)
- throw Exception(msgMethodNotFound(metaClass, valueCheckMethod));
- return BoolCastFunction{func, false};
- }
-
- auto nullCheckMethod = ste->nullCheckMethod();
- if (!nullCheckMethod.isEmpty()) {
- const auto func = metaClass->findFunction(nullCheckMethod);
- if (!func)
- throw Exception(msgMethodNotFound(metaClass, nullCheckMethod));
- return BoolCastFunction{func, true};
- }
- }
-
- auto mode = te->operatorBoolMode();
- if (useOperatorBoolAsNbNonZero()
- ? mode != TypeSystem::BoolCast::Disabled : mode == TypeSystem::BoolCast::Enabled) {
- const auto func = metaClass->findOperatorBool();
- if (func)
- return BoolCastFunction{func, false};
- }
-
- mode = te->isNullMode();
- if (useIsNullAsNbNonZero()
- ? mode != TypeSystem::BoolCast::Disabled : mode == TypeSystem::BoolCast::Enabled) {
- const auto func = metaClass->findQtIsNullMethod();
- if (func)
- return BoolCastFunction{func, true};
- }
- return std::nullopt;
-}
-
std::optional<AbstractMetaType>
CppGenerator::findSmartPointerInstantiation(const SmartPointerTypeEntryCPtr &pointer,
const TypeEntryCPtr &pointee) const