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