Debian Codegraph @

Include/cpython/memoryobject.h

raw
1 #ifndef Py_CPYTHON_MEMORYOBJECT_H
2 # error "this header file must not be included directly"
3 #endif
4
5 /* The structs are declared here so that macros can work, but they shouldn't
6 be considered public. Don't access their fields directly, use the macros
7 and functions instead! */
8 #define _Py_MANAGED_BUFFER_RELEASED 0x001 /* access to exporter blocked */
9 #define _Py_MANAGED_BUFFER_FREE_FORMAT 0x002 /* free format */
10
11 typedef struct {
12 PyObject_HEAD
13 int flags; /* state flags */
14 Py_ssize_t exports; /* number of direct memoryview exports */
15 Py_buffer master; /* snapshot buffer obtained from the original exporter */
16 } _PyManagedBufferObject;
17
18
19 /* memoryview state flags */
20 #define _Py_MEMORYVIEW_RELEASED 0x001 /* access to master buffer blocked */
21 #define _Py_MEMORYVIEW_C 0x002 /* C-contiguous layout */
22 #define _Py_MEMORYVIEW_FORTRAN 0x004 /* Fortran contiguous layout */
23 #define _Py_MEMORYVIEW_SCALAR 0x008 /* scalar: ndim = 0 */
24 #define _Py_MEMORYVIEW_PIL 0x010 /* PIL-style layout */
25 #define _Py_MEMORYVIEW_RESTRICTED 0x020 /* Disallow new references to the memoryview's buffer */
26
27 typedef struct {
28 PyObject_VAR_HEAD
29 _PyManagedBufferObject *mbuf; /* managed buffer */
30 Py_hash_t hash; /* hash value for read-only views */
31 int flags; /* state flags */
32 Py_ssize_t exports; /* number of buffer re-exports */
33 Py_buffer view; /* private copy of the exporter's view */
34 PyObject *weakreflist;
35 Py_ssize_t ob_array[1]; /* shape, strides, suboffsets */
36 } PyMemoryViewObject;
37
38 #define _PyMemoryView_CAST(op) _Py_CAST(PyMemoryViewObject*, op)
39
40 /* Get a pointer to the memoryview's private copy of the exporter's buffer. */
41 static inline Py_buffer* PyMemoryView_GET_BUFFER(PyObject *op) {
42 return (&_PyMemoryView_CAST(op)->view);
43 }
44 #define PyMemoryView_GET_BUFFER(op) PyMemoryView_GET_BUFFER(_PyObject_CAST(op))
45
46 /* Get a pointer to the exporting object (this may be NULL!). */
47 static inline PyObject* PyMemoryView_GET_BASE(PyObject *op) {
48 return _PyMemoryView_CAST(op)->view.obj;
49 }
50 #define PyMemoryView_GET_BASE(op) PyMemoryView_GET_BASE(_PyObject_CAST(op))