| 1 |
use crate::object::*; |
| 2 |
use crate::PyFrameObject; |
| 3 |
#[cfg(all(Py_3_11, not(any(PyPy, GraalPy, Py_3_14))))] |
| 4 |
use std::ffi::c_char; |
| 5 |
use std::ffi::c_int; |
| 6 |
use std::ptr::addr_of_mut; |
| 7 |
|
| 8 |
#[cfg(not(any(PyPy, GraalPy, Py_3_14)))] |
| 9 |
#[repr(C)] |
| 10 |
pub 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 |
#[allow( |
| 22 |
private_interfaces, |
| 23 |
reason = "PyGenObject layout was public until 3.14" |
| 24 |
)] |
| 25 |
pub gi_exc_state: crate::cpython::pystate::_PyErr_StackItem, |
| 26 |
#[cfg(Py_3_11)] |
| 27 |
pub gi_origin_or_finalizer: *mut PyObject, |
| 28 |
#[cfg(Py_3_11)] |
| 29 |
pub gi_hooks_inited: c_char, |
| 30 |
#[cfg(Py_3_11)] |
| 31 |
pub gi_closed: c_char, |
| 32 |
#[cfg(Py_3_11)] |
| 33 |
pub gi_running_async: c_char, |
| 34 |
#[cfg(Py_3_11)] |
| 35 |
pub gi_frame_state: i8, |
| 36 |
#[cfg(Py_3_11)] |
| 37 |
pub gi_iframe: [*mut PyObject; 1], |
| 38 |
} |
| 39 |
|
| 40 |
#[cfg(all(Py_3_14, not(any(PyPy, GraalPy))))] |
| 41 |
opaque_struct!(pub PyGenObject); |
| 42 |
|
| 43 |
#[cfg_attr(windows, link(name = "pythonXY"))] |
| 44 |
extern "C" { |
| 45 |
pub static mut PyGen_Type: PyTypeObject; |
| 46 |
} |
| 47 |
|
| 48 |
#[inline] |
| 49 |
pub unsafe fn PyGen_Check(op: *mut PyObject) -> c_int { |
| 50 |
PyObject_TypeCheck(op, addr_of_mut!(PyGen_Type)) |
| 51 |
} |
| 52 |
|
| 53 |
#[inline] |
| 54 |
pub unsafe fn PyGen_CheckExact(op: *mut PyObject) -> c_int { |
| 55 |
(Py_TYPE(op) == addr_of_mut!(PyGen_Type)) as c_int |
| 56 |
} |
| 57 |
|
| 58 |
extern "C" { |
| 59 |
pub fn PyGen_New(frame: *mut PyFrameObject) -> *mut PyObject; |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
#[cfg(not(any(Py_3_9, PyPy)))] |
| 66 |
#[deprecated(note = "This function was never documented in the Python API.")] |
| 67 |
pub fn PyGen_NeedsFinalizing(op: *mut PyGenObject) -> c_int; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
#[cfg_attr(windows, link(name = "pythonXY"))] |
| 73 |
extern "C" { |
| 74 |
pub static mut PyCoro_Type: PyTypeObject; |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
#[inline] |
| 80 |
pub unsafe fn PyCoro_CheckExact(op: *mut PyObject) -> c_int { |
| 81 |
PyObject_TypeCheck(op, addr_of_mut!(PyCoro_Type)) |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
#[cfg_attr(windows, link(name = "pythonXY"))] |
| 90 |
extern "C" { |
| 91 |
pub static mut PyAsyncGen_Type: PyTypeObject; |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
} |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
#[inline] |
| 100 |
pub unsafe fn PyAsyncGen_CheckExact(op: *mut PyObject) -> c_int { |
| 101 |
PyObject_TypeCheck(op, addr_of_mut!(PyAsyncGen_Type)) |
| 102 |
} |
| 103 |
|
| 104 |
|