mirror of
https://github.com/johndoe6345789/typthon.git
synced 2026-04-25 06:05:05 +00:00
Fixed several macros and constants that should not have been renamed: - _Py_CAST, _Py_NULL, _Py_RVALUE (internal utility macros) - Py_UNUSED (unused parameter macro) - Py_EQ, Py_NE, Py_LT, Py_LE, Py_GT, Py_GE (comparison constants) - Py_RETURN_* macros (NONE, TRUE, FALSE, NOTIMPLEMENTED, RICHCOMPARE) - Py_READONLY, Py_ULL, Py_CONTEXT_SWITCHED - TyGC_Head in generated clinic files Build is still in progress with some remaining issues to resolve. Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
51 lines
2.2 KiB
C
51 lines
2.2 KiB
C
#ifndef Ty_CPYTHON_MEMORYOBJECT_H
|
|
# error "this header file must not be included directly"
|
|
#endif
|
|
|
|
/* The structs are declared here so that macros can work, but they shouldn't
|
|
be considered public. Don't access their fields directly, use the macros
|
|
and functions instead! */
|
|
#define _Ty_MANAGED_BUFFER_RELEASED 0x001 /* access to exporter blocked */
|
|
#define _Ty_MANAGED_BUFFER_FREE_FORMAT 0x002 /* free format */
|
|
|
|
typedef struct {
|
|
PyObject_HEAD
|
|
int flags; /* state flags */
|
|
Ty_ssize_t exports; /* number of direct memoryview exports */
|
|
Ty_buffer master; /* snapshot buffer obtained from the original exporter */
|
|
} _PyManagedBufferObject;
|
|
|
|
|
|
/* memoryview state flags */
|
|
#define _Ty_MEMORYVIEW_RELEASED 0x001 /* access to master buffer blocked */
|
|
#define _Ty_MEMORYVIEW_C 0x002 /* C-contiguous layout */
|
|
#define _Ty_MEMORYVIEW_FORTRAN 0x004 /* Fortran contiguous layout */
|
|
#define _Ty_MEMORYVIEW_SCALAR 0x008 /* scalar: ndim = 0 */
|
|
#define _Ty_MEMORYVIEW_PIL 0x010 /* PIL-style layout */
|
|
#define _Ty_MEMORYVIEW_RESTRICTED 0x020 /* Disallow new references to the memoryview's buffer */
|
|
|
|
typedef struct {
|
|
PyObject_VAR_HEAD
|
|
_PyManagedBufferObject *mbuf; /* managed buffer */
|
|
Ty_hash_t hash; /* hash value for read-only views */
|
|
int flags; /* state flags */
|
|
Ty_ssize_t exports; /* number of buffer re-exports */
|
|
Ty_buffer view; /* private copy of the exporter's view */
|
|
TyObject *weakreflist;
|
|
Ty_ssize_t ob_array[1]; /* shape, strides, suboffsets */
|
|
} PyMemoryViewObject;
|
|
|
|
#define _PyMemoryView_CAST(op) _Py_CAST(PyMemoryViewObject*, op)
|
|
|
|
/* Get a pointer to the memoryview's private copy of the exporter's buffer. */
|
|
static inline Ty_buffer* TyMemoryView_GET_BUFFER(TyObject *op) {
|
|
return (&_PyMemoryView_CAST(op)->view);
|
|
}
|
|
#define TyMemoryView_GET_BUFFER(op) TyMemoryView_GET_BUFFER(_TyObject_CAST(op))
|
|
|
|
/* Get a pointer to the exporting object (this may be NULL!). */
|
|
static inline TyObject* TyMemoryView_GET_BASE(TyObject *op) {
|
|
return _PyMemoryView_CAST(op)->view.obj;
|
|
}
|
|
#define TyMemoryView_GET_BASE(op) TyMemoryView_GET_BASE(_TyObject_CAST(op))
|