aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2024-04-29 07:40:28 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2024-04-30 09:50:13 +0200
commitca3019f8a675544c788cd05177c8de84c33d2aec (patch)
treec8e105561aca64511241fbe30d761bfa64ca2980
parent0fdd1cfb4793ff1aaad5d66670d1b1beff23bc75 (diff)
shiboken6: Simplify code in argument pointer conversion
Shiboken::Object::newObject() ignores the type name passed in when exactType=true, do not generate code to determine and allocate the type name in that case. Amends e254c3c2aa140016e298107a0297885234abfde7. Pick-to: 6.7 Task-number: PYSIDE-868 Change-Id: Icae92bab0ab0358c93601d4f57180fb1bf0c4269 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index 6594a7365..84d3c93d3 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -1639,7 +1639,7 @@ void CppGenerator::writeConverterFunctions(TextStream &s, const AbstractMetaClas
<< "if (pyOut) {\n" << indent
<< "Py_INCREF(pyOut);\nreturn pyOut;\n" << outdent
<< "}\n"
- << "bool changedTypeName = false;\n"
+ << "bool exactType = false;\n"
<< "auto *tCppIn = reinterpret_cast<const " << typeName << R"( *>(cppIn);
const char *typeName = )";
@@ -1649,15 +1649,11 @@ const char *typeName = )";
else
c << nameFunc << "(tCppIn);\n";
c << R"(auto *sbkType = Shiboken::ObjectType::typeForTypeName(typeName);
-if (sbkType != nullptr && Shiboken::ObjectType::hasSpecialCastFunction(sbkType)) {
- typeName = Shiboken::typeNameOf(typeid(*tCppIn).name());
- changedTypeName = true;
-}
+if (sbkType != nullptr && Shiboken::ObjectType::hasSpecialCastFunction(sbkType))
+ exactType = true;
)"
<< "PyObject *result = Shiboken::Object::newObject(" << cpythonType
- << R"(, const_cast<void *>(cppIn), false, /* exactType */ changedTypeName, typeName);
-if (changedTypeName)
- delete [] typeName;
+ << R"(, const_cast<void *>(cppIn), false, exactType, typeName);
return result;)";
}
std::swap(targetTypeName, sourceTypeName);