PageRenderTime 74ms CodeModel.GetById 41ms RepoModel.GetById 2ms app.codeStats 0ms

/necco/python/Include/listobject.h

https://github.com/brosner/cleese
C Header | 46 lines | 24 code | 9 blank | 13 comment | 1 complexity | 83f726264616a956e2c77a2b78139cc8 MD5 | raw file
  1. /* List object interface */
  2. /*
  3. Another generally useful object type is an list of object pointers.
  4. This is a mutable type: the list items can be changed, and items can be
  5. added or removed. Out-of-range indices or non-list objects are ignored.
  6. *** WARNING *** PyList_SetItem does not increment the new item's reference
  7. count, but does decrement the reference count of the item it replaces,
  8. if not nil. It does *decrement* the reference count if it is *not*
  9. inserted in the list. Similarly, PyList_GetItem does not increment the
  10. returned item's reference count.
  11. */
  12. #ifndef Py_LISTOBJECT_H
  13. #define Py_LISTOBJECT_H
  14. typedef struct {
  15. PyObject_VAR_HEAD
  16. PyObject **ob_item;
  17. } PyListObject;
  18. PyAPI_DATA(PyTypeObject) PyList_Type;
  19. #define PyList_Check(op) PyObject_TypeCheck(op, &PyList_Type)
  20. #define PyList_CheckExact(op) ((op)->ob_type == &PyList_Type)
  21. PyAPI_FUNC(PyObject *) PyList_New(int size);
  22. PyAPI_FUNC(int) PyList_Size(PyObject *);
  23. PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, int);
  24. PyAPI_FUNC(int) PyList_SetItem(PyObject *, int, PyObject *);
  25. PyAPI_FUNC(int) PyList_Insert(PyObject *, int, PyObject *);
  26. PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *);
  27. PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, int, int);
  28. PyAPI_FUNC(int) PyList_SetSlice(PyObject *, int, int, PyObject *);
  29. PyAPI_FUNC(int) PyList_Sort(PyObject *);
  30. PyAPI_FUNC(int) PyList_Reverse(PyObject *);
  31. PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *);
  32. /* Macro, trading safety for speed */
  33. #define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i])
  34. #define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v))
  35. #define PyList_GET_SIZE(op) (((PyListObject *)(op))->ob_size)
  36. #endif /* !Py_LISTOBJECT_H */