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_attr(windows, link(name = "pythonXY"))]
7extern "C" {
8 #[cfg(not(Py_LIMITED_API))]
9 pub static mut _PyManagedBuffer_Type: PyTypeObject;
10
11 #[cfg_attr(PyPy, link_name = "PyPyMemoryView_Type")]
12 pub static mut PyMemoryView_Type: PyTypeObject;
13}
14
15#[inline]
16pub unsafe fn PyMemoryView_Check(op: *mut PyObject) -> c_int {
17 (Py_TYPE(ob:op) == addr_of_mut!(PyMemoryView_Type)) as c_int
18}
19
20// skipped non-limited PyMemoryView_GET_BUFFER
21// skipped non-limited PyMemeryView_GET_BASE
22
23extern "C" {
24 #[cfg_attr(PyPy, link_name = "PyPyMemoryView_FromObject")]
25 pub fn PyMemoryView_FromObject(base: *mut PyObject) -> *mut PyObject;
26 #[cfg_attr(PyPy, link_name = "PyPyMemoryView_FromMemory")]
27 pub fn PyMemoryView_FromMemory(
28 mem: *mut c_char,
29 size: Py_ssize_t,
30 flags: c_int,
31 ) -> *mut PyObject;
32 // skipped non-limited PyMemoryView_FromBuffer
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! */
44