diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-06-30 09:13:47 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-07-11 13:13:29 +0000 |
commit | 1c5a5cc67d8f80bd542a166b6861a234529c5c43 (patch) | |
tree | 9ec342e9ff02c00f220ead08c3fea09d66f323df | |
parent | 29ea7a10b743976b471ccc3d1749db2d7df2e321 (diff) |
Shiboken: Improve debug operators of the type system
- Add debug operator for TypeParser::Info
- Add verbose mode to AbstractMetaType
- Output more information for TypeEntry
Task-number: PYSIDE-354
Task-number: PYSIDE-516
Change-Id: Id9882e89f9b5a51929f27b100d28396d3f6c4198
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r-- | sources/shiboken2/ApiExtractor/abstractmetalang.cpp | 20 | ||||
-rw-r--r-- | sources/shiboken2/ApiExtractor/typedatabase.cpp | 7 | ||||
-rw-r--r-- | sources/shiboken2/ApiExtractor/typeparser.cpp | 44 | ||||
-rw-r--r-- | sources/shiboken2/ApiExtractor/typeparser.h | 6 |
4 files changed, 74 insertions, 3 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp index db0558a99..07bd14e55 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.cpp @@ -301,10 +301,26 @@ QDebug operator<<(QDebug d, const AbstractMetaType *at) d.noquote(); d.nospace(); d << "AbstractMetaType("; - if (at) + if (at) { d << at->name(); - else + if (d.verbosity() > 2) { + d << ", typeEntry=" << at->typeEntry() << ", signature=\"" + << at->cppSignature() << "\", pattern=" + << at->typeUsagePattern(); + if (at->indirections()) + d << ", indirections=" << at->indirections(); + if (at->referenceType()) + d << ", reftype=" << at->referenceType(); + if (at->isConstant()) + d << ", [const]"; + if (at->isArray()) { + d << ", array of \"" << at->arrayElementType()->cppSignature() + << "\", arrayElementCount=" << at->arrayElementCount(); + } + } + } else { d << '0'; + } d << ')'; return d; } diff --git a/sources/shiboken2/ApiExtractor/typedatabase.cpp b/sources/shiboken2/ApiExtractor/typedatabase.cpp index 76f8d0f77..8cd9eeb89 100644 --- a/sources/shiboken2/ApiExtractor/typedatabase.cpp +++ b/sources/shiboken2/ApiExtractor/typedatabase.cpp @@ -684,7 +684,12 @@ QDebug operator<<(QDebug d, const TypeEntry *te) d.nospace(); d << "TypeEntry("; if (te) { - d << '"' << te->qualifiedCppName() << "\", type=" << te->type(); + 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(); diff --git a/sources/shiboken2/ApiExtractor/typeparser.cpp b/sources/shiboken2/ApiExtractor/typeparser.cpp index 8165bfe44..09439a210 100644 --- a/sources/shiboken2/ApiExtractor/typeparser.cpp +++ b/sources/shiboken2/ApiExtractor/typeparser.cpp @@ -316,3 +316,47 @@ QString TypeParser::Info::toString() const } return s; } + +#ifndef QT_NO_DEBUG_STREAM + +static void formatTypeInfo(QDebug &d, const TypeParser::Info &i) +{ + if (i.is_busted) { + d << "busted"; + return; + } + + d << '"' << i.qualified_name << '"'; + if (!i.arrays.isEmpty()) { + d << ", arrays="; + for (const QString &a : i.arrays) + d << '[' << a << ']'; + } + if (!i.template_instantiations.isEmpty()) { + d << ", template_instantiations=["; + for (int t = 0, size = i.template_instantiations.size(); t < size; ++t) { + if (t) + d << ", "; + formatTypeInfo(d, i.template_instantiations.at(t)); + } + d << ']'; + } + if (i.referenceType != NoReference) + d << ", refType=" << i.referenceType; + if (i.is_constant) + d << ", [const]"; + if (i.indirections > 0) + d << ", indirections=" << i.indirections; +} + +QDebug operator<<(QDebug d, const TypeParser::Info &i) +{ + QDebugStateSaver saver(d); + d.noquote(); + d.nospace(); + d << "TypeParser::Info("; + formatTypeInfo(d, i); + d << ')'; + return d; +} +#endif // !QT_NO_DEBUG_STREAM diff --git a/sources/shiboken2/ApiExtractor/typeparser.h b/sources/shiboken2/ApiExtractor/typeparser.h index f42c42a5e..568223656 100644 --- a/sources/shiboken2/ApiExtractor/typeparser.h +++ b/sources/shiboken2/ApiExtractor/typeparser.h @@ -36,6 +36,8 @@ #include <QtCore/QStringList> #include <QtCore/QVector> +QT_FORWARD_DECLARE_CLASS(QDebug) + class TypeParser { public: @@ -57,4 +59,8 @@ public: static Info parse(const QString &str, QString *errorMessage = Q_NULLPTR); }; +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug d, const TypeParser::Info &); +#endif + #endif // TYPEPARSER_H |