chiark / gitweb /
buffer.c: Add `WriteBuffer.contents' property.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 29 Jul 2017 00:12:14 +0000 (01:12 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 10 Nov 2018 01:30:58 +0000 (01:30 +0000)
I'm fed of writing `C.ByteString(buf)'.

buffer.c

index 416063823a6b8ceb36c1bbe3a96a4664569fbd06..d2aa8d5a0f9b88dd1b11d8dffcd29a90172377e4 100644 (file)
--- a/buffer.c
+++ b/buffer.c
@@ -482,9 +482,13 @@ static PyObject *wbmeth_putgeraw(PyObject *me, PyObject *arg)
 static PyObject *wbget_size(PyObject *me, void *hunoz)
   { return (PyInt_FromLong(BLEN(BUF_B(me)))); }
 
+static PyObject *wbget_contents(PyObject *me, void *hunoz)
+  { return (bytestring_pywrap(BBASE(BUF_B(me)), BLEN(BUF_B(me)))); }
+
 static PyGetSetDef wbuf_pygetset[] = {
 #define GETSETNAME(op, name) wb##op##_##name
   GET  (size,                  "WBUF.size -> SIZE")
+  GET  (contents,              "WBUF.contents -> STR")
 #undef GETSETNAME
   { 0 }
 };