Skip to main content

pyo3_ffi/
memoryobject.rs

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