pyo3_ffi/
pystrtod.rs

1use crate::object::PyObject;
2use std::os::raw::{c_char, c_double, c_int};
3
4extern "C" {
5    #[cfg_attr(PyPy, link_name = "PyPyOS_string_to_double")]
6    pub fn PyOS_string_to_double(
7        str: *const c_char,
8        endptr: *mut *mut c_char,
9        overflow_exception: *mut PyObject,
10    ) -> c_double;
11    #[cfg_attr(PyPy, link_name = "PyPyOS_double_to_string")]
12    pub fn PyOS_double_to_string(
13        val: c_double,
14        format_code: c_char,
15        precision: c_int,
16        flags: c_int,
17        _type: *mut c_int,
18    ) -> *mut c_char;
19}
20
21// skipped non-limited _Py_string_to_number_with_underscores
22// skipped non-limited _Py_parse_inf_or_nan
23
24/* PyOS_double_to_string's "flags" parameter can be set to 0 or more of: */
25pub const Py_DTSF_SIGN: c_int = 0x01; /* always add the sign */
26pub const Py_DTSF_ADD_DOT_0: c_int = 0x02; /* if the result is an integer add ".0" */
27pub const Py_DTSF_ALT: c_int = 0x04; /* "alternate" formatting. it's format_code specific */
28
29/* PyOS_double_to_string's "type", if non-NULL, will be set to one of: */
30pub const Py_DTST_FINITE: c_int = 0;
31pub const Py_DTST_INFINITE: c_int = 1;
32pub const Py_DTST_NAN: c_int = 2;