1 /* Weak references objects for Python. */
3 #ifndef Py_WEAKREFOBJECT_H
4 #define Py_WEAKREFOBJECT_H
10 typedef struct _PyWeakReference PyWeakReference
;
12 struct _PyWeakReference
{
15 PyObject
*wr_callback
;
17 PyWeakReference
*wr_prev
;
18 PyWeakReference
*wr_next
;
21 PyAPI_DATA(PyTypeObject
) _PyWeakref_RefType
;
22 PyAPI_DATA(PyTypeObject
) _PyWeakref_ProxyType
;
23 PyAPI_DATA(PyTypeObject
) _PyWeakref_CallableProxyType
;
25 #define PyWeakref_CheckRef(op) \
26 ((op)->ob_type == &_PyWeakref_RefType)
27 #define PyWeakref_CheckProxy(op) \
28 (((op)->ob_type == &_PyWeakref_ProxyType) || \
29 ((op)->ob_type == &_PyWeakref_CallableProxyType))
30 #define PyWeakref_Check(op) \
31 (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op))
34 PyAPI_FUNC(PyObject
*) PyWeakref_NewRef(PyObject
*ob
,
36 PyAPI_FUNC(PyObject
*) PyWeakref_NewProxy(PyObject
*ob
,
38 PyAPI_FUNC(PyObject
*) PyWeakref_GetObject(PyObject
*ref
);
40 PyAPI_FUNC(long) _PyWeakref_GetWeakrefCount(PyWeakReference
*head
);
42 #define PyWeakref_GET_OBJECT(ref) (((PyWeakReference *)(ref))->wr_object)
48 #endif /* !Py_WEAKREFOBJECT_H */