1use crate::object::{PyObject, PyTypeObject};
2#[cfg(not(PyPy))]
3use crate::pyport::Py_ssize_t;
4use std::os::raw::{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
22// skipped PyStructSequence_UnnamedField;
23
24extern "C" {
25 #[cfg(not(Py_LIMITED_API))]
26 #[cfg_attr(PyPy, link_name = "PyPyStructSequence_InitType")]
27 pub fn PyStructSequence_InitType(_type: *mut PyTypeObject, desc: *mut PyStructSequence_Desc);
28
29 #[cfg(not(Py_LIMITED_API))]
30 #[cfg_attr(PyPy, link_name = "PyPyStructSequence_InitType2")]
31 pub fn PyStructSequence_InitType2(
32 _type: *mut PyTypeObject,
33 desc: *mut PyStructSequence_Desc,
34 ) -> c_int;
35
36 #[cfg(not(PyPy))]
37 pub fn PyStructSequence_NewType(desc: *mut PyStructSequence_Desc) -> *mut PyTypeObject;
38 #[cfg_attr(PyPy, link_name = "PyPyStructSequence_New")]
39 pub fn PyStructSequence_New(_type: *mut PyTypeObject) -> *mut PyObject;
40}
41
42#[cfg(not(Py_LIMITED_API))]
43pub type PyStructSequence = crate::PyTupleObject;
44
45#[cfg(not(any(Py_LIMITED_API, PyPy)))]
46#[inline]
47pub unsafe fn PyStructSequence_SET_ITEM(op: *mut PyObject, i: Py_ssize_t, v: *mut PyObject) {
48 crate::PyTuple_SET_ITEM(op, i, v)
49}
50
51#[cfg(not(any(Py_LIMITED_API, PyPy)))]
52#[inline]
53pub unsafe fn PyStructSequence_GET_ITEM(op: *mut PyObject, i: Py_ssize_t) -> *mut PyObject {
54 crate::PyTuple_GET_ITEM(op, i)
55}
56
57extern "C" {
58 #[cfg(not(PyPy))]
59 pub fn PyStructSequence_SetItem(arg1: *mut PyObject, arg2: Py_ssize_t, arg3: *mut PyObject);
60
61 #[cfg(not(PyPy))]
62 pub fn PyStructSequence_GetItem(arg1: *mut PyObject, arg2: Py_ssize_t) -> *mut PyObject;
63}
64