| #ifndef Py_CPYTHON_OBJECT_H |
| # error "this header file must not be included directly" |
| #endif |
|
|
| PyAPI_FUNC(void) _Py_NewReference(PyObject *op); |
| PyAPI_FUNC(void) _Py_NewReferenceNoTotal(PyObject *op); |
| PyAPI_FUNC(void) _Py_ResurrectReference(PyObject *op); |
|
|
| #ifdef Py_REF_DEBUG |
| |
| PyAPI_FUNC(Py_ssize_t) _Py_GetGlobalRefTotal(void); |
| # define _Py_GetRefTotal() _Py_GetGlobalRefTotal() |
| PyAPI_FUNC(Py_ssize_t) _Py_GetLegacyRefTotal(void); |
| PyAPI_FUNC(Py_ssize_t) _PyInterpreterState_GetRefTotal(PyInterpreterState *); |
| #endif |
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| typedef struct _Py_Identifier { |
| const char* string; |
| |
| |
| Py_ssize_t index; |
| |
| struct { |
| uint8_t v; |
| } mutex; |
| } _Py_Identifier; |
|
|
| #ifndef Py_BUILD_CORE |
| |
| |
|
|
| #define _Py_static_string_init(value) { .string = (value), .index = -1 } |
| #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) |
|
|
| #endif |
|
|
|
|
| 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 PySendResult (*sendfunc)(PyObject *iter, PyObject *value, PyObject **result); |
|
|
| typedef struct { |
| unaryfunc am_await; |
| unaryfunc am_aiter; |
| unaryfunc am_anext; |
| sendfunc am_send; |
| } 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; |
|
|
| |
| PyMethodDef *tp_methods; |
| PyMemberDef *tp_members; |
| PyGetSetDef *tp_getset; |
| |
| PyTypeObject *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; |
| void *tp_subclasses; |
| PyObject *tp_weaklist; |
| destructor tp_del; |
|
|
| |
| unsigned int tp_version_tag; |
|
|
| destructor tp_finalize; |
| vectorcallfunc tp_vectorcall; |
|
|
| |
| unsigned char tp_watched; |
| uint16_t tp_versions_used; |
| }; |
|
|
| |
| |
| |
| struct _specialization_cache { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| PyObject *getitem; |
| uint32_t getitem_version; |
| PyObject *init; |
| }; |
|
|
| |
| 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; |
| char *_ht_tpname; |
| struct _specialization_cache _spec_cache; |
| |
| } PyHeapTypeObject; |
|
|
| PyAPI_FUNC(const char *) _PyType_Name(PyTypeObject *); |
| PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *); |
| PyAPI_FUNC(PyObject *) _PyType_LookupRef(PyTypeObject *, PyObject *); |
| PyAPI_FUNC(PyObject *) PyType_GetDict(PyTypeObject *); |
|
|
| PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int); |
| PyAPI_FUNC(void) _Py_BreakPoint(void); |
| PyAPI_FUNC(void) _PyObject_Dump(PyObject *); |
|
|
| PyAPI_FUNC(PyObject*) _PyObject_GetAttrId(PyObject *, _Py_Identifier *); |
|
|
| PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *); |
| PyAPI_FUNC(void) PyObject_CallFinalizer(PyObject *); |
| PyAPI_FUNC(int) PyObject_CallFinalizerFromDealloc(PyObject *); |
|
|
| PyAPI_FUNC(void) PyUnstable_Object_ClearWeakRefsNoCallbacks(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 *); |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #ifdef _Py_TYPEOF |
| #define Py_SETREF(dst, src) \ |
| do { \ |
| _Py_TYPEOF(dst)* _tmp_dst_ptr = &(dst); \ |
| _Py_TYPEOF(dst) _tmp_old_dst = (*_tmp_dst_ptr); \ |
| *_tmp_dst_ptr = (src); \ |
| Py_DECREF(_tmp_old_dst); \ |
| } while (0) |
| #else |
| #define Py_SETREF(dst, src) \ |
| do { \ |
| PyObject **_tmp_dst_ptr = _Py_CAST(PyObject**, &(dst)); \ |
| PyObject *_tmp_old_dst = (*_tmp_dst_ptr); \ |
| PyObject *_tmp_src = _PyObject_CAST(src); \ |
| memcpy(_tmp_dst_ptr, &_tmp_src, sizeof(PyObject*)); \ |
| Py_DECREF(_tmp_old_dst); \ |
| } while (0) |
| #endif |
|
|
| |
| |
| |
| #ifdef _Py_TYPEOF |
| #define Py_XSETREF(dst, src) \ |
| do { \ |
| _Py_TYPEOF(dst)* _tmp_dst_ptr = &(dst); \ |
| _Py_TYPEOF(dst) _tmp_old_dst = (*_tmp_dst_ptr); \ |
| *_tmp_dst_ptr = (src); \ |
| Py_XDECREF(_tmp_old_dst); \ |
| } while (0) |
| #else |
| #define Py_XSETREF(dst, src) \ |
| do { \ |
| PyObject **_tmp_dst_ptr = _Py_CAST(PyObject**, &(dst)); \ |
| PyObject *_tmp_old_dst = (*_tmp_dst_ptr); \ |
| PyObject *_tmp_src = _PyObject_CAST(src); \ |
| memcpy(_tmp_dst_ptr, &_tmp_src, sizeof(PyObject*)); \ |
| Py_XDECREF(_tmp_old_dst); \ |
| } while (0) |
| #endif |
|
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #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) _PyTrash_begin(PyThreadState *tstate, PyObject *op); |
| PyAPI_FUNC(void) _PyTrash_end(PyThreadState *tstate); |
|
|
| PyAPI_FUNC(void) _PyTrash_thread_deposit_object(PyThreadState *tstate, PyObject *op); |
| PyAPI_FUNC(void) _PyTrash_thread_destroy_chain(PyThreadState *tstate); |
|
|
|
|
| |
|
|
| |
| |
| |
| #define Py_TRASHCAN_HEADROOM 50 |
|
|
| #define Py_TRASHCAN_BEGIN(op, dealloc) \ |
| do { \ |
| PyThreadState *tstate = PyThreadState_Get(); \ |
| if (tstate->c_recursion_remaining <= Py_TRASHCAN_HEADROOM && Py_TYPE(op)->tp_dealloc == (destructor)dealloc) { \ |
| _PyTrash_thread_deposit_object(tstate, (PyObject *)op); \ |
| break; \ |
| } \ |
| tstate->c_recursion_remaining--; |
| |
| #define Py_TRASHCAN_END \ |
| tstate->c_recursion_remaining++; \ |
| if (tstate->delete_later && tstate->c_recursion_remaining > (Py_TRASHCAN_HEADROOM*2)) { \ |
| _PyTrash_thread_destroy_chain(tstate); \ |
| } \ |
| } while (0); |
|
|
|
|
| PyAPI_FUNC(void *) PyObject_GetItemData(PyObject *obj); |
|
|
| PyAPI_FUNC(int) PyObject_VisitManagedDict(PyObject *obj, visitproc visit, void *arg); |
| PyAPI_FUNC(int) _PyObject_SetManagedDict(PyObject *obj, PyObject *new_dict); |
| PyAPI_FUNC(void) PyObject_ClearManagedDict(PyObject *obj); |
|
|
| #define TYPE_MAX_WATCHERS 8 |
|
|
| typedef int(*PyType_WatchCallback)(PyTypeObject *); |
| PyAPI_FUNC(int) PyType_AddWatcher(PyType_WatchCallback callback); |
| PyAPI_FUNC(int) PyType_ClearWatcher(int watcher_id); |
| PyAPI_FUNC(int) PyType_Watch(int watcher_id, PyObject *type); |
| PyAPI_FUNC(int) PyType_Unwatch(int watcher_id, PyObject *type); |
|
|
| |
| |
| |
| |
| |
| PyAPI_FUNC(int) PyUnstable_Type_AssignVersionTag(PyTypeObject *type); |
|
|
|
|
| typedef enum { |
| PyRefTracer_CREATE = 0, |
| PyRefTracer_DESTROY = 1, |
| } PyRefTracerEvent; |
|
|
| typedef int (*PyRefTracer)(PyObject *, PyRefTracerEvent event, void *); |
| PyAPI_FUNC(int) PyRefTracer_SetTracer(PyRefTracer tracer, void *data); |
| PyAPI_FUNC(PyRefTracer) PyRefTracer_GetTracer(void**); |
|
|