Skip to main content

pyforge_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    pub static mut PyMemoryView_Type: PyTypeObject;
9}
10
11#[inline]
12pub unsafe fn PyMemoryView_Check(op: *mut PyObject) -> c_int {
13    (Py_TYPE(op) == &raw mut PyMemoryView_Type) as c_int
14}
15
16// skipped non-limited PyMemoryView_GET_BUFFER
17// skipped non-limited PyMemoryView_GET_BASE
18
19extern_libpython! {
20    pub fn PyMemoryView_FromObject(base: *mut PyObject) -> *mut PyObject;
21    pub fn PyMemoryView_FromMemory(
22        mem: *mut c_char,
23        size: Py_ssize_t,
24        flags: c_int,
25    ) -> *mut PyObject;
26    #[cfg(any(Py_3_11, not(Py_LIMITED_API)))]
27    pub fn PyMemoryView_FromBuffer(view: *const crate::Py_buffer) -> *mut PyObject;
28    pub fn PyMemoryView_GetContiguous(
29        base: *mut PyObject,
30        buffertype: c_int,
31        order: c_char,
32    ) -> *mut PyObject;
33}
34
35// skipped remainder of file with comment:
36/* The structs are declared here so that macros can work, but they shouldn't
37be considered public. Don't access their fields directly, use the macros
38and functions instead! */