diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-10-22 13:43:07 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-10-25 15:13:41 +0200 |
commit | 6c2c4c00bc38bc9dc7b3c2f82fa8b12053902e71 (patch) | |
tree | 8fc11e858d7075cbfd78fed2cdde566d93ee19e9 /sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp | |
parent | f863ce7cc68a4def0fe9929c7f50e4e101fd8a1e (diff) |
shiboken6: Extend checks when not to fix a default value
Exclude numeric constants, boolean literals, initializer lists and
similar to prevent scope lookups for them.
Remove the conversion of integers to boolean literals from
AbstractMetaBuilderPrivate::fixDefaultValue(), since the type name was
misspelt ("boolean" instead of "bool") and bool constructs from
integers anyways.
Rename helper isNumericConstantt() to isIntegerConstant() for clarity.
Amends 2efc3669d07f77a08e334cf37913017523b8099b.
Task-number: PYSIDE-1691
Pick-to: 6.2
Change-Id: If74858ed0a4f16653d73220f33c4a98254dc5173
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp')
-rw-r--r-- | sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp index d365a285a..fef5b06c9 100644 --- a/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken6/ApiExtractor/abstractmetabuilder.cpp @@ -2542,27 +2542,12 @@ QString AbstractMetaBuilder::fixEnumDefault(const AbstractMetaType &type, QString AbstractMetaBuilderPrivate::fixDefaultValue(QString expr, const AbstractMetaType &type, const AbstractMetaClass *implementingClass) const { - if (expr.isEmpty() || expr == u"{}" || expr == u"nullptr" || expr == u"NULL") - return expr; - expr.replace(u'\n', u' '); // breaks signature parser - if (type.isPrimitive()) { - if (type.name() == QLatin1String("boolean")) { - if (expr != QLatin1String("false") && expr != QLatin1String("true")) { - bool ok = false; - int number = expr.toInt(&ok); - if (ok && number) - expr = QLatin1String("true"); - else - expr = QLatin1String("false"); - } - } else { - // This can be an enum or flag so I need to delay the - // translation until all namespaces are completely - // processed. This is done in figureOutEnumValues() - } - } else if (type.isFlags() || type.isEnum()) { + if (AbstractMetaBuilder::dontFixDefaultValue(expr)) + return expr; + + if (type.isFlags() || type.isEnum()) { expr = fixEnumDefault(type, expr); } else if (type.isContainer() && expr.contains(QLatin1Char('<'))) { static const QRegularExpression typeRegEx(QStringLiteral("[^<]*<(.*)>")); |