From e3bc0369480347d62c8bb274130daa0ee7f4e880 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 6 Apr 2022 13:50:37 +0200 Subject: shiboken6: Add a debug operator for the class context Change-Id: I3e5a7b413da3f8dd84a35e2029f23d2d2dae910c Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit c1bbe9503679ea23db8e874a0d2e2a53d1df5ffd) Reviewed-by: Qt Cherry-pick Bot --- sources/shiboken6/generator/generator.cpp | 17 +++++++++++++++++ sources/shiboken6/generator/generator.h | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/sources/shiboken6/generator/generator.cpp b/sources/shiboken6/generator/generator.cpp index c5d32c041..d800fe413 100644 --- a/sources/shiboken6/generator/generator.cpp +++ b/sources/shiboken6/generator/generator.cpp @@ -162,6 +162,23 @@ QDebug operator<<(QDebug debug, const DefaultValue &v) debug << "DefaultValue(" << v.type() << ", \"" << v.value() << "\")"; return debug; } + +QDebug operator<<(QDebug debug, const GeneratorContext &c) +{ + QDebugStateSaver saver(debug); + debug.noquote(); + debug.nospace(); + debug << "GeneratorContext(\"" << c.metaClass()->name() << "\" "; + if (c.useWrapper()) + debug << "[wrapper]"; + else if (c.forSmartPointer()) + debug << "[smart pointer] \"" << c.preciseType().cppSignature() << '"'; + else + debug << "[class]"; + debug << ')'; + return debug; +} + #endif // !QT_NO_DEBUG_STREAM QString GeneratorContext::smartPointerWrapperName() const diff --git a/sources/shiboken6/generator/generator.h b/sources/shiboken6/generator/generator.h index 36d590ca2..c335bc1ee 100644 --- a/sources/shiboken6/generator/generator.h +++ b/sources/shiboken6/generator/generator.h @@ -173,6 +173,10 @@ private: Type m_type = Class; }; +#ifndef QT_NO_DEBUG_STREAM +QDebug operator<<(QDebug debug, const GeneratorContext &c); +#endif + /** * Base class for all generators. The default implementations does nothing, * you must subclass this to create your own generators. -- cgit v1.2.3