diff options
author | Christian Heimes <christian@cheimes.de> | 2007-11-29 22:35:39 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-11-29 22:35:39 (GMT) |
commit | a22e8bdfd92cd4f1bc3d60e91df6410c4efde6a0 (patch) | |
tree | 8f865b488f65ff8bab485bafe1cdd8516a65c679 /Objects | |
parent | 513b2ac76c1f56f5a6e0d07fee57d823819ee873 (diff) | |
download | cpython-a22e8bdfd92cd4f1bc3d60e91df6410c4efde6a0.zip cpython-a22e8bdfd92cd4f1bc3d60e91df6410c4efde6a0.tar.gz cpython-a22e8bdfd92cd4f1bc3d60e91df6410c4efde6a0.tar.bz2 |
Added all PyTypeObjects to the appropriate header files.
Before the patch a lot of internal types weren't available in the header files. The patch exposes the new iterators, views and some other types to all C modules. I've also renamed some of the types and tp_names.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/descrobject.c | 12 | ||||
-rw-r--r-- | Objects/dictobject.c | 18 | ||||
-rw-r--r-- | Objects/iterobject.c | 6 | ||||
-rw-r--r-- | Objects/listobject.c | 16 | ||||
-rw-r--r-- | Objects/rangeobject.c | 12 | ||||
-rw-r--r-- | Objects/setobject.c | 2 | ||||
-rw-r--r-- | Objects/tupleobject.c | 2 |
7 files changed, 25 insertions, 43 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 294c7b3..c4d55e4 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -383,7 +383,7 @@ descr_traverse(PyObject *self, visitproc visit, void *arg) return 0; } -static PyTypeObject PyMethodDescr_Type = { +PyTypeObject PyMethodDescr_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "method_descriptor", sizeof(PyMethodDescrObject), @@ -421,7 +421,7 @@ static PyTypeObject PyMethodDescr_Type = { }; /* This is for METH_CLASS in C, not for "f = classmethod(f)" in Python! */ -static PyTypeObject PyClassMethodDescr_Type = { +PyTypeObject PyClassMethodDescr_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "classmethod_descriptor", sizeof(PyMethodDescrObject), @@ -458,7 +458,7 @@ static PyTypeObject PyClassMethodDescr_Type = { 0, /* tp_descr_set */ }; -static PyTypeObject PyMemberDescr_Type = { +PyTypeObject PyMemberDescr_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "member_descriptor", sizeof(PyMemberDescrObject), @@ -495,7 +495,7 @@ static PyTypeObject PyMemberDescr_Type = { (descrsetfunc)member_set, /* tp_descr_set */ }; -static PyTypeObject PyGetSetDescr_Type = { +PyTypeObject PyGetSetDescr_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "getset_descriptor", sizeof(PyGetSetDescrObject), @@ -786,7 +786,7 @@ proxy_richcompare(proxyobject *v, PyObject *w, int op) return PyObject_RichCompare(v->dict, w, op); } -static PyTypeObject proxytype = { +PyTypeObject PyDictProxy_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "dictproxy", /* tp_name */ sizeof(proxyobject), /* tp_basicsize */ @@ -829,7 +829,7 @@ PyDictProxy_New(PyObject *dict) { proxyobject *pp; - pp = PyObject_GC_New(proxyobject, &proxytype); + pp = PyObject_GC_New(proxyobject, &PyDictProxy_Type); if (pp != NULL) { Py_INCREF(dict); pp->dict = dict; diff --git a/Objects/dictobject.c b/Objects/dictobject.c index d1ebf1f..dad9855 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -1798,13 +1798,8 @@ dict_tp_clear(PyObject *op) return 0; } - -extern PyTypeObject PyDictIterKey_Type; /* Forward */ -extern PyTypeObject PyDictIterValue_Type; /* Forward */ -extern PyTypeObject PyDictIterItem_Type; /* Forward */ static PyObject *dictiter_new(PyDictObject *, PyTypeObject *); - PyDoc_STRVAR(contains__doc__, "D.__contains__(k) -> True if D has a key k, else False"); @@ -2401,19 +2396,6 @@ dictview_new(PyObject *dict, PyTypeObject *type) - if public then they should probably be in builtins */ -/* Forward */ -PyTypeObject PyDictKeys_Type; -PyTypeObject PyDictItems_Type; -PyTypeObject PyDictValues_Type; - -#define PyDictKeys_Check(obj) ((obj)->ob_type == &PyDictKeys_Type) -#define PyDictItems_Check(obj) ((obj)->ob_type == &PyDictItems_Type) -#define PyDictValues_Check(obj) ((obj)->ob_type == &PyDictValues_Type) - -/* This excludes Values, since they are not sets. */ -# define PyDictViewSet_Check(obj) \ - (PyDictKeys_Check(obj) || PyDictItems_Check(obj)) - /* Return 1 if self is a subset of other, iterating over self; 0 if not; -1 if an error occurred. */ static int diff --git a/Objects/iterobject.c b/Objects/iterobject.c index ce9c661..12b603a 100644 --- a/Objects/iterobject.c +++ b/Objects/iterobject.c @@ -199,7 +199,7 @@ calliter_iternext(calliterobject *it) PyTypeObject PyCallIter_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "callable-iterator", /* tp_name */ + "callable_iterator", /* tp_name */ sizeof(calliterobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ @@ -240,7 +240,7 @@ typedef struct zipiterobject_t { PyTupleObject *result; /* Reusable tuple for optimization */ } zipiterobject; -static PyTypeObject PyZipIter_Type; /* Forward */ + /* Forward */ PyObject * _PyZip_CreateIter(PyObject* args) @@ -367,7 +367,7 @@ zipiter_next(zipiterobject *zit) return result; } -static PyTypeObject PyZipIter_Type = { +PyTypeObject PyZipIter_Type = { PyVarObject_HEAD_INIT(0, 0) "zip_iterator", /* tp_name */ sizeof(zipiterobject), /* tp_basicsize */ diff --git a/Objects/listobject.c b/Objects/listobject.c index 1d82e35..ea10abf 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -1790,7 +1790,7 @@ sortwrapper_richcompare(sortwrapperobject *, sortwrapperobject *, int); static void sortwrapper_dealloc(sortwrapperobject *); -static PyTypeObject sortwrapper_type = { +PyTypeObject PySortWrapper_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "sortwrapper", /* tp_name */ sizeof(sortwrapperobject), /* tp_basicsize */ @@ -1822,7 +1822,7 @@ static PyTypeObject sortwrapper_type = { static PyObject * sortwrapper_richcompare(sortwrapperobject *a, sortwrapperobject *b, int op) { - if (!PyObject_TypeCheck(b, &sortwrapper_type)) { + if (!PyObject_TypeCheck(b, &PySortWrapper_Type)) { PyErr_SetString(PyExc_TypeError, "expected a sortwrapperobject"); return NULL; @@ -1846,7 +1846,7 @@ build_sortwrapper(PyObject *key, PyObject *value) { sortwrapperobject *so; - so = PyObject_New(sortwrapperobject, &sortwrapper_type); + so = PyObject_New(sortwrapperobject, &PySortWrapper_Type); if (so == NULL) return NULL; so->key = key; @@ -1860,7 +1860,7 @@ sortwrapper_getvalue(PyObject *so) { PyObject *value; - if (!PyObject_TypeCheck(so, &sortwrapper_type)) { + if (!PyObject_TypeCheck(so, &PySortWrapper_Type)) { PyErr_SetString(PyExc_TypeError, "expected a sortwrapperobject"); return NULL; @@ -1893,8 +1893,8 @@ cmpwrapper_call(cmpwrapperobject *co, PyObject *args, PyObject *kwds) if (!PyArg_UnpackTuple(args, "", 2, 2, &x, &y)) return NULL; - if (!PyObject_TypeCheck(x, &sortwrapper_type) || - !PyObject_TypeCheck(y, &sortwrapper_type)) { + if (!PyObject_TypeCheck(x, &PySortWrapper_Type) || + !PyObject_TypeCheck(y, &PySortWrapper_Type)) { PyErr_SetString(PyExc_TypeError, "expected a sortwrapperobject"); return NULL; @@ -1906,7 +1906,7 @@ cmpwrapper_call(cmpwrapperobject *co, PyObject *args, PyObject *kwds) PyDoc_STRVAR(cmpwrapper_doc, "cmp() wrapper for sort with custom keys."); -static PyTypeObject cmpwrapper_type = { +PyTypeObject PyCmpWrapper_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "cmpwrapper", /* tp_name */ sizeof(cmpwrapperobject), /* tp_basicsize */ @@ -1936,7 +1936,7 @@ build_cmpwrapper(PyObject *cmpfunc) { cmpwrapperobject *co; - co = PyObject_New(cmpwrapperobject, &cmpwrapper_type); + co = PyObject_New(cmpwrapperobject, &PyCmpWrapper_Type); if (co == NULL) return NULL; Py_INCREF(cmpfunc); diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index d1c959a..0b7be43 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -367,7 +367,7 @@ static PyMethodDef rangeiter_methods[] = { {NULL, NULL} /* sentinel */ }; -PyTypeObject Pyrangeiter_Type = { +PyTypeObject PyRangeIter_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "range_iterator", /* tp_name */ sizeof(rangeiterobject), /* tp_basicsize */ @@ -441,7 +441,7 @@ get_len_of_range(long lo, long hi, long step) static PyObject * int_range_iter(long start, long stop, long step) { - rangeiterobject *it = PyObject_New(rangeiterobject, &Pyrangeiter_Type); + rangeiterobject *it = PyObject_New(rangeiterobject, &PyRangeIter_Type); if (it == NULL) return NULL; it->start = start; @@ -519,9 +519,9 @@ longrangeiter_next(longrangeiterobject *r) return result; } -static PyTypeObject Pylongrangeiter_Type = { +PyTypeObject PyLongRangeIter_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "rangeiterator", /* tp_name */ + "longrange_iterator", /* tp_name */ sizeof(longrangeiterobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ @@ -567,7 +567,7 @@ range_iter(PyObject *seq) PyLong_AsLong(r->stop), PyLong_AsLong(r->step)); - it = PyObject_New(longrangeiterobject, &Pylongrangeiter_Type); + it = PyObject_New(longrangeiterobject, &PyLongRangeIter_Type); if (it == NULL) return NULL; @@ -627,7 +627,7 @@ range_reverse(PyObject *seq) return int_range_iter(new_start, new_stop, -step); } - it = PyObject_New(longrangeiterobject, &Pylongrangeiter_Type); + it = PyObject_New(longrangeiterobject, &PyLongRangeIter_Type); if (it == NULL) return NULL; diff --git a/Objects/setobject.c b/Objects/setobject.c index e4e7780..11ca407 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -849,7 +849,7 @@ fail: return NULL; } -static PyTypeObject PySetIter_Type = { +PyTypeObject PySetIter_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "set_iterator", /* tp_name */ sizeof(setiterobject), /* tp_basicsize */ diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index c22785d..fcfd09d 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -840,7 +840,7 @@ static PyMethodDef tupleiter_methods[] = { PyTypeObject PyTupleIter_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "tupleiterator", /* tp_name */ + "tuple_iterator", /* tp_name */ sizeof(tupleiterobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ |