@@ -27,20 +27,6 @@ functions should be applied to nil objects.
2727/* Caching the hash (ob_shash) saves recalculation of a string's hash value.
2828 This significantly speeds up dict lookups. */
2929
30- #ifndef Py_LIMITED_API
31- typedef struct {
32- PyObject_VAR_HEAD
33- Py_hash_t ob_shash ;
34- char ob_sval [1 ];
35-
36- /* Invariants:
37- * ob_sval contains space for 'ob_size+1' elements.
38- * ob_sval[ob_size] == 0.
39- * ob_shash is the hash of the string or -1 if not computed yet.
40- */
41- } PyBytesObject ;
42- #endif
43-
4430PyAPI_DATA (PyTypeObject ) PyBytes_Type ;
4531PyAPI_DATA (PyTypeObject ) PyBytesIter_Type ;
4632
@@ -60,38 +46,9 @@ PyAPI_FUNC(char *) PyBytes_AsString(PyObject *);
6046PyAPI_FUNC (PyObject * ) PyBytes_Repr (PyObject * , int );
6147PyAPI_FUNC (void ) PyBytes_Concat (PyObject * * , PyObject * );
6248PyAPI_FUNC (void ) PyBytes_ConcatAndDel (PyObject * * , PyObject * );
63- #ifndef Py_LIMITED_API
64- PyAPI_FUNC (int ) _PyBytes_Resize (PyObject * * , Py_ssize_t );
65- PyAPI_FUNC (PyObject * ) _PyBytes_FormatEx (
66- const char * format ,
67- Py_ssize_t format_len ,
68- PyObject * args ,
69- int use_bytearray );
70- PyAPI_FUNC (PyObject * ) _PyBytes_FromHex (
71- PyObject * string ,
72- int use_bytearray );
73- #endif
7449PyAPI_FUNC (PyObject * ) PyBytes_DecodeEscape (const char * , Py_ssize_t ,
7550 const char * , Py_ssize_t ,
7651 const char * );
77- #ifndef Py_LIMITED_API
78- /* Helper for PyBytes_DecodeEscape that detects invalid escape chars. */
79- PyAPI_FUNC (PyObject * ) _PyBytes_DecodeEscape (const char * , Py_ssize_t ,
80- const char * , const char * * );
81- #endif
82-
83- /* Macro, trading safety for speed */
84- #ifndef Py_LIMITED_API
85- #define PyBytes_AS_STRING (op ) (assert(PyBytes_Check(op)), \
86- (((PyBytesObject *)(op))->ob_sval))
87- #define PyBytes_GET_SIZE (op ) (assert(PyBytes_Check(op)),Py_SIZE(op))
88- #endif
89-
90- /* _PyBytes_Join(sep, x) is like sep.join(x). sep must be PyBytesObject*,
91- x must be an iterable object. */
92- #ifndef Py_LIMITED_API
93- PyAPI_FUNC (PyObject * ) _PyBytes_Join (PyObject * sep , PyObject * x );
94- #endif
9552
9653/* Provides access to the internal data buffer and size of a string
9754 object or the default encoded version of a Unicode object. Passing
@@ -114,85 +71,10 @@ PyAPI_FUNC(int) PyBytes_AsStringAndSize(
11471#define F_ZERO (1<<4)
11572
11673#ifndef Py_LIMITED_API
117- /* The _PyBytesWriter structure is big: it contains an embedded "stack buffer".
118- A _PyBytesWriter variable must be declared at the end of variables in a
119- function to optimize the memory allocation on the stack. */
120- typedef struct {
121- /* bytes, bytearray or NULL (when the small buffer is used) */
122- PyObject * buffer ;
123-
124- /* Number of allocated size. */
125- Py_ssize_t allocated ;
126-
127- /* Minimum number of allocated bytes,
128- incremented by _PyBytesWriter_Prepare() */
129- Py_ssize_t min_size ;
130-
131- /* If non-zero, use a bytearray instead of a bytes object for buffer. */
132- int use_bytearray ;
133-
134- /* If non-zero, overallocate the buffer (default: 0).
135- This flag must be zero if use_bytearray is non-zero. */
136- int overallocate ;
137-
138- /* Stack buffer */
139- int use_small_buffer ;
140- char small_buffer [512 ];
141- } _PyBytesWriter ;
142-
143- /* Initialize a bytes writer
144-
145- By default, the overallocation is disabled. Set the overallocate attribute
146- to control the allocation of the buffer. */
147- PyAPI_FUNC (void ) _PyBytesWriter_Init (_PyBytesWriter * writer );
148-
149- /* Get the buffer content and reset the writer.
150- Return a bytes object, or a bytearray object if use_bytearray is non-zero.
151- Raise an exception and return NULL on error. */
152- PyAPI_FUNC (PyObject * ) _PyBytesWriter_Finish (_PyBytesWriter * writer ,
153- void * str );
154-
155- /* Deallocate memory of a writer (clear its internal buffer). */
156- PyAPI_FUNC (void ) _PyBytesWriter_Dealloc (_PyBytesWriter * writer );
157-
158- /* Allocate the buffer to write size bytes.
159- Return the pointer to the beginning of buffer data.
160- Raise an exception and return NULL on error. */
161- PyAPI_FUNC (void * ) _PyBytesWriter_Alloc (_PyBytesWriter * writer ,
162- Py_ssize_t size );
163-
164- /* Ensure that the buffer is large enough to write *size* bytes.
165- Add size to the writer minimum size (min_size attribute).
166-
167- str is the current pointer inside the buffer.
168- Return the updated current pointer inside the buffer.
169- Raise an exception and return NULL on error. */
170- PyAPI_FUNC (void * ) _PyBytesWriter_Prepare (_PyBytesWriter * writer ,
171- void * str ,
172- Py_ssize_t size );
173-
174- /* Resize the buffer to make it larger.
175- The new buffer may be larger than size bytes because of overallocation.
176- Return the updated current pointer inside the buffer.
177- Raise an exception and return NULL on error.
178-
179- Note: size must be greater than the number of allocated bytes in the writer.
180-
181- This function doesn't use the writer minimum size (min_size attribute).
182-
183- See also _PyBytesWriter_Prepare().
184- */
185- PyAPI_FUNC (void * ) _PyBytesWriter_Resize (_PyBytesWriter * writer ,
186- void * str ,
187- Py_ssize_t size );
188-
189- /* Write bytes.
190- Raise an exception and return NULL on error. */
191- PyAPI_FUNC (void * ) _PyBytesWriter_WriteBytes (_PyBytesWriter * writer ,
192- void * str ,
193- const void * bytes ,
194- Py_ssize_t size );
195- #endif /* Py_LIMITED_API */
74+ # define Py_CPYTHON_BYTESOBJECT_H
75+ # include "cpython/bytesobject.h"
76+ # undef Py_CPYTHON_BYTESOBJECT_H
77+ #endif
19678
19779#ifdef __cplusplus
19880}
0 commit comments