diff options
| author | Victor Stinner <vstinner@python.org> | 2020-02-12 23:54:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-12 23:54:31 +0100 |
| commit | 98921aeaf5879b51e2dd1870c9285cfa8d1a52c7 (patch) | |
| tree | f801d5336066bb127256276b626a62842cd96011 /Include/cpython/bytearrayobject.h | |
| parent | e9e7d284c434768333fdfb53a3663eae74cb995a (diff) | |
| download | cpython-git-98921aeaf5879b51e2dd1870c9285cfa8d1a52c7.tar.gz | |
bpo-35134: Add Include/cpython/bytesobject.h file (GH-18494)
Add Include/cpython/bytearrayobject.h and
Include/cpython/bytesobject.h header files.
Move CPython C API from Include/bytesobject.h into a new
Include/cpython/bytesobject.h header file which is included by
Include/bytesobject.h. Do a similar change for
Include/bytearrayobject.h.
Diffstat (limited to 'Include/cpython/bytearrayobject.h')
| -rw-r--r-- | Include/cpython/bytearrayobject.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Include/cpython/bytearrayobject.h b/Include/cpython/bytearrayobject.h new file mode 100644 index 0000000000..569b0cd036 --- /dev/null +++ b/Include/cpython/bytearrayobject.h @@ -0,0 +1,20 @@ +#ifndef Py_CPYTHON_BYTEARRAYOBJECT_H +# error "this header file must not be included directly" +#endif + +/* Object layout */ +typedef struct { + PyObject_VAR_HEAD + Py_ssize_t ob_alloc; /* How many bytes allocated in ob_bytes */ + char *ob_bytes; /* Physical backing buffer */ + char *ob_start; /* Logical start inside ob_bytes */ + Py_ssize_t ob_exports; /* How many buffer exports */ +} PyByteArrayObject; + +/* Macros, trading safety for speed */ +#define PyByteArray_AS_STRING(self) \ + (assert(PyByteArray_Check(self)), \ + Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_start : _PyByteArray_empty_string) +#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)), Py_SIZE(self)) + +PyAPI_DATA(char) _PyByteArray_empty_string[]; |
