annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/python3.8/bytearrayobject.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 /* ByteArray object interface */
jpayne@69 2
jpayne@69 3 #ifndef Py_BYTEARRAYOBJECT_H
jpayne@69 4 #define Py_BYTEARRAYOBJECT_H
jpayne@69 5 #ifdef __cplusplus
jpayne@69 6 extern "C" {
jpayne@69 7 #endif
jpayne@69 8
jpayne@69 9 #include <stdarg.h>
jpayne@69 10
jpayne@69 11 /* Type PyByteArrayObject represents a mutable array of bytes.
jpayne@69 12 * The Python API is that of a sequence;
jpayne@69 13 * the bytes are mapped to ints in [0, 256).
jpayne@69 14 * Bytes are not characters; they may be used to encode characters.
jpayne@69 15 * The only way to go between bytes and str/unicode is via encoding
jpayne@69 16 * and decoding.
jpayne@69 17 * For the convenience of C programmers, the bytes type is considered
jpayne@69 18 * to contain a char pointer, not an unsigned char pointer.
jpayne@69 19 */
jpayne@69 20
jpayne@69 21 /* Object layout */
jpayne@69 22 #ifndef Py_LIMITED_API
jpayne@69 23 typedef struct {
jpayne@69 24 PyObject_VAR_HEAD
jpayne@69 25 Py_ssize_t ob_alloc; /* How many bytes allocated in ob_bytes */
jpayne@69 26 char *ob_bytes; /* Physical backing buffer */
jpayne@69 27 char *ob_start; /* Logical start inside ob_bytes */
jpayne@69 28 /* XXX(nnorwitz): should ob_exports be Py_ssize_t? */
jpayne@69 29 int ob_exports; /* How many buffer exports */
jpayne@69 30 } PyByteArrayObject;
jpayne@69 31 #endif
jpayne@69 32
jpayne@69 33 /* Type object */
jpayne@69 34 PyAPI_DATA(PyTypeObject) PyByteArray_Type;
jpayne@69 35 PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type;
jpayne@69 36
jpayne@69 37 /* Type check macros */
jpayne@69 38 #define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type)
jpayne@69 39 #define PyByteArray_CheckExact(self) (Py_TYPE(self) == &PyByteArray_Type)
jpayne@69 40
jpayne@69 41 /* Direct API functions */
jpayne@69 42 PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *);
jpayne@69 43 PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *);
jpayne@69 44 PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t);
jpayne@69 45 PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *);
jpayne@69 46 PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *);
jpayne@69 47 PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t);
jpayne@69 48
jpayne@69 49 /* Macros, trading safety for speed */
jpayne@69 50 #ifndef Py_LIMITED_API
jpayne@69 51 #define PyByteArray_AS_STRING(self) \
jpayne@69 52 (assert(PyByteArray_Check(self)), \
jpayne@69 53 Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_start : _PyByteArray_empty_string)
jpayne@69 54 #define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)), Py_SIZE(self))
jpayne@69 55
jpayne@69 56 PyAPI_DATA(char) _PyByteArray_empty_string[];
jpayne@69 57 #endif
jpayne@69 58
jpayne@69 59 #ifdef __cplusplus
jpayne@69 60 }
jpayne@69 61 #endif
jpayne@69 62 #endif /* !Py_BYTEARRAYOBJECT_H */