diff options
author | Guido van Rossum <guido@python.org> | 1998-10-08 02:18:52 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-10-08 02:18:52 (GMT) |
commit | 1db7070217d80f0889aed44ceb1f11a82265b3f0 (patch) | |
tree | 1abbaab201292b47c76bfb2983959c20799a7cdc /Objects/bufferobject.c | |
parent | 36eef3c1739cdec3956e5ad86b5887985d249302 (diff) | |
download | cpython-1db7070217d80f0889aed44ceb1f11a82265b3f0.zip cpython-1db7070217d80f0889aed44ceb1f11a82265b3f0.tar.gz cpython-1db7070217d80f0889aed44ceb1f11a82265b3f0.tar.bz2 |
Greg Stein: Implement the new bf_getcharbuffer function, indicating
that (as far as the data type is concerned!) this is character data.
Diffstat (limited to 'Objects/bufferobject.c')
-rw-r--r-- | Objects/bufferobject.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/Objects/bufferobject.c b/Objects/bufferobject.c index 9be1e43..091688d 100644 --- a/Objects/bufferobject.c +++ b/Objects/bufferobject.c @@ -523,7 +523,7 @@ buffer_getreadbuf(self, idx, pp) { if ( idx != 0 ) { PyErr_SetString(PyExc_SystemError, - "Accessing non-existent buffer segment"); + "accessing non-existent buffer segment"); return -1; } *pp = self->b_ptr; @@ -554,6 +554,21 @@ buffer_getsegcount(self, lenp) return 1; } +static int +buffer_getcharbuf(self, idx, pp) + PyBufferObject *self; + int idx; + const char ** pp; +{ + if ( idx != 0 ) { + PyErr_SetString(PyExc_SystemError, + "accessing non-existent buffer segment"); + return -1; + } + *pp = (const char *)self->b_ptr; + return self->b_size; +} + static PySequenceMethods buffer_as_sequence = { (inquiry)buffer_length, /*sq_length*/ @@ -569,6 +584,7 @@ static PyBufferProcs buffer_as_buffer = { (getreadbufferproc)buffer_getreadbuf, (getwritebufferproc)buffer_getwritebuf, (getsegcountproc)buffer_getsegcount, + (getcharbufferproc)buffer_getcharbuf, }; PyTypeObject PyBuffer_Type = { @@ -592,7 +608,7 @@ PyTypeObject PyBuffer_Type = { 0, /*tp_getattro*/ 0, /*tp_setattro*/ &buffer_as_buffer, /*tp_as_buffer*/ - 0, /*tp_xxx4*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ 0, /*tp_doc*/ }; |