| 1 |
#ifndef Py_OBJECT_H |
| 2 |
#define Py_OBJECT_H |
| 3 |
|
| 4 |
#ifdef __cplusplus |
| 5 |
extern "C" { |
| 6 |
#endif |
| 7 |
|
| 8 |
#include "cpyext_object.h" |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
#if defined(Py_DEBUG) && !defined(Py_REF_DEBUG) |
| 57 |
# define Py_REF_DEBUG |
| 58 |
#endif |
| 59 |
|
| 60 |
#if defined(Py_LIMITED_API) && defined(Py_TRACE_REFS) |
| 61 |
# error Py_LIMITED_API is incompatible with Py_TRACE_REFS |
| 62 |
#endif |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
typedef struct _typeobject PyTypeObject; |
| 67 |
|
| 68 |
#ifdef Py_TRACE_REFS |
| 69 |
|
| 70 |
#define _PyObject_HEAD_EXTRA \ |
| 71 |
PyObject *_ob_next; \ |
| 72 |
PyObject *_ob_prev; |
| 73 |
|
| 74 |
#define _PyObject_EXTRA_INIT _Py_NULL, _Py_NULL, |
| 75 |
|
| 76 |
#else |
| 77 |
# define _PyObject_HEAD_EXTRA |
| 78 |
# define _PyObject_EXTRA_INIT |
| 79 |
#endif |
| 80 |
|
| 81 |
|
| 82 |
#define PyObject_HEAD PyObject ob_base; |
| 83 |
|
| 84 |
|
| 85 |
#define PyObject_HEAD_INIT(type) \ |
| 86 |
{ _PyObject_EXTRA_INIT \ |
| 87 |
1, 0, type }, |
| 88 |
|
| 89 |
#define PyVarObject_HEAD_INIT(type, size) \ |
| 90 |
{ PyObject_HEAD_INIT(type) size }, |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
#define PyObject_VAR_HEAD PyVarObject ob_base; |
| 99 |
#define Py_INVALID_SIZE (Py_ssize_t)-1 |
| 100 |
|
| 101 |
#ifndef PYPY_VERSION |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
struct _object { |
| 108 |
_PyObject_HEAD_EXTRA |
| 109 |
Py_ssize_t ob_refcnt; |
| 110 |
PyTypeObject *ob_type; |
| 111 |
}; |
| 112 |
#endif |
| 113 |
|
| 114 |
|
| 115 |
#define _PyObject_CAST(op) _Py_CAST(PyObject*, (op)) |
| 116 |
|
| 117 |
|
| 118 |
#define _PyVarObject_CAST(op) _Py_CAST(PyVarObject*, (op)) |
| 119 |
|
| 120 |
static inline Py_ssize_t Py_REFCNT(PyObject *ob) { |
| 121 |
return ob->ob_refcnt; |
| 122 |
} |
| 123 |
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 |
| 124 |
# define Py_REFCNT(ob) Py_REFCNT(_PyObject_CAST(ob)) |
| 125 |
#endif |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
static inline PyTypeObject* Py_TYPE(PyObject *ob) { |
| 130 |
return ob->ob_type; |
| 131 |
} |
| 132 |
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 |
| 133 |
# define Py_TYPE(ob) Py_TYPE(_PyObject_CAST(ob)) |
| 134 |
#endif |
| 135 |
|
| 136 |
|
| 137 |
static inline Py_ssize_t Py_SIZE(PyObject *ob) { |
| 138 |
PyVarObject *var_ob = _PyVarObject_CAST(ob); |
| 139 |
return var_ob->ob_size; |
| 140 |
} |
| 141 |
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 |
| 142 |
# define Py_SIZE(ob) Py_SIZE(_PyObject_CAST(ob)) |
| 143 |
#endif |
| 144 |
|
| 145 |
|
| 146 |
static inline int Py_IS_TYPE(PyObject *ob, PyTypeObject *type) { |
| 147 |
return Py_TYPE(ob) == type; |
| 148 |
} |
| 149 |
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 |
| 150 |
# define Py_IS_TYPE(ob, type) Py_IS_TYPE(_PyObject_CAST(ob), type) |
| 151 |
#endif |
| 152 |
|
| 153 |
|
| 154 |
static inline void Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt) { |
| 155 |
ob->ob_refcnt = refcnt; |
| 156 |
} |
| 157 |
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 |
| 158 |
# define Py_SET_REFCNT(ob, refcnt) Py_SET_REFCNT(_PyObject_CAST(ob), refcnt) |
| 159 |
#endif |
| 160 |
|
| 161 |
|
| 162 |
static inline void Py_SET_TYPE(PyObject *ob, PyTypeObject *type) { |
| 163 |
ob->ob_type = type; |
| 164 |
} |
| 165 |
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 |
| 166 |
# define Py_SET_TYPE(ob, type) Py_SET_TYPE(_PyObject_CAST(ob), type) |
| 167 |
#endif |
| 168 |
|
| 169 |
|
| 170 |
static inline void Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size) { |
| 171 |
ob->ob_size = size; |
| 172 |
} |
| 173 |
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 |
| 174 |
# define Py_SET_SIZE(ob, size) Py_SET_SIZE(_PyVarObject_CAST(ob), size) |
| 175 |
#endif |
| 176 |
|
| 177 |
#ifndef PYPY_VERSION |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
typedef PyObject * (*unaryfunc)(PyObject *); |
| 196 |
typedef PyObject * (*binaryfunc)(PyObject *, PyObject *); |
| 197 |
typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *); |
| 198 |
typedef int (*inquiry)(PyObject *); |
| 199 |
typedef Py_ssize_t (*lenfunc)(PyObject *); |
| 200 |
typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t); |
| 201 |
typedef PyObject *(*ssizessizeargfunc)(PyObject *, Py_ssize_t, Py_ssize_t); |
| 202 |
typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *); |
| 203 |
typedef int(*ssizessizeobjargproc)(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *); |
| 204 |
typedef int(*objobjargproc)(PyObject *, PyObject *, PyObject *); |
| 205 |
|
| 206 |
typedef int (*objobjproc)(PyObject *, PyObject *); |
| 207 |
typedef int (*visitproc)(PyObject *, void *); |
| 208 |
typedef int (*traverseproc)(PyObject *, visitproc, void *); |
| 209 |
|
| 210 |
|
| 211 |
typedef void (*freefunc)(void *); |
| 212 |
typedef void (*destructor)(PyObject *); |
| 213 |
typedef PyObject *(*getattrfunc)(PyObject *, char *); |
| 214 |
typedef PyObject *(*getattrofunc)(PyObject *, PyObject *); |
| 215 |
typedef int (*setattrfunc)(PyObject *, char *, PyObject *); |
| 216 |
typedef int (*setattrofunc)(PyObject *, PyObject *, PyObject *); |
| 217 |
typedef PyObject *(*reprfunc)(PyObject *); |
| 218 |
typedef Py_hash_t (*hashfunc)(PyObject *); |
| 219 |
typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int); |
| 220 |
typedef PyObject *(*getiterfunc) (PyObject *); |
| 221 |
typedef PyObject *(*iternextfunc) (PyObject *); |
| 222 |
typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *); |
| 223 |
typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *); |
| 224 |
typedef int (*initproc)(PyObject *, PyObject *, PyObject *); |
| 225 |
typedef PyObject *(*newfunc)(PyTypeObject *, PyObject *, PyObject *); |
| 226 |
typedef PyObject *(*allocfunc)(PyTypeObject *, Py_ssize_t); |
| 227 |
|
| 228 |
typedef struct{ |
| 229 |
int slot; |
| 230 |
void *pfunc; |
| 231 |
} PyType_Slot; |
| 232 |
|
| 233 |
typedef struct{ |
| 234 |
const char* name; |
| 235 |
int basicsize; |
| 236 |
int itemsize; |
| 237 |
unsigned int flags; |
| 238 |
PyType_Slot *slots; |
| 239 |
} PyType_Spec; |
| 240 |
#endif |
| 241 |
|
| 242 |
PyAPI_FUNC(PyObject*) PyType_FromSpec(PyType_Spec*); |
| 243 |
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 |
| 244 |
PyAPI_FUNC(PyObject*) PyType_FromSpecWithBases(PyType_Spec*, PyObject*); |
| 245 |
#endif |
| 246 |
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03040000 |
| 247 |
PyAPI_FUNC(void*) PyType_GetSlot(PyTypeObject*, int); |
| 248 |
#endif |
| 249 |
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000 |
| 250 |
PyAPI_FUNC(PyObject*) PyType_FromModuleAndSpec(PyObject *, PyType_Spec *, PyObject *); |
| 251 |
PyAPI_FUNC(PyObject *) PyType_GetModule(PyTypeObject *); |
| 252 |
PyAPI_FUNC(void *) PyType_GetModuleState(PyTypeObject *); |
| 253 |
#endif |
| 254 |
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030B0000 |
| 255 |
PyAPI_FUNC(PyObject *) PyType_GetName(PyTypeObject *); |
| 256 |
PyAPI_FUNC(PyObject *) PyType_GetQualName(PyTypeObject *); |
| 257 |
#endif |
| 258 |
|
| 259 |
|
| 260 |
PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *); |
| 261 |
|
| 262 |
static inline int PyObject_TypeCheck(PyObject *ob, PyTypeObject *type) { |
| 263 |
return Py_IS_TYPE(ob, type) || PyType_IsSubtype(Py_TYPE(ob), type); |
| 264 |
} |
| 265 |
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 |
| 266 |
# define PyObject_TypeCheck(ob, type) PyObject_TypeCheck(_PyObject_CAST(ob), type) |
| 267 |
#endif |
| 268 |
|
| 269 |
PyAPI_DATA(PyTypeObject) PyType_Type; |
| 270 |
PyAPI_DATA(PyTypeObject) PyBaseObject_Type; |
| 271 |
PyAPI_DATA(PyTypeObject) PySuper_Type; |
| 272 |
|
| 273 |
PyAPI_FUNC(unsigned long) PyType_GetFlags(PyTypeObject*); |
| 274 |
|
| 275 |
PyAPI_FUNC(int) PyType_Ready(PyTypeObject *); |
| 276 |
PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t); |
| 277 |
PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *, |
| 278 |
PyObject *, PyObject *); |
| 279 |
PyAPI_FUNC(unsigned int) PyType_ClearCache(void); |
| 280 |
PyAPI_FUNC(void) PyType_Modified(PyTypeObject *); |
| 281 |
|
| 282 |
|
| 283 |
PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *); |
| 284 |
PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *); |
| 285 |
PyAPI_FUNC(PyObject *) PyObject_ASCII(PyObject *); |
| 286 |
PyAPI_FUNC(PyObject *) PyObject_Bytes(PyObject *); |
| 287 |
PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int); |
| 288 |
PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int); |
| 289 |
PyAPI_FUNC(PyObject *) PyObject_GetAttrString(PyObject *, const char *); |
| 290 |
PyAPI_FUNC(int) PyObject_SetAttrString(PyObject *, const char *, PyObject *); |
| 291 |
PyAPI_FUNC(int) PyObject_HasAttrString(PyObject *, const char *); |
| 292 |
PyAPI_FUNC(PyObject *) PyObject_GetAttr(PyObject *, PyObject *); |
| 293 |
PyAPI_FUNC(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *); |
| 294 |
PyAPI_FUNC(int) PyObject_HasAttr(PyObject *, PyObject *); |
| 295 |
PyAPI_FUNC(PyObject *) PyObject_SelfIter(PyObject *); |
| 296 |
PyAPI_FUNC(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *); |
| 297 |
PyAPI_FUNC(int) PyObject_GenericSetAttr(PyObject *, PyObject *, PyObject *); |
| 298 |
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 |
| 299 |
PyAPI_FUNC(int) PyObject_GenericSetDict(PyObject *, PyObject *, void *); |
| 300 |
#endif |
| 301 |
PyAPI_FUNC(Py_hash_t) PyObject_Hash(PyObject *); |
| 302 |
PyAPI_FUNC(Py_hash_t) PyObject_HashNotImplemented(PyObject *); |
| 303 |
PyAPI_FUNC(int) PyObject_IsTrue(PyObject *); |
| 304 |
PyAPI_FUNC(int) PyObject_Not(PyObject *); |
| 305 |
PyAPI_FUNC(int) PyCallable_Check(PyObject *); |
| 306 |
PyAPI_FUNC(void) PyObject_ClearWeakRefs(PyObject *); |
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
PyAPI_FUNC(PyObject *) PyObject_Dir(PyObject *); |
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
PyAPI_FUNC(int) Py_ReprEnter(PyObject *); |
| 318 |
PyAPI_FUNC(void) Py_ReprLeave(PyObject *); |
| 319 |
|
| 320 |
|
| 321 |
#define Py_PRINT_RAW 1 |
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
#ifndef Py_LIMITED_API |
| 344 |
|
| 345 |
|
| 346 |
#define _Py_TPFLAGS_STATIC_BUILTIN (1 << 1) |
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
#define Py_TPFLAGS_INLINE_VALUES (1 << 2) |
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
#define Py_TPFLAGS_MANAGED_WEAKREF (1 << 3) |
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
#define Py_TPFLAGS_MANAGED_DICT (1 << 4) |
| 363 |
|
| 364 |
|
| 365 |
#define Py_TPFLAGS_SEQUENCE (1 << 5) |
| 366 |
|
| 367 |
#define Py_TPFLAGS_MAPPING (1 << 6) |
| 368 |
#endif |
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
#define Py_TPFLAGS_DISALLOW_INSTANTIATION (1UL << 7) |
| 373 |
|
| 374 |
|
| 375 |
#define Py_TPFLAGS_IMMUTABLETYPE (1UL << 8) |
| 376 |
|
| 377 |
|
| 378 |
#define Py_TPFLAGS_HEAPTYPE (1UL << 9) |
| 379 |
|
| 380 |
|
| 381 |
#define Py_TPFLAGS_BASETYPE (1UL << 10) |
| 382 |
|
| 383 |
|
| 384 |
#ifndef Py_LIMITED_API |
| 385 |
#define Py_TPFLAGS_HAVE_VECTORCALL (1UL << 11) |
| 386 |
|
| 387 |
#define _Py_TPFLAGS_HAVE_VECTORCALL Py_TPFLAGS_HAVE_VECTORCALL |
| 388 |
#endif |
| 389 |
|
| 390 |
|
| 391 |
#define Py_TPFLAGS_READY (1UL << 12) |
| 392 |
|
| 393 |
|
| 394 |
#define Py_TPFLAGS_READYING (1UL << 13) |
| 395 |
|
| 396 |
|
| 397 |
#define Py_TPFLAGS_HAVE_GC (1UL << 14) |
| 398 |
|
| 399 |
|
| 400 |
#ifdef STACKLESS |
| 401 |
#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION (3UL << 15) |
| 402 |
#else |
| 403 |
#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION 0 |
| 404 |
#endif |
| 405 |
|
| 406 |
|
| 407 |
#define Py_TPFLAGS_METHOD_DESCRIPTOR (1UL << 17) |
| 408 |
|
| 409 |
|
| 410 |
#define Py_TPFLAGS_VALID_VERSION_TAG (1UL << 19) |
| 411 |
|
| 412 |
|
| 413 |
#define Py_TPFLAGS_IS_ABSTRACT (1UL << 20) |
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
#define _Py_TPFLAGS_MATCH_SELF (1UL << 22) |
| 419 |
|
| 420 |
|
| 421 |
#define Py_TPFLAGS_LONG_SUBCLASS (1UL << 24) |
| 422 |
#define Py_TPFLAGS_LIST_SUBCLASS (1UL << 25) |
| 423 |
#define Py_TPFLAGS_TUPLE_SUBCLASS (1UL << 26) |
| 424 |
#define Py_TPFLAGS_BYTES_SUBCLASS (1UL << 27) |
| 425 |
#define Py_TPFLAGS_UNICODE_SUBCLASS (1UL << 28) |
| 426 |
#define Py_TPFLAGS_DICT_SUBCLASS (1UL << 29) |
| 427 |
#define Py_TPFLAGS_BASE_EXC_SUBCLASS (1UL << 30) |
| 428 |
#define Py_TPFLAGS_TYPE_SUBCLASS (1UL << 31) |
| 429 |
|
| 430 |
#define Py_TPFLAGS_DEFAULT ( \ |
| 431 |
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \ |
| 432 |
0) |
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
#define Py_TPFLAGS_HAVE_FINALIZE (1UL << 0) |
| 448 |
#define Py_TPFLAGS_HAVE_VERSION_TAG (1UL << 18) |
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
#ifdef Py_REF_DEBUG |
| 480 |
PyAPI_DATA(Py_ssize_t) _Py_RefTotal; |
| 481 |
PyAPI_FUNC(void) _Py_NegativeRefcount(const char *filename, int lineno, |
| 482 |
PyObject *op); |
| 483 |
#endif |
| 484 |
|
| 485 |
PyAPI_FUNC(void) _Py_Dealloc(PyObject *); |
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
PyAPI_FUNC(void) Py_IncRef(PyObject *); |
| 492 |
PyAPI_FUNC(void) Py_DecRef(PyObject *); |
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
PyAPI_FUNC(void) _Py_IncRef(PyObject *); |
| 497 |
PyAPI_FUNC(void) _Py_DecRef(PyObject *); |
| 498 |
|
| 499 |
static inline void Py_INCREF(PyObject *op) |
| 500 |
{ |
| 501 |
#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030A0000 |
| 502 |
|
| 503 |
_Py_IncRef(op); |
| 504 |
#else |
| 505 |
|
| 506 |
|
| 507 |
#ifdef Py_REF_DEBUG |
| 508 |
_Py_RefTotal++; |
| 509 |
#endif |
| 510 |
op->ob_refcnt++; |
| 511 |
#endif |
| 512 |
} |
| 513 |
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 |
| 514 |
# define Py_INCREF(op) Py_INCREF(_PyObject_CAST(op)) |
| 515 |
#endif |
| 516 |
|
| 517 |
|
| 518 |
#if defined(Py_REF_DEBUG) && defined(Py_LIMITED_API) && Py_LIMITED_API+0 >= 0x030A0000 |
| 519 |
|
| 520 |
static inline void Py_DECREF(PyObject *op) { |
| 521 |
_Py_DecRef(op); |
| 522 |
} |
| 523 |
#define Py_DECREF(op) Py_DECREF(_PyObject_CAST(op)) |
| 524 |
|
| 525 |
#elif defined(Py_REF_DEBUG) |
| 526 |
static inline void Py_DECREF(const char *filename, int lineno, PyObject *op) |
| 527 |
{ |
| 528 |
_Py_RefTotal--; |
| 529 |
if (--op->ob_refcnt != 0) { |
| 530 |
if (op->ob_refcnt < 0) { |
| 531 |
_Py_NegativeRefcount(filename, lineno, op); |
| 532 |
} |
| 533 |
} |
| 534 |
else { |
| 535 |
_Py_Dealloc(op); |
| 536 |
} |
| 537 |
} |
| 538 |
#define Py_DECREF(op) Py_DECREF(__FILE__, __LINE__, _PyObject_CAST(op)) |
| 539 |
|
| 540 |
#else |
| 541 |
static inline void Py_DECREF(PyObject *op) |
| 542 |
{ |
| 543 |
|
| 544 |
|
| 545 |
if (--op->ob_refcnt == 0) { |
| 546 |
_Py_Dealloc(op); |
| 547 |
} |
| 548 |
} |
| 549 |
#define Py_DECREF(op) Py_DECREF(_PyObject_CAST(op)) |
| 550 |
#endif |
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
#define Py_CLEAR(op) \ |
| 588 |
do { \ |
| 589 |
PyObject *_py_tmp = _PyObject_CAST(op); \ |
| 590 |
if (_py_tmp != NULL) { \ |
| 591 |
(op) = NULL; \ |
| 592 |
Py_DECREF(_py_tmp); \ |
| 593 |
} \ |
| 594 |
} while (0) |
| 595 |
|
| 596 |
|
| 597 |
static inline void Py_XINCREF(PyObject *op) |
| 598 |
{ |
| 599 |
if (op != _Py_NULL) { |
| 600 |
Py_INCREF(op); |
| 601 |
} |
| 602 |
} |
| 603 |
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 |
| 604 |
# define Py_XINCREF(op) Py_XINCREF(_PyObject_CAST(op)) |
| 605 |
#endif |
| 606 |
|
| 607 |
static inline void Py_XDECREF(PyObject *op) |
| 608 |
{ |
| 609 |
if (op != _Py_NULL) { |
| 610 |
Py_DECREF(op); |
| 611 |
} |
| 612 |
} |
| 613 |
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 |
| 614 |
# define Py_XDECREF(op) Py_XDECREF(_PyObject_CAST(op)) |
| 615 |
#endif |
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
PyAPI_FUNC(PyObject*) Py_NewRef(PyObject *obj); |
| 620 |
|
| 621 |
|
| 622 |
PyAPI_FUNC(PyObject*) Py_XNewRef(PyObject *obj); |
| 623 |
|
| 624 |
static inline PyObject* _Py_NewRef(PyObject *obj) |
| 625 |
{ |
| 626 |
Py_INCREF(obj); |
| 627 |
return obj; |
| 628 |
} |
| 629 |
|
| 630 |
static inline PyObject* _Py_XNewRef(PyObject *obj) |
| 631 |
{ |
| 632 |
Py_XINCREF(obj); |
| 633 |
return obj; |
| 634 |
} |
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 |
| 640 |
# define Py_NewRef(obj) _Py_NewRef(_PyObject_CAST(obj)) |
| 641 |
# define Py_XNewRef(obj) _Py_XNewRef(_PyObject_CAST(obj)) |
| 642 |
#else |
| 643 |
# define Py_NewRef(obj) _Py_NewRef(obj) |
| 644 |
# define Py_XNewRef(obj) _Py_XNewRef(obj) |
| 645 |
#endif |
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
PyAPI_DATA(PyObject) _Py_NoneStruct; |
| 655 |
#define Py_None (&_Py_NoneStruct) |
| 656 |
|
| 657 |
|
| 658 |
PyAPI_FUNC(int) Py_IsNone(PyObject *x); |
| 659 |
#define Py_IsNone(x) ((x) == Py_None) |
| 660 |
|
| 661 |
|
| 662 |
#define Py_RETURN_NONE return Py_NewRef(Py_None) |
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
PyAPI_DATA(PyObject) _Py_NotImplementedStruct; |
| 669 |
#define Py_NotImplemented (&_Py_NotImplementedStruct) |
| 670 |
|
| 671 |
|
| 672 |
#define Py_RETURN_NOTIMPLEMENTED return Py_NewRef(Py_NotImplemented) |
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
#define Py_LT 0 |
| 679 |
#define Py_LE 1 |
| 680 |
#define Py_EQ 2 |
| 681 |
#define Py_NE 3 |
| 682 |
#define Py_GT 4 |
| 683 |
#define Py_GE 5 |
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
|
| 691 |
#define Py_RETURN_RICHCOMPARE(val1, val2, op) \ |
| 692 |
do { \ |
| 693 |
switch (op) { \ |
| 694 |
case Py_EQ: if ((val1) == (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \ |
| 695 |
case Py_NE: if ((val1) != (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \ |
| 696 |
case Py_LT: if ((val1) < (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \ |
| 697 |
case Py_GT: if ((val1) > (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \ |
| 698 |
case Py_LE: if ((val1) <= (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \ |
| 699 |
case Py_GE: if ((val1) >= (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \ |
| 700 |
default: \ |
| 701 |
Py_UNREACHABLE(); \ |
| 702 |
} \ |
| 703 |
} while (0) |
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
|
| 742 |
|
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
#define PyBUF_SIMPLE 0 |
| 763 |
#define PyBUF_WRITABLE 0x0001 |
| 764 |
|
| 765 |
#define PyBUF_WRITEABLE PyBUF_WRITABLE |
| 766 |
#define PyBUF_FORMAT 0x0004 |
| 767 |
#define PyBUF_ND 0x0008 |
| 768 |
#define PyBUF_STRIDES (0x0010 | PyBUF_ND) |
| 769 |
#define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) |
| 770 |
#define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) |
| 771 |
#define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) |
| 772 |
#define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) |
| 773 |
|
| 774 |
#define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE) |
| 775 |
#define PyBUF_CONTIG_RO (PyBUF_ND) |
| 776 |
|
| 777 |
#define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE) |
| 778 |
#define PyBUF_STRIDED_RO (PyBUF_STRIDES) |
| 779 |
|
| 780 |
#define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT) |
| 781 |
#define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT) |
| 782 |
|
| 783 |
#define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT) |
| 784 |
#define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT) |
| 785 |
|
| 786 |
|
| 787 |
#define PyBUF_READ 0x100 |
| 788 |
#define PyBUF_WRITE 0x200 |
| 789 |
#define PyBUF_SHADOW 0x400 |
| 790 |
|
| 791 |
|
| 792 |
PyAPI_FUNC(const char *) _PyType_Name(PyTypeObject *); |
| 793 |
|
| 794 |
struct PyModuleDef; |
| 795 |
PyAPI_FUNC(PyObject *) PyType_GetModuleByDef(PyTypeObject *, struct PyModuleDef *); |
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
#define Py_SETREF(op, op2) \ |
| 817 |
do { \ |
| 818 |
PyObject *_py_tmp = _PyObject_CAST(op); \ |
| 819 |
(op) = (op2); \ |
| 820 |
Py_DECREF(_py_tmp); \ |
| 821 |
} while (0) |
| 822 |
|
| 823 |
|
| 824 |
PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *); |
| 825 |
|
| 826 |
#define Py_XSETREF(op, op2) \ |
| 827 |
do { \ |
| 828 |
PyObject *_py_tmp = _PyObject_CAST(op); \ |
| 829 |
(op) = (op2); \ |
| 830 |
Py_XDECREF(_py_tmp); \ |
| 831 |
} while (0) |
| 832 |
|
| 833 |
#define Py_TRASHCAN_BEGIN(op, cond) do { |
| 834 |
#define Py_TRASHCAN_END ; } while(0); |
| 835 |
|
| 836 |
Py_DEPRECATED(3.11) typedef int UsingDeprecatedTrashcanMacro; |
| 837 |
#define Py_TRASHCAN_SAFE_BEGIN(pyObj) do { |
| 838 |
#define Py_TRASHCAN_SAFE_END(pyObj) ; } while(0); |
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *, const void **, Py_ssize_t *); |
| 844 |
PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *, void **, Py_ssize_t *); |
| 845 |
PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *); |
| 846 |
PyAPI_FUNC(void *) PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices); |
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
PyAPI_FUNC(int) PyBuffer_ToContiguous(void *buf, Py_buffer *view, |
| 852 |
Py_ssize_t len, char fort); |
| 853 |
PyAPI_FUNC(int) PyBuffer_FromContiguous(Py_buffer *view, void *buf, |
| 854 |
Py_ssize_t len, char fort); |
| 855 |
|
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
|
| 867 |
|
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
|
| 872 |
PyAPI_FUNC(int) PyObject_CallFinalizerFromDealloc(PyObject *); |
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
#define _Py_INC_REFTOTAL |
| 881 |
#define _Py_DEC_REFTOTAL |
| 882 |
#define _Py_REF_DEBUG_COMMA |
| 883 |
#define _Py_CHECK_REFCNT(OP) ; |
| 884 |
|
| 885 |
PyAPI_FUNC(void) _Py_NewReference(PyObject *op); |
| 886 |
|
| 887 |
#ifdef Py_TRACE_REFS |
| 888 |
|
| 889 |
PyAPI_FUNC(void) _Py_ForgetReference(PyObject *); |
| 890 |
#endif |
| 891 |
|
| 892 |
#ifdef Py_REF_DEBUG |
| 893 |
PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void); |
| 894 |
#endif |
| 895 |
|
| 896 |
|
| 897 |
|
| 898 |
static inline int |
| 899 |
PyType_HasFeature(PyTypeObject *type, unsigned long feature) |
| 900 |
{ |
| 901 |
unsigned long flags; |
| 902 |
#ifdef Py_LIMITED_API |
| 903 |
|
| 904 |
flags = PyType_GetFlags(type); |
| 905 |
#else |
| 906 |
flags = type->tp_flags; |
| 907 |
#endif |
| 908 |
return ((flags & feature) != 0); |
| 909 |
} |
| 910 |
|
| 911 |
#define PyType_FastSubclass(type, flag) PyType_HasFeature(type, flag) |
| 912 |
|
| 913 |
static inline int _PyType_Check(PyObject *op) { |
| 914 |
return PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS); |
| 915 |
} |
| 916 |
#define PyType_Check(op) _PyType_Check(_PyObject_CAST(op)) |
| 917 |
|
| 918 |
static inline int _PyType_CheckExact(PyObject *op) { |
| 919 |
return Py_IS_TYPE(op, &PyType_Type); |
| 920 |
} |
| 921 |
#define PyType_CheckExact(op) _PyType_CheckExact(_PyObject_CAST(op)) |
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
PyAPI_FUNC(int) PyPyType_Register(PyTypeObject *); |
| 926 |
#define _PyObject_GC_Del PyObject_GC_Del |
| 927 |
PyAPI_FUNC(void) _PyPy_subtype_dealloc(PyObject *); |
| 928 |
PyAPI_FUNC(void) _PyPy_object_dealloc(PyObject *); |
| 929 |
|
| 930 |
|
| 931 |
#ifdef __cplusplus |
| 932 |
} |
| 933 |
#endif |
| 934 |
#endif |