[Python-checkins] CVS: python/dist/src/Include object.h,2.79.2.8,2.79.2.9
Guido van Rossum
gvanrossum@users.sourceforge.net
Tue, 05 Jun 2001 03:49:26 -0700
Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv20188/Include
Modified Files:
Tag: descr-branch
object.h
Log Message:
Redo object creation; touching many files.
- Get rid of tp_construct, it had a bogus interface (this moves
tp_dictoffset one slot up).
- New tp_ slots; the last two are "type methods" (their first
argument is a type object, not an instance of that type):
- tp_init is what tp_construct wanted to be, without the allocation;
- tp_alloc does low-level allocation, initializing the object to its
most basic form (up to and including registering it with the GC
machinery);
- tp_new does high-level object creation: it calls tp_alloc and then
tp_init.
- New generic functions PyType_GenericAlloc() and PyType_GenericNew()
provide default implementations for tp_alloc and tp_new that are
usually sufficient.
- Used the above things to make standard list, dict and module objects
subtypable as before.
- Remove tp_construct initializer spacer from funcobject.c.
- Add an __init__() override test to test_descr.py.
Index: object.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/object.h,v
retrieving revision 2.79.2.8
retrieving revision 2.79.2.9
diff -C2 -r2.79.2.8 -r2.79.2.9
*** object.h 2001/05/22 17:21:18 2.79.2.8
--- object.h 2001/06/05 10:49:24 2.79.2.9
***************
*** 205,208 ****
--- 205,210 ----
typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *);
typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *);
+ typedef int (*initproc)(PyObject *, PyObject *, PyObject *);
+ typedef PyObject *(*allocfunc)(struct _typeobject *, PyObject *, PyObject *);
typedef struct _typeobject {
***************
*** 266,273 ****
descrgetfunc tp_descr_get;
descrsetfunc tp_descr_set;
- ternaryfunc tp_construct;
long tp_dictoffset;
-
#ifdef COUNT_ALLOCS
/* these must be last and never explicitly initialized */
--- 268,276 ----
descrgetfunc tp_descr_get;
descrsetfunc tp_descr_set;
long tp_dictoffset;
+ initproc tp_init;
+ allocfunc tp_alloc;
+ allocfunc tp_new;
#ifdef COUNT_ALLOCS
/* these must be last and never explicitly initialized */
***************
*** 290,293 ****
--- 293,300 ----
extern DL_IMPORT(int) PyType_InitDict(PyTypeObject *);
+ extern DL_IMPORT(PyObject *) PyType_GenericAlloc(PyTypeObject *,
+ PyObject *, PyObject *);
+ extern DL_IMPORT(PyObject *) PyType_GenericNew(PyTypeObject *,
+ PyObject *, PyObject *);
/* Generic operations on objects */