jpayne@69: /* ByteArray object interface */ jpayne@69: jpayne@69: #ifndef Py_BYTEARRAYOBJECT_H jpayne@69: #define Py_BYTEARRAYOBJECT_H jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: #include jpayne@69: jpayne@69: /* Type PyByteArrayObject represents a mutable array of bytes. jpayne@69: * The Python API is that of a sequence; jpayne@69: * the bytes are mapped to ints in [0, 256). jpayne@69: * Bytes are not characters; they may be used to encode characters. jpayne@69: * The only way to go between bytes and str/unicode is via encoding jpayne@69: * and decoding. jpayne@69: * For the convenience of C programmers, the bytes type is considered jpayne@69: * to contain a char pointer, not an unsigned char pointer. jpayne@69: */ jpayne@69: jpayne@69: /* Object layout */ jpayne@69: #ifndef Py_LIMITED_API jpayne@69: typedef struct { jpayne@69: PyObject_VAR_HEAD jpayne@69: Py_ssize_t ob_alloc; /* How many bytes allocated in ob_bytes */ jpayne@69: char *ob_bytes; /* Physical backing buffer */ jpayne@69: char *ob_start; /* Logical start inside ob_bytes */ jpayne@69: /* XXX(nnorwitz): should ob_exports be Py_ssize_t? */ jpayne@69: int ob_exports; /* How many buffer exports */ jpayne@69: } PyByteArrayObject; jpayne@69: #endif jpayne@69: jpayne@69: /* Type object */ jpayne@69: PyAPI_DATA(PyTypeObject) PyByteArray_Type; jpayne@69: PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type; jpayne@69: jpayne@69: /* Type check macros */ jpayne@69: #define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type) jpayne@69: #define PyByteArray_CheckExact(self) (Py_TYPE(self) == &PyByteArray_Type) jpayne@69: jpayne@69: /* Direct API functions */ jpayne@69: PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *); jpayne@69: PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *); jpayne@69: PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t); jpayne@69: PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *); jpayne@69: PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *); jpayne@69: PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t); jpayne@69: jpayne@69: /* Macros, trading safety for speed */ jpayne@69: #ifndef Py_LIMITED_API jpayne@69: #define PyByteArray_AS_STRING(self) \ jpayne@69: (assert(PyByteArray_Check(self)), \ jpayne@69: Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_start : _PyByteArray_empty_string) jpayne@69: #define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)), Py_SIZE(self)) jpayne@69: jpayne@69: PyAPI_DATA(char) _PyByteArray_empty_string[]; jpayne@69: #endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: #endif /* !Py_BYTEARRAYOBJECT_H */