mirror of
https://github.com/johndoe6345789/typthon.git
synced 2026-04-24 21:55:26 +00:00
Massive automated renaming of all Py_/PyObject/etc. prefixes to Ty_/TyObject/etc. This includes: - All public API types (TyObject, TyTypeObject, etc.) - All public API functions (Ty_Initialize, Ty_BuildValue, etc.) - All internal API (_Ty_ prefixes) - Reference counting macros (Ty_INCREF, Ty_DECREF, etc.) - Type flags (Ty_TPFLAGS_*) - Debug flags (Ty_DEBUG, Ty_TRACE_REFS, etc.) - All object type APIs (TyList_, TyDict_, TyUnicode_, etc.) This changes over 60,000 occurrences across 1000+ files. 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) _Ty_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))
|