| 1 |
#pragma once |
| 2 |
|
| 3 |
#define PyObject_HEAD PyObject ob_base; |
| 4 |
#define PyObject_VAR_HEAD PyVarObject ob_base; |
| 5 |
|
| 6 |
typedef struct _object { |
| 7 |
Py_ssize_t ob_refcnt; |
| 8 |
Py_ssize_t ob_pypy_link; |
| 9 |
struct _typeobject *ob_type; |
| 10 |
} PyObject; |
| 11 |
|
| 12 |
typedef struct { |
| 13 |
PyObject ob_base; |
| 14 |
Py_ssize_t ob_size; |
| 15 |
} PyVarObject; |
| 16 |
|
| 17 |
struct _typeobject; |
| 18 |
typedef void (*freefunc)(void *); |
| 19 |
typedef void (*destructor)(PyObject *); |
| 20 |
typedef Py_ssize_t printfunc; |
| 21 |
typedef PyObject *(*getattrfunc)(PyObject *, char *); |
| 22 |
typedef PyObject *(*getattrofunc)(PyObject *, PyObject *); |
| 23 |
typedef int (*setattrfunc)(PyObject *, char *, PyObject *); |
| 24 |
typedef int (*setattrofunc)(PyObject *, PyObject *, PyObject *); |
| 25 |
typedef int (*cmpfunc)(PyObject *, PyObject *); |
| 26 |
typedef PyObject *(*reprfunc)(PyObject *); |
| 27 |
typedef Py_hash_t (*hashfunc)(PyObject *); |
| 28 |
typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int); |
| 29 |
typedef PyObject *(*getiterfunc) (PyObject *); |
| 30 |
typedef PyObject *(*iternextfunc) (PyObject *); |
| 31 |
typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *); |
| 32 |
typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *); |
| 33 |
typedef int (*initproc)(PyObject *, PyObject *, PyObject *); |
| 34 |
typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *); |
| 35 |
typedef PyObject *(*allocfunc)(struct _typeobject *, Py_ssize_t); |
| 36 |
|
| 37 |
typedef PyObject * (*unaryfunc)(PyObject *); |
| 38 |
typedef PyObject * (*binaryfunc)(PyObject *, PyObject *); |
| 39 |
typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *); |
| 40 |
typedef int (*inquiry)(PyObject *); |
| 41 |
typedef Py_ssize_t (*lenfunc)(PyObject *); |
| 42 |
typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t); |
| 43 |
typedef PyObject *(*ssizessizeargfunc)(PyObject *, Py_ssize_t, Py_ssize_t); |
| 44 |
typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *); |
| 45 |
typedef int(*ssizessizeobjargproc)(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *); |
| 46 |
typedef int(*objobjargproc)(PyObject *, PyObject *, PyObject *); |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
#define PyBUF_MAX_NDIM 64 |
| 52 |
typedef struct bufferinfo { |
| 53 |
void *buf; |
| 54 |
PyObject *obj; |
| 55 |
Py_ssize_t len; |
| 56 |
Py_ssize_t itemsize; |
| 57 |
|
| 58 |
int readonly; |
| 59 |
int ndim; |
| 60 |
char *format; |
| 61 |
Py_ssize_t *shape; |
| 62 |
Py_ssize_t *strides; |
| 63 |
Py_ssize_t *suboffsets; |
| 64 |
void *internal; |
| 65 |
|
| 66 |
int flags; |
| 67 |
Py_ssize_t _strides[PyBUF_MAX_NDIM]; |
| 68 |
Py_ssize_t _shape[PyBUF_MAX_NDIM]; |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
} Py_buffer; |
| 73 |
|
| 74 |
typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); |
| 75 |
typedef void (*releasebufferproc)(PyObject *, Py_buffer *); |
| 76 |
|
| 77 |
typedef PyObject *(*vectorcallfunc)(PyObject *callable, PyObject *const *args, |
| 78 |
size_t nargsf, PyObject *kwnames); |
| 79 |
|
| 80 |
typedef int (*objobjproc)(PyObject *, PyObject *); |
| 81 |
typedef int (*visitproc)(PyObject *, void *); |
| 82 |
typedef int (*traverseproc)(PyObject *, visitproc, void *); |
| 83 |
|
| 84 |
|
| 85 |
typedef struct { |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
binaryfunc nb_add; |
| 91 |
binaryfunc nb_subtract; |
| 92 |
binaryfunc nb_multiply; |
| 93 |
binaryfunc nb_remainder; |
| 94 |
binaryfunc nb_divmod; |
| 95 |
ternaryfunc nb_power; |
| 96 |
unaryfunc nb_negative; |
| 97 |
unaryfunc nb_positive; |
| 98 |
unaryfunc nb_absolute; |
| 99 |
inquiry nb_bool; |
| 100 |
unaryfunc nb_invert; |
| 101 |
binaryfunc nb_lshift; |
| 102 |
binaryfunc nb_rshift; |
| 103 |
binaryfunc nb_and; |
| 104 |
binaryfunc nb_xor; |
| 105 |
binaryfunc nb_or; |
| 106 |
unaryfunc nb_int; |
| 107 |
void *nb_reserved; |
| 108 |
unaryfunc nb_float; |
| 109 |
|
| 110 |
binaryfunc nb_inplace_add; |
| 111 |
binaryfunc nb_inplace_subtract; |
| 112 |
binaryfunc nb_inplace_multiply; |
| 113 |
binaryfunc nb_inplace_remainder; |
| 114 |
ternaryfunc nb_inplace_power; |
| 115 |
binaryfunc nb_inplace_lshift; |
| 116 |
binaryfunc nb_inplace_rshift; |
| 117 |
binaryfunc nb_inplace_and; |
| 118 |
binaryfunc nb_inplace_xor; |
| 119 |
binaryfunc nb_inplace_or; |
| 120 |
|
| 121 |
binaryfunc nb_floor_divide; |
| 122 |
binaryfunc nb_true_divide; |
| 123 |
binaryfunc nb_inplace_floor_divide; |
| 124 |
binaryfunc nb_inplace_true_divide; |
| 125 |
|
| 126 |
unaryfunc nb_index; |
| 127 |
|
| 128 |
binaryfunc nb_matrix_multiply; |
| 129 |
binaryfunc nb_inplace_matrix_multiply; |
| 130 |
} PyNumberMethods; |
| 131 |
|
| 132 |
typedef struct { |
| 133 |
lenfunc sq_length; |
| 134 |
binaryfunc sq_concat; |
| 135 |
ssizeargfunc sq_repeat; |
| 136 |
ssizeargfunc sq_item; |
| 137 |
void *was_sq_slice; |
| 138 |
ssizeobjargproc sq_ass_item; |
| 139 |
void *was_sq_ass_slice; |
| 140 |
objobjproc sq_contains; |
| 141 |
|
| 142 |
binaryfunc sq_inplace_concat; |
| 143 |
ssizeargfunc sq_inplace_repeat; |
| 144 |
} PySequenceMethods; |
| 145 |
|
| 146 |
typedef struct { |
| 147 |
lenfunc mp_length; |
| 148 |
binaryfunc mp_subscript; |
| 149 |
objobjargproc mp_ass_subscript; |
| 150 |
} PyMappingMethods; |
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
enum { |
| 164 |
PYGEN_RETURN = 0, |
| 165 |
PYGEN_ERROR = -1, |
| 166 |
PYGEN_NEXT = 1, |
| 167 |
}; |
| 168 |
|
| 169 |
typedef int PySendResult; |
| 170 |
|
| 171 |
typedef int (*sendfunc)(PyObject *iter, PyObject *value, PyObject **result); |
| 172 |
|
| 173 |
typedef struct { |
| 174 |
unaryfunc am_await; |
| 175 |
unaryfunc am_aiter; |
| 176 |
unaryfunc am_anext; |
| 177 |
sendfunc am_send; |
| 178 |
} PyAsyncMethods; |
| 179 |
|
| 180 |
typedef struct { |
| 181 |
getbufferproc bf_getbuffer; |
| 182 |
releasebufferproc bf_releasebuffer; |
| 183 |
} PyBufferProcs; |
| 184 |
|
| 185 |
|
| 186 |
typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); |
| 187 |
typedef PyObject *(*_PyCFunctionFast) (PyObject *, PyObject **, Py_ssize_t); |
| 188 |
typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *, |
| 189 |
PyObject *); |
| 190 |
typedef PyObject *(*_PyCFunctionFastWithKeywords) (PyObject *, |
| 191 |
PyObject **, Py_ssize_t, |
| 192 |
PyObject *); |
| 193 |
|
| 194 |
typedef PyObject *(*PyNoArgsFunction)(PyObject *); |
| 195 |
|
| 196 |
struct PyMethodDef { |
| 197 |
const char *ml_name; |
| 198 |
PyCFunction ml_meth; |
| 199 |
int ml_flags; |
| 200 |
|
| 201 |
const char *ml_doc; |
| 202 |
}; |
| 203 |
typedef struct PyMethodDef PyMethodDef; |
| 204 |
|
| 205 |
typedef struct { |
| 206 |
PyObject_HEAD |
| 207 |
PyMethodDef *m_ml; |
| 208 |
PyObject *m_self; |
| 209 |
PyObject *m_module; |
| 210 |
PyObject *m_weakreflist; |
| 211 |
} PyCFunctionObject; |
| 212 |
|
| 213 |
|
| 214 |
typedef struct PyMemberDef { |
| 215 |
|
| 216 |
const char *name; |
| 217 |
int type; |
| 218 |
Py_ssize_t offset; |
| 219 |
int flags; |
| 220 |
const char *doc; |
| 221 |
} PyMemberDef; |
| 222 |
|
| 223 |
|
| 224 |
typedef struct _typeobject { |
| 225 |
PyObject_VAR_HEAD |
| 226 |
const char *tp_name; |
| 227 |
Py_ssize_t tp_basicsize, tp_itemsize; |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
destructor tp_dealloc; |
| 232 |
Py_ssize_t tp_vectorcall_offset; |
| 233 |
getattrfunc tp_getattr; |
| 234 |
setattrfunc tp_setattr; |
| 235 |
PyAsyncMethods *tp_as_async; |
| 236 |
|
| 237 |
reprfunc tp_repr; |
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
PyNumberMethods *tp_as_number; |
| 242 |
PySequenceMethods *tp_as_sequence; |
| 243 |
PyMappingMethods *tp_as_mapping; |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
hashfunc tp_hash; |
| 248 |
ternaryfunc tp_call; |
| 249 |
reprfunc tp_str; |
| 250 |
getattrofunc tp_getattro; |
| 251 |
setattrofunc tp_setattro; |
| 252 |
|
| 253 |
|
| 254 |
PyBufferProcs *tp_as_buffer; |
| 255 |
|
| 256 |
|
| 257 |
unsigned long tp_flags; |
| 258 |
|
| 259 |
const char *tp_doc; |
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
traverseproc tp_traverse; |
| 264 |
|
| 265 |
|
| 266 |
inquiry tp_clear; |
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
richcmpfunc tp_richcompare; |
| 271 |
|
| 272 |
|
| 273 |
Py_ssize_t tp_weaklistoffset; |
| 274 |
|
| 275 |
|
| 276 |
getiterfunc tp_iter; |
| 277 |
iternextfunc tp_iternext; |
| 278 |
|
| 279 |
|
| 280 |
struct PyMethodDef *tp_methods; |
| 281 |
struct PyMemberDef *tp_members; |
| 282 |
struct PyGetSetDef *tp_getset; |
| 283 |
struct _typeobject *tp_base; |
| 284 |
PyObject *tp_dict; |
| 285 |
descrgetfunc tp_descr_get; |
| 286 |
descrsetfunc tp_descr_set; |
| 287 |
Py_ssize_t tp_dictoffset; |
| 288 |
initproc tp_init; |
| 289 |
allocfunc tp_alloc; |
| 290 |
newfunc tp_new; |
| 291 |
freefunc tp_free; |
| 292 |
inquiry tp_is_gc; |
| 293 |
PyObject *tp_bases; |
| 294 |
PyObject *tp_mro; |
| 295 |
PyObject *tp_cache; |
| 296 |
PyObject *tp_subclasses; |
| 297 |
PyObject *tp_weaklist; |
| 298 |
destructor tp_del; |
| 299 |
|
| 300 |
|
| 301 |
unsigned int tp_version_tag; |
| 302 |
|
| 303 |
destructor tp_finalize; |
| 304 |
vectorcallfunc tp_vectorcall; |
| 305 |
} PyTypeObject; |
| 306 |
|
| 307 |
typedef struct{ |
| 308 |
int slot; |
| 309 |
void *pfunc; |
| 310 |
} PyType_Slot; |
| 311 |
|
| 312 |
typedef struct{ |
| 313 |
const char* name; |
| 314 |
int basicsize; |
| 315 |
int itemsize; |
| 316 |
unsigned int flags; |
| 317 |
PyType_Slot *slots; |
| 318 |
} PyType_Spec; |
| 319 |
|
| 320 |
typedef struct _heaptypeobject { |
| 321 |
PyTypeObject ht_type; |
| 322 |
PyAsyncMethods as_async; |
| 323 |
PyNumberMethods as_number; |
| 324 |
PyMappingMethods as_mapping; |
| 325 |
PySequenceMethods as_sequence; |
| 326 |
PyBufferProcs as_buffer; |
| 327 |
PyObject *ht_name, *ht_slots, *ht_qualname; |
| 328 |
PyObject *ht_module; |
| 329 |
} PyHeapTypeObject; |
| 330 |
|
| 331 |
|
| 332 |
#define PyHeapType_GET_MEMBERS(etype) \ |
| 333 |
((PyMemberDef *)(((char *)etype) + Py_TYPE(etype)->tp_basicsize)) |
| 334 |
|
| 335 |
typedef struct { |
| 336 |
PyCFunctionObject func; |
| 337 |
PyTypeObject *mm_class; |
| 338 |
} PyCMethodObject; |
| 339 |
|
| 340 |
|
| 341 |
typedef PyObject *(*PyCMethod)(PyObject *, PyTypeObject *, PyObject **, |
| 342 |
size_t, PyObject *); |
| 343 |
|