1use crate::object::*;
2use crate::pyport::Py_ssize_t;
3use std::os::raw::{c_char, c_int};
4use std::ptr::addr_of_mut;
5
6#[cfg(not(any(PyPy, Py_LIMITED_API)))]
7#[repr(C)]
8#[derive(Copy, Clone)]
9pub struct PyByteArrayObject {
10 pub ob_base: PyVarObject,
11 pub ob_alloc: Py_ssize_t,
12 pub ob_bytes: *mut c_char,
13 pub ob_start: *mut c_char,
14 #[cfg(Py_3_9)]
15 pub ob_exports: Py_ssize_t,
16 #[cfg(not(Py_3_9))]
17 pub ob_exports: c_int,
18}
19
20#[cfg(any(PyPy, Py_LIMITED_API))]
21opaque_struct!(PyByteArrayObject);
22
23#[cfg_attr(windows, link(name = "pythonXY"))]
24extern "C" {
25 #[cfg_attr(PyPy, link_name = "PyPyByteArray_Type")]
26 pub static mut PyByteArray_Type: PyTypeObject;
27
28 pub static mut PyByteArrayIter_Type: PyTypeObject;
29}
30
31#[inline]
32pub unsafe fn PyByteArray_Check(op: *mut PyObject) -> c_int {
33 PyObject_TypeCheck(ob:op, tp:addr_of_mut!(PyByteArray_Type))
34}
35
36#[inline]
37pub unsafe fn PyByteArray_CheckExact(op: *mut PyObject) -> c_int {
38 (Py_TYPE(ob:op) == addr_of_mut!(PyByteArray_Type)) as c_int
39}
40
41extern "C" {
42 #[cfg_attr(PyPy, link_name = "PyPyByteArray_FromObject")]
43 pub fn PyByteArray_FromObject(o: *mut PyObject) -> *mut PyObject;
44 #[cfg_attr(PyPy, link_name = "PyPyByteArray_Concat")]
45 pub fn PyByteArray_Concat(a: *mut PyObject, b: *mut PyObject) -> *mut PyObject;
46 #[cfg_attr(PyPy, link_name = "PyPyByteArray_FromStringAndSize")]
47 pub fn PyByteArray_FromStringAndSize(string: *const c_char, len: Py_ssize_t) -> *mut PyObject;
48 #[cfg_attr(PyPy, link_name = "PyPyByteArray_Size")]
49 pub fn PyByteArray_Size(bytearray: *mut PyObject) -> Py_ssize_t;
50 #[cfg_attr(PyPy, link_name = "PyPyByteArray_AsString")]
51 pub fn PyByteArray_AsString(bytearray: *mut PyObject) -> *mut c_char;
52 #[cfg_attr(PyPy, link_name = "PyPyByteArray_Resize")]
53 pub fn PyByteArray_Resize(bytearray: *mut PyObject, len: Py_ssize_t) -> c_int;
54}
55