[Python-checkins] CVS: python/dist/src/Modules spam.c,1.1.2.4,1.1.2.5
Guido van Rossum
gvanrossum@users.sourceforge.net
Tue, 05 Jun 2001 03:49:26 -0700
- Previous message: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.1.2.9,1.1.2.10
- Next message: [Python-checkins] CVS: python/dist/src/Objects dictobject.c,2.80.2.6,2.80.2.7 funcobject.c,2.37.4.3,2.37.4.4 listobject.c,2.92.6.4,2.92.6.5 moduleobject.c,2.31.6.2,2.31.6.3 typeobject.c,2.16.8.25,2.16.8.26
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv20188/Modules
Modified Files:
Tag: descr-branch
spam.c
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: spam.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/Attic/spam.c,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -r1.1.2.4 -r1.1.2.5
*** spam.c 2001/05/14 21:41:41 1.1.2.4
--- spam.c 2001/06/05 10:49:24 1.1.2.5
***************
*** 38,60 ****
staticforward PyTypeObject spamlist_type;
! static PyObject *
! spamlist_construct(spamlistobject *arg, PyObject *args, PyObject *kwds)
{
! spamlistobject *self;
!
! if (arg != NULL)
! self = arg;
! else {
! self = PyObject_New(spamlistobject, &spamlist_type);
! if (self == NULL)
! return NULL;
! }
! if (PyList_Type.tp_construct((PyObject *)self, args, kwds) == NULL) {
! if (self != arg)
! PyObject_Del(self);
! return NULL;
! }
self->state = 0;
! return (PyObject *)self;
}
--- 38,48 ----
staticforward PyTypeObject spamlist_type;
! static int
! spamlist_init(spamlistobject *self, PyObject *args, PyObject *kwds)
{
! if (PyList_Type.tp_init((PyObject *)self, args, kwds) < 0)
! return -1;
self->state = 0;
! return 0;
}
***************
*** 95,99 ****
0, /* tp_descr_get */
0, /* tp_descr_set */
! (ternaryfunc)spamlist_construct, /* tp_construct */
};
--- 83,90 ----
0, /* tp_descr_get */
0, /* tp_descr_set */
! 0, /* tp_dictoffset */
! (initproc)spamlist_init, /* tp_init */
! PyType_GenericAlloc, /* tp_alloc */
! PyType_GenericNew, /* tp_new */
};
***************
*** 141,163 ****
staticforward PyTypeObject spamdict_type;
! static PyObject *
! spamdict_construct(spamdictobject *arg, PyObject *args, PyObject *kwds)
{
! spamdictobject *self;
!
! if (arg != NULL)
! self = arg;
! else {
! self = PyObject_New(spamdictobject, &spamdict_type);
! if (self == NULL)
! return NULL;
! }
! if (PyDict_Type.tp_construct((PyObject *)self, args, kwds) == NULL) {
! if (self != arg)
! PyObject_Del(self);
! return NULL;
! }
self->state = 0;
! return (PyObject *)self;
}
--- 132,142 ----
staticforward PyTypeObject spamdict_type;
! static int
! spamdict_init(spamdictobject *self, PyObject *args, PyObject *kwds)
{
! if (PyDict_Type.tp_init((PyObject *)self, args, kwds) < 0)
! return -1;
self->state = 0;
! return 0;
}
***************
*** 198,202 ****
0, /* tp_descr_get */
0, /* tp_descr_set */
! (ternaryfunc)spamdict_construct, /* tp_construct */
};
--- 177,184 ----
0, /* tp_descr_get */
0, /* tp_descr_set */
! 0, /* tp_dictoffset */
! (initproc)spamdict_init, /* tp_init */
! PyType_GenericAlloc, /* tp_alloc */
! PyType_GenericNew, /* tp_new */
};
- Previous message: [Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.1.2.9,1.1.2.10
- Next message: [Python-checkins] CVS: python/dist/src/Objects dictobject.c,2.80.2.6,2.80.2.7 funcobject.c,2.37.4.3,2.37.4.4 listobject.c,2.92.6.4,2.92.6.5 moduleobject.c,2.31.6.2,2.31.6.3 typeobject.c,2.16.8.25,2.16.8.26
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]