diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-05-11 20:52:17 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-05-12 07:35:07 +0200 |
commit | 8760ee9ad9ab93aaa1a5a519cbfbd2d5e04fbac5 (patch) | |
tree | f453181a7e04150b837f8e966fb0f83a0f09e415 /sources | |
parent | e548f91ed5f6e030498a8dd1d8bb75f560ae20a1 (diff) |
shiboken6: Add a debug operator for Py_Buffer
Pick-to: 6.1
Task-number: PYSIDE-1563
Change-Id: I9ad443b9dcb50dfac2f3b7a3c8bea83faefa73de
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources')
-rw-r--r-- | sources/shiboken6/libshiboken/helper.cpp | 16 | ||||
-rw-r--r-- | sources/shiboken6/libshiboken/helper.h | 8 |
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 |