diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-10-22 11:09:18 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-11-05 14:11:33 +0100 |
commit | 2a7f16dccfa1986bb79d08c90ed2ef56133994e8 (patch) | |
tree | c72a427ce7e873e739d059ee7a85c8b2e42a9ca1 /sources/shiboken6/generator/shiboken/cppgenerator.cpp | |
parent | 8b414806b80683e162133338c4b3ca0816746aaa (diff) |
shiboken6: Remove ShibokenGenerator::guessScopeForDefaultValue()
Move resolving of class fields and enum values as argument default
values into AbstractMetaBuilder.
Handling of static class field constants was spread between
AbstractMetaBuilderPrivate::fixDefaultValue() and
ShibokenGenerator::guessScopeForDefaultValue().
The former was handling it for arguments of non-primitive type only
and not completely expanding namespaces. The latter was handling it
for arguments of primitive types, too, but also added some code for
non-static fields, which cannot be used as default arguments in C++.
ShibokenGenerator::guessScopeForDefaultValue() was handling enum
values for primitive and values, excluding macros by regex, but
otherwise not checking if the term is really an enum value.
Rewrite the code in AbstractMetaBuilderPrivate::fixDefaultValue()
without regexes for clarity, let it check fields and
enum values correctly via code model and fully expand namespaces.
Add tests.
Adapt the signature module to the now fully qualified signatures.
[ChangeLog][shiboken6] When qualifying function argument default
values for the generated code, shiboken no longer considers each
identifier it cannot otherwise find as an enum value and no longer
adds the class scope to it. This may require manually adding some
replace-default-expression modifications.
Task-number: PYSIDE-1691
Pick-to: 6.2
Change-Id: Id4cd2ca1f91db8c1663d7fc31e4b4ef72a5690f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
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 | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index 2606f80ea..6b26ea043 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -3025,7 +3025,7 @@ void CppGenerator::writeSingleFunctionCall(TextStream &s, const QString cppArgRemoved = QLatin1String(CPP_ARG_REMOVED) + QString::number(argIdx); s << getFullTypeName(arg.type()) << ' ' << cppArgRemoved; - s << " = " << guessScopeForDefaultValue(func, arg) << ";\n"; + s << " = " << arg.defaultValueExpression() << ";\n"; writeUnusedVariableCast(s, cppArgRemoved); } else if (!injectCodeCallsFunc && !func->isUserAdded() && !hasConversionRule) { // When an argument is removed from a method signature and no other means of calling @@ -3047,9 +3047,8 @@ void CppGenerator::writeSingleFunctionCall(TextStream &s, int argPos = argIdx - removedArgs; QString argName = QLatin1String(CPP_ARG) + QString::number(argPos); QString pyArgName = usePyArgs ? pythonArgsAt(argPos) : QLatin1String(PYTHON_ARG); - QString defaultValue = guessScopeForDefaultValue(func, arg); writeArgumentConversion(s, argType, argName, pyArgName, - func->implementingClass(), defaultValue, + func->implementingClass(), arg.defaultValueExpression(), func->isUserAdded()); } |