diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-12 09:54:35 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-16 11:25:29 +0000 |
commit | 82e805477cb811170b190e3254f89cda2c5a9568 (patch) | |
tree | a9415b9db6b64ee25bed90d11b5352aa247cc7ad /sources | |
parent | 269f835a8d21d6ad79e20de675ebb2132255367d (diff) |
shiboken: Improve debug output of TypeEntry classes
Task-number: PYSIDE-743
Change-Id: Ie4794c6387ef5ffaf8a5813b744fa725427b5f09
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources')
-rw-r--r-- | sources/shiboken2/ApiExtractor/typedatabase.cpp | 102 | ||||
-rw-r--r-- | sources/shiboken2/ApiExtractor/typesystem.h | 10 |
2 files changed, 92 insertions, 20 deletions
diff --git a/sources/shiboken2/ApiExtractor/typedatabase.cpp b/sources/shiboken2/ApiExtractor/typedatabase.cpp index 0814575ea..73b36ed6b 100644 --- a/sources/shiboken2/ApiExtractor/typedatabase.cpp +++ b/sources/shiboken2/ApiExtractor/typedatabase.cpp @@ -679,33 +679,95 @@ bool TypeDatabase::checkApiVersion(const QString &package, } #ifndef QT_NO_DEBUG_STREAM + +#define FORMAT_BOOL(name, var) \ + if (var) \ + d << ", [" << name << ']'; + +#define FORMAT_NONEMPTY_STRING(name, var) \ + if (!var.isEmpty()) \ + d << ", " << name << "=\"" << var << '"'; + +#define FORMAT_LIST_SIZE(name, var) \ + if (!var.isEmpty()) \ + d << ", " << var.size() << ' ' << name; + +void TypeEntry::formatDebug(QDebug &d) const +{ + const QString cppName = qualifiedCppName(); + d << '"' << m_name << '"'; + if (m_name != cppName) + d << "\", cppName=\"" << cppName << '"'; + d << ", type=" << m_type << ", codeGeneration=0x" + << hex << m_codeGeneration << dec; + FORMAT_NONEMPTY_STRING("package", m_targetLangPackage) + FORMAT_BOOL("preferredConversion", m_preferredConversion) + FORMAT_BOOL("stream", m_stream) + FORMAT_LIST_SIZE("codeSnips", m_codeSnips) + FORMAT_NONEMPTY_STRING("conversionRule", m_conversionRule) + if (!m_version.isNull() && m_version > QVersionNumber(0, 0)) + d << ", version=" << m_version; + if (m_revision) + d << ", revision=" << m_revision; + if (m_sbkIndex) + d << ", sbkIndex=" << m_sbkIndex; + if (m_include.isValid()) + d << ", include=" << m_include; + if (const int count = m_extraIncludes.size()) { + d << ", extraIncludes[" << count << "]="; + for (int i = 0; i < count; ++i) { + if (i) + d << ", "; + d << m_extraIncludes.at(i); + } + } +} + +void ComplexTypeEntry::formatDebug(QDebug &d) const +{ + TypeEntry::formatDebug(d); + FORMAT_NONEMPTY_STRING("targetLangName", m_targetLangName) + FORMAT_BOOL("QObject", m_qobject) + FORMAT_BOOL("polymorphicBase", m_polymorphicBase) + FORMAT_BOOL("genericClass", m_genericClass) + if (m_typeFlags != 0) + d << ", typeFlags=" << m_typeFlags; + d << ", copyableFlag=" << m_copyableFlag; + FORMAT_NONEMPTY_STRING("defaultSuperclass", m_defaultSuperclass) + FORMAT_NONEMPTY_STRING("polymorphicIdValue", m_polymorphicIdValue) + FORMAT_NONEMPTY_STRING("held", m_heldTypeValue) + FORMAT_NONEMPTY_STRING("lookupName", m_lookupName) + FORMAT_NONEMPTY_STRING("targetType", m_targetType) + FORMAT_NONEMPTY_STRING("hash", m_hashFunction) + FORMAT_LIST_SIZE("addedFunctions", m_addedFunctions) + FORMAT_LIST_SIZE("functionMods", m_functionMods) + FORMAT_LIST_SIZE("fieldMods", m_fieldMods) +} + +void EnumTypeEntry::formatDebug(QDebug &d) const +{ + TypeEntry::formatDebug(d); + FORMAT_NONEMPTY_STRING("package", m_packageName) + FORMAT_NONEMPTY_STRING("qualifier", m_qualifier) + FORMAT_NONEMPTY_STRING("targetLangName", m_targetLangName) + FORMAT_NONEMPTY_STRING("lowerBound", m_lowerBound) + FORMAT_NONEMPTY_STRING("lupperBound", m_upperBound) + FORMAT_BOOL("extensible", m_extensible) + FORMAT_BOOL("forceInteger", m_forceInteger) + if (m_flags) + d << ", flags=(" << m_flags << ')'; +} + QDebug operator<<(QDebug d, const TypeEntry *te) { QDebugStateSaver saver(d); d.noquote(); d.nospace(); d << "TypeEntry("; - if (te) { - const QString name = te->name(); - const QString cppName = te->qualifiedCppName(); - d << '"' << name << '"'; - if (name != cppName) - d << "\", cppName=\"" << cppName << '"'; - d << ", type=" << te->type(); - if (te->include().isValid()) - d << ", include=" << te->include(); - const IncludeList &extraIncludes = te->extraIncludes(); - if (const int count = extraIncludes.size()) { - d << ", extraIncludes[" << count << "]="; - for (int i = 0; i < count; ++i) { - if (i) - d << ", "; - d << extraIncludes.at(i); - } - } - } else { + if (te) + te->formatDebug(d); + else d << '0'; - } d << ')'; return d; } diff --git a/sources/shiboken2/ApiExtractor/typesystem.h b/sources/shiboken2/ApiExtractor/typesystem.h index dd4f39e7a..86eb694e6 100644 --- a/sources/shiboken2/ApiExtractor/typesystem.h +++ b/sources/shiboken2/ApiExtractor/typesystem.h @@ -892,6 +892,10 @@ public: bool hasCustomConversion() const; void setCustomConversion(CustomConversion* customConversion); CustomConversion* customConversion() const; + +#ifndef QT_NO_DEBUG_STREAM + virtual void formatDebug(QDebug &d) const; +#endif private: QString m_name; QString m_targetLangPackage; @@ -1133,6 +1137,9 @@ public: m_forceInteger = force; } +#ifndef QT_NO_DEBUG_STREAM + void formatDebug(QDebug &d) const override; +#endif private: QString m_packageName; QString m_qualifier; @@ -1395,6 +1402,9 @@ public: void setDefaultConstructor(const QString& defaultConstructor); bool hasDefaultConstructor() const; +#ifndef QT_NO_DEBUG_STREAM + void formatDebug(QDebug &d) const override; +#endif private: AddedFunctionList m_addedFunctions; FunctionModificationList m_functionMods; |