2001-10-06 05:52:26 +08:00
|
|
|
/* Weak references objects for Python. */
|
|
|
|
|
|
|
|
#ifndef Py_WEAKREFOBJECT_H
|
|
|
|
#define Py_WEAKREFOBJECT_H
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct _PyWeakReference PyWeakReference;
|
|
|
|
|
2002-08-12 15:21:58 +08:00
|
|
|
PyAPI_DATA(PyTypeObject) _PyWeakref_RefType;
|
|
|
|
PyAPI_DATA(PyTypeObject) _PyWeakref_ProxyType;
|
|
|
|
PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType;
|
2001-10-06 05:52:26 +08:00
|
|
|
|
2022-06-16 19:49:43 +08:00
|
|
|
#define PyWeakref_CheckRef(op) PyObject_TypeCheck((op), &_PyWeakref_RefType)
|
2004-07-03 02:57:45 +08:00
|
|
|
#define PyWeakref_CheckRefExact(op) \
|
2022-06-16 19:49:43 +08:00
|
|
|
Py_IS_TYPE((op), &_PyWeakref_RefType)
|
2001-10-06 05:52:26 +08:00
|
|
|
#define PyWeakref_CheckProxy(op) \
|
2022-06-16 19:49:43 +08:00
|
|
|
(Py_IS_TYPE((op), &_PyWeakref_ProxyType) \
|
|
|
|
|| Py_IS_TYPE((op), &_PyWeakref_CallableProxyType))
|
2004-07-03 02:57:45 +08:00
|
|
|
|
2001-10-06 05:52:26 +08:00
|
|
|
#define PyWeakref_Check(op) \
|
|
|
|
(PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op))
|
|
|
|
|
|
|
|
|
2002-08-12 15:21:58 +08:00
|
|
|
PyAPI_FUNC(PyObject *) PyWeakref_NewRef(PyObject *ob,
|
2021-10-19 07:31:57 +08:00
|
|
|
PyObject *callback);
|
2002-08-12 15:21:58 +08:00
|
|
|
PyAPI_FUNC(PyObject *) PyWeakref_NewProxy(PyObject *ob,
|
2021-10-19 07:31:57 +08:00
|
|
|
PyObject *callback);
|
2023-06-26 18:10:53 +08:00
|
|
|
Py_DEPRECATED(3.13) PyAPI_FUNC(PyObject *) PyWeakref_GetObject(PyObject *ref);
|
2023-06-21 17:40:09 +08:00
|
|
|
PyAPI_FUNC(int) PyWeakref_GetRef(PyObject *ref, PyObject **pobj);
|
2001-10-06 05:52:26 +08:00
|
|
|
|
|
|
|
|
2021-10-19 07:31:57 +08:00
|
|
|
#ifndef Py_LIMITED_API
|
|
|
|
# define Py_CPYTHON_WEAKREFOBJECT_H
|
|
|
|
# include "cpython/weakrefobject.h"
|
|
|
|
# undef Py_CPYTHON_WEAKREFOBJECT_H
|
2010-12-04 04:14:31 +08:00
|
|
|
#endif
|
2003-11-21 05:21:46 +08:00
|
|
|
|
2001-10-06 05:52:26 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !Py_WEAKREFOBJECT_H */
|