File indexing completed on 2025-01-18 10:06:50
0001
0002
0003 #ifndef Py_BUFFER_H
0004 #define Py_BUFFER_H
0005 #ifdef __cplusplus
0006 extern "C" {
0007 #endif
0008
0009 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030b0000
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 typedef struct {
0021 void *buf;
0022 PyObject *obj;
0023 Py_ssize_t len;
0024 Py_ssize_t itemsize;
0025
0026 int readonly;
0027 int ndim;
0028 char *format;
0029 Py_ssize_t *shape;
0030 Py_ssize_t *strides;
0031 Py_ssize_t *suboffsets;
0032 void *internal;
0033 } Py_buffer;
0034
0035 typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
0036 typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
0037
0038
0039 PyAPI_FUNC(int) PyObject_CheckBuffer(PyObject *obj);
0040
0041
0042
0043
0044
0045
0046 PyAPI_FUNC(int) PyObject_GetBuffer(PyObject *obj, Py_buffer *view,
0047 int flags);
0048
0049
0050
0051 PyAPI_FUNC(void *) PyBuffer_GetPointer(const Py_buffer *view, const Py_ssize_t *indices);
0052
0053
0054
0055 PyAPI_FUNC(Py_ssize_t) PyBuffer_SizeFromFormat(const char *format);
0056
0057
0058 PyAPI_FUNC(int) PyBuffer_ToContiguous(void *buf, const Py_buffer *view,
0059 Py_ssize_t len, char order);
0060
0061 PyAPI_FUNC(int) PyBuffer_FromContiguous(const Py_buffer *view, const void *buf,
0062 Py_ssize_t len, char order);
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077 PyAPI_FUNC(int) PyObject_CopyData(PyObject *dest, PyObject *src);
0078
0079
0080 PyAPI_FUNC(int) PyBuffer_IsContiguous(const Py_buffer *view, char fort);
0081
0082
0083
0084
0085
0086 PyAPI_FUNC(void) PyBuffer_FillContiguousStrides(int ndims,
0087 Py_ssize_t *shape,
0088 Py_ssize_t *strides,
0089 int itemsize,
0090 char fort);
0091
0092
0093
0094
0095
0096
0097 PyAPI_FUNC(int) PyBuffer_FillInfo(Py_buffer *view, PyObject *o, void *buf,
0098 Py_ssize_t len, int readonly,
0099 int flags);
0100
0101
0102 PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view);
0103
0104
0105 #define PyBUF_MAX_NDIM 64
0106
0107
0108 #define PyBUF_SIMPLE 0
0109 #define PyBUF_WRITABLE 0x0001
0110
0111 #ifndef Py_LIMITED_API
0112
0113 #define PyBUF_WRITEABLE PyBUF_WRITABLE
0114 #endif
0115
0116 #define PyBUF_FORMAT 0x0004
0117 #define PyBUF_ND 0x0008
0118 #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
0119 #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
0120 #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
0121 #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
0122 #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
0123
0124 #define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE)
0125 #define PyBUF_CONTIG_RO (PyBUF_ND)
0126
0127 #define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE)
0128 #define PyBUF_STRIDED_RO (PyBUF_STRIDES)
0129
0130 #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT)
0131 #define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT)
0132
0133 #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT)
0134 #define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT)
0135
0136
0137 #define PyBUF_READ 0x100
0138 #define PyBUF_WRITE 0x200
0139
0140 #endif
0141
0142 #ifdef __cplusplus
0143 }
0144 #endif
0145 #endif