bpo-45459: Add pytypedefs.h header file (GH-31527)

Move forward declarations of Python C API types to a new pytypedefs.h
header file to solve interdependency issues between header files.

pytypedefs.h contains forward declarations of the following types:

* PyCodeObject
* PyFrameObject
* PyGetSetDef
* PyInterpreterState
* PyLongObject
* PyMemberDef
* PyMethodDef
* PyModuleDef
* PyObject
* PyThreadState
* PyTypeObject
This commit is contained in:
Victor Stinner 2022-02-24 17:07:12 +01:00 committed by GitHub
parent a52d2528a4
commit ec091bd47e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 44 additions and 40 deletions

View file

@ -1,6 +1,5 @@
#ifndef Py_OBJECT_H
#define Py_OBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
@ -61,10 +60,6 @@ whose size is determined when the object is allocated.
# error Py_LIMITED_API is incompatible with Py_TRACE_REFS
#endif
/* PyTypeObject structure is defined in cpython/object.h.
In Py_LIMITED_API, PyTypeObject is an opaque structure. */
typedef struct _typeobject PyTypeObject;
#ifdef Py_TRACE_REFS
/* Define pointers to support a doubly-linked list of all live heap objects. */
#define _PyObject_HEAD_EXTRA \
@ -102,11 +97,11 @@ typedef struct _typeobject PyTypeObject;
* by hand. Similarly every pointer to a variable-size Python object can,
* in addition, be cast to PyVarObject*.
*/
typedef struct _object {
struct _object {
_PyObject_HEAD_EXTRA
Py_ssize_t ob_refcnt;
PyTypeObject *ob_type;
} PyObject;
};
/* Cast argument to PyObject* type. */
#define _PyObject_CAST(op) ((PyObject*)(op))
@ -765,4 +760,4 @@ static inline int PyType_CheckExact(PyObject *op) {
#ifdef __cplusplus
}
#endif
#endif /* !Py_OBJECT_H */
#endif // !Py_OBJECT_H