File indexing completed on 2025-01-18 10:06:40
0001
0002
0003 #ifndef Py_LIMITED_API
0004 #ifndef Py_FUNCOBJECT_H
0005 #define Py_FUNCOBJECT_H
0006 #ifdef __cplusplus
0007 extern "C" {
0008 #endif
0009
0010
0011 #define _Py_COMMON_FIELDS(PREFIX) \
0012 PyObject *PREFIX ## globals; \
0013 PyObject *PREFIX ## builtins; \
0014 PyObject *PREFIX ## name; \
0015 PyObject *PREFIX ## qualname; \
0016 PyObject *PREFIX ## code; \
0017 PyObject *PREFIX ## defaults; \
0018 PyObject *PREFIX ## kwdefaults; \
0019 PyObject *PREFIX ## closure;
0020
0021 typedef struct {
0022 _Py_COMMON_FIELDS(fc_)
0023 } PyFrameConstructor;
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 typedef struct {
0037 PyObject_HEAD
0038 _Py_COMMON_FIELDS(func_)
0039 PyObject *func_doc;
0040 PyObject *func_dict;
0041 PyObject *func_weakreflist;
0042 PyObject *func_module;
0043 PyObject *func_annotations;
0044 PyObject *func_typeparams;
0045 vectorcallfunc vectorcall;
0046
0047
0048
0049
0050
0051
0052
0053
0054 uint32_t func_version;
0055
0056
0057
0058
0059
0060
0061 } PyFunctionObject;
0062
0063 #undef _Py_COMMON_FIELDS
0064
0065 PyAPI_DATA(PyTypeObject) PyFunction_Type;
0066
0067 #define PyFunction_Check(op) Py_IS_TYPE((op), &PyFunction_Type)
0068
0069 PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *);
0070 PyAPI_FUNC(PyObject *) PyFunction_NewWithQualName(PyObject *, PyObject *, PyObject *);
0071 PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *);
0072 PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *);
0073 PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *);
0074 PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *);
0075 PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *);
0076 PyAPI_FUNC(void) PyFunction_SetVectorcall(PyFunctionObject *, vectorcallfunc);
0077 PyAPI_FUNC(PyObject *) PyFunction_GetKwDefaults(PyObject *);
0078 PyAPI_FUNC(int) PyFunction_SetKwDefaults(PyObject *, PyObject *);
0079 PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *);
0080 PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *);
0081 PyAPI_FUNC(PyObject *) PyFunction_GetAnnotations(PyObject *);
0082 PyAPI_FUNC(int) PyFunction_SetAnnotations(PyObject *, PyObject *);
0083
0084 PyAPI_FUNC(PyObject *) _PyFunction_Vectorcall(
0085 PyObject *func,
0086 PyObject *const *stack,
0087 size_t nargsf,
0088 PyObject *kwnames);
0089
0090 #define _PyFunction_CAST(func) \
0091 (assert(PyFunction_Check(func)), _Py_CAST(PyFunctionObject*, func))
0092
0093
0094
0095 static inline PyObject* PyFunction_GET_CODE(PyObject *func) {
0096 return _PyFunction_CAST(func)->func_code;
0097 }
0098 #define PyFunction_GET_CODE(func) PyFunction_GET_CODE(_PyObject_CAST(func))
0099
0100 static inline PyObject* PyFunction_GET_GLOBALS(PyObject *func) {
0101 return _PyFunction_CAST(func)->func_globals;
0102 }
0103 #define PyFunction_GET_GLOBALS(func) PyFunction_GET_GLOBALS(_PyObject_CAST(func))
0104
0105 static inline PyObject* PyFunction_GET_MODULE(PyObject *func) {
0106 return _PyFunction_CAST(func)->func_module;
0107 }
0108 #define PyFunction_GET_MODULE(func) PyFunction_GET_MODULE(_PyObject_CAST(func))
0109
0110 static inline PyObject* PyFunction_GET_DEFAULTS(PyObject *func) {
0111 return _PyFunction_CAST(func)->func_defaults;
0112 }
0113 #define PyFunction_GET_DEFAULTS(func) PyFunction_GET_DEFAULTS(_PyObject_CAST(func))
0114
0115 static inline PyObject* PyFunction_GET_KW_DEFAULTS(PyObject *func) {
0116 return _PyFunction_CAST(func)->func_kwdefaults;
0117 }
0118 #define PyFunction_GET_KW_DEFAULTS(func) PyFunction_GET_KW_DEFAULTS(_PyObject_CAST(func))
0119
0120 static inline PyObject* PyFunction_GET_CLOSURE(PyObject *func) {
0121 return _PyFunction_CAST(func)->func_closure;
0122 }
0123 #define PyFunction_GET_CLOSURE(func) PyFunction_GET_CLOSURE(_PyObject_CAST(func))
0124
0125 static inline PyObject* PyFunction_GET_ANNOTATIONS(PyObject *func) {
0126 return _PyFunction_CAST(func)->func_annotations;
0127 }
0128 #define PyFunction_GET_ANNOTATIONS(func) PyFunction_GET_ANNOTATIONS(_PyObject_CAST(func))
0129
0130
0131 PyAPI_DATA(PyTypeObject) PyClassMethod_Type;
0132 PyAPI_DATA(PyTypeObject) PyStaticMethod_Type;
0133
0134 PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *);
0135 PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *);
0136
0137 #define PY_FOREACH_FUNC_EVENT(V) \
0138 V(CREATE) \
0139 V(DESTROY) \
0140 V(MODIFY_CODE) \
0141 V(MODIFY_DEFAULTS) \
0142 V(MODIFY_KWDEFAULTS)
0143
0144 typedef enum {
0145 #define PY_DEF_EVENT(EVENT) PyFunction_EVENT_##EVENT,
0146 PY_FOREACH_FUNC_EVENT(PY_DEF_EVENT)
0147 #undef PY_DEF_EVENT
0148 } PyFunction_WatchEvent;
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165 typedef int (*PyFunction_WatchCallback)(
0166 PyFunction_WatchEvent event,
0167 PyFunctionObject *func,
0168 PyObject *new_value);
0169
0170
0171
0172
0173
0174
0175
0176
0177 PyAPI_FUNC(int) PyFunction_AddWatcher(PyFunction_WatchCallback callback);
0178
0179
0180
0181
0182
0183
0184 PyAPI_FUNC(int) PyFunction_ClearWatcher(int watcher_id);
0185
0186 #ifdef __cplusplus
0187 }
0188 #endif
0189 #endif
0190 #endif