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 / TUPLEOBJECT.H < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-01  |  1.6 KB  |  49 lines

  1.  
  2. /* Tuple object interface */
  3.  
  4. #ifndef Py_TUPLEOBJECT_H
  5. #define Py_TUPLEOBJECT_H
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9.  
  10. /*
  11. Another generally useful object type is an tuple of object pointers.
  12. This is a mutable type: the tuple items can be changed (but not their
  13. number).  Out-of-range indices or non-tuple objects are ignored.
  14.  
  15. *** WARNING *** PyTuple_SetItem does not increment the new item's reference
  16. count, but does decrement the reference count of the item it replaces,
  17. if not nil.  It does *decrement* the reference count if it is *not*
  18. inserted in the tuple.  Similarly, PyTuple_GetItem does not increment the
  19. returned item's reference count.
  20. */
  21.  
  22. typedef struct {
  23.     PyObject_VAR_HEAD
  24.     PyObject *ob_item[1];
  25. } PyTupleObject;
  26.  
  27. extern DL_IMPORT(PyTypeObject) PyTuple_Type;
  28.  
  29. #define PyTuple_Check(op) ((op)->ob_type == &PyTuple_Type)
  30.  
  31. extern DL_IMPORT(PyObject *) PyTuple_New(int size);
  32. extern DL_IMPORT(int) PyTuple_Size(PyObject *);
  33. extern DL_IMPORT(PyObject *) PyTuple_GetItem(PyObject *, int);
  34. extern DL_IMPORT(int) PyTuple_SetItem(PyObject *, int, PyObject *);
  35. extern DL_IMPORT(PyObject *) PyTuple_GetSlice(PyObject *, int, int);
  36. extern DL_IMPORT(int) _PyTuple_Resize(PyObject **, int, int);
  37.  
  38. /* Macro, trading safety for speed */
  39. #define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i])
  40. #define PyTuple_GET_SIZE(op)    (((PyTupleObject *)(op))->ob_size)
  41.  
  42. /* Macro, *only* to be used to fill in brand new tuples */
  43. #define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)
  44.  
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48. #endif /* !Py_TUPLEOBJECT_H */
  49.