1use crate::object::{PyObject, PyTypeObject};
2#[cfg(not(PyPy))]
3use crate::pyport::Py_ssize_t;
4use std::ffi::{c_char, c_int};
5
6#[repr(C)]
7#[derive(Copy, Clone)]
8pub struct PyStructSequence_Field {
9 pub name: *const c_char,
10 pub doc: *const c_char,
11}
12
13#[repr(C)]
14#[derive(Copy, Clone)]
15pub struct PyStructSequence_Desc {
16 pub name: *const c_char,
17 pub doc: *const c_char,
18 pub fields: *mut PyStructSequence_Field,
19 pub n_in_sequence: c_int,
20}
21
22extern_libpython! {
23 #[cfg(any(Py_3_11, all(Py_3_9, not(Py_LIMITED_API))))]
24 pub static PyStructSequence_UnnamedField: *const c_char;
25}
26
27extern_libpython! {
28 #[cfg(not(Py_LIMITED_API))]
29 #[cfg_attr(PyPy, link_name = "PyPyStructSequence_InitType")]
30 pub fn PyStructSequence_InitType(_type: *mut PyTypeObject, desc: *mut PyStructSequence_Desc);
31
32 #[cfg(not(Py_LIMITED_API))]
33 #[cfg_attr(PyPy, link_name = "PyPyStructSequence_InitType2")]
34 pub fn PyStructSequence_InitType2(
35 _type: *mut PyTypeObject,
36 desc: *mut PyStructSequence_Desc,
37 ) -> c_int;
38
39 #[cfg(not(PyPy))]
40 pub fn PyStructSequence_NewType(desc: *mut PyStructSequence_Desc) -> *mut PyTypeObject;
41 #[cfg_attr(PyPy, link_name = "PyPyStructSequence_New")]
42 pub fn PyStructSequence_New(_type: *mut PyTypeObject) -> *mut PyObject;
43}
44
45#[cfg(not(Py_LIMITED_API))]
46pub type PyStructSequence = crate::PyTupleObject;
47
48#[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))]
49#[inline]
50pub unsafe fn PyStructSequence_SET_ITEM(op: *mut PyObject, i: Py_ssize_t, v: *mut PyObject) {
51 crate::PyTuple_SET_ITEM(op, i, v)
52}
53
54#[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))]
55#[inline]
56pub unsafe fn PyStructSequence_GET_ITEM(op: *mut PyObject, i: Py_ssize_t) -> *mut PyObject {
57 crate::PyTuple_GET_ITEM(op, i)
58}
59
60extern_libpython! {
61 #[cfg(not(PyPy))]
62 pub fn PyStructSequence_SetItem(arg1: *mut PyObject, arg2: Py_ssize_t, arg3: *mut PyObject);
63
64 #[cfg(not(PyPy))]
65 pub fn PyStructSequence_GetItem(arg1: *mut PyObject, arg2: Py_ssize_t) -> *mut PyObject;
66}