Skip to content

Commit a22e8bd

Browse files
committed
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.
1 parent 513b2ac commit a22e8bd

17 files changed

+56
-44
lines changed

Include/bytesobject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ typedef struct {
2929

3030
/* Type object */
3131
PyAPI_DATA(PyTypeObject) PyBytes_Type;
32+
PyAPI_DATA(PyTypeObject) PyBytesIter_Type;
3233

3334
/* Type check macros */
3435
#define PyBytes_Check(self) PyObject_TypeCheck(self, &PyBytes_Type)

Include/descrobject.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ typedef struct {
6767
void *d_wrapped; /* This can be any function pointer */
6868
} PyWrapperDescrObject;
6969

70+
PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type;
71+
PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type;
72+
PyAPI_DATA(PyTypeObject) PyMemberDescr_Type;
73+
PyAPI_DATA(PyTypeObject) PyMethodDescr_Type;
7074
PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
75+
PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
7176

7277
PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
7378
PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);

Include/dictobject.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,23 @@ struct _dictobject {
8989
};
9090

9191
PyAPI_DATA(PyTypeObject) PyDict_Type;
92+
PyAPI_DATA(PyTypeObject) PyDictIterKey_Type;
93+
PyAPI_DATA(PyTypeObject) PyDictIterValue_Type;
94+
PyAPI_DATA(PyTypeObject) PyDictIterItem_Type;
95+
PyAPI_DATA(PyTypeObject) PyDictKeys_Type;
96+
PyAPI_DATA(PyTypeObject) PyDictItems_Type;
97+
PyAPI_DATA(PyTypeObject) PyDictValues_Type;
9298

9399
#define PyDict_Check(op) \
94100
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_DICT_SUBCLASS)
95101
#define PyDict_CheckExact(op) (Py_Type(op) == &PyDict_Type)
102+
#define PyDictKeys_Check(op) (Py_Type(op) == &PyDictKeys_Type)
103+
#define PyDictItems_Check(op) (Py_Type(op) == &PyDictItems_Type)
104+
#define PyDictValues_Check(op) (Py_Type(op) == &PyDictValues_Type)
105+
/* This excludes Values, since they are not sets. */
106+
# define PyDictViewSet_Check(op) \
107+
(PyDictKeys_Check(op) || PyDictItems_Check(op))
108+
96109

97110
PyAPI_FUNC(PyObject *) PyDict_New(void);
98111
PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key);

Include/iterobject.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ extern "C" {
66
#endif
77

88
PyAPI_DATA(PyTypeObject) PySeqIter_Type;
9+
PyAPI_DATA(PyTypeObject) PyCallIter_Type;
10+
PyAPI_DATA(PyTypeObject) PyZipIter_Type;
11+
PyAPI_DATA(PyTypeObject) PyCmpWrapper_Type;
912

1013
#define PySeqIter_Check(op) (Py_Type(op) == &PySeqIter_Type)
1114

1215
PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *);
1316

14-
PyAPI_DATA(PyTypeObject) PyCallIter_Type;
1517

1618
#define PyCallIter_Check(op) (Py_Type(op) == &PyCallIter_Type)
1719

Include/listobject.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ typedef struct {
3939
} PyListObject;
4040

4141
PyAPI_DATA(PyTypeObject) PyList_Type;
42+
PyAPI_DATA(PyTypeObject) PyListIter_Type;
43+
PyAPI_DATA(PyTypeObject) PyListRevIter_Type;
44+
PyAPI_DATA(PyTypeObject) PySortWrapper_Type;
4245

4346
#define PyList_Check(op) \
4447
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_LIST_SUBCLASS)

Include/rangeobject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ they are represented by a start, stop, and step datamembers.
1616
*/
1717

1818
PyAPI_DATA(PyTypeObject) PyRange_Type;
19+
PyAPI_DATA(PyTypeObject) PyRangeIter_Type;
20+
PyAPI_DATA(PyTypeObject) PyLongRangeIter_Type;
1921

2022
#define PyRange_Check(op) (Py_Type(op) == &PyRange_Type)
2123

Include/setobject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct _setobject {
5858

5959
PyAPI_DATA(PyTypeObject) PySet_Type;
6060
PyAPI_DATA(PyTypeObject) PyFrozenSet_Type;
61+
PyAPI_DATA(PyTypeObject) PySetIter_Type;
6162

6263
/* Invariants for frozensets:
6364
* data is immutable.

Include/stringobject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ typedef struct {
4040
} PyStringObject;
4141

4242
PyAPI_DATA(PyTypeObject) PyString_Type;
43+
PyAPI_DATA(PyTypeObject) PyStringIter_Type;
4344

4445
#define PyString_Check(op) \
4546
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_STRING_SUBCLASS)

Include/tupleobject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ typedef struct {
3232
} PyTupleObject;
3333

3434
PyAPI_DATA(PyTypeObject) PyTuple_Type;
35+
PyAPI_DATA(PyTypeObject) PyTupleIter_Type;
3536

3637
#define PyTuple_Check(op) \
3738
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_TUPLE_SUBCLASS)

Include/unicodeobject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ typedef struct {
417417
} PyUnicodeObject;
418418

419419
PyAPI_DATA(PyTypeObject) PyUnicode_Type;
420+
PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type;
420421

421422
#define SSTATE_NOT_INTERNED 0
422423
#define SSTATE_INTERNED_MORTAL 1

0 commit comments

Comments
 (0)