Files
typthon/Include/cpython/bytearrayobject.h
copilot-swe-agent[bot] 42e2356c88 Fix incorrect replacements in Py_ to Ty_ renaming
Fixed several macros and constants that should not have been renamed:
- _Py_CAST, _Py_NULL, _Py_RVALUE (internal utility macros)
- Py_UNUSED (unused parameter macro)
- Py_EQ, Py_NE, Py_LT, Py_LE, Py_GT, Py_GE (comparison constants)
- Py_RETURN_* macros (NONE, TRUE, FALSE, NOTIMPLEMENTED, RICHCOMPARE)
- Py_READONLY, Py_ULL, Py_CONTEXT_SWITCHED
- TyGC_Head in generated clinic files

Build is still in progress with some remaining issues to resolve.

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
2025-12-29 17:44:05 +00:00

39 lines
1.2 KiB
C

#ifndef Ty_CPYTHON_BYTEARRAYOBJECT_H
# error "this header file must not be included directly"
#endif
/* Object layout */
typedef struct {
PyObject_VAR_HEAD
Ty_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 */
Ty_ssize_t ob_exports; /* How many buffer exports */
} PyByteArrayObject;
PyAPI_DATA(char) _PyByteArray_empty_string[];
/* Macros and static inline functions, trading safety for speed */
#define _PyByteArray_CAST(op) \
(assert(TyByteArray_Check(op)), _Py_CAST(PyByteArrayObject*, op))
static inline char* TyByteArray_AS_STRING(TyObject *op)
{
PyByteArrayObject *self = _PyByteArray_CAST(op);
if (Ty_SIZE(self)) {
return self->ob_start;
}
return _PyByteArray_empty_string;
}
#define TyByteArray_AS_STRING(self) TyByteArray_AS_STRING(_TyObject_CAST(self))
static inline Ty_ssize_t TyByteArray_GET_SIZE(TyObject *op) {
PyByteArrayObject *self = _PyByteArray_CAST(op);
#ifdef Ty_GIL_DISABLED
return _Ty_atomic_load_ssize_relaxed(&(_PyVarObject_CAST(self)->ob_size));
#else
return Ty_SIZE(self);
#endif
}
#define TyByteArray_GET_SIZE(self) TyByteArray_GET_SIZE(_TyObject_CAST(self))