diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-09-03 11:09:59 +0200 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2024-09-03 13:15:04 +0200 |
| commit | 91da4eae80ac4d8daaaeb2ccda5b62f2ef43fd80 (patch) | |
| tree | c49d5e8612d3ce510a0c71ecfb57424cb4c941c0 | |
| parent | d303a44d55d9e6bb626185a81c4483a4567657f5 (diff) | |
shiboken6: Refactor ShibokenGenerator::converterObject()
Use string literals instead of placeholder formatting. Fix the warning
messages and use qCWarning(). Use braces for multiline-ifs. Introduce
a helper functions for enums which will be used in a follow-up change.
Pick-to: 6.7
Task-number: PYSIDE-1735
Change-Id: Ie3ad081bc615040dd67ce79cadc2bcaa115bf6b0
Reviewed-by: Christian Tismer <tismer@stackless.com>
| -rw-r--r-- | sources/shiboken6/generator/shiboken/shibokengenerator.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp index da7d8e1a3..b9bf17eda 100644 --- a/sources/shiboken6/generator/shiboken/shibokengenerator.cpp +++ b/sources/shiboken6/generator/shiboken/shibokengenerator.cpp @@ -688,27 +688,37 @@ QString ShibokenGenerator::converterObject(const AbstractMetaType &type) return converterObject(typeEntry); } +static QString sbkEnumPrivate(const QString &name) +{ + return "PepType_SETP(reinterpret_cast<SbkEnumType *>("_L1 + name + "))"_L1; +} + QString ShibokenGenerator::converterObject(const TypeEntryCPtr &type) { - if (isExtendedCppPrimitive(type)) - return QString::fromLatin1("Shiboken::Conversions::PrimitiveTypeConverter<%1>()") - .arg(type->qualifiedCppName()); - if (type->isWrapperType()) - return QString::fromLatin1("PepType_SOTP(reinterpret_cast<PyTypeObject *>(%1))->converter") - .arg(cpythonTypeNameExt(type)); + if (isExtendedCppPrimitive(type)) { + return "Shiboken::Conversions::PrimitiveTypeConverter<"_L1 + + type->qualifiedCppName() + ">()"_L1; + } + + if (type->isWrapperType()) { + return "PepType_SOTP(reinterpret_cast<PyTypeObject *>("_L1 + + cpythonTypeNameExt(type) + "))->converter"_L1; + } + if (type->isEnum() || type->isFlags()) - return QString::fromLatin1("PepType_SETP(reinterpret_cast<SbkEnumType *>(%1))->converter") - .arg(cpythonTypeNameExt(type)); + return sbkEnumPrivate(cpythonTypeNameExt(type)) + "->converter"_L1; if (type->isArray()) { - qDebug() << "Warning: no idea how to handle the Qt5 type " << type->qualifiedCppName(); + qCWarning(lcShiboken, "Warning: no idea how to handle the Qt type \"%s\"", + qPrintable(type->qualifiedCppName())); return {}; } /* the typedef'd primitive types case */ auto pte = std::dynamic_pointer_cast<const PrimitiveTypeEntry>(type); if (!pte) { - qDebug() << "Warning: the Qt5 primitive type is unknown" << type->qualifiedCppName(); + qCWarning(lcShiboken, "Warning: the Qt primitive type \"%s\" is unknown", + qPrintable(type->qualifiedCppName())); return {}; } pte = basicReferencedTypeEntry(pte); |
