home *** CD-ROM | disk | FTP | other *** search
/ Freelog 33 / Freelog033.iso / Progr / Python-2.2.1.exe / LISTOBJECT.H < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-05  |  1.9 KB  |  53 lines

  1.  
  2. /* List object interface */
  3.  
  4. /*
  5. Another generally useful object type is an list of object pointers.
  6. This is a mutable type: the list items can be changed, and items can be
  7. added or removed.  Out-of-range indices or non-list objects are ignored.
  8.  
  9. *** WARNING *** PyList_SetItem does not increment the new item's reference
  10. count, but does decrement the reference count of the item it replaces,
  11. if not nil.  It does *decrement* the reference count if it is *not*
  12. inserted in the list.  Similarly, PyList_GetItem does not increment the
  13. returned item's reference count.
  14. */
  15.  
  16. #ifndef Py_LISTOBJECT_H
  17. #define Py_LISTOBJECT_H
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21.  
  22. typedef struct {
  23.     PyObject_VAR_HEAD
  24.     PyObject **ob_item;
  25. } PyListObject;
  26.  
  27. extern DL_IMPORT(PyTypeObject) PyList_Type;
  28.  
  29. #define PyList_Check(op) PyObject_TypeCheck(op, &PyList_Type)
  30. #define PyList_CheckExact(op) ((op)->ob_type == &PyList_Type)
  31.  
  32. extern DL_IMPORT(PyObject *) PyList_New(int size);
  33. extern DL_IMPORT(int) PyList_Size(PyObject *);
  34. extern DL_IMPORT(PyObject *) PyList_GetItem(PyObject *, int);
  35. extern DL_IMPORT(int) PyList_SetItem(PyObject *, int, PyObject *);
  36. extern DL_IMPORT(int) PyList_Insert(PyObject *, int, PyObject *);
  37. extern DL_IMPORT(int) PyList_Append(PyObject *, PyObject *);
  38. extern DL_IMPORT(PyObject *) PyList_GetSlice(PyObject *, int, int);
  39. extern DL_IMPORT(int) PyList_SetSlice(PyObject *, int, int, PyObject *);
  40. extern DL_IMPORT(int) PyList_Sort(PyObject *);
  41. extern DL_IMPORT(int) PyList_Reverse(PyObject *);
  42. extern DL_IMPORT(PyObject *) PyList_AsTuple(PyObject *);
  43.  
  44. /* Macro, trading safety for speed */
  45. #define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i])
  46. #define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v))
  47. #define PyList_GET_SIZE(op)    (((PyListObject *)(op))->ob_size)
  48.  
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #endif /* !Py_LISTOBJECT_H */
  53.