mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
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.
This commit is contained in:
parent
513b2ac76c
commit
a22e8bdfd9
17 changed files with 56 additions and 44 deletions
|
@ -29,6 +29,7 @@ typedef struct {
|
|||
|
||||
/* Type object */
|
||||
PyAPI_DATA(PyTypeObject) PyBytes_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyBytesIter_Type;
|
||||
|
||||
/* Type check macros */
|
||||
#define PyBytes_Check(self) PyObject_TypeCheck(self, &PyBytes_Type)
|
||||
|
|
|
@ -67,7 +67,12 @@ typedef struct {
|
|||
void *d_wrapped; /* This can be any function pointer */
|
||||
} PyWrapperDescrObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyMemberDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyMethodDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
|
||||
|
|
|
@ -89,10 +89,23 @@ struct _dictobject {
|
|||
};
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyDict_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictIterKey_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictIterValue_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictIterItem_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictKeys_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictItems_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictValues_Type;
|
||||
|
||||
#define PyDict_Check(op) \
|
||||
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_DICT_SUBCLASS)
|
||||
#define PyDict_CheckExact(op) (Py_Type(op) == &PyDict_Type)
|
||||
#define PyDictKeys_Check(op) (Py_Type(op) == &PyDictKeys_Type)
|
||||
#define PyDictItems_Check(op) (Py_Type(op) == &PyDictItems_Type)
|
||||
#define PyDictValues_Check(op) (Py_Type(op) == &PyDictValues_Type)
|
||||
/* This excludes Values, since they are not sets. */
|
||||
# define PyDictViewSet_Check(op) \
|
||||
(PyDictKeys_Check(op) || PyDictItems_Check(op))
|
||||
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDict_New(void);
|
||||
PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key);
|
||||
|
|
|
@ -6,12 +6,14 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PySeqIter_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyCallIter_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyZipIter_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyCmpWrapper_Type;
|
||||
|
||||
#define PySeqIter_Check(op) (Py_Type(op) == &PySeqIter_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *);
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCallIter_Type;
|
||||
|
||||
#define PyCallIter_Check(op) (Py_Type(op) == &PyCallIter_Type)
|
||||
|
||||
|
|
|
@ -39,6 +39,9 @@ typedef struct {
|
|||
} PyListObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyList_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyListIter_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyListRevIter_Type;
|
||||
PyAPI_DATA(PyTypeObject) PySortWrapper_Type;
|
||||
|
||||
#define PyList_Check(op) \
|
||||
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_LIST_SUBCLASS)
|
||||
|
|
|
@ -16,6 +16,8 @@ they are represented by a start, stop, and step datamembers.
|
|||
*/
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyRange_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyRangeIter_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyLongRangeIter_Type;
|
||||
|
||||
#define PyRange_Check(op) (Py_Type(op) == &PyRange_Type)
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ struct _setobject {
|
|||
|
||||
PyAPI_DATA(PyTypeObject) PySet_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyFrozenSet_Type;
|
||||
PyAPI_DATA(PyTypeObject) PySetIter_Type;
|
||||
|
||||
/* Invariants for frozensets:
|
||||
* data is immutable.
|
||||
|
|
|
@ -40,6 +40,7 @@ typedef struct {
|
|||
} PyStringObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyString_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyStringIter_Type;
|
||||
|
||||
#define PyString_Check(op) \
|
||||
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_STRING_SUBCLASS)
|
||||
|
|
|
@ -32,6 +32,7 @@ typedef struct {
|
|||
} PyTupleObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyTuple_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyTupleIter_Type;
|
||||
|
||||
#define PyTuple_Check(op) \
|
||||
PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_TUPLE_SUBCLASS)
|
||||
|
|
|
@ -417,6 +417,7 @@ typedef struct {
|
|||
} PyUnicodeObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyUnicode_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type;
|
||||
|
||||
#define SSTATE_NOT_INTERNED 0
|
||||
#define SSTATE_INTERNED_MORTAL 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue