| | #ifndef Py_CPYTHON_OBJIMPL_H |
| | # error "this header file must not be included directly" |
| | #endif |
| |
|
| | #ifdef __cplusplus |
| | extern "C" { |
| | #endif |
| |
|
| | #define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize ) |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #if ((SIZEOF_VOID_P - 1) & SIZEOF_VOID_P) != 0 |
| | # error "_PyObject_VAR_SIZE requires SIZEOF_VOID_P be a power of 2" |
| | #endif |
| |
|
| | #define _PyObject_VAR_SIZE(typeobj, nitems) \ |
| | _Py_SIZE_ROUND_UP((typeobj)->tp_basicsize + \ |
| | (nitems)*(typeobj)->tp_itemsize, \ |
| | SIZEOF_VOID_P) |
| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | static inline PyObject* |
| | _PyObject_INIT(PyObject *op, PyTypeObject *typeobj) |
| | { |
| | assert(op != NULL); |
| | Py_SET_TYPE(op, typeobj); |
| | if (PyType_GetFlags(typeobj) & Py_TPFLAGS_HEAPTYPE) { |
| | Py_INCREF(typeobj); |
| | } |
| | _Py_NewReference(op); |
| | return op; |
| | } |
| |
|
| | #define PyObject_INIT(op, typeobj) \ |
| | _PyObject_INIT(_PyObject_CAST(op), (typeobj)) |
| |
|
| | static inline PyVarObject* |
| | _PyObject_INIT_VAR(PyVarObject *op, PyTypeObject *typeobj, Py_ssize_t size) |
| | { |
| | assert(op != NULL); |
| | Py_SET_SIZE(op, size); |
| | PyObject_INIT((PyObject *)op, typeobj); |
| | return op; |
| | } |
| |
|
| | #define PyObject_INIT_VAR(op, typeobj, size) \ |
| | _PyObject_INIT_VAR(_PyVarObject_CAST(op), (typeobj), (size)) |
| |
|
| |
|
| | |
| | PyAPI_FUNC(Py_ssize_t) _Py_GetAllocatedBlocks(void); |
| |
|
| | |
| | #ifdef WITH_PYMALLOC |
| | PyAPI_FUNC(int) _PyObject_DebugMallocStats(FILE *out); |
| | #endif |
| |
|
| |
|
| | typedef struct { |
| | |
| | void *ctx; |
| |
|
| | |
| | void* (*alloc) (void *ctx, size_t size); |
| |
|
| | |
| | void (*free) (void *ctx, void *ptr, size_t size); |
| | } PyObjectArenaAllocator; |
| |
|
| | |
| | PyAPI_FUNC(void) PyObject_GetArenaAllocator(PyObjectArenaAllocator *allocator); |
| |
|
| | |
| | PyAPI_FUNC(void) PyObject_SetArenaAllocator(PyObjectArenaAllocator *allocator); |
| |
|
| |
|
| | PyAPI_FUNC(Py_ssize_t) _PyGC_CollectNoFail(void); |
| | PyAPI_FUNC(Py_ssize_t) _PyGC_CollectIfEnabled(void); |
| |
|
| |
|
| | |
| | PyAPI_FUNC(int) PyObject_IS_GC(PyObject *obj); |
| |
|
| |
|
| | |
| | |
| | #ifndef Py_BUILD_CORE |
| | |
| | # define _PyGC_FINALIZED(o) PyObject_GC_IsFinalized(o) |
| | #endif |
| |
|
| | PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t size); |
| | PyAPI_FUNC(PyObject *) _PyObject_GC_Calloc(size_t size); |
| |
|
| |
|
| | |
| | #define PyType_SUPPORTS_WEAKREFS(t) ((t)->tp_weaklistoffset > 0) |
| |
|
| | PyAPI_FUNC(PyObject **) PyObject_GET_WEAKREFS_LISTPTR(PyObject *op); |
| |
|
| | #ifdef __cplusplus |
| | } |
| | #endif |
| |
|