Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / src / nas,5.n2.os.2 / lib / python / include / python2.4 / weakrefobject.h
CommitLineData
86530b38
AT
1#ifndef Py_WEAKREFOBJECT_H
2#define Py_WEAKREFOBJECT_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7
8typedef struct _PyWeakReference PyWeakReference;
9
10/* PyWeakReference is the base struct for the Python ReferenceType, ProxyType,
11 * and CallableProxyType.
12 */
13struct _PyWeakReference {
14 PyObject_HEAD
15
16 /* The object to which this is a weak reference, or Py_None if none.
17 * Note that this is a stealth reference: wr_object's refcount is
18 * not incremented to reflect this pointer.
19 */
20 PyObject *wr_object;
21
22 /* A callable to invoke when wr_object dies, or NULL if none. */
23 PyObject *wr_callback;
24
25 /* A cache for wr_object's hash code. As usual for hashes, this is -1
26 * if the hash code isn't known yet.
27 */
28 long hash;
29
30 /* If wr_object is weakly referenced, wr_object has a doubly-linked NULL-
31 * terminated list of weak references to it. These are the list pointers.
32 * If wr_object goes away, wr_object is set to Py_None, and these pointers
33 * have no meaning then.
34 */
35 PyWeakReference *wr_prev;
36 PyWeakReference *wr_next;
37};
38
39PyAPI_DATA(PyTypeObject) _PyWeakref_RefType;
40PyAPI_DATA(PyTypeObject) _PyWeakref_ProxyType;
41PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType;
42
43#define PyWeakref_CheckRef(op) PyObject_TypeCheck(op, &_PyWeakref_RefType)
44#define PyWeakref_CheckRefExact(op) \
45 ((op)->ob_type == &_PyWeakref_RefType)
46#define PyWeakref_CheckProxy(op) \
47 (((op)->ob_type == &_PyWeakref_ProxyType) || \
48 ((op)->ob_type == &_PyWeakref_CallableProxyType))
49
50/* This macro calls PyWeakref_CheckRef() last since that can involve a
51 function call; this makes it more likely that the function call
52 will be avoided. */
53#define PyWeakref_Check(op) \
54 (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op))
55
56
57PyAPI_FUNC(PyObject *) PyWeakref_NewRef(PyObject *ob,
58 PyObject *callback);
59PyAPI_FUNC(PyObject *) PyWeakref_NewProxy(PyObject *ob,
60 PyObject *callback);
61PyAPI_FUNC(PyObject *) PyWeakref_GetObject(PyObject *ref);
62
63PyAPI_FUNC(long) _PyWeakref_GetWeakrefCount(PyWeakReference *head);
64
65PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self);
66
67#define PyWeakref_GET_OBJECT(ref) (((PyWeakReference *)(ref))->wr_object)
68
69
70#ifdef __cplusplus
71}
72#endif
73#endif /* !Py_WEAKREFOBJECT_H */