sliceobject.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef Py_SLICEOBJECT_H
  2. #define Py_SLICEOBJECT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /* The unique ellipsis object "..." */
  7. PyAPI_DATA(PyObject) _Py_EllipsisObject; /* Don't use this directly */
  8. #define Py_Ellipsis (&_Py_EllipsisObject)
  9. /* Slice object interface */
  10. /*
  11. A slice object containing start, stop, and step data members (the
  12. names are from range). After much talk with Guido, it was decided to
  13. let these be any arbitrary python type. Py_None stands for omitted values.
  14. */
  15. #ifndef Py_LIMITED_API
  16. typedef struct {
  17. PyObject_HEAD
  18. PyObject *start, *stop, *step; /* not NULL */
  19. } PySliceObject;
  20. #endif
  21. PyAPI_DATA(PyTypeObject) PySlice_Type;
  22. PyAPI_DATA(PyTypeObject) PyEllipsis_Type;
  23. #define PySlice_Check(op) Py_IS_TYPE((op), &PySlice_Type)
  24. PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop,
  25. PyObject* step);
  26. #ifndef Py_LIMITED_API
  27. PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop);
  28. PyAPI_FUNC(int) _PySlice_GetLongIndices(PySliceObject *self, PyObject *length,
  29. PyObject **start_ptr, PyObject **stop_ptr,
  30. PyObject **step_ptr);
  31. #endif
  32. PyAPI_FUNC(int) PySlice_GetIndices(PyObject *r, Py_ssize_t length,
  33. Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step);
  34. Py_DEPRECATED(3.7)
  35. PyAPI_FUNC(int) PySlice_GetIndicesEx(PyObject *r, Py_ssize_t length,
  36. Py_ssize_t *start, Py_ssize_t *stop,
  37. Py_ssize_t *step,
  38. Py_ssize_t *slicelength);
  39. #if !defined(Py_LIMITED_API) || (Py_LIMITED_API+0 >= 0x03050400 && Py_LIMITED_API+0 < 0x03060000) || Py_LIMITED_API+0 >= 0x03060100
  40. #define PySlice_GetIndicesEx(slice, length, start, stop, step, slicelen) ( \
  41. PySlice_Unpack((slice), (start), (stop), (step)) < 0 ? \
  42. ((*(slicelen) = 0), -1) : \
  43. ((*(slicelen) = PySlice_AdjustIndices((length), (start), (stop), *(step))), \
  44. 0))
  45. PyAPI_FUNC(int) PySlice_Unpack(PyObject *slice,
  46. Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step);
  47. PyAPI_FUNC(Py_ssize_t) PySlice_AdjustIndices(Py_ssize_t length,
  48. Py_ssize_t *start, Py_ssize_t *stop,
  49. Py_ssize_t step);
  50. #endif
  51. #ifdef __cplusplus
  52. }
  53. #endif
  54. #endif /* !Py_SLICEOBJECT_H */