2001-10-05 21:52:26 +00: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 07:21:58 +00:00
|
|
|
PyAPI_DATA(PyTypeObject) _PyWeakref_RefType;
|
|
|
|
PyAPI_DATA(PyTypeObject) _PyWeakref_ProxyType;
|
|
|
|
PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType;
|
2001-10-05 21:52:26 +00:00
|
|
|
|
2022-06-16 11:49:43 +00:00
|
|
|
#define PyWeakref_CheckRef(op) PyObject_TypeCheck((op), &_PyWeakref_RefType)
|
2004-07-02 18:57:45 +00:00
|
|
|
#define PyWeakref_CheckRefExact(op) \
|
2022-06-16 11:49:43 +00:00
|
|
|
Py_IS_TYPE((op), &_PyWeakref_RefType)
|
2001-10-05 21:52:26 +00:00
|
|
|
#define PyWeakref_CheckProxy(op) \
|
2022-06-16 11:49:43 +00:00
|
|
|
(Py_IS_TYPE((op), &_PyWeakref_ProxyType) \
|
|
|
|
|| Py_IS_TYPE((op), &_PyWeakref_CallableProxyType))
|
2004-07-02 18:57:45 +00:00
|
|
|
|
2001-10-05 21:52:26 +00:00
|
|
|
#define PyWeakref_Check(op) \
|
|
|
|
(PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op))
|
|
|
|
|
|
|
|
|
2002-08-12 07:21:58 +00:00
|
|
|
PyAPI_FUNC(PyObject *) PyWeakref_NewRef(PyObject *ob,
|
2021-10-18 23:31:57 +00:00
|
|
|
PyObject *callback);
|
2002-08-12 07:21:58 +00:00
|
|
|
PyAPI_FUNC(PyObject *) PyWeakref_NewProxy(PyObject *ob,
|
2021-10-18 23:31:57 +00:00
|
|
|
PyObject *callback);
|
2023-06-26 10:10:53 +00:00
|
|
|
Py_DEPRECATED(3.13) PyAPI_FUNC(PyObject *) PyWeakref_GetObject(PyObject *ref);
|
2024-03-20 22:52:23 +00:00
|
|
|
|
|
|
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030D0000
|
2023-06-21 09:40:09 +00:00
|
|
|
PyAPI_FUNC(int) PyWeakref_GetRef(PyObject *ref, PyObject **pobj);
|
2024-03-20 22:52:23 +00:00
|
|
|
#endif
|
2001-10-05 21:52:26 +00:00
|
|
|
|
|
|
|
|
2021-10-18 23:31:57 +00:00
|
|
|
#ifndef Py_LIMITED_API
|
|
|
|
# define Py_CPYTHON_WEAKREFOBJECT_H
|
|
|
|
# include "cpython/weakrefobject.h"
|
|
|
|
# undef Py_CPYTHON_WEAKREFOBJECT_H
|
2010-12-03 20:14:31 +00:00
|
|
|
#endif
|
2003-11-20 21:21:46 +00:00
|
|
|
|
2001-10-05 21:52:26 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* !Py_WEAKREFOBJECT_H */
|