pyo3_ffi/cpython/
genobject.rs1use crate::object::*;
2use crate::PyFrameObject;
3#[cfg(all(Py_3_11, not(any(PyPy, GraalPy))))]
4use std::os::raw::c_char;
5use std::os::raw::c_int;
6use std::ptr::addr_of_mut;
7
8#[cfg(not(any(PyPy, GraalPy)))]
9#[repr(C)]
10pub struct PyGenObject {
11 pub ob_base: PyObject,
12 #[cfg(not(Py_3_11))]
13 pub gi_frame: *mut PyFrameObject,
14 #[cfg(not(Py_3_10))]
15 pub gi_running: c_int,
16 #[cfg(not(Py_3_12))]
17 pub gi_code: *mut PyObject,
18 pub gi_weakreflist: *mut PyObject,
19 pub gi_name: *mut PyObject,
20 pub gi_qualname: *mut PyObject,
21 pub gi_exc_state: crate::cpython::pystate::_PyErr_StackItem,
22 #[cfg(Py_3_11)]
23 pub gi_origin_or_finalizer: *mut PyObject,
24 #[cfg(Py_3_11)]
25 pub gi_hooks_inited: c_char,
26 #[cfg(Py_3_11)]
27 pub gi_closed: c_char,
28 #[cfg(Py_3_11)]
29 pub gi_running_async: c_char,
30 #[cfg(Py_3_11)]
31 pub gi_frame_state: i8,
32 #[cfg(Py_3_11)]
33 pub gi_iframe: [*mut PyObject; 1],
34}
35
36#[cfg_attr(windows, link(name = "pythonXY"))]
37extern "C" {
38 pub static mut PyGen_Type: PyTypeObject;
39}
40
41#[inline]
42pub unsafe fn PyGen_Check(op: *mut PyObject) -> c_int {
43 PyObject_TypeCheck(op, addr_of_mut!(PyGen_Type))
44}
45
46#[inline]
47pub unsafe fn PyGen_CheckExact(op: *mut PyObject) -> c_int {
48 (Py_TYPE(op) == addr_of_mut!(PyGen_Type)) as c_int
49}
50
51extern "C" {
52 pub fn PyGen_New(frame: *mut PyFrameObject) -> *mut PyObject;
53 #[cfg(not(any(Py_3_9, PyPy)))]
59 #[deprecated(note = "This function was never documented in the Python API.")]
60 pub fn PyGen_NeedsFinalizing(op: *mut PyGenObject) -> c_int;
61}
62
63#[cfg_attr(windows, link(name = "pythonXY"))]
66extern "C" {
67 pub static mut PyCoro_Type: PyTypeObject;
68 pub static mut _PyCoroWrapper_Type: PyTypeObject;
69}
70
71#[inline]
72pub unsafe fn PyCoro_CheckExact(op: *mut PyObject) -> c_int {
73 PyObject_TypeCheck(op, addr_of_mut!(PyCoro_Type))
74}
75
76#[cfg_attr(windows, link(name = "pythonXY"))]
82extern "C" {
83 pub static mut PyAsyncGen_Type: PyTypeObject;
84 }
88
89#[inline]
92pub unsafe fn PyAsyncGen_CheckExact(op: *mut PyObject) -> c_int {
93 PyObject_TypeCheck(op, addr_of_mut!(PyAsyncGen_Type))
94}
95
96