Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-19 09:50:41

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