Skip to main content

pyo3_ffi/
longobject.rs

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