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 / LISTOBJECT.H < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-01  |  1.8 KB  |  52 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) ((op)->ob_type == &PyList_Type)
  30.  
  31. extern DL_IMPORT(PyObject *) PyList_New(int size);
  32. extern DL_IMPORT(int) PyList_Size(PyObject *);
  33. extern DL_IMPORT(PyObject *) PyList_GetItem(PyObject *, int);
  34. extern DL_IMPORT(int) PyList_SetItem(PyObject *, int, PyObject *);
  35. extern DL_IMPORT(int) PyList_Insert(PyObject *, int, PyObject *);
  36. extern DL_IMPORT(int) PyList_Append(PyObject *, PyObject *);
  37. extern DL_IMPORT(PyObject *) PyList_GetSlice(PyObject *, int, int);
  38. extern DL_IMPORT(int) PyList_SetSlice(PyObject *, int, int, PyObject *);
  39. extern DL_IMPORT(int) PyList_Sort(PyObject *);
  40. extern DL_IMPORT(int) PyList_Reverse(PyObject *);
  41. extern DL_IMPORT(PyObject *) PyList_AsTuple(PyObject *);
  42.  
  43. /* Macro, trading safety for speed */
  44. #define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i])
  45. #define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v))
  46. #define PyList_GET_SIZE(op)    (((PyListObject *)(op))->ob_size)
  47.  
  48. #ifdef __cplusplus
  49. }
  50. #endif
  51. #endif /* !Py_LISTOBJECT_H */
  52.