diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-09-08 14:11:27 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-09-08 16:34:06 +0200 |
commit | 6dcbbcc08895e3565f95570842f666050aef61a1 (patch) | |
tree | 3ed4ce1d30f241f48b0a49ac5e17f95148f191b6 /sources/shiboken6/generator/shiboken/cppgenerator.cpp | |
parent | 61fb8894ff8402cbb34c9dca114f4037b70beb82 (diff) |
shiboken6: Fix generated code indentation in writePythonToCppTypeConversion()
Add indentation in case the conversion function needs to
be checked and explanatory comment.
Task-number: PYSIDE-1605
Change-Id: If992d2a06590d434e3dbec8326e4231da302b335
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6/generator/shiboken/cppgenerator.cpp')
-rw-r--r-- | sources/shiboken6/generator/shiboken/cppgenerator.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index 806a1e895..d2237b973 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -2651,34 +2651,34 @@ void CppGenerator::writePythonToCppTypeConversion(TextStream &s, QString pythonToCppFunc = pythonToCppConverterForArgumentName(pyIn); - if (!defaultValue.isEmpty()) - s << "if (" << pythonToCppFunc << ") "; - QString pythonToCppCall = pythonToCppFunc + u'(' + pyIn + u", &"_qs + cppOut + u')'; if (!mayHaveImplicitConversion) { + // pythonToCppFunc may be 0 when less parameters are passed and + // the defaultValue takes effect. + if (!defaultValue.isEmpty()) + s << "if (" << pythonToCppFunc << ")\n" << indent; s << pythonToCppCall << ";\n"; + if (!defaultValue.isEmpty()) + s << outdent; return; } + // pythonToCppFunc may be 0 when less parameters are passed and + // the defaultValue takes effect. if (!defaultValue.isEmpty()) - s << "{\n"; + s << "if (" << pythonToCppFunc << ") {\n" << indent; s << "if (Shiboken::Conversions::isImplicitConversion(reinterpret_cast<SbkObjectType *>(" - << cpythonTypeNameExt(type) << "), " << pythonToCppFunc << "))\n"; - { - Indentation indent(s); - s << pythonToCppFunc << '(' << pyIn << ", &" << cppOutAux << ");\n"; - } - s << "else\n"; - { - Indentation indent(s); - s << pythonToCppCall << ";\n"; - } + << cpythonTypeNameExt(type) << "), " << pythonToCppFunc << "))\n" + << indent << pythonToCppFunc << '(' << pyIn << ", &" << cppOutAux << ");\n" + << outdent << "else\n" << indent + << pythonToCppCall << ";\n" << outdent; - if (!defaultValue.isEmpty()) - s << '}'; - s << '\n'; + if (defaultValue.isEmpty()) + s << '\n'; + else + s << "}\n" << outdent; } static void addConversionRuleCodeSnippet(CodeSnipList &snippetList, QString &rule, |