MCPcopy Index your code
hub / github.com/RustPython/RustPython / localeconv

Function localeconv

crates/stdlib/src/locale.rs:174–223  ·  view source on GitHub ↗
(vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

172
173 #[pyfunction]
174 fn localeconv(vm: &VirtualMachine) -> PyResult<PyDictRef> {
175 let result = vm.ctx.new_dict();
176
177 unsafe {
178 macro_rules! set_string_field {
179 ($lc:expr, $field:ident) => {{
180 result.set_item(
181 stringify!($field),
182 pystr_from_raw_cstr(vm, (*$lc).$field)?,
183 vm,
184 )?
185 }};
186 }
187
188 macro_rules! set_int_field {
189 ($lc:expr, $field:ident) => {{ result.set_item(stringify!($field), vm.new_pyobj((*$lc).$field), vm)? }};
190 }
191
192 macro_rules! set_group_field {
193 ($lc:expr, $field:ident) => {{
194 result.set_item(
195 stringify!($field),
196 copy_grouping((*$lc).$field, vm).into(),
197 vm,
198 )?
199 }};
200 }
201
202 let lc = super::localeconv();
203 set_group_field!(lc, mon_grouping);
204 set_group_field!(lc, grouping);
205 set_int_field!(lc, int_frac_digits);
206 set_int_field!(lc, frac_digits);
207 set_int_field!(lc, p_cs_precedes);
208 set_int_field!(lc, p_sep_by_space);
209 set_int_field!(lc, n_cs_precedes);
210 set_int_field!(lc, p_sign_posn);
211 set_int_field!(lc, n_sign_posn);
212 set_string_field!(lc, decimal_point);
213 set_string_field!(lc, thousands_sep);
214 set_string_field!(lc, int_curr_symbol);
215 set_string_field!(lc, currency_symbol);
216 set_string_field!(lc, mon_decimal_point);
217 set_string_field!(lc, mon_thousands_sep);
218 set_int_field!(lc, n_sep_by_space);
219 set_string_field!(lc, positive_sign);
220 set_string_field!(lc, negative_sign);
221 }
222 Ok(result)
223 }
224
225 #[derive(FromArgs)]
226 struct LocaleArgs {

Callers 1

get_locale_infoFunction · 0.50

Calls 1

new_dictMethod · 0.80

Tested by

no test coverage detected