| | #ifndef Py_CPYTHON_OBJECT_H |
| | # error "this header file must not be included directly" |
| | #endif |
| |
|
| | #ifdef __cplusplus |
| | extern "C" { |
| | #endif |
| |
|
| | PyAPI_FUNC(void) _Py_NewReference(PyObject *op); |
| |
|
| | #ifdef Py_TRACE_REFS |
| | |
| | PyAPI_FUNC(void) _Py_ForgetReference(PyObject *); |
| | #endif |
| |
|
| | |
| | |
| | PyAPI_FUNC(int) _PyTraceMalloc_NewReference(PyObject *op); |
| |
|
| | #ifdef Py_REF_DEBUG |
| | PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void); |
| | #endif |
| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | typedef struct _Py_Identifier { |
| | struct _Py_Identifier *next; |
| | const char* string; |
| | PyObject *object; |
| | } _Py_Identifier; |
| |
|
| | #define _Py_static_string_init(value) { .next = NULL, .string = value, .object = NULL } |
| | #define _Py_static_string(varname, value) static _Py_Identifier varname = _Py_static_string_init(value) |
| | #define _Py_IDENTIFIER(varname) _Py_static_string(PyId_##varname, #varname) |
| |
|
| | |
| | typedef struct bufferinfo { |
| | void *buf; |
| | PyObject *obj; |
| | Py_ssize_t len; |
| | Py_ssize_t itemsize; |
| | |
| | int readonly; |
| | int ndim; |
| | char *format; |
| | Py_ssize_t *shape; |
| | Py_ssize_t *strides; |
| | Py_ssize_t *suboffsets; |
| | void *internal; |
| | } Py_buffer; |
| |
|
| | typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); |
| | typedef void (*releasebufferproc)(PyObject *, Py_buffer *); |
| |
|
| | typedef PyObject *(*vectorcallfunc)(PyObject *callable, PyObject *const *args, |
| | size_t nargsf, PyObject *kwnames); |
| |
|
| | |
| | #define PyBUF_MAX_NDIM 64 |
| |
|
| | |
| | #define PyBUF_SIMPLE 0 |
| | #define PyBUF_WRITABLE 0x0001 |
| | |
| | #define PyBUF_WRITEABLE PyBUF_WRITABLE |
| | #define PyBUF_FORMAT 0x0004 |
| | #define PyBUF_ND 0x0008 |
| | #define PyBUF_STRIDES (0x0010 | PyBUF_ND) |
| | #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) |
| | #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) |
| | #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) |
| | #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) |
| |
|
| | #define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE) |
| | #define PyBUF_CONTIG_RO (PyBUF_ND) |
| |
|
| | #define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE) |
| | #define PyBUF_STRIDED_RO (PyBUF_STRIDES) |
| |
|
| | #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT) |
| | #define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT) |
| |
|
| | #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT) |
| | #define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT) |
| |
|
| |
|
| | #define PyBUF_READ 0x100 |
| | #define PyBUF_WRITE 0x200 |
| | |
| |
|
| |
|
| | typedef struct { |
| | |
| | |
| | |
| |
|
| | binaryfunc nb_add; |
| | binaryfunc nb_subtract; |
| | binaryfunc nb_multiply; |
| | binaryfunc nb_remainder; |
| | binaryfunc nb_divmod; |
| | ternaryfunc nb_power; |
| | unaryfunc nb_negative; |
| | unaryfunc nb_positive; |
| | unaryfunc nb_absolute; |
| | inquiry nb_bool; |
| | unaryfunc nb_invert; |
| | binaryfunc nb_lshift; |
| | binaryfunc nb_rshift; |
| | binaryfunc nb_and; |
| | binaryfunc nb_xor; |
| | binaryfunc nb_or; |
| | unaryfunc nb_int; |
| | void *nb_reserved; |
| | unaryfunc nb_float; |
| |
|
| | binaryfunc nb_inplace_add; |
| | binaryfunc nb_inplace_subtract; |
| | binaryfunc nb_inplace_multiply; |
| | binaryfunc nb_inplace_remainder; |
| | ternaryfunc nb_inplace_power; |
| | binaryfunc nb_inplace_lshift; |
| | binaryfunc nb_inplace_rshift; |
| | binaryfunc nb_inplace_and; |
| | binaryfunc nb_inplace_xor; |
| | binaryfunc nb_inplace_or; |
| |
|
| | binaryfunc nb_floor_divide; |
| | binaryfunc nb_true_divide; |
| | binaryfunc nb_inplace_floor_divide; |
| | binaryfunc nb_inplace_true_divide; |
| |
|
| | unaryfunc nb_index; |
| |
|
| | binaryfunc nb_matrix_multiply; |
| | binaryfunc nb_inplace_matrix_multiply; |
| | } PyNumberMethods; |
| |
|
| | typedef struct { |
| | lenfunc sq_length; |
| | binaryfunc sq_concat; |
| | ssizeargfunc sq_repeat; |
| | ssizeargfunc sq_item; |
| | void *was_sq_slice; |
| | ssizeobjargproc sq_ass_item; |
| | void *was_sq_ass_slice; |
| | objobjproc sq_contains; |
| |
|
| | binaryfunc sq_inplace_concat; |
| | ssizeargfunc sq_inplace_repeat; |
| | } PySequenceMethods; |
| |
|
| | typedef struct { |
| | lenfunc mp_length; |
| | binaryfunc mp_subscript; |
| | objobjargproc mp_ass_subscript; |
| | } PyMappingMethods; |
| |
|
| | typedef struct { |
| | unaryfunc am_await; |
| | unaryfunc am_aiter; |
| | unaryfunc am_anext; |
| | } PyAsyncMethods; |
| |
|
| | typedef struct { |
| | getbufferproc bf_getbuffer; |
| | releasebufferproc bf_releasebuffer; |
| | } PyBufferProcs; |
| |
|
| | |
| | |
| | typedef Py_ssize_t printfunc; |
| |
|
| | struct _typeobject { |
| | PyObject_VAR_HEAD |
| | const char *tp_name; |
| | Py_ssize_t tp_basicsize, tp_itemsize; |
| |
|
| | |
| |
|
| | destructor tp_dealloc; |
| | Py_ssize_t tp_vectorcall_offset; |
| | getattrfunc tp_getattr; |
| | setattrfunc tp_setattr; |
| | PyAsyncMethods *tp_as_async; |
| | |
| | reprfunc tp_repr; |
| |
|
| | |
| |
|
| | PyNumberMethods *tp_as_number; |
| | PySequenceMethods *tp_as_sequence; |
| | PyMappingMethods *tp_as_mapping; |
| |
|
| | |
| |
|
| | hashfunc tp_hash; |
| | ternaryfunc tp_call; |
| | reprfunc tp_str; |
| | getattrofunc tp_getattro; |
| | setattrofunc tp_setattro; |
| |
|
| | |
| | PyBufferProcs *tp_as_buffer; |
| |
|
| | |
| | unsigned long tp_flags; |
| |
|
| | const char *tp_doc; |
| |
|
| | |
| | |
| | traverseproc tp_traverse; |
| |
|
| | |
| | inquiry tp_clear; |
| |
|
| | |
| | |
| | richcmpfunc tp_richcompare; |
| |
|
| | |
| | Py_ssize_t tp_weaklistoffset; |
| |
|
| | |
| | getiterfunc tp_iter; |
| | iternextfunc tp_iternext; |
| |
|
| | |
| | struct PyMethodDef *tp_methods; |
| | struct PyMemberDef *tp_members; |
| | struct PyGetSetDef *tp_getset; |
| | struct _typeobject *tp_base; |
| | PyObject *tp_dict; |
| | descrgetfunc tp_descr_get; |
| | descrsetfunc tp_descr_set; |
| | Py_ssize_t tp_dictoffset; |
| | initproc tp_init; |
| | allocfunc tp_alloc; |
| | newfunc tp_new; |
| | freefunc tp_free; |
| | inquiry tp_is_gc; |
| | PyObject *tp_bases; |
| | PyObject *tp_mro; |
| | PyObject *tp_cache; |
| | PyObject *tp_subclasses; |
| | PyObject *tp_weaklist; |
| | destructor tp_del; |
| |
|
| | |
| | unsigned int tp_version_tag; |
| |
|
| | destructor tp_finalize; |
| | vectorcallfunc tp_vectorcall; |
| | }; |
| |
|
| | |
| | typedef struct _heaptypeobject { |
| | |
| | |
| | PyTypeObject ht_type; |
| | PyAsyncMethods as_async; |
| | PyNumberMethods as_number; |
| | PyMappingMethods as_mapping; |
| | PySequenceMethods as_sequence; |
| | |
| | |
| | |
| | |
| | PyBufferProcs as_buffer; |
| | PyObject *ht_name, *ht_slots, *ht_qualname; |
| | struct _dictkeysobject *ht_cached_keys; |
| | PyObject *ht_module; |
| | |
| | } PyHeapTypeObject; |
| |
|
| | |
| | #define PyHeapType_GET_MEMBERS(etype) \ |
| | ((PyMemberDef *)(((char *)etype) + Py_TYPE(etype)->tp_basicsize)) |
| |
|
| | PyAPI_FUNC(const char *) _PyType_Name(PyTypeObject *); |
| | PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *); |
| | PyAPI_FUNC(PyObject *) _PyType_LookupId(PyTypeObject *, _Py_Identifier *); |
| | PyAPI_FUNC(PyObject *) _PyObject_LookupSpecial(PyObject *, _Py_Identifier *); |
| | PyAPI_FUNC(PyTypeObject *) _PyType_CalculateMetaclass(PyTypeObject *, PyObject *); |
| | PyAPI_FUNC(PyObject *) _PyType_GetDocFromInternalDoc(const char *, const char *); |
| | PyAPI_FUNC(PyObject *) _PyType_GetTextSignatureFromInternalDoc(const char *, const char *); |
| |
|
| | struct _Py_Identifier; |
| | PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int); |
| | PyAPI_FUNC(void) _Py_BreakPoint(void); |
| | PyAPI_FUNC(void) _PyObject_Dump(PyObject *); |
| | PyAPI_FUNC(int) _PyObject_IsFreed(PyObject *); |
| |
|
| | PyAPI_FUNC(int) _PyObject_IsAbstract(PyObject *); |
| | PyAPI_FUNC(PyObject *) _PyObject_GetAttrId(PyObject *, struct _Py_Identifier *); |
| | PyAPI_FUNC(int) _PyObject_SetAttrId(PyObject *, struct _Py_Identifier *, PyObject *); |
| | PyAPI_FUNC(int) _PyObject_HasAttrId(PyObject *, struct _Py_Identifier *); |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | PyAPI_FUNC(int) _PyObject_LookupAttr(PyObject *, PyObject *, PyObject **); |
| | PyAPI_FUNC(int) _PyObject_LookupAttrId(PyObject *, struct _Py_Identifier *, PyObject **); |
| |
|
| | PyAPI_FUNC(int) _PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method); |
| |
|
| | PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *); |
| | PyAPI_FUNC(PyObject *) _PyObject_NextNotImplemented(PyObject *); |
| | PyAPI_FUNC(void) PyObject_CallFinalizer(PyObject *); |
| | PyAPI_FUNC(int) PyObject_CallFinalizerFromDealloc(PyObject *); |
| |
|
| | |
| | |
| | PyAPI_FUNC(PyObject *) |
| | _PyObject_GenericGetAttrWithDict(PyObject *, PyObject *, PyObject *, int); |
| | PyAPI_FUNC(int) |
| | _PyObject_GenericSetAttrWithDict(PyObject *, PyObject *, |
| | PyObject *, PyObject *); |
| |
|
| | PyAPI_FUNC(PyObject *) _PyObject_FunctionStr(PyObject *); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #define Py_SETREF(op, op2) \ |
| | do { \ |
| | PyObject *_py_tmp = _PyObject_CAST(op); \ |
| | (op) = (op2); \ |
| | Py_DECREF(_py_tmp); \ |
| | } while (0) |
| |
|
| | #define Py_XSETREF(op, op2) \ |
| | do { \ |
| | PyObject *_py_tmp = _PyObject_CAST(op); \ |
| | (op) = (op2); \ |
| | Py_XDECREF(_py_tmp); \ |
| | } while (0) |
| |
|
| |
|
| | PyAPI_DATA(PyTypeObject) _PyNone_Type; |
| | PyAPI_DATA(PyTypeObject) _PyNotImplemented_Type; |
| |
|
| | |
| | |
| | |
| | PyAPI_DATA(int) _Py_SwappedOp[]; |
| |
|
| | PyAPI_FUNC(void) |
| | _PyDebugAllocatorStats(FILE *out, const char *block_name, int num_blocks, |
| | size_t sizeof_block); |
| | PyAPI_FUNC(void) |
| | _PyObject_DebugTypeStats(FILE *out); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | #ifdef NDEBUG |
| | |
| | # define _PyObject_ASSERT_FROM(obj, expr, msg, filename, lineno, func) \ |
| | ((void)0) |
| | #else |
| | |
| | # define _PyObject_ASSERT_FROM(obj, expr, msg, filename, lineno, func) \ |
| | ((expr) \ |
| | ? (void)(0) \ |
| | : _PyObject_AssertFailed((obj), Py_STRINGIFY(expr), \ |
| | (msg), (filename), (lineno), (func))) |
| | #endif |
| |
|
| | #define _PyObject_ASSERT_WITH_MSG(obj, expr, msg) \ |
| | _PyObject_ASSERT_FROM(obj, expr, msg, __FILE__, __LINE__, __func__) |
| | #define _PyObject_ASSERT(obj, expr) \ |
| | _PyObject_ASSERT_WITH_MSG(obj, expr, NULL) |
| |
|
| | #define _PyObject_ASSERT_FAILED_MSG(obj, msg) \ |
| | _PyObject_AssertFailed((obj), NULL, (msg), __FILE__, __LINE__, __func__) |
| |
|
| | |
| | |
| | |
| | |
| | |
| | PyAPI_FUNC(void) _Py_NO_RETURN _PyObject_AssertFailed( |
| | PyObject *obj, |
| | const char *expr, |
| | const char *msg, |
| | const char *file, |
| | int line, |
| | const char *function); |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | PyAPI_FUNC(int) _PyObject_CheckConsistency( |
| | PyObject *op, |
| | int check_content); |
| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | |
| | |
| | PyAPI_FUNC(void) _PyTrash_deposit_object(PyObject*); |
| | PyAPI_FUNC(void) _PyTrash_destroy_chain(void); |
| |
|
| | |
| | |
| | PyAPI_FUNC(void) _PyTrash_thread_deposit_object(PyObject*); |
| | PyAPI_FUNC(void) _PyTrash_thread_destroy_chain(void); |
| |
|
| | |
| | struct _ts; |
| |
|
| | |
| | PyAPI_FUNC(int) _PyTrash_begin(struct _ts *tstate, PyObject *op); |
| | PyAPI_FUNC(void) _PyTrash_end(struct _ts *tstate); |
| |
|
| | #define PyTrash_UNWIND_LEVEL 50 |
| |
|
| | #define Py_TRASHCAN_BEGIN_CONDITION(op, cond) \ |
| | do { \ |
| | PyThreadState *_tstate = NULL; \ |
| | |
| | \ |
| | if (cond) { \ |
| | _tstate = PyThreadState_GET(); \ |
| | if (_PyTrash_begin(_tstate, _PyObject_CAST(op))) { \ |
| | break; \ |
| | } \ |
| | } |
| | |
| | #define Py_TRASHCAN_END \ |
| | if (_tstate) { \ |
| | _PyTrash_end(_tstate); \ |
| | } \ |
| | } while (0); |
| |
|
| | #define Py_TRASHCAN_BEGIN(op, dealloc) \ |
| | Py_TRASHCAN_BEGIN_CONDITION(op, \ |
| | Py_TYPE(op)->tp_dealloc == (destructor)(dealloc)) |
| |
|
| | |
| | |
| | #define Py_TRASHCAN_SAFE_BEGIN(op) Py_TRASHCAN_BEGIN_CONDITION(op, 1) |
| | #define Py_TRASHCAN_SAFE_END(op) Py_TRASHCAN_END |
| |
|
| | #ifdef __cplusplus |
| | } |
| | #endif |
| |
|