diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-10-01 16:40:23 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-10-04 13:44:57 +0200 |
commit | 9698a678937c3dfd23e38b890a29b16ad6885d96 (patch) | |
tree | 910282f4f6d25314dee73bfa173bf70407430ade | |
parent | 6d4c76578f3228c76d36574fbd50698060a65268 (diff) |
shiboken: Remove ShibokenGenerator::getDefaultValue()
Replace by AbstractMetaArgument::hasDefaultValueExpression(),
which is now restricted to the effective default value expression
after the previous commit.
This effectively reverts 96bd943d57b1864d1f5e7359b100c67d01934619 for
the old bug 919, which was trying to re-apply the modifications again,
potentially hitting on a remove modification in a loop.
Task-number: PYSIDE-1095
Change-Id: I08fc005cfdc2f7b91f8303abd4d75a479d670ba9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Tismer <tismer@stackless.com>
3 files changed, 8 insertions, 29 deletions
diff --git a/sources/shiboken2/generator/shiboken2/overloaddata.cpp b/sources/shiboken2/generator/shiboken2/overloaddata.cpp index 4aa5e5c02..5f74ee64d 100644 --- a/sources/shiboken2/generator/shiboken2/overloaddata.cpp +++ b/sources/shiboken2/generator/shiboken2/overloaddata.cpp @@ -520,7 +520,7 @@ void OverloadData::addOverload(const AbstractMetaFunction *func) for (int i = 0; m_headOverloadData->m_minArgs > 0 && i < origNumArgs; i++) { if (func->argumentRemoved(i + 1)) continue; - if (!ShibokenGenerator::getDefaultValue(func, func->arguments().at(i)).isEmpty()) { + if (func->arguments().at(i)->hasDefaultValueExpression()) { int fixedArgIndex = i - removed; if (fixedArgIndex < m_headOverloadData->m_minArgs) m_headOverloadData->m_minArgs = fixedArgIndex; @@ -754,7 +754,7 @@ const AbstractMetaFunction *OverloadData::getFunctionWithDefaultValue() const if (func->argumentRemoved(i + 1)) removedArgs++; } - if (!ShibokenGenerator::getDefaultValue(func, func->arguments().at(m_argPos + removedArgs)).isEmpty()) + if (func->arguments().at(m_argPos + removedArgs)->hasDefaultValueExpression()) return func; } return nullptr; @@ -771,7 +771,7 @@ QVector<int> OverloadData::invalidArgumentLengths() const if (func->argumentRemoved(i+1)) { offset++; } else { - if (!ShibokenGenerator::getDefaultValue(func, args[i]).isEmpty()) + if (args.at(i)->hasDefaultValueExpression()) validArgLengths << i-offset; } } @@ -820,7 +820,7 @@ QPair<int, int> OverloadData::getMinMaxArguments(const AbstractMetaFunctionList if (func->argumentRemoved(j + 1)) continue; int fixedArgIndex = j - removed; - if (fixedArgIndex < minArgs && !ShibokenGenerator::getDefaultValue(func, func->arguments().at(j)).isEmpty()) + if (fixedArgIndex < minArgs && func->arguments().at(j)->hasDefaultValueExpression()) minArgs = fixedArgIndex; } } @@ -967,7 +967,7 @@ QString OverloadData::dumpGraph() const const AbstractMetaArgument *arg = argument(func); if (!arg) continue; - QString argDefault = ShibokenGenerator::getDefaultValue(func, arg); + QString argDefault = arg->defaultValueExpression(); if (!argDefault.isEmpty() || argDefault != arg->originalDefaultValueExpression()) { s << "<tr><td bgcolor=\"gray\" align=\"right\">f" << functionNumber(func); @@ -1038,7 +1038,7 @@ bool OverloadData::hasArgumentWithDefaultValue(const AbstractMetaFunction *func) for (const AbstractMetaArgument *arg : arguments) { if (func->argumentRemoved(arg->argumentIndex() + 1)) continue; - if (!ShibokenGenerator::getDefaultValue(func, arg).isEmpty()) + if (arg->hasDefaultValueExpression()) return true; } return false; @@ -1049,7 +1049,7 @@ AbstractMetaArgumentList OverloadData::getArgumentsWithDefaultValues(const Abstr AbstractMetaArgumentList args; const AbstractMetaArgumentList &arguments = func->arguments(); for (AbstractMetaArgument *arg : arguments) { - if (ShibokenGenerator::getDefaultValue(func, arg).isEmpty() + if (!arg->hasDefaultValueExpression() || func->argumentRemoved(arg->argumentIndex() + 1)) continue; args << arg; diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp index 5b76f25e2..6d94af248 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp @@ -571,7 +571,7 @@ QString ShibokenGenerator::guessScopeForDefaultFlagsValue(const AbstractMetaFunc QString ShibokenGenerator::guessScopeForDefaultValue(const AbstractMetaFunction *func, const AbstractMetaArgument *arg) const { - QString value = getDefaultValue(func, arg); + QString value = arg->defaultValueExpression(); if (value.isEmpty()) return QString(); @@ -2708,22 +2708,6 @@ bool ShibokenGenerator::pythonFunctionWrapperUsesListOfArguments(const OverloadD || overloadData.hasArgumentWithDefaultValue(); } -QString ShibokenGenerator::getDefaultValue(const AbstractMetaFunction *func, const AbstractMetaArgument *arg) -{ - if (!arg->defaultValueExpression().isEmpty()) - return arg->defaultValueExpression(); - - //Check modifications - const FunctionModificationList &mods = func->modifications(); - for (const FunctionModification &m : mods) { - for (const ArgumentModification &am : m.argument_mods) { - if (am.index == (arg->argumentIndex() + 1)) - return am.replacedDefaultExpression; - } - } - return QString(); -} - void ShibokenGenerator::writeMinimalConstructorExpression(QTextStream &s, const AbstractMetaType *type, const QString &defaultCtor) { if (!defaultCtor.isEmpty()) { diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.h b/sources/shiboken2/generator/shiboken2/shibokengenerator.h index 84b3137b8..7970ceb94 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.h +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.h @@ -71,11 +71,6 @@ public: const char *name() const override { return "Shiboken"; } - /** - * Helper function to find for argument default value - */ - static QString getDefaultValue(const AbstractMetaFunction *func, const AbstractMetaArgument *arg); - /// Returns a list of all ancestor classes for the given class. AbstractMetaClassList getAllAncestors(const AbstractMetaClass *metaClass) const; |