aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/generator/shiboken/cppgenerator.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-10-27 10:31:08 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-10-30 13:49:35 +0200
commite82812a17888e8bbf30908f790b16433b086a4ef (patch)
tree6c63f3c68a5aea41715a0bb339dfa3c4073c036b /sources/shiboken6/generator/shiboken/cppgenerator.cpp
parent090ce94f241496cdaac68eec4e7175b3e3395764 (diff)
Fix losing the default value when the type altered
The changes influence, for instance, the following line: ```python @staticmethod def translate( context: str, key: str, disambiguation: Optional[str] = ..., n: int = ... ) -> str: ... ``` Namely, the `disambiguation` argument now indicates that it has a default value. It seems that the `pyi-type` attribute of the modify-argument tag eats the argument default value. The commit should add the omitted values if they're provided. Initial-patch-by: Anton Yablokov (stsav012@gmail.com) Pick-to: 6.6 Change-Id: Ie3914c3ef13578ef8cfff9ecb8c6c64f167b5360 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken6/generator/shiboken/cppgenerator.cpp')
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index e56982b6c..74a9d8e91 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -5003,12 +5003,6 @@ QString CppGenerator::signatureParameter(const AbstractMetaArgument &arg) const
if (size > 1)
s << ']';
- if (!arg.defaultValueExpression().isEmpty()) {
- s << '=';
- QString e = arg.defaultValueExpression();
- e.replace(u"::"_s, u"."_s);
- s << e;
- }
return result;
}
@@ -5029,14 +5023,18 @@ void CppGenerator::writeSignatureInfo(TextStream &s, const OverloadData &overloa
const auto &arguments = f->arguments();
for (qsizetype i = 0, size = arguments.size(); i < size; ++i) {
const auto n = i + 1;
+ const auto &arg = arguments.at(i);
if (!f->argumentRemoved(n)) {
QString t = f->pyiTypeReplaced(n);
if (t.isEmpty()) {
- t = signatureParameter(arguments.at(i));
+ t = signatureParameter(arg);
} else {
t.prepend(u':');
- t.prepend(arguments.at(i).name());
+ t.prepend(arg.name());
}
+ QString defaultValue = arg.defaultValueExpression();
+ if (!defaultValue.isEmpty())
+ t += u'=' + defaultValue.replace(u"::"_s, u"."_s);
args.append(t);
}
}