summaryrefslogtreecommitdiffstats
path: root/Include/object.h
diff options
context:
space:
mode:
authorTravis E. Oliphant <oliphant@enthought.com>2007-08-18 11:21:56 (GMT)
committerTravis E. Oliphant <oliphant@enthought.com>2007-08-18 11:21:56 (GMT)
commitb99f762f10edb2646a634c2290ecb064bd52e5c7 (patch)
treee0a354d42dccb18b7b2c99ed2733c135135a50af /Include/object.h
parent3de862df45480438dc6756103109ea9010d2825e (diff)
downloadcpython-b99f762f10edb2646a634c2290ecb064bd52e5c7.zip
cpython-b99f762f10edb2646a634c2290ecb064bd52e5c7.tar.gz
cpython-b99f762f10edb2646a634c2290ecb064bd52e5c7.tar.bz2
Merged in py3k-buffer branch to main line. All objects now use the buffer protocol in PEP 3118.
Diffstat (limited to 'Include/object.h')
-rw-r--r--Include/object.h67
1 files changed, 57 insertions, 10 deletions
diff --git a/Include/object.h b/Include/object.h
index 9470ed7..d936bca 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -140,11 +140,59 @@ typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *);
typedef int(*ssizessizeobjargproc)(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
typedef int(*objobjargproc)(PyObject *, PyObject *, PyObject *);
-/* ssize_t-based buffer interface */
-typedef Py_ssize_t (*readbufferproc)(PyObject *, Py_ssize_t, void **);
-typedef Py_ssize_t (*writebufferproc)(PyObject *, Py_ssize_t, void **);
-typedef Py_ssize_t (*segcountproc)(PyObject *, Py_ssize_t *);
-typedef Py_ssize_t (*charbufferproc)(PyObject *, Py_ssize_t, char **);
+
+/* buffer interface */
+typedef struct bufferinfo {
+ void *buf;
+ Py_ssize_t len;
+ Py_ssize_t itemsize;
+ int readonly;
+ int ndim;
+ char *format;
+ Py_ssize_t *shape;
+ Py_ssize_t *strides;
+ Py_ssize_t *suboffsets;
+ void *internal;
+} PyBuffer;
+
+typedef int (*getbufferproc)(PyObject *, PyBuffer *, int);
+typedef void (*releasebufferproc)(PyObject *, PyBuffer *);
+
+ /* Flags for getting buffers */
+#define PyBUF_SIMPLE 0
+#define PyBUF_CHARACTER 1
+#define PyBUF_WRITEABLE 0x0002
+#define PyBUF_LOCKDATA 0x0004
+#define PyBUF_FORMAT 0x0008
+#define PyBUF_ND 0x0010
+#define PyBUF_STRIDES (0x0020 | PyBUF_ND)
+#define PyBUF_C_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
+#define PyBUF_F_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
+#define PyBUF_ANY_CONTIGUOUS (0x0100 | PyBUF_STRIDES)
+#define PyBUF_INDIRECT (0x0200 | PyBUF_STRIDES)
+
+#define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITEABLE)
+#define PyBUF_CONTIG_RO (PyBUF_ND)
+#define PyBUF_CONTIG_LCK (PyBUF_ND | PyBUF_LOCKDATA)
+
+#define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITEABLE)
+#define PyBUF_STRIDED_RO (PyBUF_STRIDES)
+#define PyBUF_STRIDED_LCK (PyBUF_STRIDES | PyBUF_LOCKDATA)
+
+#define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITEABLE | PyBUF_FORMAT)
+#define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT)
+#define PyBUF_RECORDS_LCK (PyBUF_STRIDES | PyBUF_LOCKDATA | PyBUF_FORMAT)
+
+#define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITEABLE | PyBUF_FORMAT)
+#define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT)
+#define PyBUF_FULL_LCK (PyBUF_INDIRECT | PyBUF_LOCKDATA | PyBUF_FORMAT)
+
+
+#define PyBUF_READ 0x100
+#define PyBUF_WRITE 0x200
+#define PyBUF_SHADOW 0x400
+
+/* End buffer interface */
typedef int (*objobjproc)(PyObject *, PyObject *);
typedef int (*visitproc)(PyObject *, void *);
@@ -218,14 +266,13 @@ typedef struct {
objobjargproc mp_ass_subscript;
} PyMappingMethods;
+
typedef struct {
- readbufferproc bf_getreadbuffer;
- writebufferproc bf_getwritebuffer;
- segcountproc bf_getsegcount;
- charbufferproc bf_getcharbuffer;
+ getbufferproc bf_getbuffer;
+ releasebufferproc bf_releasebuffer;
+ inquiry bf_multisegment;
} PyBufferProcs;
-
typedef void (*freefunc)(void *);
typedef void (*destructor)(PyObject *);
typedef int (*printfunc)(PyObject *, FILE *, int);