From: Mark Wooding Date: Sat, 29 Jul 2017 00:12:14 +0000 (+0100) Subject: buffer.c: Add `WriteBuffer.contents' property. X-Git-Tag: 1.3.0~27 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb-python/commitdiff_plain/0051d10f431c6788d73f88a856159199ee004015 buffer.c: Add `WriteBuffer.contents' property. I'm fed of writing `C.ByteString(buf)'. --- diff --git a/buffer.c b/buffer.c index 4160638..d2aa8d5 100644 --- 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 } };