bytearrayobject.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* ByteArray object interface */
  2. #ifndef Py_BYTEARRAYOBJECT_H
  3. #define Py_BYTEARRAYOBJECT_H
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #include <stdarg.h>
  8. /* Type PyByteArrayObject represents a mutable array of bytes.
  9. * The Python API is that of a sequence;
  10. * the bytes are mapped to ints in [0, 256).
  11. * Bytes are not characters; they may be used to encode characters.
  12. * The only way to go between bytes and str/unicode is via encoding
  13. * and decoding.
  14. * For the convenience of C programmers, the bytes type is considered
  15. * to contain a char pointer, not an unsigned char pointer.
  16. */
  17. /* Type object */
  18. PyAPI_DATA(PyTypeObject) PyByteArray_Type;
  19. PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type;
  20. /* Type check macros */
  21. #define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type)
  22. #define PyByteArray_CheckExact(self) Py_IS_TYPE(self, &PyByteArray_Type)
  23. /* Direct API functions */
  24. PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *);
  25. PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *);
  26. PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t);
  27. PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *);
  28. PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *);
  29. PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t);
  30. #ifndef Py_LIMITED_API
  31. # define Py_CPYTHON_BYTEARRAYOBJECT_H
  32. # include "cpython/bytearrayobject.h"
  33. # undef Py_CPYTHON_BYTEARRAYOBJECT_H
  34. #endif
  35. #ifdef __cplusplus
  36. }
  37. #endif
  38. #endif /* !Py_BYTEARRAYOBJECT_H */