blob: 9e95433f0f26f0b319c1bf5c1c469a0e089a31f2 [file] [log] [blame]
Georg Brandl0c77a822008-06-10 16:37:50 +00001/* ByteArray object interface */
Christian Heimes2c9c7a52008-05-26 13:42:13 +00002
Georg Brandl0c77a822008-06-10 16:37:50 +00003#ifndef Py_BYTEARRAYOBJECT_H
4#define Py_BYTEARRAYOBJECT_H
Christian Heimes2c9c7a52008-05-26 13:42:13 +00005#ifdef __cplusplus
6extern "C" {
7#endif
8
9#include <stdarg.h>
10
11/* Type PyByteArrayObject represents a mutable array of bytes.
12 * The Python API is that of a sequence;
13 * the bytes are mapped to ints in [0, 256).
14 * Bytes are not characters; they may be used to encode characters.
15 * The only way to go between bytes and str/unicode is via encoding
16 * and decoding.
17 * For the convenience of C programmers, the bytes type is considered
18 * to contain a char pointer, not an unsigned char pointer.
19 */
20
Christian Heimes2c9c7a52008-05-26 13:42:13 +000021/* Type object */
22PyAPI_DATA(PyTypeObject) PyByteArray_Type;
23PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type;
24
25/* Type check macros */
26#define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type)
Dong-hee Nad905df72020-02-14 02:37:17 +090027#define PyByteArray_CheckExact(self) Py_IS_TYPE(self, &PyByteArray_Type)
Christian Heimes2c9c7a52008-05-26 13:42:13 +000028
29/* Direct API functions */
30PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *);
31PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *);
32PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t);
33PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *);
34PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *);
35PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t);
36
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000037#ifndef Py_LIMITED_API
Victor Stinner98921ae2020-02-12 23:54:31 +010038# define Py_CPYTHON_BYTEARRAYOBJECT_H
39# include "cpython/bytearrayobject.h"
40# undef Py_CPYTHON_BYTEARRAYOBJECT_H
Martin v. Löwis4d0d4712010-12-03 20:14:31 +000041#endif
Antoine Pitroufc8d6f42010-01-17 12:38:54 +000042
Christian Heimes2c9c7a52008-05-26 13:42:13 +000043#ifdef __cplusplus
44}
45#endif
Georg Brandl0c77a822008-06-10 16:37:50 +000046#endif /* !Py_BYTEARRAYOBJECT_H */