From 453f8f9d0b659f6e6cb9f2d6590073496c8a9be6 Mon Sep 17 00:00:00 2001 From: Filip Filmar Date: Tue, 23 Jun 2020 16:47:01 -0700 Subject: [PATCH] Added umisc types for fields. Issue #141 --- rust_icu_common/src/lib.rs | 24 ++ rust_icu_sys/bindgen/lib_63.rs | 359 +++++++++++++++++++++++++++ rust_icu_sys/bindgen/lib_64.rs | 372 ++++++++++++++++++++++++++++ rust_icu_sys/bindgen/lib_65.rs | 372 ++++++++++++++++++++++++++++ rust_icu_sys/bindgen/lib_66.rs | 372 ++++++++++++++++++++++++++++ rust_icu_sys/bindgen/lib_67.rs | 372 ++++++++++++++++++++++++++++ rust_icu_sys/bindgen/run_bindgen.sh | 2 + rust_icu_sys/build.rs | 2 + rust_icu_umsg/src/lib.rs | 26 +- rust_icu_unum/Cargo.toml | 7 + rust_icu_unum/src/lib.rs | 66 ++++- 11 files changed, 1947 insertions(+), 27 deletions(-) diff --git a/rust_icu_common/src/lib.rs b/rust_icu_common/src/lib.rs index 470dafe5..fda6c99c 100644 --- a/rust_icu_common/src/lib.rs +++ b/rust_icu_common/src/lib.rs @@ -17,6 +17,7 @@ //! At the moment, this crate contains the declaration of various errors use { + anyhow::anyhow, rust_icu_sys as sys, std::{ffi, os}, thiserror::Error, @@ -306,6 +307,8 @@ impl CStringVec { } } + + #[cfg(test)] mod tests { use super::*; @@ -333,3 +336,24 @@ mod tests { let _c_array = CStringVec::new(&values).expect_err("should fail"); } } + +/// A zero-value parse error, used to initialize types that get passed into FFI code. +pub static NO_PARSE_ERROR: sys::UParseError = sys::UParseError { + line: 0, + offset: 0, + preContext: [0; 16usize], + postContext: [0; 16usize], +}; + +/// Converts a parse error to a Result. +pub fn parse_ok(e: sys::UParseError) -> Result<(), crate::Error> { + if e == NO_PARSE_ERROR { + return Ok(()); + } + Err(Error::Wrapper(anyhow!( + "parse error: line: {}, offset: {}", + e.line, + e.offset + ))) +} + diff --git a/rust_icu_sys/bindgen/lib_63.rs b/rust_icu_sys/bindgen/lib_63.rs index 80bc8dc9..bb0d7cbd 100644 --- a/rust_icu_sys/bindgen/lib_63.rs +++ b/rust_icu_sys/bindgen/lib_63.rs @@ -2366,6 +2366,365 @@ pub struct UFieldPositionIterator { _unused: [u8; 0], } pub type UNumberFormat = *mut ::std::os::raw::c_void; +impl UNumberFormatStyle { + pub const UNUM_DEFAULT: UNumberFormatStyle = UNumberFormatStyle::UNUM_DECIMAL; +} +impl UNumberFormatStyle { + pub const UNUM_IGNORE: UNumberFormatStyle = UNumberFormatStyle::UNUM_PATTERN_DECIMAL; +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatStyle { + UNUM_PATTERN_DECIMAL = 0, + UNUM_DECIMAL = 1, + UNUM_CURRENCY = 2, + UNUM_PERCENT = 3, + UNUM_SCIENTIFIC = 4, + UNUM_SPELLOUT = 5, + UNUM_ORDINAL = 6, + UNUM_DURATION = 7, + UNUM_NUMBERING_SYSTEM = 8, + UNUM_PATTERN_RULEBASED = 9, + UNUM_CURRENCY_ISO = 10, + UNUM_CURRENCY_PLURAL = 11, + UNUM_CURRENCY_ACCOUNTING = 12, + UNUM_CASH_CURRENCY = 13, + UNUM_DECIMAL_COMPACT_SHORT = 14, + UNUM_DECIMAL_COMPACT_LONG = 15, + UNUM_CURRENCY_STANDARD = 16, + UNUM_FORMAT_STYLE_COUNT = 17, +} +extern "C" { + pub fn unum_open_63( + style: UNumberFormatStyle, + pattern: *const UChar, + patternLength: i32, + locale: *const ::std::os::raw::c_char, + parseErr: *mut UParseError, + status: *mut UErrorCode, + ) -> *mut UNumberFormat; +} +extern "C" { + pub fn unum_close_63(fmt: *mut UNumberFormat); +} +extern "C" { + pub fn unum_clone_63(fmt: *const UNumberFormat, status: *mut UErrorCode) -> *mut UNumberFormat; +} +extern "C" { + pub fn unum_format_63( + fmt: *const UNumberFormat, + number: i32, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatInt64_63( + fmt: *const UNumberFormat, + number: i64, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDouble_63( + fmt: *const UNumberFormat, + number: f64, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDoubleForFields_63( + format: *const UNumberFormat, + number: f64, + result: *mut UChar, + resultLength: i32, + fpositer: *mut UFieldPositionIterator, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDecimal_63( + fmt: *const UNumberFormat, + number: *const ::std::os::raw::c_char, + length: i32, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDoubleCurrency_63( + fmt: *const UNumberFormat, + number: f64, + currency: *mut UChar, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatUFormattable_63( + fmt: *const UNumberFormat, + number: *const UFormattable, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_parse_63( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_parseInt64_63( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> i64; +} +extern "C" { + pub fn unum_parseDouble_63( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> f64; +} +extern "C" { + pub fn unum_parseDecimal_63( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + outBuf: *mut ::std::os::raw::c_char, + outBufLength: i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_parseDoubleCurrency_63( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + currency: *mut UChar, + status: *mut UErrorCode, + ) -> f64; +} +extern "C" { + pub fn unum_parseToUFormattable_63( + fmt: *const UNumberFormat, + result: *mut UFormattable, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> *mut UFormattable; +} +extern "C" { + pub fn unum_applyPattern_63( + format: *mut UNumberFormat, + localized: UBool, + pattern: *const UChar, + patternLength: i32, + parseError: *mut UParseError, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_getAvailable_63(localeIndex: i32) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn unum_countAvailable_63() -> i32; +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatAttribute { + UNUM_PARSE_INT_ONLY = 0, + UNUM_GROUPING_USED = 1, + UNUM_DECIMAL_ALWAYS_SHOWN = 2, + UNUM_MAX_INTEGER_DIGITS = 3, + UNUM_MIN_INTEGER_DIGITS = 4, + UNUM_INTEGER_DIGITS = 5, + UNUM_MAX_FRACTION_DIGITS = 6, + UNUM_MIN_FRACTION_DIGITS = 7, + UNUM_FRACTION_DIGITS = 8, + UNUM_MULTIPLIER = 9, + UNUM_GROUPING_SIZE = 10, + UNUM_ROUNDING_MODE = 11, + UNUM_ROUNDING_INCREMENT = 12, + UNUM_FORMAT_WIDTH = 13, + UNUM_PADDING_POSITION = 14, + UNUM_SECONDARY_GROUPING_SIZE = 15, + UNUM_SIGNIFICANT_DIGITS_USED = 16, + UNUM_MIN_SIGNIFICANT_DIGITS = 17, + UNUM_MAX_SIGNIFICANT_DIGITS = 18, + UNUM_LENIENT_PARSE = 19, + UNUM_PARSE_ALL_INPUT = 20, + UNUM_SCALE = 21, + UNUM_MINIMUM_GROUPING_DIGITS = 22, + UNUM_CURRENCY_USAGE = 23, + UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 4095, + UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS = 4096, + UNUM_PARSE_NO_EXPONENT = 4097, + UNUM_PARSE_DECIMAL_MARK_REQUIRED = 4098, + UNUM_LIMIT_BOOLEAN_ATTRIBUTE = 4099, + UNUM_PARSE_CASE_SENSITIVE = 4100, + UNUM_SIGN_ALWAYS_SHOWN = 4101, +} +extern "C" { + pub fn unum_getAttribute_63(fmt: *const UNumberFormat, attr: UNumberFormatAttribute) -> i32; +} +extern "C" { + pub fn unum_setAttribute_63( + fmt: *mut UNumberFormat, + attr: UNumberFormatAttribute, + newValue: i32, + ); +} +extern "C" { + pub fn unum_getDoubleAttribute_63( + fmt: *const UNumberFormat, + attr: UNumberFormatAttribute, + ) -> f64; +} +extern "C" { + pub fn unum_setDoubleAttribute_63( + fmt: *mut UNumberFormat, + attr: UNumberFormatAttribute, + newValue: f64, + ); +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatTextAttribute { + UNUM_POSITIVE_PREFIX = 0, + UNUM_POSITIVE_SUFFIX = 1, + UNUM_NEGATIVE_PREFIX = 2, + UNUM_NEGATIVE_SUFFIX = 3, + UNUM_PADDING_CHARACTER = 4, + UNUM_CURRENCY_CODE = 5, + UNUM_DEFAULT_RULESET = 6, + UNUM_PUBLIC_RULESETS = 7, +} +extern "C" { + pub fn unum_getTextAttribute_63( + fmt: *const UNumberFormat, + tag: UNumberFormatTextAttribute, + result: *mut UChar, + resultLength: i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_setTextAttribute_63( + fmt: *mut UNumberFormat, + tag: UNumberFormatTextAttribute, + newValue: *const UChar, + newValueLength: i32, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_toPattern_63( + fmt: *const UNumberFormat, + isPatternLocalized: UBool, + result: *mut UChar, + resultLength: i32, + status: *mut UErrorCode, + ) -> i32; +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatSymbol { + UNUM_DECIMAL_SEPARATOR_SYMBOL = 0, + UNUM_GROUPING_SEPARATOR_SYMBOL = 1, + UNUM_PATTERN_SEPARATOR_SYMBOL = 2, + UNUM_PERCENT_SYMBOL = 3, + UNUM_ZERO_DIGIT_SYMBOL = 4, + UNUM_DIGIT_SYMBOL = 5, + UNUM_MINUS_SIGN_SYMBOL = 6, + UNUM_PLUS_SIGN_SYMBOL = 7, + UNUM_CURRENCY_SYMBOL = 8, + UNUM_INTL_CURRENCY_SYMBOL = 9, + UNUM_MONETARY_SEPARATOR_SYMBOL = 10, + UNUM_EXPONENTIAL_SYMBOL = 11, + UNUM_PERMILL_SYMBOL = 12, + UNUM_PAD_ESCAPE_SYMBOL = 13, + UNUM_INFINITY_SYMBOL = 14, + UNUM_NAN_SYMBOL = 15, + UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16, + UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17, + UNUM_ONE_DIGIT_SYMBOL = 18, + UNUM_TWO_DIGIT_SYMBOL = 19, + UNUM_THREE_DIGIT_SYMBOL = 20, + UNUM_FOUR_DIGIT_SYMBOL = 21, + UNUM_FIVE_DIGIT_SYMBOL = 22, + UNUM_SIX_DIGIT_SYMBOL = 23, + UNUM_SEVEN_DIGIT_SYMBOL = 24, + UNUM_EIGHT_DIGIT_SYMBOL = 25, + UNUM_NINE_DIGIT_SYMBOL = 26, + UNUM_EXPONENT_MULTIPLICATION_SYMBOL = 27, + UNUM_FORMAT_SYMBOL_COUNT = 28, +} +extern "C" { + pub fn unum_getSymbol_63( + fmt: *const UNumberFormat, + symbol: UNumberFormatSymbol, + buffer: *mut UChar, + size: i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_setSymbol_63( + fmt: *mut UNumberFormat, + symbol: UNumberFormatSymbol, + value: *const UChar, + length: i32, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_getLocaleByType_63( + fmt: *const UNumberFormat, + type_: ULocDataLocaleType, + status: *mut UErrorCode, + ) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn unum_setContext_63( + fmt: *mut UNumberFormat, + value: UDisplayContext, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_getContext_63( + fmt: *const UNumberFormat, + type_: UDisplayContextType, + status: *mut UErrorCode, + ) -> UDisplayContext; +} pub type UDateFormat = *mut ::std::os::raw::c_void; impl UDateFormatStyle { pub const UDAT_DEFAULT: UDateFormatStyle = UDateFormatStyle::UDAT_MEDIUM; diff --git a/rust_icu_sys/bindgen/lib_64.rs b/rust_icu_sys/bindgen/lib_64.rs index 0aaede60..647bdff1 100644 --- a/rust_icu_sys/bindgen/lib_64.rs +++ b/rust_icu_sys/bindgen/lib_64.rs @@ -2366,6 +2366,365 @@ pub struct UFieldPositionIterator { _unused: [u8; 0], } pub type UNumberFormat = *mut ::std::os::raw::c_void; +impl UNumberFormatStyle { + pub const UNUM_DEFAULT: UNumberFormatStyle = UNumberFormatStyle::UNUM_DECIMAL; +} +impl UNumberFormatStyle { + pub const UNUM_IGNORE: UNumberFormatStyle = UNumberFormatStyle::UNUM_PATTERN_DECIMAL; +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatStyle { + UNUM_PATTERN_DECIMAL = 0, + UNUM_DECIMAL = 1, + UNUM_CURRENCY = 2, + UNUM_PERCENT = 3, + UNUM_SCIENTIFIC = 4, + UNUM_SPELLOUT = 5, + UNUM_ORDINAL = 6, + UNUM_DURATION = 7, + UNUM_NUMBERING_SYSTEM = 8, + UNUM_PATTERN_RULEBASED = 9, + UNUM_CURRENCY_ISO = 10, + UNUM_CURRENCY_PLURAL = 11, + UNUM_CURRENCY_ACCOUNTING = 12, + UNUM_CASH_CURRENCY = 13, + UNUM_DECIMAL_COMPACT_SHORT = 14, + UNUM_DECIMAL_COMPACT_LONG = 15, + UNUM_CURRENCY_STANDARD = 16, + UNUM_FORMAT_STYLE_COUNT = 17, +} +extern "C" { + pub fn unum_open_64( + style: UNumberFormatStyle, + pattern: *const UChar, + patternLength: i32, + locale: *const ::std::os::raw::c_char, + parseErr: *mut UParseError, + status: *mut UErrorCode, + ) -> *mut UNumberFormat; +} +extern "C" { + pub fn unum_close_64(fmt: *mut UNumberFormat); +} +extern "C" { + pub fn unum_clone_64(fmt: *const UNumberFormat, status: *mut UErrorCode) -> *mut UNumberFormat; +} +extern "C" { + pub fn unum_format_64( + fmt: *const UNumberFormat, + number: i32, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatInt64_64( + fmt: *const UNumberFormat, + number: i64, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDouble_64( + fmt: *const UNumberFormat, + number: f64, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDoubleForFields_64( + format: *const UNumberFormat, + number: f64, + result: *mut UChar, + resultLength: i32, + fpositer: *mut UFieldPositionIterator, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDecimal_64( + fmt: *const UNumberFormat, + number: *const ::std::os::raw::c_char, + length: i32, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDoubleCurrency_64( + fmt: *const UNumberFormat, + number: f64, + currency: *mut UChar, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatUFormattable_64( + fmt: *const UNumberFormat, + number: *const UFormattable, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_parse_64( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_parseInt64_64( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> i64; +} +extern "C" { + pub fn unum_parseDouble_64( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> f64; +} +extern "C" { + pub fn unum_parseDecimal_64( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + outBuf: *mut ::std::os::raw::c_char, + outBufLength: i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_parseDoubleCurrency_64( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + currency: *mut UChar, + status: *mut UErrorCode, + ) -> f64; +} +extern "C" { + pub fn unum_parseToUFormattable_64( + fmt: *const UNumberFormat, + result: *mut UFormattable, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> *mut UFormattable; +} +extern "C" { + pub fn unum_applyPattern_64( + format: *mut UNumberFormat, + localized: UBool, + pattern: *const UChar, + patternLength: i32, + parseError: *mut UParseError, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_getAvailable_64(localeIndex: i32) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn unum_countAvailable_64() -> i32; +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatAttribute { + UNUM_PARSE_INT_ONLY = 0, + UNUM_GROUPING_USED = 1, + UNUM_DECIMAL_ALWAYS_SHOWN = 2, + UNUM_MAX_INTEGER_DIGITS = 3, + UNUM_MIN_INTEGER_DIGITS = 4, + UNUM_INTEGER_DIGITS = 5, + UNUM_MAX_FRACTION_DIGITS = 6, + UNUM_MIN_FRACTION_DIGITS = 7, + UNUM_FRACTION_DIGITS = 8, + UNUM_MULTIPLIER = 9, + UNUM_GROUPING_SIZE = 10, + UNUM_ROUNDING_MODE = 11, + UNUM_ROUNDING_INCREMENT = 12, + UNUM_FORMAT_WIDTH = 13, + UNUM_PADDING_POSITION = 14, + UNUM_SECONDARY_GROUPING_SIZE = 15, + UNUM_SIGNIFICANT_DIGITS_USED = 16, + UNUM_MIN_SIGNIFICANT_DIGITS = 17, + UNUM_MAX_SIGNIFICANT_DIGITS = 18, + UNUM_LENIENT_PARSE = 19, + UNUM_PARSE_ALL_INPUT = 20, + UNUM_SCALE = 21, + UNUM_MINIMUM_GROUPING_DIGITS = 22, + UNUM_CURRENCY_USAGE = 23, + UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 4095, + UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS = 4096, + UNUM_PARSE_NO_EXPONENT = 4097, + UNUM_PARSE_DECIMAL_MARK_REQUIRED = 4098, + UNUM_PARSE_CASE_SENSITIVE = 4099, + UNUM_SIGN_ALWAYS_SHOWN = 4100, + UNUM_LIMIT_BOOLEAN_ATTRIBUTE = 4101, +} +extern "C" { + pub fn unum_getAttribute_64(fmt: *const UNumberFormat, attr: UNumberFormatAttribute) -> i32; +} +extern "C" { + pub fn unum_setAttribute_64( + fmt: *mut UNumberFormat, + attr: UNumberFormatAttribute, + newValue: i32, + ); +} +extern "C" { + pub fn unum_getDoubleAttribute_64( + fmt: *const UNumberFormat, + attr: UNumberFormatAttribute, + ) -> f64; +} +extern "C" { + pub fn unum_setDoubleAttribute_64( + fmt: *mut UNumberFormat, + attr: UNumberFormatAttribute, + newValue: f64, + ); +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatTextAttribute { + UNUM_POSITIVE_PREFIX = 0, + UNUM_POSITIVE_SUFFIX = 1, + UNUM_NEGATIVE_PREFIX = 2, + UNUM_NEGATIVE_SUFFIX = 3, + UNUM_PADDING_CHARACTER = 4, + UNUM_CURRENCY_CODE = 5, + UNUM_DEFAULT_RULESET = 6, + UNUM_PUBLIC_RULESETS = 7, +} +extern "C" { + pub fn unum_getTextAttribute_64( + fmt: *const UNumberFormat, + tag: UNumberFormatTextAttribute, + result: *mut UChar, + resultLength: i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_setTextAttribute_64( + fmt: *mut UNumberFormat, + tag: UNumberFormatTextAttribute, + newValue: *const UChar, + newValueLength: i32, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_toPattern_64( + fmt: *const UNumberFormat, + isPatternLocalized: UBool, + result: *mut UChar, + resultLength: i32, + status: *mut UErrorCode, + ) -> i32; +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatSymbol { + UNUM_DECIMAL_SEPARATOR_SYMBOL = 0, + UNUM_GROUPING_SEPARATOR_SYMBOL = 1, + UNUM_PATTERN_SEPARATOR_SYMBOL = 2, + UNUM_PERCENT_SYMBOL = 3, + UNUM_ZERO_DIGIT_SYMBOL = 4, + UNUM_DIGIT_SYMBOL = 5, + UNUM_MINUS_SIGN_SYMBOL = 6, + UNUM_PLUS_SIGN_SYMBOL = 7, + UNUM_CURRENCY_SYMBOL = 8, + UNUM_INTL_CURRENCY_SYMBOL = 9, + UNUM_MONETARY_SEPARATOR_SYMBOL = 10, + UNUM_EXPONENTIAL_SYMBOL = 11, + UNUM_PERMILL_SYMBOL = 12, + UNUM_PAD_ESCAPE_SYMBOL = 13, + UNUM_INFINITY_SYMBOL = 14, + UNUM_NAN_SYMBOL = 15, + UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16, + UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17, + UNUM_ONE_DIGIT_SYMBOL = 18, + UNUM_TWO_DIGIT_SYMBOL = 19, + UNUM_THREE_DIGIT_SYMBOL = 20, + UNUM_FOUR_DIGIT_SYMBOL = 21, + UNUM_FIVE_DIGIT_SYMBOL = 22, + UNUM_SIX_DIGIT_SYMBOL = 23, + UNUM_SEVEN_DIGIT_SYMBOL = 24, + UNUM_EIGHT_DIGIT_SYMBOL = 25, + UNUM_NINE_DIGIT_SYMBOL = 26, + UNUM_EXPONENT_MULTIPLICATION_SYMBOL = 27, + UNUM_FORMAT_SYMBOL_COUNT = 28, +} +extern "C" { + pub fn unum_getSymbol_64( + fmt: *const UNumberFormat, + symbol: UNumberFormatSymbol, + buffer: *mut UChar, + size: i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_setSymbol_64( + fmt: *mut UNumberFormat, + symbol: UNumberFormatSymbol, + value: *const UChar, + length: i32, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_getLocaleByType_64( + fmt: *const UNumberFormat, + type_: ULocDataLocaleType, + status: *mut UErrorCode, + ) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn unum_setContext_64( + fmt: *mut UNumberFormat, + value: UDisplayContext, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_getContext_64( + fmt: *const UNumberFormat, + type_: UDisplayContextType, + status: *mut UErrorCode, + ) -> UDisplayContext; +} pub type UDateFormat = *mut ::std::os::raw::c_void; impl UDateFormatStyle { pub const UDAT_DEFAULT: UDateFormatStyle = UDateFormatStyle::UDAT_MEDIUM; @@ -2913,6 +3272,19 @@ pub enum UDataFileAccess { extern "C" { pub fn udata_setFileAccess_64(access: UDataFileAccess, status: *mut UErrorCode); } +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UFieldCategory { + UFIELD_CATEGORY_UNDEFINED = 0, + UFIELD_CATEGORY_DATE = 1, + UFIELD_CATEGORY_NUMBER = 2, + UFIELD_CATEGORY_LIST = 3, + UFIELD_CATEGORY_RELATIVE_DATETIME = 4, + UFIELD_CATEGORY_DATE_INTERVAL = 5, + UFIELD_CATEGORY_COUNT = 6, + UFIELD_CATEGORY_LIST_SPAN = 4099, + UFIELD_CATEGORY_DATE_INTERVAL_SPAN = 4101, +} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct UFormattedValue { diff --git a/rust_icu_sys/bindgen/lib_65.rs b/rust_icu_sys/bindgen/lib_65.rs index 77b09d92..c8b241fc 100644 --- a/rust_icu_sys/bindgen/lib_65.rs +++ b/rust_icu_sys/bindgen/lib_65.rs @@ -2387,6 +2387,365 @@ pub struct UFieldPositionIterator { _unused: [u8; 0], } pub type UNumberFormat = *mut ::std::os::raw::c_void; +impl UNumberFormatStyle { + pub const UNUM_DEFAULT: UNumberFormatStyle = UNumberFormatStyle::UNUM_DECIMAL; +} +impl UNumberFormatStyle { + pub const UNUM_IGNORE: UNumberFormatStyle = UNumberFormatStyle::UNUM_PATTERN_DECIMAL; +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatStyle { + UNUM_PATTERN_DECIMAL = 0, + UNUM_DECIMAL = 1, + UNUM_CURRENCY = 2, + UNUM_PERCENT = 3, + UNUM_SCIENTIFIC = 4, + UNUM_SPELLOUT = 5, + UNUM_ORDINAL = 6, + UNUM_DURATION = 7, + UNUM_NUMBERING_SYSTEM = 8, + UNUM_PATTERN_RULEBASED = 9, + UNUM_CURRENCY_ISO = 10, + UNUM_CURRENCY_PLURAL = 11, + UNUM_CURRENCY_ACCOUNTING = 12, + UNUM_CASH_CURRENCY = 13, + UNUM_DECIMAL_COMPACT_SHORT = 14, + UNUM_DECIMAL_COMPACT_LONG = 15, + UNUM_CURRENCY_STANDARD = 16, + UNUM_FORMAT_STYLE_COUNT = 17, +} +extern "C" { + pub fn unum_open_65( + style: UNumberFormatStyle, + pattern: *const UChar, + patternLength: i32, + locale: *const ::std::os::raw::c_char, + parseErr: *mut UParseError, + status: *mut UErrorCode, + ) -> *mut UNumberFormat; +} +extern "C" { + pub fn unum_close_65(fmt: *mut UNumberFormat); +} +extern "C" { + pub fn unum_clone_65(fmt: *const UNumberFormat, status: *mut UErrorCode) -> *mut UNumberFormat; +} +extern "C" { + pub fn unum_format_65( + fmt: *const UNumberFormat, + number: i32, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatInt64_65( + fmt: *const UNumberFormat, + number: i64, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDouble_65( + fmt: *const UNumberFormat, + number: f64, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDoubleForFields_65( + format: *const UNumberFormat, + number: f64, + result: *mut UChar, + resultLength: i32, + fpositer: *mut UFieldPositionIterator, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDecimal_65( + fmt: *const UNumberFormat, + number: *const ::std::os::raw::c_char, + length: i32, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDoubleCurrency_65( + fmt: *const UNumberFormat, + number: f64, + currency: *mut UChar, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatUFormattable_65( + fmt: *const UNumberFormat, + number: *const UFormattable, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_parse_65( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_parseInt64_65( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> i64; +} +extern "C" { + pub fn unum_parseDouble_65( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> f64; +} +extern "C" { + pub fn unum_parseDecimal_65( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + outBuf: *mut ::std::os::raw::c_char, + outBufLength: i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_parseDoubleCurrency_65( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + currency: *mut UChar, + status: *mut UErrorCode, + ) -> f64; +} +extern "C" { + pub fn unum_parseToUFormattable_65( + fmt: *const UNumberFormat, + result: *mut UFormattable, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> *mut UFormattable; +} +extern "C" { + pub fn unum_applyPattern_65( + format: *mut UNumberFormat, + localized: UBool, + pattern: *const UChar, + patternLength: i32, + parseError: *mut UParseError, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_getAvailable_65(localeIndex: i32) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn unum_countAvailable_65() -> i32; +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatAttribute { + UNUM_PARSE_INT_ONLY = 0, + UNUM_GROUPING_USED = 1, + UNUM_DECIMAL_ALWAYS_SHOWN = 2, + UNUM_MAX_INTEGER_DIGITS = 3, + UNUM_MIN_INTEGER_DIGITS = 4, + UNUM_INTEGER_DIGITS = 5, + UNUM_MAX_FRACTION_DIGITS = 6, + UNUM_MIN_FRACTION_DIGITS = 7, + UNUM_FRACTION_DIGITS = 8, + UNUM_MULTIPLIER = 9, + UNUM_GROUPING_SIZE = 10, + UNUM_ROUNDING_MODE = 11, + UNUM_ROUNDING_INCREMENT = 12, + UNUM_FORMAT_WIDTH = 13, + UNUM_PADDING_POSITION = 14, + UNUM_SECONDARY_GROUPING_SIZE = 15, + UNUM_SIGNIFICANT_DIGITS_USED = 16, + UNUM_MIN_SIGNIFICANT_DIGITS = 17, + UNUM_MAX_SIGNIFICANT_DIGITS = 18, + UNUM_LENIENT_PARSE = 19, + UNUM_PARSE_ALL_INPUT = 20, + UNUM_SCALE = 21, + UNUM_MINIMUM_GROUPING_DIGITS = 22, + UNUM_CURRENCY_USAGE = 23, + UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 4095, + UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS = 4096, + UNUM_PARSE_NO_EXPONENT = 4097, + UNUM_PARSE_DECIMAL_MARK_REQUIRED = 4098, + UNUM_PARSE_CASE_SENSITIVE = 4099, + UNUM_SIGN_ALWAYS_SHOWN = 4100, + UNUM_LIMIT_BOOLEAN_ATTRIBUTE = 4101, +} +extern "C" { + pub fn unum_getAttribute_65(fmt: *const UNumberFormat, attr: UNumberFormatAttribute) -> i32; +} +extern "C" { + pub fn unum_setAttribute_65( + fmt: *mut UNumberFormat, + attr: UNumberFormatAttribute, + newValue: i32, + ); +} +extern "C" { + pub fn unum_getDoubleAttribute_65( + fmt: *const UNumberFormat, + attr: UNumberFormatAttribute, + ) -> f64; +} +extern "C" { + pub fn unum_setDoubleAttribute_65( + fmt: *mut UNumberFormat, + attr: UNumberFormatAttribute, + newValue: f64, + ); +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatTextAttribute { + UNUM_POSITIVE_PREFIX = 0, + UNUM_POSITIVE_SUFFIX = 1, + UNUM_NEGATIVE_PREFIX = 2, + UNUM_NEGATIVE_SUFFIX = 3, + UNUM_PADDING_CHARACTER = 4, + UNUM_CURRENCY_CODE = 5, + UNUM_DEFAULT_RULESET = 6, + UNUM_PUBLIC_RULESETS = 7, +} +extern "C" { + pub fn unum_getTextAttribute_65( + fmt: *const UNumberFormat, + tag: UNumberFormatTextAttribute, + result: *mut UChar, + resultLength: i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_setTextAttribute_65( + fmt: *mut UNumberFormat, + tag: UNumberFormatTextAttribute, + newValue: *const UChar, + newValueLength: i32, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_toPattern_65( + fmt: *const UNumberFormat, + isPatternLocalized: UBool, + result: *mut UChar, + resultLength: i32, + status: *mut UErrorCode, + ) -> i32; +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatSymbol { + UNUM_DECIMAL_SEPARATOR_SYMBOL = 0, + UNUM_GROUPING_SEPARATOR_SYMBOL = 1, + UNUM_PATTERN_SEPARATOR_SYMBOL = 2, + UNUM_PERCENT_SYMBOL = 3, + UNUM_ZERO_DIGIT_SYMBOL = 4, + UNUM_DIGIT_SYMBOL = 5, + UNUM_MINUS_SIGN_SYMBOL = 6, + UNUM_PLUS_SIGN_SYMBOL = 7, + UNUM_CURRENCY_SYMBOL = 8, + UNUM_INTL_CURRENCY_SYMBOL = 9, + UNUM_MONETARY_SEPARATOR_SYMBOL = 10, + UNUM_EXPONENTIAL_SYMBOL = 11, + UNUM_PERMILL_SYMBOL = 12, + UNUM_PAD_ESCAPE_SYMBOL = 13, + UNUM_INFINITY_SYMBOL = 14, + UNUM_NAN_SYMBOL = 15, + UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16, + UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17, + UNUM_ONE_DIGIT_SYMBOL = 18, + UNUM_TWO_DIGIT_SYMBOL = 19, + UNUM_THREE_DIGIT_SYMBOL = 20, + UNUM_FOUR_DIGIT_SYMBOL = 21, + UNUM_FIVE_DIGIT_SYMBOL = 22, + UNUM_SIX_DIGIT_SYMBOL = 23, + UNUM_SEVEN_DIGIT_SYMBOL = 24, + UNUM_EIGHT_DIGIT_SYMBOL = 25, + UNUM_NINE_DIGIT_SYMBOL = 26, + UNUM_EXPONENT_MULTIPLICATION_SYMBOL = 27, + UNUM_FORMAT_SYMBOL_COUNT = 28, +} +extern "C" { + pub fn unum_getSymbol_65( + fmt: *const UNumberFormat, + symbol: UNumberFormatSymbol, + buffer: *mut UChar, + size: i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_setSymbol_65( + fmt: *mut UNumberFormat, + symbol: UNumberFormatSymbol, + value: *const UChar, + length: i32, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_getLocaleByType_65( + fmt: *const UNumberFormat, + type_: ULocDataLocaleType, + status: *mut UErrorCode, + ) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn unum_setContext_65( + fmt: *mut UNumberFormat, + value: UDisplayContext, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_getContext_65( + fmt: *const UNumberFormat, + type_: UDisplayContextType, + status: *mut UErrorCode, + ) -> UDisplayContext; +} pub type UDateFormat = *mut ::std::os::raw::c_void; impl UDateFormatStyle { pub const UDAT_DEFAULT: UDateFormatStyle = UDateFormatStyle::UDAT_MEDIUM; @@ -2934,6 +3293,19 @@ pub enum UDataFileAccess { extern "C" { pub fn udata_setFileAccess_65(access: UDataFileAccess, status: *mut UErrorCode); } +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UFieldCategory { + UFIELD_CATEGORY_UNDEFINED = 0, + UFIELD_CATEGORY_DATE = 1, + UFIELD_CATEGORY_NUMBER = 2, + UFIELD_CATEGORY_LIST = 3, + UFIELD_CATEGORY_RELATIVE_DATETIME = 4, + UFIELD_CATEGORY_DATE_INTERVAL = 5, + UFIELD_CATEGORY_COUNT = 6, + UFIELD_CATEGORY_LIST_SPAN = 4099, + UFIELD_CATEGORY_DATE_INTERVAL_SPAN = 4101, +} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct UFormattedValue { diff --git a/rust_icu_sys/bindgen/lib_66.rs b/rust_icu_sys/bindgen/lib_66.rs index 60ec19d8..30684993 100644 --- a/rust_icu_sys/bindgen/lib_66.rs +++ b/rust_icu_sys/bindgen/lib_66.rs @@ -2387,6 +2387,365 @@ pub struct UFieldPositionIterator { _unused: [u8; 0], } pub type UNumberFormat = *mut ::std::os::raw::c_void; +impl UNumberFormatStyle { + pub const UNUM_DEFAULT: UNumberFormatStyle = UNumberFormatStyle::UNUM_DECIMAL; +} +impl UNumberFormatStyle { + pub const UNUM_IGNORE: UNumberFormatStyle = UNumberFormatStyle::UNUM_PATTERN_DECIMAL; +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatStyle { + UNUM_PATTERN_DECIMAL = 0, + UNUM_DECIMAL = 1, + UNUM_CURRENCY = 2, + UNUM_PERCENT = 3, + UNUM_SCIENTIFIC = 4, + UNUM_SPELLOUT = 5, + UNUM_ORDINAL = 6, + UNUM_DURATION = 7, + UNUM_NUMBERING_SYSTEM = 8, + UNUM_PATTERN_RULEBASED = 9, + UNUM_CURRENCY_ISO = 10, + UNUM_CURRENCY_PLURAL = 11, + UNUM_CURRENCY_ACCOUNTING = 12, + UNUM_CASH_CURRENCY = 13, + UNUM_DECIMAL_COMPACT_SHORT = 14, + UNUM_DECIMAL_COMPACT_LONG = 15, + UNUM_CURRENCY_STANDARD = 16, + UNUM_FORMAT_STYLE_COUNT = 17, +} +extern "C" { + pub fn unum_open_66( + style: UNumberFormatStyle, + pattern: *const UChar, + patternLength: i32, + locale: *const ::std::os::raw::c_char, + parseErr: *mut UParseError, + status: *mut UErrorCode, + ) -> *mut UNumberFormat; +} +extern "C" { + pub fn unum_close_66(fmt: *mut UNumberFormat); +} +extern "C" { + pub fn unum_clone_66(fmt: *const UNumberFormat, status: *mut UErrorCode) -> *mut UNumberFormat; +} +extern "C" { + pub fn unum_format_66( + fmt: *const UNumberFormat, + number: i32, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatInt64_66( + fmt: *const UNumberFormat, + number: i64, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDouble_66( + fmt: *const UNumberFormat, + number: f64, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDoubleForFields_66( + format: *const UNumberFormat, + number: f64, + result: *mut UChar, + resultLength: i32, + fpositer: *mut UFieldPositionIterator, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDecimal_66( + fmt: *const UNumberFormat, + number: *const ::std::os::raw::c_char, + length: i32, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDoubleCurrency_66( + fmt: *const UNumberFormat, + number: f64, + currency: *mut UChar, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatUFormattable_66( + fmt: *const UNumberFormat, + number: *const UFormattable, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_parse_66( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_parseInt64_66( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> i64; +} +extern "C" { + pub fn unum_parseDouble_66( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> f64; +} +extern "C" { + pub fn unum_parseDecimal_66( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + outBuf: *mut ::std::os::raw::c_char, + outBufLength: i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_parseDoubleCurrency_66( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + currency: *mut UChar, + status: *mut UErrorCode, + ) -> f64; +} +extern "C" { + pub fn unum_parseToUFormattable_66( + fmt: *const UNumberFormat, + result: *mut UFormattable, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> *mut UFormattable; +} +extern "C" { + pub fn unum_applyPattern_66( + format: *mut UNumberFormat, + localized: UBool, + pattern: *const UChar, + patternLength: i32, + parseError: *mut UParseError, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_getAvailable_66(localeIndex: i32) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn unum_countAvailable_66() -> i32; +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatAttribute { + UNUM_PARSE_INT_ONLY = 0, + UNUM_GROUPING_USED = 1, + UNUM_DECIMAL_ALWAYS_SHOWN = 2, + UNUM_MAX_INTEGER_DIGITS = 3, + UNUM_MIN_INTEGER_DIGITS = 4, + UNUM_INTEGER_DIGITS = 5, + UNUM_MAX_FRACTION_DIGITS = 6, + UNUM_MIN_FRACTION_DIGITS = 7, + UNUM_FRACTION_DIGITS = 8, + UNUM_MULTIPLIER = 9, + UNUM_GROUPING_SIZE = 10, + UNUM_ROUNDING_MODE = 11, + UNUM_ROUNDING_INCREMENT = 12, + UNUM_FORMAT_WIDTH = 13, + UNUM_PADDING_POSITION = 14, + UNUM_SECONDARY_GROUPING_SIZE = 15, + UNUM_SIGNIFICANT_DIGITS_USED = 16, + UNUM_MIN_SIGNIFICANT_DIGITS = 17, + UNUM_MAX_SIGNIFICANT_DIGITS = 18, + UNUM_LENIENT_PARSE = 19, + UNUM_PARSE_ALL_INPUT = 20, + UNUM_SCALE = 21, + UNUM_MINIMUM_GROUPING_DIGITS = 22, + UNUM_CURRENCY_USAGE = 23, + UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 4095, + UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS = 4096, + UNUM_PARSE_NO_EXPONENT = 4097, + UNUM_PARSE_DECIMAL_MARK_REQUIRED = 4098, + UNUM_PARSE_CASE_SENSITIVE = 4099, + UNUM_SIGN_ALWAYS_SHOWN = 4100, + UNUM_LIMIT_BOOLEAN_ATTRIBUTE = 4101, +} +extern "C" { + pub fn unum_getAttribute_66(fmt: *const UNumberFormat, attr: UNumberFormatAttribute) -> i32; +} +extern "C" { + pub fn unum_setAttribute_66( + fmt: *mut UNumberFormat, + attr: UNumberFormatAttribute, + newValue: i32, + ); +} +extern "C" { + pub fn unum_getDoubleAttribute_66( + fmt: *const UNumberFormat, + attr: UNumberFormatAttribute, + ) -> f64; +} +extern "C" { + pub fn unum_setDoubleAttribute_66( + fmt: *mut UNumberFormat, + attr: UNumberFormatAttribute, + newValue: f64, + ); +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatTextAttribute { + UNUM_POSITIVE_PREFIX = 0, + UNUM_POSITIVE_SUFFIX = 1, + UNUM_NEGATIVE_PREFIX = 2, + UNUM_NEGATIVE_SUFFIX = 3, + UNUM_PADDING_CHARACTER = 4, + UNUM_CURRENCY_CODE = 5, + UNUM_DEFAULT_RULESET = 6, + UNUM_PUBLIC_RULESETS = 7, +} +extern "C" { + pub fn unum_getTextAttribute_66( + fmt: *const UNumberFormat, + tag: UNumberFormatTextAttribute, + result: *mut UChar, + resultLength: i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_setTextAttribute_66( + fmt: *mut UNumberFormat, + tag: UNumberFormatTextAttribute, + newValue: *const UChar, + newValueLength: i32, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_toPattern_66( + fmt: *const UNumberFormat, + isPatternLocalized: UBool, + result: *mut UChar, + resultLength: i32, + status: *mut UErrorCode, + ) -> i32; +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatSymbol { + UNUM_DECIMAL_SEPARATOR_SYMBOL = 0, + UNUM_GROUPING_SEPARATOR_SYMBOL = 1, + UNUM_PATTERN_SEPARATOR_SYMBOL = 2, + UNUM_PERCENT_SYMBOL = 3, + UNUM_ZERO_DIGIT_SYMBOL = 4, + UNUM_DIGIT_SYMBOL = 5, + UNUM_MINUS_SIGN_SYMBOL = 6, + UNUM_PLUS_SIGN_SYMBOL = 7, + UNUM_CURRENCY_SYMBOL = 8, + UNUM_INTL_CURRENCY_SYMBOL = 9, + UNUM_MONETARY_SEPARATOR_SYMBOL = 10, + UNUM_EXPONENTIAL_SYMBOL = 11, + UNUM_PERMILL_SYMBOL = 12, + UNUM_PAD_ESCAPE_SYMBOL = 13, + UNUM_INFINITY_SYMBOL = 14, + UNUM_NAN_SYMBOL = 15, + UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16, + UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17, + UNUM_ONE_DIGIT_SYMBOL = 18, + UNUM_TWO_DIGIT_SYMBOL = 19, + UNUM_THREE_DIGIT_SYMBOL = 20, + UNUM_FOUR_DIGIT_SYMBOL = 21, + UNUM_FIVE_DIGIT_SYMBOL = 22, + UNUM_SIX_DIGIT_SYMBOL = 23, + UNUM_SEVEN_DIGIT_SYMBOL = 24, + UNUM_EIGHT_DIGIT_SYMBOL = 25, + UNUM_NINE_DIGIT_SYMBOL = 26, + UNUM_EXPONENT_MULTIPLICATION_SYMBOL = 27, + UNUM_FORMAT_SYMBOL_COUNT = 28, +} +extern "C" { + pub fn unum_getSymbol_66( + fmt: *const UNumberFormat, + symbol: UNumberFormatSymbol, + buffer: *mut UChar, + size: i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_setSymbol_66( + fmt: *mut UNumberFormat, + symbol: UNumberFormatSymbol, + value: *const UChar, + length: i32, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_getLocaleByType_66( + fmt: *const UNumberFormat, + type_: ULocDataLocaleType, + status: *mut UErrorCode, + ) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn unum_setContext_66( + fmt: *mut UNumberFormat, + value: UDisplayContext, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_getContext_66( + fmt: *const UNumberFormat, + type_: UDisplayContextType, + status: *mut UErrorCode, + ) -> UDisplayContext; +} pub type UDateFormat = *mut ::std::os::raw::c_void; impl UDateFormatStyle { pub const UDAT_DEFAULT: UDateFormatStyle = UDateFormatStyle::UDAT_MEDIUM; @@ -2934,6 +3293,19 @@ pub enum UDataFileAccess { extern "C" { pub fn udata_setFileAccess_66(access: UDataFileAccess, status: *mut UErrorCode); } +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UFieldCategory { + UFIELD_CATEGORY_UNDEFINED = 0, + UFIELD_CATEGORY_DATE = 1, + UFIELD_CATEGORY_NUMBER = 2, + UFIELD_CATEGORY_LIST = 3, + UFIELD_CATEGORY_RELATIVE_DATETIME = 4, + UFIELD_CATEGORY_DATE_INTERVAL = 5, + UFIELD_CATEGORY_COUNT = 6, + UFIELD_CATEGORY_LIST_SPAN = 4099, + UFIELD_CATEGORY_DATE_INTERVAL_SPAN = 4101, +} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct UFormattedValue { diff --git a/rust_icu_sys/bindgen/lib_67.rs b/rust_icu_sys/bindgen/lib_67.rs index 9133177e..25079a23 100644 --- a/rust_icu_sys/bindgen/lib_67.rs +++ b/rust_icu_sys/bindgen/lib_67.rs @@ -2387,6 +2387,365 @@ pub struct UFieldPositionIterator { _unused: [u8; 0], } pub type UNumberFormat = *mut ::std::os::raw::c_void; +impl UNumberFormatStyle { + pub const UNUM_DEFAULT: UNumberFormatStyle = UNumberFormatStyle::UNUM_DECIMAL; +} +impl UNumberFormatStyle { + pub const UNUM_IGNORE: UNumberFormatStyle = UNumberFormatStyle::UNUM_PATTERN_DECIMAL; +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatStyle { + UNUM_PATTERN_DECIMAL = 0, + UNUM_DECIMAL = 1, + UNUM_CURRENCY = 2, + UNUM_PERCENT = 3, + UNUM_SCIENTIFIC = 4, + UNUM_SPELLOUT = 5, + UNUM_ORDINAL = 6, + UNUM_DURATION = 7, + UNUM_NUMBERING_SYSTEM = 8, + UNUM_PATTERN_RULEBASED = 9, + UNUM_CURRENCY_ISO = 10, + UNUM_CURRENCY_PLURAL = 11, + UNUM_CURRENCY_ACCOUNTING = 12, + UNUM_CASH_CURRENCY = 13, + UNUM_DECIMAL_COMPACT_SHORT = 14, + UNUM_DECIMAL_COMPACT_LONG = 15, + UNUM_CURRENCY_STANDARD = 16, + UNUM_FORMAT_STYLE_COUNT = 17, +} +extern "C" { + pub fn unum_open_67( + style: UNumberFormatStyle, + pattern: *const UChar, + patternLength: i32, + locale: *const ::std::os::raw::c_char, + parseErr: *mut UParseError, + status: *mut UErrorCode, + ) -> *mut UNumberFormat; +} +extern "C" { + pub fn unum_close_67(fmt: *mut UNumberFormat); +} +extern "C" { + pub fn unum_clone_67(fmt: *const UNumberFormat, status: *mut UErrorCode) -> *mut UNumberFormat; +} +extern "C" { + pub fn unum_format_67( + fmt: *const UNumberFormat, + number: i32, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatInt64_67( + fmt: *const UNumberFormat, + number: i64, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDouble_67( + fmt: *const UNumberFormat, + number: f64, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDoubleForFields_67( + format: *const UNumberFormat, + number: f64, + result: *mut UChar, + resultLength: i32, + fpositer: *mut UFieldPositionIterator, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDecimal_67( + fmt: *const UNumberFormat, + number: *const ::std::os::raw::c_char, + length: i32, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatDoubleCurrency_67( + fmt: *const UNumberFormat, + number: f64, + currency: *mut UChar, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_formatUFormattable_67( + fmt: *const UNumberFormat, + number: *const UFormattable, + result: *mut UChar, + resultLength: i32, + pos: *mut UFieldPosition, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_parse_67( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_parseInt64_67( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> i64; +} +extern "C" { + pub fn unum_parseDouble_67( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> f64; +} +extern "C" { + pub fn unum_parseDecimal_67( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + outBuf: *mut ::std::os::raw::c_char, + outBufLength: i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_parseDoubleCurrency_67( + fmt: *const UNumberFormat, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + currency: *mut UChar, + status: *mut UErrorCode, + ) -> f64; +} +extern "C" { + pub fn unum_parseToUFormattable_67( + fmt: *const UNumberFormat, + result: *mut UFormattable, + text: *const UChar, + textLength: i32, + parsePos: *mut i32, + status: *mut UErrorCode, + ) -> *mut UFormattable; +} +extern "C" { + pub fn unum_applyPattern_67( + format: *mut UNumberFormat, + localized: UBool, + pattern: *const UChar, + patternLength: i32, + parseError: *mut UParseError, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_getAvailable_67(localeIndex: i32) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn unum_countAvailable_67() -> i32; +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatAttribute { + UNUM_PARSE_INT_ONLY = 0, + UNUM_GROUPING_USED = 1, + UNUM_DECIMAL_ALWAYS_SHOWN = 2, + UNUM_MAX_INTEGER_DIGITS = 3, + UNUM_MIN_INTEGER_DIGITS = 4, + UNUM_INTEGER_DIGITS = 5, + UNUM_MAX_FRACTION_DIGITS = 6, + UNUM_MIN_FRACTION_DIGITS = 7, + UNUM_FRACTION_DIGITS = 8, + UNUM_MULTIPLIER = 9, + UNUM_GROUPING_SIZE = 10, + UNUM_ROUNDING_MODE = 11, + UNUM_ROUNDING_INCREMENT = 12, + UNUM_FORMAT_WIDTH = 13, + UNUM_PADDING_POSITION = 14, + UNUM_SECONDARY_GROUPING_SIZE = 15, + UNUM_SIGNIFICANT_DIGITS_USED = 16, + UNUM_MIN_SIGNIFICANT_DIGITS = 17, + UNUM_MAX_SIGNIFICANT_DIGITS = 18, + UNUM_LENIENT_PARSE = 19, + UNUM_PARSE_ALL_INPUT = 20, + UNUM_SCALE = 21, + UNUM_MINIMUM_GROUPING_DIGITS = 22, + UNUM_CURRENCY_USAGE = 23, + UNUM_MAX_NONBOOLEAN_ATTRIBUTE = 4095, + UNUM_FORMAT_FAIL_IF_MORE_THAN_MAX_DIGITS = 4096, + UNUM_PARSE_NO_EXPONENT = 4097, + UNUM_PARSE_DECIMAL_MARK_REQUIRED = 4098, + UNUM_PARSE_CASE_SENSITIVE = 4099, + UNUM_SIGN_ALWAYS_SHOWN = 4100, + UNUM_LIMIT_BOOLEAN_ATTRIBUTE = 4101, +} +extern "C" { + pub fn unum_getAttribute_67(fmt: *const UNumberFormat, attr: UNumberFormatAttribute) -> i32; +} +extern "C" { + pub fn unum_setAttribute_67( + fmt: *mut UNumberFormat, + attr: UNumberFormatAttribute, + newValue: i32, + ); +} +extern "C" { + pub fn unum_getDoubleAttribute_67( + fmt: *const UNumberFormat, + attr: UNumberFormatAttribute, + ) -> f64; +} +extern "C" { + pub fn unum_setDoubleAttribute_67( + fmt: *mut UNumberFormat, + attr: UNumberFormatAttribute, + newValue: f64, + ); +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatTextAttribute { + UNUM_POSITIVE_PREFIX = 0, + UNUM_POSITIVE_SUFFIX = 1, + UNUM_NEGATIVE_PREFIX = 2, + UNUM_NEGATIVE_SUFFIX = 3, + UNUM_PADDING_CHARACTER = 4, + UNUM_CURRENCY_CODE = 5, + UNUM_DEFAULT_RULESET = 6, + UNUM_PUBLIC_RULESETS = 7, +} +extern "C" { + pub fn unum_getTextAttribute_67( + fmt: *const UNumberFormat, + tag: UNumberFormatTextAttribute, + result: *mut UChar, + resultLength: i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_setTextAttribute_67( + fmt: *mut UNumberFormat, + tag: UNumberFormatTextAttribute, + newValue: *const UChar, + newValueLength: i32, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_toPattern_67( + fmt: *const UNumberFormat, + isPatternLocalized: UBool, + result: *mut UChar, + resultLength: i32, + status: *mut UErrorCode, + ) -> i32; +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UNumberFormatSymbol { + UNUM_DECIMAL_SEPARATOR_SYMBOL = 0, + UNUM_GROUPING_SEPARATOR_SYMBOL = 1, + UNUM_PATTERN_SEPARATOR_SYMBOL = 2, + UNUM_PERCENT_SYMBOL = 3, + UNUM_ZERO_DIGIT_SYMBOL = 4, + UNUM_DIGIT_SYMBOL = 5, + UNUM_MINUS_SIGN_SYMBOL = 6, + UNUM_PLUS_SIGN_SYMBOL = 7, + UNUM_CURRENCY_SYMBOL = 8, + UNUM_INTL_CURRENCY_SYMBOL = 9, + UNUM_MONETARY_SEPARATOR_SYMBOL = 10, + UNUM_EXPONENTIAL_SYMBOL = 11, + UNUM_PERMILL_SYMBOL = 12, + UNUM_PAD_ESCAPE_SYMBOL = 13, + UNUM_INFINITY_SYMBOL = 14, + UNUM_NAN_SYMBOL = 15, + UNUM_SIGNIFICANT_DIGIT_SYMBOL = 16, + UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL = 17, + UNUM_ONE_DIGIT_SYMBOL = 18, + UNUM_TWO_DIGIT_SYMBOL = 19, + UNUM_THREE_DIGIT_SYMBOL = 20, + UNUM_FOUR_DIGIT_SYMBOL = 21, + UNUM_FIVE_DIGIT_SYMBOL = 22, + UNUM_SIX_DIGIT_SYMBOL = 23, + UNUM_SEVEN_DIGIT_SYMBOL = 24, + UNUM_EIGHT_DIGIT_SYMBOL = 25, + UNUM_NINE_DIGIT_SYMBOL = 26, + UNUM_EXPONENT_MULTIPLICATION_SYMBOL = 27, + UNUM_FORMAT_SYMBOL_COUNT = 28, +} +extern "C" { + pub fn unum_getSymbol_67( + fmt: *const UNumberFormat, + symbol: UNumberFormatSymbol, + buffer: *mut UChar, + size: i32, + status: *mut UErrorCode, + ) -> i32; +} +extern "C" { + pub fn unum_setSymbol_67( + fmt: *mut UNumberFormat, + symbol: UNumberFormatSymbol, + value: *const UChar, + length: i32, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_getLocaleByType_67( + fmt: *const UNumberFormat, + type_: ULocDataLocaleType, + status: *mut UErrorCode, + ) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn unum_setContext_67( + fmt: *mut UNumberFormat, + value: UDisplayContext, + status: *mut UErrorCode, + ); +} +extern "C" { + pub fn unum_getContext_67( + fmt: *const UNumberFormat, + type_: UDisplayContextType, + status: *mut UErrorCode, + ) -> UDisplayContext; +} pub type UDateFormat = *mut ::std::os::raw::c_void; impl UDateFormatStyle { pub const UDAT_DEFAULT: UDateFormatStyle = UDateFormatStyle::UDAT_MEDIUM; @@ -2942,6 +3301,19 @@ pub enum UDataFileAccess { extern "C" { pub fn udata_setFileAccess_67(access: UDataFileAccess, status: *mut UErrorCode); } +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd)] +pub enum UFieldCategory { + UFIELD_CATEGORY_UNDEFINED = 0, + UFIELD_CATEGORY_DATE = 1, + UFIELD_CATEGORY_NUMBER = 2, + UFIELD_CATEGORY_LIST = 3, + UFIELD_CATEGORY_RELATIVE_DATETIME = 4, + UFIELD_CATEGORY_DATE_INTERVAL = 5, + UFIELD_CATEGORY_COUNT = 6, + UFIELD_CATEGORY_LIST_SPAN = 4099, + UFIELD_CATEGORY_DATE_INTERVAL_SPAN = 4101, +} #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct UFormattedValue { diff --git a/rust_icu_sys/bindgen/run_bindgen.sh b/rust_icu_sys/bindgen/run_bindgen.sh index ed5c31f2..33307766 100755 --- a/rust_icu_sys/bindgen/run_bindgen.sh +++ b/rust_icu_sys/bindgen/run_bindgen.sh @@ -41,6 +41,7 @@ readonly BINDGEN_SOURCE_MODULES=( "uenum" "uformattable" "ulistformatter" + "umisc" "umsg" "unum" "upluralrules" @@ -66,6 +67,7 @@ readonly BINDGEN_ALLOWLIST_TYPES=( "UDisplayContext.*" "UEnumeration.*" "UErrorCode" + "UField.*" "UFormat.*" "UFormattedList.*" "UListFormatter.*" diff --git a/rust_icu_sys/build.rs b/rust_icu_sys/build.rs index da84c6af..8609210a 100644 --- a/rust_icu_sys/build.rs +++ b/rust_icu_sys/build.rs @@ -46,6 +46,7 @@ mod inner { "uenum", "uformattable", "ulistformatter", + "umisc", "umsg", "unum", "upluralrules", @@ -88,6 +89,7 @@ mod inner { "UDisplayContext.*", "UEnumeration.*", "UErrorCode", + "UField.*", "UFormat.*", "UFormattedList.*", "UListFormatter.*", diff --git a/rust_icu_umsg/src/lib.rs b/rust_icu_umsg/src/lib.rs index 92d43434..13b47819 100644 --- a/rust_icu_umsg/src/lib.rs +++ b/rust_icu_umsg/src/lib.rs @@ -89,30 +89,10 @@ //! ``` use { - anyhow::anyhow, rust_icu_common as common, rust_icu_sys as sys, rust_icu_sys::*, + rust_icu_common as common, rust_icu_sys as sys, rust_icu_sys::*, rust_icu_uloc as uloc, rust_icu_ustring as ustring, std::convert::TryFrom, }; -/// A zero-value parse error, used to initialize types that get passed into FFI code. -static NO_PARSE_ERROR: sys::UParseError = sys::UParseError { - line: 0, - offset: 0, - preContext: [0; 16usize], - postContext: [0; 16usize], -}; - -/// Converts a parse error to a Result. -fn parse_ok(e: sys::UParseError) -> Result<(), common::Error> { - if e == NO_PARSE_ERROR { - return Ok(()); - } - Err(common::Error::Wrapper(anyhow!( - "parse error: line: {}, offset: {}", - e.line, - e.offset - ))) -} - /// The implementation of the ICU `UMessageFormat*`. /// /// Use the [UMessageFormat::try_from] to create a message formatter for a given message pattern in @@ -177,7 +157,7 @@ impl UMessageFormat { let pstr = pattern.as_c_ptr(); let loc = locale.as_c_str(); let mut status = common::Error::OK_CODE; - let mut parse_status = NO_PARSE_ERROR.clone(); + let mut parse_status = common::NO_PARSE_ERROR.clone(); let rep = unsafe { assert!(common::Error::is_ok(status)); @@ -190,7 +170,7 @@ impl UMessageFormat { ) }; common::Error::ok_or_warning(status)?; - parse_ok(parse_status)?; + common::parse_ok(parse_status)?; Ok(UMessageFormat { rep: std::rc::Rc::new(Rep { rep }), }) diff --git a/rust_icu_unum/Cargo.toml b/rust_icu_unum/Cargo.toml index d74c651d..696a90a2 100644 --- a/rust_icu_unum/Cargo.toml +++ b/rust_icu_unum/Cargo.toml @@ -20,6 +20,7 @@ log = "0.4.6" paste = "0.1.5" rust_icu_common = { path = "../rust_icu_common", version = "0.3.1", default-features = false } rust_icu_sys = { path = "../rust_icu_sys", version = "0.3.1", default-features = false } +rust_icu_uloc = { path = "../rust_icu_uloc", version = "0.3.1", default-features = false } rust_icu_ustring = { path = "../rust_icu_ustring", version = "0.3.1", default-features = false } anyhow = "1.0.25" @@ -33,31 +34,37 @@ default = ["use-bindgen", "renaming", "icu_config"] use-bindgen = [ "rust_icu_common/use-bindgen", "rust_icu_sys/use-bindgen", + "rust_icu_uloc/use-bindgen", "rust_icu_ustring/use-bindgen", ] renaming = [ "rust_icu_common/renaming", "rust_icu_sys/renaming", + "rust_icu_uloc/renaming", "rust_icu_ustring/renaming", ] icu_config = [ "rust_icu_common/icu_config", "rust_icu_sys/icu_config", + "rust_icu_uloc/icu_config", "rust_icu_ustring/icu_config", ] icu_version_in_env = [ "rust_icu_common/icu_version_in_env", "rust_icu_sys/icu_version_in_env", + "rust_icu_uloc/icu_version_in_env", "rust_icu_ustring/icu_version_in_env", ] icu_version_64_plus = [ "rust_icu_common/icu_version_64_plus", "rust_icu_sys/icu_version_64_plus", + "rust_icu_uloc/icu_version_64_plus", "rust_icu_ustring/icu_version_64_plus", ] icu_version_67_plus = [ "rust_icu_common/icu_version_67_plus", "rust_icu_sys/icu_version_67_plus", + "rust_icu_uloc/icu_version_67_plus", "rust_icu_ustring/icu_version_67_plus", ] diff --git a/rust_icu_unum/src/lib.rs b/rust_icu_unum/src/lib.rs index ef88bf67..0d7218e0 100644 --- a/rust_icu_unum/src/lib.rs +++ b/rust_icu_unum/src/lib.rs @@ -20,10 +20,68 @@ use { rust_icu_common as common, rust_icu_sys as sys, rust_icu_sys::versioned_function, rust_icu_sys::*, - rust_icu_ustring as ustring, - std::{convert::TryFrom, os::raw, ffi, ptr}, + rust_icu_uloc as uloc, rust_icu_ustring as ustring, + std::{convert::TryFrom, ffi, os::raw, ptr}, }; -#[cfg(test)] -mod tests { +#[derive(Debug)] +pub struct UNumberFormat { + rep: ptr::NonNull, +} + +impl Drop for UNumberFormat { + /// Implements `unum_close` + fn drop(&mut self) { + unsafe { versioned_function!(unum_close)(self.rep.as_ptr()) }; + } } + +impl UNumberFormat { + /// Implements `unum_open` + pub fn try_new_ustring( + style: sys::UNumberFormatStyle, + pattern: ustring::UChar, + locale: &uloc::ULoc, + ) -> Result { + let mut status = common::Error::OK_CODE; + let mut parse = common::NO_PARSE_ERROR.clone(); + let loc = locale.as_c_str(); + + // Unsafety note: all variables should be valid. + let rep = unsafe { + assert!(common::Error::is_ok(status)); + assert!(common::parse_ok(parse).is_ok()); + versioned_function!(unum_open)( + style, + pattern.as_c_ptr(), + // Mostly OK... + pattern.len() as i32, + loc.as_ptr(), + &mut parse, + &mut status, + ) + }; + common::Error::ok_or_warning(status)?; + common::parse_ok(parse)?; + assert_ne!(rep, 0 as *mut sys::UNumberFormat); + Ok(UNumberFormat { + rep: ptr::NonNull::new(rep).unwrap(), + }) + } + + /// Implements `unum_clone` + pub fn try_clone(&self) -> Result { + let mut status = common::Error::OK_CODE; + let rep = unsafe { + assert!(common::Error::is_ok(status)); + versioned_function!(unum_clone)(self.rep.as_ptr(), &mut status) + }; + common::Error::ok_or_warning(status)?; + Ok(UNumberFormat { + rep: ptr::NonNull::new(rep).unwrap(), + }) + } +} + +#[cfg(test)] +mod tests {}