diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-01-06 16:09:11 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-01-20 18:05:42 +0000 |
commit | f81019b4dac5bc9015d88020fca970e495427a2b (patch) | |
tree | f47be9d6ba64ad5b815ce0b1d4c0ff9b18623adc | |
parent | 37b0ad35845b8097d10eeb3b286a22ff641ceae8 (diff) |
Add debug output to type database
Task-number: PYSIDE-323
Change-Id: I306ccbb3a1c69e00129f5cc17626b502f79ed191
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r-- | ApiExtractor/typedatabase.cpp | 42 | ||||
-rw-r--r-- | ApiExtractor/typedatabase.h | 9 | ||||
-rw-r--r-- | ApiExtractor/typesystem.cpp | 37 | ||||
-rw-r--r-- | ApiExtractor/typesystem.h | 5 |
4 files changed, 93 insertions, 0 deletions
diff --git a/ApiExtractor/typedatabase.cpp b/ApiExtractor/typedatabase.cpp index def71fd..fc75953 100644 --- a/ApiExtractor/typedatabase.cpp +++ b/ApiExtractor/typedatabase.cpp @@ -567,3 +567,45 @@ bool TypeDatabase::checkApiVersion(const QString& package, const QByteArray& ver } return false; } + +#ifndef QT_NO_DEBUG_STREAM +void TypeDatabase::formatDebug(QDebug &d) const +{ + typedef TypeEntryHash::ConstIterator Eit; + d << "TypeDatabase(" + << "entries="; + for (Eit it = m_entries.cbegin(), end = m_entries.cend(); it != end; ++it) { + d << '"' << it.key() << "\": ["; + for (int t = 0, cnt = it.value().size(); t < cnt; ++t) { + if (t) + d << ", "; + d << it.value().at(t); + } + d << "]\n"; + } + d <<"\nglobalUserFunctions=" << m_globalUserFunctions << ')'; +} + +QDebug operator<<(QDebug d, const TypeEntry *te) +{ + QDebugStateSaver saver(d); + d.noquote(); + d.nospace(); + d << "TypeEntry("; + if (te) + d << te->qualifiedCppName() << ", type=" << te->type(); + else + d << '0'; + d << ')'; + return d; +} + +QDebug operator<<(QDebug d, const TypeDatabase &db) +{ + QDebugStateSaver saver(d); + d.noquote(); + d.nospace(); + db.formatDebug(d); + return d; +} +#endif // !QT_NO_DEBUG_STREAM diff --git a/ApiExtractor/typedatabase.h b/ApiExtractor/typedatabase.h index d53da45..cf5028d 100644 --- a/ApiExtractor/typedatabase.h +++ b/ApiExtractor/typedatabase.h @@ -49,6 +49,8 @@ class TypeEntry; struct TypeRejection; +QT_FORWARD_DECLARE_CLASS(QDebug) + void setTypeRevision(TypeEntry* typeEntry, int revision); int getTypeRevision(const TypeEntry* typeEntry); int getTypeIndex(const TypeEntry* typeEntry); @@ -144,6 +146,9 @@ public: void setDropTypeEntries(QStringList dropTypeEntries); +#ifndef QT_NO_DEBUG_STREAM + void formatDebug(QDebug &d) const; +#endif private: QList<TypeEntry *> findTypes(const QString &name) const; QString modifiedTypesystemFilepath(const QString &tsFile) const; @@ -167,4 +172,8 @@ private: QStringList m_dropTypeEntries; }; +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug d, const TypeEntry *te); +QDebug operator<<(QDebug d, const TypeDatabase &db); #endif +#endif // TYPEDATABASE_H diff --git a/ApiExtractor/typesystem.cpp b/ApiExtractor/typesystem.cpp index e07d485..94bdb10 100644 --- a/ApiExtractor/typesystem.cpp +++ b/ApiExtractor/typesystem.cpp @@ -2238,6 +2238,43 @@ AddedFunction::AddedFunction(QString signature, QString returnType, double vr) : } } +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug d, const AddedFunction::TypeInfo &ti) +{ + QDebugStateSaver saver(d); + d.noquote(); + d.nospace(); + d << "TypeInfo("; + if (ti.isConstant) + d << "const"; + if (ti.indirections) + d << QByteArray(ti.indirections, '*'); + if (ti.isReference) + d << " &"; + d << ti.name; + if (!ti.defaultValue.isEmpty()) + d << " = " << ti.defaultValue; + d << ')'; + return d; +} + +QDebug operator<<(QDebug d, const AddedFunction &af) +{ + QDebugStateSaver saver(d); + d.noquote(); + d.nospace(); + d << "AddedFunction("; + if (af.access() == AddedFunction::Protected) + d << "protected"; + if (af.isStatic()) + d << " static"; + d << af.returnType() << ' ' << af.name() << '(' << af.arguments() << ')'; + if (af.isConstant()) + d << " const"; + return d; +} +#endif // !QT_NO_DEBUG_STREAM + AddedFunction::TypeInfo AddedFunction::TypeInfo::fromSignature(const QString& signature) { return parseType(signature); diff --git a/ApiExtractor/typesystem.h b/ApiExtractor/typesystem.h index 4d34a1b..a645cfc 100644 --- a/ApiExtractor/typesystem.h +++ b/ApiExtractor/typesystem.h @@ -505,6 +505,11 @@ private: double m_version; }; +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug d, const AddedFunction::TypeInfo &ti); +QDebug operator<<(QDebug d, const AddedFunction &af); +#endif + struct ExpensePolicy { ExpensePolicy() : limit(-1) {} |