[Python-checkins] CVS: python/dist/src/Include objimpl.h,2.34.4.1,2.34.4.2

Guido van Rossum gvanrossum@users.sourceforge.net
2001年6月29日 08:48:23 -0700


Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv10465
Modified Files:
 Tag: descr-branch
	objimpl.h 
Log Message:
PyType_BASICSIZE() and PyType_SET_BASICSIZE(): two macros that make
calculations involving tp_basicsize easier, by automating the
PyGC_HEAD_SIZE bias calculation.
Index: objimpl.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/objimpl.h,v
retrieving revision 2.34.4.1
retrieving revision 2.34.4.2
diff -C2 -r2.34.4.1 -r2.34.4.2
*** objimpl.h	2001年05月04日 16:48:08	2.34.4.1
--- objimpl.h	2001年06月29日 15:48:21	2.34.4.2
***************
*** 241,244 ****
--- 241,246 ----
 #define PyObject_AS_GC(o) (o)
 #define PyObject_FROM_GC(o) (o)
+ #define PyType_BASICSIZE(t) ((t)->tp_basicsize)
+ #define PyType_SET_BASICSIZE(t, s) ((t)->tp_basicsize = (s))
 
 #else
***************
*** 273,276 ****
--- 275,285 ----
 /* Get the object given the PyGC_Head */
 #define PyObject_FROM_GC(g) ((PyObject *)(((PyGC_Head *)g)+1))
+ 
+ /* Calculate tp_basicsize excluding PyGC_HEAD_SIZE if applicable */
+ #define PyType_BASICSIZE(t) (!PyType_IS_GC(t) ? (t)->tp_basicsize : \
+ 			 (t)->tp_basicsize - PyGC_HEAD_SIZE)
+ #define PyType_SET_BASICSIZE(t, s) (!PyType_IS_GC(t) ? \
+ 			((t)->tp_basicsize = (s)) : \
+ 			((t)->tp_basicsize = (s) + PyGC_HEAD_SIZE))
 
 extern DL_IMPORT(void) _PyGC_Dump(PyGC_Head *);

AltStyle によって変換されたページ (->オリジナル) /