listobject.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* List object interface
  2. Another generally useful object type is a list of object pointers.
  3. This is a mutable type: the list items can be changed, and items can be
  4. added or removed. Out-of-range indices or non-list objects are ignored.
  5. WARNING: PyList_SetItem does not increment the new item's reference count,
  6. but does decrement the reference count of the item it replaces, if not nil.
  7. It does *decrement* the reference count if it is *not* inserted in the list.
  8. Similarly, PyList_GetItem does not increment the returned item's reference
  9. count.
  10. */
  11. #ifndef Py_LISTOBJECT_H
  12. #define Py_LISTOBJECT_H
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. PyAPI_DATA(PyTypeObject) PyList_Type;
  17. PyAPI_DATA(PyTypeObject) PyListIter_Type;
  18. PyAPI_DATA(PyTypeObject) PyListRevIter_Type;
  19. #define PyList_Check(op) \
  20. PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS)
  21. #define PyList_CheckExact(op) Py_IS_TYPE((op), &PyList_Type)
  22. PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size);
  23. PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *);
  24. PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, Py_ssize_t);
  25. PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *);
  26. PyAPI_FUNC(int) PyList_Insert(PyObject *, Py_ssize_t, PyObject *);
  27. PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *);
  28. PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
  29. PyAPI_FUNC(int) PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
  30. PyAPI_FUNC(int) PyList_Sort(PyObject *);
  31. PyAPI_FUNC(int) PyList_Reverse(PyObject *);
  32. PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *);
  33. #ifndef Py_LIMITED_API
  34. # define Py_CPYTHON_LISTOBJECT_H
  35. # include "cpython/listobject.h"
  36. # undef Py_CPYTHON_LISTOBJECT_H
  37. #endif
  38. #ifdef __cplusplus
  39. }
  40. #endif
  41. #endif /* !Py_LISTOBJECT_H */