diff --git a/Cargo.lock b/Cargo.lock index a79ab6cad7d..6c29d8495c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -182,8 +182,8 @@ dependencies = [ ] [[package]] -name = "bakeddata-scripts" -version = "1.5.0" +name = "bakeddata" +version = "0.0.0" dependencies = [ "crlify", "icu", @@ -566,6 +566,10 @@ dependencies = [ "serde_json", ] +[[package]] +name = "depcheck" +version = "0.0.0" + [[package]] name = "deranged" version = "0.3.11" @@ -600,7 +604,7 @@ dependencies = [ [[package]] name = "diplomat" version = "0.8.0" -source = "git+https://github.com/rust-diplomat/diplomat?rev=3b875c676f60a892eeb818c6a0f6f10086c69a24#3b875c676f60a892eeb818c6a0f6f10086c69a24" +source = "git+https://github.com/rust-diplomat/diplomat?rev=bd491cb7da695486588e0345f45c95345c79a9ee#bd491cb7da695486588e0345f45c95345c79a9ee" dependencies = [ "diplomat_core", "proc-macro2", @@ -608,6 +612,18 @@ dependencies = [ "syn 2.0.66", ] +[[package]] +name = "diplomat-coverage" +version = "0.0.0" +dependencies = [ + "diplomat_core", + "elsa", + "lazy_static", + "rustdoc-types", + "serde_json", + "syn-inline-mod", +] + [[package]] name = "diplomat-gen" version = "0.0.0" @@ -618,7 +634,7 @@ dependencies = [ [[package]] name = "diplomat-runtime" version = "0.8.1" -source = "git+https://github.com/rust-diplomat/diplomat?rev=3b875c676f60a892eeb818c6a0f6f10086c69a24#3b875c676f60a892eeb818c6a0f6f10086c69a24" +source = "git+https://github.com/rust-diplomat/diplomat?rev=bd491cb7da695486588e0345f45c95345c79a9ee#bd491cb7da695486588e0345f45c95345c79a9ee" dependencies = [ "log", ] @@ -626,7 +642,7 @@ dependencies = [ [[package]] name = "diplomat-tool" version = "0.8.0" -source = "git+https://github.com/rust-diplomat/diplomat?rev=3b875c676f60a892eeb818c6a0f6f10086c69a24#3b875c676f60a892eeb818c6a0f6f10086c69a24" +source = "git+https://github.com/rust-diplomat/diplomat?rev=bd491cb7da695486588e0345f45c95345c79a9ee#bd491cb7da695486588e0345f45c95345c79a9ee" dependencies = [ "askama", "clap", @@ -646,7 +662,7 @@ dependencies = [ [[package]] name = "diplomat_core" version = "0.8.0" -source = "git+https://github.com/rust-diplomat/diplomat?rev=3b875c676f60a892eeb818c6a0f6f10086c69a24#3b875c676f60a892eeb818c6a0f6f10086c69a24" +source = "git+https://github.com/rust-diplomat/diplomat?rev=bd491cb7da695486588e0345f45c95345c79a9ee#bd491cb7da695486588e0345f45c95345c79a9ee" dependencies = [ "displaydoc", "either", @@ -687,6 +703,22 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" +[[package]] +name = "download-repo-sources" +version = "0.0.0" +dependencies = [ + "clap", + "crlify", + "eyre", + "icu_locale_core", + "icu_provider", + "icu_provider_source", + "log", + "simple_logger", + "ureq", + "zip", +] + [[package]] name = "ecma402_traits" version = "4.2.3" @@ -965,6 +997,7 @@ dependencies = [ "icu_calendar_data", "icu_locale_core", "icu_provider", + "ixdtf", "serde", "serde_json", "simple_logger", @@ -1172,10 +1205,6 @@ dependencies = [ "icu_provider_baked", ] -[[package]] -name = "icu_depcheck" -version = "0.0.0" - [[package]] name = "icu_experimental" version = "0.1.0" @@ -1220,18 +1249,6 @@ dependencies = [ "icu_provider_baked", ] -[[package]] -name = "icu_ffi_coverage" -version = "0.0.0" -dependencies = [ - "diplomat_core", - "elsa", - "lazy_static", - "rustdoc-types", - "serde_json", - "syn-inline-mod", -] - [[package]] name = "icu_freertos" version = "1.5.0" @@ -1634,22 +1651,6 @@ dependencies = [ "icu_provider_baked", ] -[[package]] -name = "icu_testdata_scripts" -version = "0.0.0" -dependencies = [ - "clap", - "crlify", - "eyre", - "icu_locale_core", - "icu_provider", - "icu_provider_source", - "log", - "simple_logger", - "ureq", - "zip", -] - [[package]] name = "icu_timezone" version = "1.5.0" diff --git a/Cargo.toml b/Cargo.toml index 0f84928201a..bf26fef4fa1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -83,14 +83,14 @@ members = [ "utils/zerovec/derive", # Tools - "tools/bakeddata-scripts", "tools/benchmark/binsize", "tools/benchmark/macros", "tools/benchmark/memory", - "tools/depcheck", - "tools/diplomat-gen", - "tools/ffi_coverage", - "tools/testdata-scripts", + "tools/make/bakeddata", + "tools/make/depcheck", + "tools/make/diplomat-coverage", + "tools/make/diplomat-gen", + "tools/make/download-repo-sources", "tools/md-tests", ] # Note: Workspaces in subdirectories, such as tutorials/crates, are @@ -200,18 +200,16 @@ zerovec-derive = { version = "0.10.2", path = "utils/zerovec/derive", default-fe # Tools icu_benchmark_macros = { path = "tools/benchmark/macros" } -# icu_benchmark_binsize never used as a dep -# icu_benchmark_memory never used as a dep -# depcheck never used as a dep -# ffi_coverage never used as a dep -# testdata-scripts never used as a dep +# bench-binsize never used as a dep +# bench-memory never used as a dep +# make/* never used as a dep # The version here can either be a `version = ".."` spec or `git = "https://github.com/rust-diplomat/diplomat", rev = ".."` # Diplomat must be published preceding a new ICU4X release but may use git versions in between -diplomat = { git = "https://github.com/rust-diplomat/diplomat", rev = "3b875c676f60a892eeb818c6a0f6f10086c69a24" } -diplomat-runtime = { git = "https://github.com/rust-diplomat/diplomat", rev = "3b875c676f60a892eeb818c6a0f6f10086c69a24" } -diplomat_core = { git = "https://github.com/rust-diplomat/diplomat", rev = "3b875c676f60a892eeb818c6a0f6f10086c69a24" } -diplomat-tool = { git = "https://github.com/rust-diplomat/diplomat", rev = "3b875c676f60a892eeb818c6a0f6f10086c69a24" } +diplomat = { git = "https://github.com/rust-diplomat/diplomat", rev = "bd491cb7da695486588e0345f45c95345c79a9ee" } +diplomat-runtime = { git = "https://github.com/rust-diplomat/diplomat", rev = "bd491cb7da695486588e0345f45c95345c79a9ee" } +diplomat_core = { git = "https://github.com/rust-diplomat/diplomat", rev = "bd491cb7da695486588e0345f45c95345c79a9ee" } +diplomat-tool = { git = "https://github.com/rust-diplomat/diplomat", rev = "bd491cb7da695486588e0345f45c95345c79a9ee" } # EXTERNAL DEPENDENCIES # diff --git a/components/calendar/Cargo.toml b/components/calendar/Cargo.toml index 1dd4f71003e..43b818b4089 100644 --- a/components/calendar/Cargo.toml +++ b/components/calendar/Cargo.toml @@ -24,6 +24,7 @@ calendrical_calculations = { workspace = true } displaydoc = { workspace = true } icu_provider = { workspace = true, features = ["macros"] } icu_locale_core = { workspace = true } +ixdtf = { workspace = true, optional = true } tinystr = { workspace = true, features = ["alloc", "zerovec"] } zerovec = { workspace = true, features = ["derive"] } writeable = { workspace = true } @@ -46,7 +47,8 @@ criterion = { workspace = true } [features] -default = ["compiled_data"] +default = ["compiled_data", "ixdtf"] +ixdtf = ["dep:ixdtf"] logging = ["calendrical_calculations/logging"] std = ["icu_provider/std", "icu_locale_core/std", "calendrical_calculations/std"] serde = ["dep:serde", "zerovec/serde", "tinystr/serde", "icu_provider/serde"] diff --git a/components/calendar/src/ixdtf.rs b/components/calendar/src/ixdtf.rs new file mode 100644 index 00000000000..54f884ca3f1 --- /dev/null +++ b/components/calendar/src/ixdtf.rs @@ -0,0 +1,301 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +use core::str::FromStr; + +use crate::{AnyCalendar, Date, DateTime, Iso, RangeError, Time}; +use ixdtf::parsers::records::IxdtfParseRecord; +use ixdtf::parsers::IxdtfParser; +use ixdtf::ParserError; + +/// An error returned from parsing an IXDTF string to an `icu_calendar` type. +#[derive(Debug)] +#[non_exhaustive] +pub enum ParseError { + /// Syntax error in the IXDTF string. + Syntax(ParserError), + /// Value is out of range. + Range(RangeError), + /// The IXDTF is missing fields required for parsing into the chosen type. + MissingFields, + /// The IXDTF specifies an unknown calendar. + UnknownCalendar, +} + +impl From for ParseError { + fn from(value: RangeError) -> Self { + Self::Range(value) + } +} + +impl From for ParseError { + fn from(value: ParserError) -> Self { + Self::Syntax(value) + } +} + +impl AnyCalendar { + #[cfg(feature = "compiled_data")] + fn try_from_ixdtf_record(ixdtf_record: &IxdtfParseRecord) -> Result { + let calendar_id = ixdtf_record.calendar.unwrap_or(b"iso"); + let calendar_kind = crate::AnyCalendarKind::get_for_bcp47_bytes(calendar_id) + .ok_or(ParseError::UnknownCalendar)?; + let calendar = AnyCalendar::new(calendar_kind); + Ok(calendar) + } +} + +impl Date { + /// Creates a [`Date`] in the ISO-8601 calendar from an IXDTF syntax string. + /// + /// Ignores any calendar annotations in the string. + /// + /// ✨ *Enabled with the `ixdtf` Cargo feature.* + /// + /// # Examples + /// + /// ``` + /// use icu::calendar::Date; + /// + /// let date = Date::try_iso_from_str("2024-07-17").unwrap(); + /// + /// assert_eq!(date.year().number, 2024); + /// assert_eq!( + /// date.month().code, + /// icu::calendar::types::MonthCode(tinystr::tinystr!(4, "M07")) + /// ); + /// assert_eq!(date.day_of_month().0, 17); + /// ``` + pub fn try_iso_from_str(ixdtf_str: &str) -> Result { + Self::try_iso_from_utf8(ixdtf_str.as_bytes()) + } + + /// Creates a [`Date`] in the ISO-8601 calendar from an IXDTF syntax string. + /// + /// See [`Self::try_iso_from_str()`]. + /// + /// ✨ *Enabled with the `ixdtf` Cargo feature.* + pub fn try_iso_from_utf8(ixdtf_str: &[u8]) -> Result { + let ixdtf_record = IxdtfParser::from_utf8(ixdtf_str).parse()?; + Self::try_from_ixdtf_record(&ixdtf_record) + } + + fn try_from_ixdtf_record(ixdtf_record: &IxdtfParseRecord) -> Result { + let date_record = ixdtf_record.date.ok_or(ParseError::MissingFields)?; + let date = Self::try_new_iso_date(date_record.year, date_record.month, date_record.day)?; + Ok(date) + } +} + +impl FromStr for Date { + type Err = ParseError; + fn from_str(ixdtf_str: &str) -> Result { + Self::try_iso_from_str(ixdtf_str) + } +} + +impl Date { + /// Creates a [`Date`] in any calendar from an IXDTF syntax string with compiled data. + /// + /// ✨ *Enabled with the `compiled_data` and `ixdtf` Cargo features.* + /// + /// # Examples + /// + /// ``` + /// use icu::calendar::Date; + /// + /// let date = Date::try_from_str("2024-07-17[u-ca=hebrew]").unwrap(); + /// + /// assert_eq!(date.year().number, 5784); + /// assert_eq!( + /// date.month().code, + /// icu::calendar::types::MonthCode(tinystr::tinystr!(4, "M10")) + /// ); + /// assert_eq!(date.day_of_month().0, 11); + /// ``` + #[cfg(feature = "compiled_data")] + pub fn try_from_str(ixdtf_str: &str) -> Result { + Self::try_from_utf8(ixdtf_str.as_bytes()) + } + + /// Creates a [`Date`] in any calendar from an IXDTF syntax string with compiled data. + /// + /// ✨ *Enabled with the `compiled_data` and `ixdtf` Cargo features.* + /// + /// See [`Self::try_from_str()`]. + #[cfg(feature = "compiled_data")] + pub fn try_from_utf8(ixdtf_str: &[u8]) -> Result { + let ixdtf_record = IxdtfParser::from_utf8(ixdtf_str).parse()?; + let iso_date = Date::::try_from_ixdtf_record(&ixdtf_record)?; + let calendar = AnyCalendar::try_from_ixdtf_record(&ixdtf_record)?; + let date = iso_date.to_any().to_calendar(calendar); + Ok(date) + } +} + +#[cfg(feature = "compiled_data")] +impl FromStr for Date { + type Err = ParseError; + fn from_str(ixdtf_str: &str) -> Result { + Self::try_from_str(ixdtf_str) + } +} + +impl Time { + /// Creates a [`Time`] from an IXDTF syntax string of a time. + /// + /// Does not support parsing an IXDTF string with a date and time; for that, use [`DateTime`]. + /// + /// ✨ *Enabled with the `ixdtf` Cargo feature.* + /// + /// # Examples + /// + /// ``` + /// use icu::calendar::Time; + /// + /// let time = Time::try_from_str("16:01:17.045").unwrap(); + /// + /// assert_eq!(time.hour.number(), 16); + /// assert_eq!(time.minute.number(), 1); + /// assert_eq!(time.second.number(), 17); + /// assert_eq!(time.nanosecond.number(), 45000000); + /// ``` + pub fn try_from_str(ixdtf_str: &str) -> Result { + Self::try_from_utf8(ixdtf_str.as_bytes()) + } + + /// Creates a [`Time`] in the ISO-8601 calendar from an IXDTF syntax string. + /// + /// ✨ *Enabled with the `ixdtf` Cargo feature.* + /// + /// See [`Self::try_from_str()`]. + pub fn try_from_utf8(ixdtf_str: &[u8]) -> Result { + let ixdtf_record = IxdtfParser::from_utf8(ixdtf_str).parse_time()?; + Self::try_from_ixdtf_record(&ixdtf_record) + } + + fn try_from_ixdtf_record(ixdtf_record: &IxdtfParseRecord) -> Result { + let time_record = ixdtf_record.time.ok_or(ParseError::MissingFields)?; + let time = Self::try_new( + time_record.hour, + time_record.minute, + time_record.second, + time_record.nanosecond, + )?; + Ok(time) + } +} + +impl FromStr for Time { + type Err = ParseError; + fn from_str(ixdtf_str: &str) -> Result { + Self::try_from_str(ixdtf_str) + } +} + +impl DateTime { + /// Creates a [`DateTime`] in the ISO-8601 calendar from an IXDTF syntax string. + /// + /// Ignores any calendar annotations in the string. + /// + /// ✨ *Enabled with the `ixdtf` Cargo feature.* + /// + /// # Examples + /// + /// ``` + /// use icu::calendar::DateTime; + /// + /// let datetime = DateTime::try_iso_from_str("2024-07-17T16:01:17.045").unwrap(); + /// + /// assert_eq!(datetime.date.year().number, 2024); + /// assert_eq!( + /// datetime.date.month().code, + /// icu::calendar::types::MonthCode(tinystr::tinystr!(4, "M07")) + /// ); + /// assert_eq!(datetime.date.day_of_month().0, 17); + /// + /// assert_eq!(datetime.time.hour.number(), 16); + /// assert_eq!(datetime.time.minute.number(), 1); + /// assert_eq!(datetime.time.second.number(), 17); + /// assert_eq!(datetime.time.nanosecond.number(), 45000000); + /// ``` + pub fn try_iso_from_str(ixdtf_str: &str) -> Result { + Self::try_iso_from_utf8(ixdtf_str.as_bytes()) + } + + /// Creates a [`DateTime`] in the ISO-8601 calendar from an IXDTF syntax string. + /// + /// ✨ *Enabled with the `ixdtf` Cargo feature.* + /// + /// See [`Self::try_iso_from_str()`]. + pub fn try_iso_from_utf8(ixdtf_str: &[u8]) -> Result { + let ixdtf_record = IxdtfParser::from_utf8(ixdtf_str).parse()?; + Self::try_from_ixdtf_record(&ixdtf_record) + } + + fn try_from_ixdtf_record(ixdtf_record: &IxdtfParseRecord) -> Result { + let date = Date::::try_from_ixdtf_record(ixdtf_record)?; + let time = Time::try_from_ixdtf_record(ixdtf_record)?; + Ok(Self::new(date, time)) + } +} + +impl FromStr for DateTime { + type Err = ParseError; + fn from_str(ixdtf_str: &str) -> Result { + Self::try_iso_from_str(ixdtf_str) + } +} + +impl DateTime { + /// Creates a [`DateTime`] in any calendar from an IXDTF syntax string with compiled data. + /// + /// ✨ *Enabled with the `compiled_data` and `ixdtf` Cargo features.* + /// + /// # Examples + /// + /// ``` + /// use icu::calendar::DateTime; + /// + /// let datetime = DateTime::try_from_str("2024-07-17T16:01:17.045[u-ca=hebrew]").unwrap(); + /// + /// assert_eq!(datetime.date.year().number, 5784); + /// assert_eq!( + /// datetime.date.month().code, + /// icu::calendar::types::MonthCode(tinystr::tinystr!(4, "M10")) + /// ); + /// assert_eq!(datetime.date.day_of_month().0, 11); + /// + /// assert_eq!(datetime.time.hour.number(), 16); + /// assert_eq!(datetime.time.minute.number(), 1); + /// assert_eq!(datetime.time.second.number(), 17); + /// assert_eq!(datetime.time.nanosecond.number(), 45000000); + /// ``` + #[cfg(feature = "compiled_data")] + pub fn try_from_str(ixdtf_str: &str) -> Result { + Self::try_from_utf8(ixdtf_str.as_bytes()) + } + + /// Creates a [`DateTime`] in any calendar from an IXDTF syntax string with compiled data. + /// + /// See [`Self::try_from_str()`]. + /// + /// ✨ *Enabled with the `compiled_data` and `ixdtf` Cargo features.* + #[cfg(feature = "compiled_data")] + pub fn try_from_utf8(ixdtf_str: &[u8]) -> Result { + let ixdtf_record = IxdtfParser::from_utf8(ixdtf_str).parse()?; + let iso_datetime = DateTime::::try_from_ixdtf_record(&ixdtf_record)?; + let calendar = AnyCalendar::try_from_ixdtf_record(&ixdtf_record)?; + let datetime = iso_datetime.to_any().to_calendar(calendar); + Ok(datetime) + } +} + +#[cfg(feature = "compiled_data")] +impl FromStr for DateTime { + type Err = ParseError; + fn from_str(ixdtf_str: &str) -> Result { + Self::try_from_str(ixdtf_str) + } +} diff --git a/components/calendar/src/lib.rs b/components/calendar/src/lib.rs index 4241abed6e2..b3ffb0d021c 100644 --- a/components/calendar/src/lib.rs +++ b/components/calendar/src/lib.rs @@ -131,6 +131,8 @@ pub mod hebrew; pub mod indian; pub mod islamic; pub mod iso; +#[cfg(feature = "ixdtf")] +mod ixdtf; pub mod japanese; pub mod julian; pub mod persian; @@ -151,6 +153,8 @@ pub mod week { pub use week_of::MIN_UNIT_DAYS; } +#[cfg(feature = "ixdtf")] +pub use crate::ixdtf::ParseError; #[doc(no_inline)] pub use any_calendar::{AnyCalendar, AnyCalendarKind}; pub use calendar::Calendar; diff --git a/components/datetime/Cargo.toml b/components/datetime/Cargo.toml index 11f37eeca17..1d26c29f40e 100644 --- a/components/datetime/Cargo.toml +++ b/components/datetime/Cargo.toml @@ -45,6 +45,7 @@ litemap = { workspace = true, optional = true } [dev-dependencies] icu = { path = "../../components/icu", default-features = false } icu_benchmark_macros = { path = "../../tools/benchmark/macros" } +icu_calendar = { path = "../calendar", features = ["ixdtf"] } icu_provider_adapters = { path = "../../provider/adapters" } icu_provider_blob = { path = "../../provider/blob" } litemap = { path = "../../utils/litemap" } diff --git a/components/datetime/benches/datetime.rs b/components/datetime/benches/datetime.rs index d4786dd67f1..ed81d89aa93 100644 --- a/components/datetime/benches/datetime.rs +++ b/components/datetime/benches/datetime.rs @@ -130,7 +130,7 @@ fn datetime_benches(c: &mut Criterion) { TypedNeoFormatter::::try_new_with_components( &locale.into(), neo_components, - length, + length.into(), ) .expect("Failed to create TypedNeoFormatter.") }; diff --git a/components/datetime/src/format/datetime.rs b/components/datetime/src/format/datetime.rs index 4179b3080d3..bb684bc0949 100644 --- a/components/datetime/src/format/datetime.rs +++ b/components/datetime/src/format/datetime.rs @@ -1067,8 +1067,9 @@ mod tests { use icu_calendar::Date; let locale = "en-u-ca-japanese".parse().unwrap(); - let dtf = NeoFormatter::::try_new(&locale, NeoSkeletonLength::Medium) - .expect("DateTimeFormat construction succeeds"); + let dtf = + NeoFormatter::::try_new(&locale, NeoSkeletonLength::Medium.into()) + .expect("DateTimeFormat construction succeeds"); let date = Date::try_new_gregorian_date(1800, 9, 1).expect("Failed to construct Date."); let date = date diff --git a/components/datetime/src/neo.rs b/components/datetime/src/neo.rs index 72f798848c4..988ed404e23 100644 --- a/components/datetime/src/neo.rs +++ b/components/datetime/src/neo.rs @@ -36,7 +36,7 @@ use writeable::TryWriteable; /// Helper macro for generating any/buffer constructors in this file. macro_rules! gen_any_buffer_constructors_with_external_loader { - ($compiled_fn:ident, $any_fn:ident, $buffer_fn:ident, $internal_fn:ident, $($arg:ident: $ty:path),+) => { + ($compiled_fn:ident, $any_fn:ident, $buffer_fn:ident, $internal_fn:ident, $($arg:ident: $ty:ty),+) => { #[doc = icu_provider::gen_any_buffer_unstable_docs!(ANY, Self::$compiled_fn)] pub fn $any_fn

( provider: &P, @@ -71,7 +71,7 @@ macro_rules! gen_any_buffer_constructors_with_external_loader { ) } }; - (R, $compiled_fn:ident, $any_fn:ident, $buffer_fn:ident, $internal_fn:ident, $($arg:ident: $ty:path),+) => { + (R, $compiled_fn:ident, $any_fn:ident, $buffer_fn:ident, $internal_fn:ident, $($arg:ident: $ty:ty),+) => { #[doc = icu_provider::gen_any_buffer_unstable_docs!(ANY, Self::$compiled_fn)] pub fn $any_fn

( provider: &P, @@ -86,7 +86,7 @@ macro_rules! gen_any_buffer_constructors_with_external_loader { &ExternalLoaderAny(provider), locale, R::COMPONENTS, - $($arg),+ + $($arg.into()),+ ) } #[doc = icu_provider::gen_any_buffer_unstable_docs!(BUFFER, Self::$compiled_fn)] @@ -104,11 +104,11 @@ macro_rules! gen_any_buffer_constructors_with_external_loader { &ExternalLoaderBuffer(provider), locale, R::COMPONENTS, - $($arg),+ + $($arg.into()),+ ) } }; - (S: $skel:path | $compts:path, $compiled_fn:ident, $any_fn:ident, $buffer_fn:ident, $internal_fn:ident, $($arg:ident: $ty:path),+) => { + (S: $skel:path | $compts:path, $compiled_fn:ident, $any_fn:ident, $buffer_fn:ident, $internal_fn:ident, $($arg:ident: $ty:ty),+) => { #[doc = icu_provider::gen_any_buffer_unstable_docs!(ANY, Self::$compiled_fn)] pub fn $any_fn( provider: &P, @@ -147,6 +147,45 @@ macro_rules! gen_any_buffer_constructors_with_external_loader { }; } +/// Options bag for datetime formatting. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[non_exhaustive] +pub struct NeoOptions { + /// The desired length of the formatted string, + /// if required for the chosen field set. + /// + /// See [`NeoSkeletonLength`]. + pub length: R::LengthOption, +} + +impl From for NeoOptions +where + R: DateTimeMarkers, + R::LengthOption: From, +{ + #[inline] + fn from(value: NeoSkeletonLength) -> Self { + NeoOptions { + length: value.into(), + } + } +} + +// Note: This is implemented manually because the auto-derive adds an extra +// bound `R: Default` which we don't need. +impl Default for NeoOptions +where + R: DateTimeMarkers, + R::LengthOption: Default, +{ + #[inline] + fn default() -> Self { + NeoOptions { + length: Default::default(), + } + } +} + size_test!(TypedNeoFormatter, typed_neo_year_month_day_formatter_size, 504); /// [`TypedNeoFormatter`] is a formatter capable of formatting dates and/or times from @@ -198,7 +237,7 @@ where /// let formatter = /// TypedNeoFormatter::::try_new( /// &locale!("es-MX").into(), - /// NeoSkeletonLength::Long, + /// NeoSkeletonLength::Long.into(), /// ) /// .unwrap(); /// @@ -208,7 +247,7 @@ where /// ); /// ``` #[cfg(feature = "compiled_data")] - pub fn try_new(locale: &DataLocale, length: NeoSkeletonLength) -> Result + pub fn try_new(locale: &DataLocale, options: NeoOptions) -> Result where crate::provider::Baked: Sized // Date formatting markers @@ -231,7 +270,7 @@ where &ExternalLoaderCompiledData, locale, R::COMPONENTS, - length, + options, ) } @@ -241,14 +280,14 @@ where try_new_with_any_provider, try_new_with_buffer_provider, try_new_internal, - length: NeoSkeletonLength + options: NeoOptions ); #[doc = icu_provider::gen_any_buffer_unstable_docs!(UNSTABLE, Self::try_new)] pub fn try_new_unstable

( provider: &P, locale: &DataLocale, - length: NeoSkeletonLength, + options: NeoOptions, ) -> Result where P: ?Sized @@ -276,7 +315,7 @@ where &ExternalLoaderUnstable(provider), locale, R::COMPONENTS, - length, + options, ) } } @@ -313,7 +352,7 @@ where /// let fmt = TypedNeoFormatter::::try_new_with_components( /// &locale!("es-MX").into(), /// NeoDateComponents::EraYearMonth, - /// NeoSkeletonLength::Medium, + /// NeoSkeletonLength::Medium.into(), /// ) /// .unwrap(); /// let dt = Date::try_new_gregorian_date(2024, 1, 10).unwrap(); @@ -335,7 +374,7 @@ where /// let fmt = TypedNeoFormatter::::try_new_with_components( /// &locale!("es-MX").into(), /// NeoTimeComponents::Hour, - /// NeoSkeletonLength::Medium, + /// NeoSkeletonLength::Medium.into(), /// ) /// .unwrap(); /// let dt = Time::try_new(16, 20, 0, 0).unwrap(); @@ -362,7 +401,7 @@ where /// NeoDayComponents::Weekday, /// NeoTimeComponents::HourMinute, /// ), - /// NeoSkeletonLength::Long, + /// NeoSkeletonLength::Long.into(), /// ) /// .unwrap(); /// let dt = @@ -374,7 +413,7 @@ where pub fn try_new_with_components( locale: &DataLocale, components: R, - length: NeoSkeletonLength, + options: NeoOptions, ) -> Result where crate::provider::Baked: Sized @@ -398,7 +437,7 @@ where &ExternalLoaderCompiledData, locale, components.into(), - length, + options, ) } @@ -408,7 +447,7 @@ where try_new_with_components_with_buffer_provider, try_new_internal, components: R, - length: NeoSkeletonLength + options: NeoOptions ); #[doc = icu_provider::gen_any_buffer_unstable_docs!(UNSTABLE, Self::try_new)] @@ -416,7 +455,7 @@ where provider: &P, locale: &DataLocale, components: R, - length: NeoSkeletonLength, + options: NeoOptions, ) -> Result where P: ?Sized @@ -444,7 +483,7 @@ where &ExternalLoaderUnstable(provider), locale, components.into(), - length, + options, ) } } @@ -460,7 +499,7 @@ where loader: &L, locale: &DataLocale, components: NeoComponents, - length: NeoSkeletonLength, + options: NeoOptions, ) -> Result where P: ?Sized @@ -485,7 +524,7 @@ where &::TimeSkeletonPatternsV1Marker::bind(provider), &R::GluePatternV1Marker::bind(provider), locale, - length, + options.length.into(), components, ) .map_err(LoadError::Data)?; @@ -537,7 +576,7 @@ where /// let formatter = /// TypedNeoFormatter::::try_new( /// &locale!("es-MX").into(), - /// NeoSkeletonLength::Long, + /// NeoSkeletonLength::Long.into(), /// ) /// .unwrap(); /// @@ -558,7 +597,7 @@ where /// let formatter = /// TypedNeoFormatter::::try_new( /// &locale!("es-MX").into(), - /// NeoSkeletonLength::Long, + /// NeoSkeletonLength::Long.into(), /// ) /// .unwrap(); /// @@ -643,7 +682,7 @@ where /// let locale = locale!("en-u-ca-hebrew"); /// /// let formatter = - /// NeoFormatter::::try_new(&locale.into(), length) + /// NeoFormatter::::try_new(&locale.into(), length.into()) /// .unwrap(); /// /// let datetime = DateTime::try_new_iso_datetime(2024, 5, 8, 0, 0, 0).unwrap(); @@ -657,7 +696,7 @@ where /// [`AnyCalendarKind`]: icu_calendar::AnyCalendarKind #[inline(never)] #[cfg(feature = "compiled_data")] - pub fn try_new(locale: &DataLocale, length: NeoSkeletonLength) -> Result + pub fn try_new(locale: &DataLocale, options: NeoOptions) -> Result where crate::provider::Baked: Sized // Date formatting markers @@ -728,7 +767,7 @@ where &ExternalLoaderCompiledData, locale, R::COMPONENTS, - length, + options, ) } @@ -738,14 +777,14 @@ where try_new_with_any_provider, try_new_with_buffer_provider, try_new_internal, - length: NeoSkeletonLength + options: NeoOptions ); #[doc = icu_provider::gen_any_buffer_unstable_docs!(UNSTABLE, Self::try_new)] pub fn try_new_unstable

( provider: &P, locale: &DataLocale, - length: NeoSkeletonLength, + options: NeoOptions, ) -> Result where P: ?Sized @@ -828,7 +867,7 @@ where &ExternalLoaderUnstable(provider), locale, R::COMPONENTS, - length, + options, ) } } @@ -864,7 +903,7 @@ where /// let fmt = NeoFormatter::try_new_with_components( /// &locale!("es-MX").into(), /// NeoDateComponents::EraYearMonth, - /// NeoSkeletonLength::Medium, + /// NeoSkeletonLength::Medium.into(), /// ) /// .unwrap(); /// let dt = Date::try_new_iso_date(2024, 1, 10).unwrap(); @@ -885,7 +924,7 @@ where /// let fmt = NeoFormatter::try_new_with_components( /// &locale!("es-MX").into(), /// NeoTimeComponents::Hour, - /// NeoSkeletonLength::Medium, + /// NeoSkeletonLength::Medium.into(), /// ) /// .unwrap(); /// let dt = Time::try_new(16, 20, 0, 0).unwrap(); @@ -911,7 +950,7 @@ where /// NeoDayComponents::Weekday, /// NeoTimeComponents::HourMinute, /// ), - /// NeoSkeletonLength::Long, + /// NeoSkeletonLength::Long.into(), /// ) /// .unwrap(); /// let dt = DateTime::try_new_iso_datetime(2024, 1, 10, 16, 20, 0).unwrap(); @@ -922,7 +961,7 @@ where /// ); /// ``` #[cfg(feature = "compiled_data")] - pub fn try_new_with_components(locale: &DataLocale, components: R, length: NeoSkeletonLength) -> Result + pub fn try_new_with_components(locale: &DataLocale, components: R, options: NeoOptions) -> Result where crate::provider::Baked: Sized // Date formatting markers @@ -993,7 +1032,7 @@ where &ExternalLoaderCompiledData, locale, components.into(), - length, + options, ) } @@ -1003,7 +1042,7 @@ where try_new_with_components_with_buffer_provider, try_new_internal, components: R, - length: NeoSkeletonLength + options: NeoOptions ); #[doc = icu_provider::gen_any_buffer_unstable_docs!(UNSTABLE, Self::try_new)] @@ -1011,7 +1050,7 @@ where provider: &P, locale: &DataLocale, components: R, - length: NeoSkeletonLength, + options: NeoOptions, ) -> Result where P: ?Sized @@ -1094,7 +1133,7 @@ where &ExternalLoaderUnstable(provider), locale, components.into(), - length, + options, ) } } @@ -1110,7 +1149,7 @@ where loader: &L, locale: &DataLocale, components: NeoComponents, - length: NeoSkeletonLength, + options: NeoOptions, ) -> Result where P: ?Sized @@ -1185,7 +1224,7 @@ where &::TimeSkeletonPatternsV1Marker::bind(provider), &R::GluePatternV1Marker::bind(provider), locale, - length, + options.length.into(), components, ) .map_err(LoadError::Data)?; @@ -1239,7 +1278,7 @@ where /// /// let formatter = NeoFormatter::::try_new( /// &locale!("en-u-ca-hebrew").into(), - /// NeoSkeletonLength::Long, + /// NeoSkeletonLength::Long.into(), /// ) /// .unwrap(); /// @@ -1262,7 +1301,7 @@ where /// /// let formatter = NeoFormatter::::try_new( /// &locale!("es-MX").into(), - /// NeoSkeletonLength::Long, + /// NeoSkeletonLength::Long.into(), /// ) /// .unwrap(); /// @@ -1314,7 +1353,7 @@ where /// /// let formatter = NeoFormatter::::try_new( /// &locale!("en-u-ca-hebrew").into(), - /// NeoSkeletonLength::Long, + /// NeoSkeletonLength::Long.into(), /// ) /// .unwrap(); /// @@ -1337,7 +1376,7 @@ where /// /// let formatter = NeoFormatter::::try_new( /// &locale!("es-MX").into(), - /// NeoSkeletonLength::Long, + /// NeoSkeletonLength::Long.into(), /// ) /// .unwrap(); /// diff --git a/components/datetime/src/neo_marker.rs b/components/datetime/src/neo_marker.rs index 4d8805d2aa3..5d6eb25b6fa 100644 --- a/components/datetime/src/neo_marker.rs +++ b/components/datetime/src/neo_marker.rs @@ -3,6 +3,75 @@ // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). //! Temporary module for neo formatter markers. +//! +//! # Examples +//! +//! ## Time Zone Formatting +//! +//! Here, we configure a [`NeoFormatter`] to format with generic non-location short, +//! which falls back to GMT when unavailable (see [`NeoTimeZoneGenericShortMarker`]). +//! +//! ``` +//! use icu::calendar::DateTime; +//! use icu::timezone::{CustomTimeZone, MetazoneCalculator, TimeZoneIdMapper}; +//! use icu::datetime::neo::TypedNeoFormatter; +//! use icu::datetime::neo_marker::NeoTimeZoneGenericShortMarker; +//! use icu::datetime::NeverCalendar; +//! use icu::locale::locale; +//! use tinystr::tinystr; +//! use writeable::assert_try_writeable_eq; +//! +//! // Set up the time zone. Note: the inputs here are +//! // 1. The GMT offset +//! // 2. The IANA time zone ID +//! // 3. A datetime (for metazone resolution) +//! // 4. Note: we do not need the zone variant because of `load_generic_*()` +//! +//! // Set up the Metazone calculator, time zone ID mapper, +//! // and the DateTime to use in calculation +//! let mzc = MetazoneCalculator::new(); +//! let mapper = TimeZoneIdMapper::new(); +//! let datetime = DateTime::try_new_iso_datetime(2022, 8, 29, 0, 0, 0) +//! .unwrap(); +//! +//! // Set up the formatter +//! let mut tzf = TypedNeoFormatter::::try_new( +//! &locale!("en").into(), +//! // Length does not matter here: it is specified in the type parameter +//! Default::default(), +//! ) +//! .unwrap(); +//! +//! // "uschi" - has metazone symbol data for generic_non_location_short +//! let mut time_zone = "-0600".parse::().unwrap(); +//! time_zone.time_zone_id = mapper.as_borrowed().iana_to_bcp47("America/Chicago"); +//! time_zone.maybe_calculate_metazone(&mzc, &datetime); +//! assert_try_writeable_eq!( +//! tzf.format(&time_zone), +//! "CT" +//! ); +//! +//! // "ushnl" - has time zone override symbol data for generic_non_location_short +//! let mut time_zone = "-1000".parse::().unwrap(); +//! time_zone.time_zone_id = Some(tinystr!(8, "ushnl").into()); +//! time_zone.maybe_calculate_metazone(&mzc, &datetime); +//! assert_try_writeable_eq!( +//! tzf.format(&time_zone), +//! "HST" +//! ); +//! +//! // GMT with offset - used when metazone is not available +//! let mut time_zone = "+0530".parse::().unwrap(); +//! assert_try_writeable_eq!( +//! tzf.format(&time_zone), +//! "GMT+05:30" +//! ); +//! +//! # Ok::<(), icu::datetime::DateTimeError>(()) +//! ``` + +#[cfg(doc)] +use crate::neo::NeoFormatter; use core::marker::PhantomData; @@ -387,7 +456,7 @@ impl> NeoGetField // Note: `impl NeoGetField for CustomTimeZone` comes via blanket impl /// Struct representing the absence of a datetime formatting field. -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Copy, Clone, Default)] #[allow(clippy::exhaustive_structs)] // empty marker struct pub struct NeverField; @@ -503,6 +572,13 @@ impl From for Option { } } +impl From for Option { + #[inline] + fn from(_: NeverField) -> Self { + None + } +} + /// A trait associating [`NeoComponents`]. pub trait HasConstComponents { /// The associated components. @@ -629,6 +705,8 @@ pub trait DateTimeMarkers: private::Sealed + DateTimeNamesMarker { /// /// Should implement [`ZoneMarkers`]. type Z; + /// Type of the length option in the constructor. + type LengthOption: Into>; /// Marker for loading the date/time glue pattern. type GluePatternV1Marker: DataMarker>; } @@ -760,11 +838,12 @@ where impl DateTimeMarkers for DateTimeCombo where - D: DateDataMarkers + DateInputMarkers + DateTimeNamesMarker, + D: DateTimeMarkers, { type D = D; type T = NeoNeverMarker; type Z = NeoNeverMarker; + type LengthOption = NeoSkeletonLength; // always needed for date type GluePatternV1Marker = NeverMarker>; } @@ -793,14 +872,49 @@ where impl DateTimeMarkers for DateTimeCombo where - T: TimeMarkers + DateTimeNamesMarker, + T: DateTimeMarkers, { type D = NeoNeverMarker; type T = T; type Z = NeoNeverMarker; + type LengthOption = NeoSkeletonLength; // always needed for time type GluePatternV1Marker = NeverMarker>; } +impl DateTimeNamesMarker for DateTimeCombo +where + Z: DateTimeNamesMarker, +{ + type YearNames = NeverMarker<()>; + type MonthNames = NeverMarker<()>; + type WeekdayNames = NeverMarker<()>; + type DayPeriodNames = NeverMarker<()>; + type ZoneEssentials = Z::ZoneEssentials; + type ZoneExemplarCities = Z::ZoneExemplarCities; + type ZoneGenericLong = Z::ZoneGenericLong; + type ZoneGenericShort = Z::ZoneGenericShort; + type ZoneSpecificLong = Z::ZoneSpecificLong; + type ZoneSpecificShort = Z::ZoneSpecificShort; +} + +impl HasConstComponents for DateTimeCombo +where + Z: HasConstZoneComponent, +{ + const COMPONENTS: NeoComponents = NeoComponents::Zone(Z::COMPONENT); +} + +impl DateTimeMarkers for DateTimeCombo +where + Z: DateTimeMarkers, +{ + type D = NeoNeverMarker; + type T = NeoNeverMarker; + type Z = Z; + type LengthOption = Z::LengthOption; // no date or time: inherit from zone + type GluePatternV1Marker = GluePatternV1Marker; +} + impl DateTimeNamesMarker for DateTimeCombo where D: DateTimeNamesMarker, @@ -828,12 +942,13 @@ where impl DateTimeMarkers for DateTimeCombo where - D: DateDataMarkers + DateInputMarkers + DateTimeNamesMarker, - T: TimeMarkers + DateTimeNamesMarker, + D: DateTimeMarkers, + T: DateTimeMarkers, { type D = D; type T = T; type Z = NeoNeverMarker; + type LengthOption = NeoSkeletonLength; // always needed for date/time type GluePatternV1Marker = GluePatternV1Marker; } @@ -869,13 +984,14 @@ where impl DateTimeMarkers for DateTimeCombo where - D: DateDataMarkers + DateInputMarkers + DateTimeNamesMarker, - T: TimeMarkers + DateTimeNamesMarker, - Z: ZoneMarkers + DateTimeNamesMarker, + D: DateTimeMarkers, + T: DateTimeMarkers, + Z: DateTimeMarkers, { type D = D; type T = T; type Z = Z; + type LengthOption = NeoSkeletonLength; // always needed for date/time type GluePatternV1Marker = GluePatternV1Marker; } @@ -930,6 +1046,12 @@ macro_rules! datetime_marker_helper { (@glue, no) => { NeverMarker> }; + (@option/length, yes) => { + NeoSkeletonLength + }; + (@option/length, no) => { + NeverField + }; (@input/year, yes) => { FormattableYear }; @@ -1040,6 +1162,16 @@ macro_rules! datetime_marker_helper { }; } +/// Generates the options argument passed into the docs test constructor +macro_rules! length_option_helper { + (yes) => { + stringify!(NeoSkeletonLength::Medium.into()) + }; + (no) => { + stringify!(Default::default()) + }; +} + macro_rules! impl_date_marker { ( $type:ident, @@ -1072,7 +1204,7 @@ macro_rules! impl_date_marker { /// use writeable::assert_try_writeable_eq; #[doc = concat!("let fmt = NeoFormatter::<", stringify!($type), ">::try_new(")] /// &locale!("en").into(), - /// NeoSkeletonLength::Medium, + /// NeoSkeletonLength::Medium.into(), /// ) /// .unwrap(); /// let dt = Date::try_new_iso_date(2024, 5, 17).unwrap(); @@ -1096,7 +1228,7 @@ macro_rules! impl_date_marker { /// #[doc = concat!("let fmt = TypedNeoFormatter::::try_new(")] /// &locale!("en").into(), - /// NeoSkeletonLength::Medium, + /// NeoSkeletonLength::Medium.into(), /// ) /// .unwrap(); /// let dt = Date::try_new_gregorian_date(2024, 5, 17).unwrap(); @@ -1149,6 +1281,7 @@ macro_rules! impl_date_marker { type D = Self; type T = NeoNeverMarker; type Z = NeoNeverMarker; + type LengthOption = datetime_marker_helper!(@option/length, yes); type GluePatternV1Marker = datetime_marker_helper!(@glue, no); } impl HasConstComponents for $type { @@ -1225,7 +1358,7 @@ macro_rules! impl_time_marker { /// #[doc = concat!("let fmt = NeoFormatter::<", stringify!($type), ">::try_new(")] /// &locale!("en").into(), - /// NeoSkeletonLength::Medium, + /// NeoSkeletonLength::Medium.into(), /// ) /// .unwrap(); /// let dt = DateTime::try_new_iso_datetime(2024, 5, 17, 15, 47, 50).unwrap(); @@ -1249,7 +1382,7 @@ macro_rules! impl_time_marker { /// #[doc = concat!("let fmt = TypedNeoFormatter::::try_new(")] /// &locale!("en").into(), - /// NeoSkeletonLength::Medium, + /// NeoSkeletonLength::Medium.into(), /// ) /// .unwrap(); /// let dt = Time::try_new(15, 47, 50, 0).unwrap(); @@ -1290,6 +1423,7 @@ macro_rules! impl_time_marker { type D = NeoNeverMarker; type T = Self; type Z = NeoNeverMarker; + type LengthOption = datetime_marker_helper!(@option/length, yes); type GluePatternV1Marker = datetime_marker_helper!(@glue, no); } impl HasConstComponents for $type { @@ -1305,6 +1439,7 @@ macro_rules! impl_zone_marker { $components:expr, description = $description:literal, expectation = $expectation:literal, + needs_length_option = $option_length_yesno:ident, zone_essentials = $zone_essentials_yesno:ident, zone_exemplar_cities = $zone_exemplar_cities_yesno:ident, zone_generic_long = $zone_generic_long_yesno:ident, @@ -1329,7 +1464,7 @@ macro_rules! impl_zone_marker { /// #[doc = concat!("let fmt = NeoFormatter::<", stringify!($type), ">::try_new(")] /// &locale!("en").into(), - /// NeoSkeletonLength::Medium, + #[doc = concat!(" ", length_option_helper!($option_length_yesno), ",")] /// ) /// .unwrap(); /// @@ -1362,7 +1497,7 @@ macro_rules! impl_zone_marker { /// #[doc = concat!("let fmt = TypedNeoFormatter::::try_new(")] /// &locale!("en").into(), - /// NeoSkeletonLength::Medium, + #[doc = concat!(" ", length_option_helper!($option_length_yesno), ",")] /// ) /// .unwrap(); /// @@ -1412,6 +1547,7 @@ macro_rules! impl_zone_marker { type D = NeoNeverMarker; type T = NeoNeverMarker; type Z = Self; + type LengthOption = datetime_marker_helper!(@option/length, $option_length_yesno); type GluePatternV1Marker = datetime_marker_helper!(@glue, no); } impl HasConstComponents for $type { @@ -1444,7 +1580,7 @@ macro_rules! impl_datetime_marker { /// #[doc = concat!("let fmt = NeoFormatter::<", stringify!($type), ">::try_new(")] /// &locale!("en").into(), - /// NeoSkeletonLength::Medium, + /// NeoSkeletonLength::Medium.into(), /// ) /// .unwrap(); /// let dt = DateTime::try_new_iso_datetime(2024, 5, 17, 15, 47, 50).unwrap(); @@ -1468,7 +1604,7 @@ macro_rules! impl_datetime_marker { /// #[doc = concat!("let fmt = TypedNeoFormatter::::try_new(")] /// &locale!("en").into(), - /// NeoSkeletonLength::Medium, + /// NeoSkeletonLength::Medium.into(), /// ) /// .unwrap(); /// let dt = DateTime::try_new_gregorian_datetime(2024, 5, 17, 15, 47, 50).unwrap(); @@ -1508,7 +1644,7 @@ macro_rules! impl_zoneddatetime_marker { /// #[doc = concat!("let fmt = NeoFormatter::<", stringify!($type), ">::try_new(")] /// &locale!("en").into(), - /// NeoSkeletonLength::Medium, + /// NeoSkeletonLength::Medium.into(), /// ) /// .unwrap(); /// let dtz = CustomZonedDateTime { @@ -1537,7 +1673,7 @@ macro_rules! impl_zoneddatetime_marker { /// #[doc = concat!("let fmt = TypedNeoFormatter::::try_new(")] /// &locale!("en").into(), - /// NeoSkeletonLength::Medium, + /// NeoSkeletonLength::Medium.into(), /// ) /// .unwrap(); /// let dtz = CustomZonedDateTime { @@ -1651,6 +1787,7 @@ impl_zone_marker!( NeoTimeZoneSkeleton::specific(), description = "a specific time zone format with inherited length", expectation = "CDT", + needs_length_option = yes, zone_essentials = yes, zone_exemplar_cities = no, zone_generic_long = no, @@ -1675,7 +1812,7 @@ impl_zone_marker!( /// /// let fmt = TypedNeoFormatter::::try_new( /// &locale!("en").into(), - /// NeoSkeletonLength::Medium, + /// Default::default(), /// ) /// .unwrap(); /// @@ -1696,6 +1833,7 @@ impl_zone_marker!( NeoTimeZoneSkeleton::specific_short(), description = "a short specific time zone format", expectation = "CDT", + needs_length_option = no, zone_essentials = yes, zone_exemplar_cities = no, zone_generic_long = no, @@ -1709,6 +1847,7 @@ impl_zone_marker!( NeoTimeZoneSkeleton::specific_long(), description = "a long specific time zone format", expectation = "Central Daylight Time", + needs_length_option = no, zone_essentials = yes, zone_exemplar_cities = no, zone_generic_long = no, @@ -1722,6 +1861,7 @@ impl_zone_marker!( NeoTimeZoneSkeleton::gmt(), description = "a GMT-offset time zone format with inherited length", expectation = "GMT-05:00", // TODO: Implement short localized GMT + needs_length_option = yes, zone_essentials = yes, zone_exemplar_cities = no, zone_generic_long = no, @@ -1735,6 +1875,7 @@ impl_zone_marker!( NeoTimeZoneSkeleton::gmt_short(), description = "a GMT-offset short time zone format", expectation = "GMT-05:00", // TODO: Implement short localized GMT + needs_length_option = no, zone_essentials = yes, zone_exemplar_cities = no, zone_generic_long = no, @@ -1748,6 +1889,7 @@ impl_zone_marker!( NeoTimeZoneSkeleton::gmt_long(), description = "a GMT-offset long time zone format", expectation = "GMT-05:00", + needs_length_option = no, zone_essentials = yes, zone_exemplar_cities = no, zone_generic_long = no, @@ -1761,6 +1903,7 @@ impl_zone_marker!( NeoTimeZoneSkeleton::generic(), description = "a generic time zone format with inherited length", expectation = "CT", + needs_length_option = yes, zone_essentials = yes, zone_exemplar_cities = yes, zone_generic_long = no, @@ -1785,7 +1928,7 @@ impl_zone_marker!( /// /// let fmt = TypedNeoFormatter::::try_new( /// &locale!("en").into(), - /// NeoSkeletonLength::Medium, + /// Default::default(), /// ) /// .unwrap(); /// @@ -1806,6 +1949,7 @@ impl_zone_marker!( NeoTimeZoneSkeleton::generic_short(), description = "a generic short time zone format", expectation = "CT", + needs_length_option = no, zone_essentials = yes, zone_exemplar_cities = yes, zone_generic_long = no, @@ -1819,6 +1963,7 @@ impl_zone_marker!( NeoTimeZoneSkeleton::generic_long(), description = "a generic long time zone format", expectation = "Central Time", + needs_length_option = no, zone_essentials = yes, zone_exemplar_cities = yes, zone_generic_long = yes, @@ -1832,6 +1977,7 @@ impl_zone_marker!( NeoTimeZoneSkeleton::location(), description = "a location time zone format", expectation = "Chicago Time", + needs_length_option = no, zone_essentials = yes, zone_exemplar_cities = yes, zone_generic_long = no, @@ -1897,6 +2043,7 @@ impl DateTimeMarkers for NeoDateComponents { type D = Self; type T = NeoNeverMarker; type Z = NeoNeverMarker; + type LengthOption = datetime_marker_helper!(@option/length, yes); type GluePatternV1Marker = datetime_marker_helper!(@glue, no); } @@ -1930,6 +2077,7 @@ impl DateTimeMarkers for NeoTimeComponents { type D = NeoNeverMarker; type T = Self; type Z = NeoNeverMarker; + type LengthOption = datetime_marker_helper!(@option/length, yes); type GluePatternV1Marker = datetime_marker_helper!(@glue, no); } @@ -1964,6 +2112,7 @@ impl DateTimeMarkers for NeoTimeZoneSkeleton { type D = NeoNeverMarker; type T = NeoNeverMarker; type Z = Self; + type LengthOption = datetime_marker_helper!(@option/length, yes); type GluePatternV1Marker = datetime_marker_helper!(@glue, no); } @@ -1988,6 +2137,7 @@ impl DateTimeMarkers for NeoDateTimeComponents { type D = NeoDateComponents; type T = NeoTimeComponents; type Z = NeoNeverMarker; + type LengthOption = datetime_marker_helper!(@option/length, yes); type GluePatternV1Marker = datetime_marker_helper!(@glue, yes); } @@ -2012,5 +2162,6 @@ impl DateTimeMarkers for NeoComponents { type D = NeoDateComponents; type T = NeoTimeComponents; type Z = NeoTimeZoneSkeleton; + type LengthOption = datetime_marker_helper!(@option/length, yes); type GluePatternV1Marker = datetime_marker_helper!(@glue, yes); } diff --git a/components/datetime/src/neo_pattern.rs b/components/datetime/src/neo_pattern.rs index d4ea087df80..1d164c98e43 100644 --- a/components/datetime/src/neo_pattern.rs +++ b/components/datetime/src/neo_pattern.rs @@ -41,7 +41,7 @@ size_test!(DateTimePattern, date_time_pattern_size, 32); /// let data_pattern = /// TypedNeoFormatter::::try_new( /// &locale!("es-MX").into(), -/// NeoSkeletonLength::Medium, +/// NeoSkeletonLength::Medium.into(), /// ) /// .unwrap() /// // The pattern can depend on the datetime being formatted. diff --git a/components/datetime/src/neo_skeleton.rs b/components/datetime/src/neo_skeleton.rs index fa27a24826e..c4b3b198794 100644 --- a/components/datetime/src/neo_skeleton.rs +++ b/components/datetime/src/neo_skeleton.rs @@ -7,6 +7,8 @@ use crate::options::components; use crate::options::length; #[cfg(feature = "experimental")] +use crate::raw::neo::MaybeLength; +#[cfg(feature = "experimental")] use crate::time_zone::ResolvedNeoTimeZoneSkeleton; use crate::DateTimeFormatterOptions; use icu_provider::DataMarkerAttributes; @@ -803,8 +805,11 @@ pub struct NeoTimeZoneSkeleton { #[cfg(feature = "experimental")] impl NeoTimeZoneSkeleton { - pub(crate) fn resolve(self, length: NeoSkeletonLength) -> ResolvedNeoTimeZoneSkeleton { - crate::tz_registry::skeleton_to_resolved(self.style, self.length.unwrap_or(length)) + pub(crate) fn resolve(self, length: MaybeLength) -> ResolvedNeoTimeZoneSkeleton { + crate::tz_registry::skeleton_to_resolved( + self.style, + self.length.unwrap_or_else(|| length.get::()), + ) } } diff --git a/components/datetime/src/raw/neo.rs b/components/datetime/src/raw/neo.rs index 1949288020e..31da6fcfc32 100644 --- a/components/datetime/src/raw/neo.rs +++ b/components/datetime/src/raw/neo.rs @@ -18,6 +18,25 @@ use marker_attrs::GlueType; use zerovec::ule::AsULE; use zerovec::ZeroSlice; +#[derive(Debug, Copy, Clone)] +pub(crate) struct MaybeLength(Option); + +impl MaybeLength { + pub(crate) fn get(self) -> NeoSkeletonLength { + match self.0 { + Some(length) => length, + None => { + debug_assert!( + false, + "expected length: in {}", + core::any::type_name::() + ); + NeoSkeletonLength::Long + } + } + } +} + #[derive(Debug)] pub(crate) enum DatePatternSelectionData { SkeletonDate { @@ -117,7 +136,7 @@ impl DatePatternSelectionData { pub(crate) fn try_new_with_skeleton( provider: &(impl BoundDataProvider + ?Sized), locale: &DataLocale, - length: NeoSkeletonLength, + length: MaybeLength, components: NeoDateComponents, ) -> Result { let payload = provider @@ -131,7 +150,10 @@ impl DatePatternSelectionData { .payload .cast(); Ok(Self::SkeletonDate { - skeleton: NeoDateSkeleton { length, components }, + skeleton: NeoDateSkeleton { + length: length.get::(), + components, + }, payload, }) } @@ -165,7 +187,7 @@ impl TimePatternSelectionData { pub(crate) fn try_new_with_skeleton( provider: &(impl BoundDataProvider + ?Sized), locale: &DataLocale, - length: NeoSkeletonLength, + length: MaybeLength, components: NeoTimeComponents, ) -> Result { let payload = provider @@ -179,7 +201,10 @@ impl TimePatternSelectionData { .payload .cast(); Ok(Self::SkeletonTime { - skeleton: NeoTimeSkeleton { length, components }, + skeleton: NeoTimeSkeleton { + length: length.get::(), + components, + }, payload, }) } @@ -210,10 +235,7 @@ impl TimePatternSelectionData { } impl ZonePatternSelectionData { - pub(crate) fn new_with_skeleton( - length: NeoSkeletonLength, - components: NeoTimeZoneSkeleton, - ) -> Self { + pub(crate) fn new_with_skeleton(length: MaybeLength, components: NeoTimeZoneSkeleton) -> Self { let time_zone = components.resolve(length); let pattern_item = PatternItem::Field(time_zone.to_field()); Self::SinglePatternItem(time_zone, pattern_item.to_unaligned()) @@ -241,9 +263,10 @@ impl DateTimeZonePatternSelectionData { time_provider: &(impl BoundDataProvider + ?Sized), glue_provider: &(impl BoundDataProvider + ?Sized), locale: &DataLocale, - length: NeoSkeletonLength, + length: Option, components: NeoComponents, ) -> Result { + let length = MaybeLength(length); match components { NeoComponents::Date(components) => { let selection = DatePatternSelectionData::try_new_with_skeleton( @@ -342,7 +365,7 @@ impl DateTimeZonePatternSelectionData { fn load_glue( glue_provider: &(impl BoundDataProvider + ?Sized), locale: &DataLocale, - length: NeoSkeletonLength, + length: MaybeLength, glue_type: GlueType, ) -> Result, DataError> { glue_provider @@ -351,7 +374,7 @@ impl DateTimeZonePatternSelectionData { marker_attrs::pattern_marker_attr_for_glue( // According to UTS 35, use the date length here: use the glue // pattern "whose type matches the type of the date pattern" - match length { + match length.get::() { NeoSkeletonLength::Long => marker_attrs::PatternLength::Long, NeoSkeletonLength::Medium => marker_attrs::PatternLength::Medium, NeoSkeletonLength::Short => marker_attrs::PatternLength::Short, diff --git a/components/datetime/src/time_zone.rs b/components/datetime/src/time_zone.rs index c531b01d064..3257d6e62f2 100644 --- a/components/datetime/src/time_zone.rs +++ b/components/datetime/src/time_zone.rs @@ -89,80 +89,6 @@ where /// /// [`CustomTimeZone`](icu_timezone::CustomTimeZone) can be used as formatting input. /// -/// # Examples -/// -/// Here, we configure the [`TimeZoneFormatter`] to first look for time zone formatting symbol -/// data for `generic_non_location_short`, and if it does not exist, to subsequently check -/// for `generic_non_location_long` data. -/// -/// ``` -/// use icu::calendar::DateTime; -/// use icu::timezone::{CustomTimeZone, MetazoneCalculator, TimeZoneIdMapper}; -/// use icu::datetime::{DateTimeError, time_zone::TimeZoneFormatter}; -/// use icu::locale::locale; -/// use tinystr::tinystr; -/// use writeable::assert_writeable_eq; -/// -/// // Set up the time zone. Note: the inputs here are -/// // 1. The GMT offset -/// // 2. The IANA time zone ID -/// // 3. A datetime (for metazone resolution) -/// // 4. Note: we do not need the zone variant because of `load_generic_*()` -/// -/// // Set up the Metazone calculator, time zone ID mapper, -/// // and the DateTime to use in calculation -/// let mzc = MetazoneCalculator::new(); -/// let mapper = TimeZoneIdMapper::new(); -/// let datetime = DateTime::try_new_iso_datetime(2022, 8, 29, 0, 0, 0) -/// .unwrap(); -/// -/// // Set up the formatter -/// let mut tzf = TimeZoneFormatter::try_new( -/// &locale!("en").into(), -/// Default::default(), -/// ) -/// .unwrap(); -/// tzf.include_generic_non_location_short()? -/// .include_generic_non_location_long()?; -/// -/// // "uschi" - has metazone symbol data for generic_non_location_short -/// let mut time_zone = "-0600".parse::().unwrap(); -/// time_zone.time_zone_id = mapper.as_borrowed().iana_to_bcp47("America/Chicago"); -/// time_zone.maybe_calculate_metazone(&mzc, &datetime); -/// assert_writeable_eq!( -/// tzf.format(&time_zone), -/// "CT" -/// ); -/// -/// // "ushnl" - has time zone override symbol data for generic_non_location_short -/// let mut time_zone = "-1000".parse::().unwrap(); -/// time_zone.time_zone_id = Some(tinystr!(8, "ushnl").into()); -/// time_zone.maybe_calculate_metazone(&mzc, &datetime); -/// assert_writeable_eq!( -/// tzf.format(&time_zone), -/// "HST" -/// ); -/// -/// // "frpar" - does not have symbol data for generic_non_location_short, so falls -/// // back to generic_non_location_long -/// let mut time_zone = "+0100".parse::().unwrap(); -/// time_zone.time_zone_id = Some(tinystr!(8, "frpar").into()); -/// time_zone.maybe_calculate_metazone(&mzc, &datetime); -/// assert_writeable_eq!( -/// tzf.format(&time_zone), -/// "Central European Time" -/// ); -/// -/// // GMT with offset - used when metazone is not available -/// let mut time_zone = "+0530".parse::().unwrap(); -/// assert_writeable_eq!( -/// tzf.format(&time_zone), -/// "GMT+05:30" -/// ); -/// -/// # Ok::<(), DateTimeError>(()) -/// ``` -/// /// [data provider]: icu_provider #[derive(Debug)] pub struct TimeZoneFormatter { @@ -477,29 +403,6 @@ impl TimeZoneFormatter { /// ✨ *Enabled with the `compiled_data` Cargo feature.* /// /// [📚 Help choosing a constructor](icu_provider::constructors) - /// - /// # Examples - /// - /// Default format is Localized GMT: - /// - /// ``` - /// use icu::datetime::time_zone::{ - /// TimeZoneFormatter, TimeZoneFormatterOptions, - /// }; - /// use icu::locale::locale; - /// use icu::timezone::CustomTimeZone; - /// use writeable::assert_writeable_eq; - /// - /// let tzf = TimeZoneFormatter::try_new( - /// &locale!("es").into(), - /// TimeZoneFormatterOptions::default(), - /// ) - /// .unwrap(); - /// - /// let time_zone = "-0700".parse::().unwrap(); - /// - /// assert_writeable_eq!(tzf.format(&time_zone), "GMT-07:00"); - /// ``` ); #[doc = icu_provider::gen_any_buffer_unstable_docs!(UNSTABLE, Self::try_new)] @@ -732,27 +635,6 @@ impl TimeZoneFormatter { /// Takes a [`TimeZoneInput`] implementer and returns an instance of a [`FormattedTimeZone`] /// that contains all information necessary to display a formatted time zone and operate on it. - /// - /// # Examples - /// - /// ``` - /// use icu::datetime::time_zone::{ - /// TimeZoneFormatter, TimeZoneFormatterOptions, - /// }; - /// use icu::locale::locale; - /// use icu::timezone::CustomTimeZone; - /// use writeable::assert_writeable_eq; - /// - /// let tzf = TimeZoneFormatter::try_new( - /// &locale!("en").into(), - /// TimeZoneFormatterOptions::default(), - /// ) - /// .expect("Failed to create TimeZoneFormatter"); - /// - /// let time_zone = CustomTimeZone::utc(); - /// - /// assert_writeable_eq!(tzf.format(&time_zone), "GMT"); - /// ``` pub fn format<'l, T>(&'l self, value: &T) -> FormattedTimeZone<'l> where T: TimeZoneInput, diff --git a/components/datetime/src/tz_registry.rs b/components/datetime/src/tz_registry.rs index 1251114f55f..a5b79344c96 100644 --- a/components/datetime/src/tz_registry.rs +++ b/components/datetime/src/tz_registry.rs @@ -20,10 +20,7 @@ macro_rules! time_zone_style_registry { (gmt_long, Offset, Long, GmtLong, UpperO, Wide), // 'OOOO' (generic_short, NonLocation, Short, GenericShort, LowerV, One), // 'v' (generic_long, NonLocation, Long, GenericLong, LowerV, Wide), // 'vvvv' - ], - // Styles with None-length, functions, and matchers - [ - (location, Location, Location, UpperV, Wide), // 'VVVV' + (location, Location, Long, Location, UpperV, Wide), // 'VVVV' ], // Styles with function only for None-length [ @@ -38,7 +35,6 @@ macro_rules! time_zone_style_registry { (NonLocation, Medium, GenericShort), (Location, Short, Location), (Location, Medium, Location), - (Location, Long, Location), // See comments above about Default behavior (Default, Short, SpecificShort), (Default, Medium, SpecificShort), @@ -67,7 +63,6 @@ macro_rules! time_zone_style_registry { macro_rules! make_constructors { ( [$(($fn:ident, $style:ident, $length:ident, $resolved:ident, $field_symbol:ident, $field_length:ident)),+,], - [$(($fn0:ident, $style0:ident, $resolved0:ident, $field_symbol0:ident, $field_length0:ident)),+,], [$(($fn1:ident, $style1:ident)),+,], [$(($style2:ident, $length2:ident, $resolved2:ident)),+,], [$(($resolved3:ident, $field_symbol3:ident, $field_length3:ident)),+,], @@ -83,16 +78,6 @@ macro_rules! make_constructors { } } )+ - $( - impl NeoTimeZoneSkeleton { - pub(crate) const fn $fn0() -> Self { - Self { - length: None, - style: NeoTimeZoneStyle::$style0, - } - } - } - )+ $( impl NeoTimeZoneSkeleton { pub(crate) const fn $fn1() -> Self { @@ -113,7 +98,6 @@ time_zone_style_registry!(make_constructors); macro_rules! make_resolved_to_field_match { ( [$(($fn:ident, $style:ident, $length:ident, $resolved:ident, $field_symbol:ident, $field_length:ident)),+,], - [$(($fn0:ident, $style0:ident, $resolved0:ident, $field_symbol0:ident, $field_length0:ident)),+,], [$(($fn1:ident, $resolved1:ident)),+,], [$(($style2:ident, $length2:ident, $resolved2:ident)),+,], [$(($resolved3:ident, $field_symbol3:ident, $field_length3:ident)),+,], @@ -127,12 +111,6 @@ macro_rules! make_resolved_to_field_match { length: FieldLength::$field_length, }, )+ - $( - ResolvedNeoTimeZoneSkeleton::$resolved0 => Field { - symbol: FieldSymbol::TimeZone(fields::TimeZone::$field_symbol0), - length: FieldLength::$field_length0, - }, - )+ $( ResolvedNeoTimeZoneSkeleton::$resolved4 => Field { symbol: FieldSymbol::TimeZone(fields::TimeZone::$field_symbol4), @@ -151,7 +129,6 @@ time_zone_style_registry!(make_resolved_to_field_match); macro_rules! make_skeleton_to_resolved_match { ( [$(($fn:ident, $style:ident, $length:ident, $resolved:ident, $field_symbol:ident, $field_length:ident)),+,], - [$(($fn0:ident, $style0:ident, $resolved0:ident, $field_symbol0:ident, $field_length0:ident)),+,], [$(($fn1:ident, $resolved1:ident)),+,], [$(($style2:ident, $length2:ident, $resolved2:ident)),+,], [$(($resolved3:ident, $field_symbol3:ident, $field_length3:ident)),+,], @@ -176,7 +153,6 @@ time_zone_style_registry!(make_skeleton_to_resolved_match); macro_rules! make_field_to_skeleton_match { ( [$(($fn:ident, $style:ident, $length:ident, $resolved:ident, $field_symbol:ident, $field_length:ident)),+,], - [$(($fn0:ident, $style0:ident, $resolved0:ident, $field_symbol0:ident, $field_length0:ident)),+,], [$(($fn1:ident, $resolved1:ident)),+,], [$(($style2:ident, $length2:ident, $resolved2:ident)),+,], [$(($resolved3:ident, $field_symbol3:ident, $field_length3:ident)),+,], @@ -187,9 +163,6 @@ macro_rules! make_field_to_skeleton_match { $( (fields::TimeZone::$field_symbol, FieldLength::$field_length) => Some(ResolvedNeoTimeZoneSkeleton::$resolved), )+ - $( - (fields::TimeZone::$field_symbol0, FieldLength::$field_length0) => Some(ResolvedNeoTimeZoneSkeleton::$resolved0), - )+ $( (fields::TimeZone::$field_symbol3, FieldLength::$field_length3) => Some(ResolvedNeoTimeZoneSkeleton::$resolved3), )+ diff --git a/components/datetime/tests/mock.rs b/components/datetime/tests/mock.rs index 86affe96db2..b31c3bfcbb9 100644 --- a/components/datetime/tests/mock.rs +++ b/components/datetime/tests/mock.rs @@ -33,30 +33,8 @@ use icu_timezone::CustomTimeZone; /// assert_eq!(u32::from(date.time.nanosecond), 101_000_000); /// ``` pub fn parse_gregorian_from_str(input: &str) -> DateTime { - #![allow(clippy::indexing_slicing)] - assert!(input.len() > 20 || input.len() == 19); - let year: i32 = input[0..4].parse().unwrap(); - assert_eq!(input.as_bytes()[4], b'-'); - let month: u8 = input[5..7].parse().unwrap(); - assert_eq!(input.as_bytes()[7], b'-'); - let day: u8 = input[8..10].parse().unwrap(); - assert_eq!(input.as_bytes()[10], b'T'); - let hour: u8 = input[11..13].parse().unwrap(); - assert_eq!(input.as_bytes()[13], b':'); - let minute: u8 = input[14..16].parse().unwrap(); - assert_eq!(input.as_bytes()[16], b':'); - let second: u8 = input[17..19].parse().unwrap(); - let mut datetime = - DateTime::try_new_gregorian_datetime(year, month, day, hour, minute, second).unwrap(); - if input.len() > 20 { - assert_eq!(input.as_bytes()[19], b'.'); - let fraction_str = &input[20..29.min(input.len())]; - let fraction = fraction_str.parse::().unwrap(); - let nanoseconds = fraction * (10u32.pow(9 - fraction_str.len() as u32)); - datetime.time = icu_calendar::Time::try_new(hour, minute, second, nanoseconds).unwrap(); - }; - - datetime + let datetime_iso = DateTime::try_iso_from_str(input).unwrap(); + datetime_iso.to_calendar(Gregorian) } /// Parse a [`DateTime`] and [`CustomTimeZone`] from a string. diff --git a/components/datetime/tests/simple_test.rs b/components/datetime/tests/simple_test.rs index 0b9530fe8ff..cf6f93571e0 100644 --- a/components/datetime/tests/simple_test.rs +++ b/components/datetime/tests/simple_test.rs @@ -88,7 +88,7 @@ fn neo_datetime_lengths() { let formatter = TypedNeoFormatter::try_new_with_components( &locale, NeoDateTimeComponents::DateTime(day_components, time_components), - length, + length.into(), ) .unwrap(); let formatted = formatter.format(&datetime); @@ -124,7 +124,7 @@ fn neo_date_lengths() { let formatter = TypedNeoFormatter::try_new_with_components( &locale, NeoDateComponents::Day(day_components), - length, + length.into(), ) .unwrap(); let formatted = formatter.format(&datetime); diff --git a/ffi/capi/Cargo.toml b/ffi/capi/Cargo.toml index a17afea2749..f2d6c816edf 100644 --- a/ffi/capi/Cargo.toml +++ b/ffi/capi/Cargo.toml @@ -118,8 +118,8 @@ diplomat = { workspace = true } diplomat-runtime = { workspace = true } # Optional ICU4X components and their dependent utils -fixed_decimal = { workspace = true, features = ["ryu"] , optional = true} -icu_calendar = { workspace = true, optional = true } +fixed_decimal = { workspace = true, features = ["ryu"] , optional = true } +icu_calendar = { workspace = true, features = ["ixdtf"], optional = true } icu_casemap = { workspace = true, optional = true } icu_collator = { workspace = true, optional = true } icu_collections = { workspace = true, optional = true } diff --git a/ffi/capi/bindings/c/Bidi.h b/ffi/capi/bindings/c/Bidi.h index 9fe92d0c5ae..79911ade686 100644 --- a/ffi/capi/bindings/c/Bidi.h +++ b/ffi/capi/bindings/c/Bidi.h @@ -22,7 +22,7 @@ typedef struct icu4x_Bidi_create_mv1_result {union {Bidi* ok; DataError err;}; bool is_ok;} icu4x_Bidi_create_mv1_result; icu4x_Bidi_create_mv1_result icu4x_Bidi_create_mv1(const DataProvider* provider); -BidiInfo* icu4x_Bidi_for_text_mv1(const Bidi* self, const char* text_data, size_t text_len, uint8_t default_level); +BidiInfo* icu4x_Bidi_for_text_utf8_mv1(const Bidi* self, const char* text_data, size_t text_len, uint8_t default_level); ReorderedIndexMap* icu4x_Bidi_reorder_visual_mv1(const Bidi* self, const uint8_t* levels_data, size_t levels_len); @@ -30,9 +30,9 @@ bool icu4x_Bidi_level_is_rtl_mv1(uint8_t level); bool icu4x_Bidi_level_is_ltr_mv1(uint8_t level); -uint8_t icu4x_Bidi_level_rtl_mv1(); +uint8_t icu4x_Bidi_level_rtl_mv1(void); -uint8_t icu4x_Bidi_level_ltr_mv1(); +uint8_t icu4x_Bidi_level_ltr_mv1(void); void icu4x_Bidi_destroy_mv1(Bidi* self); diff --git a/ffi/capi/bindings/c/CalendarParseError.d.h b/ffi/capi/bindings/c/CalendarParseError.d.h new file mode 100644 index 00000000000..7d08754d40c --- /dev/null +++ b/ffi/capi/bindings/c/CalendarParseError.d.h @@ -0,0 +1,26 @@ +#ifndef CalendarParseError_D_H +#define CalendarParseError_D_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + + + + +typedef enum CalendarParseError { + CalendarParseError_Unknown = 0, + CalendarParseError_InvalidSyntax = 1, + CalendarParseError_OutOfRange = 2, + CalendarParseError_MissingFields = 3, + CalendarParseError_UnknownCalendar = 4, +} CalendarParseError; + + + + + +#endif // CalendarParseError_D_H diff --git a/ffi/capi/bindings/c/CalendarParseError.h b/ffi/capi/bindings/c/CalendarParseError.h new file mode 100644 index 00000000000..6f0ed1c9977 --- /dev/null +++ b/ffi/capi/bindings/c/CalendarParseError.h @@ -0,0 +1,23 @@ +#ifndef CalendarParseError_H +#define CalendarParseError_H + +#include +#include +#include +#include +#include "diplomat_runtime.h" + + +#include "CalendarParseError.d.h" + + + + + + + + + + + +#endif // CalendarParseError_H diff --git a/ffi/capi/bindings/c/CanonicalCombiningClassMap.h b/ffi/capi/bindings/c/CanonicalCombiningClassMap.h index 0981c7bd99b..02faebbc5f1 100644 --- a/ffi/capi/bindings/c/CanonicalCombiningClassMap.h +++ b/ffi/capi/bindings/c/CanonicalCombiningClassMap.h @@ -22,8 +22,6 @@ icu4x_CanonicalCombiningClassMap_create_mv1_result icu4x_CanonicalCombiningClass uint8_t icu4x_CanonicalCombiningClassMap_get_mv1(const CanonicalCombiningClassMap* self, char32_t ch); -uint8_t icu4x_CanonicalCombiningClassMap_get32_mv1(const CanonicalCombiningClassMap* self, uint32_t ch); - void icu4x_CanonicalCombiningClassMap_destroy_mv1(CanonicalCombiningClassMap* self); diff --git a/ffi/capi/bindings/c/CodePointMapData16.h b/ffi/capi/bindings/c/CodePointMapData16.h index 7f0ed8ef8fb..119b0605224 100644 --- a/ffi/capi/bindings/c/CodePointMapData16.h +++ b/ffi/capi/bindings/c/CodePointMapData16.h @@ -21,8 +21,6 @@ uint16_t icu4x_CodePointMapData16_get_mv1(const CodePointMapData16* self, char32_t cp); -uint16_t icu4x_CodePointMapData16_get32_mv1(const CodePointMapData16* self, uint32_t cp); - CodePointRangeIterator* icu4x_CodePointMapData16_iter_ranges_for_value_mv1(const CodePointMapData16* self, uint16_t value); CodePointRangeIterator* icu4x_CodePointMapData16_iter_ranges_for_value_complemented_mv1(const CodePointMapData16* self, uint16_t value); diff --git a/ffi/capi/bindings/c/CodePointMapData8.h b/ffi/capi/bindings/c/CodePointMapData8.h index 99e1d76d24e..235ff5dec00 100644 --- a/ffi/capi/bindings/c/CodePointMapData8.h +++ b/ffi/capi/bindings/c/CodePointMapData8.h @@ -21,8 +21,6 @@ uint8_t icu4x_CodePointMapData8_get_mv1(const CodePointMapData8* self, char32_t cp); -uint8_t icu4x_CodePointMapData8_get32_mv1(const CodePointMapData8* self, uint32_t cp); - uint32_t icu4x_CodePointMapData8_general_category_to_mask_mv1(uint8_t gc); CodePointRangeIterator* icu4x_CodePointMapData8_iter_ranges_for_value_mv1(const CodePointMapData8* self, uint8_t value); diff --git a/ffi/capi/bindings/c/CodePointSetBuilder.h b/ffi/capi/bindings/c/CodePointSetBuilder.h index fc2980294bb..eb2dbc46782 100644 --- a/ffi/capi/bindings/c/CodePointSetBuilder.h +++ b/ffi/capi/bindings/c/CodePointSetBuilder.h @@ -16,7 +16,7 @@ -CodePointSetBuilder* icu4x_CodePointSetBuilder_create_mv1(); +CodePointSetBuilder* icu4x_CodePointSetBuilder_create_mv1(void); CodePointSetData* icu4x_CodePointSetBuilder_build_mv1(CodePointSetBuilder* self); diff --git a/ffi/capi/bindings/c/CodePointSetData.h b/ffi/capi/bindings/c/CodePointSetData.h index c1f4d723152..61b34073558 100644 --- a/ffi/capi/bindings/c/CodePointSetData.h +++ b/ffi/capi/bindings/c/CodePointSetData.h @@ -21,8 +21,6 @@ bool icu4x_CodePointSetData_contains_mv1(const CodePointSetData* self, char32_t cp); -bool icu4x_CodePointSetData_contains32_mv1(const CodePointSetData* self, uint32_t cp); - CodePointRangeIterator* icu4x_CodePointSetData_iter_ranges_mv1(const CodePointSetData* self); CodePointRangeIterator* icu4x_CodePointSetData_iter_ranges_complemented_mv1(const CodePointSetData* self); diff --git a/ffi/capi/bindings/c/Collator.h b/ffi/capi/bindings/c/Collator.h index 41d4ced1dc5..e1d0a13dc05 100644 --- a/ffi/capi/bindings/c/Collator.h +++ b/ffi/capi/bindings/c/Collator.h @@ -23,11 +23,11 @@ typedef struct icu4x_Collator_create_v1_mv1_result {union {Collator* ok; DataError err;}; bool is_ok;} icu4x_Collator_create_v1_mv1_result; icu4x_Collator_create_v1_mv1_result icu4x_Collator_create_v1_mv1(const DataProvider* provider, const Locale* locale, CollatorOptionsV1 options); -int8_t icu4x_Collator_compare_utf16_mv1(const Collator* self, const char16_t* left_data, size_t left_len, const char16_t* right_data, size_t right_len); +int8_t icu4x_Collator_compare_utf8_mv1(const Collator* self, const char* left_data, size_t left_len, const char* right_data, size_t right_len); -int8_t icu4x_Collator_compare_mv1(const Collator* self, const char* left_data, size_t left_len, const char* right_data, size_t right_len); +int8_t icu4x_Collator_compare_utf16_mv1(const Collator* self, const char16_t* left_data, size_t left_len, const char16_t* right_data, size_t right_len); -CollatorResolvedOptionsV1 icu4x_Collator_resolved_options_mv1(const Collator* self); +CollatorResolvedOptionsV1 icu4x_Collator_resolved_options_v1_mv1(const Collator* self); void icu4x_Collator_destroy_mv1(Collator* self); diff --git a/ffi/capi/bindings/c/ComposingNormalizer.h b/ffi/capi/bindings/c/ComposingNormalizer.h index bcbebac271d..6017a36a101 100644 --- a/ffi/capi/bindings/c/ComposingNormalizer.h +++ b/ffi/capi/bindings/c/ComposingNormalizer.h @@ -25,11 +25,11 @@ icu4x_ComposingNormalizer_create_nfkc_mv1_result icu4x_ComposingNormalizer_creat void icu4x_ComposingNormalizer_normalize_mv1(const ComposingNormalizer* self, const char* s_data, size_t s_len, DiplomatWrite* write); -bool icu4x_ComposingNormalizer_is_normalized_mv1(const ComposingNormalizer* self, const char* s_data, size_t s_len); +bool icu4x_ComposingNormalizer_is_normalized_utf8_mv1(const ComposingNormalizer* self, const char* s_data, size_t s_len); bool icu4x_ComposingNormalizer_is_normalized_utf16_mv1(const ComposingNormalizer* self, const char16_t* s_data, size_t s_len); -size_t icu4x_ComposingNormalizer_is_normalized_up_to_mv1(const ComposingNormalizer* self, const char* s_data, size_t s_len); +size_t icu4x_ComposingNormalizer_is_normalized_utf8_up_to_mv1(const ComposingNormalizer* self, const char* s_data, size_t s_len); size_t icu4x_ComposingNormalizer_is_normalized_utf16_up_to_mv1(const ComposingNormalizer* self, const char16_t* s_data, size_t s_len); diff --git a/ffi/capi/bindings/c/CustomTimeZone.h b/ffi/capi/bindings/c/CustomTimeZone.h index 6181a71e2e8..ec64cbf000f 100644 --- a/ffi/capi/bindings/c/CustomTimeZone.h +++ b/ffi/capi/bindings/c/CustomTimeZone.h @@ -10,8 +10,6 @@ #include "IsoDateTime.d.h" #include "MetazoneCalculator.d.h" #include "TimeZoneIdMapper.d.h" -#include "TimeZoneInvalidIdError.d.h" -#include "TimeZoneInvalidOffsetError.d.h" #include "CustomTimeZone.d.h" @@ -20,18 +18,18 @@ -typedef struct icu4x_CustomTimeZone_create_from_string_mv1_result {union {CustomTimeZone* ok; TimeZoneInvalidOffsetError err;}; bool is_ok;} icu4x_CustomTimeZone_create_from_string_mv1_result; -icu4x_CustomTimeZone_create_from_string_mv1_result icu4x_CustomTimeZone_create_from_string_mv1(const char* s_data, size_t s_len); +typedef struct icu4x_CustomTimeZone_from_string_mv1_result {union {CustomTimeZone* ok; }; bool is_ok;} icu4x_CustomTimeZone_from_string_mv1_result; +icu4x_CustomTimeZone_from_string_mv1_result icu4x_CustomTimeZone_from_string_mv1(const char* s_data, size_t s_len); -CustomTimeZone* icu4x_CustomTimeZone_create_empty_mv1(); +CustomTimeZone* icu4x_CustomTimeZone_empty_mv1(void); -CustomTimeZone* icu4x_CustomTimeZone_create_utc_mv1(); +CustomTimeZone* icu4x_CustomTimeZone_utc_mv1(void); -CustomTimeZone* icu4x_CustomTimeZone_create_gmt_mv1(); +CustomTimeZone* icu4x_CustomTimeZone_gmt_mv1(void); -CustomTimeZone* icu4x_CustomTimeZone_create_bst_mv1(); +CustomTimeZone* icu4x_CustomTimeZone_bst_mv1(void); -typedef struct icu4x_CustomTimeZone_try_set_gmt_offset_seconds_mv1_result {union { TimeZoneInvalidOffsetError err;}; bool is_ok;} icu4x_CustomTimeZone_try_set_gmt_offset_seconds_mv1_result; +typedef struct icu4x_CustomTimeZone_try_set_gmt_offset_seconds_mv1_result { bool is_ok;} icu4x_CustomTimeZone_try_set_gmt_offset_seconds_mv1_result; icu4x_CustomTimeZone_try_set_gmt_offset_seconds_mv1_result icu4x_CustomTimeZone_try_set_gmt_offset_seconds_mv1(CustomTimeZone* self, int32_t offset_seconds); void icu4x_CustomTimeZone_set_gmt_offset_eighths_of_hour_mv1(CustomTimeZone* self, int8_t offset_eighths_of_hour); @@ -53,10 +51,10 @@ icu4x_CustomTimeZone_gmt_offset_has_minutes_mv1_result icu4x_CustomTimeZone_gmt_ typedef struct icu4x_CustomTimeZone_gmt_offset_has_seconds_mv1_result {union {bool ok; }; bool is_ok;} icu4x_CustomTimeZone_gmt_offset_has_seconds_mv1_result; icu4x_CustomTimeZone_gmt_offset_has_seconds_mv1_result icu4x_CustomTimeZone_gmt_offset_has_seconds_mv1(const CustomTimeZone* self); -typedef struct icu4x_CustomTimeZone_try_set_time_zone_id_mv1_result {union { TimeZoneInvalidIdError err;}; bool is_ok;} icu4x_CustomTimeZone_try_set_time_zone_id_mv1_result; +typedef struct icu4x_CustomTimeZone_try_set_time_zone_id_mv1_result { bool is_ok;} icu4x_CustomTimeZone_try_set_time_zone_id_mv1_result; icu4x_CustomTimeZone_try_set_time_zone_id_mv1_result icu4x_CustomTimeZone_try_set_time_zone_id_mv1(CustomTimeZone* self, const char* id_data, size_t id_len); -typedef struct icu4x_CustomTimeZone_try_set_iana_time_zone_id_mv1_result {union { TimeZoneInvalidIdError err;}; bool is_ok;} icu4x_CustomTimeZone_try_set_iana_time_zone_id_mv1_result; +typedef struct icu4x_CustomTimeZone_try_set_iana_time_zone_id_mv1_result { bool is_ok;} icu4x_CustomTimeZone_try_set_iana_time_zone_id_mv1_result; icu4x_CustomTimeZone_try_set_iana_time_zone_id_mv1_result icu4x_CustomTimeZone_try_set_iana_time_zone_id_mv1(CustomTimeZone* self, const TimeZoneIdMapper* mapper, const char* id_data, size_t id_len); void icu4x_CustomTimeZone_clear_time_zone_id_mv1(CustomTimeZone* self); @@ -64,7 +62,7 @@ void icu4x_CustomTimeZone_clear_time_zone_id_mv1(CustomTimeZone* self); typedef struct icu4x_CustomTimeZone_time_zone_id_mv1_result { bool is_ok;} icu4x_CustomTimeZone_time_zone_id_mv1_result; icu4x_CustomTimeZone_time_zone_id_mv1_result icu4x_CustomTimeZone_time_zone_id_mv1(const CustomTimeZone* self, DiplomatWrite* write); -typedef struct icu4x_CustomTimeZone_try_set_metazone_id_mv1_result {union { TimeZoneInvalidIdError err;}; bool is_ok;} icu4x_CustomTimeZone_try_set_metazone_id_mv1_result; +typedef struct icu4x_CustomTimeZone_try_set_metazone_id_mv1_result { bool is_ok;} icu4x_CustomTimeZone_try_set_metazone_id_mv1_result; icu4x_CustomTimeZone_try_set_metazone_id_mv1_result icu4x_CustomTimeZone_try_set_metazone_id_mv1(CustomTimeZone* self, const char* id_data, size_t id_len); void icu4x_CustomTimeZone_clear_metazone_id_mv1(CustomTimeZone* self); diff --git a/ffi/capi/bindings/c/DataProvider.h b/ffi/capi/bindings/c/DataProvider.h index 0543df31311..f86672c5dd6 100644 --- a/ffi/capi/bindings/c/DataProvider.h +++ b/ffi/capi/bindings/c/DataProvider.h @@ -17,15 +17,15 @@ -DataProvider* icu4x_DataProvider_create_compiled_mv1(); +DataProvider* icu4x_DataProvider_compiled_mv1(void); -typedef struct icu4x_DataProvider_create_fs_mv1_result {union {DataProvider* ok; DataError err;}; bool is_ok;} icu4x_DataProvider_create_fs_mv1_result; -icu4x_DataProvider_create_fs_mv1_result icu4x_DataProvider_create_fs_mv1(const char* path_data, size_t path_len); +typedef struct icu4x_DataProvider_from_fs_mv1_result {union {DataProvider* ok; DataError err;}; bool is_ok;} icu4x_DataProvider_from_fs_mv1_result; +icu4x_DataProvider_from_fs_mv1_result icu4x_DataProvider_from_fs_mv1(const char* path_data, size_t path_len); -typedef struct icu4x_DataProvider_create_from_byte_slice_mv1_result {union {DataProvider* ok; DataError err;}; bool is_ok;} icu4x_DataProvider_create_from_byte_slice_mv1_result; -icu4x_DataProvider_create_from_byte_slice_mv1_result icu4x_DataProvider_create_from_byte_slice_mv1(const uint8_t* blob_data, size_t blob_len); +typedef struct icu4x_DataProvider_from_byte_slice_mv1_result {union {DataProvider* ok; DataError err;}; bool is_ok;} icu4x_DataProvider_from_byte_slice_mv1_result; +icu4x_DataProvider_from_byte_slice_mv1_result icu4x_DataProvider_from_byte_slice_mv1(const uint8_t* blob_data, size_t blob_len); -DataProvider* icu4x_DataProvider_create_empty_mv1(); +DataProvider* icu4x_DataProvider_empty_mv1(void); typedef struct icu4x_DataProvider_fork_by_key_mv1_result {union { DataError err;}; bool is_ok;} icu4x_DataProvider_fork_by_key_mv1_result; icu4x_DataProvider_fork_by_key_mv1_result icu4x_DataProvider_fork_by_key_mv1(DataProvider* self, DataProvider* other); diff --git a/ffi/capi/bindings/c/DataStruct.d.h b/ffi/capi/bindings/c/DataStruct.d.h deleted file mode 100644 index c3711df030b..00000000000 --- a/ffi/capi/bindings/c/DataStruct.d.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef DataStruct_D_H -#define DataStruct_D_H - -#include -#include -#include -#include -#include "diplomat_runtime.h" - - - - - -typedef struct DataStruct DataStruct; - - - - -#endif // DataStruct_D_H diff --git a/ffi/capi/bindings/c/DataStruct.h b/ffi/capi/bindings/c/DataStruct.h deleted file mode 100644 index b762456184d..00000000000 --- a/ffi/capi/bindings/c/DataStruct.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef DataStruct_H -#define DataStruct_H - -#include -#include -#include -#include -#include "diplomat_runtime.h" - - -#include "DataStruct.d.h" - - - - - - -DataStruct* icu4x_DataStruct_create_decimal_symbols_v1_mv1(const char* plus_sign_prefix_data, size_t plus_sign_prefix_len, const char* plus_sign_suffix_data, size_t plus_sign_suffix_len, const char* minus_sign_prefix_data, size_t minus_sign_prefix_len, const char* minus_sign_suffix_data, size_t minus_sign_suffix_len, const char* decimal_separator_data, size_t decimal_separator_len, const char* grouping_separator_data, size_t grouping_separator_len, uint8_t primary_group_size, uint8_t secondary_group_size, uint8_t min_group_size, const char32_t* digits_data, size_t digits_len); - - -void icu4x_DataStruct_destroy_mv1(DataStruct* self); - - - - - -#endif // DataStruct_H diff --git a/ffi/capi/bindings/c/Date.h b/ffi/capi/bindings/c/Date.h index 4fec3e9208a..6c25b2e43b2 100644 --- a/ffi/capi/bindings/c/Date.h +++ b/ffi/capi/bindings/c/Date.h @@ -9,6 +9,7 @@ #include "Calendar.d.h" #include "CalendarError.d.h" +#include "CalendarParseError.d.h" #include "IsoDate.d.h" #include "IsoWeekday.d.h" #include "WeekCalculator.d.h" @@ -21,11 +22,14 @@ -typedef struct icu4x_Date_create_from_iso_in_calendar_mv1_result {union {Date* ok; CalendarError err;}; bool is_ok;} icu4x_Date_create_from_iso_in_calendar_mv1_result; -icu4x_Date_create_from_iso_in_calendar_mv1_result icu4x_Date_create_from_iso_in_calendar_mv1(int32_t year, uint8_t month, uint8_t day, const Calendar* calendar); +typedef struct icu4x_Date_from_iso_in_calendar_mv1_result {union {Date* ok; CalendarError err;}; bool is_ok;} icu4x_Date_from_iso_in_calendar_mv1_result; +icu4x_Date_from_iso_in_calendar_mv1_result icu4x_Date_from_iso_in_calendar_mv1(int32_t year, uint8_t month, uint8_t day, const Calendar* calendar); -typedef struct icu4x_Date_create_from_codes_in_calendar_mv1_result {union {Date* ok; CalendarError err;}; bool is_ok;} icu4x_Date_create_from_codes_in_calendar_mv1_result; -icu4x_Date_create_from_codes_in_calendar_mv1_result icu4x_Date_create_from_codes_in_calendar_mv1(const char* era_code_data, size_t era_code_len, int32_t year, const char* month_code_data, size_t month_code_len, uint8_t day, const Calendar* calendar); +typedef struct icu4x_Date_from_codes_in_calendar_mv1_result {union {Date* ok; CalendarError err;}; bool is_ok;} icu4x_Date_from_codes_in_calendar_mv1_result; +icu4x_Date_from_codes_in_calendar_mv1_result icu4x_Date_from_codes_in_calendar_mv1(const char* era_code_data, size_t era_code_len, int32_t year, const char* month_code_data, size_t month_code_len, uint8_t day, const Calendar* calendar); + +typedef struct icu4x_Date_from_string_mv1_result {union {Date* ok; CalendarParseError err;}; bool is_ok;} icu4x_Date_from_string_mv1_result; +icu4x_Date_from_string_mv1_result icu4x_Date_from_string_mv1(const char* v_data, size_t v_len); Date* icu4x_Date_to_calendar_mv1(const Date* self, const Calendar* calendar); diff --git a/ffi/capi/bindings/c/DateTime.h b/ffi/capi/bindings/c/DateTime.h index 5d61d0a088d..5277770e9bd 100644 --- a/ffi/capi/bindings/c/DateTime.h +++ b/ffi/capi/bindings/c/DateTime.h @@ -9,6 +9,7 @@ #include "Calendar.d.h" #include "CalendarError.d.h" +#include "CalendarParseError.d.h" #include "Date.d.h" #include "IsoDateTime.d.h" #include "IsoWeekday.d.h" @@ -23,13 +24,16 @@ -typedef struct icu4x_DateTime_create_from_iso_in_calendar_mv1_result {union {DateTime* ok; CalendarError err;}; bool is_ok;} icu4x_DateTime_create_from_iso_in_calendar_mv1_result; -icu4x_DateTime_create_from_iso_in_calendar_mv1_result icu4x_DateTime_create_from_iso_in_calendar_mv1(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const Calendar* calendar); +typedef struct icu4x_DateTime_from_iso_in_calendar_mv1_result {union {DateTime* ok; CalendarError err;}; bool is_ok;} icu4x_DateTime_from_iso_in_calendar_mv1_result; +icu4x_DateTime_from_iso_in_calendar_mv1_result icu4x_DateTime_from_iso_in_calendar_mv1(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const Calendar* calendar); -typedef struct icu4x_DateTime_create_from_codes_in_calendar_mv1_result {union {DateTime* ok; CalendarError err;}; bool is_ok;} icu4x_DateTime_create_from_codes_in_calendar_mv1_result; -icu4x_DateTime_create_from_codes_in_calendar_mv1_result icu4x_DateTime_create_from_codes_in_calendar_mv1(const char* era_code_data, size_t era_code_len, int32_t year, const char* month_code_data, size_t month_code_len, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const Calendar* calendar); +typedef struct icu4x_DateTime_from_codes_in_calendar_mv1_result {union {DateTime* ok; CalendarError err;}; bool is_ok;} icu4x_DateTime_from_codes_in_calendar_mv1_result; +icu4x_DateTime_from_codes_in_calendar_mv1_result icu4x_DateTime_from_codes_in_calendar_mv1(const char* era_code_data, size_t era_code_len, int32_t year, const char* month_code_data, size_t month_code_len, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const Calendar* calendar); -DateTime* icu4x_DateTime_create_from_date_and_time_mv1(const Date* date, const Time* time); +DateTime* icu4x_DateTime_from_date_and_time_mv1(const Date* date, const Time* time); + +typedef struct icu4x_DateTime_from_string_mv1_result {union {DateTime* ok; CalendarParseError err;}; bool is_ok;} icu4x_DateTime_from_string_mv1_result; +icu4x_DateTime_from_string_mv1_result icu4x_DateTime_from_string_mv1(const char* v_data, size_t v_len); Date* icu4x_DateTime_date_mv1(const DateTime* self); diff --git a/ffi/capi/bindings/c/FixedDecimal.h b/ffi/capi/bindings/c/FixedDecimal.h index 83c0bb16fd4..9de9f3b8cca 100644 --- a/ffi/capi/bindings/c/FixedDecimal.h +++ b/ffi/capi/bindings/c/FixedDecimal.h @@ -7,7 +7,6 @@ #include #include "diplomat_runtime.h" -#include "FixedDecimalLimitError.d.h" #include "FixedDecimalParseError.d.h" #include "FixedDecimalRoundingIncrement.d.h" #include "FixedDecimalRoundingMode.d.h" @@ -21,28 +20,28 @@ -FixedDecimal* icu4x_FixedDecimal_create_from_i32_mv1(int32_t v); +FixedDecimal* icu4x_FixedDecimal_from_int32_mv1(int32_t v); -FixedDecimal* icu4x_FixedDecimal_create_from_u32_mv1(uint32_t v); +FixedDecimal* icu4x_FixedDecimal_from_uint32_mv1(uint32_t v); -FixedDecimal* icu4x_FixedDecimal_create_from_i64_mv1(int64_t v); +FixedDecimal* icu4x_FixedDecimal_from_int64_mv1(int64_t v); -FixedDecimal* icu4x_FixedDecimal_create_from_u64_mv1(uint64_t v); +FixedDecimal* icu4x_FixedDecimal_from_uint64_mv1(uint64_t v); -typedef struct icu4x_FixedDecimal_create_from_f64_with_integer_precision_mv1_result {union {FixedDecimal* ok; FixedDecimalLimitError err;}; bool is_ok;} icu4x_FixedDecimal_create_from_f64_with_integer_precision_mv1_result; -icu4x_FixedDecimal_create_from_f64_with_integer_precision_mv1_result icu4x_FixedDecimal_create_from_f64_with_integer_precision_mv1(double f); +typedef struct icu4x_FixedDecimal_from_double_with_integer_precision_mv1_result {union {FixedDecimal* ok; }; bool is_ok;} icu4x_FixedDecimal_from_double_with_integer_precision_mv1_result; +icu4x_FixedDecimal_from_double_with_integer_precision_mv1_result icu4x_FixedDecimal_from_double_with_integer_precision_mv1(double f); -typedef struct icu4x_FixedDecimal_create_from_f64_with_lower_magnitude_mv1_result {union {FixedDecimal* ok; FixedDecimalLimitError err;}; bool is_ok;} icu4x_FixedDecimal_create_from_f64_with_lower_magnitude_mv1_result; -icu4x_FixedDecimal_create_from_f64_with_lower_magnitude_mv1_result icu4x_FixedDecimal_create_from_f64_with_lower_magnitude_mv1(double f, int16_t magnitude); +typedef struct icu4x_FixedDecimal_from_double_with_lower_magnitude_mv1_result {union {FixedDecimal* ok; }; bool is_ok;} icu4x_FixedDecimal_from_double_with_lower_magnitude_mv1_result; +icu4x_FixedDecimal_from_double_with_lower_magnitude_mv1_result icu4x_FixedDecimal_from_double_with_lower_magnitude_mv1(double f, int16_t magnitude); -typedef struct icu4x_FixedDecimal_create_from_f64_with_significant_digits_mv1_result {union {FixedDecimal* ok; FixedDecimalLimitError err;}; bool is_ok;} icu4x_FixedDecimal_create_from_f64_with_significant_digits_mv1_result; -icu4x_FixedDecimal_create_from_f64_with_significant_digits_mv1_result icu4x_FixedDecimal_create_from_f64_with_significant_digits_mv1(double f, uint8_t digits); +typedef struct icu4x_FixedDecimal_from_double_with_significant_digits_mv1_result {union {FixedDecimal* ok; }; bool is_ok;} icu4x_FixedDecimal_from_double_with_significant_digits_mv1_result; +icu4x_FixedDecimal_from_double_with_significant_digits_mv1_result icu4x_FixedDecimal_from_double_with_significant_digits_mv1(double f, uint8_t digits); -typedef struct icu4x_FixedDecimal_create_from_f64_with_floating_precision_mv1_result {union {FixedDecimal* ok; FixedDecimalLimitError err;}; bool is_ok;} icu4x_FixedDecimal_create_from_f64_with_floating_precision_mv1_result; -icu4x_FixedDecimal_create_from_f64_with_floating_precision_mv1_result icu4x_FixedDecimal_create_from_f64_with_floating_precision_mv1(double f); +typedef struct icu4x_FixedDecimal_from_double_with_floating_precision_mv1_result {union {FixedDecimal* ok; }; bool is_ok;} icu4x_FixedDecimal_from_double_with_floating_precision_mv1_result; +icu4x_FixedDecimal_from_double_with_floating_precision_mv1_result icu4x_FixedDecimal_from_double_with_floating_precision_mv1(double f); -typedef struct icu4x_FixedDecimal_create_from_string_mv1_result {union {FixedDecimal* ok; FixedDecimalParseError err;}; bool is_ok;} icu4x_FixedDecimal_create_from_string_mv1_result; -icu4x_FixedDecimal_create_from_string_mv1_result icu4x_FixedDecimal_create_from_string_mv1(const char* v_data, size_t v_len); +typedef struct icu4x_FixedDecimal_from_string_mv1_result {union {FixedDecimal* ok; FixedDecimalParseError err;}; bool is_ok;} icu4x_FixedDecimal_from_string_mv1_result; +icu4x_FixedDecimal_from_string_mv1_result icu4x_FixedDecimal_from_string_mv1(const char* v_data, size_t v_len); uint8_t icu4x_FixedDecimal_digit_at_mv1(const FixedDecimal* self, int16_t magnitude); diff --git a/ffi/capi/bindings/c/FixedDecimalFormatter.h b/ffi/capi/bindings/c/FixedDecimalFormatter.h index 1bb5764ad3a..02682967a81 100644 --- a/ffi/capi/bindings/c/FixedDecimalFormatter.h +++ b/ffi/capi/bindings/c/FixedDecimalFormatter.h @@ -9,7 +9,6 @@ #include "DataError.d.h" #include "DataProvider.d.h" -#include "DataStruct.d.h" #include "FixedDecimal.d.h" #include "FixedDecimalGroupingStrategy.d.h" #include "Locale.d.h" @@ -24,8 +23,8 @@ typedef struct icu4x_FixedDecimalFormatter_create_with_grouping_strategy_mv1_result {union {FixedDecimalFormatter* ok; DataError err;}; bool is_ok;} icu4x_FixedDecimalFormatter_create_with_grouping_strategy_mv1_result; icu4x_FixedDecimalFormatter_create_with_grouping_strategy_mv1_result icu4x_FixedDecimalFormatter_create_with_grouping_strategy_mv1(const DataProvider* provider, const Locale* locale, FixedDecimalGroupingStrategy grouping_strategy); -typedef struct icu4x_FixedDecimalFormatter_create_with_decimal_symbols_v1_mv1_result {union {FixedDecimalFormatter* ok; DataError err;}; bool is_ok;} icu4x_FixedDecimalFormatter_create_with_decimal_symbols_v1_mv1_result; -icu4x_FixedDecimalFormatter_create_with_decimal_symbols_v1_mv1_result icu4x_FixedDecimalFormatter_create_with_decimal_symbols_v1_mv1(const DataStruct* data_struct, FixedDecimalGroupingStrategy grouping_strategy); +typedef struct icu4x_FixedDecimalFormatter_create_with_manual_data_mv1_result {union {FixedDecimalFormatter* ok; DataError err;}; bool is_ok;} icu4x_FixedDecimalFormatter_create_with_manual_data_mv1_result; +icu4x_FixedDecimalFormatter_create_with_manual_data_mv1_result icu4x_FixedDecimalFormatter_create_with_manual_data_mv1(const char* plus_sign_prefix_data, size_t plus_sign_prefix_len, const char* plus_sign_suffix_data, size_t plus_sign_suffix_len, const char* minus_sign_prefix_data, size_t minus_sign_prefix_len, const char* minus_sign_suffix_data, size_t minus_sign_suffix_len, const char* decimal_separator_data, size_t decimal_separator_len, const char* grouping_separator_data, size_t grouping_separator_len, uint8_t primary_group_size, uint8_t secondary_group_size, uint8_t min_group_size, const char32_t* digits_data, size_t digits_len, FixedDecimalGroupingStrategy grouping_strategy); void icu4x_FixedDecimalFormatter_format_mv1(const FixedDecimalFormatter* self, const FixedDecimal* value, DiplomatWrite* write); diff --git a/ffi/capi/bindings/c/FixedDecimalLimitError.d.h b/ffi/capi/bindings/c/FixedDecimalLimitError.d.h index df533137a1e..ebd8565d611 100644 --- a/ffi/capi/bindings/c/FixedDecimalLimitError.d.h +++ b/ffi/capi/bindings/c/FixedDecimalLimitError.d.h @@ -11,9 +11,7 @@ -typedef enum FixedDecimalLimitError { - FixedDecimalLimitError_TodoZst = 0, -} FixedDecimalLimitError; + diff --git a/ffi/capi/bindings/c/IsoDate.h b/ffi/capi/bindings/c/IsoDate.h index f1ef11b7c99..f269b6fe0eb 100644 --- a/ffi/capi/bindings/c/IsoDate.h +++ b/ffi/capi/bindings/c/IsoDate.h @@ -9,6 +9,7 @@ #include "Calendar.d.h" #include "CalendarError.d.h" +#include "CalendarParseError.d.h" #include "Date.d.h" #include "IsoWeekday.d.h" #include "WeekCalculator.d.h" @@ -24,7 +25,10 @@ typedef struct icu4x_IsoDate_create_mv1_result {union {IsoDate* ok; CalendarError err;}; bool is_ok;} icu4x_IsoDate_create_mv1_result; icu4x_IsoDate_create_mv1_result icu4x_IsoDate_create_mv1(int32_t year, uint8_t month, uint8_t day); -IsoDate* icu4x_IsoDate_create_for_unix_epoch_mv1(); +typedef struct icu4x_IsoDate_from_string_mv1_result {union {IsoDate* ok; CalendarParseError err;}; bool is_ok;} icu4x_IsoDate_from_string_mv1_result; +icu4x_IsoDate_from_string_mv1_result icu4x_IsoDate_from_string_mv1(const char* v_data, size_t v_len); + +IsoDate* icu4x_IsoDate_unix_epoch_mv1(void); Date* icu4x_IsoDate_to_calendar_mv1(const IsoDate* self, const Calendar* calendar); diff --git a/ffi/capi/bindings/c/IsoDateTime.h b/ffi/capi/bindings/c/IsoDateTime.h index b759ad24fc8..42c6e20b811 100644 --- a/ffi/capi/bindings/c/IsoDateTime.h +++ b/ffi/capi/bindings/c/IsoDateTime.h @@ -9,6 +9,7 @@ #include "Calendar.d.h" #include "CalendarError.d.h" +#include "CalendarParseError.d.h" #include "DateTime.d.h" #include "IsoDate.d.h" #include "IsoWeekday.d.h" @@ -26,11 +27,14 @@ typedef struct icu4x_IsoDateTime_create_mv1_result {union {IsoDateTime* ok; CalendarError err;}; bool is_ok;} icu4x_IsoDateTime_create_mv1_result; icu4x_IsoDateTime_create_mv1_result icu4x_IsoDateTime_create_mv1(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond); -IsoDateTime* icu4x_IsoDateTime_crate_from_date_and_time_mv1(const IsoDate* date, const Time* time); +IsoDateTime* icu4x_IsoDateTime_from_date_and_time_mv1(const IsoDate* date, const Time* time); -IsoDateTime* icu4x_IsoDateTime_local_unix_epoch_mv1(); +typedef struct icu4x_IsoDateTime_from_string_mv1_result {union {IsoDateTime* ok; CalendarParseError err;}; bool is_ok;} icu4x_IsoDateTime_from_string_mv1_result; +icu4x_IsoDateTime_from_string_mv1_result icu4x_IsoDateTime_from_string_mv1(const char* v_data, size_t v_len); -IsoDateTime* icu4x_IsoDateTime_create_from_minutes_since_local_unix_epoch_mv1(int32_t minutes); +IsoDateTime* icu4x_IsoDateTime_local_unix_epoch_mv1(void); + +IsoDateTime* icu4x_IsoDateTime_from_minutes_since_local_unix_epoch_mv1(int32_t minutes); IsoDate* icu4x_IsoDateTime_date_mv1(const IsoDateTime* self); diff --git a/ffi/capi/bindings/c/ListFormatter.h b/ffi/capi/bindings/c/ListFormatter.h index 0d1572c1357..0a6a7e95388 100644 --- a/ffi/capi/bindings/c/ListFormatter.h +++ b/ffi/capi/bindings/c/ListFormatter.h @@ -28,8 +28,6 @@ icu4x_ListFormatter_create_or_with_length_mv1_result icu4x_ListFormatter_create_ typedef struct icu4x_ListFormatter_create_unit_with_length_mv1_result {union {ListFormatter* ok; DataError err;}; bool is_ok;} icu4x_ListFormatter_create_unit_with_length_mv1_result; icu4x_ListFormatter_create_unit_with_length_mv1_result icu4x_ListFormatter_create_unit_with_length_mv1(const DataProvider* provider, const Locale* locale, ListLength length); -void icu4x_ListFormatter_format_valid_utf8_mv1(const ListFormatter* self, DiplomatStringsView* list_data, size_t list_len, DiplomatWrite* write); - void icu4x_ListFormatter_format_utf8_mv1(const ListFormatter* self, DiplomatStringsView* list_data, size_t list_len, DiplomatWrite* write); void icu4x_ListFormatter_format_utf16_mv1(const ListFormatter* self, DiplomatStrings16View* list_data, size_t list_len, DiplomatWrite* write); diff --git a/ffi/capi/bindings/c/Locale.h b/ffi/capi/bindings/c/Locale.h index b86780fc6d4..059d4577ea2 100644 --- a/ffi/capi/bindings/c/Locale.h +++ b/ffi/capi/bindings/c/Locale.h @@ -16,10 +16,10 @@ -typedef struct icu4x_Locale_create_from_string_mv1_result {union {Locale* ok; LocaleParseError err;}; bool is_ok;} icu4x_Locale_create_from_string_mv1_result; -icu4x_Locale_create_from_string_mv1_result icu4x_Locale_create_from_string_mv1(const char* name_data, size_t name_len); +typedef struct icu4x_Locale_from_string_mv1_result {union {Locale* ok; LocaleParseError err;}; bool is_ok;} icu4x_Locale_from_string_mv1_result; +icu4x_Locale_from_string_mv1_result icu4x_Locale_from_string_mv1(const char* name_data, size_t name_len); -Locale* icu4x_Locale_create_und_mv1(); +Locale* icu4x_Locale_und_mv1(void); Locale* icu4x_Locale_clone_mv1(const Locale* self); diff --git a/ffi/capi/bindings/c/LocaleDisplayNamesFormatter.h b/ffi/capi/bindings/c/LocaleDisplayNamesFormatter.h index 8a7705bec81..9e6e61fcac7 100644 --- a/ffi/capi/bindings/c/LocaleDisplayNamesFormatter.h +++ b/ffi/capi/bindings/c/LocaleDisplayNamesFormatter.h @@ -19,8 +19,8 @@ -typedef struct icu4x_LocaleDisplayNamesFormatter_create_mv1_result {union {LocaleDisplayNamesFormatter* ok; DataError err;}; bool is_ok;} icu4x_LocaleDisplayNamesFormatter_create_mv1_result; -icu4x_LocaleDisplayNamesFormatter_create_mv1_result icu4x_LocaleDisplayNamesFormatter_create_mv1(const DataProvider* provider, const Locale* locale, DisplayNamesOptionsV1 options); +typedef struct icu4x_LocaleDisplayNamesFormatter_create_v1_mv1_result {union {LocaleDisplayNamesFormatter* ok; DataError err;}; bool is_ok;} icu4x_LocaleDisplayNamesFormatter_create_v1_mv1_result; +icu4x_LocaleDisplayNamesFormatter_create_v1_mv1_result icu4x_LocaleDisplayNamesFormatter_create_v1_mv1(const DataProvider* provider, const Locale* locale, DisplayNamesOptionsV1 options); void icu4x_LocaleDisplayNamesFormatter_of_mv1(const LocaleDisplayNamesFormatter* self, const Locale* locale, DiplomatWrite* write); diff --git a/ffi/capi/bindings/c/LocaleFallbacker.h b/ffi/capi/bindings/c/LocaleFallbacker.h index 16ff5c18b19..aca807736ca 100644 --- a/ffi/capi/bindings/c/LocaleFallbacker.h +++ b/ffi/capi/bindings/c/LocaleFallbacker.h @@ -23,7 +23,7 @@ typedef struct icu4x_LocaleFallbacker_create_mv1_result {union {LocaleFallbacker* ok; DataError err;}; bool is_ok;} icu4x_LocaleFallbacker_create_mv1_result; icu4x_LocaleFallbacker_create_mv1_result icu4x_LocaleFallbacker_create_mv1(const DataProvider* provider); -LocaleFallbacker* icu4x_LocaleFallbacker_create_without_data_mv1(); +LocaleFallbacker* icu4x_LocaleFallbacker_without_data_mv1(void); typedef struct icu4x_LocaleFallbacker_for_config_mv1_result {union {LocaleFallbackerWithConfig* ok; LocaleParseError err;}; bool is_ok;} icu4x_LocaleFallbacker_for_config_mv1_result; icu4x_LocaleFallbacker_for_config_mv1_result icu4x_LocaleFallbacker_for_config_mv1(const LocaleFallbacker* self, LocaleFallbackConfig config); diff --git a/ffi/capi/bindings/c/Logger.h b/ffi/capi/bindings/c/Logger.h index b893066ea13..c17ae55bfc8 100644 --- a/ffi/capi/bindings/c/Logger.h +++ b/ffi/capi/bindings/c/Logger.h @@ -15,7 +15,7 @@ -bool icu4x_Logger_init_simple_logger_mv1(); +bool icu4x_Logger_init_simple_logger_mv1(void); void icu4x_Logger_destroy_mv1(Logger* self); diff --git a/ffi/capi/bindings/c/PluralOperands.h b/ffi/capi/bindings/c/PluralOperands.h index 260eeb75dd5..3448419dfb7 100644 --- a/ffi/capi/bindings/c/PluralOperands.h +++ b/ffi/capi/bindings/c/PluralOperands.h @@ -17,10 +17,10 @@ -typedef struct icu4x_PluralOperands_create_from_string_mv1_result {union {PluralOperands* ok; FixedDecimalParseError err;}; bool is_ok;} icu4x_PluralOperands_create_from_string_mv1_result; -icu4x_PluralOperands_create_from_string_mv1_result icu4x_PluralOperands_create_from_string_mv1(const char* s_data, size_t s_len); +typedef struct icu4x_PluralOperands_from_string_mv1_result {union {PluralOperands* ok; FixedDecimalParseError err;}; bool is_ok;} icu4x_PluralOperands_from_string_mv1_result; +icu4x_PluralOperands_from_string_mv1_result icu4x_PluralOperands_from_string_mv1(const char* s_data, size_t s_len); -PluralOperands* icu4x_PluralOperands_create_from_fixed_decimal_mv1(const FixedDecimal* x); +PluralOperands* icu4x_PluralOperands_from_fixed_decimal_mv1(const FixedDecimal* x); void icu4x_PluralOperands_destroy_mv1(PluralOperands* self); diff --git a/ffi/capi/bindings/c/Time.h b/ffi/capi/bindings/c/Time.h index 9ae1c2c25cb..e73e13d56ba 100644 --- a/ffi/capi/bindings/c/Time.h +++ b/ffi/capi/bindings/c/Time.h @@ -8,6 +8,7 @@ #include "diplomat_runtime.h" #include "CalendarError.d.h" +#include "CalendarParseError.d.h" #include "Time.d.h" @@ -19,8 +20,11 @@ typedef struct icu4x_Time_create_mv1_result {union {Time* ok; CalendarError err;}; bool is_ok;} icu4x_Time_create_mv1_result; icu4x_Time_create_mv1_result icu4x_Time_create_mv1(uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond); -typedef struct icu4x_Time_create_midnight_mv1_result {union {Time* ok; CalendarError err;}; bool is_ok;} icu4x_Time_create_midnight_mv1_result; -icu4x_Time_create_midnight_mv1_result icu4x_Time_create_midnight_mv1(); +typedef struct icu4x_Time_from_string_mv1_result {union {Time* ok; CalendarParseError err;}; bool is_ok;} icu4x_Time_from_string_mv1_result; +icu4x_Time_from_string_mv1_result icu4x_Time_from_string_mv1(const char* v_data, size_t v_len); + +typedef struct icu4x_Time_midnight_mv1_result {union {Time* ok; CalendarError err;}; bool is_ok;} icu4x_Time_midnight_mv1_result; +icu4x_Time_midnight_mv1_result icu4x_Time_midnight_mv1(void); uint8_t icu4x_Time_hour_mv1(const Time* self); diff --git a/ffi/capi/bindings/c/TimeZoneIdMapper.h b/ffi/capi/bindings/c/TimeZoneIdMapper.h index 1acf4fa0fd8..b28400ee05f 100644 --- a/ffi/capi/bindings/c/TimeZoneIdMapper.h +++ b/ffi/capi/bindings/c/TimeZoneIdMapper.h @@ -9,7 +9,6 @@ #include "DataError.d.h" #include "DataProvider.d.h" -#include "TimeZoneInvalidIdError.d.h" #include "TimeZoneIdMapper.d.h" @@ -21,16 +20,16 @@ typedef struct icu4x_TimeZoneIdMapper_create_mv1_result {union {TimeZoneIdMapper* ok; DataError err;}; bool is_ok;} icu4x_TimeZoneIdMapper_create_mv1_result; icu4x_TimeZoneIdMapper_create_mv1_result icu4x_TimeZoneIdMapper_create_mv1(const DataProvider* provider); -typedef struct icu4x_TimeZoneIdMapper_iana_to_bcp47_mv1_result {union { TimeZoneInvalidIdError err;}; bool is_ok;} icu4x_TimeZoneIdMapper_iana_to_bcp47_mv1_result; +typedef struct icu4x_TimeZoneIdMapper_iana_to_bcp47_mv1_result { bool is_ok;} icu4x_TimeZoneIdMapper_iana_to_bcp47_mv1_result; icu4x_TimeZoneIdMapper_iana_to_bcp47_mv1_result icu4x_TimeZoneIdMapper_iana_to_bcp47_mv1(const TimeZoneIdMapper* self, const char* value_data, size_t value_len, DiplomatWrite* write); -typedef struct icu4x_TimeZoneIdMapper_normalize_iana_mv1_result {union { TimeZoneInvalidIdError err;}; bool is_ok;} icu4x_TimeZoneIdMapper_normalize_iana_mv1_result; +typedef struct icu4x_TimeZoneIdMapper_normalize_iana_mv1_result { bool is_ok;} icu4x_TimeZoneIdMapper_normalize_iana_mv1_result; icu4x_TimeZoneIdMapper_normalize_iana_mv1_result icu4x_TimeZoneIdMapper_normalize_iana_mv1(const TimeZoneIdMapper* self, const char* value_data, size_t value_len, DiplomatWrite* write); -typedef struct icu4x_TimeZoneIdMapper_canonicalize_iana_mv1_result {union { TimeZoneInvalidIdError err;}; bool is_ok;} icu4x_TimeZoneIdMapper_canonicalize_iana_mv1_result; +typedef struct icu4x_TimeZoneIdMapper_canonicalize_iana_mv1_result { bool is_ok;} icu4x_TimeZoneIdMapper_canonicalize_iana_mv1_result; icu4x_TimeZoneIdMapper_canonicalize_iana_mv1_result icu4x_TimeZoneIdMapper_canonicalize_iana_mv1(const TimeZoneIdMapper* self, const char* value_data, size_t value_len, DiplomatWrite* write); -typedef struct icu4x_TimeZoneIdMapper_find_canonical_iana_from_bcp47_mv1_result {union { TimeZoneInvalidIdError err;}; bool is_ok;} icu4x_TimeZoneIdMapper_find_canonical_iana_from_bcp47_mv1_result; +typedef struct icu4x_TimeZoneIdMapper_find_canonical_iana_from_bcp47_mv1_result { bool is_ok;} icu4x_TimeZoneIdMapper_find_canonical_iana_from_bcp47_mv1_result; icu4x_TimeZoneIdMapper_find_canonical_iana_from_bcp47_mv1_result icu4x_TimeZoneIdMapper_find_canonical_iana_from_bcp47_mv1(const TimeZoneIdMapper* self, const char* value_data, size_t value_len, DiplomatWrite* write); diff --git a/ffi/capi/bindings/c/TimeZoneIdMapperWithFastCanonicalization.h b/ffi/capi/bindings/c/TimeZoneIdMapperWithFastCanonicalization.h index ba32dc0c9f4..1712dd7c4a4 100644 --- a/ffi/capi/bindings/c/TimeZoneIdMapperWithFastCanonicalization.h +++ b/ffi/capi/bindings/c/TimeZoneIdMapperWithFastCanonicalization.h @@ -9,7 +9,6 @@ #include "DataError.d.h" #include "DataProvider.d.h" -#include "TimeZoneInvalidIdError.d.h" #include "TimeZoneIdMapperWithFastCanonicalization.d.h" @@ -21,10 +20,10 @@ typedef struct icu4x_TimeZoneIdMapperWithFastCanonicalization_create_mv1_result {union {TimeZoneIdMapperWithFastCanonicalization* ok; DataError err;}; bool is_ok;} icu4x_TimeZoneIdMapperWithFastCanonicalization_create_mv1_result; icu4x_TimeZoneIdMapperWithFastCanonicalization_create_mv1_result icu4x_TimeZoneIdMapperWithFastCanonicalization_create_mv1(const DataProvider* provider); -typedef struct icu4x_TimeZoneIdMapperWithFastCanonicalization_canonicalize_iana_mv1_result {union { TimeZoneInvalidIdError err;}; bool is_ok;} icu4x_TimeZoneIdMapperWithFastCanonicalization_canonicalize_iana_mv1_result; +typedef struct icu4x_TimeZoneIdMapperWithFastCanonicalization_canonicalize_iana_mv1_result { bool is_ok;} icu4x_TimeZoneIdMapperWithFastCanonicalization_canonicalize_iana_mv1_result; icu4x_TimeZoneIdMapperWithFastCanonicalization_canonicalize_iana_mv1_result icu4x_TimeZoneIdMapperWithFastCanonicalization_canonicalize_iana_mv1(const TimeZoneIdMapperWithFastCanonicalization* self, const char* value_data, size_t value_len, DiplomatWrite* write); -typedef struct icu4x_TimeZoneIdMapperWithFastCanonicalization_canonical_iana_from_bcp47_mv1_result {union { TimeZoneInvalidIdError err;}; bool is_ok;} icu4x_TimeZoneIdMapperWithFastCanonicalization_canonical_iana_from_bcp47_mv1_result; +typedef struct icu4x_TimeZoneIdMapperWithFastCanonicalization_canonical_iana_from_bcp47_mv1_result { bool is_ok;} icu4x_TimeZoneIdMapperWithFastCanonicalization_canonical_iana_from_bcp47_mv1_result; icu4x_TimeZoneIdMapperWithFastCanonicalization_canonical_iana_from_bcp47_mv1_result icu4x_TimeZoneIdMapperWithFastCanonicalization_canonical_iana_from_bcp47_mv1(const TimeZoneIdMapperWithFastCanonicalization* self, const char* value_data, size_t value_len, DiplomatWrite* write); diff --git a/ffi/capi/bindings/c/TimeZoneInvalidIdError.d.h b/ffi/capi/bindings/c/TimeZoneInvalidIdError.d.h index 1bf1fb83718..d0692b2af8f 100644 --- a/ffi/capi/bindings/c/TimeZoneInvalidIdError.d.h +++ b/ffi/capi/bindings/c/TimeZoneInvalidIdError.d.h @@ -11,9 +11,7 @@ -typedef enum TimeZoneInvalidIdError { - TimeZoneInvalidIdError_TodoZst = 0, -} TimeZoneInvalidIdError; + diff --git a/ffi/capi/bindings/c/TimeZoneInvalidOffsetError.d.h b/ffi/capi/bindings/c/TimeZoneInvalidOffsetError.d.h index a37ca8823cf..bc49ba6d28a 100644 --- a/ffi/capi/bindings/c/TimeZoneInvalidOffsetError.d.h +++ b/ffi/capi/bindings/c/TimeZoneInvalidOffsetError.d.h @@ -11,9 +11,7 @@ -typedef enum TimeZoneInvalidOffsetError { - TimeZoneInvalidOffsetError_TodoZst = 0, -} TimeZoneInvalidOffsetError; + diff --git a/ffi/capi/bindings/c/TitlecaseOptionsV1.h b/ffi/capi/bindings/c/TitlecaseOptionsV1.h index b5d102f7b69..dd295f3a178 100644 --- a/ffi/capi/bindings/c/TitlecaseOptionsV1.h +++ b/ffi/capi/bindings/c/TitlecaseOptionsV1.h @@ -15,7 +15,7 @@ -TitlecaseOptionsV1 icu4x_TitlecaseOptionsV1_default_options_mv1(); +TitlecaseOptionsV1 icu4x_TitlecaseOptionsV1_default_mv1(void); diff --git a/ffi/capi/bindings/c/UnicodeSetData.h b/ffi/capi/bindings/c/UnicodeSetData.h index e40e3c5fb2f..39df328b93f 100644 --- a/ffi/capi/bindings/c/UnicodeSetData.h +++ b/ffi/capi/bindings/c/UnicodeSetData.h @@ -22,8 +22,6 @@ bool icu4x_UnicodeSetData_contains_mv1(const UnicodeSetData* self, const char* s bool icu4x_UnicodeSetData_contains_char_mv1(const UnicodeSetData* self, char32_t cp); -bool icu4x_UnicodeSetData_contains32_mv1(const UnicodeSetData* self, uint32_t cp); - typedef struct icu4x_UnicodeSetData_load_basic_emoji_mv1_result {union {UnicodeSetData* ok; DataError err;}; bool is_ok;} icu4x_UnicodeSetData_load_basic_emoji_mv1_result; icu4x_UnicodeSetData_load_basic_emoji_mv1_result icu4x_UnicodeSetData_load_basic_emoji_mv1(const DataProvider* provider); diff --git a/ffi/capi/bindings/c/UnitsConverter.h b/ffi/capi/bindings/c/UnitsConverter.h index 88e3fea50b6..5ff09fe9abd 100644 --- a/ffi/capi/bindings/c/UnitsConverter.h +++ b/ffi/capi/bindings/c/UnitsConverter.h @@ -15,7 +15,7 @@ -double icu4x_UnitsConverter_convert_f64_mv1(const UnitsConverter* self, double value); +double icu4x_UnitsConverter_convert_double_mv1(const UnitsConverter* self, double value); UnitsConverter* icu4x_UnitsConverter_clone_mv1(const UnitsConverter* self); diff --git a/ffi/capi/bindings/c/WeekCalculator.h b/ffi/capi/bindings/c/WeekCalculator.h index 053d32e2183..3157a1ab494 100644 --- a/ffi/capi/bindings/c/WeekCalculator.h +++ b/ffi/capi/bindings/c/WeekCalculator.h @@ -23,7 +23,7 @@ typedef struct icu4x_WeekCalculator_create_mv1_result {union {WeekCalculator* ok; DataError err;}; bool is_ok;} icu4x_WeekCalculator_create_mv1_result; icu4x_WeekCalculator_create_mv1_result icu4x_WeekCalculator_create_mv1(const DataProvider* provider, const Locale* locale); -WeekCalculator* icu4x_WeekCalculator_create_from_first_day_of_week_and_min_week_days_mv1(IsoWeekday first_weekday, uint8_t min_week_days); +WeekCalculator* icu4x_WeekCalculator_from_first_day_of_week_and_min_week_days_mv1(IsoWeekday first_weekday, uint8_t min_week_days); IsoWeekday icu4x_WeekCalculator_first_weekday_mv1(const WeekCalculator* self); diff --git a/ffi/capi/bindings/c/diplomat_runtime.h b/ffi/capi/bindings/c/diplomat_runtime.h index e77d6e5faf8..399dd0c8f5d 100644 --- a/ffi/capi/bindings/c/diplomat_runtime.h +++ b/ffi/capi/bindings/c/diplomat_runtime.h @@ -1,23 +1,24 @@ #ifndef DIPLOMAT_RUNTIME_C_H #define DIPLOMAT_RUNTIME_C_H -#include -#include +#include #include -#include - -// uchar.h doesn't always exist, but char32_t is always available -// in C++ anyway -#ifndef __cplusplus -#ifdef __APPLE__ +#include #include -typedef uint16_t char16_t; -typedef uint32_t char32_t; -#else -#include -#endif + +// These come from `uchar.h`, which is not available on all platforms. +// Redefining them in C is no problem, however in >C++11 they are fundamental +// types, which don't like being redefined. +#if !(__cplusplus >= 201100) +// https://en.cppreference.com/w/c/string/multibyte/char16_t +typedef uint_least16_t char16_t; +// https://en.cppreference.com/w/c/string/multibyte/char32_t +typedef uint_least32_t char32_t; #endif +static_assert(sizeof(char) == sizeof(uint8_t), "your architecture's `char` is not 8 bits"); +static_assert(sizeof(char16_t) == sizeof(uint16_t), "your architecture's `char16_t` is not 16 bits"); +static_assert(sizeof(char32_t) == sizeof(uint32_t), "your architecture's `char32_t` is not 32 bits"); diff --git a/ffi/capi/bindings/cpp/AnyCalendarKind.hpp b/ffi/capi/bindings/cpp/AnyCalendarKind.hpp index 52013299d50..14fb6b9003d 100644 --- a/ffi/capi/bindings/cpp/AnyCalendarKind.hpp +++ b/ffi/capi/bindings/cpp/AnyCalendarKind.hpp @@ -9,8 +9,8 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "Locale.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/Bidi.hpp b/ffi/capi/bindings/cpp/Bidi.hpp index 1cab6a74004..f08f458403b 100644 --- a/ffi/capi/bindings/cpp/Bidi.hpp +++ b/ffi/capi/bindings/cpp/Bidi.hpp @@ -9,11 +9,11 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "BidiInfo.hpp" #include "DataError.hpp" #include "DataProvider.hpp" #include "ReorderedIndexMap.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -23,7 +23,7 @@ namespace capi { typedef struct icu4x_Bidi_create_mv1_result {union {diplomat::capi::Bidi* ok; diplomat::capi::DataError err;}; bool is_ok;} icu4x_Bidi_create_mv1_result; icu4x_Bidi_create_mv1_result icu4x_Bidi_create_mv1(const diplomat::capi::DataProvider* provider); - diplomat::capi::BidiInfo* icu4x_Bidi_for_text_mv1(const diplomat::capi::Bidi* self, const char* text_data, size_t text_len, uint8_t default_level); + diplomat::capi::BidiInfo* icu4x_Bidi_for_text_utf8_mv1(const diplomat::capi::Bidi* self, const char* text_data, size_t text_len, uint8_t default_level); diplomat::capi::ReorderedIndexMap* icu4x_Bidi_reorder_visual_mv1(const diplomat::capi::Bidi* self, const uint8_t* levels_data, size_t levels_len); @@ -31,9 +31,9 @@ namespace capi { bool icu4x_Bidi_level_is_ltr_mv1(uint8_t level); - uint8_t icu4x_Bidi_level_rtl_mv1(); + uint8_t icu4x_Bidi_level_rtl_mv1(void); - uint8_t icu4x_Bidi_level_ltr_mv1(); + uint8_t icu4x_Bidi_level_ltr_mv1(void); void icu4x_Bidi_destroy_mv1(Bidi* self); @@ -48,7 +48,7 @@ inline diplomat::result, DataError> Bidi::create(const Dat } inline std::unique_ptr Bidi::for_text(std::string_view text, uint8_t default_level) const { - auto result = diplomat::capi::icu4x_Bidi_for_text_mv1(this->AsFFI(), + auto result = diplomat::capi::icu4x_Bidi_for_text_utf8_mv1(this->AsFFI(), text.data(), text.size(), default_level); diff --git a/ffi/capi/bindings/cpp/BidiInfo.hpp b/ffi/capi/bindings/cpp/BidiInfo.hpp index 2279c509a6d..0a66d81c7cc 100644 --- a/ffi/capi/bindings/cpp/BidiInfo.hpp +++ b/ffi/capi/bindings/cpp/BidiInfo.hpp @@ -9,8 +9,8 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "BidiParagraph.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/BidiParagraph.hpp b/ffi/capi/bindings/cpp/BidiParagraph.hpp index 871e187f313..e5dc3b8828f 100644 --- a/ffi/capi/bindings/cpp/BidiParagraph.hpp +++ b/ffi/capi/bindings/cpp/BidiParagraph.hpp @@ -9,8 +9,8 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "BidiDirection.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/Calendar.hpp b/ffi/capi/bindings/cpp/Calendar.hpp index 87b2db44ad5..6fc4014ba39 100644 --- a/ffi/capi/bindings/cpp/Calendar.hpp +++ b/ffi/capi/bindings/cpp/Calendar.hpp @@ -9,11 +9,11 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "AnyCalendarKind.hpp" #include "DataError.hpp" #include "DataProvider.hpp" #include "Locale.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/CalendarParseError.d.hpp b/ffi/capi/bindings/cpp/CalendarParseError.d.hpp new file mode 100644 index 00000000000..e09b4c50d6b --- /dev/null +++ b/ffi/capi/bindings/cpp/CalendarParseError.d.hpp @@ -0,0 +1,49 @@ +#ifndef CalendarParseError_D_HPP +#define CalendarParseError_D_HPP + +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + + +namespace diplomat { +namespace capi { + enum CalendarParseError { + CalendarParseError_Unknown = 0, + CalendarParseError_InvalidSyntax = 1, + CalendarParseError_OutOfRange = 2, + CalendarParseError_MissingFields = 3, + CalendarParseError_UnknownCalendar = 4, + }; +} // namespace capi +} // namespace + +class CalendarParseError { +public: + enum Value { + Unknown = 0, + InvalidSyntax = 1, + OutOfRange = 2, + MissingFields = 3, + UnknownCalendar = 4, + }; + + CalendarParseError() = default; + // Implicit conversions between enum and ::Value + constexpr CalendarParseError(Value v) : value(v) {} + constexpr operator Value() const { return value; } + // Prevent usage as boolean value + explicit operator bool() const = delete; + + inline diplomat::capi::CalendarParseError AsFFI() const; + inline static CalendarParseError FromFFI(diplomat::capi::CalendarParseError c_enum); +private: + Value value; +}; + + +#endif // CalendarParseError_D_HPP diff --git a/ffi/capi/bindings/cpp/CalendarParseError.hpp b/ffi/capi/bindings/cpp/CalendarParseError.hpp new file mode 100644 index 00000000000..4d62a27ca85 --- /dev/null +++ b/ffi/capi/bindings/cpp/CalendarParseError.hpp @@ -0,0 +1,40 @@ +#ifndef CalendarParseError_HPP +#define CalendarParseError_HPP + +#include "CalendarParseError.d.hpp" + +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + + +namespace diplomat { +namespace capi { + extern "C" { + + + } // extern "C" +} // namespace capi +} // namespace + +inline diplomat::capi::CalendarParseError CalendarParseError::AsFFI() const { + return static_cast(value); +} + +inline CalendarParseError CalendarParseError::FromFFI(diplomat::capi::CalendarParseError c_enum) { + switch (c_enum) { + case diplomat::capi::CalendarParseError_Unknown: + case diplomat::capi::CalendarParseError_InvalidSyntax: + case diplomat::capi::CalendarParseError_OutOfRange: + case diplomat::capi::CalendarParseError_MissingFields: + case diplomat::capi::CalendarParseError_UnknownCalendar: + return static_cast(c_enum); + default: + abort(); + } +} +#endif // CalendarParseError_HPP diff --git a/ffi/capi/bindings/cpp/CanonicalCombiningClassMap.d.hpp b/ffi/capi/bindings/cpp/CanonicalCombiningClassMap.d.hpp index 7c2ba807555..eaf45434b47 100644 --- a/ffi/capi/bindings/cpp/CanonicalCombiningClassMap.d.hpp +++ b/ffi/capi/bindings/cpp/CanonicalCombiningClassMap.d.hpp @@ -27,8 +27,6 @@ class CanonicalCombiningClassMap { inline uint8_t get(char32_t ch) const; - inline uint8_t get32(uint32_t ch) const; - inline const diplomat::capi::CanonicalCombiningClassMap* AsFFI() const; inline diplomat::capi::CanonicalCombiningClassMap* AsFFI(); inline static const CanonicalCombiningClassMap* FromFFI(const diplomat::capi::CanonicalCombiningClassMap* ptr); diff --git a/ffi/capi/bindings/cpp/CanonicalCombiningClassMap.hpp b/ffi/capi/bindings/cpp/CanonicalCombiningClassMap.hpp index 998337e94af..6a763422ad7 100644 --- a/ffi/capi/bindings/cpp/CanonicalCombiningClassMap.hpp +++ b/ffi/capi/bindings/cpp/CanonicalCombiningClassMap.hpp @@ -9,9 +9,9 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -23,8 +23,6 @@ namespace capi { uint8_t icu4x_CanonicalCombiningClassMap_get_mv1(const diplomat::capi::CanonicalCombiningClassMap* self, char32_t ch); - uint8_t icu4x_CanonicalCombiningClassMap_get32_mv1(const diplomat::capi::CanonicalCombiningClassMap* self, uint32_t ch); - void icu4x_CanonicalCombiningClassMap_destroy_mv1(CanonicalCombiningClassMap* self); @@ -43,12 +41,6 @@ inline uint8_t CanonicalCombiningClassMap::get(char32_t ch) const { return result; } -inline uint8_t CanonicalCombiningClassMap::get32(uint32_t ch) const { - auto result = diplomat::capi::icu4x_CanonicalCombiningClassMap_get32_mv1(this->AsFFI(), - ch); - return result; -} - inline const diplomat::capi::CanonicalCombiningClassMap* CanonicalCombiningClassMap::AsFFI() const { return reinterpret_cast(this); } diff --git a/ffi/capi/bindings/cpp/CanonicalComposition.hpp b/ffi/capi/bindings/cpp/CanonicalComposition.hpp index 5f433e9a202..9631407bbbe 100644 --- a/ffi/capi/bindings/cpp/CanonicalComposition.hpp +++ b/ffi/capi/bindings/cpp/CanonicalComposition.hpp @@ -9,9 +9,9 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/CanonicalDecomposition.hpp b/ffi/capi/bindings/cpp/CanonicalDecomposition.hpp index cc91ce8f7dd..5be84a5bbb0 100644 --- a/ffi/capi/bindings/cpp/CanonicalDecomposition.hpp +++ b/ffi/capi/bindings/cpp/CanonicalDecomposition.hpp @@ -9,10 +9,10 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" #include "Decomposed.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/CaseMapCloser.hpp b/ffi/capi/bindings/cpp/CaseMapCloser.hpp index 1725a501505..856db551bf5 100644 --- a/ffi/capi/bindings/cpp/CaseMapCloser.hpp +++ b/ffi/capi/bindings/cpp/CaseMapCloser.hpp @@ -9,10 +9,10 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "CodePointSetBuilder.hpp" #include "DataError.hpp" #include "DataProvider.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/CaseMapper.hpp b/ffi/capi/bindings/cpp/CaseMapper.hpp index 4d30b942f52..6877b59105a 100644 --- a/ffi/capi/bindings/cpp/CaseMapper.hpp +++ b/ffi/capi/bindings/cpp/CaseMapper.hpp @@ -9,12 +9,12 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "CodePointSetBuilder.hpp" #include "DataError.hpp" #include "DataProvider.hpp" #include "Locale.hpp" #include "TitlecaseOptionsV1.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/CodePointMapData16.d.hpp b/ffi/capi/bindings/cpp/CodePointMapData16.d.hpp index 44dc877da80..114bb6348e4 100644 --- a/ffi/capi/bindings/cpp/CodePointMapData16.d.hpp +++ b/ffi/capi/bindings/cpp/CodePointMapData16.d.hpp @@ -29,8 +29,6 @@ class CodePointMapData16 { inline uint16_t get(char32_t cp) const; - inline uint16_t get32(uint32_t cp) const; - inline std::unique_ptr iter_ranges_for_value(uint16_t value) const; inline std::unique_ptr iter_ranges_for_value_complemented(uint16_t value) const; diff --git a/ffi/capi/bindings/cpp/CodePointMapData16.hpp b/ffi/capi/bindings/cpp/CodePointMapData16.hpp index 4c5f5ac6d2b..09c87f3f12c 100644 --- a/ffi/capi/bindings/cpp/CodePointMapData16.hpp +++ b/ffi/capi/bindings/cpp/CodePointMapData16.hpp @@ -9,11 +9,11 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "CodePointRangeIterator.hpp" #include "CodePointSetData.hpp" #include "DataError.hpp" #include "DataProvider.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -22,8 +22,6 @@ namespace capi { uint16_t icu4x_CodePointMapData16_get_mv1(const diplomat::capi::CodePointMapData16* self, char32_t cp); - uint16_t icu4x_CodePointMapData16_get32_mv1(const diplomat::capi::CodePointMapData16* self, uint32_t cp); - diplomat::capi::CodePointRangeIterator* icu4x_CodePointMapData16_iter_ranges_for_value_mv1(const diplomat::capi::CodePointMapData16* self, uint16_t value); diplomat::capi::CodePointRangeIterator* icu4x_CodePointMapData16_iter_ranges_for_value_complemented_mv1(const diplomat::capi::CodePointMapData16* self, uint16_t value); @@ -46,12 +44,6 @@ inline uint16_t CodePointMapData16::get(char32_t cp) const { return result; } -inline uint16_t CodePointMapData16::get32(uint32_t cp) const { - auto result = diplomat::capi::icu4x_CodePointMapData16_get32_mv1(this->AsFFI(), - cp); - return result; -} - inline std::unique_ptr CodePointMapData16::iter_ranges_for_value(uint16_t value) const { auto result = diplomat::capi::icu4x_CodePointMapData16_iter_ranges_for_value_mv1(this->AsFFI(), value); diff --git a/ffi/capi/bindings/cpp/CodePointMapData8.d.hpp b/ffi/capi/bindings/cpp/CodePointMapData8.d.hpp index 2950ce37659..4852bf5b75e 100644 --- a/ffi/capi/bindings/cpp/CodePointMapData8.d.hpp +++ b/ffi/capi/bindings/cpp/CodePointMapData8.d.hpp @@ -29,8 +29,6 @@ class CodePointMapData8 { inline uint8_t get(char32_t cp) const; - inline uint8_t get32(uint32_t cp) const; - inline static uint32_t general_category_to_mask(uint8_t gc); inline std::unique_ptr iter_ranges_for_value(uint8_t value) const; diff --git a/ffi/capi/bindings/cpp/CodePointMapData8.hpp b/ffi/capi/bindings/cpp/CodePointMapData8.hpp index c4e20cbc136..10289193b2f 100644 --- a/ffi/capi/bindings/cpp/CodePointMapData8.hpp +++ b/ffi/capi/bindings/cpp/CodePointMapData8.hpp @@ -9,11 +9,11 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "CodePointRangeIterator.hpp" #include "CodePointSetData.hpp" #include "DataError.hpp" #include "DataProvider.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -22,8 +22,6 @@ namespace capi { uint8_t icu4x_CodePointMapData8_get_mv1(const diplomat::capi::CodePointMapData8* self, char32_t cp); - uint8_t icu4x_CodePointMapData8_get32_mv1(const diplomat::capi::CodePointMapData8* self, uint32_t cp); - uint32_t icu4x_CodePointMapData8_general_category_to_mask_mv1(uint8_t gc); diplomat::capi::CodePointRangeIterator* icu4x_CodePointMapData8_iter_ranges_for_value_mv1(const diplomat::capi::CodePointMapData8* self, uint8_t value); @@ -77,12 +75,6 @@ inline uint8_t CodePointMapData8::get(char32_t cp) const { return result; } -inline uint8_t CodePointMapData8::get32(uint32_t cp) const { - auto result = diplomat::capi::icu4x_CodePointMapData8_get32_mv1(this->AsFFI(), - cp); - return result; -} - inline uint32_t CodePointMapData8::general_category_to_mask(uint8_t gc) { auto result = diplomat::capi::icu4x_CodePointMapData8_general_category_to_mask_mv1(gc); return result; diff --git a/ffi/capi/bindings/cpp/CodePointRangeIterator.hpp b/ffi/capi/bindings/cpp/CodePointRangeIterator.hpp index e2c691bcd78..0a31fab3d67 100644 --- a/ffi/capi/bindings/cpp/CodePointRangeIterator.hpp +++ b/ffi/capi/bindings/cpp/CodePointRangeIterator.hpp @@ -9,8 +9,8 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "CodePointRangeIteratorResult.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/CodePointRangeIteratorResult.hpp b/ffi/capi/bindings/cpp/CodePointRangeIteratorResult.hpp index c0df2b5d25d..1159ab6eb7d 100644 --- a/ffi/capi/bindings/cpp/CodePointRangeIteratorResult.hpp +++ b/ffi/capi/bindings/cpp/CodePointRangeIteratorResult.hpp @@ -24,17 +24,17 @@ namespace capi { inline diplomat::capi::CodePointRangeIteratorResult CodePointRangeIteratorResult::AsFFI() const { return diplomat::capi::CodePointRangeIteratorResult { - .start = start, - .end = end, - .done = done, + /* .start = */ start, + /* .end = */ end, + /* .done = */ done, }; } inline CodePointRangeIteratorResult CodePointRangeIteratorResult::FromFFI(diplomat::capi::CodePointRangeIteratorResult c_struct) { return CodePointRangeIteratorResult { - .start = c_struct.start, - .end = c_struct.end, - .done = c_struct.done, + /* .start = */ c_struct.start, + /* .end = */ c_struct.end, + /* .done = */ c_struct.done, }; } diff --git a/ffi/capi/bindings/cpp/CodePointSetBuilder.hpp b/ffi/capi/bindings/cpp/CodePointSetBuilder.hpp index cb16d26ce36..c443b8bc19d 100644 --- a/ffi/capi/bindings/cpp/CodePointSetBuilder.hpp +++ b/ffi/capi/bindings/cpp/CodePointSetBuilder.hpp @@ -9,15 +9,15 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "CodePointSetData.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { namespace capi { extern "C" { - diplomat::capi::CodePointSetBuilder* icu4x_CodePointSetBuilder_create_mv1(); + diplomat::capi::CodePointSetBuilder* icu4x_CodePointSetBuilder_create_mv1(void); diplomat::capi::CodePointSetData* icu4x_CodePointSetBuilder_build_mv1(diplomat::capi::CodePointSetBuilder* self); diff --git a/ffi/capi/bindings/cpp/CodePointSetData.d.hpp b/ffi/capi/bindings/cpp/CodePointSetData.d.hpp index f576bd74449..4208d2d7869 100644 --- a/ffi/capi/bindings/cpp/CodePointSetData.d.hpp +++ b/ffi/capi/bindings/cpp/CodePointSetData.d.hpp @@ -28,8 +28,6 @@ class CodePointSetData { inline bool contains(char32_t cp) const; - inline bool contains32(uint32_t cp) const; - inline std::unique_ptr iter_ranges() const; inline std::unique_ptr iter_ranges_complemented() const; diff --git a/ffi/capi/bindings/cpp/CodePointSetData.hpp b/ffi/capi/bindings/cpp/CodePointSetData.hpp index 3eaa202e02e..4627a606fa4 100644 --- a/ffi/capi/bindings/cpp/CodePointSetData.hpp +++ b/ffi/capi/bindings/cpp/CodePointSetData.hpp @@ -9,11 +9,11 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "CodePointRangeIterator.hpp" #include "DataError.hpp" #include "DataProvider.hpp" #include "Error.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -22,8 +22,6 @@ namespace capi { bool icu4x_CodePointSetData_contains_mv1(const diplomat::capi::CodePointSetData* self, char32_t cp); - bool icu4x_CodePointSetData_contains32_mv1(const diplomat::capi::CodePointSetData* self, uint32_t cp); - diplomat::capi::CodePointRangeIterator* icu4x_CodePointSetData_iter_ranges_mv1(const diplomat::capi::CodePointSetData* self); diplomat::capi::CodePointRangeIterator* icu4x_CodePointSetData_iter_ranges_complemented_mv1(const diplomat::capi::CodePointSetData* self); @@ -242,12 +240,6 @@ inline bool CodePointSetData::contains(char32_t cp) const { return result; } -inline bool CodePointSetData::contains32(uint32_t cp) const { - auto result = diplomat::capi::icu4x_CodePointSetData_contains32_mv1(this->AsFFI(), - cp); - return result; -} - inline std::unique_ptr CodePointSetData::iter_ranges() const { auto result = diplomat::capi::icu4x_CodePointSetData_iter_ranges_mv1(this->AsFFI()); return std::unique_ptr(CodePointRangeIterator::FromFFI(result)); @@ -596,7 +588,7 @@ inline diplomat::result, Erro auto result = diplomat::capi::icu4x_CodePointSetData_load_for_ecma262_mv1(provider.AsFFI(), property_name.data(), property_name.size()); - return diplomat::Ok, Error>>(std::move(result.is_ok ? diplomat::result, Error>(diplomat::Ok>(std::unique_ptr(CodePointSetData::FromFFI(result.ok)))) : diplomat::result, Error>(diplomat::Err(Error::FromFFI(result.err))))); + return diplomat::Ok, Error>>(result.is_ok ? diplomat::result, Error>(diplomat::Ok>(std::unique_ptr(CodePointSetData::FromFFI(result.ok)))) : diplomat::result, Error>(diplomat::Err(Error::FromFFI(result.err)))); } inline const diplomat::capi::CodePointSetData* CodePointSetData::AsFFI() const { diff --git a/ffi/capi/bindings/cpp/Collator.d.hpp b/ffi/capi/bindings/cpp/Collator.d.hpp index 0665970e3f9..486d7ef874d 100644 --- a/ffi/capi/bindings/cpp/Collator.d.hpp +++ b/ffi/capi/bindings/cpp/Collator.d.hpp @@ -29,11 +29,11 @@ class Collator { inline static diplomat::result, DataError> create_v1(const DataProvider& provider, const Locale& locale, CollatorOptionsV1 options); - inline int8_t compare16(std::u16string_view left, std::u16string_view right) const; - inline int8_t compare(std::string_view left, std::string_view right) const; - inline CollatorResolvedOptionsV1 resolved_options() const; + inline int8_t compare16(std::u16string_view left, std::u16string_view right) const; + + inline CollatorResolvedOptionsV1 resolved_options_v1() const; inline const diplomat::capi::Collator* AsFFI() const; inline diplomat::capi::Collator* AsFFI(); diff --git a/ffi/capi/bindings/cpp/Collator.hpp b/ffi/capi/bindings/cpp/Collator.hpp index 6ceec452924..ac1850ca59c 100644 --- a/ffi/capi/bindings/cpp/Collator.hpp +++ b/ffi/capi/bindings/cpp/Collator.hpp @@ -9,12 +9,12 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "CollatorOptionsV1.hpp" #include "CollatorResolvedOptionsV1.hpp" #include "DataError.hpp" #include "DataProvider.hpp" #include "Locale.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -24,11 +24,11 @@ namespace capi { typedef struct icu4x_Collator_create_v1_mv1_result {union {diplomat::capi::Collator* ok; diplomat::capi::DataError err;}; bool is_ok;} icu4x_Collator_create_v1_mv1_result; icu4x_Collator_create_v1_mv1_result icu4x_Collator_create_v1_mv1(const diplomat::capi::DataProvider* provider, const diplomat::capi::Locale* locale, diplomat::capi::CollatorOptionsV1 options); - int8_t icu4x_Collator_compare_utf16_mv1(const diplomat::capi::Collator* self, const char16_t* left_data, size_t left_len, const char16_t* right_data, size_t right_len); + int8_t icu4x_Collator_compare_utf8_mv1(const diplomat::capi::Collator* self, const char* left_data, size_t left_len, const char* right_data, size_t right_len); - int8_t icu4x_Collator_compare_mv1(const diplomat::capi::Collator* self, const char* left_data, size_t left_len, const char* right_data, size_t right_len); + int8_t icu4x_Collator_compare_utf16_mv1(const diplomat::capi::Collator* self, const char16_t* left_data, size_t left_len, const char16_t* right_data, size_t right_len); - diplomat::capi::CollatorResolvedOptionsV1 icu4x_Collator_resolved_options_mv1(const diplomat::capi::Collator* self); + diplomat::capi::CollatorResolvedOptionsV1 icu4x_Collator_resolved_options_v1_mv1(const diplomat::capi::Collator* self); void icu4x_Collator_destroy_mv1(Collator* self); @@ -44,8 +44,8 @@ inline diplomat::result, DataError> Collator::create_v return result.is_ok ? diplomat::result, DataError>(diplomat::Ok>(std::unique_ptr(Collator::FromFFI(result.ok)))) : diplomat::result, DataError>(diplomat::Err(DataError::FromFFI(result.err))); } -inline int8_t Collator::compare16(std::u16string_view left, std::u16string_view right) const { - auto result = diplomat::capi::icu4x_Collator_compare_utf16_mv1(this->AsFFI(), +inline int8_t Collator::compare(std::string_view left, std::string_view right) const { + auto result = diplomat::capi::icu4x_Collator_compare_utf8_mv1(this->AsFFI(), left.data(), left.size(), right.data(), @@ -53,8 +53,8 @@ inline int8_t Collator::compare16(std::u16string_view left, std::u16string_view return result; } -inline int8_t Collator::compare(std::string_view left, std::string_view right) const { - auto result = diplomat::capi::icu4x_Collator_compare_mv1(this->AsFFI(), +inline int8_t Collator::compare16(std::u16string_view left, std::u16string_view right) const { + auto result = diplomat::capi::icu4x_Collator_compare_utf16_mv1(this->AsFFI(), left.data(), left.size(), right.data(), @@ -62,8 +62,8 @@ inline int8_t Collator::compare(std::string_view left, std::string_view right) c return result; } -inline CollatorResolvedOptionsV1 Collator::resolved_options() const { - auto result = diplomat::capi::icu4x_Collator_resolved_options_mv1(this->AsFFI()); +inline CollatorResolvedOptionsV1 Collator::resolved_options_v1() const { + auto result = diplomat::capi::icu4x_Collator_resolved_options_v1_mv1(this->AsFFI()); return CollatorResolvedOptionsV1::FromFFI(result); } diff --git a/ffi/capi/bindings/cpp/CollatorOptionsV1.d.hpp b/ffi/capi/bindings/cpp/CollatorOptionsV1.d.hpp index 723b45ca316..4186b500783 100644 --- a/ffi/capi/bindings/cpp/CollatorOptionsV1.d.hpp +++ b/ffi/capi/bindings/cpp/CollatorOptionsV1.d.hpp @@ -7,7 +7,6 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "CollatorAlternateHandling.d.hpp" #include "CollatorBackwardSecondLevel.d.hpp" #include "CollatorCaseFirst.d.hpp" @@ -15,6 +14,7 @@ #include "CollatorMaxVariable.d.hpp" #include "CollatorNumeric.d.hpp" #include "CollatorStrength.d.hpp" +#include "diplomat_runtime.hpp" class CollatorAlternateHandling; class CollatorBackwardSecondLevel; diff --git a/ffi/capi/bindings/cpp/CollatorOptionsV1.hpp b/ffi/capi/bindings/cpp/CollatorOptionsV1.hpp index e11b6d60ffa..ab015d30e27 100644 --- a/ffi/capi/bindings/cpp/CollatorOptionsV1.hpp +++ b/ffi/capi/bindings/cpp/CollatorOptionsV1.hpp @@ -9,7 +9,6 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "CollatorAlternateHandling.hpp" #include "CollatorBackwardSecondLevel.hpp" #include "CollatorCaseFirst.hpp" @@ -17,6 +16,7 @@ #include "CollatorMaxVariable.hpp" #include "CollatorNumeric.hpp" #include "CollatorStrength.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -31,25 +31,25 @@ namespace capi { inline diplomat::capi::CollatorOptionsV1 CollatorOptionsV1::AsFFI() const { return diplomat::capi::CollatorOptionsV1 { - .strength = strength.AsFFI(), - .alternate_handling = alternate_handling.AsFFI(), - .case_first = case_first.AsFFI(), - .max_variable = max_variable.AsFFI(), - .case_level = case_level.AsFFI(), - .numeric = numeric.AsFFI(), - .backward_second_level = backward_second_level.AsFFI(), + /* .strength = */ strength.AsFFI(), + /* .alternate_handling = */ alternate_handling.AsFFI(), + /* .case_first = */ case_first.AsFFI(), + /* .max_variable = */ max_variable.AsFFI(), + /* .case_level = */ case_level.AsFFI(), + /* .numeric = */ numeric.AsFFI(), + /* .backward_second_level = */ backward_second_level.AsFFI(), }; } inline CollatorOptionsV1 CollatorOptionsV1::FromFFI(diplomat::capi::CollatorOptionsV1 c_struct) { return CollatorOptionsV1 { - .strength = CollatorStrength::FromFFI(c_struct.strength), - .alternate_handling = CollatorAlternateHandling::FromFFI(c_struct.alternate_handling), - .case_first = CollatorCaseFirst::FromFFI(c_struct.case_first), - .max_variable = CollatorMaxVariable::FromFFI(c_struct.max_variable), - .case_level = CollatorCaseLevel::FromFFI(c_struct.case_level), - .numeric = CollatorNumeric::FromFFI(c_struct.numeric), - .backward_second_level = CollatorBackwardSecondLevel::FromFFI(c_struct.backward_second_level), + /* .strength = */ CollatorStrength::FromFFI(c_struct.strength), + /* .alternate_handling = */ CollatorAlternateHandling::FromFFI(c_struct.alternate_handling), + /* .case_first = */ CollatorCaseFirst::FromFFI(c_struct.case_first), + /* .max_variable = */ CollatorMaxVariable::FromFFI(c_struct.max_variable), + /* .case_level = */ CollatorCaseLevel::FromFFI(c_struct.case_level), + /* .numeric = */ CollatorNumeric::FromFFI(c_struct.numeric), + /* .backward_second_level = */ CollatorBackwardSecondLevel::FromFFI(c_struct.backward_second_level), }; } diff --git a/ffi/capi/bindings/cpp/CollatorResolvedOptionsV1.d.hpp b/ffi/capi/bindings/cpp/CollatorResolvedOptionsV1.d.hpp index 88605f51a82..d6aafa29eff 100644 --- a/ffi/capi/bindings/cpp/CollatorResolvedOptionsV1.d.hpp +++ b/ffi/capi/bindings/cpp/CollatorResolvedOptionsV1.d.hpp @@ -7,7 +7,6 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "CollatorAlternateHandling.d.hpp" #include "CollatorBackwardSecondLevel.d.hpp" #include "CollatorCaseFirst.d.hpp" @@ -15,6 +14,7 @@ #include "CollatorMaxVariable.d.hpp" #include "CollatorNumeric.d.hpp" #include "CollatorStrength.d.hpp" +#include "diplomat_runtime.hpp" class CollatorAlternateHandling; class CollatorBackwardSecondLevel; diff --git a/ffi/capi/bindings/cpp/CollatorResolvedOptionsV1.hpp b/ffi/capi/bindings/cpp/CollatorResolvedOptionsV1.hpp index c2676830ee9..4013519a895 100644 --- a/ffi/capi/bindings/cpp/CollatorResolvedOptionsV1.hpp +++ b/ffi/capi/bindings/cpp/CollatorResolvedOptionsV1.hpp @@ -9,7 +9,6 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "CollatorAlternateHandling.hpp" #include "CollatorBackwardSecondLevel.hpp" #include "CollatorCaseFirst.hpp" @@ -17,6 +16,7 @@ #include "CollatorMaxVariable.hpp" #include "CollatorNumeric.hpp" #include "CollatorStrength.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -31,25 +31,25 @@ namespace capi { inline diplomat::capi::CollatorResolvedOptionsV1 CollatorResolvedOptionsV1::AsFFI() const { return diplomat::capi::CollatorResolvedOptionsV1 { - .strength = strength.AsFFI(), - .alternate_handling = alternate_handling.AsFFI(), - .case_first = case_first.AsFFI(), - .max_variable = max_variable.AsFFI(), - .case_level = case_level.AsFFI(), - .numeric = numeric.AsFFI(), - .backward_second_level = backward_second_level.AsFFI(), + /* .strength = */ strength.AsFFI(), + /* .alternate_handling = */ alternate_handling.AsFFI(), + /* .case_first = */ case_first.AsFFI(), + /* .max_variable = */ max_variable.AsFFI(), + /* .case_level = */ case_level.AsFFI(), + /* .numeric = */ numeric.AsFFI(), + /* .backward_second_level = */ backward_second_level.AsFFI(), }; } inline CollatorResolvedOptionsV1 CollatorResolvedOptionsV1::FromFFI(diplomat::capi::CollatorResolvedOptionsV1 c_struct) { return CollatorResolvedOptionsV1 { - .strength = CollatorStrength::FromFFI(c_struct.strength), - .alternate_handling = CollatorAlternateHandling::FromFFI(c_struct.alternate_handling), - .case_first = CollatorCaseFirst::FromFFI(c_struct.case_first), - .max_variable = CollatorMaxVariable::FromFFI(c_struct.max_variable), - .case_level = CollatorCaseLevel::FromFFI(c_struct.case_level), - .numeric = CollatorNumeric::FromFFI(c_struct.numeric), - .backward_second_level = CollatorBackwardSecondLevel::FromFFI(c_struct.backward_second_level), + /* .strength = */ CollatorStrength::FromFFI(c_struct.strength), + /* .alternate_handling = */ CollatorAlternateHandling::FromFFI(c_struct.alternate_handling), + /* .case_first = */ CollatorCaseFirst::FromFFI(c_struct.case_first), + /* .max_variable = */ CollatorMaxVariable::FromFFI(c_struct.max_variable), + /* .case_level = */ CollatorCaseLevel::FromFFI(c_struct.case_level), + /* .numeric = */ CollatorNumeric::FromFFI(c_struct.numeric), + /* .backward_second_level = */ CollatorBackwardSecondLevel::FromFFI(c_struct.backward_second_level), }; } diff --git a/ffi/capi/bindings/cpp/ComposingNormalizer.d.hpp b/ffi/capi/bindings/cpp/ComposingNormalizer.d.hpp index 98baa8554a8..ddf5c81f150 100644 --- a/ffi/capi/bindings/cpp/ComposingNormalizer.d.hpp +++ b/ffi/capi/bindings/cpp/ComposingNormalizer.d.hpp @@ -31,11 +31,11 @@ class ComposingNormalizer { inline bool is_normalized(std::string_view s) const; - inline bool is_normalized_utf16(std::u16string_view s) const; + inline bool is_normalized16(std::u16string_view s) const; inline size_t is_normalized_up_to(std::string_view s) const; - inline size_t is_normalized_utf16_up_to(std::u16string_view s) const; + inline size_t is_normalized16_up_to(std::u16string_view s) const; inline const diplomat::capi::ComposingNormalizer* AsFFI() const; inline diplomat::capi::ComposingNormalizer* AsFFI(); diff --git a/ffi/capi/bindings/cpp/ComposingNormalizer.hpp b/ffi/capi/bindings/cpp/ComposingNormalizer.hpp index 732fb5f68e0..6476b3a7190 100644 --- a/ffi/capi/bindings/cpp/ComposingNormalizer.hpp +++ b/ffi/capi/bindings/cpp/ComposingNormalizer.hpp @@ -9,9 +9,9 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -26,11 +26,11 @@ namespace capi { void icu4x_ComposingNormalizer_normalize_mv1(const diplomat::capi::ComposingNormalizer* self, const char* s_data, size_t s_len, diplomat::capi::DiplomatWrite* write); - bool icu4x_ComposingNormalizer_is_normalized_mv1(const diplomat::capi::ComposingNormalizer* self, const char* s_data, size_t s_len); + bool icu4x_ComposingNormalizer_is_normalized_utf8_mv1(const diplomat::capi::ComposingNormalizer* self, const char* s_data, size_t s_len); bool icu4x_ComposingNormalizer_is_normalized_utf16_mv1(const diplomat::capi::ComposingNormalizer* self, const char16_t* s_data, size_t s_len); - size_t icu4x_ComposingNormalizer_is_normalized_up_to_mv1(const diplomat::capi::ComposingNormalizer* self, const char* s_data, size_t s_len); + size_t icu4x_ComposingNormalizer_is_normalized_utf8_up_to_mv1(const diplomat::capi::ComposingNormalizer* self, const char* s_data, size_t s_len); size_t icu4x_ComposingNormalizer_is_normalized_utf16_up_to_mv1(const diplomat::capi::ComposingNormalizer* self, const char16_t* s_data, size_t s_len); @@ -62,13 +62,13 @@ inline std::string ComposingNormalizer::normalize(std::string_view s) const { } inline bool ComposingNormalizer::is_normalized(std::string_view s) const { - auto result = diplomat::capi::icu4x_ComposingNormalizer_is_normalized_mv1(this->AsFFI(), + auto result = diplomat::capi::icu4x_ComposingNormalizer_is_normalized_utf8_mv1(this->AsFFI(), s.data(), s.size()); return result; } -inline bool ComposingNormalizer::is_normalized_utf16(std::u16string_view s) const { +inline bool ComposingNormalizer::is_normalized16(std::u16string_view s) const { auto result = diplomat::capi::icu4x_ComposingNormalizer_is_normalized_utf16_mv1(this->AsFFI(), s.data(), s.size()); @@ -76,13 +76,13 @@ inline bool ComposingNormalizer::is_normalized_utf16(std::u16string_view s) cons } inline size_t ComposingNormalizer::is_normalized_up_to(std::string_view s) const { - auto result = diplomat::capi::icu4x_ComposingNormalizer_is_normalized_up_to_mv1(this->AsFFI(), + auto result = diplomat::capi::icu4x_ComposingNormalizer_is_normalized_utf8_up_to_mv1(this->AsFFI(), s.data(), s.size()); return result; } -inline size_t ComposingNormalizer::is_normalized_utf16_up_to(std::u16string_view s) const { +inline size_t ComposingNormalizer::is_normalized16_up_to(std::u16string_view s) const { auto result = diplomat::capi::icu4x_ComposingNormalizer_is_normalized_utf16_up_to_mv1(this->AsFFI(), s.data(), s.size()); diff --git a/ffi/capi/bindings/cpp/CustomTimeZone.d.hpp b/ffi/capi/bindings/cpp/CustomTimeZone.d.hpp index 1c64ff0679b..bba2fc60fa5 100644 --- a/ffi/capi/bindings/cpp/CustomTimeZone.d.hpp +++ b/ffi/capi/bindings/cpp/CustomTimeZone.d.hpp @@ -15,8 +15,8 @@ namespace diplomat::capi { struct MetazoneCalculator; } class MetazoneCalculator; namespace diplomat::capi { struct TimeZoneIdMapper; } class TimeZoneIdMapper; -class TimeZoneInvalidIdError; -class TimeZoneInvalidOffsetError; +struct TimeZoneInvalidIdError; +struct TimeZoneInvalidOffsetError; namespace diplomat { @@ -28,15 +28,15 @@ namespace capi { class CustomTimeZone { public: - inline static diplomat::result, TimeZoneInvalidOffsetError> create_from_string(std::string_view s); + inline static diplomat::result, TimeZoneInvalidOffsetError> from_string(std::string_view s); - inline static std::unique_ptr create_empty(); + inline static std::unique_ptr empty(); - inline static std::unique_ptr create_utc(); + inline static std::unique_ptr utc(); - inline static std::unique_ptr create_gmt(); + inline static std::unique_ptr gmt(); - inline static std::unique_ptr create_bst(); + inline static std::unique_ptr bst(); inline diplomat::result try_set_gmt_offset_seconds(int32_t offset_seconds); diff --git a/ffi/capi/bindings/cpp/CustomTimeZone.hpp b/ffi/capi/bindings/cpp/CustomTimeZone.hpp index db03e0f91e2..a0d62b931af 100644 --- a/ffi/capi/bindings/cpp/CustomTimeZone.hpp +++ b/ffi/capi/bindings/cpp/CustomTimeZone.hpp @@ -9,30 +9,30 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "IsoDateTime.hpp" #include "MetazoneCalculator.hpp" #include "TimeZoneIdMapper.hpp" #include "TimeZoneInvalidIdError.hpp" #include "TimeZoneInvalidOffsetError.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { namespace capi { extern "C" { - typedef struct icu4x_CustomTimeZone_create_from_string_mv1_result {union {diplomat::capi::CustomTimeZone* ok; diplomat::capi::TimeZoneInvalidOffsetError err;}; bool is_ok;} icu4x_CustomTimeZone_create_from_string_mv1_result; - icu4x_CustomTimeZone_create_from_string_mv1_result icu4x_CustomTimeZone_create_from_string_mv1(const char* s_data, size_t s_len); + typedef struct icu4x_CustomTimeZone_from_string_mv1_result {union {diplomat::capi::CustomTimeZone* ok; }; bool is_ok;} icu4x_CustomTimeZone_from_string_mv1_result; + icu4x_CustomTimeZone_from_string_mv1_result icu4x_CustomTimeZone_from_string_mv1(const char* s_data, size_t s_len); - diplomat::capi::CustomTimeZone* icu4x_CustomTimeZone_create_empty_mv1(); + diplomat::capi::CustomTimeZone* icu4x_CustomTimeZone_empty_mv1(void); - diplomat::capi::CustomTimeZone* icu4x_CustomTimeZone_create_utc_mv1(); + diplomat::capi::CustomTimeZone* icu4x_CustomTimeZone_utc_mv1(void); - diplomat::capi::CustomTimeZone* icu4x_CustomTimeZone_create_gmt_mv1(); + diplomat::capi::CustomTimeZone* icu4x_CustomTimeZone_gmt_mv1(void); - diplomat::capi::CustomTimeZone* icu4x_CustomTimeZone_create_bst_mv1(); + diplomat::capi::CustomTimeZone* icu4x_CustomTimeZone_bst_mv1(void); - typedef struct icu4x_CustomTimeZone_try_set_gmt_offset_seconds_mv1_result {union { diplomat::capi::TimeZoneInvalidOffsetError err;}; bool is_ok;} icu4x_CustomTimeZone_try_set_gmt_offset_seconds_mv1_result; + typedef struct icu4x_CustomTimeZone_try_set_gmt_offset_seconds_mv1_result { bool is_ok;} icu4x_CustomTimeZone_try_set_gmt_offset_seconds_mv1_result; icu4x_CustomTimeZone_try_set_gmt_offset_seconds_mv1_result icu4x_CustomTimeZone_try_set_gmt_offset_seconds_mv1(diplomat::capi::CustomTimeZone* self, int32_t offset_seconds); void icu4x_CustomTimeZone_set_gmt_offset_eighths_of_hour_mv1(diplomat::capi::CustomTimeZone* self, int8_t offset_eighths_of_hour); @@ -54,10 +54,10 @@ namespace capi { typedef struct icu4x_CustomTimeZone_gmt_offset_has_seconds_mv1_result {union {bool ok; }; bool is_ok;} icu4x_CustomTimeZone_gmt_offset_has_seconds_mv1_result; icu4x_CustomTimeZone_gmt_offset_has_seconds_mv1_result icu4x_CustomTimeZone_gmt_offset_has_seconds_mv1(const diplomat::capi::CustomTimeZone* self); - typedef struct icu4x_CustomTimeZone_try_set_time_zone_id_mv1_result {union { diplomat::capi::TimeZoneInvalidIdError err;}; bool is_ok;} icu4x_CustomTimeZone_try_set_time_zone_id_mv1_result; + typedef struct icu4x_CustomTimeZone_try_set_time_zone_id_mv1_result { bool is_ok;} icu4x_CustomTimeZone_try_set_time_zone_id_mv1_result; icu4x_CustomTimeZone_try_set_time_zone_id_mv1_result icu4x_CustomTimeZone_try_set_time_zone_id_mv1(diplomat::capi::CustomTimeZone* self, const char* id_data, size_t id_len); - typedef struct icu4x_CustomTimeZone_try_set_iana_time_zone_id_mv1_result {union { diplomat::capi::TimeZoneInvalidIdError err;}; bool is_ok;} icu4x_CustomTimeZone_try_set_iana_time_zone_id_mv1_result; + typedef struct icu4x_CustomTimeZone_try_set_iana_time_zone_id_mv1_result { bool is_ok;} icu4x_CustomTimeZone_try_set_iana_time_zone_id_mv1_result; icu4x_CustomTimeZone_try_set_iana_time_zone_id_mv1_result icu4x_CustomTimeZone_try_set_iana_time_zone_id_mv1(diplomat::capi::CustomTimeZone* self, const diplomat::capi::TimeZoneIdMapper* mapper, const char* id_data, size_t id_len); void icu4x_CustomTimeZone_clear_time_zone_id_mv1(diplomat::capi::CustomTimeZone* self); @@ -65,7 +65,7 @@ namespace capi { typedef struct icu4x_CustomTimeZone_time_zone_id_mv1_result { bool is_ok;} icu4x_CustomTimeZone_time_zone_id_mv1_result; icu4x_CustomTimeZone_time_zone_id_mv1_result icu4x_CustomTimeZone_time_zone_id_mv1(const diplomat::capi::CustomTimeZone* self, diplomat::capi::DiplomatWrite* write); - typedef struct icu4x_CustomTimeZone_try_set_metazone_id_mv1_result {union { diplomat::capi::TimeZoneInvalidIdError err;}; bool is_ok;} icu4x_CustomTimeZone_try_set_metazone_id_mv1_result; + typedef struct icu4x_CustomTimeZone_try_set_metazone_id_mv1_result { bool is_ok;} icu4x_CustomTimeZone_try_set_metazone_id_mv1_result; icu4x_CustomTimeZone_try_set_metazone_id_mv1_result icu4x_CustomTimeZone_try_set_metazone_id_mv1(diplomat::capi::CustomTimeZone* self, const char* id_data, size_t id_len); void icu4x_CustomTimeZone_clear_metazone_id_mv1(diplomat::capi::CustomTimeZone* self); @@ -100,36 +100,36 @@ namespace capi { } // namespace capi } // namespace -inline diplomat::result, TimeZoneInvalidOffsetError> CustomTimeZone::create_from_string(std::string_view s) { - auto result = diplomat::capi::icu4x_CustomTimeZone_create_from_string_mv1(s.data(), +inline diplomat::result, TimeZoneInvalidOffsetError> CustomTimeZone::from_string(std::string_view s) { + auto result = diplomat::capi::icu4x_CustomTimeZone_from_string_mv1(s.data(), s.size()); - return result.is_ok ? diplomat::result, TimeZoneInvalidOffsetError>(diplomat::Ok>(std::unique_ptr(CustomTimeZone::FromFFI(result.ok)))) : diplomat::result, TimeZoneInvalidOffsetError>(diplomat::Err(TimeZoneInvalidOffsetError::FromFFI(result.err))); + return result.is_ok ? diplomat::result, TimeZoneInvalidOffsetError>(diplomat::Ok>(std::unique_ptr(CustomTimeZone::FromFFI(result.ok)))) : diplomat::result, TimeZoneInvalidOffsetError>(diplomat::Err(TimeZoneInvalidOffsetError {})); } -inline std::unique_ptr CustomTimeZone::create_empty() { - auto result = diplomat::capi::icu4x_CustomTimeZone_create_empty_mv1(); +inline std::unique_ptr CustomTimeZone::empty() { + auto result = diplomat::capi::icu4x_CustomTimeZone_empty_mv1(); return std::unique_ptr(CustomTimeZone::FromFFI(result)); } -inline std::unique_ptr CustomTimeZone::create_utc() { - auto result = diplomat::capi::icu4x_CustomTimeZone_create_utc_mv1(); +inline std::unique_ptr CustomTimeZone::utc() { + auto result = diplomat::capi::icu4x_CustomTimeZone_utc_mv1(); return std::unique_ptr(CustomTimeZone::FromFFI(result)); } -inline std::unique_ptr CustomTimeZone::create_gmt() { - auto result = diplomat::capi::icu4x_CustomTimeZone_create_gmt_mv1(); +inline std::unique_ptr CustomTimeZone::gmt() { + auto result = diplomat::capi::icu4x_CustomTimeZone_gmt_mv1(); return std::unique_ptr(CustomTimeZone::FromFFI(result)); } -inline std::unique_ptr CustomTimeZone::create_bst() { - auto result = diplomat::capi::icu4x_CustomTimeZone_create_bst_mv1(); +inline std::unique_ptr CustomTimeZone::bst() { + auto result = diplomat::capi::icu4x_CustomTimeZone_bst_mv1(); return std::unique_ptr(CustomTimeZone::FromFFI(result)); } inline diplomat::result CustomTimeZone::try_set_gmt_offset_seconds(int32_t offset_seconds) { auto result = diplomat::capi::icu4x_CustomTimeZone_try_set_gmt_offset_seconds_mv1(this->AsFFI(), offset_seconds); - return result.is_ok ? diplomat::result(diplomat::Ok()) : diplomat::result(diplomat::Err(TimeZoneInvalidOffsetError::FromFFI(result.err))); + return result.is_ok ? diplomat::result(diplomat::Ok()) : diplomat::result(diplomat::Err(TimeZoneInvalidOffsetError {})); } inline void CustomTimeZone::set_gmt_offset_eighths_of_hour(int8_t offset_eighths_of_hour) { @@ -170,7 +170,7 @@ inline diplomat::result CustomTimeZone:: auto result = diplomat::capi::icu4x_CustomTimeZone_try_set_time_zone_id_mv1(this->AsFFI(), id.data(), id.size()); - return result.is_ok ? diplomat::result(diplomat::Ok()) : diplomat::result(diplomat::Err(TimeZoneInvalidIdError::FromFFI(result.err))); + return result.is_ok ? diplomat::result(diplomat::Ok()) : diplomat::result(diplomat::Err(TimeZoneInvalidIdError {})); } inline diplomat::result CustomTimeZone::try_set_iana_time_zone_id(const TimeZoneIdMapper& mapper, std::string_view id) { @@ -178,7 +178,7 @@ inline diplomat::result CustomTimeZone:: mapper.AsFFI(), id.data(), id.size()); - return result.is_ok ? diplomat::result(diplomat::Ok()) : diplomat::result(diplomat::Err(TimeZoneInvalidIdError::FromFFI(result.err))); + return result.is_ok ? diplomat::result(diplomat::Ok()) : diplomat::result(diplomat::Err(TimeZoneInvalidIdError {})); } inline void CustomTimeZone::clear_time_zone_id() { @@ -197,7 +197,7 @@ inline diplomat::result CustomTimeZone:: auto result = diplomat::capi::icu4x_CustomTimeZone_try_set_metazone_id_mv1(this->AsFFI(), id.data(), id.size()); - return result.is_ok ? diplomat::result(diplomat::Ok()) : diplomat::result(diplomat::Err(TimeZoneInvalidIdError::FromFFI(result.err))); + return result.is_ok ? diplomat::result(diplomat::Ok()) : diplomat::result(diplomat::Err(TimeZoneInvalidIdError {})); } inline void CustomTimeZone::clear_metazone_id() { diff --git a/ffi/capi/bindings/cpp/DataProvider.d.hpp b/ffi/capi/bindings/cpp/DataProvider.d.hpp index 6e6c87be07a..2b486797254 100644 --- a/ffi/capi/bindings/cpp/DataProvider.d.hpp +++ b/ffi/capi/bindings/cpp/DataProvider.d.hpp @@ -23,13 +23,13 @@ namespace capi { class DataProvider { public: - inline static std::unique_ptr create_compiled(); + inline static std::unique_ptr compiled(); - inline static diplomat::result, DataError> create_fs(std::string_view path); + inline static diplomat::result, DataError> from_fs(std::string_view path); - inline static diplomat::result, DataError> create_from_byte_slice(diplomat::span blob); + inline static diplomat::result, DataError> from_byte_slice(diplomat::span blob); - inline static std::unique_ptr create_empty(); + inline static std::unique_ptr empty(); inline diplomat::result fork_by_key(DataProvider& other); diff --git a/ffi/capi/bindings/cpp/DataProvider.hpp b/ffi/capi/bindings/cpp/DataProvider.hpp index b54c3e4ee92..928f5bdf39c 100644 --- a/ffi/capi/bindings/cpp/DataProvider.hpp +++ b/ffi/capi/bindings/cpp/DataProvider.hpp @@ -9,24 +9,24 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "LocaleFallbacker.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { namespace capi { extern "C" { - diplomat::capi::DataProvider* icu4x_DataProvider_create_compiled_mv1(); + diplomat::capi::DataProvider* icu4x_DataProvider_compiled_mv1(void); - typedef struct icu4x_DataProvider_create_fs_mv1_result {union {diplomat::capi::DataProvider* ok; diplomat::capi::DataError err;}; bool is_ok;} icu4x_DataProvider_create_fs_mv1_result; - icu4x_DataProvider_create_fs_mv1_result icu4x_DataProvider_create_fs_mv1(const char* path_data, size_t path_len); + typedef struct icu4x_DataProvider_from_fs_mv1_result {union {diplomat::capi::DataProvider* ok; diplomat::capi::DataError err;}; bool is_ok;} icu4x_DataProvider_from_fs_mv1_result; + icu4x_DataProvider_from_fs_mv1_result icu4x_DataProvider_from_fs_mv1(const char* path_data, size_t path_len); - typedef struct icu4x_DataProvider_create_from_byte_slice_mv1_result {union {diplomat::capi::DataProvider* ok; diplomat::capi::DataError err;}; bool is_ok;} icu4x_DataProvider_create_from_byte_slice_mv1_result; - icu4x_DataProvider_create_from_byte_slice_mv1_result icu4x_DataProvider_create_from_byte_slice_mv1(const uint8_t* blob_data, size_t blob_len); + typedef struct icu4x_DataProvider_from_byte_slice_mv1_result {union {diplomat::capi::DataProvider* ok; diplomat::capi::DataError err;}; bool is_ok;} icu4x_DataProvider_from_byte_slice_mv1_result; + icu4x_DataProvider_from_byte_slice_mv1_result icu4x_DataProvider_from_byte_slice_mv1(const uint8_t* blob_data, size_t blob_len); - diplomat::capi::DataProvider* icu4x_DataProvider_create_empty_mv1(); + diplomat::capi::DataProvider* icu4x_DataProvider_empty_mv1(void); typedef struct icu4x_DataProvider_fork_by_key_mv1_result {union { diplomat::capi::DataError err;}; bool is_ok;} icu4x_DataProvider_fork_by_key_mv1_result; icu4x_DataProvider_fork_by_key_mv1_result icu4x_DataProvider_fork_by_key_mv1(diplomat::capi::DataProvider* self, diplomat::capi::DataProvider* other); @@ -44,25 +44,25 @@ namespace capi { } // namespace capi } // namespace -inline std::unique_ptr DataProvider::create_compiled() { - auto result = diplomat::capi::icu4x_DataProvider_create_compiled_mv1(); +inline std::unique_ptr DataProvider::compiled() { + auto result = diplomat::capi::icu4x_DataProvider_compiled_mv1(); return std::unique_ptr(DataProvider::FromFFI(result)); } -inline diplomat::result, DataError> DataProvider::create_fs(std::string_view path) { - auto result = diplomat::capi::icu4x_DataProvider_create_fs_mv1(path.data(), +inline diplomat::result, DataError> DataProvider::from_fs(std::string_view path) { + auto result = diplomat::capi::icu4x_DataProvider_from_fs_mv1(path.data(), path.size()); return result.is_ok ? diplomat::result, DataError>(diplomat::Ok>(std::unique_ptr(DataProvider::FromFFI(result.ok)))) : diplomat::result, DataError>(diplomat::Err(DataError::FromFFI(result.err))); } -inline diplomat::result, DataError> DataProvider::create_from_byte_slice(diplomat::span blob) { - auto result = diplomat::capi::icu4x_DataProvider_create_from_byte_slice_mv1(blob.data(), +inline diplomat::result, DataError> DataProvider::from_byte_slice(diplomat::span blob) { + auto result = diplomat::capi::icu4x_DataProvider_from_byte_slice_mv1(blob.data(), blob.size()); return result.is_ok ? diplomat::result, DataError>(diplomat::Ok>(std::unique_ptr(DataProvider::FromFFI(result.ok)))) : diplomat::result, DataError>(diplomat::Err(DataError::FromFFI(result.err))); } -inline std::unique_ptr DataProvider::create_empty() { - auto result = diplomat::capi::icu4x_DataProvider_create_empty_mv1(); +inline std::unique_ptr DataProvider::empty() { + auto result = diplomat::capi::icu4x_DataProvider_empty_mv1(); return std::unique_ptr(DataProvider::FromFFI(result)); } diff --git a/ffi/capi/bindings/cpp/DataStruct.d.hpp b/ffi/capi/bindings/cpp/DataStruct.d.hpp deleted file mode 100644 index c721d6b2c3a..00000000000 --- a/ffi/capi/bindings/cpp/DataStruct.d.hpp +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef DataStruct_D_HPP -#define DataStruct_D_HPP - -#include -#include -#include -#include -#include -#include -#include "diplomat_runtime.hpp" - - -namespace diplomat { -namespace capi { - struct DataStruct; -} // namespace capi -} // namespace - -class DataStruct { -public: - - inline static std::unique_ptr create_decimal_symbols_v1(std::string_view plus_sign_prefix, std::string_view plus_sign_suffix, std::string_view minus_sign_prefix, std::string_view minus_sign_suffix, std::string_view decimal_separator, std::string_view grouping_separator, uint8_t primary_group_size, uint8_t secondary_group_size, uint8_t min_group_size, diplomat::span digits); - - inline const diplomat::capi::DataStruct* AsFFI() const; - inline diplomat::capi::DataStruct* AsFFI(); - inline static const DataStruct* FromFFI(const diplomat::capi::DataStruct* ptr); - inline static DataStruct* FromFFI(diplomat::capi::DataStruct* ptr); - inline static void operator delete(void* ptr); -private: - DataStruct() = delete; - DataStruct(const DataStruct&) = delete; - DataStruct(DataStruct&&) noexcept = delete; - DataStruct operator=(const DataStruct&) = delete; - DataStruct operator=(DataStruct&&) noexcept = delete; - static void operator delete[](void*, size_t) = delete; -}; - - -#endif // DataStruct_D_HPP diff --git a/ffi/capi/bindings/cpp/DataStruct.hpp b/ffi/capi/bindings/cpp/DataStruct.hpp deleted file mode 100644 index ab91ed8cf9b..00000000000 --- a/ffi/capi/bindings/cpp/DataStruct.hpp +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef DataStruct_HPP -#define DataStruct_HPP - -#include "DataStruct.d.hpp" - -#include -#include -#include -#include -#include -#include -#include "diplomat_runtime.hpp" - - -namespace diplomat { -namespace capi { - extern "C" { - - diplomat::capi::DataStruct* icu4x_DataStruct_create_decimal_symbols_v1_mv1(const char* plus_sign_prefix_data, size_t plus_sign_prefix_len, const char* plus_sign_suffix_data, size_t plus_sign_suffix_len, const char* minus_sign_prefix_data, size_t minus_sign_prefix_len, const char* minus_sign_suffix_data, size_t minus_sign_suffix_len, const char* decimal_separator_data, size_t decimal_separator_len, const char* grouping_separator_data, size_t grouping_separator_len, uint8_t primary_group_size, uint8_t secondary_group_size, uint8_t min_group_size, const char32_t* digits_data, size_t digits_len); - - - void icu4x_DataStruct_destroy_mv1(DataStruct* self); - - } // extern "C" -} // namespace capi -} // namespace - -inline std::unique_ptr DataStruct::create_decimal_symbols_v1(std::string_view plus_sign_prefix, std::string_view plus_sign_suffix, std::string_view minus_sign_prefix, std::string_view minus_sign_suffix, std::string_view decimal_separator, std::string_view grouping_separator, uint8_t primary_group_size, uint8_t secondary_group_size, uint8_t min_group_size, diplomat::span digits) { - auto result = diplomat::capi::icu4x_DataStruct_create_decimal_symbols_v1_mv1(plus_sign_prefix.data(), - plus_sign_prefix.size(), - plus_sign_suffix.data(), - plus_sign_suffix.size(), - minus_sign_prefix.data(), - minus_sign_prefix.size(), - minus_sign_suffix.data(), - minus_sign_suffix.size(), - decimal_separator.data(), - decimal_separator.size(), - grouping_separator.data(), - grouping_separator.size(), - primary_group_size, - secondary_group_size, - min_group_size, - digits.data(), - digits.size()); - return std::unique_ptr(DataStruct::FromFFI(result)); -} - -inline const diplomat::capi::DataStruct* DataStruct::AsFFI() const { - return reinterpret_cast(this); -} - -inline diplomat::capi::DataStruct* DataStruct::AsFFI() { - return reinterpret_cast(this); -} - -inline const DataStruct* DataStruct::FromFFI(const diplomat::capi::DataStruct* ptr) { - return reinterpret_cast(ptr); -} - -inline DataStruct* DataStruct::FromFFI(diplomat::capi::DataStruct* ptr) { - return reinterpret_cast(ptr); -} - -inline void DataStruct::operator delete(void* ptr) { - diplomat::capi::icu4x_DataStruct_destroy_mv1(reinterpret_cast(ptr)); -} - - -#endif // DataStruct_HPP diff --git a/ffi/capi/bindings/cpp/Date.d.hpp b/ffi/capi/bindings/cpp/Date.d.hpp index 1e5a5a7916e..affe42f5a38 100644 --- a/ffi/capi/bindings/cpp/Date.d.hpp +++ b/ffi/capi/bindings/cpp/Date.d.hpp @@ -17,6 +17,7 @@ namespace diplomat::capi { struct WeekCalculator; } class WeekCalculator; struct WeekOf; class CalendarError; +class CalendarParseError; class IsoWeekday; @@ -29,9 +30,11 @@ namespace capi { class Date { public: - inline static diplomat::result, CalendarError> create_from_iso_in_calendar(int32_t year, uint8_t month, uint8_t day, const Calendar& calendar); + inline static diplomat::result, CalendarError> from_iso_in_calendar(int32_t year, uint8_t month, uint8_t day, const Calendar& calendar); - inline static diplomat::result, CalendarError> create_from_codes_in_calendar(std::string_view era_code, int32_t year, std::string_view month_code, uint8_t day, const Calendar& calendar); + inline static diplomat::result, CalendarError> from_codes_in_calendar(std::string_view era_code, int32_t year, std::string_view month_code, uint8_t day, const Calendar& calendar); + + inline static diplomat::result, CalendarParseError> from_string(std::string_view v); inline std::unique_ptr to_calendar(const Calendar& calendar) const; diff --git a/ffi/capi/bindings/cpp/Date.hpp b/ffi/capi/bindings/cpp/Date.hpp index 39a9396e942..23ce507331a 100644 --- a/ffi/capi/bindings/cpp/Date.hpp +++ b/ffi/capi/bindings/cpp/Date.hpp @@ -9,24 +9,28 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "Calendar.hpp" #include "CalendarError.hpp" +#include "CalendarParseError.hpp" #include "IsoDate.hpp" #include "IsoWeekday.hpp" #include "WeekCalculator.hpp" #include "WeekOf.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { namespace capi { extern "C" { - typedef struct icu4x_Date_create_from_iso_in_calendar_mv1_result {union {diplomat::capi::Date* ok; diplomat::capi::CalendarError err;}; bool is_ok;} icu4x_Date_create_from_iso_in_calendar_mv1_result; - icu4x_Date_create_from_iso_in_calendar_mv1_result icu4x_Date_create_from_iso_in_calendar_mv1(int32_t year, uint8_t month, uint8_t day, const diplomat::capi::Calendar* calendar); + typedef struct icu4x_Date_from_iso_in_calendar_mv1_result {union {diplomat::capi::Date* ok; diplomat::capi::CalendarError err;}; bool is_ok;} icu4x_Date_from_iso_in_calendar_mv1_result; + icu4x_Date_from_iso_in_calendar_mv1_result icu4x_Date_from_iso_in_calendar_mv1(int32_t year, uint8_t month, uint8_t day, const diplomat::capi::Calendar* calendar); + + typedef struct icu4x_Date_from_codes_in_calendar_mv1_result {union {diplomat::capi::Date* ok; diplomat::capi::CalendarError err;}; bool is_ok;} icu4x_Date_from_codes_in_calendar_mv1_result; + icu4x_Date_from_codes_in_calendar_mv1_result icu4x_Date_from_codes_in_calendar_mv1(const char* era_code_data, size_t era_code_len, int32_t year, const char* month_code_data, size_t month_code_len, uint8_t day, const diplomat::capi::Calendar* calendar); - typedef struct icu4x_Date_create_from_codes_in_calendar_mv1_result {union {diplomat::capi::Date* ok; diplomat::capi::CalendarError err;}; bool is_ok;} icu4x_Date_create_from_codes_in_calendar_mv1_result; - icu4x_Date_create_from_codes_in_calendar_mv1_result icu4x_Date_create_from_codes_in_calendar_mv1(const char* era_code_data, size_t era_code_len, int32_t year, const char* month_code_data, size_t month_code_len, uint8_t day, const diplomat::capi::Calendar* calendar); + typedef struct icu4x_Date_from_string_mv1_result {union {diplomat::capi::Date* ok; diplomat::capi::CalendarParseError err;}; bool is_ok;} icu4x_Date_from_string_mv1_result; + icu4x_Date_from_string_mv1_result icu4x_Date_from_string_mv1(const char* v_data, size_t v_len); diplomat::capi::Date* icu4x_Date_to_calendar_mv1(const diplomat::capi::Date* self, const diplomat::capi::Calendar* calendar); @@ -65,16 +69,16 @@ namespace capi { } // namespace capi } // namespace -inline diplomat::result, CalendarError> Date::create_from_iso_in_calendar(int32_t year, uint8_t month, uint8_t day, const Calendar& calendar) { - auto result = diplomat::capi::icu4x_Date_create_from_iso_in_calendar_mv1(year, +inline diplomat::result, CalendarError> Date::from_iso_in_calendar(int32_t year, uint8_t month, uint8_t day, const Calendar& calendar) { + auto result = diplomat::capi::icu4x_Date_from_iso_in_calendar_mv1(year, month, day, calendar.AsFFI()); return result.is_ok ? diplomat::result, CalendarError>(diplomat::Ok>(std::unique_ptr(Date::FromFFI(result.ok)))) : diplomat::result, CalendarError>(diplomat::Err(CalendarError::FromFFI(result.err))); } -inline diplomat::result, CalendarError> Date::create_from_codes_in_calendar(std::string_view era_code, int32_t year, std::string_view month_code, uint8_t day, const Calendar& calendar) { - auto result = diplomat::capi::icu4x_Date_create_from_codes_in_calendar_mv1(era_code.data(), +inline diplomat::result, CalendarError> Date::from_codes_in_calendar(std::string_view era_code, int32_t year, std::string_view month_code, uint8_t day, const Calendar& calendar) { + auto result = diplomat::capi::icu4x_Date_from_codes_in_calendar_mv1(era_code.data(), era_code.size(), year, month_code.data(), @@ -84,6 +88,12 @@ inline diplomat::result, CalendarError> Date::create_from_ return result.is_ok ? diplomat::result, CalendarError>(diplomat::Ok>(std::unique_ptr(Date::FromFFI(result.ok)))) : diplomat::result, CalendarError>(diplomat::Err(CalendarError::FromFFI(result.err))); } +inline diplomat::result, CalendarParseError> Date::from_string(std::string_view v) { + auto result = diplomat::capi::icu4x_Date_from_string_mv1(v.data(), + v.size()); + return result.is_ok ? diplomat::result, CalendarParseError>(diplomat::Ok>(std::unique_ptr(Date::FromFFI(result.ok)))) : diplomat::result, CalendarParseError>(diplomat::Err(CalendarParseError::FromFFI(result.err))); +} + inline std::unique_ptr Date::to_calendar(const Calendar& calendar) const { auto result = diplomat::capi::icu4x_Date_to_calendar_mv1(this->AsFFI(), calendar.AsFFI()); diff --git a/ffi/capi/bindings/cpp/DateFormatter.hpp b/ffi/capi/bindings/cpp/DateFormatter.hpp index b93b25b4f95..a78bf92f5fb 100644 --- a/ffi/capi/bindings/cpp/DateFormatter.hpp +++ b/ffi/capi/bindings/cpp/DateFormatter.hpp @@ -9,7 +9,6 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataProvider.hpp" #include "Date.hpp" #include "DateLength.hpp" @@ -18,6 +17,7 @@ #include "IsoDate.hpp" #include "IsoDateTime.hpp" #include "Locale.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/DateTime.d.hpp b/ffi/capi/bindings/cpp/DateTime.d.hpp index fad238deb1d..62633c065eb 100644 --- a/ffi/capi/bindings/cpp/DateTime.d.hpp +++ b/ffi/capi/bindings/cpp/DateTime.d.hpp @@ -21,6 +21,7 @@ namespace diplomat::capi { struct WeekCalculator; } class WeekCalculator; struct WeekOf; class CalendarError; +class CalendarParseError; class IsoWeekday; @@ -33,11 +34,13 @@ namespace capi { class DateTime { public: - inline static diplomat::result, CalendarError> create_from_iso_in_calendar(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const Calendar& calendar); + inline static diplomat::result, CalendarError> from_iso_in_calendar(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const Calendar& calendar); - inline static diplomat::result, CalendarError> create_from_codes_in_calendar(std::string_view era_code, int32_t year, std::string_view month_code, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const Calendar& calendar); + inline static diplomat::result, CalendarError> from_codes_in_calendar(std::string_view era_code, int32_t year, std::string_view month_code, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const Calendar& calendar); - inline static std::unique_ptr create_from_date_and_time(const Date& date, const Time& time); + inline static std::unique_ptr from_date_and_time(const Date& date, const Time& time); + + inline static diplomat::result, CalendarParseError> from_string(std::string_view v); inline std::unique_ptr date() const; diff --git a/ffi/capi/bindings/cpp/DateTime.hpp b/ffi/capi/bindings/cpp/DateTime.hpp index 6c45e802ef2..c818b22e920 100644 --- a/ffi/capi/bindings/cpp/DateTime.hpp +++ b/ffi/capi/bindings/cpp/DateTime.hpp @@ -9,28 +9,32 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "Calendar.hpp" #include "CalendarError.hpp" +#include "CalendarParseError.hpp" #include "Date.hpp" #include "IsoDateTime.hpp" #include "IsoWeekday.hpp" #include "Time.hpp" #include "WeekCalculator.hpp" #include "WeekOf.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { namespace capi { extern "C" { - typedef struct icu4x_DateTime_create_from_iso_in_calendar_mv1_result {union {diplomat::capi::DateTime* ok; diplomat::capi::CalendarError err;}; bool is_ok;} icu4x_DateTime_create_from_iso_in_calendar_mv1_result; - icu4x_DateTime_create_from_iso_in_calendar_mv1_result icu4x_DateTime_create_from_iso_in_calendar_mv1(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const diplomat::capi::Calendar* calendar); + typedef struct icu4x_DateTime_from_iso_in_calendar_mv1_result {union {diplomat::capi::DateTime* ok; diplomat::capi::CalendarError err;}; bool is_ok;} icu4x_DateTime_from_iso_in_calendar_mv1_result; + icu4x_DateTime_from_iso_in_calendar_mv1_result icu4x_DateTime_from_iso_in_calendar_mv1(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const diplomat::capi::Calendar* calendar); + + typedef struct icu4x_DateTime_from_codes_in_calendar_mv1_result {union {diplomat::capi::DateTime* ok; diplomat::capi::CalendarError err;}; bool is_ok;} icu4x_DateTime_from_codes_in_calendar_mv1_result; + icu4x_DateTime_from_codes_in_calendar_mv1_result icu4x_DateTime_from_codes_in_calendar_mv1(const char* era_code_data, size_t era_code_len, int32_t year, const char* month_code_data, size_t month_code_len, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const diplomat::capi::Calendar* calendar); - typedef struct icu4x_DateTime_create_from_codes_in_calendar_mv1_result {union {diplomat::capi::DateTime* ok; diplomat::capi::CalendarError err;}; bool is_ok;} icu4x_DateTime_create_from_codes_in_calendar_mv1_result; - icu4x_DateTime_create_from_codes_in_calendar_mv1_result icu4x_DateTime_create_from_codes_in_calendar_mv1(const char* era_code_data, size_t era_code_len, int32_t year, const char* month_code_data, size_t month_code_len, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const diplomat::capi::Calendar* calendar); + diplomat::capi::DateTime* icu4x_DateTime_from_date_and_time_mv1(const diplomat::capi::Date* date, const diplomat::capi::Time* time); - diplomat::capi::DateTime* icu4x_DateTime_create_from_date_and_time_mv1(const diplomat::capi::Date* date, const diplomat::capi::Time* time); + typedef struct icu4x_DateTime_from_string_mv1_result {union {diplomat::capi::DateTime* ok; diplomat::capi::CalendarParseError err;}; bool is_ok;} icu4x_DateTime_from_string_mv1_result; + icu4x_DateTime_from_string_mv1_result icu4x_DateTime_from_string_mv1(const char* v_data, size_t v_len); diplomat::capi::Date* icu4x_DateTime_date_mv1(const diplomat::capi::DateTime* self); @@ -81,8 +85,8 @@ namespace capi { } // namespace capi } // namespace -inline diplomat::result, CalendarError> DateTime::create_from_iso_in_calendar(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const Calendar& calendar) { - auto result = diplomat::capi::icu4x_DateTime_create_from_iso_in_calendar_mv1(year, +inline diplomat::result, CalendarError> DateTime::from_iso_in_calendar(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const Calendar& calendar) { + auto result = diplomat::capi::icu4x_DateTime_from_iso_in_calendar_mv1(year, month, day, hour, @@ -93,8 +97,8 @@ inline diplomat::result, CalendarError> DateTime::crea return result.is_ok ? diplomat::result, CalendarError>(diplomat::Ok>(std::unique_ptr(DateTime::FromFFI(result.ok)))) : diplomat::result, CalendarError>(diplomat::Err(CalendarError::FromFFI(result.err))); } -inline diplomat::result, CalendarError> DateTime::create_from_codes_in_calendar(std::string_view era_code, int32_t year, std::string_view month_code, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const Calendar& calendar) { - auto result = diplomat::capi::icu4x_DateTime_create_from_codes_in_calendar_mv1(era_code.data(), +inline diplomat::result, CalendarError> DateTime::from_codes_in_calendar(std::string_view era_code, int32_t year, std::string_view month_code, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const Calendar& calendar) { + auto result = diplomat::capi::icu4x_DateTime_from_codes_in_calendar_mv1(era_code.data(), era_code.size(), year, month_code.data(), @@ -108,12 +112,18 @@ inline diplomat::result, CalendarError> DateTime::crea return result.is_ok ? diplomat::result, CalendarError>(diplomat::Ok>(std::unique_ptr(DateTime::FromFFI(result.ok)))) : diplomat::result, CalendarError>(diplomat::Err(CalendarError::FromFFI(result.err))); } -inline std::unique_ptr DateTime::create_from_date_and_time(const Date& date, const Time& time) { - auto result = diplomat::capi::icu4x_DateTime_create_from_date_and_time_mv1(date.AsFFI(), +inline std::unique_ptr DateTime::from_date_and_time(const Date& date, const Time& time) { + auto result = diplomat::capi::icu4x_DateTime_from_date_and_time_mv1(date.AsFFI(), time.AsFFI()); return std::unique_ptr(DateTime::FromFFI(result)); } +inline diplomat::result, CalendarParseError> DateTime::from_string(std::string_view v) { + auto result = diplomat::capi::icu4x_DateTime_from_string_mv1(v.data(), + v.size()); + return result.is_ok ? diplomat::result, CalendarParseError>(diplomat::Ok>(std::unique_ptr(DateTime::FromFFI(result.ok)))) : diplomat::result, CalendarParseError>(diplomat::Err(CalendarParseError::FromFFI(result.err))); +} + inline std::unique_ptr DateTime::date() const { auto result = diplomat::capi::icu4x_DateTime_date_mv1(this->AsFFI()); return std::unique_ptr(Date::FromFFI(result)); diff --git a/ffi/capi/bindings/cpp/DateTimeFormatter.hpp b/ffi/capi/bindings/cpp/DateTimeFormatter.hpp index d892ae4486b..20a7c4a0e5e 100644 --- a/ffi/capi/bindings/cpp/DateTimeFormatter.hpp +++ b/ffi/capi/bindings/cpp/DateTimeFormatter.hpp @@ -9,7 +9,6 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataProvider.hpp" #include "DateLength.hpp" #include "DateTime.hpp" @@ -17,6 +16,7 @@ #include "IsoDateTime.hpp" #include "Locale.hpp" #include "TimeLength.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/Decomposed.hpp b/ffi/capi/bindings/cpp/Decomposed.hpp index a9b1d283749..3ea1fe951cc 100644 --- a/ffi/capi/bindings/cpp/Decomposed.hpp +++ b/ffi/capi/bindings/cpp/Decomposed.hpp @@ -24,15 +24,15 @@ namespace capi { inline diplomat::capi::Decomposed Decomposed::AsFFI() const { return diplomat::capi::Decomposed { - .first = first, - .second = second, + /* .first = */ first, + /* .second = */ second, }; } inline Decomposed Decomposed::FromFFI(diplomat::capi::Decomposed c_struct) { return Decomposed { - .first = c_struct.first, - .second = c_struct.second, + /* .first = */ c_struct.first, + /* .second = */ c_struct.second, }; } diff --git a/ffi/capi/bindings/cpp/DecomposingNormalizer.hpp b/ffi/capi/bindings/cpp/DecomposingNormalizer.hpp index cecadbf8f90..0d917970f60 100644 --- a/ffi/capi/bindings/cpp/DecomposingNormalizer.hpp +++ b/ffi/capi/bindings/cpp/DecomposingNormalizer.hpp @@ -9,9 +9,9 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/DisplayNamesOptionsV1.d.hpp b/ffi/capi/bindings/cpp/DisplayNamesOptionsV1.d.hpp index f5bfd9aade8..bfe482bf6f4 100644 --- a/ffi/capi/bindings/cpp/DisplayNamesOptionsV1.d.hpp +++ b/ffi/capi/bindings/cpp/DisplayNamesOptionsV1.d.hpp @@ -7,10 +7,10 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DisplayNamesFallback.d.hpp" #include "DisplayNamesStyle.d.hpp" #include "LanguageDisplay.d.hpp" +#include "diplomat_runtime.hpp" class DisplayNamesFallback; class DisplayNamesStyle; diff --git a/ffi/capi/bindings/cpp/DisplayNamesOptionsV1.hpp b/ffi/capi/bindings/cpp/DisplayNamesOptionsV1.hpp index 83b0fd3ad31..c77ca161c1b 100644 --- a/ffi/capi/bindings/cpp/DisplayNamesOptionsV1.hpp +++ b/ffi/capi/bindings/cpp/DisplayNamesOptionsV1.hpp @@ -9,10 +9,10 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DisplayNamesFallback.hpp" #include "DisplayNamesStyle.hpp" #include "LanguageDisplay.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -27,17 +27,17 @@ namespace capi { inline diplomat::capi::DisplayNamesOptionsV1 DisplayNamesOptionsV1::AsFFI() const { return diplomat::capi::DisplayNamesOptionsV1 { - .style = style.AsFFI(), - .fallback = fallback.AsFFI(), - .language_display = language_display.AsFFI(), + /* .style = */ style.AsFFI(), + /* .fallback = */ fallback.AsFFI(), + /* .language_display = */ language_display.AsFFI(), }; } inline DisplayNamesOptionsV1 DisplayNamesOptionsV1::FromFFI(diplomat::capi::DisplayNamesOptionsV1 c_struct) { return DisplayNamesOptionsV1 { - .style = DisplayNamesStyle::FromFFI(c_struct.style), - .fallback = DisplayNamesFallback::FromFFI(c_struct.fallback), - .language_display = LanguageDisplay::FromFFI(c_struct.language_display), + /* .style = */ DisplayNamesStyle::FromFFI(c_struct.style), + /* .fallback = */ DisplayNamesFallback::FromFFI(c_struct.fallback), + /* .language_display = */ LanguageDisplay::FromFFI(c_struct.language_display), }; } diff --git a/ffi/capi/bindings/cpp/FixedDecimal.d.hpp b/ffi/capi/bindings/cpp/FixedDecimal.d.hpp index 777b3a41a05..f7bb205e670 100644 --- a/ffi/capi/bindings/cpp/FixedDecimal.d.hpp +++ b/ffi/capi/bindings/cpp/FixedDecimal.d.hpp @@ -9,7 +9,7 @@ #include #include "diplomat_runtime.hpp" -class FixedDecimalLimitError; +struct FixedDecimalLimitError; class FixedDecimalParseError; class FixedDecimalRoundingIncrement; class FixedDecimalRoundingMode; @@ -26,23 +26,23 @@ namespace capi { class FixedDecimal { public: - inline static std::unique_ptr create_from_i32(int32_t v); + inline static std::unique_ptr from(int32_t v); - inline static std::unique_ptr create_from_u32(uint32_t v); + inline static std::unique_ptr from(uint32_t v); - inline static std::unique_ptr create_from_i64(int64_t v); + inline static std::unique_ptr from(int64_t v); - inline static std::unique_ptr create_from_u64(uint64_t v); + inline static std::unique_ptr from(uint64_t v); - inline static diplomat::result, FixedDecimalLimitError> create_from_f64_with_integer_precision(double f); + inline static diplomat::result, FixedDecimalLimitError> from_double_with_integer_precision(double f); - inline static diplomat::result, FixedDecimalLimitError> create_from_f64_with_lower_magnitude(double f, int16_t magnitude); + inline static diplomat::result, FixedDecimalLimitError> from_double_with_lower_magnitude(double f, int16_t magnitude); - inline static diplomat::result, FixedDecimalLimitError> create_from_f64_with_significant_digits(double f, uint8_t digits); + inline static diplomat::result, FixedDecimalLimitError> from_double_with_significant_digits(double f, uint8_t digits); - inline static diplomat::result, FixedDecimalLimitError> create_from_f64_with_floating_precision(double f); + inline static diplomat::result, FixedDecimalLimitError> from_double_with_floating_precision(double f); - inline static diplomat::result, FixedDecimalParseError> create_from_string(std::string_view v); + inline static diplomat::result, FixedDecimalParseError> from_string(std::string_view v); inline uint8_t digit_at(int16_t magnitude) const; diff --git a/ffi/capi/bindings/cpp/FixedDecimal.hpp b/ffi/capi/bindings/cpp/FixedDecimal.hpp index e203eacf9a4..2ac1400d5cc 100644 --- a/ffi/capi/bindings/cpp/FixedDecimal.hpp +++ b/ffi/capi/bindings/cpp/FixedDecimal.hpp @@ -9,41 +9,41 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "FixedDecimalLimitError.hpp" #include "FixedDecimalParseError.hpp" #include "FixedDecimalRoundingIncrement.hpp" #include "FixedDecimalRoundingMode.hpp" #include "FixedDecimalSign.hpp" #include "FixedDecimalSignDisplay.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { namespace capi { extern "C" { - diplomat::capi::FixedDecimal* icu4x_FixedDecimal_create_from_i32_mv1(int32_t v); + diplomat::capi::FixedDecimal* icu4x_FixedDecimal_from_int32_mv1(int32_t v); - diplomat::capi::FixedDecimal* icu4x_FixedDecimal_create_from_u32_mv1(uint32_t v); + diplomat::capi::FixedDecimal* icu4x_FixedDecimal_from_uint32_mv1(uint32_t v); - diplomat::capi::FixedDecimal* icu4x_FixedDecimal_create_from_i64_mv1(int64_t v); + diplomat::capi::FixedDecimal* icu4x_FixedDecimal_from_int64_mv1(int64_t v); - diplomat::capi::FixedDecimal* icu4x_FixedDecimal_create_from_u64_mv1(uint64_t v); + diplomat::capi::FixedDecimal* icu4x_FixedDecimal_from_uint64_mv1(uint64_t v); - typedef struct icu4x_FixedDecimal_create_from_f64_with_integer_precision_mv1_result {union {diplomat::capi::FixedDecimal* ok; diplomat::capi::FixedDecimalLimitError err;}; bool is_ok;} icu4x_FixedDecimal_create_from_f64_with_integer_precision_mv1_result; - icu4x_FixedDecimal_create_from_f64_with_integer_precision_mv1_result icu4x_FixedDecimal_create_from_f64_with_integer_precision_mv1(double f); + typedef struct icu4x_FixedDecimal_from_double_with_integer_precision_mv1_result {union {diplomat::capi::FixedDecimal* ok; }; bool is_ok;} icu4x_FixedDecimal_from_double_with_integer_precision_mv1_result; + icu4x_FixedDecimal_from_double_with_integer_precision_mv1_result icu4x_FixedDecimal_from_double_with_integer_precision_mv1(double f); - typedef struct icu4x_FixedDecimal_create_from_f64_with_lower_magnitude_mv1_result {union {diplomat::capi::FixedDecimal* ok; diplomat::capi::FixedDecimalLimitError err;}; bool is_ok;} icu4x_FixedDecimal_create_from_f64_with_lower_magnitude_mv1_result; - icu4x_FixedDecimal_create_from_f64_with_lower_magnitude_mv1_result icu4x_FixedDecimal_create_from_f64_with_lower_magnitude_mv1(double f, int16_t magnitude); + typedef struct icu4x_FixedDecimal_from_double_with_lower_magnitude_mv1_result {union {diplomat::capi::FixedDecimal* ok; }; bool is_ok;} icu4x_FixedDecimal_from_double_with_lower_magnitude_mv1_result; + icu4x_FixedDecimal_from_double_with_lower_magnitude_mv1_result icu4x_FixedDecimal_from_double_with_lower_magnitude_mv1(double f, int16_t magnitude); - typedef struct icu4x_FixedDecimal_create_from_f64_with_significant_digits_mv1_result {union {diplomat::capi::FixedDecimal* ok; diplomat::capi::FixedDecimalLimitError err;}; bool is_ok;} icu4x_FixedDecimal_create_from_f64_with_significant_digits_mv1_result; - icu4x_FixedDecimal_create_from_f64_with_significant_digits_mv1_result icu4x_FixedDecimal_create_from_f64_with_significant_digits_mv1(double f, uint8_t digits); + typedef struct icu4x_FixedDecimal_from_double_with_significant_digits_mv1_result {union {diplomat::capi::FixedDecimal* ok; }; bool is_ok;} icu4x_FixedDecimal_from_double_with_significant_digits_mv1_result; + icu4x_FixedDecimal_from_double_with_significant_digits_mv1_result icu4x_FixedDecimal_from_double_with_significant_digits_mv1(double f, uint8_t digits); - typedef struct icu4x_FixedDecimal_create_from_f64_with_floating_precision_mv1_result {union {diplomat::capi::FixedDecimal* ok; diplomat::capi::FixedDecimalLimitError err;}; bool is_ok;} icu4x_FixedDecimal_create_from_f64_with_floating_precision_mv1_result; - icu4x_FixedDecimal_create_from_f64_with_floating_precision_mv1_result icu4x_FixedDecimal_create_from_f64_with_floating_precision_mv1(double f); + typedef struct icu4x_FixedDecimal_from_double_with_floating_precision_mv1_result {union {diplomat::capi::FixedDecimal* ok; }; bool is_ok;} icu4x_FixedDecimal_from_double_with_floating_precision_mv1_result; + icu4x_FixedDecimal_from_double_with_floating_precision_mv1_result icu4x_FixedDecimal_from_double_with_floating_precision_mv1(double f); - typedef struct icu4x_FixedDecimal_create_from_string_mv1_result {union {diplomat::capi::FixedDecimal* ok; diplomat::capi::FixedDecimalParseError err;}; bool is_ok;} icu4x_FixedDecimal_create_from_string_mv1_result; - icu4x_FixedDecimal_create_from_string_mv1_result icu4x_FixedDecimal_create_from_string_mv1(const char* v_data, size_t v_len); + typedef struct icu4x_FixedDecimal_from_string_mv1_result {union {diplomat::capi::FixedDecimal* ok; diplomat::capi::FixedDecimalParseError err;}; bool is_ok;} icu4x_FixedDecimal_from_string_mv1_result; + icu4x_FixedDecimal_from_string_mv1_result icu4x_FixedDecimal_from_string_mv1(const char* v_data, size_t v_len); uint8_t icu4x_FixedDecimal_digit_at_mv1(const diplomat::capi::FixedDecimal* self, int16_t magnitude); @@ -101,50 +101,50 @@ namespace capi { } // namespace capi } // namespace -inline std::unique_ptr FixedDecimal::create_from_i32(int32_t v) { - auto result = diplomat::capi::icu4x_FixedDecimal_create_from_i32_mv1(v); +inline std::unique_ptr FixedDecimal::from(int32_t v) { + auto result = diplomat::capi::icu4x_FixedDecimal_from_int32_mv1(v); return std::unique_ptr(FixedDecimal::FromFFI(result)); } -inline std::unique_ptr FixedDecimal::create_from_u32(uint32_t v) { - auto result = diplomat::capi::icu4x_FixedDecimal_create_from_u32_mv1(v); +inline std::unique_ptr FixedDecimal::from(uint32_t v) { + auto result = diplomat::capi::icu4x_FixedDecimal_from_uint32_mv1(v); return std::unique_ptr(FixedDecimal::FromFFI(result)); } -inline std::unique_ptr FixedDecimal::create_from_i64(int64_t v) { - auto result = diplomat::capi::icu4x_FixedDecimal_create_from_i64_mv1(v); +inline std::unique_ptr FixedDecimal::from(int64_t v) { + auto result = diplomat::capi::icu4x_FixedDecimal_from_int64_mv1(v); return std::unique_ptr(FixedDecimal::FromFFI(result)); } -inline std::unique_ptr FixedDecimal::create_from_u64(uint64_t v) { - auto result = diplomat::capi::icu4x_FixedDecimal_create_from_u64_mv1(v); +inline std::unique_ptr FixedDecimal::from(uint64_t v) { + auto result = diplomat::capi::icu4x_FixedDecimal_from_uint64_mv1(v); return std::unique_ptr(FixedDecimal::FromFFI(result)); } -inline diplomat::result, FixedDecimalLimitError> FixedDecimal::create_from_f64_with_integer_precision(double f) { - auto result = diplomat::capi::icu4x_FixedDecimal_create_from_f64_with_integer_precision_mv1(f); - return result.is_ok ? diplomat::result, FixedDecimalLimitError>(diplomat::Ok>(std::unique_ptr(FixedDecimal::FromFFI(result.ok)))) : diplomat::result, FixedDecimalLimitError>(diplomat::Err(FixedDecimalLimitError::FromFFI(result.err))); +inline diplomat::result, FixedDecimalLimitError> FixedDecimal::from_double_with_integer_precision(double f) { + auto result = diplomat::capi::icu4x_FixedDecimal_from_double_with_integer_precision_mv1(f); + return result.is_ok ? diplomat::result, FixedDecimalLimitError>(diplomat::Ok>(std::unique_ptr(FixedDecimal::FromFFI(result.ok)))) : diplomat::result, FixedDecimalLimitError>(diplomat::Err(FixedDecimalLimitError {})); } -inline diplomat::result, FixedDecimalLimitError> FixedDecimal::create_from_f64_with_lower_magnitude(double f, int16_t magnitude) { - auto result = diplomat::capi::icu4x_FixedDecimal_create_from_f64_with_lower_magnitude_mv1(f, +inline diplomat::result, FixedDecimalLimitError> FixedDecimal::from_double_with_lower_magnitude(double f, int16_t magnitude) { + auto result = diplomat::capi::icu4x_FixedDecimal_from_double_with_lower_magnitude_mv1(f, magnitude); - return result.is_ok ? diplomat::result, FixedDecimalLimitError>(diplomat::Ok>(std::unique_ptr(FixedDecimal::FromFFI(result.ok)))) : diplomat::result, FixedDecimalLimitError>(diplomat::Err(FixedDecimalLimitError::FromFFI(result.err))); + return result.is_ok ? diplomat::result, FixedDecimalLimitError>(diplomat::Ok>(std::unique_ptr(FixedDecimal::FromFFI(result.ok)))) : diplomat::result, FixedDecimalLimitError>(diplomat::Err(FixedDecimalLimitError {})); } -inline diplomat::result, FixedDecimalLimitError> FixedDecimal::create_from_f64_with_significant_digits(double f, uint8_t digits) { - auto result = diplomat::capi::icu4x_FixedDecimal_create_from_f64_with_significant_digits_mv1(f, +inline diplomat::result, FixedDecimalLimitError> FixedDecimal::from_double_with_significant_digits(double f, uint8_t digits) { + auto result = diplomat::capi::icu4x_FixedDecimal_from_double_with_significant_digits_mv1(f, digits); - return result.is_ok ? diplomat::result, FixedDecimalLimitError>(diplomat::Ok>(std::unique_ptr(FixedDecimal::FromFFI(result.ok)))) : diplomat::result, FixedDecimalLimitError>(diplomat::Err(FixedDecimalLimitError::FromFFI(result.err))); + return result.is_ok ? diplomat::result, FixedDecimalLimitError>(diplomat::Ok>(std::unique_ptr(FixedDecimal::FromFFI(result.ok)))) : diplomat::result, FixedDecimalLimitError>(diplomat::Err(FixedDecimalLimitError {})); } -inline diplomat::result, FixedDecimalLimitError> FixedDecimal::create_from_f64_with_floating_precision(double f) { - auto result = diplomat::capi::icu4x_FixedDecimal_create_from_f64_with_floating_precision_mv1(f); - return result.is_ok ? diplomat::result, FixedDecimalLimitError>(diplomat::Ok>(std::unique_ptr(FixedDecimal::FromFFI(result.ok)))) : diplomat::result, FixedDecimalLimitError>(diplomat::Err(FixedDecimalLimitError::FromFFI(result.err))); +inline diplomat::result, FixedDecimalLimitError> FixedDecimal::from_double_with_floating_precision(double f) { + auto result = diplomat::capi::icu4x_FixedDecimal_from_double_with_floating_precision_mv1(f); + return result.is_ok ? diplomat::result, FixedDecimalLimitError>(diplomat::Ok>(std::unique_ptr(FixedDecimal::FromFFI(result.ok)))) : diplomat::result, FixedDecimalLimitError>(diplomat::Err(FixedDecimalLimitError {})); } -inline diplomat::result, FixedDecimalParseError> FixedDecimal::create_from_string(std::string_view v) { - auto result = diplomat::capi::icu4x_FixedDecimal_create_from_string_mv1(v.data(), +inline diplomat::result, FixedDecimalParseError> FixedDecimal::from_string(std::string_view v) { + auto result = diplomat::capi::icu4x_FixedDecimal_from_string_mv1(v.data(), v.size()); return result.is_ok ? diplomat::result, FixedDecimalParseError>(diplomat::Ok>(std::unique_ptr(FixedDecimal::FromFFI(result.ok)))) : diplomat::result, FixedDecimalParseError>(diplomat::Err(FixedDecimalParseError::FromFFI(result.err))); } diff --git a/ffi/capi/bindings/cpp/FixedDecimalFormatter.d.hpp b/ffi/capi/bindings/cpp/FixedDecimalFormatter.d.hpp index 757f3f30149..626d442c8ba 100644 --- a/ffi/capi/bindings/cpp/FixedDecimalFormatter.d.hpp +++ b/ffi/capi/bindings/cpp/FixedDecimalFormatter.d.hpp @@ -11,8 +11,6 @@ namespace diplomat::capi { struct DataProvider; } class DataProvider; -namespace diplomat::capi { struct DataStruct; } -class DataStruct; namespace diplomat::capi { struct FixedDecimal; } class FixedDecimal; namespace diplomat::capi { struct Locale; } @@ -32,7 +30,7 @@ class FixedDecimalFormatter { inline static diplomat::result, DataError> create_with_grouping_strategy(const DataProvider& provider, const Locale& locale, FixedDecimalGroupingStrategy grouping_strategy); - inline static diplomat::result, DataError> create_with_decimal_symbols_v1(const DataStruct& data_struct, FixedDecimalGroupingStrategy grouping_strategy); + inline static diplomat::result, DataError> create_with_manual_data(std::string_view plus_sign_prefix, std::string_view plus_sign_suffix, std::string_view minus_sign_prefix, std::string_view minus_sign_suffix, std::string_view decimal_separator, std::string_view grouping_separator, uint8_t primary_group_size, uint8_t secondary_group_size, uint8_t min_group_size, diplomat::span digits, FixedDecimalGroupingStrategy grouping_strategy); inline std::string format(const FixedDecimal& value) const; diff --git a/ffi/capi/bindings/cpp/FixedDecimalFormatter.hpp b/ffi/capi/bindings/cpp/FixedDecimalFormatter.hpp index a860955d3c7..d446f9c476a 100644 --- a/ffi/capi/bindings/cpp/FixedDecimalFormatter.hpp +++ b/ffi/capi/bindings/cpp/FixedDecimalFormatter.hpp @@ -9,13 +9,12 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" -#include "DataStruct.hpp" #include "FixedDecimal.hpp" #include "FixedDecimalGroupingStrategy.hpp" #include "Locale.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -25,8 +24,8 @@ namespace capi { typedef struct icu4x_FixedDecimalFormatter_create_with_grouping_strategy_mv1_result {union {diplomat::capi::FixedDecimalFormatter* ok; diplomat::capi::DataError err;}; bool is_ok;} icu4x_FixedDecimalFormatter_create_with_grouping_strategy_mv1_result; icu4x_FixedDecimalFormatter_create_with_grouping_strategy_mv1_result icu4x_FixedDecimalFormatter_create_with_grouping_strategy_mv1(const diplomat::capi::DataProvider* provider, const diplomat::capi::Locale* locale, diplomat::capi::FixedDecimalGroupingStrategy grouping_strategy); - typedef struct icu4x_FixedDecimalFormatter_create_with_decimal_symbols_v1_mv1_result {union {diplomat::capi::FixedDecimalFormatter* ok; diplomat::capi::DataError err;}; bool is_ok;} icu4x_FixedDecimalFormatter_create_with_decimal_symbols_v1_mv1_result; - icu4x_FixedDecimalFormatter_create_with_decimal_symbols_v1_mv1_result icu4x_FixedDecimalFormatter_create_with_decimal_symbols_v1_mv1(const diplomat::capi::DataStruct* data_struct, diplomat::capi::FixedDecimalGroupingStrategy grouping_strategy); + typedef struct icu4x_FixedDecimalFormatter_create_with_manual_data_mv1_result {union {diplomat::capi::FixedDecimalFormatter* ok; diplomat::capi::DataError err;}; bool is_ok;} icu4x_FixedDecimalFormatter_create_with_manual_data_mv1_result; + icu4x_FixedDecimalFormatter_create_with_manual_data_mv1_result icu4x_FixedDecimalFormatter_create_with_manual_data_mv1(const char* plus_sign_prefix_data, size_t plus_sign_prefix_len, const char* plus_sign_suffix_data, size_t plus_sign_suffix_len, const char* minus_sign_prefix_data, size_t minus_sign_prefix_len, const char* minus_sign_suffix_data, size_t minus_sign_suffix_len, const char* decimal_separator_data, size_t decimal_separator_len, const char* grouping_separator_data, size_t grouping_separator_len, uint8_t primary_group_size, uint8_t secondary_group_size, uint8_t min_group_size, const char32_t* digits_data, size_t digits_len, diplomat::capi::FixedDecimalGroupingStrategy grouping_strategy); void icu4x_FixedDecimalFormatter_format_mv1(const diplomat::capi::FixedDecimalFormatter* self, const diplomat::capi::FixedDecimal* value, diplomat::capi::DiplomatWrite* write); @@ -44,8 +43,24 @@ inline diplomat::result, DataError> Fixed return result.is_ok ? diplomat::result, DataError>(diplomat::Ok>(std::unique_ptr(FixedDecimalFormatter::FromFFI(result.ok)))) : diplomat::result, DataError>(diplomat::Err(DataError::FromFFI(result.err))); } -inline diplomat::result, DataError> FixedDecimalFormatter::create_with_decimal_symbols_v1(const DataStruct& data_struct, FixedDecimalGroupingStrategy grouping_strategy) { - auto result = diplomat::capi::icu4x_FixedDecimalFormatter_create_with_decimal_symbols_v1_mv1(data_struct.AsFFI(), +inline diplomat::result, DataError> FixedDecimalFormatter::create_with_manual_data(std::string_view plus_sign_prefix, std::string_view plus_sign_suffix, std::string_view minus_sign_prefix, std::string_view minus_sign_suffix, std::string_view decimal_separator, std::string_view grouping_separator, uint8_t primary_group_size, uint8_t secondary_group_size, uint8_t min_group_size, diplomat::span digits, FixedDecimalGroupingStrategy grouping_strategy) { + auto result = diplomat::capi::icu4x_FixedDecimalFormatter_create_with_manual_data_mv1(plus_sign_prefix.data(), + plus_sign_prefix.size(), + plus_sign_suffix.data(), + plus_sign_suffix.size(), + minus_sign_prefix.data(), + minus_sign_prefix.size(), + minus_sign_suffix.data(), + minus_sign_suffix.size(), + decimal_separator.data(), + decimal_separator.size(), + grouping_separator.data(), + grouping_separator.size(), + primary_group_size, + secondary_group_size, + min_group_size, + digits.data(), + digits.size(), grouping_strategy.AsFFI()); return result.is_ok ? diplomat::result, DataError>(diplomat::Ok>(std::unique_ptr(FixedDecimalFormatter::FromFFI(result.ok)))) : diplomat::result, DataError>(diplomat::Err(DataError::FromFFI(result.err))); } diff --git a/ffi/capi/bindings/cpp/FixedDecimalLimitError.d.hpp b/ffi/capi/bindings/cpp/FixedDecimalLimitError.d.hpp index 205803efb38..7dbf757d3b0 100644 --- a/ffi/capi/bindings/cpp/FixedDecimalLimitError.d.hpp +++ b/ffi/capi/bindings/cpp/FixedDecimalLimitError.d.hpp @@ -12,29 +12,13 @@ namespace diplomat { namespace capi { - enum FixedDecimalLimitError { - FixedDecimalLimitError_TodoZst = 0, - }; + } // namespace capi } // namespace -class FixedDecimalLimitError { -public: - enum Value { - TodoZst = 0, - }; - - FixedDecimalLimitError() = default; - // Implicit conversions between enum and ::Value - constexpr FixedDecimalLimitError(Value v) : value(v) {} - constexpr operator Value() const { return value; } - // Prevent usage as boolean value - explicit operator bool() const = delete; - - inline diplomat::capi::FixedDecimalLimitError AsFFI() const; - inline static FixedDecimalLimitError FromFFI(diplomat::capi::FixedDecimalLimitError c_enum); -private: - Value value; + +struct FixedDecimalLimitError { + }; diff --git a/ffi/capi/bindings/cpp/FixedDecimalLimitError.hpp b/ffi/capi/bindings/cpp/FixedDecimalLimitError.hpp index 58ba52e5726..84e02b94f75 100644 --- a/ffi/capi/bindings/cpp/FixedDecimalLimitError.hpp +++ b/ffi/capi/bindings/cpp/FixedDecimalLimitError.hpp @@ -21,16 +21,7 @@ namespace capi { } // namespace capi } // namespace -inline diplomat::capi::FixedDecimalLimitError FixedDecimalLimitError::AsFFI() const { - return static_cast(value); -} - -inline FixedDecimalLimitError FixedDecimalLimitError::FromFFI(diplomat::capi::FixedDecimalLimitError c_enum) { - switch (c_enum) { - case diplomat::capi::FixedDecimalLimitError_TodoZst: - return static_cast(c_enum); - default: - abort(); - } -} + + + #endif // FixedDecimalLimitError_HPP diff --git a/ffi/capi/bindings/cpp/GeneralCategoryNameToMaskMapper.hpp b/ffi/capi/bindings/cpp/GeneralCategoryNameToMaskMapper.hpp index c8c5edbb3b7..9ab2ca361b3 100644 --- a/ffi/capi/bindings/cpp/GeneralCategoryNameToMaskMapper.hpp +++ b/ffi/capi/bindings/cpp/GeneralCategoryNameToMaskMapper.hpp @@ -9,9 +9,9 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/GraphemeClusterSegmenter.d.hpp b/ffi/capi/bindings/cpp/GraphemeClusterSegmenter.d.hpp index 5c40d953704..ee28b315d8c 100644 --- a/ffi/capi/bindings/cpp/GraphemeClusterSegmenter.d.hpp +++ b/ffi/capi/bindings/cpp/GraphemeClusterSegmenter.d.hpp @@ -31,9 +31,9 @@ class GraphemeClusterSegmenter { inline static diplomat::result, DataError> create(const DataProvider& provider); - inline std::unique_ptr segment_utf8(std::string_view input) const; + inline std::unique_ptr segment(std::string_view input) const; - inline std::unique_ptr segment_utf16(std::u16string_view input) const; + inline std::unique_ptr segment16(std::u16string_view input) const; inline std::unique_ptr segment_latin1(diplomat::span input) const; diff --git a/ffi/capi/bindings/cpp/GraphemeClusterSegmenter.hpp b/ffi/capi/bindings/cpp/GraphemeClusterSegmenter.hpp index 5f2204d4886..b611d16e8d5 100644 --- a/ffi/capi/bindings/cpp/GraphemeClusterSegmenter.hpp +++ b/ffi/capi/bindings/cpp/GraphemeClusterSegmenter.hpp @@ -9,12 +9,12 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" #include "GraphemeClusterBreakIteratorLatin1.hpp" #include "GraphemeClusterBreakIteratorUtf16.hpp" #include "GraphemeClusterBreakIteratorUtf8.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -42,14 +42,14 @@ inline diplomat::result, DataError> Gr return result.is_ok ? diplomat::result, DataError>(diplomat::Ok>(std::unique_ptr(GraphemeClusterSegmenter::FromFFI(result.ok)))) : diplomat::result, DataError>(diplomat::Err(DataError::FromFFI(result.err))); } -inline std::unique_ptr GraphemeClusterSegmenter::segment_utf8(std::string_view input) const { +inline std::unique_ptr GraphemeClusterSegmenter::segment(std::string_view input) const { auto result = diplomat::capi::icu4x_GraphemeClusterSegmenter_segment_utf8_mv1(this->AsFFI(), input.data(), input.size()); return std::unique_ptr(GraphemeClusterBreakIteratorUtf8::FromFFI(result)); } -inline std::unique_ptr GraphemeClusterSegmenter::segment_utf16(std::u16string_view input) const { +inline std::unique_ptr GraphemeClusterSegmenter::segment16(std::u16string_view input) const { auto result = diplomat::capi::icu4x_GraphemeClusterSegmenter_segment_utf16_mv1(this->AsFFI(), input.data(), input.size()); diff --git a/ffi/capi/bindings/cpp/GregorianDateFormatter.hpp b/ffi/capi/bindings/cpp/GregorianDateFormatter.hpp index 2fee9629e23..0182d605b52 100644 --- a/ffi/capi/bindings/cpp/GregorianDateFormatter.hpp +++ b/ffi/capi/bindings/cpp/GregorianDateFormatter.hpp @@ -9,13 +9,13 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataProvider.hpp" #include "DateLength.hpp" #include "Error.hpp" #include "IsoDate.hpp" #include "IsoDateTime.hpp" #include "Locale.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/GregorianDateTimeFormatter.hpp b/ffi/capi/bindings/cpp/GregorianDateTimeFormatter.hpp index 8d510bcf183..9b35e594465 100644 --- a/ffi/capi/bindings/cpp/GregorianDateTimeFormatter.hpp +++ b/ffi/capi/bindings/cpp/GregorianDateTimeFormatter.hpp @@ -9,13 +9,13 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataProvider.hpp" #include "DateLength.hpp" #include "Error.hpp" #include "IsoDateTime.hpp" #include "Locale.hpp" #include "TimeLength.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/GregorianZonedDateTimeFormatter.hpp b/ffi/capi/bindings/cpp/GregorianZonedDateTimeFormatter.hpp index 72d33cd8292..88f883c74f2 100644 --- a/ffi/capi/bindings/cpp/GregorianZonedDateTimeFormatter.hpp +++ b/ffi/capi/bindings/cpp/GregorianZonedDateTimeFormatter.hpp @@ -9,7 +9,6 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "CustomTimeZone.hpp" #include "DataProvider.hpp" #include "DateLength.hpp" @@ -18,6 +17,7 @@ #include "IsoTimeZoneOptions.hpp" #include "Locale.hpp" #include "TimeLength.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/IsoDate.d.hpp b/ffi/capi/bindings/cpp/IsoDate.d.hpp index aa5af5ed107..ef1c18f1269 100644 --- a/ffi/capi/bindings/cpp/IsoDate.d.hpp +++ b/ffi/capi/bindings/cpp/IsoDate.d.hpp @@ -17,6 +17,7 @@ namespace diplomat::capi { struct WeekCalculator; } class WeekCalculator; struct WeekOf; class CalendarError; +class CalendarParseError; class IsoWeekday; @@ -31,7 +32,9 @@ class IsoDate { inline static diplomat::result, CalendarError> create(int32_t year, uint8_t month, uint8_t day); - inline static std::unique_ptr create_for_unix_epoch(); + inline static diplomat::result, CalendarParseError> from_string(std::string_view v); + + inline static std::unique_ptr unix_epoch(); inline std::unique_ptr to_calendar(const Calendar& calendar) const; diff --git a/ffi/capi/bindings/cpp/IsoDate.hpp b/ffi/capi/bindings/cpp/IsoDate.hpp index 00c1d98f850..8c0201bb4cf 100644 --- a/ffi/capi/bindings/cpp/IsoDate.hpp +++ b/ffi/capi/bindings/cpp/IsoDate.hpp @@ -9,13 +9,14 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "Calendar.hpp" #include "CalendarError.hpp" +#include "CalendarParseError.hpp" #include "Date.hpp" #include "IsoWeekday.hpp" #include "WeekCalculator.hpp" #include "WeekOf.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -25,7 +26,10 @@ namespace capi { typedef struct icu4x_IsoDate_create_mv1_result {union {diplomat::capi::IsoDate* ok; diplomat::capi::CalendarError err;}; bool is_ok;} icu4x_IsoDate_create_mv1_result; icu4x_IsoDate_create_mv1_result icu4x_IsoDate_create_mv1(int32_t year, uint8_t month, uint8_t day); - diplomat::capi::IsoDate* icu4x_IsoDate_create_for_unix_epoch_mv1(); + typedef struct icu4x_IsoDate_from_string_mv1_result {union {diplomat::capi::IsoDate* ok; diplomat::capi::CalendarParseError err;}; bool is_ok;} icu4x_IsoDate_from_string_mv1_result; + icu4x_IsoDate_from_string_mv1_result icu4x_IsoDate_from_string_mv1(const char* v_data, size_t v_len); + + diplomat::capi::IsoDate* icu4x_IsoDate_unix_epoch_mv1(void); diplomat::capi::Date* icu4x_IsoDate_to_calendar_mv1(const diplomat::capi::IsoDate* self, const diplomat::capi::Calendar* calendar); @@ -67,8 +71,14 @@ inline diplomat::result, CalendarError> IsoDate::create return result.is_ok ? diplomat::result, CalendarError>(diplomat::Ok>(std::unique_ptr(IsoDate::FromFFI(result.ok)))) : diplomat::result, CalendarError>(diplomat::Err(CalendarError::FromFFI(result.err))); } -inline std::unique_ptr IsoDate::create_for_unix_epoch() { - auto result = diplomat::capi::icu4x_IsoDate_create_for_unix_epoch_mv1(); +inline diplomat::result, CalendarParseError> IsoDate::from_string(std::string_view v) { + auto result = diplomat::capi::icu4x_IsoDate_from_string_mv1(v.data(), + v.size()); + return result.is_ok ? diplomat::result, CalendarParseError>(diplomat::Ok>(std::unique_ptr(IsoDate::FromFFI(result.ok)))) : diplomat::result, CalendarParseError>(diplomat::Err(CalendarParseError::FromFFI(result.err))); +} + +inline std::unique_ptr IsoDate::unix_epoch() { + auto result = diplomat::capi::icu4x_IsoDate_unix_epoch_mv1(); return std::unique_ptr(IsoDate::FromFFI(result)); } diff --git a/ffi/capi/bindings/cpp/IsoDateTime.d.hpp b/ffi/capi/bindings/cpp/IsoDateTime.d.hpp index 897e01c18a8..2247a1f156d 100644 --- a/ffi/capi/bindings/cpp/IsoDateTime.d.hpp +++ b/ffi/capi/bindings/cpp/IsoDateTime.d.hpp @@ -21,6 +21,7 @@ namespace diplomat::capi { struct WeekCalculator; } class WeekCalculator; struct WeekOf; class CalendarError; +class CalendarParseError; class IsoWeekday; @@ -35,11 +36,13 @@ class IsoDateTime { inline static diplomat::result, CalendarError> create(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond); - inline static std::unique_ptr crate_from_date_and_time(const IsoDate& date, const Time& time); + inline static std::unique_ptr from_date_and_time(const IsoDate& date, const Time& time); + + inline static diplomat::result, CalendarParseError> from_string(std::string_view v); inline static std::unique_ptr local_unix_epoch(); - inline static std::unique_ptr create_from_minutes_since_local_unix_epoch(int32_t minutes); + inline static std::unique_ptr from_minutes_since_local_unix_epoch(int32_t minutes); inline std::unique_ptr date() const; diff --git a/ffi/capi/bindings/cpp/IsoDateTime.hpp b/ffi/capi/bindings/cpp/IsoDateTime.hpp index 422c05c9691..acecb7229bc 100644 --- a/ffi/capi/bindings/cpp/IsoDateTime.hpp +++ b/ffi/capi/bindings/cpp/IsoDateTime.hpp @@ -9,15 +9,16 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "Calendar.hpp" #include "CalendarError.hpp" +#include "CalendarParseError.hpp" #include "DateTime.hpp" #include "IsoDate.hpp" #include "IsoWeekday.hpp" #include "Time.hpp" #include "WeekCalculator.hpp" #include "WeekOf.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -27,11 +28,14 @@ namespace capi { typedef struct icu4x_IsoDateTime_create_mv1_result {union {diplomat::capi::IsoDateTime* ok; diplomat::capi::CalendarError err;}; bool is_ok;} icu4x_IsoDateTime_create_mv1_result; icu4x_IsoDateTime_create_mv1_result icu4x_IsoDateTime_create_mv1(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond); - diplomat::capi::IsoDateTime* icu4x_IsoDateTime_crate_from_date_and_time_mv1(const diplomat::capi::IsoDate* date, const diplomat::capi::Time* time); + diplomat::capi::IsoDateTime* icu4x_IsoDateTime_from_date_and_time_mv1(const diplomat::capi::IsoDate* date, const diplomat::capi::Time* time); + + typedef struct icu4x_IsoDateTime_from_string_mv1_result {union {diplomat::capi::IsoDateTime* ok; diplomat::capi::CalendarParseError err;}; bool is_ok;} icu4x_IsoDateTime_from_string_mv1_result; + icu4x_IsoDateTime_from_string_mv1_result icu4x_IsoDateTime_from_string_mv1(const char* v_data, size_t v_len); - diplomat::capi::IsoDateTime* icu4x_IsoDateTime_local_unix_epoch_mv1(); + diplomat::capi::IsoDateTime* icu4x_IsoDateTime_local_unix_epoch_mv1(void); - diplomat::capi::IsoDateTime* icu4x_IsoDateTime_create_from_minutes_since_local_unix_epoch_mv1(int32_t minutes); + diplomat::capi::IsoDateTime* icu4x_IsoDateTime_from_minutes_since_local_unix_epoch_mv1(int32_t minutes); diplomat::capi::IsoDate* icu4x_IsoDateTime_date_mv1(const diplomat::capi::IsoDateTime* self); @@ -91,19 +95,25 @@ inline diplomat::result, CalendarError> IsoDateTime return result.is_ok ? diplomat::result, CalendarError>(diplomat::Ok>(std::unique_ptr(IsoDateTime::FromFFI(result.ok)))) : diplomat::result, CalendarError>(diplomat::Err(CalendarError::FromFFI(result.err))); } -inline std::unique_ptr IsoDateTime::crate_from_date_and_time(const IsoDate& date, const Time& time) { - auto result = diplomat::capi::icu4x_IsoDateTime_crate_from_date_and_time_mv1(date.AsFFI(), +inline std::unique_ptr IsoDateTime::from_date_and_time(const IsoDate& date, const Time& time) { + auto result = diplomat::capi::icu4x_IsoDateTime_from_date_and_time_mv1(date.AsFFI(), time.AsFFI()); return std::unique_ptr(IsoDateTime::FromFFI(result)); } +inline diplomat::result, CalendarParseError> IsoDateTime::from_string(std::string_view v) { + auto result = diplomat::capi::icu4x_IsoDateTime_from_string_mv1(v.data(), + v.size()); + return result.is_ok ? diplomat::result, CalendarParseError>(diplomat::Ok>(std::unique_ptr(IsoDateTime::FromFFI(result.ok)))) : diplomat::result, CalendarParseError>(diplomat::Err(CalendarParseError::FromFFI(result.err))); +} + inline std::unique_ptr IsoDateTime::local_unix_epoch() { auto result = diplomat::capi::icu4x_IsoDateTime_local_unix_epoch_mv1(); return std::unique_ptr(IsoDateTime::FromFFI(result)); } -inline std::unique_ptr IsoDateTime::create_from_minutes_since_local_unix_epoch(int32_t minutes) { - auto result = diplomat::capi::icu4x_IsoDateTime_create_from_minutes_since_local_unix_epoch_mv1(minutes); +inline std::unique_ptr IsoDateTime::from_minutes_since_local_unix_epoch(int32_t minutes) { + auto result = diplomat::capi::icu4x_IsoDateTime_from_minutes_since_local_unix_epoch_mv1(minutes); return std::unique_ptr(IsoDateTime::FromFFI(result)); } diff --git a/ffi/capi/bindings/cpp/IsoTimeZoneOptions.d.hpp b/ffi/capi/bindings/cpp/IsoTimeZoneOptions.d.hpp index b3f794a1d51..6a1f7313237 100644 --- a/ffi/capi/bindings/cpp/IsoTimeZoneOptions.d.hpp +++ b/ffi/capi/bindings/cpp/IsoTimeZoneOptions.d.hpp @@ -7,10 +7,10 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "IsoTimeZoneFormat.d.hpp" #include "IsoTimeZoneMinuteDisplay.d.hpp" #include "IsoTimeZoneSecondDisplay.d.hpp" +#include "diplomat_runtime.hpp" class IsoTimeZoneFormat; class IsoTimeZoneMinuteDisplay; diff --git a/ffi/capi/bindings/cpp/IsoTimeZoneOptions.hpp b/ffi/capi/bindings/cpp/IsoTimeZoneOptions.hpp index 5256fc531f3..f2a804cafa6 100644 --- a/ffi/capi/bindings/cpp/IsoTimeZoneOptions.hpp +++ b/ffi/capi/bindings/cpp/IsoTimeZoneOptions.hpp @@ -9,10 +9,10 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "IsoTimeZoneFormat.hpp" #include "IsoTimeZoneMinuteDisplay.hpp" #include "IsoTimeZoneSecondDisplay.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -27,17 +27,17 @@ namespace capi { inline diplomat::capi::IsoTimeZoneOptions IsoTimeZoneOptions::AsFFI() const { return diplomat::capi::IsoTimeZoneOptions { - .format = format.AsFFI(), - .minutes = minutes.AsFFI(), - .seconds = seconds.AsFFI(), + /* .format = */ format.AsFFI(), + /* .minutes = */ minutes.AsFFI(), + /* .seconds = */ seconds.AsFFI(), }; } inline IsoTimeZoneOptions IsoTimeZoneOptions::FromFFI(diplomat::capi::IsoTimeZoneOptions c_struct) { return IsoTimeZoneOptions { - .format = IsoTimeZoneFormat::FromFFI(c_struct.format), - .minutes = IsoTimeZoneMinuteDisplay::FromFFI(c_struct.minutes), - .seconds = IsoTimeZoneSecondDisplay::FromFFI(c_struct.seconds), + /* .format = */ IsoTimeZoneFormat::FromFFI(c_struct.format), + /* .minutes = */ IsoTimeZoneMinuteDisplay::FromFFI(c_struct.minutes), + /* .seconds = */ IsoTimeZoneSecondDisplay::FromFFI(c_struct.seconds), }; } diff --git a/ffi/capi/bindings/cpp/LineBreakOptionsV1.d.hpp b/ffi/capi/bindings/cpp/LineBreakOptionsV1.d.hpp index 6dced167ec0..c223ec62a94 100644 --- a/ffi/capi/bindings/cpp/LineBreakOptionsV1.d.hpp +++ b/ffi/capi/bindings/cpp/LineBreakOptionsV1.d.hpp @@ -7,9 +7,9 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "LineBreakStrictness.d.hpp" #include "LineBreakWordOption.d.hpp" +#include "diplomat_runtime.hpp" class LineBreakStrictness; class LineBreakWordOption; diff --git a/ffi/capi/bindings/cpp/LineBreakOptionsV1.hpp b/ffi/capi/bindings/cpp/LineBreakOptionsV1.hpp index b769091f58a..e7fa6c4370c 100644 --- a/ffi/capi/bindings/cpp/LineBreakOptionsV1.hpp +++ b/ffi/capi/bindings/cpp/LineBreakOptionsV1.hpp @@ -9,9 +9,9 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "LineBreakStrictness.hpp" #include "LineBreakWordOption.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -26,17 +26,17 @@ namespace capi { inline diplomat::capi::LineBreakOptionsV1 LineBreakOptionsV1::AsFFI() const { return diplomat::capi::LineBreakOptionsV1 { - .strictness = strictness.AsFFI(), - .word_option = word_option.AsFFI(), - .ja_zh = ja_zh, + /* .strictness = */ strictness.AsFFI(), + /* .word_option = */ word_option.AsFFI(), + /* .ja_zh = */ ja_zh, }; } inline LineBreakOptionsV1 LineBreakOptionsV1::FromFFI(diplomat::capi::LineBreakOptionsV1 c_struct) { return LineBreakOptionsV1 { - .strictness = LineBreakStrictness::FromFFI(c_struct.strictness), - .word_option = LineBreakWordOption::FromFFI(c_struct.word_option), - .ja_zh = c_struct.ja_zh, + /* .strictness = */ LineBreakStrictness::FromFFI(c_struct.strictness), + /* .word_option = */ LineBreakWordOption::FromFFI(c_struct.word_option), + /* .ja_zh = */ c_struct.ja_zh, }; } diff --git a/ffi/capi/bindings/cpp/LineSegmenter.d.hpp b/ffi/capi/bindings/cpp/LineSegmenter.d.hpp index b570ac320e1..c11d5fd1437 100644 --- a/ffi/capi/bindings/cpp/LineSegmenter.d.hpp +++ b/ffi/capi/bindings/cpp/LineSegmenter.d.hpp @@ -42,9 +42,9 @@ class LineSegmenter { inline static diplomat::result, DataError> create_dictionary_with_options_v1(const DataProvider& provider, LineBreakOptionsV1 options); - inline std::unique_ptr segment_utf8(std::string_view input) const; + inline std::unique_ptr segment(std::string_view input) const; - inline std::unique_ptr segment_utf16(std::u16string_view input) const; + inline std::unique_ptr segment16(std::u16string_view input) const; inline std::unique_ptr segment_latin1(diplomat::span input) const; diff --git a/ffi/capi/bindings/cpp/LineSegmenter.hpp b/ffi/capi/bindings/cpp/LineSegmenter.hpp index 6333afd212b..024688a8db5 100644 --- a/ffi/capi/bindings/cpp/LineSegmenter.hpp +++ b/ffi/capi/bindings/cpp/LineSegmenter.hpp @@ -9,13 +9,13 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" #include "LineBreakIteratorLatin1.hpp" #include "LineBreakIteratorUtf16.hpp" #include "LineBreakIteratorUtf8.hpp" #include "LineBreakOptionsV1.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -86,14 +86,14 @@ inline diplomat::result, DataError> LineSegmenter return result.is_ok ? diplomat::result, DataError>(diplomat::Ok>(std::unique_ptr(LineSegmenter::FromFFI(result.ok)))) : diplomat::result, DataError>(diplomat::Err(DataError::FromFFI(result.err))); } -inline std::unique_ptr LineSegmenter::segment_utf8(std::string_view input) const { +inline std::unique_ptr LineSegmenter::segment(std::string_view input) const { auto result = diplomat::capi::icu4x_LineSegmenter_segment_utf8_mv1(this->AsFFI(), input.data(), input.size()); return std::unique_ptr(LineBreakIteratorUtf8::FromFFI(result)); } -inline std::unique_ptr LineSegmenter::segment_utf16(std::u16string_view input) const { +inline std::unique_ptr LineSegmenter::segment16(std::u16string_view input) const { auto result = diplomat::capi::icu4x_LineSegmenter_segment_utf16_mv1(this->AsFFI(), input.data(), input.size()); diff --git a/ffi/capi/bindings/cpp/ListFormatter.d.hpp b/ffi/capi/bindings/cpp/ListFormatter.d.hpp index ba75271dc68..97831ba1fb5 100644 --- a/ffi/capi/bindings/cpp/ListFormatter.d.hpp +++ b/ffi/capi/bindings/cpp/ListFormatter.d.hpp @@ -32,11 +32,9 @@ class ListFormatter { inline static diplomat::result, DataError> create_unit_with_length(const DataProvider& provider, const Locale& locale, ListLength length); - inline std::string format_valid_utf8(diplomat::span list) const; + inline std::string format(diplomat::span list) const; - inline std::string format_utf8(diplomat::span list) const; - - inline std::string format_utf16(diplomat::span list) const; + inline std::string format16(diplomat::span list) const; inline const diplomat::capi::ListFormatter* AsFFI() const; inline diplomat::capi::ListFormatter* AsFFI(); diff --git a/ffi/capi/bindings/cpp/ListFormatter.hpp b/ffi/capi/bindings/cpp/ListFormatter.hpp index f0f461d9d4c..e8d3125e393 100644 --- a/ffi/capi/bindings/cpp/ListFormatter.hpp +++ b/ffi/capi/bindings/cpp/ListFormatter.hpp @@ -9,11 +9,11 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" #include "ListLength.hpp" #include "Locale.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -29,11 +29,9 @@ namespace capi { typedef struct icu4x_ListFormatter_create_unit_with_length_mv1_result {union {diplomat::capi::ListFormatter* ok; diplomat::capi::DataError err;}; bool is_ok;} icu4x_ListFormatter_create_unit_with_length_mv1_result; icu4x_ListFormatter_create_unit_with_length_mv1_result icu4x_ListFormatter_create_unit_with_length_mv1(const diplomat::capi::DataProvider* provider, const diplomat::capi::Locale* locale, diplomat::capi::ListLength length); - void icu4x_ListFormatter_format_valid_utf8_mv1(const diplomat::capi::ListFormatter* self, DiplomatStringsView* list_data, size_t list_len, diplomat::capi::DiplomatWrite* write); - - void icu4x_ListFormatter_format_utf8_mv1(const diplomat::capi::ListFormatter* self, DiplomatStringsView* list_data, size_t list_len, diplomat::capi::DiplomatWrite* write); + void icu4x_ListFormatter_format_utf8_mv1(const diplomat::capi::ListFormatter* self, diplomat::capi::DiplomatStringsView* list_data, size_t list_len, diplomat::capi::DiplomatWrite* write); - void icu4x_ListFormatter_format_utf16_mv1(const diplomat::capi::ListFormatter* self, DiplomatStrings16View* list_data, size_t list_len, diplomat::capi::DiplomatWrite* write); + void icu4x_ListFormatter_format_utf16_mv1(const diplomat::capi::ListFormatter* self, diplomat::capi::DiplomatStrings16View* list_data, size_t list_len, diplomat::capi::DiplomatWrite* write); void icu4x_ListFormatter_destroy_mv1(ListFormatter* self); @@ -63,17 +61,7 @@ inline diplomat::result, DataError> ListFormatter return result.is_ok ? diplomat::result, DataError>(diplomat::Ok>(std::unique_ptr(ListFormatter::FromFFI(result.ok)))) : diplomat::result, DataError>(diplomat::Err(DataError::FromFFI(result.err))); } -inline std::string ListFormatter::format_valid_utf8(diplomat::span list) const { - std::string output; - diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output); - diplomat::capi::icu4x_ListFormatter_format_valid_utf8_mv1(this->AsFFI(), - list.data(), - list.size(), - &write); - return output; -} - -inline std::string ListFormatter::format_utf8(diplomat::span list) const { +inline std::string ListFormatter::format(diplomat::span list) const { std::string output; diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output); diplomat::capi::icu4x_ListFormatter_format_utf8_mv1(this->AsFFI(), @@ -83,7 +71,7 @@ inline std::string ListFormatter::format_utf8(diplomat::span list) const { +inline std::string ListFormatter::format16(diplomat::span list) const { std::string output; diplomat::capi::DiplomatWrite write = diplomat::WriteFromString(output); diplomat::capi::icu4x_ListFormatter_format_utf16_mv1(this->AsFFI(), diff --git a/ffi/capi/bindings/cpp/Locale.d.hpp b/ffi/capi/bindings/cpp/Locale.d.hpp index 103c9e5f81e..d672ddae4c8 100644 --- a/ffi/capi/bindings/cpp/Locale.d.hpp +++ b/ffi/capi/bindings/cpp/Locale.d.hpp @@ -21,9 +21,9 @@ namespace capi { class Locale { public: - inline static diplomat::result, LocaleParseError> create_from_string(std::string_view name); + inline static diplomat::result, LocaleParseError> from_string(std::string_view name); - inline static std::unique_ptr create_und(); + inline static std::unique_ptr und(); inline std::unique_ptr clone() const; diff --git a/ffi/capi/bindings/cpp/Locale.hpp b/ffi/capi/bindings/cpp/Locale.hpp index 6475bc35775..1fdc4fee867 100644 --- a/ffi/capi/bindings/cpp/Locale.hpp +++ b/ffi/capi/bindings/cpp/Locale.hpp @@ -9,18 +9,18 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "LocaleParseError.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { namespace capi { extern "C" { - typedef struct icu4x_Locale_create_from_string_mv1_result {union {diplomat::capi::Locale* ok; diplomat::capi::LocaleParseError err;}; bool is_ok;} icu4x_Locale_create_from_string_mv1_result; - icu4x_Locale_create_from_string_mv1_result icu4x_Locale_create_from_string_mv1(const char* name_data, size_t name_len); + typedef struct icu4x_Locale_from_string_mv1_result {union {diplomat::capi::Locale* ok; diplomat::capi::LocaleParseError err;}; bool is_ok;} icu4x_Locale_from_string_mv1_result; + icu4x_Locale_from_string_mv1_result icu4x_Locale_from_string_mv1(const char* name_data, size_t name_len); - diplomat::capi::Locale* icu4x_Locale_create_und_mv1(); + diplomat::capi::Locale* icu4x_Locale_und_mv1(void); diplomat::capi::Locale* icu4x_Locale_clone_mv1(const diplomat::capi::Locale* self); @@ -64,14 +64,14 @@ namespace capi { } // namespace capi } // namespace -inline diplomat::result, LocaleParseError> Locale::create_from_string(std::string_view name) { - auto result = diplomat::capi::icu4x_Locale_create_from_string_mv1(name.data(), +inline diplomat::result, LocaleParseError> Locale::from_string(std::string_view name) { + auto result = diplomat::capi::icu4x_Locale_from_string_mv1(name.data(), name.size()); return result.is_ok ? diplomat::result, LocaleParseError>(diplomat::Ok>(std::unique_ptr(Locale::FromFFI(result.ok)))) : diplomat::result, LocaleParseError>(diplomat::Err(LocaleParseError::FromFFI(result.err))); } -inline std::unique_ptr Locale::create_und() { - auto result = diplomat::capi::icu4x_Locale_create_und_mv1(); +inline std::unique_ptr Locale::und() { + auto result = diplomat::capi::icu4x_Locale_und_mv1(); return std::unique_ptr(Locale::FromFFI(result)); } diff --git a/ffi/capi/bindings/cpp/LocaleCanonicalizer.hpp b/ffi/capi/bindings/cpp/LocaleCanonicalizer.hpp index 78d082df489..4acc5243f46 100644 --- a/ffi/capi/bindings/cpp/LocaleCanonicalizer.hpp +++ b/ffi/capi/bindings/cpp/LocaleCanonicalizer.hpp @@ -9,11 +9,11 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataProvider.hpp" #include "Error.hpp" #include "Locale.hpp" #include "TransformResult.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/LocaleDirectionality.hpp b/ffi/capi/bindings/cpp/LocaleDirectionality.hpp index ce44373e0fa..d14797c76a5 100644 --- a/ffi/capi/bindings/cpp/LocaleDirectionality.hpp +++ b/ffi/capi/bindings/cpp/LocaleDirectionality.hpp @@ -9,12 +9,12 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" #include "Locale.hpp" #include "LocaleDirection.hpp" #include "LocaleExpander.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/LocaleDisplayNamesFormatter.d.hpp b/ffi/capi/bindings/cpp/LocaleDisplayNamesFormatter.d.hpp index f469b27fec2..8ebafd683e0 100644 --- a/ffi/capi/bindings/cpp/LocaleDisplayNamesFormatter.d.hpp +++ b/ffi/capi/bindings/cpp/LocaleDisplayNamesFormatter.d.hpp @@ -26,7 +26,7 @@ namespace capi { class LocaleDisplayNamesFormatter { public: - inline static diplomat::result, DataError> create(const DataProvider& provider, const Locale& locale, DisplayNamesOptionsV1 options); + inline static diplomat::result, DataError> create_v1(const DataProvider& provider, const Locale& locale, DisplayNamesOptionsV1 options); inline std::string of(const Locale& locale) const; diff --git a/ffi/capi/bindings/cpp/LocaleDisplayNamesFormatter.hpp b/ffi/capi/bindings/cpp/LocaleDisplayNamesFormatter.hpp index e1bb4fd9e27..eb04a48af01 100644 --- a/ffi/capi/bindings/cpp/LocaleDisplayNamesFormatter.hpp +++ b/ffi/capi/bindings/cpp/LocaleDisplayNamesFormatter.hpp @@ -9,19 +9,19 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" #include "DisplayNamesOptionsV1.hpp" #include "Locale.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { namespace capi { extern "C" { - typedef struct icu4x_LocaleDisplayNamesFormatter_create_mv1_result {union {diplomat::capi::LocaleDisplayNamesFormatter* ok; diplomat::capi::DataError err;}; bool is_ok;} icu4x_LocaleDisplayNamesFormatter_create_mv1_result; - icu4x_LocaleDisplayNamesFormatter_create_mv1_result icu4x_LocaleDisplayNamesFormatter_create_mv1(const diplomat::capi::DataProvider* provider, const diplomat::capi::Locale* locale, diplomat::capi::DisplayNamesOptionsV1 options); + typedef struct icu4x_LocaleDisplayNamesFormatter_create_v1_mv1_result {union {diplomat::capi::LocaleDisplayNamesFormatter* ok; diplomat::capi::DataError err;}; bool is_ok;} icu4x_LocaleDisplayNamesFormatter_create_v1_mv1_result; + icu4x_LocaleDisplayNamesFormatter_create_v1_mv1_result icu4x_LocaleDisplayNamesFormatter_create_v1_mv1(const diplomat::capi::DataProvider* provider, const diplomat::capi::Locale* locale, diplomat::capi::DisplayNamesOptionsV1 options); void icu4x_LocaleDisplayNamesFormatter_of_mv1(const diplomat::capi::LocaleDisplayNamesFormatter* self, const diplomat::capi::Locale* locale, diplomat::capi::DiplomatWrite* write); @@ -32,8 +32,8 @@ namespace capi { } // namespace capi } // namespace -inline diplomat::result, DataError> LocaleDisplayNamesFormatter::create(const DataProvider& provider, const Locale& locale, DisplayNamesOptionsV1 options) { - auto result = diplomat::capi::icu4x_LocaleDisplayNamesFormatter_create_mv1(provider.AsFFI(), +inline diplomat::result, DataError> LocaleDisplayNamesFormatter::create_v1(const DataProvider& provider, const Locale& locale, DisplayNamesOptionsV1 options) { + auto result = diplomat::capi::icu4x_LocaleDisplayNamesFormatter_create_v1_mv1(provider.AsFFI(), locale.AsFFI(), options.AsFFI()); return result.is_ok ? diplomat::result, DataError>(diplomat::Ok>(std::unique_ptr(LocaleDisplayNamesFormatter::FromFFI(result.ok)))) : diplomat::result, DataError>(diplomat::Err(DataError::FromFFI(result.err))); diff --git a/ffi/capi/bindings/cpp/LocaleExpander.hpp b/ffi/capi/bindings/cpp/LocaleExpander.hpp index b2b7cde5167..5ccb7168509 100644 --- a/ffi/capi/bindings/cpp/LocaleExpander.hpp +++ b/ffi/capi/bindings/cpp/LocaleExpander.hpp @@ -9,11 +9,11 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataProvider.hpp" #include "Error.hpp" #include "Locale.hpp" #include "TransformResult.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/LocaleFallbackConfig.d.hpp b/ffi/capi/bindings/cpp/LocaleFallbackConfig.d.hpp index 33e9124ad2c..4d3ceb7968f 100644 --- a/ffi/capi/bindings/cpp/LocaleFallbackConfig.d.hpp +++ b/ffi/capi/bindings/cpp/LocaleFallbackConfig.d.hpp @@ -7,9 +7,9 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "LocaleFallbackPriority.d.hpp" #include "LocaleFallbackSupplement.d.hpp" +#include "diplomat_runtime.hpp" class LocaleFallbackPriority; class LocaleFallbackSupplement; @@ -19,7 +19,7 @@ namespace diplomat { namespace capi { struct LocaleFallbackConfig { diplomat::capi::LocaleFallbackPriority priority; - DiplomatStringView extension_key; + diplomat::capi::DiplomatStringView extension_key; diplomat::capi::LocaleFallbackSupplement fallback_supplement; }; } // namespace capi diff --git a/ffi/capi/bindings/cpp/LocaleFallbackConfig.hpp b/ffi/capi/bindings/cpp/LocaleFallbackConfig.hpp index 849a7371ec4..151f58cdcf9 100644 --- a/ffi/capi/bindings/cpp/LocaleFallbackConfig.hpp +++ b/ffi/capi/bindings/cpp/LocaleFallbackConfig.hpp @@ -9,9 +9,9 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "LocaleFallbackPriority.hpp" #include "LocaleFallbackSupplement.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -26,17 +26,17 @@ namespace capi { inline diplomat::capi::LocaleFallbackConfig LocaleFallbackConfig::AsFFI() const { return diplomat::capi::LocaleFallbackConfig { - .priority = priority.AsFFI(), - .extension_key = { .data = extension_key.data(), .len = extension_key.size() }, - .fallback_supplement = fallback_supplement.AsFFI(), + /* .priority = */ priority.AsFFI(), + /* .extension_key = */ {extension_key.data(), extension_key.size()}, + /* .fallback_supplement = */ fallback_supplement.AsFFI(), }; } inline LocaleFallbackConfig LocaleFallbackConfig::FromFFI(diplomat::capi::LocaleFallbackConfig c_struct) { return LocaleFallbackConfig { - .priority = LocaleFallbackPriority::FromFFI(c_struct.priority), - .extension_key = std::string_view(c_struct.extension_key.data, c_struct.extension_key.len), - .fallback_supplement = LocaleFallbackSupplement::FromFFI(c_struct.fallback_supplement), + /* .priority = */ LocaleFallbackPriority::FromFFI(c_struct.priority), + /* .extension_key = */ std::string_view(c_struct.extension_key.data, c_struct.extension_key.len), + /* .fallback_supplement = */ LocaleFallbackSupplement::FromFFI(c_struct.fallback_supplement), }; } diff --git a/ffi/capi/bindings/cpp/LocaleFallbackIterator.hpp b/ffi/capi/bindings/cpp/LocaleFallbackIterator.hpp index 833a805becb..70aae6261fb 100644 --- a/ffi/capi/bindings/cpp/LocaleFallbackIterator.hpp +++ b/ffi/capi/bindings/cpp/LocaleFallbackIterator.hpp @@ -9,8 +9,8 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "Locale.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/LocaleFallbacker.d.hpp b/ffi/capi/bindings/cpp/LocaleFallbacker.d.hpp index 0922020fa22..7457c7ab6b8 100644 --- a/ffi/capi/bindings/cpp/LocaleFallbacker.d.hpp +++ b/ffi/capi/bindings/cpp/LocaleFallbacker.d.hpp @@ -29,7 +29,7 @@ class LocaleFallbacker { inline static diplomat::result, DataError> create(const DataProvider& provider); - inline static std::unique_ptr create_without_data(); + inline static std::unique_ptr without_data(); inline diplomat::result, LocaleParseError> for_config(LocaleFallbackConfig config) const; diff --git a/ffi/capi/bindings/cpp/LocaleFallbacker.hpp b/ffi/capi/bindings/cpp/LocaleFallbacker.hpp index bb16b9b9ad3..cd5655e575d 100644 --- a/ffi/capi/bindings/cpp/LocaleFallbacker.hpp +++ b/ffi/capi/bindings/cpp/LocaleFallbacker.hpp @@ -9,12 +9,12 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" #include "LocaleFallbackConfig.hpp" #include "LocaleFallbackerWithConfig.hpp" #include "LocaleParseError.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -24,7 +24,7 @@ namespace capi { typedef struct icu4x_LocaleFallbacker_create_mv1_result {union {diplomat::capi::LocaleFallbacker* ok; diplomat::capi::DataError err;}; bool is_ok;} icu4x_LocaleFallbacker_create_mv1_result; icu4x_LocaleFallbacker_create_mv1_result icu4x_LocaleFallbacker_create_mv1(const diplomat::capi::DataProvider* provider); - diplomat::capi::LocaleFallbacker* icu4x_LocaleFallbacker_create_without_data_mv1(); + diplomat::capi::LocaleFallbacker* icu4x_LocaleFallbacker_without_data_mv1(void); typedef struct icu4x_LocaleFallbacker_for_config_mv1_result {union {diplomat::capi::LocaleFallbackerWithConfig* ok; diplomat::capi::LocaleParseError err;}; bool is_ok;} icu4x_LocaleFallbacker_for_config_mv1_result; icu4x_LocaleFallbacker_for_config_mv1_result icu4x_LocaleFallbacker_for_config_mv1(const diplomat::capi::LocaleFallbacker* self, diplomat::capi::LocaleFallbackConfig config); @@ -41,8 +41,8 @@ inline diplomat::result, DataError> LocaleFall return result.is_ok ? diplomat::result, DataError>(diplomat::Ok>(std::unique_ptr(LocaleFallbacker::FromFFI(result.ok)))) : diplomat::result, DataError>(diplomat::Err(DataError::FromFFI(result.err))); } -inline std::unique_ptr LocaleFallbacker::create_without_data() { - auto result = diplomat::capi::icu4x_LocaleFallbacker_create_without_data_mv1(); +inline std::unique_ptr LocaleFallbacker::without_data() { + auto result = diplomat::capi::icu4x_LocaleFallbacker_without_data_mv1(); return std::unique_ptr(LocaleFallbacker::FromFFI(result)); } diff --git a/ffi/capi/bindings/cpp/LocaleFallbackerWithConfig.hpp b/ffi/capi/bindings/cpp/LocaleFallbackerWithConfig.hpp index 31e544e0555..fbf60c6fdbc 100644 --- a/ffi/capi/bindings/cpp/LocaleFallbackerWithConfig.hpp +++ b/ffi/capi/bindings/cpp/LocaleFallbackerWithConfig.hpp @@ -9,9 +9,9 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "Locale.hpp" #include "LocaleFallbackIterator.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/Logger.hpp b/ffi/capi/bindings/cpp/Logger.hpp index cee0b710bba..069dc706d93 100644 --- a/ffi/capi/bindings/cpp/Logger.hpp +++ b/ffi/capi/bindings/cpp/Logger.hpp @@ -16,7 +16,7 @@ namespace diplomat { namespace capi { extern "C" { - bool icu4x_Logger_init_simple_logger_mv1(); + bool icu4x_Logger_init_simple_logger_mv1(void); void icu4x_Logger_destroy_mv1(Logger* self); diff --git a/ffi/capi/bindings/cpp/MeasureUnitParser.hpp b/ffi/capi/bindings/cpp/MeasureUnitParser.hpp index 5c69e7e3cfc..e6bd4159d56 100644 --- a/ffi/capi/bindings/cpp/MeasureUnitParser.hpp +++ b/ffi/capi/bindings/cpp/MeasureUnitParser.hpp @@ -9,8 +9,8 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "MeasureUnit.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/MetazoneCalculator.hpp b/ffi/capi/bindings/cpp/MetazoneCalculator.hpp index 4d914045b2e..e39738014c3 100644 --- a/ffi/capi/bindings/cpp/MetazoneCalculator.hpp +++ b/ffi/capi/bindings/cpp/MetazoneCalculator.hpp @@ -9,9 +9,9 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/PluralCategories.hpp b/ffi/capi/bindings/cpp/PluralCategories.hpp index a65f1181a6b..f70c1705f03 100644 --- a/ffi/capi/bindings/cpp/PluralCategories.hpp +++ b/ffi/capi/bindings/cpp/PluralCategories.hpp @@ -24,23 +24,23 @@ namespace capi { inline diplomat::capi::PluralCategories PluralCategories::AsFFI() const { return diplomat::capi::PluralCategories { - .zero = zero, - .one = one, - .two = two, - .few = few, - .many = many, - .other = other, + /* .zero = */ zero, + /* .one = */ one, + /* .two = */ two, + /* .few = */ few, + /* .many = */ many, + /* .other = */ other, }; } inline PluralCategories PluralCategories::FromFFI(diplomat::capi::PluralCategories c_struct) { return PluralCategories { - .zero = c_struct.zero, - .one = c_struct.one, - .two = c_struct.two, - .few = c_struct.few, - .many = c_struct.many, - .other = c_struct.other, + /* .zero = */ c_struct.zero, + /* .one = */ c_struct.one, + /* .two = */ c_struct.two, + /* .few = */ c_struct.few, + /* .many = */ c_struct.many, + /* .other = */ c_struct.other, }; } diff --git a/ffi/capi/bindings/cpp/PluralOperands.d.hpp b/ffi/capi/bindings/cpp/PluralOperands.d.hpp index f8b0f01acea..88cd6767f49 100644 --- a/ffi/capi/bindings/cpp/PluralOperands.d.hpp +++ b/ffi/capi/bindings/cpp/PluralOperands.d.hpp @@ -23,9 +23,9 @@ namespace capi { class PluralOperands { public: - inline static diplomat::result, FixedDecimalParseError> create_from_string(std::string_view s); + inline static diplomat::result, FixedDecimalParseError> from_string(std::string_view s); - inline static std::unique_ptr create_from_fixed_decimal(const FixedDecimal& x); + inline static std::unique_ptr from_fixed_decimal(const FixedDecimal& x); inline const diplomat::capi::PluralOperands* AsFFI() const; inline diplomat::capi::PluralOperands* AsFFI(); diff --git a/ffi/capi/bindings/cpp/PluralOperands.hpp b/ffi/capi/bindings/cpp/PluralOperands.hpp index 85806e62e59..57ae62bd9b8 100644 --- a/ffi/capi/bindings/cpp/PluralOperands.hpp +++ b/ffi/capi/bindings/cpp/PluralOperands.hpp @@ -9,19 +9,19 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "FixedDecimal.hpp" #include "FixedDecimalParseError.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { namespace capi { extern "C" { - typedef struct icu4x_PluralOperands_create_from_string_mv1_result {union {diplomat::capi::PluralOperands* ok; diplomat::capi::FixedDecimalParseError err;}; bool is_ok;} icu4x_PluralOperands_create_from_string_mv1_result; - icu4x_PluralOperands_create_from_string_mv1_result icu4x_PluralOperands_create_from_string_mv1(const char* s_data, size_t s_len); + typedef struct icu4x_PluralOperands_from_string_mv1_result {union {diplomat::capi::PluralOperands* ok; diplomat::capi::FixedDecimalParseError err;}; bool is_ok;} icu4x_PluralOperands_from_string_mv1_result; + icu4x_PluralOperands_from_string_mv1_result icu4x_PluralOperands_from_string_mv1(const char* s_data, size_t s_len); - diplomat::capi::PluralOperands* icu4x_PluralOperands_create_from_fixed_decimal_mv1(const diplomat::capi::FixedDecimal* x); + diplomat::capi::PluralOperands* icu4x_PluralOperands_from_fixed_decimal_mv1(const diplomat::capi::FixedDecimal* x); void icu4x_PluralOperands_destroy_mv1(PluralOperands* self); @@ -30,14 +30,14 @@ namespace capi { } // namespace capi } // namespace -inline diplomat::result, FixedDecimalParseError> PluralOperands::create_from_string(std::string_view s) { - auto result = diplomat::capi::icu4x_PluralOperands_create_from_string_mv1(s.data(), +inline diplomat::result, FixedDecimalParseError> PluralOperands::from_string(std::string_view s) { + auto result = diplomat::capi::icu4x_PluralOperands_from_string_mv1(s.data(), s.size()); return result.is_ok ? diplomat::result, FixedDecimalParseError>(diplomat::Ok>(std::unique_ptr(PluralOperands::FromFFI(result.ok)))) : diplomat::result, FixedDecimalParseError>(diplomat::Err(FixedDecimalParseError::FromFFI(result.err))); } -inline std::unique_ptr PluralOperands::create_from_fixed_decimal(const FixedDecimal& x) { - auto result = diplomat::capi::icu4x_PluralOperands_create_from_fixed_decimal_mv1(x.AsFFI()); +inline std::unique_ptr PluralOperands::from_fixed_decimal(const FixedDecimal& x) { + auto result = diplomat::capi::icu4x_PluralOperands_from_fixed_decimal_mv1(x.AsFFI()); return std::unique_ptr(PluralOperands::FromFFI(result)); } diff --git a/ffi/capi/bindings/cpp/PluralRules.hpp b/ffi/capi/bindings/cpp/PluralRules.hpp index a12f75a8f76..8c42c73986b 100644 --- a/ffi/capi/bindings/cpp/PluralRules.hpp +++ b/ffi/capi/bindings/cpp/PluralRules.hpp @@ -9,13 +9,13 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" #include "Locale.hpp" #include "PluralCategories.hpp" #include "PluralCategory.hpp" #include "PluralOperands.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/PropertyValueNameToEnumMapper.hpp b/ffi/capi/bindings/cpp/PropertyValueNameToEnumMapper.hpp index 2e7ddee0c35..06c89164d5e 100644 --- a/ffi/capi/bindings/cpp/PropertyValueNameToEnumMapper.hpp +++ b/ffi/capi/bindings/cpp/PropertyValueNameToEnumMapper.hpp @@ -9,9 +9,9 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/RegionDisplayNames.hpp b/ffi/capi/bindings/cpp/RegionDisplayNames.hpp index d4c95578232..148e34f8b16 100644 --- a/ffi/capi/bindings/cpp/RegionDisplayNames.hpp +++ b/ffi/capi/bindings/cpp/RegionDisplayNames.hpp @@ -9,11 +9,11 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" #include "Locale.hpp" #include "LocaleParseError.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/ScriptWithExtensions.hpp b/ffi/capi/bindings/cpp/ScriptWithExtensions.hpp index fc2ded2db73..769ec234c05 100644 --- a/ffi/capi/bindings/cpp/ScriptWithExtensions.hpp +++ b/ffi/capi/bindings/cpp/ScriptWithExtensions.hpp @@ -9,11 +9,11 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "CodePointRangeIterator.hpp" #include "DataError.hpp" #include "DataProvider.hpp" #include "ScriptWithExtensionsBorrowed.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/ScriptWithExtensionsBorrowed.hpp b/ffi/capi/bindings/cpp/ScriptWithExtensionsBorrowed.hpp index 98d33b0fbb5..23c0ab91c64 100644 --- a/ffi/capi/bindings/cpp/ScriptWithExtensionsBorrowed.hpp +++ b/ffi/capi/bindings/cpp/ScriptWithExtensionsBorrowed.hpp @@ -9,9 +9,9 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "CodePointSetData.hpp" #include "ScriptExtensionsSet.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { diff --git a/ffi/capi/bindings/cpp/SentenceSegmenter.d.hpp b/ffi/capi/bindings/cpp/SentenceSegmenter.d.hpp index 4ac01089843..92361411d44 100644 --- a/ffi/capi/bindings/cpp/SentenceSegmenter.d.hpp +++ b/ffi/capi/bindings/cpp/SentenceSegmenter.d.hpp @@ -31,9 +31,9 @@ class SentenceSegmenter { inline static diplomat::result, DataError> create(const DataProvider& provider); - inline std::unique_ptr segment_utf8(std::string_view input) const; + inline std::unique_ptr segment(std::string_view input) const; - inline std::unique_ptr segment_utf16(std::u16string_view input) const; + inline std::unique_ptr segment16(std::u16string_view input) const; inline std::unique_ptr segment_latin1(diplomat::span input) const; diff --git a/ffi/capi/bindings/cpp/SentenceSegmenter.hpp b/ffi/capi/bindings/cpp/SentenceSegmenter.hpp index ab057dd83e1..0c0fff10307 100644 --- a/ffi/capi/bindings/cpp/SentenceSegmenter.hpp +++ b/ffi/capi/bindings/cpp/SentenceSegmenter.hpp @@ -9,12 +9,12 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "DataError.hpp" #include "DataProvider.hpp" #include "SentenceBreakIteratorLatin1.hpp" #include "SentenceBreakIteratorUtf16.hpp" #include "SentenceBreakIteratorUtf8.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -42,14 +42,14 @@ inline diplomat::result, DataError> SentenceS return result.is_ok ? diplomat::result, DataError>(diplomat::Ok>(std::unique_ptr(SentenceSegmenter::FromFFI(result.ok)))) : diplomat::result, DataError>(diplomat::Err(DataError::FromFFI(result.err))); } -inline std::unique_ptr SentenceSegmenter::segment_utf8(std::string_view input) const { +inline std::unique_ptr SentenceSegmenter::segment(std::string_view input) const { auto result = diplomat::capi::icu4x_SentenceSegmenter_segment_utf8_mv1(this->AsFFI(), input.data(), input.size()); return std::unique_ptr(SentenceBreakIteratorUtf8::FromFFI(result)); } -inline std::unique_ptr SentenceSegmenter::segment_utf16(std::u16string_view input) const { +inline std::unique_ptr SentenceSegmenter::segment16(std::u16string_view input) const { auto result = diplomat::capi::icu4x_SentenceSegmenter_segment_utf16_mv1(this->AsFFI(), input.data(), input.size()); diff --git a/ffi/capi/bindings/cpp/Time.d.hpp b/ffi/capi/bindings/cpp/Time.d.hpp index 3800584e473..ee6323b2d03 100644 --- a/ffi/capi/bindings/cpp/Time.d.hpp +++ b/ffi/capi/bindings/cpp/Time.d.hpp @@ -10,6 +10,7 @@ #include "diplomat_runtime.hpp" class CalendarError; +class CalendarParseError; namespace diplomat { @@ -23,7 +24,9 @@ class Time { inline static diplomat::result, CalendarError> create(uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond); - inline static diplomat::result, CalendarError> create_midnight(); + inline static diplomat::result, CalendarParseError> from_string(std::string_view v); + + inline static diplomat::result, CalendarError> midnight(); inline uint8_t hour() const; diff --git a/ffi/capi/bindings/cpp/Time.hpp b/ffi/capi/bindings/cpp/Time.hpp index d2edd085905..712e08f8dfa 100644 --- a/ffi/capi/bindings/cpp/Time.hpp +++ b/ffi/capi/bindings/cpp/Time.hpp @@ -9,8 +9,9 @@ #include #include #include -#include "diplomat_runtime.hpp" #include "CalendarError.hpp" +#include "CalendarParseError.hpp" +#include "diplomat_runtime.hpp" namespace diplomat { @@ -20,8 +21,11 @@ namespace capi { typedef struct icu4x_Time_create_mv1_result {union {diplomat::capi::Time* ok; diplomat::capi::CalendarError err;}; bool is_ok;} icu4x_Time_create_mv1_result; icu4x_Time_create_mv1_result icu4x_Time_create_mv1(uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond); - typedef struct icu4x_Time_create_midnight_mv1_result {union {diplomat::capi::Time* ok; diplomat::capi::CalendarError err;}; bool is_ok;} icu4x_Time_create_midnight_mv1_result; - icu4x_Time_create_midnight_mv1_result icu4x_Time_create_midnight_mv1(); + typedef struct icu4x_Time_from_string_mv1_result {union {diplomat::capi::Time* ok; diplomat::capi::CalendarParseError err;}; bool is_ok;} icu4x_Time_from_string_mv1_result; + icu4x_Time_from_string_mv1_result icu4x_Time_from_string_mv1(const char* v_data, size_t v_len); + + typedef struct icu4x_Time_midnight_mv1_result {union {diplomat::capi::Time* ok; diplomat::capi::CalendarError err;}; bool is_ok;} icu4x_Time_midnight_mv1_result; + icu4x_Time_midnight_mv1_result icu4x_Time_midnight_mv1(void); uint8_t icu4x_Time_hour_mv1(const diplomat::capi::Time* self); @@ -46,8 +50,14 @@ inline diplomat::result, CalendarError> Time::create(uint8 return result.is_ok ? diplomat::result, CalendarError>(diplomat::Ok>(std::unique_ptr