From 67e112826557421d3494e9d8e53fcd951f0a360f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 3 Mar 2017 11:48:15 +0100 Subject: Further improve debug output Output accessibility and template parameters of functions. Add verbose output to TypeInfo. Fix a type in 77eefb7a42c4a96f69ac4f5af464ea3520ae4de7. Task-number: PYSIDE-323 Change-Id: Ia2eba89c35b1d2a9d41070784a9c49a88254a5c2 Reviewed-by: Christian Tismer --- ApiExtractor/parser/codemodel.cpp | 79 +++++++++++++++++++++++++++++++++------ ApiExtractor/parser/codemodel.h | 4 ++ 2 files changed, 71 insertions(+), 12 deletions(-) diff --git a/ApiExtractor/parser/codemodel.cpp b/ApiExtractor/parser/codemodel.cpp index 87cb6bd..a1142fb 100644 --- a/ApiExtractor/parser/codemodel.cpp +++ b/ApiExtractor/parser/codemodel.cpp @@ -251,12 +251,65 @@ bool TypeInfo::operator==(const TypeInfo &other) } #ifndef QT_NO_DEBUG_STREAM +template +void formatSequence(QDebug &d, It i1, It i2, const char *separator=", ") +{ + for (It i = i1; i != i2; ++i) { + if (i != i1) + d << separator; + d << *i; + } +} + +void TypeInfo::formatDebug(QDebug &d) const +{ + d << '"'; + formatSequence(d, m_qualifiedName.begin(), m_qualifiedName.end(), "\", \""); + d << '"'; + if (m_constant) + d << ", [const]"; + if (m_volatile) + d << ", [volatile]"; + if (m_indirections) + d << ", indirections=" << m_indirections; + switch (m_referenceType) { + case NoReference: + break; + case LValueReference: + d << ", [ref]"; + break; + case RValueReference: + d << ", [rvalref]"; + break; + } + if (m_functionPointer) { + d << ", function ptr("; + formatSequence(d, m_arguments.begin(), m_arguments.end()); + d << ')'; + } + if (!m_arrayElements.isEmpty()) { + d << ", array[" << m_arrayElements.size() << "]["; + formatSequence(d, m_arrayElements.begin(), m_arrayElements.end()); + d << ']'; + } +} + QDebug operator<<(QDebug d, const TypeInfo &t) { QDebugStateSaver s(d); +#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) + const int verbosity = d.verbosity(); +#else + const int verbosity = 0; +#endif d.noquote(); d.nospace(); - d << "TypeInfo(" << t.toString() << ')'; + d << "TypeInfo("; + if (verbosity > 2) + t.formatDebug(d); + else + d << t.toString(); + d << ')'; return d; } #endif // !QT_NO_DEBUG_STREAM @@ -362,16 +415,6 @@ void _CodeModelItem::setEndPosition(int line, int column) } #ifndef QT_NO_DEBUG_STREAM -template -void formatSequence(QDebug &d, It i1, It i2, const char *separator=", ") -{ - for (It i = i1; i != i2; ++i) { - if (i != i1) - d << separator; - d << *i; - } -} - template static void formatPtrSequence(QDebug &d, It i1, It i2, const char *separator=", ") { @@ -413,7 +456,7 @@ void _CodeModelItem::formatKind(QDebug &d, int k) d << "NamespaceModelItem"; break; case Kind_Variable: - d << "ScopeModelItem"; + d << "VariableModelItem"; break; case Kind_Scope: d << "ScopeModelItem"; @@ -1144,7 +1187,19 @@ void _MemberModelItem::setMutable(bool isMutable) void _MemberModelItem::formatDebug(QDebug &d) const { _CodeModelItem::formatDebug(d); + switch (m_accessPolicy) { + case CodeModel::Public: + d << ", public"; + break; + case CodeModel::Protected: + d << ", protected"; + break; + case CodeModel::Private: + d << ", private"; + break; + } d << ", type=" << m_type; + formatScopeList(d, ", templateParameters", m_templateParameters); } #endif // !QT_NO_DEBUG_STREAM diff --git a/ApiExtractor/parser/codemodel.h b/ApiExtractor/parser/codemodel.h index 8350349..d32bdd1 100644 --- a/ApiExtractor/parser/codemodel.h +++ b/ApiExtractor/parser/codemodel.h @@ -184,6 +184,10 @@ public: static TypeInfo combine(const TypeInfo &__lhs, const TypeInfo &__rhs); static TypeInfo resolveType(TypeInfo const &__type, CodeModelItem __scope); +#ifndef QT_NO_DEBUG_STREAM + void formatDebug(QDebug &d) const; +#endif + private: static TypeInfo resolveType(CodeModelItem item, TypeInfo const &__type, CodeModelItem __scope); -- cgit v1.2.3