pyo3_ffi/cpython/
descrobject.rs1use crate::{PyGetSetDef, PyMethodDef, PyObject, PyTypeObject};
2use std::ffi::{c_char, c_int, c_void};
3
4#[cfg(Py_3_11)]
5use crate::PyMemberDef;
6
7pub type wrapperfunc = Option<
8 unsafe extern "C" fn(
9 slf: *mut PyObject,
10 args: *mut PyObject,
11 wrapped: *mut c_void,
12 ) -> *mut PyObject,
13>;
14
15pub type wrapperfunc_kwds = Option<
16 unsafe extern "C" fn(
17 slf: *mut PyObject,
18 args: *mut PyObject,
19 wrapped: *mut c_void,
20 kwds: *mut PyObject,
21 ) -> *mut PyObject,
22>;
23
24#[repr(C)]
25pub struct wrapperbase {
26 pub name: *const c_char,
27 pub offset: c_int,
28 pub function: *mut c_void,
29 pub wrapper: wrapperfunc,
30 pub doc: *const c_char,
31 pub flags: c_int,
32 pub name_strobj: *mut PyObject,
33}
34
35pub const PyWrapperFlag_KEYWORDS: c_int = 1;
36
37#[repr(C)]
38pub struct PyDescrObject {
39 pub ob_base: PyObject,
40 pub d_type: *mut PyTypeObject,
41 pub d_name: *mut PyObject,
42 pub d_qualname: *mut PyObject,
43}
44
45#[repr(C)]
49pub struct PyMethodDescrObject {
50 pub d_common: PyDescrObject,
51 pub d_method: *mut PyMethodDef,
52 #[cfg(all(not(PyPy), Py_3_8))]
53 pub vectorcall: Option<crate::vectorcallfunc>,
54}
55
56#[repr(C)]
57pub struct PyMemberDescrObject {
58 pub d_common: PyDescrObject,
59 #[cfg(not(Py_3_11))]
60 pub d_member: *mut PyGetSetDef,
61 #[cfg(Py_3_11)]
62 pub d_member: *mut PyMemberDef,
63}
64
65#[repr(C)]
66pub struct PyGetSetDescrObject {
67 pub d_common: PyDescrObject,
68 pub d_getset: *mut PyGetSetDef,
69}
70
71#[repr(C)]
72pub struct PyWrapperDescrObject {
73 pub d_common: PyDescrObject,
74 pub d_base: *mut wrapperbase,
75 pub d_wrapped: *mut c_void,
76}
77
78