aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-04-05 09:14:34 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-04-05 15:53:21 +0000
commit7ab564201cd47153b622feaed39529a89b00622a (patch)
treec5b2d30a0f9a6da6e44c7436281c96030b61a35f
parentdc281d26be84bc161ea1b9db04bb16e94d640b5c (diff)
shiboken6: Fix wrong Python argument name for functions with one parameter and default value
When a default value is present, an argument list needs to be used. Fix CppGenerator::argumentNameFromIndex() to use OverloadData::pythonFunctionWrapperUsesListOfArguments() instead of OverloadData::isSingleArgument() and remove the latter. Task-number: PYSIDE-454 Change-Id: I263bce12b8103fbb729180188843f45d3e430e64 Reviewed-by: Christian Tismer <tismer@stackless.com> (cherry picked from commit 5f836597140d2ae82f235d69561cc7f426e2d7af) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp12
-rw-r--r--sources/shiboken6/generator/shiboken/overloaddata.cpp12
-rw-r--r--sources/shiboken6/generator/shiboken/overloaddata.h2
3 files changed, 7 insertions, 19 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index 15f2012ab..424d2fbe6 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -3541,12 +3541,14 @@ QString CppGenerator::argumentNameFromIndex(const ApiExtractorResult &api,
*wrappedClass = AbstractMetaClass::findClass(api.classes(), argType.typeEntry());
if (*wrappedClass == nullptr && errorMessage != nullptr)
*errorMessage = msgClassNotFound(argType.typeEntry());
- if (argIndex == 1
- && !func->isConstructor()
- && OverloadData::isSingleArgument(getFunctionGroups(func->implementingClass()).value(func->name())))
- pyArgName = QLatin1String(PYTHON_ARG);
- else
+ if (argIndex != 1) {
pyArgName = pythonArgsAt(argIndex - 1);
+ } else {
+ OverloadData data(getFunctionGroups(func->implementingClass()).value(func->name()),
+ api);
+ pyArgName = data.pythonFunctionWrapperUsesListOfArguments()
+ ? pythonArgsAt(argIndex - 1) : QLatin1String(PYTHON_ARG);
+ }
}
return pyArgName;
}
diff --git a/sources/shiboken6/generator/shiboken/overloaddata.cpp b/sources/shiboken6/generator/shiboken/overloaddata.cpp
index c6e2b5d83..63511ff69 100644
--- a/sources/shiboken6/generator/shiboken/overloaddata.cpp
+++ b/sources/shiboken6/generator/shiboken/overloaddata.cpp
@@ -733,18 +733,6 @@ int OverloadData::numberOfRemovedArguments(const AbstractMetaFunctionCPtr &func,
return removed;
}
-bool OverloadData::isSingleArgument(const AbstractMetaFunctionCList &overloads)
-{
- bool singleArgument = true;
- for (const auto &func : overloads) {
- if (func->arguments().size() - numberOfRemovedArguments(func) != 1) {
- singleArgument = false;
- break;
- }
- }
- return singleArgument;
-}
-
void OverloadData::dumpGraph(const QString &filename) const
{
QFile file(filename);
diff --git a/sources/shiboken6/generator/shiboken/overloaddata.h b/sources/shiboken6/generator/shiboken/overloaddata.h
index 0271fd3d0..146310bdd 100644
--- a/sources/shiboken6/generator/shiboken/overloaddata.h
+++ b/sources/shiboken6/generator/shiboken/overloaddata.h
@@ -174,8 +174,6 @@ public:
static int numberOfRemovedArguments(const AbstractMetaFunctionCPtr &func);
static int numberOfRemovedArguments(const AbstractMetaFunctionCPtr &func, int finalArgPos);
- /// Returns true if all overloads have no more than one argument.
- static bool isSingleArgument(const AbstractMetaFunctionCList &overloads);
void dumpGraph(const QString &filename) const;
QString dumpGraph() const;