diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-09-09 11:06:33 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-09-10 17:36:04 +0200 |
commit | 42b82d953f2d2b85d15a6ce59e77fea885b67932 (patch) | |
tree | bcf1a3b98f38cc190f25168bb88f8a5d7677c508 /sources/shiboken6/generator/shiboken/cppgenerator.cpp | |
parent | fabf40e4dce39a8427480ca6836ae3e806368eee (diff) |
shiboken6: Add helper to write setting the pointer conversion
Task-number: PYSIDE-1605
Change-Id: Ia9b92a49dc199f184d23dd955d20ddb9eb8a7322
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 | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index 5645043a6..e85a3ceef 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -3356,16 +3356,32 @@ void CppGenerator::writePythonToCppConversionFunctions(TextStream &s, const Abst s << '\n'; } +static void writeSetConverterFunction(TextStream &s, + const char *function, + const QString &converterVar, + const QString &pythonToCppFunc, + const QString &isConvertibleFunc) +{ + s << "Shiboken::Conversions::" << function << '(' << converterVar << ',' << '\n' + << indent << pythonToCppFunc << ',' << '\n' << isConvertibleFunc + << outdent << ");\n"; +} + void CppGenerator::writeAddPythonToCppConversion(TextStream &s, const QString &converterVar, const QString &pythonToCppFunc, const QString &isConvertibleFunc) { - s << "Shiboken::Conversions::addPythonToCppValueConversion(" << converterVar << ',' << '\n'; - { - Indentation indent(s); - s << pythonToCppFunc << ',' << '\n' << isConvertibleFunc; - } - s << ");\n"; + writeSetConverterFunction(s, "addPythonToCppValueConversion", + converterVar, pythonToCppFunc, isConvertibleFunc); +} + +void CppGenerator::writeSetPythonToCppPointerConversion(TextStream &s, + const QString &converterVar, + const QString &pythonToCppFunc, + const QString &isConvertibleFunc) +{ + writeSetConverterFunction(s, "setPythonToCppPointerFunctions", + converterVar, pythonToCppFunc, isConvertibleFunc); } void CppGenerator::writeNamedArgumentResolution(TextStream &s, const AbstractMetaFunctionCPtr &func, |