[Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.16.8.50,2.16.8.51

Guido van Rossum gvanrossum@users.sourceforge.net
Fri, 29 Jun 2001 08:50:20 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv11116

Modified Files:
      Tag: descr-branch
	typeobject.c 
Log Message:
Put the new PyType_(SET_)BASICSIZE() macros to use.  (This was an idea
from Tim Peters that removes most of my desire to incorporate Neil's
patch to the GC API.)


Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.16.8.50
retrieving revision 2.16.8.51
diff -C2 -r2.16.8.50 -r2.16.8.51
*** typeobject.c	2001/06/29 15:02:58	2.16.8.50
--- typeobject.c	2001/06/29 15:50:18	2.16.8.51
***************
*** 332,344 ****
  extra_ivars(PyTypeObject *type, PyTypeObject *base)
  {
! 	int t_size = type->tp_basicsize;
! 	int b_size = base->tp_basicsize;
  
- 	assert((type->tp_flags & Py_TPFLAGS_GC) >=
- 	       (base->tp_flags & Py_TPFLAGS_GC)); /* base has GC, type not! */
- 	if (type->tp_flags & Py_TPFLAGS_GC)
- 		t_size -= PyGC_HEAD_SIZE;
- 	if (base->tp_flags & Py_TPFLAGS_GC)
- 		b_size -= PyGC_HEAD_SIZE;
  	assert(t_size >= b_size); /* type smaller than base! */
  	if (type->tp_itemsize || base->tp_itemsize) {
--- 332,338 ----
  extra_ivars(PyTypeObject *type, PyTypeObject *base)
  {
! 	int t_size = PyType_BASICSIZE(type);
! 	int b_size = PyType_BASICSIZE(base);
  
  	assert(t_size >= b_size); /* type smaller than base! */
  	if (type->tp_itemsize || base->tp_itemsize) {
***************
*** 537,543 ****
  	/* Add descriptors for custom slots from __slots__, or for __dict__ */
  	mp = et->members;
! 	slotoffset = base->tp_basicsize;
! 	if (base->tp_flags & Py_TPFLAGS_GC)
! 		slotoffset -= PyGC_HEAD_SIZE;
  	if (slots != NULL) {
  		for (i = 0; i < nslots; i++, mp++) {
--- 531,535 ----
  	/* Add descriptors for custom slots from __slots__, or for __dict__ */
  	mp = et->members;
! 	slotoffset = PyType_BASICSIZE(base);
  	if (slots != NULL) {
  		for (i = 0; i < nslots; i++, mp++) {
***************
*** 962,973 ****
  
  	/* Copying basicsize is connected to the GC flags */
! 	oldsize = base->tp_basicsize;
! 	if (base->tp_flags & Py_TPFLAGS_GC)
! 		oldsize -= PyGC_HEAD_SIZE;
! 	newsize = type->tp_basicsize;
! 	if (newsize && (type->tp_flags & Py_TPFLAGS_GC))
! 		newsize -= PyGC_HEAD_SIZE;
! 	if (!newsize)
! 		newsize = oldsize;
  	if (!(type->tp_flags & Py_TPFLAGS_GC) &&
  	    (base->tp_flags & Py_TPFLAGS_GC) &&
--- 954,959 ----
  
  	/* Copying basicsize is connected to the GC flags */
! 	oldsize = PyType_BASICSIZE(base);
! 	newsize = type->tp_basicsize ? PyType_BASICSIZE(type) : oldsize;
  	if (!(type->tp_flags & Py_TPFLAGS_GC) &&
  	    (base->tp_flags & Py_TPFLAGS_GC) &&
***************
*** 978,984 ****
  		COPYSLOT(tp_clear);
  	}
! 	if (type->tp_flags & Py_TPFLAGS_GC)
! 		newsize += PyGC_HEAD_SIZE;
! 	type->tp_basicsize = newsize;
  
  	COPYSLOT(tp_itemsize);
--- 964,968 ----
  		COPYSLOT(tp_clear);
  	}
! 	PyType_SET_BASICSIZE(type, newsize);
  
  	COPYSLOT(tp_itemsize);