#include "Python.h"
#include "pycore_critical_section.h"
#include "pycore_lock.h"
#include "pycore_modsupport.h"
#include "pycore_object.h"
#include "pycore_pyerrors.h"
#include "pycore_pystate.h"
#include "pycore_weakref.h"
#ifdef Py_GIL_DISABLED
#endif
#define GET_WEAKREFS_LISTPTR(o) …
Py_ssize_t
_PyWeakref_GetWeakrefCount(PyObject *obj)
{ … }
static PyObject *weakref_vectorcall(PyObject *self, PyObject *const *args, size_t nargsf, PyObject *kwnames);
static void
init_weakref(PyWeakReference *self, PyObject *ob, PyObject *callback)
{ … }
static void
clear_weakref_lock_held(PyWeakReference *self, PyObject **callback)
{ … }
static void
clear_weakref(PyObject *op)
{ … }
void
_PyWeakref_ClearRef(PyWeakReference *self)
{ … }
static void
weakref_dealloc(PyObject *self)
{ … }
static int
gc_traverse(PyObject *op, visitproc visit, void *arg)
{ … }
static int
gc_clear(PyObject *op)
{ … }
static PyObject *
weakref_vectorcall(PyObject *self, PyObject *const *args,
size_t nargsf, PyObject *kwnames)
{ … }
static Py_hash_t
weakref_hash_lock_held(PyWeakReference *self)
{ … }
static Py_hash_t
weakref_hash(PyObject *op)
{ … }
static PyObject *
weakref_repr(PyObject *self)
{ … }
static PyObject *
weakref_richcompare(PyObject* self, PyObject* other, int op)
{ … }
static void
get_basic_refs(PyWeakReference *head,
PyWeakReference **refp, PyWeakReference **proxyp)
{ … }
static void
insert_after(PyWeakReference *newref, PyWeakReference *prev)
{ … }
static void
insert_head(PyWeakReference *newref, PyWeakReference **list)
{ … }
static PyWeakReference *
try_reuse_basic_ref(PyWeakReference *list, PyTypeObject *type,
PyObject *callback)
{ … }
static int
is_basic_ref(PyWeakReference *ref)
{ … }
static int
is_basic_proxy(PyWeakReference *proxy)
{ … }
static int
is_basic_ref_or_proxy(PyWeakReference *wr)
{ … }
static void
insert_weakref(PyWeakReference *newref, PyWeakReference **list)
{ … }
static PyWeakReference *
allocate_weakref(PyTypeObject *type, PyObject *obj, PyObject *callback)
{ … }
static PyWeakReference *
get_or_create_weakref(PyTypeObject *type, PyObject *obj, PyObject *callback)
{ … }
static int
parse_weakref_init_args(const char *funcname, PyObject *args, PyObject *kwargs,
PyObject **obp, PyObject **callbackp)
{ … }
static PyObject *
weakref___new__(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{ … }
static int
weakref___init__(PyObject *self, PyObject *args, PyObject *kwargs)
{ … }
static PyMemberDef weakref_members[] = …;
static PyMethodDef weakref_methods[] = …;
PyTypeObject
_PyWeakref_RefType = …;
static bool
proxy_check_ref(PyObject *obj)
{ … }
#define UNWRAP(o) …
#define WRAP_UNARY(method, generic) …
#define WRAP_BINARY(method, generic) …
#define WRAP_TERNARY(method, generic) …
#define WRAP_METHOD(method, SPECIAL) …
WRAP_BINARY(proxy_getattr, PyObject_GetAttr)
WRAP_UNARY(proxy_str, PyObject_Str)
WRAP_TERNARY(proxy_call, PyObject_Call)
static PyObject *
proxy_repr(PyObject *proxy)
{ … }
static int
proxy_setattr(PyObject *proxy, PyObject *name, PyObject *value)
{ … }
static PyObject *
proxy_richcompare(PyObject *proxy, PyObject *v, int op)
{ … }
WRAP_BINARY(proxy_add, PyNumber_Add)
WRAP_BINARY(proxy_sub, PyNumber_Subtract)
WRAP_BINARY(proxy_mul, PyNumber_Multiply)
WRAP_BINARY(proxy_floor_div, PyNumber_FloorDivide)
WRAP_BINARY(proxy_true_div, PyNumber_TrueDivide)
WRAP_BINARY(proxy_mod, PyNumber_Remainder)
WRAP_BINARY(proxy_divmod, PyNumber_Divmod)
WRAP_TERNARY(proxy_pow, PyNumber_Power)
WRAP_UNARY(proxy_neg, PyNumber_Negative)
WRAP_UNARY(proxy_pos, PyNumber_Positive)
WRAP_UNARY(proxy_abs, PyNumber_Absolute)
WRAP_UNARY(proxy_invert, PyNumber_Invert)
WRAP_BINARY(proxy_lshift, PyNumber_Lshift)
WRAP_BINARY(proxy_rshift, PyNumber_Rshift)
WRAP_BINARY(proxy_and, PyNumber_And)
WRAP_BINARY(proxy_xor, PyNumber_Xor)
WRAP_BINARY(proxy_or, PyNumber_Or)
WRAP_UNARY(proxy_int, PyNumber_Long)
WRAP_UNARY(proxy_float, PyNumber_Float)
WRAP_BINARY(proxy_iadd, PyNumber_InPlaceAdd)
WRAP_BINARY(proxy_isub, PyNumber_InPlaceSubtract)
WRAP_BINARY(proxy_imul, PyNumber_InPlaceMultiply)
WRAP_BINARY(proxy_ifloor_div, PyNumber_InPlaceFloorDivide)
WRAP_BINARY(proxy_itrue_div, PyNumber_InPlaceTrueDivide)
WRAP_BINARY(proxy_imod, PyNumber_InPlaceRemainder)
WRAP_TERNARY(proxy_ipow, PyNumber_InPlacePower)
WRAP_BINARY(proxy_ilshift, PyNumber_InPlaceLshift)
WRAP_BINARY(proxy_irshift, PyNumber_InPlaceRshift)
WRAP_BINARY(proxy_iand, PyNumber_InPlaceAnd)
WRAP_BINARY(proxy_ixor, PyNumber_InPlaceXor)
WRAP_BINARY(proxy_ior, PyNumber_InPlaceOr)
WRAP_UNARY(proxy_index, PyNumber_Index)
WRAP_BINARY(proxy_matmul, PyNumber_MatrixMultiply)
WRAP_BINARY(proxy_imatmul, PyNumber_InPlaceMatrixMultiply)
static int
proxy_bool(PyObject *proxy)
{ … }
static void
proxy_dealloc(PyObject *self)
{ … }
static int
proxy_contains(PyObject *proxy, PyObject *value)
{ … }
static Py_ssize_t
proxy_length(PyObject *proxy)
{ … }
WRAP_BINARY(proxy_getitem, PyObject_GetItem)
static int
proxy_setitem(PyObject *proxy, PyObject *key, PyObject *value)
{ … }
static PyObject *
proxy_iter(PyObject *proxy)
{ … }
static PyObject *
proxy_iternext(PyObject *proxy)
{ … }
WRAP_METHOD(…)
WRAP_METHOD(…)
static PyMethodDef proxy_methods[] = …;
static PyNumberMethods proxy_as_number = …;
static PySequenceMethods proxy_as_sequence = …;
static PyMappingMethods proxy_as_mapping = …;
PyTypeObject
_PyWeakref_ProxyType = …;
PyTypeObject
_PyWeakref_CallableProxyType = …;
PyObject *
PyWeakref_NewRef(PyObject *ob, PyObject *callback)
{ … }
PyObject *
PyWeakref_NewProxy(PyObject *ob, PyObject *callback)
{ … }
int
PyWeakref_GetRef(PyObject *ref, PyObject **pobj)
{ … }
PyObject *
PyWeakref_GetObject(PyObject *ref)
{ … }
static void
handle_callback(PyWeakReference *ref, PyObject *callback)
{ … }
void
PyObject_ClearWeakRefs(PyObject *object)
{ … }
void
PyUnstable_Object_ClearWeakRefsNoCallbacks(PyObject *obj)
{ … }
void
_PyStaticType_ClearWeakRefs(PyInterpreterState *interp, PyTypeObject *type)
{ … }
void
_PyWeakref_ClearWeakRefsNoCallbacks(PyObject *obj)
{ … }
int
_PyWeakref_IsDead(PyObject *weakref)
{ … }