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