Skip to main content

pyo3_ffi/
memoryobject.rs

1use crate::object::*;
2use crate::pyport::Py_ssize_t;
3use std::ffi::{c_char, c_int};
4
5// skipped _PyManagedBuffer_Type
6
7extern_libpython! {
8    #[cfg_attr(PyPy, link_name = "PyPyMemoryView_Type")]
9    pub static mut PyMemoryView_Type: PyTypeObject;
10}
11
12#[inline]
13pub unsafe fn PyMemoryView_Check(op: *mut PyObject) -> c_int {
14    (Py_TYPE(op) == &raw mut PyMemoryView_Type) as c_int
15}
16
17// skipped non-limited PyMemoryView_GET_BUFFER
18// skipped non-limited PyMemoryView_GET_BASE
19
20extern_libpython! {
21    #[cfg_attr(PyPy, link_name = "PyPyMemoryView_FromObject")]
22    pub fn PyMemoryView_FromObject(base: *mut PyObject) -> *mut PyObject;
23    #[cfg_attr(PyPy, link_name = "PyPyMemoryView_FromMemory")]
24    pub fn PyMemoryView_FromMemory(
25        mem: *mut c_char,
26        size: Py_ssize_t,
27        flags: c_int,
28    ) -> *mut PyObject;
29    #[cfg(any(Py_3_11, not(Py_LIMITED_API)))]
30    #[cfg_attr(PyPy, link_name = "PyPyMemoryView_FromBuffer")]
31    pub fn PyMemoryView_FromBuffer(view: *const crate::Py_buffer) -> *mut PyObject;
32    #[cfg_attr(PyPy, link_name = "PyPyMemoryView_GetContiguous")]
33    pub fn PyMemoryView_GetContiguous(
34        base: *mut PyObject,
35        buffertype: c_int,
36        order: c_char,
37    ) -> *mut PyObject;
38}
39
40// skipped remainder of file with comment:
41/* The structs are declared here so that macros can work, but they shouldn't
42be considered public. Don't access their fields directly, use the macros
43and functions instead! */