home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 April / PCWorld_2001-04_cd.bin / Software / TemaCD / webclean / !!!python!!! / BeOpen-Python-2.0.exe / OBJECT.H < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-17  |  19.2 KB  |  570 lines

  1. #ifndef Py_OBJECT_H
  2. #define Py_OBJECT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7.  
  8. /* Object and type object interface */
  9.  
  10. /*
  11. Objects are structures allocated on the heap.  Special rules apply to
  12. the use of objects to ensure they are properly garbage-collected.
  13. Objects are never allocated statically or on the stack; they must be
  14. accessed through special macros and functions only.  (Type objects are
  15. exceptions to the first rule; the standard types are represented by
  16. statically initialized type objects.)
  17.  
  18. An object has a 'reference count' that is increased or decreased when a
  19. pointer to the object is copied or deleted; when the reference count
  20. reaches zero there are no references to the object left and it can be
  21. removed from the heap.
  22.  
  23. An object has a 'type' that determines what it represents and what kind
  24. of data it contains.  An object's type is fixed when it is created.
  25. Types themselves are represented as objects; an object contains a
  26. pointer to the corresponding type object.  The type itself has a type
  27. pointer pointing to the object representing the type 'type', which
  28. contains a pointer to itself!).
  29.  
  30. Objects do not float around in memory; once allocated an object keeps
  31. the same size and address.  Objects that must hold variable-size data
  32. can contain pointers to variable-size parts of the object.  Not all
  33. objects of the same type have the same size; but the size cannot change
  34. after allocation.  (These restrictions are made so a reference to an
  35. object can be simply a pointer -- moving an object would require
  36. updating all the pointers, and changing an object's size would require
  37. moving it if there was another object right next to it.)
  38.  
  39. Objects are always accessed through pointers of the type 'PyObject *'.
  40. The type 'PyObject' is a structure that only contains the reference count
  41. and the type pointer.  The actual memory allocated for an object
  42. contains other data that can only be accessed after casting the pointer
  43. to a pointer to a longer structure type.  This longer type must start
  44. with the reference count and type fields; the macro PyObject_HEAD should be
  45. used for this (to accommodate for future changes).  The implementation
  46. of a particular object type can cast the object pointer to the proper
  47. type and back.
  48.  
  49. A standard interface exists for objects that contain an array of items
  50. whose size is determined when the object is allocated.
  51. */
  52.  
  53. #ifdef Py_DEBUG
  54.  
  55. /* Turn on heavy reference debugging */
  56. #define Py_TRACE_REFS
  57.  
  58. /* Turn on reference counting */
  59. #define Py_REF_DEBUG
  60.  
  61. #endif /* Py_DEBUG */
  62.  
  63. #ifdef Py_TRACE_REFS
  64. #define PyObject_HEAD \
  65.     struct _object *_ob_next, *_ob_prev; \
  66.     int ob_refcnt; \
  67.     struct _typeobject *ob_type;
  68. #define PyObject_HEAD_INIT(type) 0, 0, 1, type,
  69. #else /* !Py_TRACE_REFS */
  70. #define PyObject_HEAD \
  71.     int ob_refcnt; \
  72.     struct _typeobject *ob_type;
  73. #define PyObject_HEAD_INIT(type) 1, type,
  74. #endif /* !Py_TRACE_REFS */
  75.  
  76. #define PyObject_VAR_HEAD \
  77.     PyObject_HEAD \
  78.     int ob_size; /* Number of items in variable part */
  79.  
  80. typedef struct _object {
  81.     PyObject_HEAD
  82. } PyObject;
  83.  
  84. typedef struct {
  85.     PyObject_VAR_HEAD
  86. } PyVarObject;
  87.  
  88.  
  89. /*
  90. Type objects contain a string containing the type name (to help somewhat
  91. in debugging), the allocation parameters (see newobj() and newvarobj()),
  92. and methods for accessing objects of the type.  Methods are optional,a
  93. nil pointer meaning that particular kind of access is not available for
  94. this type.  The Py_DECREF() macro uses the tp_dealloc method without
  95. checking for a nil pointer; it should always be implemented except if
  96. the implementation can guarantee that the reference count will never
  97. reach zero (e.g., for type objects).
  98.  
  99. NB: the methods for certain type groups are now contained in separate
  100. method blocks.
  101. */
  102.  
  103. typedef PyObject * (*unaryfunc)(PyObject *);
  104. typedef PyObject * (*binaryfunc)(PyObject *, PyObject *);
  105. typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *);
  106. typedef int (*inquiry)(PyObject *);
  107. typedef int (*coercion)(PyObject **, PyObject **);
  108. typedef PyObject *(*intargfunc)(PyObject *, int);
  109. typedef PyObject *(*intintargfunc)(PyObject *, int, int);
  110. typedef int(*intobjargproc)(PyObject *, int, PyObject *);
  111. typedef int(*intintobjargproc)(PyObject *, int, int, PyObject *);
  112. typedef int(*objobjargproc)(PyObject *, PyObject *, PyObject *);
  113. typedef int (*getreadbufferproc)(PyObject *, int, void **);
  114. typedef int (*getwritebufferproc)(PyObject *, int, void **);
  115. typedef int (*getsegcountproc)(PyObject *, int *);
  116. typedef int (*getcharbufferproc)(PyObject *, int, const char **);
  117. typedef int (*objobjproc)(PyObject *, PyObject *);
  118. typedef int (*visitproc)(PyObject *, void *);
  119. typedef int (*traverseproc)(PyObject *, visitproc, void *);
  120.  
  121. typedef struct {
  122.     binaryfunc nb_add;
  123.     binaryfunc nb_subtract;
  124.     binaryfunc nb_multiply;
  125.     binaryfunc nb_divide;
  126.     binaryfunc nb_remainder;
  127.     binaryfunc nb_divmod;
  128.     ternaryfunc nb_power;
  129.     unaryfunc nb_negative;
  130.     unaryfunc nb_positive;
  131.     unaryfunc nb_absolute;
  132.     inquiry nb_nonzero;
  133.     unaryfunc nb_invert;
  134.     binaryfunc nb_lshift;
  135.     binaryfunc nb_rshift;
  136.     binaryfunc nb_and;
  137.     binaryfunc nb_xor;
  138.     binaryfunc nb_or;
  139.     coercion nb_coerce;
  140.     unaryfunc nb_int;
  141.     unaryfunc nb_long;
  142.     unaryfunc nb_float;
  143.     unaryfunc nb_oct;
  144.     unaryfunc nb_hex;
  145.     binaryfunc nb_inplace_add;
  146.     binaryfunc nb_inplace_subtract;
  147.     binaryfunc nb_inplace_multiply;
  148.     binaryfunc nb_inplace_divide;
  149.     binaryfunc nb_inplace_remainder;
  150.     ternaryfunc nb_inplace_power;
  151.     binaryfunc nb_inplace_lshift;
  152.     binaryfunc nb_inplace_rshift;
  153.     binaryfunc nb_inplace_and;
  154.     binaryfunc nb_inplace_xor;
  155.     binaryfunc nb_inplace_or;
  156. } PyNumberMethods;
  157.  
  158. typedef struct {
  159.     inquiry sq_length;
  160.     binaryfunc sq_concat;
  161.     intargfunc sq_repeat;
  162.     intargfunc sq_item;
  163.     intintargfunc sq_slice;
  164.     intobjargproc sq_ass_item;
  165.     intintobjargproc sq_ass_slice;
  166.     objobjproc sq_contains;
  167.     binaryfunc sq_inplace_concat;
  168.     intargfunc sq_inplace_repeat;
  169. } PySequenceMethods;
  170.  
  171. typedef struct {
  172.     inquiry mp_length;
  173.     binaryfunc mp_subscript;
  174.     objobjargproc mp_ass_subscript;
  175. } PyMappingMethods;
  176.  
  177. typedef struct {
  178.     getreadbufferproc bf_getreadbuffer;
  179.     getwritebufferproc bf_getwritebuffer;
  180.     getsegcountproc bf_getsegcount;
  181.     getcharbufferproc bf_getcharbuffer;
  182. } PyBufferProcs;
  183.     
  184.  
  185. typedef void (*destructor)(PyObject *);
  186. typedef int (*printfunc)(PyObject *, FILE *, int);
  187. typedef PyObject *(*getattrfunc)(PyObject *, char *);
  188. typedef PyObject *(*getattrofunc)(PyObject *, PyObject *);
  189. typedef int (*setattrfunc)(PyObject *, char *, PyObject *);
  190. typedef int (*setattrofunc)(PyObject *, PyObject *, PyObject *);
  191. typedef int (*cmpfunc)(PyObject *, PyObject *);
  192. typedef PyObject *(*reprfunc)(PyObject *);
  193. typedef long (*hashfunc)(PyObject *);
  194.  
  195. typedef struct _typeobject {
  196.     PyObject_VAR_HEAD
  197.     char *tp_name; /* For printing */
  198.     int tp_basicsize, tp_itemsize; /* For allocation */
  199.     
  200.     /* Methods to implement standard operations */
  201.     
  202.     destructor tp_dealloc;
  203.     printfunc tp_print;
  204.     getattrfunc tp_getattr;
  205.     setattrfunc tp_setattr;
  206.     cmpfunc tp_compare;
  207.     reprfunc tp_repr;
  208.     
  209.     /* Method suites for standard classes */
  210.     
  211.     PyNumberMethods *tp_as_number;
  212.     PySequenceMethods *tp_as_sequence;
  213.     PyMappingMethods *tp_as_mapping;
  214.  
  215.     /* More standard operations (here for binary compatibility) */
  216.  
  217.     hashfunc tp_hash;
  218.     ternaryfunc tp_call;
  219.     reprfunc tp_str;
  220.     getattrofunc tp_getattro;
  221.     setattrofunc tp_setattro;
  222.  
  223.     /* Functions to access object as input/output buffer */
  224.     PyBufferProcs *tp_as_buffer;
  225.     
  226.     /* Flags to define presence of optional/expanded features */
  227.     long tp_flags;
  228.  
  229.     char *tp_doc; /* Documentation string */
  230.  
  231.     /* call function for all accessible objects */
  232.     traverseproc tp_traverse;
  233.     
  234.     /* delete references to contained objects */
  235.     inquiry tp_clear;
  236.  
  237.     /* More spares */
  238.     long tp_xxx7;
  239.     long tp_xxx8;
  240.  
  241. #ifdef COUNT_ALLOCS
  242.     /* these must be last */
  243.     int tp_alloc;
  244.     int tp_free;
  245.     int tp_maxalloc;
  246.     struct _typeobject *tp_next;
  247. #endif
  248. } PyTypeObject;
  249.  
  250. extern DL_IMPORT(PyTypeObject) PyType_Type; /* The type of type objects */
  251.  
  252. #define PyType_Check(op) ((op)->ob_type == &PyType_Type)
  253.  
  254. /* Generic operations on objects */
  255. extern DL_IMPORT(int) PyObject_Print(PyObject *, FILE *, int);
  256. extern DL_IMPORT(PyObject *) PyObject_Repr(PyObject *);
  257. extern DL_IMPORT(PyObject *) PyObject_Str(PyObject *);
  258. extern DL_IMPORT(int) PyObject_Compare(PyObject *, PyObject *);
  259. extern DL_IMPORT(PyObject *) PyObject_GetAttrString(PyObject *, char *);
  260. extern DL_IMPORT(int) PyObject_SetAttrString(PyObject *, char *, PyObject *);
  261. extern DL_IMPORT(int) PyObject_HasAttrString(PyObject *, char *);
  262. extern DL_IMPORT(PyObject *) PyObject_GetAttr(PyObject *, PyObject *);
  263. extern DL_IMPORT(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *);
  264. extern DL_IMPORT(int) PyObject_HasAttr(PyObject *, PyObject *);
  265. extern DL_IMPORT(long) PyObject_Hash(PyObject *);
  266. extern DL_IMPORT(int) PyObject_IsTrue(PyObject *);
  267. extern DL_IMPORT(int) PyObject_Not(PyObject *);
  268. extern DL_IMPORT(int) PyCallable_Check(PyObject *);
  269. extern DL_IMPORT(int) PyNumber_Coerce(PyObject **, PyObject **);
  270. extern DL_IMPORT(int) PyNumber_CoerceEx(PyObject **, PyObject **);
  271.  
  272. /* Helpers for printing recursive container types */
  273. extern DL_IMPORT(int) Py_ReprEnter(PyObject *);
  274. extern DL_IMPORT(void) Py_ReprLeave(PyObject *);
  275.  
  276. /* tstate dict key for PyObject_Compare helper */
  277. extern PyObject *_PyCompareState_Key;
  278.  
  279. /* Helpers for hash functions */
  280. extern DL_IMPORT(long) _Py_HashDouble(double);
  281. extern DL_IMPORT(long) _Py_HashPointer(void*);
  282.  
  283. /* Flag bits for printing: */
  284. #define Py_PRINT_RAW    1    /* No string quotes etc. */
  285.  
  286. /*
  287.  
  288. Type flags (tp_flags)
  289.  
  290. These flags are used to extend the type structure in a backwards-compatible
  291. fashion. Extensions can use the flags to indicate (and test) when a given
  292. type structure contains a new feature. The Python core will use these when
  293. introducing new functionality between major revisions (to avoid mid-version
  294. changes in the PYTHON_API_VERSION).
  295.  
  296. Arbitration of the flag bit positions will need to be coordinated among
  297. all extension writers who publically release their extensions (this will
  298. be fewer than you might expect!)..
  299.  
  300. Python 1.5.2 introduced the bf_getcharbuffer slot into PyBufferProcs.
  301.  
  302. Type definitions should use Py_TPFLAGS_DEFAULT for their tp_flags value.
  303.  
  304. Code can use PyType_HasFeature(type_ob, flag_value) to test whether the
  305. given type object has a specified feature.
  306.  
  307. */
  308.  
  309. /* PyBufferProcs contains bf_getcharbuffer */
  310. #define Py_TPFLAGS_HAVE_GETCHARBUFFER  (1L<<0)
  311.  
  312. /* PySequenceMethods contains sq_contains */
  313. #define Py_TPFLAGS_HAVE_SEQUENCE_IN (1L<<1)
  314.  
  315. /* Objects which participate in garbage collection (see objimp.h) */
  316. #ifdef WITH_CYCLE_GC
  317. #define Py_TPFLAGS_GC (1L<<2)
  318. #else
  319. #define Py_TPFLAGS_GC 0
  320. #endif
  321.  
  322. /* PySequenceMethods and PyNumberMethods contain in-place operators */
  323. #define Py_TPFLAGS_HAVE_INPLACEOPS (1L<<3)
  324.  
  325. #define Py_TPFLAGS_DEFAULT  (Py_TPFLAGS_HAVE_GETCHARBUFFER | \
  326.                              Py_TPFLAGS_HAVE_SEQUENCE_IN | \
  327.                              Py_TPFLAGS_HAVE_INPLACEOPS)
  328.  
  329. #define PyType_HasFeature(t,f)  (((t)->tp_flags & (f)) != 0)
  330.  
  331.  
  332. /*
  333. The macros Py_INCREF(op) and Py_DECREF(op) are used to increment or decrement
  334. reference counts.  Py_DECREF calls the object's deallocator function; for
  335. objects that don't contain references to other objects or heap memory
  336. this can be the standard function free().  Both macros can be used
  337. wherever a void expression is allowed.  The argument shouldn't be a
  338. NIL pointer.  The macro _Py_NewReference(op) is used only to initialize
  339. reference counts to 1; it is defined here for convenience.
  340.  
  341. We assume that the reference count field can never overflow; this can
  342. be proven when the size of the field is the same as the pointer size
  343. but even with a 16-bit reference count field it is pretty unlikely so
  344. we ignore the possibility.  (If you are paranoid, make it a long.)
  345.  
  346. Type objects should never be deallocated; the type pointer in an object
  347. is not considered to be a reference to the type object, to save
  348. complications in the deallocation function.  (This is actually a
  349. decision that's up to the implementer of each new type so if you want,
  350. you can count such references to the type object.)
  351.  
  352. *** WARNING*** The Py_DECREF macro must have a side-effect-free argument
  353. since it may evaluate its argument multiple times.  (The alternative
  354. would be to mace it a proper function or assign it to a global temporary
  355. variable first, both of which are slower; and in a multi-threaded
  356. environment the global variable trick is not safe.)
  357. */
  358.  
  359. #ifdef Py_TRACE_REFS
  360. #ifndef Py_REF_DEBUG
  361. #define Py_REF_DEBUG
  362. #endif
  363. #endif
  364.  
  365. #ifdef Py_TRACE_REFS
  366. extern DL_IMPORT(void) _Py_Dealloc(PyObject *);
  367. extern DL_IMPORT(void) _Py_NewReference(PyObject *);
  368. extern DL_IMPORT(void) _Py_ForgetReference(PyObject *);
  369. extern DL_IMPORT(void) _Py_PrintReferences(FILE *);
  370. extern DL_IMPORT(void) _Py_ResetReferences(void);
  371. #endif
  372.  
  373. #ifndef Py_TRACE_REFS
  374. #ifdef COUNT_ALLOCS
  375. #define _Py_Dealloc(op) ((op)->ob_type->tp_free++, (*(op)->ob_type->tp_dealloc)((PyObject *)(op)))
  376. #define _Py_ForgetReference(op) ((op)->ob_type->tp_free++)
  377. #else /* !COUNT_ALLOCS */
  378. #define _Py_Dealloc(op) (*(op)->ob_type->tp_dealloc)((PyObject *)(op))
  379. #define _Py_ForgetReference(op) /*empty*/
  380. #endif /* !COUNT_ALLOCS */
  381. #endif /* !Py_TRACE_REFS */
  382.  
  383. #ifdef COUNT_ALLOCS
  384. extern DL_IMPORT(void) inc_count(PyTypeObject *);
  385. #endif
  386.  
  387. #ifdef Py_REF_DEBUG
  388.  
  389. extern DL_IMPORT(long) _Py_RefTotal;
  390.  
  391. #ifndef Py_TRACE_REFS
  392. #ifdef COUNT_ALLOCS
  393. #define _Py_NewReference(op) (inc_count((op)->ob_type), _Py_RefTotal++, (op)->ob_refcnt = 1)
  394. #else
  395. #define _Py_NewReference(op) (_Py_RefTotal++, (op)->ob_refcnt = 1)
  396. #endif
  397. #endif /* !Py_TRACE_REFS */
  398.  
  399. #define Py_INCREF(op) (_Py_RefTotal++, (op)->ob_refcnt++)
  400. #define Py_DECREF(op) \
  401.     if (--_Py_RefTotal, --(op)->ob_refcnt != 0) \
  402.         ; \
  403.     else \
  404.         _Py_Dealloc((PyObject *)(op))
  405. #else /* !Py_REF_DEBUG */
  406.  
  407. #ifdef COUNT_ALLOCS
  408. #define _Py_NewReference(op) (inc_count((op)->ob_type), (op)->ob_refcnt = 1)
  409. #else
  410. #define _Py_NewReference(op) ((op)->ob_refcnt = 1)
  411. #endif
  412.  
  413. #define Py_INCREF(op) ((op)->ob_refcnt++)
  414. #define Py_DECREF(op) \
  415.     if (--(op)->ob_refcnt != 0) \
  416.         ; \
  417.     else \
  418.         _Py_Dealloc((PyObject *)(op))
  419. #endif /* !Py_REF_DEBUG */
  420.  
  421. /* Macros to use in case the object pointer may be NULL: */
  422.  
  423. #define Py_XINCREF(op) if ((op) == NULL) ; else Py_INCREF(op)
  424. #define Py_XDECREF(op) if ((op) == NULL) ; else Py_DECREF(op)
  425.  
  426. /*
  427. _Py_NoneStruct is an object of undefined type which can be used in contexts
  428. where NULL (nil) is not suitable (since NULL often means 'error').
  429.  
  430. Don't forget to apply Py_INCREF() when returning this value!!!
  431. */
  432.  
  433. extern DL_IMPORT(PyObject) _Py_NoneStruct; /* Don't use this directly */
  434.  
  435. #define Py_None (&_Py_NoneStruct)
  436.  
  437.  
  438. /*
  439. A common programming style in Python requires the forward declaration
  440. of static, initialized structures, e.g. for a type object that is used
  441. by the functions whose address must be used in the initializer.
  442. Some compilers (notably SCO ODT 3.0, I seem to remember early AIX as
  443. well) botch this if you use the static keyword for both declarations
  444. (they allocate two objects, and use the first, uninitialized one until
  445. the second declaration is encountered).  Therefore, the forward
  446. declaration should use the 'forwardstatic' keyword.  This expands to
  447. static on most systems, but to extern on a few.  The actual storage
  448. and name will still be static because the second declaration is
  449. static, so no linker visible symbols will be generated.  (Standard C
  450. compilers take offense to the extern forward declaration of a static
  451. object, so I can't just put extern in all cases. :-( )
  452. */
  453.  
  454. #ifdef BAD_STATIC_FORWARD
  455. #define staticforward extern
  456. #define statichere static
  457. #else /* !BAD_STATIC_FORWARD */
  458. #define staticforward static
  459. #define statichere static
  460. #endif /* !BAD_STATIC_FORWARD */
  461.  
  462.  
  463. /*
  464. More conventions
  465. ================
  466.  
  467. Argument Checking
  468. -----------------
  469.  
  470. Functions that take objects as arguments normally don't check for nil
  471. arguments, but they do check the type of the argument, and return an
  472. error if the function doesn't apply to the type.
  473.  
  474. Failure Modes
  475. -------------
  476.  
  477. Functions may fail for a variety of reasons, including running out of
  478. memory.  This is communicated to the caller in two ways: an error string
  479. is set (see errors.h), and the function result differs: functions that
  480. normally return a pointer return NULL for failure, functions returning
  481. an integer return -1 (which could be a legal return value too!), and
  482. other functions return 0 for success and -1 for failure.
  483. Callers should always check for errors before using the result.
  484.  
  485. Reference Counts
  486. ----------------
  487.  
  488. It takes a while to get used to the proper usage of reference counts.
  489.  
  490. Functions that create an object set the reference count to 1; such new
  491. objects must be stored somewhere or destroyed again with Py_DECREF().
  492. Functions that 'store' objects such as PyTuple_SetItem() and
  493. PyDict_SetItemString()
  494. don't increment the reference count of the object, since the most
  495. frequent use is to store a fresh object.  Functions that 'retrieve'
  496. objects such as PyTuple_GetItem() and PyDict_GetItemString() also
  497. don't increment
  498. the reference count, since most frequently the object is only looked at
  499. quickly.  Thus, to retrieve an object and store it again, the caller
  500. must call Py_INCREF() explicitly.
  501.  
  502. NOTE: functions that 'consume' a reference count like
  503. PyList_SetItemString() even consume the reference if the object wasn't
  504. stored, to simplify error handling.
  505.  
  506. It seems attractive to make other functions that take an object as
  507. argument consume a reference count; however this may quickly get
  508. confusing (even the current practice is already confusing).  Consider
  509. it carefully, it may save lots of calls to Py_INCREF() and Py_DECREF() at
  510. times.
  511. */
  512.  
  513. /*
  514.   trashcan
  515.   CT 2k0130
  516.   non-recursively destroy nested objects
  517.  
  518.   CT 2k0223
  519.   redefinition for better locality and less overhead.
  520.  
  521.   Objects that want to be recursion safe need to use
  522.   the macro's 
  523.         Py_TRASHCAN_SAFE_BEGIN(name)
  524.   and
  525.         Py_TRASHCAN_SAFE_END(name)
  526.   surrounding their actual deallocation code.
  527.  
  528.   It would be nice to do this using the thread state.
  529.   Also, we could do an exact stack measure then.
  530.   Unfortunately, deallocations also take place when
  531.   the thread state is undefined.
  532.  
  533.   CT 2k0422 complete rewrite.
  534.   There is no need to allocate new objects.
  535.   Everything is done vialob_refcnt and ob_type now.
  536.   Adding support for free-threading should be easy, too.
  537. */
  538.  
  539. #define PyTrash_UNWIND_LEVEL 50
  540.  
  541. #define Py_TRASHCAN_SAFE_BEGIN(op) \
  542.     { \
  543.         ++_PyTrash_delete_nesting; \
  544.         if (_PyTrash_delete_nesting < PyTrash_UNWIND_LEVEL) { \
  545.  
  546. #define Py_TRASHCAN_SAFE_END(op) \
  547.         ;} \
  548.         else \
  549.             _PyTrash_deposit_object((PyObject*)op);\
  550.         --_PyTrash_delete_nesting; \
  551.         if (_PyTrash_delete_later && _PyTrash_delete_nesting <= 0) \
  552.             _PyTrash_destroy_chain(); \
  553.     } \
  554.  
  555. extern DL_IMPORT(void) _PyTrash_deposit_object(PyObject*);
  556. extern DL_IMPORT(void) _PyTrash_destroy_chain(void);
  557.  
  558. extern DL_IMPORT(int) _PyTrash_delete_nesting;
  559. extern DL_IMPORT(PyObject *) _PyTrash_delete_later;
  560.  
  561. /* swap the "xx" to check the speed loss */
  562.  
  563. #define xxPy_TRASHCAN_SAFE_BEGIN(op) 
  564. #define xxPy_TRASHCAN_SAFE_END(op) ;
  565.  
  566. #ifdef __cplusplus
  567. }
  568. #endif
  569. #endif /* !Py_OBJECT_H */
  570.