pyo3_ffi/
longobject.rs

1use crate::object::*;
2use crate::pyport::Py_ssize_t;
3use libc::size_t;
4use std::os::raw::{c_char, c_double, c_int, c_long, c_longlong, c_ulong, c_ulonglong, c_void};
5use std::ptr::addr_of_mut;
6
7opaque_struct!(PyLongObject);
8
9#[cfg_attr(windows, link(name = "pythonXY"))]
10extern "C" {
11    #[cfg_attr(PyPy, link_name = "PyPyLong_Type")]
12    pub static mut PyLong_Type: PyTypeObject;
13}
14
15#[inline]
16pub unsafe fn PyLong_Check(op: *mut PyObject) -> c_int {
17    PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS)
18}
19
20#[inline]
21pub unsafe fn PyLong_CheckExact(op: *mut PyObject) -> c_int {
22    (Py_TYPE(op) == addr_of_mut!(PyLong_Type)) as c_int
23}
24
25extern "C" {
26    #[cfg_attr(PyPy, link_name = "PyPyLong_FromLong")]
27    pub fn PyLong_FromLong(arg1: c_long) -> *mut PyObject;
28    #[cfg_attr(PyPy, link_name = "PyPyLong_FromUnsignedLong")]
29    pub fn PyLong_FromUnsignedLong(arg1: c_ulong) -> *mut PyObject;
30    #[cfg_attr(PyPy, link_name = "PyPyLong_FromSize_t")]
31    pub fn PyLong_FromSize_t(arg1: size_t) -> *mut PyObject;
32    #[cfg_attr(PyPy, link_name = "PyPyLong_FromSsize_t")]
33    pub fn PyLong_FromSsize_t(arg1: Py_ssize_t) -> *mut PyObject;
34    #[cfg_attr(PyPy, link_name = "PyPyLong_FromDouble")]
35    pub fn PyLong_FromDouble(arg1: c_double) -> *mut PyObject;
36    #[cfg_attr(PyPy, link_name = "PyPyLong_AsLong")]
37    pub fn PyLong_AsLong(arg1: *mut PyObject) -> c_long;
38    #[cfg_attr(PyPy, link_name = "PyPyLong_AsLongAndOverflow")]
39    pub fn PyLong_AsLongAndOverflow(arg1: *mut PyObject, arg2: *mut c_int) -> c_long;
40    #[cfg_attr(PyPy, link_name = "PyPyLong_AsSsize_t")]
41    pub fn PyLong_AsSsize_t(arg1: *mut PyObject) -> Py_ssize_t;
42    #[cfg_attr(PyPy, link_name = "PyPyLong_AsSize_t")]
43    pub fn PyLong_AsSize_t(arg1: *mut PyObject) -> size_t;
44    #[cfg_attr(PyPy, link_name = "PyPyLong_AsUnsignedLong")]
45    pub fn PyLong_AsUnsignedLong(arg1: *mut PyObject) -> c_ulong;
46    #[cfg_attr(PyPy, link_name = "PyPyLong_AsUnsignedLongMask")]
47    pub fn PyLong_AsUnsignedLongMask(arg1: *mut PyObject) -> c_ulong;
48    // skipped non-limited _PyLong_AsInt
49    pub fn PyLong_GetInfo() -> *mut PyObject;
50    // skipped PyLong_AS_LONG
51
52    // skipped PyLong_FromPid
53    // skipped PyLong_AsPid
54    // skipped _Py_PARSE_INTPTR
55    // skipped _Py_PARSE_UINTPTR
56
57    // skipped non-limited _PyLong_UnsignedShort_Converter
58    // skipped non-limited _PyLong_UnsignedInt_Converter
59    // skipped non-limited _PyLong_UnsignedLong_Converter
60    // skipped non-limited _PyLong_UnsignedLongLong_Converter
61    // skipped non-limited _PyLong_Size_t_Converter
62
63    // skipped non-limited _PyLong_DigitValue
64    // skipped non-limited _PyLong_Frexp
65
66    #[cfg_attr(PyPy, link_name = "PyPyLong_AsDouble")]
67    pub fn PyLong_AsDouble(arg1: *mut PyObject) -> c_double;
68    #[cfg_attr(PyPy, link_name = "PyPyLong_FromVoidPtr")]
69    pub fn PyLong_FromVoidPtr(arg1: *mut c_void) -> *mut PyObject;
70    #[cfg_attr(PyPy, link_name = "PyPyLong_AsVoidPtr")]
71    pub fn PyLong_AsVoidPtr(arg1: *mut PyObject) -> *mut c_void;
72    #[cfg_attr(PyPy, link_name = "PyPyLong_FromLongLong")]
73    pub fn PyLong_FromLongLong(arg1: c_longlong) -> *mut PyObject;
74    #[cfg_attr(PyPy, link_name = "PyPyLong_FromUnsignedLongLong")]
75    pub fn PyLong_FromUnsignedLongLong(arg1: c_ulonglong) -> *mut PyObject;
76    #[cfg_attr(PyPy, link_name = "PyPyLong_AsLongLong")]
77    pub fn PyLong_AsLongLong(arg1: *mut PyObject) -> c_longlong;
78    #[cfg_attr(PyPy, link_name = "PyPyLong_AsUnsignedLongLong")]
79    pub fn PyLong_AsUnsignedLongLong(arg1: *mut PyObject) -> c_ulonglong;
80    #[cfg_attr(PyPy, link_name = "PyPyLong_AsUnsignedLongLongMask")]
81    pub fn PyLong_AsUnsignedLongLongMask(arg1: *mut PyObject) -> c_ulonglong;
82    #[cfg_attr(PyPy, link_name = "PyPyLong_AsLongLongAndOverflow")]
83    pub fn PyLong_AsLongLongAndOverflow(arg1: *mut PyObject, arg2: *mut c_int) -> c_longlong;
84    #[cfg_attr(PyPy, link_name = "PyPyLong_FromString")]
85    pub fn PyLong_FromString(
86        arg1: *const c_char,
87        arg2: *mut *mut c_char,
88        arg3: c_int,
89    ) -> *mut PyObject;
90}
91
92#[cfg(not(Py_LIMITED_API))]
93extern "C" {
94    #[cfg_attr(PyPy, link_name = "_PyPyLong_NumBits")]
95    pub fn _PyLong_NumBits(obj: *mut PyObject) -> size_t;
96}
97
98// skipped non-limited _PyLong_Format
99// skipped non-limited _PyLong_FormatWriter
100// skipped non-limited _PyLong_FormatBytesWriter
101// skipped non-limited _PyLong_FormatAdvancedWriter
102
103extern "C" {
104    pub fn PyOS_strtoul(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_ulong;
105    pub fn PyOS_strtol(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_long;
106}
107
108// skipped non-limited _PyLong_Rshift
109// skipped non-limited _PyLong_Lshift