bpo-35134: Don't define types twice in header files (GH-10754) · python/cpython@9bdd2de (original) (raw)

`@@ -175,8 +175,12 @@ typedef int (*initproc)(PyObject *, PyObject *, PyObject *);

`

175

175

`typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *);

`

176

176

`typedef PyObject *(*allocfunc)(struct _typeobject *, Py_ssize_t);

`

177

177

``

``

178

`+

#ifdef Py_LIMITED_API

`

178

179

`/* In Py_LIMITED_API, PyTypeObject is an opaque structure. */

`

179

180

`typedef struct _typeobject PyTypeObject;

`

``

181

`+

#else

`

``

182

`+

/* PyTypeObject is defined in cpython/object.h */

`

``

183

`+

#endif

`

180

184

``

181

185

`typedef struct{

`

182

186

`int slot; /* slot id, see below */

`

`@@ -196,30 +200,30 @@ PyAPI_FUNC(PyObject*) PyType_FromSpec(PyType_Spec*);

`

196

200

`PyAPI_FUNC(PyObject*) PyType_FromSpecWithBases(PyType_Spec*, PyObject*);

`

197

201

`#endif

`

198

202

`#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03040000

`

199

``

`-

PyAPI_FUNC(void*) PyType_GetSlot(PyTypeObject*, int);

`

``

203

`+

PyAPI_FUNC(void*) PyType_GetSlot(struct _typeobject*, int);

`

200

204

`#endif

`

201

205

``

202

206

`/* Generic type check */

`

203

``

`-

PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *);

`

``

207

`+

PyAPI_FUNC(int) PyType_IsSubtype(struct _typeobject *, struct _typeobject *);

`

204

208

`#define PyObject_TypeCheck(ob, tp) \

`

205

209

` (Py_TYPE(ob) == (tp) || PyType_IsSubtype(Py_TYPE(ob), (tp)))

`

206

210

``

207

``

`-

PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */

`

208

``

`-

PyAPI_DATA(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */

`

209

``

`-

PyAPI_DATA(PyTypeObject) PySuper_Type; /* built-in 'super' */

`

``

211

`+

PyAPI_DATA(struct _typeobject) PyType_Type; /* built-in 'type' */

`

``

212

`+

PyAPI_DATA(struct _typeobject) PyBaseObject_Type; /* built-in 'object' */

`

``

213

`+

PyAPI_DATA(struct _typeobject) PySuper_Type; /* built-in 'super' */

`

210

214

``

211

``

`-

PyAPI_FUNC(unsigned long) PyType_GetFlags(PyTypeObject*);

`

``

215

`+

PyAPI_FUNC(unsigned long) PyType_GetFlags(struct _typeobject*);

`

212

216

``

213

217

`#define PyType_Check(op) \

`

214

218

` PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS)

`

215

219

`#define PyType_CheckExact(op) (Py_TYPE(op) == &PyType_Type)

`

216

220

``

217

``

`-

PyAPI_FUNC(int) PyType_Ready(PyTypeObject *);

`

218

``

`-

PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t);

`

219

``

`-

PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *,

`

``

221

`+

PyAPI_FUNC(int) PyType_Ready(struct _typeobject *);

`

``

222

`+

PyAPI_FUNC(PyObject *) PyType_GenericAlloc(struct _typeobject *, Py_ssize_t);

`

``

223

`+

PyAPI_FUNC(PyObject *) PyType_GenericNew(struct _typeobject *,

`

220

224

`PyObject *, PyObject *);

`

221

225

`PyAPI_FUNC(unsigned int) PyType_ClearCache(void);

`

222

``

`-

PyAPI_FUNC(void) PyType_Modified(PyTypeObject *);

`

``

226

`+

PyAPI_FUNC(void) PyType_Modified(struct _typeobject *);

`

223

227

``

224

228

`/* Generic operations on objects */

`

225

229

`PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *);

`

`@@ -397,8 +401,8 @@ PyAPI_FUNC(void) _PyDebug_PrintTotalRefs(void);

`

397

401

`#endif /* Py_REF_DEBUG */

`

398

402

``

399

403

`#ifdef COUNT_ALLOCS

`

400

``

`-

PyAPI_FUNC(void) _Py_inc_count(PyTypeObject *);

`

401

``

`-

PyAPI_FUNC(void) _Py_dec_count(PyTypeObject *);

`

``

404

`+

PyAPI_FUNC(void) _Py_inc_count(struct _typeobject *);

`

``

405

`+

PyAPI_FUNC(void) _Py_dec_count(struct _typeobject *);

`

402

406

`#define _Py_INC_TPALLOCS(OP) _Py_inc_count(Py_TYPE(OP))

`

403

407

`#define _Py_INC_TPFREES(OP) _Py_dec_count(Py_TYPE(OP))

`

404

408

`#define _Py_DEC_TPFREES(OP) Py_TYPE(OP)->tp_frees--

`