diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-11-05 09:55:49 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-11-05 15:09:32 +0000 |
commit | 53e1a5f8a22faee31015a06c1cfcb8cac0ae0ff2 (patch) | |
tree | 1a55dff3d6c42c5dccc5d02e4e8a9c4fcf1c29d8 | |
parent | 3019e2079a55d0eea252495954ee784652bca46b (diff) |
shiboken6: Move defaultValue from AddedFunction::TypeInfo to AddedFunction::Argument
It does not really belong into the type. This makes it easier to merge
CodeModel's TypeInfo and AddedFunction::TypeInfo.
Change-Id: I38c947839e4dc785aad70e8636838db020f031d4
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r-- | sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp | 10 | ||||
-rw-r--r-- | sources/shiboken6/ApiExtractor/typesystem.cpp | 15 | ||||
-rw-r--r-- | sources/shiboken6/ApiExtractor/typesystem.h | 4 |
3 files changed, 16 insertions, 13 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp index 122ea374f..dbbfd76ec 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp @@ -1548,12 +1548,12 @@ AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFu const auto &args = addedFunc->arguments(); for (int i = 0; i < args.count(); ++i) { - const AddedFunction::TypeInfo& typeInfo = args.at(i).typeInfo; - AbstractMetaType type = translateType(typeInfo, metaClass, &errorMessage); + const AddedFunction::Argument &arg = args.at(i); + AbstractMetaType type = translateType(arg.typeInfo, metaClass, &errorMessage); if (Q_UNLIKELY(!type)) { qCWarning(lcShiboken, "%s", qPrintable(msgAddedFunctionInvalidArgType(addedFunc->name(), - typeInfo.name, i + 1, + arg.typeInfo.name, i + 1, errorMessage, metaClass))); delete metaFunction; @@ -1566,8 +1566,8 @@ AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFu metaArg.setName(args.at(i).name); metaArg.setType(type); metaArg.setArgumentIndex(i); - metaArg.setDefaultValueExpression(typeInfo.defaultValue); - metaArg.setOriginalDefaultValueExpression(typeInfo.defaultValue); + metaArg.setDefaultValueExpression(arg.defaultValue); + metaArg.setOriginalDefaultValueExpression(arg.defaultValue); metaFunction->addArgument(metaArg); } diff --git a/sources/shiboken6/ApiExtractor/typesystem.cpp b/sources/shiboken6/ApiExtractor/typesystem.cpp index 92f2b38ae..b13f26464 100644 --- a/sources/shiboken6/ApiExtractor/typesystem.cpp +++ b/sources/shiboken6/ApiExtractor/typesystem.cpp @@ -359,7 +359,8 @@ QString FunctionModification::toString() const static AddedFunction::TypeInfo parseType(const QString& signature, int startPos = 0, int *endPos = nullptr, - QString *argumentName = nullptr) + QString *argumentName = nullptr, + QString *defaultValue = nullptr) { AddedFunction::TypeInfo result; static const QRegularExpression regex(QLatin1String("\\w")); @@ -401,7 +402,8 @@ static AddedFunction::TypeInfo parseType(const QString& signature, if (paramString.contains(QLatin1Char('='))) { QStringList lst = paramString.split(QLatin1Char('=')); paramString = lst[0].trimmed(); - result.defaultValue = lst[1].trimmed(); + if (defaultValue != nullptr) + *defaultValue = lst[1].trimmed(); } // check constness @@ -458,9 +460,10 @@ AddedFunction::AddedFunction(QString signature, const QString &returnType) : int signatureLength = signature.length(); while (endPos < signatureLength) { QString argumentName; - TypeInfo arg = parseType(signature, endPos, &endPos, &argumentName); + QString defaultValue; + TypeInfo arg = parseType(signature, endPos, &endPos, &argumentName, &defaultValue); if (!arg.name.isEmpty()) - m_arguments.append({argumentName, arg}); + m_arguments.append({arg, argumentName, defaultValue}); // end of parameters... if (endPos >= signatureLength || signature[endPos] == QLatin1Char(')')) break; @@ -600,8 +603,6 @@ QDebug operator<<(QDebug d, const AddedFunction::TypeInfo &ti) if (ti.isReference) d << " &"; d << ti.name; - if (!ti.defaultValue.isEmpty()) - d << " = " << ti.defaultValue; d << ')'; return d; } @@ -615,6 +616,8 @@ QDebug operator<<(QDebug d, const AddedFunction::Argument &a) d << a.typeInfo; if (!a.name.isEmpty()) d << ' ' << a.name; + if (!a.defaultValue.isEmpty()) + d << " = " << a.defaultValue; d << ')'; return d; } diff --git a/sources/shiboken6/ApiExtractor/typesystem.h b/sources/shiboken6/ApiExtractor/typesystem.h index 4f9da99ef..1a401558a 100644 --- a/sources/shiboken6/ApiExtractor/typesystem.h +++ b/sources/shiboken6/ApiExtractor/typesystem.h @@ -427,7 +427,6 @@ struct AddedFunction static TypeInfo fromSignature(const QString& signature); QString name; - QString defaultValue; int indirections = 0; bool isConstant = false; bool isReference = false; @@ -435,8 +434,9 @@ struct AddedFunction struct Argument { - QString name; TypeInfo typeInfo; + QString name; + QString defaultValue; }; /// Creates a new AddedFunction with a signature and a return type. |