summaryrefslogtreecommitdiffstats
path: root/Include/cpython
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-02-24 16:51:59 (GMT)
committerGitHub <noreply@github.com>2022-02-24 16:51:59 (GMT)
commit042f31da552c19054acd3ef7bb6cfd857bce172b (patch)
treed1aa8f20f873c89adebbac7072d80dceb19d32c4 /Include/cpython
parentec091bd47e2f968b0d1631b9a8104283a7beeb1b (diff)
downloadcpython-042f31da552c19054acd3ef7bb6cfd857bce172b.zip
cpython-042f31da552c19054acd3ef7bb6cfd857bce172b.tar.gz
cpython-042f31da552c19054acd3ef7bb6cfd857bce172b.tar.bz2
bpo-45459: C API uses type names rather than structure names (GH-31528)
Thanks to the new pytypedefs.h, it becomes to use type names like PyObject rather like structure names like "struct _object".
Diffstat (limited to 'Include/cpython')
-rw-r--r--Include/cpython/abstract.h2
-rw-r--r--Include/cpython/descrobject.h2
-rw-r--r--Include/cpython/dictobject.h8
-rw-r--r--Include/cpython/frameobject.h2
-rw-r--r--Include/cpython/import.h2
-rw-r--r--Include/cpython/object.h20
-rw-r--r--Include/cpython/pystate.h17
-rw-r--r--Include/cpython/traceback.h8
8 files changed, 31 insertions, 30 deletions
diff --git a/Include/cpython/abstract.h b/Include/cpython/abstract.h
index cf142b8..bdc0c49 100644
--- a/Include/cpython/abstract.h
+++ b/Include/cpython/abstract.h
@@ -133,7 +133,7 @@ PyAPI_FUNC(PyObject *) _PyObject_CallMethodId_SizeT(PyObject *obj,
PyAPI_FUNC(PyObject *) _PyObject_CallMethodIdObjArgs(
PyObject *obj,
- struct _Py_Identifier *name,
+ _Py_Identifier *name,
...);
static inline PyObject *
diff --git a/Include/cpython/descrobject.h b/Include/cpython/descrobject.h
index 5d6c3a2..e2ea1b9 100644
--- a/Include/cpython/descrobject.h
+++ b/Include/cpython/descrobject.h
@@ -43,7 +43,7 @@ typedef struct {
typedef struct {
PyDescr_COMMON;
- struct PyMemberDef *d_member;
+ PyMemberDef *d_member;
} PyMemberDescrObject;
typedef struct {
diff --git a/Include/cpython/dictobject.h b/Include/cpython/dictobject.h
index d511964..68b4593 100644
--- a/Include/cpython/dictobject.h
+++ b/Include/cpython/dictobject.h
@@ -32,7 +32,7 @@ PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key,
Py_hash_t hash);
PyAPI_FUNC(PyObject *) _PyDict_GetItemWithError(PyObject *dp, PyObject *key);
PyAPI_FUNC(PyObject *) _PyDict_GetItemIdWithError(PyObject *dp,
- struct _Py_Identifier *key);
+ _Py_Identifier *key);
PyAPI_FUNC(PyObject *) _PyDict_GetItemStringWithError(PyObject *, const char *);
PyAPI_FUNC(PyObject *) PyDict_SetDefault(
PyObject *mp, PyObject *key, PyObject *defaultobj);
@@ -49,7 +49,7 @@ PyAPI_FUNC(int) _PyDict_Next(
/* Get the number of items of a dictionary. */
#define PyDict_GET_SIZE(mp) (assert(PyDict_Check(mp)),((PyDictObject *)mp)->ma_used)
PyAPI_FUNC(int) _PyDict_Contains_KnownHash(PyObject *, PyObject *, Py_hash_t);
-PyAPI_FUNC(int) _PyDict_ContainsId(PyObject *, struct _Py_Identifier *);
+PyAPI_FUNC(int) _PyDict_ContainsId(PyObject *, _Py_Identifier *);
PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
PyAPI_FUNC(int) _PyDict_HasOnlyStringKeys(PyObject *mp);
@@ -66,9 +66,9 @@ PyObject *_PyDict_FromKeys(PyObject *, PyObject *, PyObject *);
argument is raised.
*/
PyAPI_FUNC(int) _PyDict_MergeEx(PyObject *mp, PyObject *other, int override);
-PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, struct _Py_Identifier *key, PyObject *item);
+PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, _Py_Identifier *key, PyObject *item);
-PyAPI_FUNC(int) _PyDict_DelItemId(PyObject *mp, struct _Py_Identifier *key);
+PyAPI_FUNC(int) _PyDict_DelItemId(PyObject *mp, _Py_Identifier *key);
PyAPI_FUNC(void) _PyDict_DebugMallocStats(FILE *out);
int _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr, PyObject *name, PyObject *value);
diff --git a/Include/cpython/frameobject.h b/Include/cpython/frameobject.h
index 67f98a7..3d862d9 100644
--- a/Include/cpython/frameobject.h
+++ b/Include/cpython/frameobject.h
@@ -6,7 +6,7 @@
struct _frame {
PyObject_HEAD
- struct _frame *f_back; /* previous frame, or NULL */
+ PyFrameObject *f_back; /* previous frame, or NULL */
struct _interpreter_frame *f_frame; /* points to the frame data */
PyObject *f_trace; /* Trace function */
int f_lineno; /* Current line number. Only valid if non-zero */
diff --git a/Include/cpython/import.h b/Include/cpython/import.h
index da9fb77..c734802 100644
--- a/Include/cpython/import.h
+++ b/Include/cpython/import.h
@@ -6,7 +6,7 @@ PyMODINIT_FUNC PyInit__imp(void);
PyAPI_FUNC(int) _PyImport_IsInitialized(PyInterpreterState *);
-PyAPI_FUNC(PyObject *) _PyImport_GetModuleId(struct _Py_Identifier *name);
+PyAPI_FUNC(PyObject *) _PyImport_GetModuleId(_Py_Identifier *name);
PyAPI_FUNC(int) _PyImport_SetModule(PyObject *name, PyObject *module);
PyAPI_FUNC(int) _PyImport_SetModuleString(const char *name, PyObject* module);
diff --git a/Include/cpython/object.h b/Include/cpython/object.h
index 65d7d85..5f978ee 100644
--- a/Include/cpython/object.h
+++ b/Include/cpython/object.h
@@ -201,11 +201,11 @@ struct _typeobject {
iternextfunc tp_iternext;
/* Attribute descriptor and subclassing stuff */
- struct PyMethodDef *tp_methods;
- struct PyMemberDef *tp_members;
- struct PyGetSetDef *tp_getset;
+ PyMethodDef *tp_methods;
+ PyMemberDef *tp_members;
+ PyGetSetDef *tp_getset;
// Strong reference on a heap type, borrowed reference on a static type
- struct _typeobject *tp_base;
+ PyTypeObject *tp_base;
PyObject *tp_dict;
descrgetfunc tp_descr_get;
descrsetfunc tp_descr_set;
@@ -262,7 +262,7 @@ PyAPI_FUNC(PyObject *) _PyObject_LookupSpecialId(PyObject *, _Py_Identifier *);
PyAPI_FUNC(PyTypeObject *) _PyType_CalculateMetaclass(PyTypeObject *, PyObject *);
PyAPI_FUNC(PyObject *) _PyType_GetDocFromInternalDoc(const char *, const char *);
PyAPI_FUNC(PyObject *) _PyType_GetTextSignatureFromInternalDoc(const char *, const char *);
-PyAPI_FUNC(PyObject *) PyType_GetModuleByDef(PyTypeObject *, struct PyModuleDef *);
+PyAPI_FUNC(PyObject *) PyType_GetModuleByDef(PyTypeObject *, PyModuleDef *);
PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int);
PyAPI_FUNC(void) _Py_BreakPoint(void);
@@ -270,8 +270,8 @@ PyAPI_FUNC(void) _PyObject_Dump(PyObject *);
PyAPI_FUNC(int) _PyObject_IsFreed(PyObject *);
PyAPI_FUNC(int) _PyObject_IsAbstract(PyObject *);
-PyAPI_FUNC(PyObject *) _PyObject_GetAttrId(PyObject *, struct _Py_Identifier *);
-PyAPI_FUNC(int) _PyObject_SetAttrId(PyObject *, struct _Py_Identifier *, PyObject *);
+PyAPI_FUNC(PyObject *) _PyObject_GetAttrId(PyObject *, _Py_Identifier *);
+PyAPI_FUNC(int) _PyObject_SetAttrId(PyObject *, _Py_Identifier *, PyObject *);
/* Replacements of PyObject_GetAttr() and _PyObject_GetAttrId() which
don't raise AttributeError.
@@ -282,7 +282,7 @@ PyAPI_FUNC(int) _PyObject_SetAttrId(PyObject *, struct _Py_Identifier *, PyObjec
is raised.
*/
PyAPI_FUNC(int) _PyObject_LookupAttr(PyObject *, PyObject *, PyObject **);
-PyAPI_FUNC(int) _PyObject_LookupAttrId(PyObject *, struct _Py_Identifier *, PyObject **);
+PyAPI_FUNC(int) _PyObject_LookupAttrId(PyObject *, _Py_Identifier *, PyObject **);
PyAPI_FUNC(int) _PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
@@ -461,8 +461,8 @@ passed as second argument to Py_TRASHCAN_BEGIN().
*/
/* Python 3.9 private API, invoked by the macros below. */
-PyAPI_FUNC(int) _PyTrash_begin(struct _ts *tstate, PyObject *op);
-PyAPI_FUNC(void) _PyTrash_end(struct _ts *tstate);
+PyAPI_FUNC(int) _PyTrash_begin(PyThreadState *tstate, PyObject *op);
+PyAPI_FUNC(void) _PyTrash_end(PyThreadState *tstate);
/* Python 3.10 private API, invoked by the Py_TRASHCAN_BEGIN(). */
PyAPI_FUNC(int) _PyTrash_cond(PyObject *op, destructor dealloc);
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index 74dd44d..8150d50 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -79,12 +79,11 @@ typedef struct _stack_chunk {
PyObject * data[1]; /* Variable sized */
} _PyStackChunk;
-// The PyThreadState typedef is in Include/pystate.h.
struct _ts {
/* See Python/ceval.c for comments explaining most fields */
- struct _ts *prev;
- struct _ts *next;
+ PyThreadState *prev;
+ PyThreadState *next;
PyInterpreterState *interp;
/* Has been initialized to a safe state.
@@ -308,12 +307,12 @@ PyAPI_FUNC(const PyConfig*) _Py_GetConfig(void);
/* cross-interpreter data */
-struct _xid;
-
// _PyCrossInterpreterData is similar to Py_buffer as an effectively
// opaque struct that holds data outside the object machinery. This
// is necessary to pass safely between interpreters in the same process.
-typedef struct _xid {
+typedef struct _xid _PyCrossInterpreterData;
+
+struct _xid {
// data is the cross-interpreter-safe derivation of a Python object
// (see _PyObject_GetCrossInterpreterData). It will be NULL if the
// new_object func (below) encodes the data.
@@ -339,7 +338,7 @@ typedef struct _xid {
// interpreter given the data. The resulting object (a new
// reference) will be equivalent to the original object. This field
// is required.
- PyObject *(*new_object)(struct _xid *);
+ PyObject *(*new_object)(_PyCrossInterpreterData *);
// free is called when the data is released. If it is NULL then
// nothing will be done to free the data. For some types this is
// okay (e.g. bytes) and for those types this field should be set
@@ -350,7 +349,7 @@ typedef struct _xid {
// to PyMem_RawFree (the default if not explicitly set to NULL).
// The call will happen with the original interpreter activated.
void (*free)(void *);
-} _PyCrossInterpreterData;
+};
PyAPI_FUNC(int) _PyObject_GetCrossInterpreterData(PyObject *, _PyCrossInterpreterData *);
PyAPI_FUNC(PyObject *) _PyCrossInterpreterData_NewObject(_PyCrossInterpreterData *);
@@ -360,7 +359,7 @@ PyAPI_FUNC(int) _PyObject_CheckCrossInterpreterData(PyObject *);
/* cross-interpreter data registry */
-typedef int (*crossinterpdatafunc)(PyObject *, struct _xid *);
+typedef int (*crossinterpdatafunc)(PyObject *, _PyCrossInterpreterData *);
PyAPI_FUNC(int) _PyCrossInterpreterData_RegisterClass(PyTypeObject *, crossinterpdatafunc);
PyAPI_FUNC(crossinterpdatafunc) _PyCrossInterpreterData_Lookup(PyObject *);
diff --git a/Include/cpython/traceback.h b/Include/cpython/traceback.h
index d0dde33..a4e087b 100644
--- a/Include/cpython/traceback.h
+++ b/Include/cpython/traceback.h
@@ -2,13 +2,15 @@
# error "this header file must not be included directly"
#endif
-typedef struct _traceback {
+typedef struct _traceback PyTracebackObject;
+
+struct _traceback {
PyObject_HEAD
- struct _traceback *tb_next;
+ PyTracebackObject *tb_next;
PyFrameObject *tb_frame;
int tb_lasti;
int tb_lineno;
-} PyTracebackObject;
+};
PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int, int *, PyObject **);
PyAPI_FUNC(void) _PyTraceback_Add(const char *, const char *, int);