diff options
-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 |