1/* Weak references objects for Python. */
2
3#ifndef Py_WEAKREFOBJECT_H
4#define Py_WEAKREFOBJECT_H
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9typedef struct _PyWeakReference PyWeakReference;
10
11PyAPI_DATA(PyTypeObject) _PyWeakref_RefType;
12PyAPI_DATA(PyTypeObject) _PyWeakref_ProxyType;
13PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType;
14
15#define PyWeakref_CheckRef(op) PyObject_TypeCheck((op), &_PyWeakref_RefType)
16#define PyWeakref_CheckRefExact(op) \
17 Py_IS_TYPE((op), &_PyWeakref_RefType)
18#define PyWeakref_CheckProxy(op) \
19 (Py_IS_TYPE((op), &_PyWeakref_ProxyType) \
20 || Py_IS_TYPE((op), &_PyWeakref_CallableProxyType))
21
22#define PyWeakref_Check(op) \
23 (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op))
24
25
26PyAPI_FUNC(PyObject *) PyWeakref_NewRef(PyObject *ob,
27 PyObject *callback);
28PyAPI_FUNC(PyObject *) PyWeakref_NewProxy(PyObject *ob,
29 PyObject *callback);
30PyAPI_FUNC(PyObject *) PyWeakref_GetObject(PyObject *ref);
31
32
33#ifndef Py_LIMITED_API
34# define Py_CPYTHON_WEAKREFOBJECT_H
35# include "cpython/weakrefobject.h"
36# undef Py_CPYTHON_WEAKREFOBJECT_H
37#endif
38
39#ifdef __cplusplus
40}
41#endif
42#endif /* !Py_WEAKREFOBJECT_H */
43

source code of include/python3.12/weakrefobject.h