|
|
#ifndef Py_CPYTHON_BYTESOBJECT_H |
|
|
# error "this header file must not be included directly" |
|
|
#endif |
|
|
|
|
|
typedef struct { |
|
|
PyObject_VAR_HEAD |
|
|
Py_DEPRECATED(3.11) Py_hash_t ob_shash; |
|
|
char ob_sval[1]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} PyBytesObject; |
|
|
|
|
|
PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t); |
|
|
PyAPI_FUNC(PyObject*) _PyBytes_FormatEx( |
|
|
const char *format, |
|
|
Py_ssize_t format_len, |
|
|
PyObject *args, |
|
|
int use_bytearray); |
|
|
PyAPI_FUNC(PyObject*) _PyBytes_FromHex( |
|
|
PyObject *string, |
|
|
int use_bytearray); |
|
|
|
|
|
|
|
|
PyAPI_FUNC(PyObject *) _PyBytes_DecodeEscape(const char *, Py_ssize_t, |
|
|
const char *, const char **); |
|
|
|
|
|
|
|
|
#define _PyBytes_CAST(op) \ |
|
|
(assert(PyBytes_Check(op)), _Py_CAST(PyBytesObject*, op)) |
|
|
|
|
|
static inline char* PyBytes_AS_STRING(PyObject *op) |
|
|
{ |
|
|
return _PyBytes_CAST(op)->ob_sval; |
|
|
} |
|
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 |
|
|
# define PyBytes_AS_STRING(op) PyBytes_AS_STRING(_PyObject_CAST(op)) |
|
|
#endif |
|
|
|
|
|
static inline Py_ssize_t PyBytes_GET_SIZE(PyObject *op) { |
|
|
PyBytesObject *self = _PyBytes_CAST(op); |
|
|
return Py_SIZE(self); |
|
|
} |
|
|
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 |
|
|
# define PyBytes_GET_SIZE(self) PyBytes_GET_SIZE(_PyObject_CAST(self)) |
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct { |
|
|
|
|
|
PyObject *buffer; |
|
|
|
|
|
|
|
|
Py_ssize_t allocated; |
|
|
|
|
|
|
|
|
|
|
|
Py_ssize_t min_size; |
|
|
|
|
|
|
|
|
int use_bytearray; |
|
|
|
|
|
|
|
|
|
|
|
int overallocate; |
|
|
|
|
|
|
|
|
int use_small_buffer; |
|
|
char small_buffer[512]; |
|
|
} _PyBytesWriter; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PyAPI_FUNC(void) _PyBytesWriter_Init(_PyBytesWriter *writer); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PyAPI_FUNC(PyObject *) _PyBytesWriter_Finish(_PyBytesWriter *writer, |
|
|
void *str); |
|
|
|
|
|
|
|
|
PyAPI_FUNC(void) _PyBytesWriter_Dealloc(_PyBytesWriter *writer); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PyAPI_FUNC(void*) _PyBytesWriter_Alloc(_PyBytesWriter *writer, |
|
|
Py_ssize_t size); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PyAPI_FUNC(void*) _PyBytesWriter_Prepare(_PyBytesWriter *writer, |
|
|
void *str, |
|
|
Py_ssize_t size); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PyAPI_FUNC(void*) _PyBytesWriter_Resize(_PyBytesWriter *writer, |
|
|
void *str, |
|
|
Py_ssize_t size); |
|
|
|
|
|
|
|
|
|
|
|
PyAPI_FUNC(void*) _PyBytesWriter_WriteBytes(_PyBytesWriter *writer, |
|
|
void *str, |
|
|
const void *bytes, |
|
|
Py_ssize_t size); |
|
|
|