1 | use crate::object::*; |
2 | #[cfg (not(PyPy))] |
3 | use crate::pyport::Py_ssize_t; |
4 | |
5 | #[repr (C)] |
6 | pub struct PyTupleObject { |
7 | pub ob_base: PyVarObject, |
8 | pub ob_item: [*mut PyObject; 1], |
9 | } |
10 | |
11 | // skipped _PyTuple_Resize |
12 | // skipped _PyTuple_MaybeUntrack |
13 | |
14 | /// Macro, trading safety for speed |
15 | |
16 | // skipped _PyTuple_CAST |
17 | |
18 | #[inline ] |
19 | #[cfg (not(PyPy))] |
20 | pub unsafe fn PyTuple_GET_SIZE(op: *mut PyObject) -> Py_ssize_t { |
21 | Py_SIZE(ob:op) |
22 | } |
23 | |
24 | #[inline ] |
25 | #[cfg (not(PyPy))] |
26 | pub unsafe fn PyTuple_GET_ITEM(op: *mut PyObject, i: Py_ssize_t) -> *mut PyObject { |
27 | *(*(op as *mut PyTupleObject)).ob_item.as_ptr().offset(count:i) |
28 | } |
29 | |
30 | /// Macro, *only* to be used to fill in brand new tuples |
31 | #[inline ] |
32 | #[cfg (not(PyPy))] |
33 | pub unsafe fn PyTuple_SET_ITEM(op: *mut PyObject, i: Py_ssize_t, v: *mut PyObject) { |
34 | *(*(op as *mut PyTupleObject)).ob_item.as_mut_ptr().offset(count:i) = v; |
35 | } |
36 | |
37 | // skipped _PyTuple_DebugMallocStats |
38 | |