/src/cpython-install/include/python3.15/cpython/bytesobject.h
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef Py_CPYTHON_BYTESOBJECT_H |
2 | | # error "this header file must not be included directly" |
3 | | #endif |
4 | | |
5 | | typedef struct { |
6 | | PyObject_VAR_HEAD |
7 | | Py_DEPRECATED(3.11) Py_hash_t ob_shash; |
8 | | char ob_sval[1]; |
9 | | |
10 | | /* Invariants: |
11 | | * ob_sval contains space for 'ob_size+1' elements. |
12 | | * ob_sval[ob_size] == 0. |
13 | | * ob_shash is the hash of the byte string or -1 if not computed yet. |
14 | | */ |
15 | | } PyBytesObject; |
16 | | |
17 | | PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t); |
18 | | |
19 | | /* Macros and static inline functions, trading safety for speed */ |
20 | | #define _PyBytes_CAST(op) \ |
21 | | (assert(PyBytes_Check(op)), _Py_CAST(PyBytesObject*, op)) |
22 | | |
23 | | static inline char* PyBytes_AS_STRING(PyObject *op) |
24 | 0 | { |
25 | 0 | return _PyBytes_CAST(op)->ob_sval; |
26 | 0 | } |
27 | | #define PyBytes_AS_STRING(op) PyBytes_AS_STRING(_PyObject_CAST(op)) |
28 | | |
29 | 0 | static inline Py_ssize_t PyBytes_GET_SIZE(PyObject *op) { |
30 | 0 | PyBytesObject *self = _PyBytes_CAST(op); |
31 | 0 | return Py_SIZE(self); |
32 | 0 | } |
33 | | #define PyBytes_GET_SIZE(self) PyBytes_GET_SIZE(_PyObject_CAST(self)) |
34 | | |
35 | | PyAPI_FUNC(PyObject*) PyBytes_Join(PyObject *sep, PyObject *iterable); |
36 | | |
37 | | // Deprecated alias kept for backward compatibility |
38 | | Py_DEPRECATED(3.14) static inline PyObject* |
39 | | _PyBytes_Join(PyObject *sep, PyObject *iterable) |
40 | 0 | { |
41 | 0 | return PyBytes_Join(sep, iterable); |
42 | 0 | } |