aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-04-05 09:14:34 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2022-04-05 14:45:06 +0200
commit5f836597140d2ae82f235d69561cc7f426e2d7af (patch)
tree06abd82101606805be52dee2be0603043ac83dec
parent62e90aefbe860024576d51ea7d5eec3100a4613a (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. Pick-to: 6.2 Task-number: PYSIDE-454 Change-Id: I263bce12b8103fbb729180188843f45d3e430e64 Reviewed-by: Christian Tismer <tismer@stackless.com>
-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 64c748ca5..ee3bfb542 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -3642,12 +3642,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 adaadebbd..eae177c7a 100644
--- a/sources/shiboken6/generator/shiboken/overloaddata.cpp
+++ b/sources/shiboken6/generator/shiboken/overloaddata.cpp
@@ -718,18 +718,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 cbf2470f6..10119a397 100644
--- a/sources/shiboken6/generator/shiboken/overloaddata.h
+++ b/sources/shiboken6/generator/shiboken/overloaddata.h
@@ -177,8 +177,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;