55 #if defined(Py_DEBUG) && !defined(Py_TRACE_REFS)
60 #if defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG)
66 #define _PyObject_HEAD_EXTRA \
67 struct _object *_ob_next; \
68 struct _object *_ob_prev;
70 #define _PyObject_EXTRA_INIT 0, 0,
73 #define _PyObject_HEAD_EXTRA
74 #define _PyObject_EXTRA_INIT
78 #define PyObject_HEAD \
79 _PyObject_HEAD_EXTRA \
80 Py_ssize_t ob_refcnt; \
81 struct _typeobject *ob_type;
83 #define PyObject_HEAD_INIT(type) \
84 _PyObject_EXTRA_INIT \
87 #define PyVarObject_HEAD_INIT(type, size) \
88 PyObject_HEAD_INIT(type) size,
96 #define PyObject_VAR_HEAD \
99 #define Py_INVALID_SIZE (Py_ssize_t)-1
114 #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
115 #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
116 #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
135 typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *);
185 #define PyBUF_SIMPLE 0
186 #define PyBUF_WRITABLE 0x0001
188 #define PyBUF_WRITEABLE PyBUF_WRITABLE
189 #define PyBUF_FORMAT 0x0004
190 #define PyBUF_ND 0x0008
191 #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
192 #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
193 #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
194 #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
195 #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
197 #define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE)
198 #define PyBUF_CONTIG_RO (PyBUF_ND)
200 #define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE)
201 #define PyBUF_STRIDED_RO (PyBUF_STRIDES)
203 #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT)
204 #define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT)
206 #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT)
207 #define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT)
210 #define PyBUF_READ 0x100
211 #define PyBUF_WRITE 0x200
212 #define PyBUF_SHADOW 0x400
308 typedef PyObject *(*getattrfunc)(PyObject *,
char *);
309 typedef PyObject *(*getattrofunc)(PyObject *, PyObject *);
313 typedef PyObject *(*reprfunc)(PyObject *);
315 typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *,
int);
316 typedef PyObject *(*getiterfunc) (PyObject *);
317 typedef PyObject *(*iternextfunc) (PyObject *);
318 typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *);
321 typedef PyObject *(*newfunc)(
struct _typeobject *, PyObject *, PyObject *);
405 Py_ssize_t tp_allocs;
407 Py_ssize_t tp_maxalloc;
432 #define PyHeapType_GET_MEMBERS(etype) \
433 ((PyMemberDef *)(((char *)etype) + Py_TYPE(etype)->tp_basicsize))
438 #define PyObject_TypeCheck(ob, tp) \
439 (Py_TYPE(ob) == (tp) || PyType_IsSubtype(Py_TYPE(ob), (tp)))
445 #define PyType_Check(op) \
446 PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS)
447 #define PyType_CheckExact(op) (Py_TYPE(op) == &PyType_Type)
450 PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t);
451 PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *,
452 PyObject *, PyObject *);
453 PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *);
454 PyAPI_FUNC(PyObject *) _PyObject_LookupSpecial(PyObject *,
char *, PyObject **);
455 PyAPI_FUNC(
unsigned int) PyType_ClearCache(
void);
456 PyAPI_FUNC(
void) PyType_Modified(PyTypeObject *);
461 PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *);
462 PyAPI_FUNC(PyObject *) _PyObject_Str(PyObject *);
463 PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *);
464 #define PyObject_Bytes PyObject_Str
465 #ifdef Py_USING_UNICODE
466 PyAPI_FUNC(PyObject *) PyObject_Unicode(PyObject *);
468 PyAPI_FUNC(
int) PyObject_Compare(PyObject *, PyObject *);
469 PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *,
int);
470 PyAPI_FUNC(
int) PyObject_RichCompareBool(PyObject *, PyObject *,
int);
471 PyAPI_FUNC(PyObject *) PyObject_GetAttrString(PyObject *, const
char *);
472 PyAPI_FUNC(
int) PyObject_SetAttrString(PyObject *, const
char *, PyObject *);
473 PyAPI_FUNC(
int) PyObject_HasAttrString(PyObject *, const
char *);
474 PyAPI_FUNC(PyObject *) PyObject_GetAttr(PyObject *, PyObject *);
475 PyAPI_FUNC(
int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *);
476 PyAPI_FUNC(
int) PyObject_HasAttr(PyObject *, PyObject *);
477 PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *);
478 PyAPI_FUNC(PyObject *) PyObject_SelfIter(PyObject *);
479 PyAPI_FUNC(PyObject *) _PyObject_NextNotImplemented(PyObject *);
480 PyAPI_FUNC(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *);
481 PyAPI_FUNC(
int) PyObject_GenericSetAttr(PyObject *,
482 PyObject *, PyObject *);
484 PyAPI_FUNC(
long) PyObject_HashNotImplemented(PyObject *);
488 PyAPI_FUNC(
int) PyNumber_Coerce(PyObject **, PyObject **);
489 PyAPI_FUNC(
int) PyNumber_CoerceEx(PyObject **, PyObject **);
491 PyAPI_FUNC(
void) PyObject_ClearWeakRefs(PyObject *);
498 _PyObject_GenericGetAttrWithDict(PyObject *, PyObject *, PyObject *);
500 _PyObject_GenericSetAttrWithDict(PyObject *, PyObject *,
501 PyObject *, PyObject *);
509 PyAPI_FUNC(PyObject *) PyObject_Dir(PyObject *);
531 #define PyObject_REPR(obj) PyString_AS_STRING(PyObject_Repr(obj))
534 #define Py_PRINT_RAW 1
564 #define Py_TPFLAGS_HAVE_GETCHARBUFFER (1L<<0)
567 #define Py_TPFLAGS_HAVE_SEQUENCE_IN (1L<<1)
571 #define Py_TPFLAGS_GC 0
574 #define Py_TPFLAGS_HAVE_INPLACEOPS (1L<<3)
577 #define Py_TPFLAGS_CHECKTYPES (1L<<4)
580 #define Py_TPFLAGS_HAVE_RICHCOMPARE (1L<<5)
583 #define Py_TPFLAGS_HAVE_WEAKREFS (1L<<6)
586 #define Py_TPFLAGS_HAVE_ITER (1L<<7)
589 #define Py_TPFLAGS_HAVE_CLASS (1L<<8)
592 #define Py_TPFLAGS_HEAPTYPE (1L<<9)
595 #define Py_TPFLAGS_BASETYPE (1L<<10)
598 #define Py_TPFLAGS_READY (1L<<12)
601 #define Py_TPFLAGS_READYING (1L<<13)
604 #define Py_TPFLAGS_HAVE_GC (1L<<14)
608 #define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION (3L<<15)
610 #define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION 0
614 #define Py_TPFLAGS_HAVE_INDEX (1L<<17)
617 #define Py_TPFLAGS_HAVE_VERSION_TAG (1L<<18)
618 #define Py_TPFLAGS_VALID_VERSION_TAG (1L<<19)
621 #define Py_TPFLAGS_IS_ABSTRACT (1L<<20)
624 #define Py_TPFLAGS_HAVE_NEWBUFFER (1L<<21)
627 #define Py_TPFLAGS_INT_SUBCLASS (1L<<23)
628 #define Py_TPFLAGS_LONG_SUBCLASS (1L<<24)
629 #define Py_TPFLAGS_LIST_SUBCLASS (1L<<25)
630 #define Py_TPFLAGS_TUPLE_SUBCLASS (1L<<26)
631 #define Py_TPFLAGS_STRING_SUBCLASS (1L<<27)
632 #define Py_TPFLAGS_UNICODE_SUBCLASS (1L<<28)
633 #define Py_TPFLAGS_DICT_SUBCLASS (1L<<29)
634 #define Py_TPFLAGS_BASE_EXC_SUBCLASS (1L<<30)
635 #define Py_TPFLAGS_TYPE_SUBCLASS (1L<<31)
637 #define Py_TPFLAGS_DEFAULT_EXTERNAL ( \
638 Py_TPFLAGS_HAVE_GETCHARBUFFER | \
639 Py_TPFLAGS_HAVE_SEQUENCE_IN | \
640 Py_TPFLAGS_HAVE_INPLACEOPS | \
641 Py_TPFLAGS_HAVE_RICHCOMPARE | \
642 Py_TPFLAGS_HAVE_WEAKREFS | \
643 Py_TPFLAGS_HAVE_ITER | \
644 Py_TPFLAGS_HAVE_CLASS | \
645 Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \
646 Py_TPFLAGS_HAVE_INDEX | \
648 #define Py_TPFLAGS_DEFAULT_CORE (Py_TPFLAGS_DEFAULT_EXTERNAL | \
649 Py_TPFLAGS_HAVE_VERSION_TAG)
652 #define Py_TPFLAGS_DEFAULT Py_TPFLAGS_DEFAULT_CORE
654 #define Py_TPFLAGS_DEFAULT Py_TPFLAGS_DEFAULT_EXTERNAL
657 #define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0)
658 #define PyType_FastSubclass(t,f) PyType_HasFeature(t,f)
706 PyAPI_FUNC(
void) _Py_NegativeRefcount(const
char *fname,
707 int lineno, PyObject *op);
711 #define _Py_INC_REFTOTAL _Py_RefTotal++
712 #define _Py_DEC_REFTOTAL _Py_RefTotal--
713 #define _Py_REF_DEBUG_COMMA ,
714 #define _Py_CHECK_REFCNT(OP) \
715 { if (((PyObject*)OP)->ob_refcnt < 0) \
716 _Py_NegativeRefcount(__FILE__, __LINE__, \
720 #define _Py_INC_REFTOTAL
721 #define _Py_DEC_REFTOTAL
722 #define _Py_REF_DEBUG_COMMA
723 #define _Py_CHECK_REFCNT(OP) ;
729 #define _Py_INC_TPALLOCS(OP) inc_count(Py_TYPE(OP))
730 #define _Py_INC_TPFREES(OP) dec_count(Py_TYPE(OP))
731 #define _Py_DEC_TPFREES(OP) Py_TYPE(OP)->tp_frees--
732 #define _Py_COUNT_ALLOCS_COMMA ,
734 #define _Py_INC_TPALLOCS(OP)
735 #define _Py_INC_TPFREES(OP)
736 #define _Py_DEC_TPFREES(OP)
737 #define _Py_COUNT_ALLOCS_COMMA
746 PyAPI_FUNC(
void) _Py_PrintReferenceAddresses(FILE *);
747 PyAPI_FUNC(
void) _Py_AddToAllObjects(PyObject *,
int force);
753 #define _Py_NewReference(op) ( \
754 _Py_INC_TPALLOCS(op) _Py_COUNT_ALLOCS_COMMA \
755 _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \
758 #define _Py_ForgetReference(op) _Py_INC_TPFREES(op)
760 #define _Py_Dealloc(op) ( \
761 _Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA \
762 (*Py_TYPE(op)->tp_dealloc)((PyObject *)(op)))
765 #define Py_INCREF(op) ( \
766 _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \
767 ((PyObject*)(op))->ob_refcnt++)
769 #define Py_DECREF(op) \
771 if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \
772 --((PyObject*)(op))->ob_refcnt != 0) \
773 _Py_CHECK_REFCNT(op) \
775 _Py_Dealloc((PyObject *)(op)); \
812 #define Py_CLEAR(op) \
815 PyObject *_py_tmp = (PyObject *)(op); \
817 Py_DECREF(_py_tmp); \
822 #define Py_XINCREF(op) do { if ((op) == NULL) ; else Py_INCREF(op); } while (0)
823 #define Py_XDECREF(op) do { if ((op) == NULL) ; else Py_DECREF(op); } while (0)
839 #define Py_None (&_Py_NoneStruct)
842 #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
848 PyAPI_DATA(PyObject) _Py_NotImplementedStruct;
849 #define Py_NotImplemented (&_Py_NotImplementedStruct)
876 #define staticforward static
877 #define statichere static
976 PyAPI_FUNC(
void) _PyTrash_deposit_object(PyObject*);
977 PyAPI_FUNC(
void) _PyTrash_destroy_chain(
void);
982 PyAPI_FUNC(
void) _PyTrash_thread_deposit_object(PyObject*);
983 PyAPI_FUNC(
void) _PyTrash_thread_destroy_chain(
void);
985 #define PyTrash_UNWIND_LEVEL 50
988 #define Py_TRASHCAN_SAFE_BEGIN(op) \
990 PyThreadState *_tstate = PyThreadState_GET(); \
992 _tstate->trash_delete_nesting < PyTrash_UNWIND_LEVEL) { \
994 ++_tstate->trash_delete_nesting;
996 #define Py_TRASHCAN_SAFE_END(op) \
998 --_tstate->trash_delete_nesting; \
999 if (_tstate->trash_delete_later \
1000 && _tstate->trash_delete_nesting <= 0) \
1001 _PyTrash_thread_destroy_chain(); \
1005 _PyTrash_thread_deposit_object((PyObject*)op); \