Skip to main content

pyforge_ffi/
pystrtod.rs

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