aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-05-11 20:52:17 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-05-12 07:49:57 +0000
commitd97a3590b29c2c83d8e9622fbe36f624c4399432 (patch)
tree8a1b0d029a598e4f9b459a2d9d5d03cec9a085b9
parent114b7f94b8cb63c1b76481a4aa460f5dadcefc42 (diff)
shiboken6: Add a debug operator for Py_Buffer
Task-number: PYSIDE-1563 Change-Id: I9ad443b9dcb50dfac2f3b7a3c8bea83faefa73de Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit 8760ee9ad9ab93aaa1a5a519cbfbd2d5e04fbac5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/shiboken6/libshiboken/helper.cpp16
-rw-r--r--sources/shiboken6/libshiboken/helper.h8
2 files changed, 24 insertions, 0 deletions
diff --git a/sources/shiboken6/libshiboken/helper.cpp b/sources/shiboken6/libshiboken/helper.cpp
index 3f8d7b8d0..02f8177f3 100644
--- a/sources/shiboken6/libshiboken/helper.cpp
+++ b/sources/shiboken6/libshiboken/helper.cpp
@@ -141,6 +141,10 @@ debugPyTypeObject::debugPyTypeObject(const PyTypeObject *o) : m_object(o)
{
}
+debugPyBuffer::debugPyBuffer(const Py_buffer &b) : m_buffer(b)
+{
+}
+
std::ostream &operator<<(std::ostream &str, const debugPyTypeObject &o)
{
str << "PyTypeObject(";
@@ -157,6 +161,18 @@ std::ostream &operator<<(std::ostream &str, const debugPyObject &o)
return str;
}
+std::ostream &operator<<(std::ostream &str, const debugPyBuffer &b)
+{
+ str << "PyBuffer(buf=" << b.m_buffer.buf << ", len="
+ << b.m_buffer.len << ", itemsize=" << b.m_buffer.itemsize
+ << ", readonly=" << b.m_buffer.readonly << ", ndim=" << b.m_buffer.ndim;
+ if (b.m_buffer.format)
+ str << ", format=\"" << b.m_buffer.format << '"';
+ str << ", shape=" << b.m_buffer.shape << ", strides=" << b.m_buffer.strides
+ << ", suboffsets=" << b.m_buffer.suboffsets << ')';
+ return str;
+}
+
#ifdef _WIN32
// Converts a Unicode string to a string encoded in the Windows console's
// code page via wchar_t for use with argv (PYSIDE-1425).
diff --git a/sources/shiboken6/libshiboken/helper.h b/sources/shiboken6/libshiboken/helper.h
index 1a2c2e29d..8221d68b0 100644
--- a/sources/shiboken6/libshiboken/helper.h
+++ b/sources/shiboken6/libshiboken/helper.h
@@ -115,8 +115,16 @@ struct LIBSHIBOKEN_API debugPyTypeObject
const PyTypeObject *m_object;
};
+struct LIBSHIBOKEN_API debugPyBuffer
+{
+ explicit debugPyBuffer(const Py_buffer &b);
+
+ const Py_buffer &m_buffer;
+};
+
LIBSHIBOKEN_API std::ostream &operator<<(std::ostream &str, const debugPyObject &o);
LIBSHIBOKEN_API std::ostream &operator<<(std::ostream &str, const debugPyTypeObject &o);
+LIBSHIBOKEN_API std::ostream &operator<<(std::ostream &str, const debugPyBuffer &b);
} // namespace Shiboken