diff options
author | Alex Blasche <alexander.blasche@qt.io> | 2019-07-18 10:18:43 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@qt.io> | 2019-07-18 10:21:51 +0200 |
commit | 4646b8660721e5b8d06b06d714b4562e375f8c34 (patch) | |
tree | d12f0c1af2b6cdf486ff389607844a657a1b67c1 /sources/shiboken2/generator | |
parent | 97718de50e14f69048993df4e87dda1cadcc599a (diff) | |
parent | 295d9d7fb52505666a6dc9ac7b6fba2323814c48 (diff) |
Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: Ic2c43ef80769e3063dac771518c803861510f72e
Diffstat (limited to 'sources/shiboken2/generator')
-rw-r--r-- | sources/shiboken2/generator/shiboken2/cppgenerator.cpp | 10 | ||||
-rw-r--r-- | sources/shiboken2/generator/shiboken2/shibokengenerator.cpp | 9 |
2 files changed, 12 insertions, 7 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index 84f0cd1f5..e36b6edc3 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -3032,18 +3032,21 @@ void CppGenerator::writeNamedArgumentResolution(QTextStream &s, const AbstractMe s << INDENT << "if (kwds) {" << endl; { Indentation indent(INDENT); - s << INDENT << "PyObject *"; + s << INDENT << "PyObject *keyName = nullptr;" << endl; + s << INDENT << "PyObject *value = nullptr;" << endl; for (const AbstractMetaArgument *arg : args) { int pyArgIndex = arg->argumentIndex() - OverloadData::numberOfRemovedArguments(func, arg->argumentIndex()); QString pyArgName = usePyArgs ? pythonArgsAt(pyArgIndex) : QLatin1String(PYTHON_ARG); - s << "value = PyDict_GetItemString(kwds, \"" << arg->name() << "\");" << endl; + s << INDENT << "keyName = Py_BuildValue(\"s\",\"" << arg->name() << "\");" << endl; + s << INDENT << "if (PyDict_Contains(kwds, keyName)) {" << endl; + s << INDENT << "value = PyDict_GetItemString(kwds, \"" << arg->name() << "\");" << endl; s << INDENT << "if (value && " << pyArgName << ") {" << endl; { Indentation indent(INDENT); s << INDENT << pyErrString.arg(arg->name()) << endl; s << INDENT << returnStatement(m_currentErrorCode) << endl; } - s << INDENT << "} else if (value) {" << endl; + s << INDENT << INDENT << "} else if (value) {" << endl; { Indentation indent(INDENT); s << INDENT << pyArgName << " = value;" << endl; @@ -3058,6 +3061,7 @@ void CppGenerator::writeNamedArgumentResolution(QTextStream &s, const AbstractMe s << INDENT << '}' << endl; if (arg != args.constLast()) s << INDENT; + s << "}" << endl; } } s << INDENT << '}' << endl; diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp index 8e27777d6..e41c91716 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp @@ -149,6 +149,8 @@ ShibokenGenerator::ShibokenGenerator() const char CHECKTYPE_REGEX[] = R"(%CHECKTYPE\[([^\[]*)\]\()"; const char ISCONVERTIBLE_REGEX[] = R"(%ISCONVERTIBLE\[([^\[]*)\]\()"; const char CONVERTTOPYTHON_REGEX[] = R"(%CONVERTTOPYTHON\[([^\[]*)\]\()"; + // Capture a '*' leading the variable name into the target + // so that "*valuePtr = %CONVERTTOCPP..." works as expected. const char CONVERTTOCPP_REGEX[] = R"((\*?%?[a-zA-Z_][\w\.]*(?:\[[^\[^<^>]+\])*)(?:\s+)=(?:\s+)%CONVERTTOCPP\[([^\[]*)\]\()"; m_typeSystemConvRegEx[TypeSystemCheckFunction] = QRegularExpression(QLatin1String(CHECKTYPE_REGEX)); @@ -2044,10 +2046,9 @@ void ShibokenGenerator::replaceConverterTypeSystemVariable(TypeSystemConverterVa varType = miniNormalizer(varType); QString varName = list.at(1).trimmed(); if (!varType.isEmpty()) { - if (varType != conversionType->cppSignature()) { - qFatal("Types of receiver variable ('%s') and %%CONVERTTOCPP type system variable ('%s') differ.", - qPrintable(varType), qPrintable(conversionType->cppSignature())); - } + const QString conversionSignature = conversionType->cppSignature(); + if (varType != conversionSignature) + qFatal("%s", qPrintable(msgConversionTypesDiffer(varType, conversionSignature))); c << getFullTypeName(conversionType) << ' ' << varName; writeMinimalConstructorExpression(c, conversionType); c << ';' << endl; |