1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use crate::object::{PyObject, PyTypeObject};
#[cfg(not(PyPy))]
use crate::pyport::Py_ssize_t;
use std::os::raw::{c_char, c_int};

#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyStructSequence_Field {
    pub name: *const c_char,
    pub doc: *const c_char,
}

#[repr(C)]
#[derive(Copy, Clone)]
pub struct PyStructSequence_Desc {
    pub name: *const c_char,
    pub doc: *const c_char,
    pub fields: *mut PyStructSequence_Field,
    pub n_in_sequence: c_int,
}

// skipped PyStructSequence_UnnamedField;

extern "C" {
    #[cfg(not(Py_LIMITED_API))]
    #[cfg_attr(PyPy, link_name = "PyPyStructSequence_InitType")]
    pub fn PyStructSequence_InitType(_type: *mut PyTypeObject, desc: *mut PyStructSequence_Desc);

    #[cfg(not(Py_LIMITED_API))]
    #[cfg_attr(PyPy, link_name = "PyPyStructSequence_InitType2")]
    pub fn PyStructSequence_InitType2(
        _type: *mut PyTypeObject,
        desc: *mut PyStructSequence_Desc,
    ) -> c_int;

    #[cfg(not(PyPy))]
    pub fn PyStructSequence_NewType(desc: *mut PyStructSequence_Desc) -> *mut PyTypeObject;
    #[cfg_attr(PyPy, link_name = "PyPyStructSequence_New")]
    pub fn PyStructSequence_New(_type: *mut PyTypeObject) -> *mut PyObject;
}

#[cfg(not(Py_LIMITED_API))]
pub type PyStructSequence = crate::PyTupleObject;

#[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))]
#[inline]
pub unsafe fn PyStructSequence_SET_ITEM(op: *mut PyObject, i: Py_ssize_t, v: *mut PyObject) {
    crate::PyTuple_SET_ITEM(op, i, v)
}

#[cfg(not(any(Py_LIMITED_API, PyPy, GraalPy)))]
#[inline]
pub unsafe fn PyStructSequence_GET_ITEM(op: *mut PyObject, i: Py_ssize_t) -> *mut PyObject {
    crate::PyTuple_GET_ITEM(op, i)
}

extern "C" {
    #[cfg(not(PyPy))]
    pub fn PyStructSequence_SetItem(arg1: *mut PyObject, arg2: Py_ssize_t, arg3: *mut PyObject);

    #[cfg(not(PyPy))]
    pub fn PyStructSequence_GetItem(arg1: *mut PyObject, arg2: Py_ssize_t) -> *mut PyObject;
}