[Python-checkins] CVS: python/dist/src/Include classobject.h,2.35,2.36 object.h,2.73,2.74 objimpl.h,2.30,2.31
Fred L. Drake
fdrake@users.sourceforge.net
Wed, 31 Jan 2001 21:25:29 -0800
Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv17385/Include
Modified Files:
classobject.h object.h objimpl.h
Log Message:
PEP 205, Weak References -- initial checkin.
Index: classobject.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/classobject.h,v
retrieving revision 2.35
retrieving revision 2.36
diff -C2 -r2.35 -r2.36
*** classobject.h 2001/01/28 03:52:08 2.35
--- classobject.h 2001/02/01 05:25:27 2.36
***************
*** 25,28 ****
--- 25,29 ----
PyClassObject *in_class; /* The class object */
PyObject *in_dict; /* A dictionary */
+ PyObject *in_weakreflist; /* List of weak references */
} PyInstanceObject;
Index: object.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/object.h,v
retrieving revision 2.73
retrieving revision 2.74
diff -C2 -r2.73 -r2.74
*** object.h 2001/01/24 22:13:48 2.73
--- object.h 2001/02/01 05:25:27 2.74
***************
*** 247,252 ****
richcmpfunc tp_richcompare;
! /* More spares */
! long tp_xxx8;
#ifdef COUNT_ALLOCS
--- 247,252 ----
richcmpfunc tp_richcompare;
! /* weak reference enabler */
! long tp_weaklistoffset;
#ifdef COUNT_ALLOCS
***************
*** 285,288 ****
--- 285,290 ----
extern DL_IMPORT(int) PyNumber_CoerceEx(PyObject **, PyObject **);
+ extern DL_IMPORT(int) (*PyObject_ClearWeakRefs)(PyObject *);
+
/* Helpers for printing recursive container types */
extern DL_IMPORT(int) Py_ReprEnter(PyObject *);
***************
*** 419,423 ****
#define Py_INCREF(op) (_Py_RefTotal++, (op)->ob_refcnt++)
#define Py_DECREF(op) \
! if (--_Py_RefTotal, --(op)->ob_refcnt != 0) \
; \
else \
--- 421,425 ----
#define Py_INCREF(op) (_Py_RefTotal++, (op)->ob_refcnt++)
#define Py_DECREF(op) \
! if (--_Py_RefTotal, (--((op)->ob_refcnt) != 0)) \
; \
else \
Index: objimpl.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/objimpl.h,v
retrieving revision 2.30
retrieving revision 2.31
diff -C2 -r2.30 -r2.31
*** objimpl.h 2001/01/24 04:17:26 2.30
--- objimpl.h 2001/02/01 05:25:27 2.31
***************
*** 161,165 ****
Note that these macros expect non-NULL object pointers.*/
#define PyObject_INIT(op, typeobj) \
! ( (op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), (op) )
#define PyObject_INIT_VAR(op, typeobj, size) \
( (op)->ob_size = (size), PyObject_INIT((op), (typeobj)) )
--- 161,169 ----
Note that these macros expect non-NULL object pointers.*/
#define PyObject_INIT(op, typeobj) \
! ((op)->ob_type = (typeobj), _Py_NewReference((PyObject *)(op)), \
! (PyType_SUPPORTS_WEAKREFS((typeobj)) \
! ? *(PyObject_GET_WEAKREFS_LISTPTR(op)) = NULL \
! : NULL), \
! (op))
#define PyObject_INIT_VAR(op, typeobj, size) \
( (op)->ob_size = (size), PyObject_INIT((op), (typeobj)) )
***************
*** 266,269 ****
--- 270,279 ----
#endif /* WITH_CYCLE_GC */
+
+ /* Test if a type supports weak references */
+ #define PyType_SUPPORTS_WEAKREFS(t) ((t)->tp_weaklistoffset > 0)
+
+ #define PyObject_GET_WEAKREFS_LISTPTR(o) \
+ ((PyObject **) (((char *) (o)) + (o)->ob_type->tp_weaklistoffset))
#ifdef __cplusplus