Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:06:41

0001 #ifndef Py_CPYTHON_MEMORYOBJECT_H
0002 #  error "this header file must not be included directly"
0003 #endif
0004 
0005 PyAPI_DATA(PyTypeObject) _PyManagedBuffer_Type;
0006 
0007 /* The structs are declared here so that macros can work, but they shouldn't
0008    be considered public. Don't access their fields directly, use the macros
0009    and functions instead! */
0010 #define _Py_MANAGED_BUFFER_RELEASED    0x001  /* access to exporter blocked */
0011 #define _Py_MANAGED_BUFFER_FREE_FORMAT 0x002  /* free format */
0012 
0013 typedef struct {
0014     PyObject_HEAD
0015     int flags;          /* state flags */
0016     Py_ssize_t exports; /* number of direct memoryview exports */
0017     Py_buffer master; /* snapshot buffer obtained from the original exporter */
0018 } _PyManagedBufferObject;
0019 
0020 
0021 /* memoryview state flags */
0022 #define _Py_MEMORYVIEW_RELEASED    0x001  /* access to master buffer blocked */
0023 #define _Py_MEMORYVIEW_C           0x002  /* C-contiguous layout */
0024 #define _Py_MEMORYVIEW_FORTRAN     0x004  /* Fortran contiguous layout */
0025 #define _Py_MEMORYVIEW_SCALAR      0x008  /* scalar: ndim = 0 */
0026 #define _Py_MEMORYVIEW_PIL         0x010  /* PIL-style layout */
0027 #define _Py_MEMORYVIEW_RESTRICTED  0x020  /* Disallow new references to the memoryview's buffer */
0028 
0029 typedef struct {
0030     PyObject_VAR_HEAD
0031     _PyManagedBufferObject *mbuf; /* managed buffer */
0032     Py_hash_t hash;               /* hash value for read-only views */
0033     int flags;                    /* state flags */
0034     Py_ssize_t exports;           /* number of buffer re-exports */
0035     Py_buffer view;               /* private copy of the exporter's view */
0036     PyObject *weakreflist;
0037     Py_ssize_t ob_array[1];       /* shape, strides, suboffsets */
0038 } PyMemoryViewObject;
0039 
0040 #define _PyMemoryView_CAST(op) _Py_CAST(PyMemoryViewObject*, op)
0041 
0042 /* Get a pointer to the memoryview's private copy of the exporter's buffer. */
0043 static inline Py_buffer* PyMemoryView_GET_BUFFER(PyObject *op) {
0044     return (&_PyMemoryView_CAST(op)->view);
0045 }
0046 #define PyMemoryView_GET_BUFFER(op) PyMemoryView_GET_BUFFER(_PyObject_CAST(op))
0047 
0048 /* Get a pointer to the exporting object (this may be NULL!). */
0049 static inline PyObject* PyMemoryView_GET_BASE(PyObject *op) {
0050     return _PyMemoryView_CAST(op)->view.obj;
0051 }
0052 #define PyMemoryView_GET_BASE(op) PyMemoryView_GET_BASE(_PyObject_CAST(op))