1 | use crate::object::*; |
2 | use std::os::raw::{c_char, c_int, c_void}; |
3 | use std::ptr::addr_of_mut; |
4 | |
5 | #[cfg_attr (windows, link(name = "pythonXY" ))] |
6 | extern "C" { |
7 | #[cfg_attr (PyPy, link_name = "PyPyCapsule_Type" )] |
8 | pub static mut PyCapsule_Type: PyTypeObject; |
9 | } |
10 | |
11 | pub type PyCapsule_Destructor = unsafe extern "C" fn(o: *mut PyObject); |
12 | |
13 | #[inline ] |
14 | pub unsafe fn PyCapsule_CheckExact(ob: *mut PyObject) -> c_int { |
15 | (Py_TYPE(ob) == addr_of_mut!(PyCapsule_Type)) as c_int |
16 | } |
17 | |
18 | extern "C" { |
19 | #[cfg_attr (PyPy, link_name = "PyPyCapsule_New" )] |
20 | pub fn PyCapsule_New( |
21 | pointer: *mut c_void, |
22 | name: *const c_char, |
23 | destructor: Option<PyCapsule_Destructor>, |
24 | ) -> *mut PyObject; |
25 | #[cfg_attr (PyPy, link_name = "PyPyCapsule_GetPointer" )] |
26 | pub fn PyCapsule_GetPointer(capsule: *mut PyObject, name: *const c_char) -> *mut c_void; |
27 | #[cfg_attr (PyPy, link_name = "PyPyCapsule_GetDestructor" )] |
28 | pub fn PyCapsule_GetDestructor(capsule: *mut PyObject) -> Option<PyCapsule_Destructor>; |
29 | #[cfg_attr (PyPy, link_name = "PyPyCapsule_GetName" )] |
30 | pub fn PyCapsule_GetName(capsule: *mut PyObject) -> *const c_char; |
31 | #[cfg_attr (PyPy, link_name = "PyPyCapsule_GetContext" )] |
32 | pub fn PyCapsule_GetContext(capsule: *mut PyObject) -> *mut c_void; |
33 | #[cfg_attr (PyPy, link_name = "PyPyCapsule_IsValid" )] |
34 | pub fn PyCapsule_IsValid(capsule: *mut PyObject, name: *const c_char) -> c_int; |
35 | #[cfg_attr (PyPy, link_name = "PyPyCapsule_SetPointer" )] |
36 | pub fn PyCapsule_SetPointer(capsule: *mut PyObject, pointer: *mut c_void) -> c_int; |
37 | #[cfg_attr (PyPy, link_name = "PyPyCapsule_SetDestructor" )] |
38 | pub fn PyCapsule_SetDestructor( |
39 | capsule: *mut PyObject, |
40 | destructor: Option<PyCapsule_Destructor>, |
41 | ) -> c_int; |
42 | #[cfg_attr (PyPy, link_name = "PyPyCapsule_SetName" )] |
43 | pub fn PyCapsule_SetName(capsule: *mut PyObject, name: *const c_char) -> c_int; |
44 | #[cfg_attr (PyPy, link_name = "PyPyCapsule_SetContext" )] |
45 | pub fn PyCapsule_SetContext(capsule: *mut PyObject, context: *mut c_void) -> c_int; |
46 | #[cfg_attr (PyPy, link_name = "PyPyCapsule_Import" )] |
47 | pub fn PyCapsule_Import(name: *const c_char, no_block: c_int) -> *mut c_void; |
48 | } |
49 | |