1 | use crate::object::*; |
2 | use crate::pyport::Py_ssize_t; |
3 | use std::os::raw::c_int; |
4 | use std::ptr::addr_of_mut; |
5 | |
6 | #[cfg_attr (windows, link(name = "pythonXY" ))] |
7 | extern "C" { |
8 | #[cfg_attr (PyPy, link_name = "PyPyList_Type" )] |
9 | pub static mut PyList_Type: PyTypeObject; |
10 | pub static mut PyListIter_Type: PyTypeObject; |
11 | pub static mut PyListRevIter_Type: PyTypeObject; |
12 | } |
13 | |
14 | #[inline ] |
15 | pub unsafe fn PyList_Check(op: *mut PyObject) -> c_int { |
16 | PyType_FastSubclass(t:Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS) |
17 | } |
18 | |
19 | #[inline ] |
20 | pub unsafe fn PyList_CheckExact(op: *mut PyObject) -> c_int { |
21 | (Py_TYPE(ob:op) == addr_of_mut!(PyList_Type)) as c_int |
22 | } |
23 | |
24 | extern "C" { |
25 | #[cfg_attr (PyPy, link_name = "PyPyList_New" )] |
26 | pub fn PyList_New(size: Py_ssize_t) -> *mut PyObject; |
27 | #[cfg_attr (PyPy, link_name = "PyPyList_Size" )] |
28 | pub fn PyList_Size(arg1: *mut PyObject) -> Py_ssize_t; |
29 | #[cfg_attr (PyPy, link_name = "PyPyList_GetItem" )] |
30 | pub fn PyList_GetItem(arg1: *mut PyObject, arg2: Py_ssize_t) -> *mut PyObject; |
31 | #[cfg_attr (PyPy, link_name = "PyPyList_SetItem" )] |
32 | pub fn PyList_SetItem(arg1: *mut PyObject, arg2: Py_ssize_t, arg3: *mut PyObject) -> c_int; |
33 | #[cfg_attr (PyPy, link_name = "PyPyList_Insert" )] |
34 | pub fn PyList_Insert(arg1: *mut PyObject, arg2: Py_ssize_t, arg3: *mut PyObject) -> c_int; |
35 | #[cfg_attr (PyPy, link_name = "PyPyList_Append" )] |
36 | pub fn PyList_Append(arg1: *mut PyObject, arg2: *mut PyObject) -> c_int; |
37 | #[cfg_attr (PyPy, link_name = "PyPyList_GetSlice" )] |
38 | pub fn PyList_GetSlice( |
39 | arg1: *mut PyObject, |
40 | arg2: Py_ssize_t, |
41 | arg3: Py_ssize_t, |
42 | ) -> *mut PyObject; |
43 | #[cfg_attr (PyPy, link_name = "PyPyList_SetSlice" )] |
44 | pub fn PyList_SetSlice( |
45 | arg1: *mut PyObject, |
46 | arg2: Py_ssize_t, |
47 | arg3: Py_ssize_t, |
48 | arg4: *mut PyObject, |
49 | ) -> c_int; |
50 | #[cfg_attr (PyPy, link_name = "PyPyList_Sort" )] |
51 | pub fn PyList_Sort(arg1: *mut PyObject) -> c_int; |
52 | #[cfg_attr (PyPy, link_name = "PyPyList_Reverse" )] |
53 | pub fn PyList_Reverse(arg1: *mut PyObject) -> c_int; |
54 | #[cfg_attr (PyPy, link_name = "PyPyList_AsTuple" )] |
55 | pub fn PyList_AsTuple(arg1: *mut PyObject) -> *mut PyObject; |
56 | |
57 | // CPython macros exported as functions on PyPy |
58 | #[cfg (PyPy)] |
59 | #[cfg_attr (PyPy, link_name = "PyPyList_GET_ITEM" )] |
60 | pub fn PyList_GET_ITEM(arg1: *mut PyObject, arg2: Py_ssize_t) -> *mut PyObject; |
61 | #[cfg (PyPy)] |
62 | #[cfg_attr (PyPy, link_name = "PyPyList_GET_SIZE" )] |
63 | pub fn PyList_GET_SIZE(arg1: *mut PyObject) -> Py_ssize_t; |
64 | #[cfg (PyPy)] |
65 | #[cfg_attr (PyPy, link_name = "PyPyList_SET_ITEM" )] |
66 | pub fn PyList_SET_ITEM(arg1: *mut PyObject, arg2: Py_ssize_t, arg3: *mut PyObject); |
67 | } |
68 | |