bpo-39542: Define PyTypeObject earlier in object.h (GH-18366) · python/cpython@0e4e735 (original) (raw)
`@@ -61,6 +61,9 @@ whose size is determined when the object is allocated.
`
61
61
`#error Py_LIMITED_API is incompatible with Py_DEBUG, Py_TRACE_REFS, and Py_REF_DEBUG
`
62
62
`#endif
`
63
63
``
``
64
`+
/* PyTypeObject structure is defined in cpython/object.h.
`
``
65
`+
In Py_LIMITED_API, PyTypeObject is an opaque structure. */
`
``
66
`+
typedef struct _typeobject PyTypeObject;
`
64
67
``
65
68
`#ifdef Py_TRACE_REFS
`
66
69
`/* Define pointers to support a doubly-linked list of all live heap objects. */
`
`@@ -102,7 +105,7 @@ whose size is determined when the object is allocated.
`
102
105
`typedef struct _object {
`
103
106
`_PyObject_HEAD_EXTRA
`
104
107
`Py_ssize_t ob_refcnt;
`
105
``
`-
struct _typeobject *ob_type;
`
``
108
`+
PyTypeObject *ob_type;
`
106
109
`} PyObject;
`
107
110
``
108
111
`/* Cast argument to PyObject* type. */
`
`@@ -165,15 +168,8 @@ typedef PyObject *(*iternextfunc) (PyObject *);
`
165
168
`typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *);
`
166
169
`typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *);
`
167
170
`typedef int (*initproc)(PyObject *, PyObject *, PyObject *);
`
168
``
`-
typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *);
`
169
``
`-
typedef PyObject *(*allocfunc)(struct _typeobject *, Py_ssize_t);
`
170
``
-
171
``
`-
#ifdef Py_LIMITED_API
`
172
``
`-
/* In Py_LIMITED_API, PyTypeObject is an opaque structure. */
`
173
``
`-
typedef struct _typeobject PyTypeObject;
`
174
``
`-
#else
`
175
``
`-
/* PyTypeObject is defined in cpython/object.h */
`
176
``
`-
#endif
`
``
171
`+
typedef PyObject *(*newfunc)(PyTypeObject *, PyObject *, PyObject *);
`
``
172
`+
typedef PyObject *(*allocfunc)(PyTypeObject *, Py_ssize_t);
`
177
173
``
178
174
`typedef struct{
`
179
175
`int slot; /* slot id, see below */
`
`@@ -193,26 +189,26 @@ PyAPI_FUNC(PyObject*) PyType_FromSpec(PyType_Spec*);
`
193
189
`PyAPI_FUNC(PyObject*) PyType_FromSpecWithBases(PyType_Spec*, PyObject*);
`
194
190
`#endif
`
195
191
`#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03040000
`
196
``
`-
PyAPI_FUNC(void*) PyType_GetSlot(struct _typeobject*, int);
`
``
192
`+
PyAPI_FUNC(void*) PyType_GetSlot(PyTypeObject*, int);
`
197
193
`#endif
`
198
194
``
199
195
`/* Generic type check */
`
200
``
`-
PyAPI_FUNC(int) PyType_IsSubtype(struct _typeobject *, struct _typeobject *);
`
``
196
`+
PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *);
`
201
197
`#define PyObject_TypeCheck(ob, tp) \
`
202
198
` (Py_TYPE(ob) == (tp) || PyType_IsSubtype(Py_TYPE(ob), (tp)))
`
203
199
``
204
``
`-
PyAPI_DATA(struct _typeobject) PyType_Type; /* built-in 'type' */
`
205
``
`-
PyAPI_DATA(struct _typeobject) PyBaseObject_Type; /* built-in 'object' */
`
206
``
`-
PyAPI_DATA(struct _typeobject) PySuper_Type; /* built-in 'super' */
`
``
200
`+
PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */
`
``
201
`+
PyAPI_DATA(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */
`
``
202
`+
PyAPI_DATA(PyTypeObject) PySuper_Type; /* built-in 'super' */
`
207
203
``
208
``
`-
PyAPI_FUNC(unsigned long) PyType_GetFlags(struct _typeobject*);
`
``
204
`+
PyAPI_FUNC(unsigned long) PyType_GetFlags(PyTypeObject*);
`
209
205
``
210
``
`-
PyAPI_FUNC(int) PyType_Ready(struct _typeobject *);
`
211
``
`-
PyAPI_FUNC(PyObject *) PyType_GenericAlloc(struct _typeobject *, Py_ssize_t);
`
212
``
`-
PyAPI_FUNC(PyObject *) PyType_GenericNew(struct _typeobject *,
`
``
206
`+
PyAPI_FUNC(int) PyType_Ready(PyTypeObject *);
`
``
207
`+
PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t);
`
``
208
`+
PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *,
`
213
209
`PyObject *, PyObject *);
`
214
210
`PyAPI_FUNC(unsigned int) PyType_ClearCache(void);
`
215
``
`-
PyAPI_FUNC(void) PyType_Modified(struct _typeobject *);
`
``
211
`+
PyAPI_FUNC(void) PyType_Modified(PyTypeObject *);
`
216
212
``
217
213
`/* Generic operations on objects */
`
218
214
`PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *);
`