mirror of https://github.com/python/cpython
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".
This commit is contained in:
parent
ec091bd47e
commit
042f31da55
|
@ -15,8 +15,8 @@ PyAPI_DATA(PyTypeObject) PyBool_Type;
|
||||||
Don't forget to apply Py_INCREF() when returning either!!! */
|
Don't forget to apply Py_INCREF() when returning either!!! */
|
||||||
|
|
||||||
/* Don't use these directly */
|
/* Don't use these directly */
|
||||||
PyAPI_DATA(struct _longobject) _Py_FalseStruct;
|
PyAPI_DATA(PyLongObject) _Py_FalseStruct;
|
||||||
PyAPI_DATA(struct _longobject) _Py_TrueStruct;
|
PyAPI_DATA(PyLongObject) _Py_TrueStruct;
|
||||||
|
|
||||||
/* Use these macros */
|
/* Use these macros */
|
||||||
#define Py_False ((PyObject *) &_Py_FalseStruct)
|
#define Py_False ((PyObject *) &_Py_FalseStruct)
|
||||||
|
|
|
@ -133,7 +133,7 @@ PyAPI_FUNC(PyObject *) _PyObject_CallMethodId_SizeT(PyObject *obj,
|
||||||
|
|
||||||
PyAPI_FUNC(PyObject *) _PyObject_CallMethodIdObjArgs(
|
PyAPI_FUNC(PyObject *) _PyObject_CallMethodIdObjArgs(
|
||||||
PyObject *obj,
|
PyObject *obj,
|
||||||
struct _Py_Identifier *name,
|
_Py_Identifier *name,
|
||||||
...);
|
...);
|
||||||
|
|
||||||
static inline PyObject *
|
static inline PyObject *
|
||||||
|
|
|
@ -43,7 +43,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyDescr_COMMON;
|
PyDescr_COMMON;
|
||||||
struct PyMemberDef *d_member;
|
PyMemberDef *d_member;
|
||||||
} PyMemberDescrObject;
|
} PyMemberDescrObject;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -32,7 +32,7 @@ PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key,
|
||||||
Py_hash_t hash);
|
Py_hash_t hash);
|
||||||
PyAPI_FUNC(PyObject *) _PyDict_GetItemWithError(PyObject *dp, PyObject *key);
|
PyAPI_FUNC(PyObject *) _PyDict_GetItemWithError(PyObject *dp, PyObject *key);
|
||||||
PyAPI_FUNC(PyObject *) _PyDict_GetItemIdWithError(PyObject *dp,
|
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_GetItemStringWithError(PyObject *, const char *);
|
||||||
PyAPI_FUNC(PyObject *) PyDict_SetDefault(
|
PyAPI_FUNC(PyObject *) PyDict_SetDefault(
|
||||||
PyObject *mp, PyObject *key, PyObject *defaultobj);
|
PyObject *mp, PyObject *key, PyObject *defaultobj);
|
||||||
|
@ -49,7 +49,7 @@ PyAPI_FUNC(int) _PyDict_Next(
|
||||||
/* Get the number of items of a dictionary. */
|
/* Get the number of items of a dictionary. */
|
||||||
#define PyDict_GET_SIZE(mp) (assert(PyDict_Check(mp)),((PyDictObject *)mp)->ma_used)
|
#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_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(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
|
||||||
PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
|
PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
|
||||||
PyAPI_FUNC(int) _PyDict_HasOnlyStringKeys(PyObject *mp);
|
PyAPI_FUNC(int) _PyDict_HasOnlyStringKeys(PyObject *mp);
|
||||||
|
@ -66,9 +66,9 @@ PyObject *_PyDict_FromKeys(PyObject *, PyObject *, PyObject *);
|
||||||
argument is raised.
|
argument is raised.
|
||||||
*/
|
*/
|
||||||
PyAPI_FUNC(int) _PyDict_MergeEx(PyObject *mp, PyObject *other, int override);
|
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);
|
PyAPI_FUNC(void) _PyDict_DebugMallocStats(FILE *out);
|
||||||
|
|
||||||
int _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr, PyObject *name, PyObject *value);
|
int _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr, PyObject *name, PyObject *value);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
struct _frame {
|
struct _frame {
|
||||||
PyObject_HEAD
|
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 */
|
struct _interpreter_frame *f_frame; /* points to the frame data */
|
||||||
PyObject *f_trace; /* Trace function */
|
PyObject *f_trace; /* Trace function */
|
||||||
int f_lineno; /* Current line number. Only valid if non-zero */
|
int f_lineno; /* Current line number. Only valid if non-zero */
|
||||||
|
|
|
@ -6,7 +6,7 @@ PyMODINIT_FUNC PyInit__imp(void);
|
||||||
|
|
||||||
PyAPI_FUNC(int) _PyImport_IsInitialized(PyInterpreterState *);
|
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_SetModule(PyObject *name, PyObject *module);
|
||||||
PyAPI_FUNC(int) _PyImport_SetModuleString(const char *name, PyObject* module);
|
PyAPI_FUNC(int) _PyImport_SetModuleString(const char *name, PyObject* module);
|
||||||
|
|
||||||
|
|
|
@ -201,11 +201,11 @@ struct _typeobject {
|
||||||
iternextfunc tp_iternext;
|
iternextfunc tp_iternext;
|
||||||
|
|
||||||
/* Attribute descriptor and subclassing stuff */
|
/* Attribute descriptor and subclassing stuff */
|
||||||
struct PyMethodDef *tp_methods;
|
PyMethodDef *tp_methods;
|
||||||
struct PyMemberDef *tp_members;
|
PyMemberDef *tp_members;
|
||||||
struct PyGetSetDef *tp_getset;
|
PyGetSetDef *tp_getset;
|
||||||
// Strong reference on a heap type, borrowed reference on a static type
|
// Strong reference on a heap type, borrowed reference on a static type
|
||||||
struct _typeobject *tp_base;
|
PyTypeObject *tp_base;
|
||||||
PyObject *tp_dict;
|
PyObject *tp_dict;
|
||||||
descrgetfunc tp_descr_get;
|
descrgetfunc tp_descr_get;
|
||||||
descrsetfunc tp_descr_set;
|
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(PyTypeObject *) _PyType_CalculateMetaclass(PyTypeObject *, PyObject *);
|
||||||
PyAPI_FUNC(PyObject *) _PyType_GetDocFromInternalDoc(const char *, const char *);
|
PyAPI_FUNC(PyObject *) _PyType_GetDocFromInternalDoc(const char *, const char *);
|
||||||
PyAPI_FUNC(PyObject *) _PyType_GetTextSignatureFromInternalDoc(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(int) PyObject_Print(PyObject *, FILE *, int);
|
||||||
PyAPI_FUNC(void) _Py_BreakPoint(void);
|
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_IsFreed(PyObject *);
|
||||||
|
|
||||||
PyAPI_FUNC(int) _PyObject_IsAbstract(PyObject *);
|
PyAPI_FUNC(int) _PyObject_IsAbstract(PyObject *);
|
||||||
PyAPI_FUNC(PyObject *) _PyObject_GetAttrId(PyObject *, struct _Py_Identifier *);
|
PyAPI_FUNC(PyObject *) _PyObject_GetAttrId(PyObject *, _Py_Identifier *);
|
||||||
PyAPI_FUNC(int) _PyObject_SetAttrId(PyObject *, struct _Py_Identifier *, PyObject *);
|
PyAPI_FUNC(int) _PyObject_SetAttrId(PyObject *, _Py_Identifier *, PyObject *);
|
||||||
/* Replacements of PyObject_GetAttr() and _PyObject_GetAttrId() which
|
/* Replacements of PyObject_GetAttr() and _PyObject_GetAttrId() which
|
||||||
don't raise AttributeError.
|
don't raise AttributeError.
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ PyAPI_FUNC(int) _PyObject_SetAttrId(PyObject *, struct _Py_Identifier *, PyObjec
|
||||||
is raised.
|
is raised.
|
||||||
*/
|
*/
|
||||||
PyAPI_FUNC(int) _PyObject_LookupAttr(PyObject *, PyObject *, PyObject **);
|
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);
|
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. */
|
/* Python 3.9 private API, invoked by the macros below. */
|
||||||
PyAPI_FUNC(int) _PyTrash_begin(struct _ts *tstate, PyObject *op);
|
PyAPI_FUNC(int) _PyTrash_begin(PyThreadState *tstate, PyObject *op);
|
||||||
PyAPI_FUNC(void) _PyTrash_end(struct _ts *tstate);
|
PyAPI_FUNC(void) _PyTrash_end(PyThreadState *tstate);
|
||||||
/* Python 3.10 private API, invoked by the Py_TRASHCAN_BEGIN(). */
|
/* Python 3.10 private API, invoked by the Py_TRASHCAN_BEGIN(). */
|
||||||
PyAPI_FUNC(int) _PyTrash_cond(PyObject *op, destructor dealloc);
|
PyAPI_FUNC(int) _PyTrash_cond(PyObject *op, destructor dealloc);
|
||||||
|
|
||||||
|
|
|
@ -79,12 +79,11 @@ typedef struct _stack_chunk {
|
||||||
PyObject * data[1]; /* Variable sized */
|
PyObject * data[1]; /* Variable sized */
|
||||||
} _PyStackChunk;
|
} _PyStackChunk;
|
||||||
|
|
||||||
// The PyThreadState typedef is in Include/pystate.h.
|
|
||||||
struct _ts {
|
struct _ts {
|
||||||
/* See Python/ceval.c for comments explaining most fields */
|
/* See Python/ceval.c for comments explaining most fields */
|
||||||
|
|
||||||
struct _ts *prev;
|
PyThreadState *prev;
|
||||||
struct _ts *next;
|
PyThreadState *next;
|
||||||
PyInterpreterState *interp;
|
PyInterpreterState *interp;
|
||||||
|
|
||||||
/* Has been initialized to a safe state.
|
/* Has been initialized to a safe state.
|
||||||
|
@ -308,12 +307,12 @@ PyAPI_FUNC(const PyConfig*) _Py_GetConfig(void);
|
||||||
|
|
||||||
/* cross-interpreter data */
|
/* cross-interpreter data */
|
||||||
|
|
||||||
struct _xid;
|
|
||||||
|
|
||||||
// _PyCrossInterpreterData is similar to Py_buffer as an effectively
|
// _PyCrossInterpreterData is similar to Py_buffer as an effectively
|
||||||
// opaque struct that holds data outside the object machinery. This
|
// opaque struct that holds data outside the object machinery. This
|
||||||
// is necessary to pass safely between interpreters in the same process.
|
// 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
|
// data is the cross-interpreter-safe derivation of a Python object
|
||||||
// (see _PyObject_GetCrossInterpreterData). It will be NULL if the
|
// (see _PyObject_GetCrossInterpreterData). It will be NULL if the
|
||||||
// new_object func (below) encodes the data.
|
// new_object func (below) encodes the data.
|
||||||
|
@ -339,7 +338,7 @@ typedef struct _xid {
|
||||||
// interpreter given the data. The resulting object (a new
|
// interpreter given the data. The resulting object (a new
|
||||||
// reference) will be equivalent to the original object. This field
|
// reference) will be equivalent to the original object. This field
|
||||||
// is required.
|
// is required.
|
||||||
PyObject *(*new_object)(struct _xid *);
|
PyObject *(*new_object)(_PyCrossInterpreterData *);
|
||||||
// free is called when the data is released. If it is NULL then
|
// 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
|
// 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
|
// 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).
|
// to PyMem_RawFree (the default if not explicitly set to NULL).
|
||||||
// The call will happen with the original interpreter activated.
|
// The call will happen with the original interpreter activated.
|
||||||
void (*free)(void *);
|
void (*free)(void *);
|
||||||
} _PyCrossInterpreterData;
|
};
|
||||||
|
|
||||||
PyAPI_FUNC(int) _PyObject_GetCrossInterpreterData(PyObject *, _PyCrossInterpreterData *);
|
PyAPI_FUNC(int) _PyObject_GetCrossInterpreterData(PyObject *, _PyCrossInterpreterData *);
|
||||||
PyAPI_FUNC(PyObject *) _PyCrossInterpreterData_NewObject(_PyCrossInterpreterData *);
|
PyAPI_FUNC(PyObject *) _PyCrossInterpreterData_NewObject(_PyCrossInterpreterData *);
|
||||||
|
@ -360,7 +359,7 @@ PyAPI_FUNC(int) _PyObject_CheckCrossInterpreterData(PyObject *);
|
||||||
|
|
||||||
/* cross-interpreter data registry */
|
/* cross-interpreter data registry */
|
||||||
|
|
||||||
typedef int (*crossinterpdatafunc)(PyObject *, struct _xid *);
|
typedef int (*crossinterpdatafunc)(PyObject *, _PyCrossInterpreterData *);
|
||||||
|
|
||||||
PyAPI_FUNC(int) _PyCrossInterpreterData_RegisterClass(PyTypeObject *, crossinterpdatafunc);
|
PyAPI_FUNC(int) _PyCrossInterpreterData_RegisterClass(PyTypeObject *, crossinterpdatafunc);
|
||||||
PyAPI_FUNC(crossinterpdatafunc) _PyCrossInterpreterData_Lookup(PyObject *);
|
PyAPI_FUNC(crossinterpdatafunc) _PyCrossInterpreterData_Lookup(PyObject *);
|
||||||
|
|
|
@ -2,13 +2,15 @@
|
||||||
# error "this header file must not be included directly"
|
# error "this header file must not be included directly"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct _traceback {
|
typedef struct _traceback PyTracebackObject;
|
||||||
|
|
||||||
|
struct _traceback {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
struct _traceback *tb_next;
|
PyTracebackObject *tb_next;
|
||||||
PyFrameObject *tb_frame;
|
PyFrameObject *tb_frame;
|
||||||
int tb_lasti;
|
int tb_lasti;
|
||||||
int tb_lineno;
|
int tb_lineno;
|
||||||
} PyTracebackObject;
|
};
|
||||||
|
|
||||||
PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int, int *, PyObject **);
|
PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int, int *, PyObject **);
|
||||||
PyAPI_FUNC(void) _PyTraceback_Add(const char *, const char *, int);
|
PyAPI_FUNC(void) _PyTraceback_Add(const char *, const char *, int);
|
||||||
|
|
|
@ -23,15 +23,11 @@ PyAPI_DATA(PyTypeObject) PyMethodDescr_Type;
|
||||||
PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
|
PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
|
||||||
PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
|
PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
|
||||||
PyAPI_DATA(PyTypeObject) PyProperty_Type;
|
PyAPI_DATA(PyTypeObject) PyProperty_Type;
|
||||||
// Forward declaration for following prototype
|
|
||||||
struct PyMemberDef;
|
|
||||||
|
|
||||||
PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
|
PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
|
||||||
PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
|
PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
|
||||||
PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *,
|
PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *, PyMemberDef *);
|
||||||
struct PyMemberDef *);
|
PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *, PyGetSetDef *);
|
||||||
PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
|
|
||||||
struct PyGetSetDef *);
|
|
||||||
|
|
||||||
PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
|
PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
|
||||||
PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);
|
PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);
|
||||||
|
|
|
@ -232,11 +232,9 @@ PyAPI_FUNC(int) PyModule_ExecDef(PyObject *module, PyModuleDef *def);
|
||||||
#define PyModule_FromDefAndSpec2 PyModule_FromDefAndSpec2TraceRefs
|
#define PyModule_FromDefAndSpec2 PyModule_FromDefAndSpec2TraceRefs
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PyAPI_FUNC(PyObject *) PyModule_Create2(struct PyModuleDef*,
|
PyAPI_FUNC(PyObject *) PyModule_Create2(PyModuleDef*, int apiver);
|
||||||
int apiver);
|
|
||||||
#ifndef Py_LIMITED_API
|
#ifndef Py_LIMITED_API
|
||||||
PyAPI_FUNC(PyObject *) _PyModule_CreateInitialized(struct PyModuleDef*,
|
PyAPI_FUNC(PyObject *) _PyModule_CreateInitialized(PyModuleDef*, int apiver);
|
||||||
int apiver);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Py_LIMITED_API
|
#ifdef Py_LIMITED_API
|
||||||
|
|
|
@ -32,12 +32,12 @@ PyAPI_FUNC(void) _PyModule_Clear(PyObject *);
|
||||||
PyAPI_FUNC(void) _PyModule_ClearDict(PyObject *);
|
PyAPI_FUNC(void) _PyModule_ClearDict(PyObject *);
|
||||||
PyAPI_FUNC(int) _PyModuleSpec_IsInitializing(PyObject *);
|
PyAPI_FUNC(int) _PyModuleSpec_IsInitializing(PyObject *);
|
||||||
#endif
|
#endif
|
||||||
PyAPI_FUNC(struct PyModuleDef*) PyModule_GetDef(PyObject*);
|
PyAPI_FUNC(PyModuleDef*) PyModule_GetDef(PyObject*);
|
||||||
PyAPI_FUNC(void*) PyModule_GetState(PyObject*);
|
PyAPI_FUNC(void*) PyModule_GetState(PyObject*);
|
||||||
|
|
||||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||||
/* New in 3.5 */
|
/* New in 3.5 */
|
||||||
PyAPI_FUNC(PyObject *) PyModuleDef_Init(struct PyModuleDef*);
|
PyAPI_FUNC(PyObject *) PyModuleDef_Init(PyModuleDef*);
|
||||||
PyAPI_DATA(PyTypeObject) PyModuleDef_Type;
|
PyAPI_DATA(PyTypeObject) PyModuleDef_Type;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ typedef struct PyModuleDef_Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PyModuleDef_Slot;
|
struct PyModuleDef_Slot;
|
||||||
|
|
||||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||||
/* New in 3.5 */
|
/* New in 3.5 */
|
||||||
typedef struct PyModuleDef_Slot{
|
typedef struct PyModuleDef_Slot{
|
||||||
|
@ -78,7 +79,7 @@ struct PyModuleDef {
|
||||||
const char* m_doc;
|
const char* m_doc;
|
||||||
Py_ssize_t m_size;
|
Py_ssize_t m_size;
|
||||||
PyMethodDef *m_methods;
|
PyMethodDef *m_methods;
|
||||||
struct PyModuleDef_Slot* m_slots;
|
PyModuleDef_Slot *m_slots;
|
||||||
traverseproc m_traverse;
|
traverseproc m_traverse;
|
||||||
inquiry m_clear;
|
inquiry m_clear;
|
||||||
freefunc m_free;
|
freefunc m_free;
|
||||||
|
|
|
@ -63,8 +63,8 @@ whose size is determined when the object is allocated.
|
||||||
#ifdef Py_TRACE_REFS
|
#ifdef Py_TRACE_REFS
|
||||||
/* Define pointers to support a doubly-linked list of all live heap objects. */
|
/* Define pointers to support a doubly-linked list of all live heap objects. */
|
||||||
#define _PyObject_HEAD_EXTRA \
|
#define _PyObject_HEAD_EXTRA \
|
||||||
struct _object *_ob_next; \
|
PyObject *_ob_next; \
|
||||||
struct _object *_ob_prev;
|
PyObject *_ob_prev;
|
||||||
|
|
||||||
#define _PyObject_EXTRA_INIT 0, 0,
|
#define _PyObject_EXTRA_INIT 0, 0,
|
||||||
|
|
||||||
|
@ -237,8 +237,8 @@ PyAPI_FUNC(void*) PyType_GetSlot(PyTypeObject*, int);
|
||||||
#endif
|
#endif
|
||||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
|
||||||
PyAPI_FUNC(PyObject*) PyType_FromModuleAndSpec(PyObject *, PyType_Spec *, PyObject *);
|
PyAPI_FUNC(PyObject*) PyType_FromModuleAndSpec(PyObject *, PyType_Spec *, PyObject *);
|
||||||
PyAPI_FUNC(PyObject *) PyType_GetModule(struct _typeobject *);
|
PyAPI_FUNC(PyObject *) PyType_GetModule(PyTypeObject *);
|
||||||
PyAPI_FUNC(void *) PyType_GetModuleState(struct _typeobject *);
|
PyAPI_FUNC(void *) PyType_GetModuleState(PyTypeObject *);
|
||||||
#endif
|
#endif
|
||||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030B0000
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030B0000
|
||||||
PyAPI_FUNC(PyObject *) PyType_GetName(PyTypeObject *);
|
PyAPI_FUNC(PyObject *) PyType_GetName(PyTypeObject *);
|
||||||
|
|
|
@ -40,10 +40,10 @@ PyAPI_FUNC(int64_t) PyInterpreterState_GetID(PyInterpreterState *);
|
||||||
/* State unique per thread */
|
/* State unique per thread */
|
||||||
|
|
||||||
/* New in 3.3 */
|
/* New in 3.3 */
|
||||||
PyAPI_FUNC(int) PyState_AddModule(PyObject*, struct PyModuleDef*);
|
PyAPI_FUNC(int) PyState_AddModule(PyObject*, PyModuleDef*);
|
||||||
PyAPI_FUNC(int) PyState_RemoveModule(struct PyModuleDef*);
|
PyAPI_FUNC(int) PyState_RemoveModule(PyModuleDef*);
|
||||||
#endif
|
#endif
|
||||||
PyAPI_FUNC(PyObject*) PyState_FindModule(struct PyModuleDef*);
|
PyAPI_FUNC(PyObject*) PyState_FindModule(PyModuleDef*);
|
||||||
|
|
||||||
PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *);
|
PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *);
|
||||||
PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *);
|
PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *);
|
||||||
|
|
|
@ -65,8 +65,8 @@ struct PyMemberDef {
|
||||||
#define PY_AUDIT_READ READ_RESTRICTED
|
#define PY_AUDIT_READ READ_RESTRICTED
|
||||||
|
|
||||||
/* Current API, use this */
|
/* Current API, use this */
|
||||||
PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, struct PyMemberDef *);
|
PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, PyMemberDef *);
|
||||||
PyAPI_FUNC(int) PyMember_SetOne(char *, struct PyMemberDef *, PyObject *);
|
PyAPI_FUNC(int) PyMember_SetOne(char *, PyMemberDef *, PyObject *);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -15,7 +15,7 @@ typedef struct PyStructSequence_Field {
|
||||||
typedef struct PyStructSequence_Desc {
|
typedef struct PyStructSequence_Desc {
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *doc;
|
const char *doc;
|
||||||
struct PyStructSequence_Field *fields;
|
PyStructSequence_Field *fields;
|
||||||
int n_in_sequence;
|
int n_in_sequence;
|
||||||
} PyStructSequence_Desc;
|
} PyStructSequence_Desc;
|
||||||
|
|
||||||
|
|
|
@ -884,8 +884,7 @@ PyObject_CallMethodObjArgs(PyObject *obj, PyObject *name, ...)
|
||||||
|
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
_PyObject_CallMethodIdObjArgs(PyObject *obj,
|
_PyObject_CallMethodIdObjArgs(PyObject *obj, _Py_Identifier *name, ...)
|
||||||
struct _Py_Identifier *name, ...)
|
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = _PyThreadState_GET();
|
PyThreadState *tstate = _PyThreadState_GET();
|
||||||
if (obj == NULL || name == NULL) {
|
if (obj == NULL || name == NULL) {
|
||||||
|
|
|
@ -1500,7 +1500,7 @@ _PyDict_GetItemWithError(PyObject *dp, PyObject *kv)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
_PyDict_GetItemIdWithError(PyObject *dp, struct _Py_Identifier *key)
|
_PyDict_GetItemIdWithError(PyObject *dp, _Py_Identifier *key)
|
||||||
{
|
{
|
||||||
PyObject *kv;
|
PyObject *kv;
|
||||||
kv = _PyUnicode_FromId(key); /* borrowed */
|
kv = _PyUnicode_FromId(key); /* borrowed */
|
||||||
|
@ -3411,7 +3411,7 @@ _PyDict_Contains_KnownHash(PyObject *op, PyObject *key, Py_hash_t hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_PyDict_ContainsId(PyObject *op, struct _Py_Identifier *key)
|
_PyDict_ContainsId(PyObject *op, _Py_Identifier *key)
|
||||||
{
|
{
|
||||||
PyObject *kv = _PyUnicode_FromId(key); /* borrowed */
|
PyObject *kv = _PyUnicode_FromId(key); /* borrowed */
|
||||||
if (kv == NULL) {
|
if (kv == NULL) {
|
||||||
|
@ -3589,7 +3589,7 @@ PyDict_GetItemString(PyObject *v, const char *key)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_PyDict_SetItemId(PyObject *v, struct _Py_Identifier *key, PyObject *item)
|
_PyDict_SetItemId(PyObject *v, _Py_Identifier *key, PyObject *item)
|
||||||
{
|
{
|
||||||
PyObject *kv;
|
PyObject *kv;
|
||||||
kv = _PyUnicode_FromId(key); /* borrowed */
|
kv = _PyUnicode_FromId(key); /* borrowed */
|
||||||
|
|
|
@ -19,7 +19,7 @@ static PyMemberDef module_members[] = {
|
||||||
PyTypeObject PyModuleDef_Type = {
|
PyTypeObject PyModuleDef_Type = {
|
||||||
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
||||||
"moduledef", /* tp_name */
|
"moduledef", /* tp_name */
|
||||||
sizeof(struct PyModuleDef), /* tp_basicsize */
|
sizeof(PyModuleDef), /* tp_basicsize */
|
||||||
0, /* tp_itemsize */
|
0, /* tp_itemsize */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,13 +32,13 @@ _PyModule_IsExtension(PyObject *obj)
|
||||||
}
|
}
|
||||||
PyModuleObject *module = (PyModuleObject*)obj;
|
PyModuleObject *module = (PyModuleObject*)obj;
|
||||||
|
|
||||||
struct PyModuleDef *def = module->md_def;
|
PyModuleDef *def = module->md_def;
|
||||||
return (def != NULL && def->m_methods != NULL);
|
return (def != NULL && def->m_methods != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PyObject*
|
PyObject*
|
||||||
PyModuleDef_Init(struct PyModuleDef* def)
|
PyModuleDef_Init(PyModuleDef* def)
|
||||||
{
|
{
|
||||||
assert(PyModuleDef_Type.tp_flags & Py_TPFLAGS_READY);
|
assert(PyModuleDef_Type.tp_flags & Py_TPFLAGS_READY);
|
||||||
if (def->m_base.m_index == 0) {
|
if (def->m_base.m_index == 0) {
|
||||||
|
@ -182,7 +182,7 @@ _add_methods_to_object(PyObject *module, PyObject *name, PyMethodDef *functions)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyModule_Create2(struct PyModuleDef* module, int module_api_version)
|
PyModule_Create2(PyModuleDef* module, int module_api_version)
|
||||||
{
|
{
|
||||||
if (!_PyImport_IsInitialized(_PyInterpreterState_GET())) {
|
if (!_PyImport_IsInitialized(_PyInterpreterState_GET())) {
|
||||||
PyErr_SetString(PyExc_SystemError,
|
PyErr_SetString(PyExc_SystemError,
|
||||||
|
@ -193,7 +193,7 @@ PyModule_Create2(struct PyModuleDef* module, int module_api_version)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
_PyModule_CreateInitialized(struct PyModuleDef* module, int module_api_version)
|
_PyModule_CreateInitialized(PyModuleDef* module, int module_api_version)
|
||||||
{
|
{
|
||||||
const char* name;
|
const char* name;
|
||||||
PyModuleObject *m;
|
PyModuleObject *m;
|
||||||
|
@ -256,7 +256,7 @@ _PyModule_CreateInitialized(struct PyModuleDef* module, int module_api_version)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyModule_FromDefAndSpec2(struct PyModuleDef* def, PyObject *spec, int module_api_version)
|
PyModule_FromDefAndSpec2(PyModuleDef* def, PyObject *spec, int module_api_version)
|
||||||
{
|
{
|
||||||
PyModuleDef_Slot* cur_slot;
|
PyModuleDef_Slot* cur_slot;
|
||||||
PyObject *(*create)(PyObject *, PyModuleDef*) = NULL;
|
PyObject *(*create)(PyObject *, PyModuleDef*) = NULL;
|
||||||
|
|
|
@ -3716,7 +3716,7 @@ PyType_GetModuleState(PyTypeObject *type)
|
||||||
* given PyModuleDef.
|
* given PyModuleDef.
|
||||||
*/
|
*/
|
||||||
PyObject *
|
PyObject *
|
||||||
PyType_GetModuleByDef(PyTypeObject *type, struct PyModuleDef *def)
|
PyType_GetModuleByDef(PyTypeObject *type, PyModuleDef *def)
|
||||||
{
|
{
|
||||||
assert(PyType_Check(type));
|
assert(PyType_Check(type));
|
||||||
|
|
||||||
|
@ -3869,7 +3869,7 @@ _PyType_Lookup(PyTypeObject *type, PyObject *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
_PyType_LookupId(PyTypeObject *type, struct _Py_Identifier *name)
|
_PyType_LookupId(PyTypeObject *type, _Py_Identifier *name)
|
||||||
{
|
{
|
||||||
PyObject *oname;
|
PyObject *oname;
|
||||||
oname = _PyUnicode_FromId(name); /* borrowed */
|
oname = _PyUnicode_FromId(name); /* borrowed */
|
||||||
|
|
|
@ -283,7 +283,7 @@ _PyImport_IsInitialized(PyInterpreterState *interp)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
_PyImport_GetModuleId(struct _Py_Identifier *nameid)
|
_PyImport_GetModuleId(_Py_Identifier *nameid)
|
||||||
{
|
{
|
||||||
PyObject *name = _PyUnicode_FromId(nameid); /* borrowed */
|
PyObject *name = _PyUnicode_FromId(nameid); /* borrowed */
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
|
|
|
@ -862,7 +862,7 @@ _PyThreadState_SetCurrent(PyThreadState *tstate)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject*
|
PyObject*
|
||||||
PyState_FindModule(struct PyModuleDef* module)
|
PyState_FindModule(PyModuleDef* module)
|
||||||
{
|
{
|
||||||
Py_ssize_t index = module->m_base.m_index;
|
Py_ssize_t index = module->m_base.m_index;
|
||||||
PyInterpreterState *state = _PyInterpreterState_GET();
|
PyInterpreterState *state = _PyInterpreterState_GET();
|
||||||
|
@ -881,7 +881,7 @@ PyState_FindModule(struct PyModuleDef* module)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_PyState_AddModule(PyThreadState *tstate, PyObject* module, struct PyModuleDef* def)
|
_PyState_AddModule(PyThreadState *tstate, PyObject* module, PyModuleDef* def)
|
||||||
{
|
{
|
||||||
if (!def) {
|
if (!def) {
|
||||||
assert(_PyErr_Occurred(tstate));
|
assert(_PyErr_Occurred(tstate));
|
||||||
|
@ -914,7 +914,7 @@ _PyState_AddModule(PyThreadState *tstate, PyObject* module, struct PyModuleDef*
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyState_AddModule(PyObject* module, struct PyModuleDef* def)
|
PyState_AddModule(PyObject* module, PyModuleDef* def)
|
||||||
{
|
{
|
||||||
if (!def) {
|
if (!def) {
|
||||||
Py_FatalError("module definition is NULL");
|
Py_FatalError("module definition is NULL");
|
||||||
|
@ -935,7 +935,7 @@ PyState_AddModule(PyObject* module, struct PyModuleDef* def)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyState_RemoveModule(struct PyModuleDef* def)
|
PyState_RemoveModule(PyModuleDef* def)
|
||||||
{
|
{
|
||||||
PyThreadState *tstate = _PyThreadState_GET();
|
PyThreadState *tstate = _PyThreadState_GET();
|
||||||
PyInterpreterState *interp = tstate->interp;
|
PyInterpreterState *interp = tstate->interp;
|
||||||
|
|
|
@ -3665,8 +3665,7 @@ class self_converter(CConverter):
|
||||||
self.show_in_signature = False
|
self.show_in_signature = False
|
||||||
|
|
||||||
# tp_new (METHOD_NEW) functions are of type newfunc:
|
# tp_new (METHOD_NEW) functions are of type newfunc:
|
||||||
# typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *);
|
# typedef PyObject *(*newfunc)(PyTypeObject *, PyObject *, PyObject *);
|
||||||
# PyTypeObject is a typedef for struct _typeobject.
|
|
||||||
#
|
#
|
||||||
# tp_init (METHOD_INIT) functions are of type initproc:
|
# tp_init (METHOD_INIT) functions are of type initproc:
|
||||||
# typedef int (*initproc)(PyObject *, PyObject *, PyObject *);
|
# typedef int (*initproc)(PyObject *, PyObject *, PyObject *);
|
||||||
|
|
Loading…
Reference in New Issue