summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-11-22 13:25:01 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-11-24 11:37:48 +0000
commit0f5920b798af86454abbc2e466f96336920b4f1c (patch)
tree7f2e88751f4243634e1f8d39af6ac62c88072be9
parentb92fb6e81be252a2ffae26768434028c5029ddc7 (diff)
shiboken: Add debug output for function modifications
Task-number: PYSIDE-834 Change-Id: I2530b44f704ef96b784a77512f71777d9fd492bb Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r--sources/shiboken2/ApiExtractor/typedatabase.cpp29
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem.cpp116
-rw-r--r--sources/shiboken2/ApiExtractor/typesystem.h15
3 files changed, 150 insertions, 10 deletions
diff --git a/sources/shiboken2/ApiExtractor/typedatabase.cpp b/sources/shiboken2/ApiExtractor/typedatabase.cpp
index 4cb6cdd8..c0999e7a 100644
--- a/sources/shiboken2/ApiExtractor/typedatabase.cpp
+++ b/sources/shiboken2/ApiExtractor/typedatabase.cpp
@@ -746,6 +746,20 @@ bool TypeDatabase::checkApiVersion(const QString &package,
if (!var.isEmpty()) \
d << ", " << var.size() << ' ' << name;
+template <class Container, class Separator>
+static void formatList(QDebug &d, const char *name, const Container &c, Separator sep)
+{
+ if (const int size = c.size()) {
+ d << ", " << name << '[' << size << "]=(";
+ for (int i = 0; i < size; ++i) {
+ if (i)
+ d << sep;
+ d << c.at(i);
+ }
+ d << ')';
+ }
+}
+
void TypeEntry::formatDebug(QDebug &d) const
{
const QString cppName = qualifiedCppName();
@@ -766,14 +780,7 @@ void TypeEntry::formatDebug(QDebug &d) const
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);
- }
- }
+ formatList(d, "extraIncludes", m_extraIncludes, ", ");
}
void ComplexTypeEntry::formatDebug(QDebug &d) const
@@ -794,7 +801,7 @@ void ComplexTypeEntry::formatDebug(QDebug &d) const
FORMAT_NONEMPTY_STRING("targetType", m_targetType)
FORMAT_NONEMPTY_STRING("hash", m_hashFunction)
FORMAT_LIST_SIZE("addedFunctions", m_addedFunctions)
- FORMAT_LIST_SIZE("functionMods", m_functionMods)
+ formatList(d, "functionMods", m_functionMods, ", ");
FORMAT_LIST_SIZE("fieldMods", m_fieldMods)
}
@@ -876,7 +883,9 @@ void TypeDatabase::formatDebug(QDebug &d) const
}
d << ")\n";
}
- d <<"\nglobalUserFunctions=" << m_globalUserFunctions << ')';
+ d <<"\nglobalUserFunctions=" << m_globalUserFunctions << '\n';
+ formatList(d, "globalFunctionMods", m_functionMods, '\n');
+ d << ')';
}
QDebug operator<<(QDebug d, const TypeDatabase &db)
diff --git a/sources/shiboken2/ApiExtractor/typesystem.cpp b/sources/shiboken2/ApiExtractor/typesystem.cpp
index 2c7f5eea..4c522be6 100644
--- a/sources/shiboken2/ApiExtractor/typesystem.cpp
+++ b/sources/shiboken2/ApiExtractor/typesystem.cpp
@@ -3208,6 +3208,122 @@ AddedFunction::AddedFunction(QString signature, const QString &returnType) :
}
#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const ReferenceCount &r)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "ReferenceCount(" << r.varName << ", action=" << r.action << ')';
+ return d;
+}
+
+QDebug operator<<(QDebug d, const CodeSnip &s)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "CodeSnip(language=" << s.language << ", position=" << s.position << ", \"";
+ for (const auto &f : s.codeList) {
+ const QString &code = f.code();
+ const auto lines = code.splitRef(QLatin1Char('\n'));
+ for (int i = 0, size = lines.size(); i < size; ++i) {
+ if (i)
+ d << "\\n";
+ d << lines.at(i).trimmed();
+ }
+ }
+ d << '"';
+ if (!s.argumentMap.isEmpty()) {
+ d << ", argumentMap{";
+ for (auto it = s.argumentMap.cbegin(), end = s.argumentMap.cend(); it != end; ++it)
+ d << it.key() << "->\"" << it.value() << '"';
+ d << '}';
+ }
+ d << ')';
+ return d;
+}
+
+void Modification::formatDebug(QDebug &d) const
+{
+ d << "modifiers=" << hex << showbase << modifiers << noshowbase << dec;
+ if (removal)
+ d << ", removal";
+ if (!renamedToName.isEmpty())
+ d << ", renamedToName=\"" << renamedToName << '"';
+}
+
+void FunctionModification::formatDebug(QDebug &d) const
+{
+ if (m_signature.isEmpty())
+ d << "pattern=\"" << m_signaturePattern.pattern();
+ else
+ d << "signature=\"" << m_signature;
+ d << "\", ";
+ Modification::formatDebug(d);
+ if (!association.isEmpty())
+ d << ", association=\"" << association << '"';
+ if (m_allowThread != TypeSystem::AllowThread::Unspecified)
+ d << ", allowThread=" << int(m_allowThread);
+ if (m_thread)
+ d << ", thread";
+ if (m_exceptionHandling != TypeSystem::ExceptionHandling::Unspecified)
+ d << ", exceptionHandling=" << int(m_exceptionHandling);
+ if (!snips.isEmpty())
+ d << ", snips=(" << snips << ')';
+ if (!argument_mods.isEmpty())
+ d << ", argument_mods=(" << argument_mods << ')';
+}
+
+QDebug operator<<(QDebug d, const ArgumentOwner &a)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "ArgumentOwner(index=" << a.index << ", action=" << a.action << ')';
+ return d;
+}
+
+QDebug operator<<(QDebug d, const ArgumentModification &a)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "ArgumentModification(index=" << a.index;
+ if (a.removedDefaultExpression)
+ d << ", removedDefaultExpression";
+ if (a.removed)
+ d << ", removed";
+ if (a.noNullPointers)
+ d << ", noNullPointers";
+ if (a.array)
+ d << ", array";
+ if (!a.referenceCounts.isEmpty())
+ d << ", referenceCounts=" << a.referenceCounts;
+ if (!a.modified_type.isEmpty())
+ d << ", modified_type=\"" << a.modified_type << '"';
+ if (!a.replace_value.isEmpty())
+ d << ", replace_value=\"" << a.replace_value << '"';
+ if (!a.replacedDefaultExpression.isEmpty())
+ d << ", replacedDefaultExpression=\"" << a.replacedDefaultExpression << '"';
+ if (!a.ownerships.isEmpty())
+ d << ", ownerships=" << a.ownerships;
+ if (!a.renamed_to.isEmpty())
+ d << ", renamed_to=\"" << a.renamed_to << '"';
+ d << ", owner=" << a.owner << ')';
+ return d;
+}
+
+QDebug operator<<(QDebug d, const FunctionModification &fm)
+{
+ QDebugStateSaver saver(d);
+ d.noquote();
+ d.nospace();
+ d << "FunctionModification(";
+ fm.formatDebug(d);
+ d << ')';
+ return d;
+}
+
QDebug operator<<(QDebug d, const AddedFunction::TypeInfo &ti)
{
QDebugStateSaver saver(d);
diff --git a/sources/shiboken2/ApiExtractor/typesystem.h b/sources/shiboken2/ApiExtractor/typesystem.h
index 721d19f2..b0144923 100644
--- a/sources/shiboken2/ApiExtractor/typesystem.h
+++ b/sources/shiboken2/ApiExtractor/typesystem.h
@@ -308,6 +308,10 @@ struct Modification
return removal != TypeSystem::NoLanguage;
}
+#ifndef QT_NO_DEBUG_STREAM
+ void formatDebug(QDebug &d) const;
+#endif
+
QString renamedToName;
uint modifiers = 0;
TypeSystem::Language removal = TypeSystem::NoLanguage;
@@ -351,6 +355,10 @@ struct FunctionModification: public Modification
QString toString() const;
+#ifndef QT_NO_DEBUG_STREAM
+ void formatDebug(QDebug &d) const;
+#endif
+
QString association;
CodeSnipList snips;
@@ -365,6 +373,13 @@ private:
TypeSystem::ExceptionHandling m_exceptionHandling = TypeSystem::ExceptionHandling::Unspecified;
};
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug d, const ReferenceCount &);
+QDebug operator<<(QDebug d, const ArgumentOwner &a);
+QDebug operator<<(QDebug d, const ArgumentModification &a);
+QDebug operator<<(QDebug d, const FunctionModification &fm);
+#endif
+
struct FieldModification: public Modification
{
bool isReadable() const