aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/generator/shiboken/cppgenerator.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-09-16 09:44:05 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-10-01 11:24:55 +0200
commitee38500932bb2c4275811bcaabaaf7a831d29f4f (patch)
tree59a51e4db8f9ad9e13bb5fa5c8ef58a394d8a5f3 /sources/shiboken6/generator/shiboken/cppgenerator.cpp
parent2edf0042bb23fa8528dfb964377dae5bd35ee932 (diff)
shiboken6: Store removed modification in AbstractMetaArgument
Similar to 984559a68d57d76b49c8ed0cbaf3492521aebebd, store the "removed" modification in AbstractMetaArgument. Task-number: PYSIDE-1660 Change-Id: Id541b4dccdcf3eba708a0da5dc873fe3b20b8151 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.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index 8aba8cd20..8f86cbaff 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -843,14 +843,9 @@ Shiboken::Object::destroy(wrapper, this);
static bool allArgumentsRemoved(const AbstractMetaFunctionCPtr& func)
{
- if (func->arguments().isEmpty())
- return false;
const AbstractMetaArgumentList &arguments = func->arguments();
- for (const AbstractMetaArgument &arg : arguments) {
- if (!func->argumentRemoved(arg.argumentIndex() + 1))
- return false;
- }
- return true;
+ return std::all_of(arguments.cbegin(), arguments.cend(),
+ [](const AbstractMetaArgument &a) { return a.isModifiedRemoved(); });
}
// Return type for error messages when getting invalid types from virtual
@@ -1091,7 +1086,7 @@ void CppGenerator::writeVirtualMethodNative(TextStream &s,
QStringList argConversions;
const AbstractMetaArgumentList &arguments = func->arguments();
for (const AbstractMetaArgument &arg : arguments) {
- if (func->argumentRemoved(arg.argumentIndex() + 1))
+ if (arg.isModifiedRemoved())
continue;
const auto &argType = arg.type();
@@ -2434,12 +2429,15 @@ static void checkTypeViability(const AbstractMetaFunctionCPtr &func,
const bool modified = argIdx == 0
? func->isTypeModified()
: func->arguments().at(argIdx -1).isTypeModified();
+ const bool isRemoved = argIdx == 0
+ ? func->argumentRemoved(0)
+ : func->arguments().at(argIdx -1).isModifiedRemoved();
if (type.isVoid()
|| !type.typeEntry()->isPrimitive()
|| type.indirections() == 0
|| (type.indirections() == 1 && type.typeUsagePattern() == AbstractMetaType::NativePointerAsArrayPattern)
|| type.isCString()
- || func->argumentRemoved(argIdx)
+ || isRemoved
|| modified
|| !func->conversionRule(TypeSystem::All, argIdx).isEmpty()
|| func->hasInjectedCode())
@@ -3014,7 +3012,7 @@ void CppGenerator::writeSingleFunctionCall(TextStream &s,
for (int argIdx = 0; argIdx < func->arguments().count(); ++argIdx) {
bool hasConversionRule = !func->conversionRule(TypeSystem::NativeCode, argIdx + 1).isEmpty();
const AbstractMetaArgument &arg = func->arguments().at(argIdx);
- if (func->argumentRemoved(argIdx + 1)) {
+ if (arg.isModifiedRemoved()) {
if (!arg.defaultValueExpression().isEmpty()) {
const QString cppArgRemoved = QLatin1String(CPP_ARG_REMOVED)
+ QString::number(argIdx);
@@ -3533,8 +3531,7 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr
if (maxArgs > 0 && maxArgs < func->arguments().size() - OverloadData::numberOfRemovedArguments(func)) {
int removedArgs = 0;
for (int i = 0; i < maxArgs + removedArgs; i++) {
- lastArg = &func->arguments().at(i);
- if (func->argumentRemoved(i + 1))
+ if (func->arguments().at(i).isModifiedRemoved())
removedArgs++;
}
} else if (maxArgs != 0 && !func->arguments().isEmpty()) {
@@ -3555,7 +3552,7 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr
const AbstractMetaArgument &arg = func->arguments().at(i);
bool hasConversionRule = !func->conversionRule(TypeSystem::NativeCode,
arg.argumentIndex() + 1).isEmpty();
- if (func->argumentRemoved(i + 1)) {
+ if (arg.isModifiedRemoved()) {
// If some argument with default value is removed from a
// method signature, the said value must be explicitly
// added to the method call.
@@ -3596,7 +3593,7 @@ void CppGenerator::writeMethodCall(TextStream &s, const AbstractMetaFunctionCPtr
if (argsClear && !defValModified && !hasConversionRule)
continue;
argsClear = false;
- otherArgsModified |= defValModified || hasConversionRule || func->argumentRemoved(i + 1);
+ otherArgsModified |= defValModified || hasConversionRule || arg.isModifiedRemoved();
if (hasConversionRule)
otherArgs.prepend(arg.name() + QLatin1String(CONV_RULE_OUT_VAR_SUFFIX));
else