Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Implement is_identifier_(start/part) using icu_properties #2865

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions boa_icu_provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,26 @@ rust-version.workspace = true

[dependencies]
icu_provider = { version = "1.2.0", features = ["serde", "sync"] }
icu_provider_blob = "1.2.0"
icu_provider_adapters = { version = "1.2.0", features = ["serde"] }
icu_collections = "1.2.0"
icu_normalizer = "1.2.0"
icu_properties = "1.2.0"
zerovec = "0.9.4"

icu_datagen = { version = "1.2.3", optional = true }
once_cell = {version = "1.17.1", default-features = false, features = ["critical-section"], optional = true }
icu_provider_blob = { version = "1.2.0", optional = true }
icu_provider_adapters = { version = "1.2.0", features = ["serde"], optional = true }
once_cell = { version = "1.17.1", default-features = false, features = [
"critical-section",
], optional = true }
log = { version = "0.4.17", optional = true }
simple_logger = { version = "4.1.0", optional = true }
icu_casemapping = { version = "0.7.2", optional = true }

[features]
default = ["std"]
full = ["dep:once_cell"]
full = ["dep:once_cell", "dep:icu_provider_blob", "dep:icu_provider_adapters"]
std = ["once_cell?/std"]
bin = ["dep:icu_datagen", "dep:simple_logger", "dep:log"]
bin = ["dep:icu_datagen", "dep:simple_logger", "dep:log", "dep:icu_casemapping"]

[[bin]]
name = "boa-datagen"
Expand Down
Binary file modified boa_icu_provider/data/icudata.postcard
Binary file not shown.
66 changes: 0 additions & 66 deletions boa_icu_provider/data/min/fallback/likelysubtags_v1/und.rs.data

This file was deleted.

4 changes: 0 additions & 4 deletions boa_icu_provider/data/min/fallback/mod.rs

This file was deleted.

13 changes: 0 additions & 13 deletions boa_icu_provider/data/min/fallback/parents_v1/und.rs.data

This file was deleted.

6 changes: 0 additions & 6 deletions boa_icu_provider/data/min/fallback/supplement/co_v1/mod.rs

This file was deleted.

22 changes: 0 additions & 22 deletions boa_icu_provider/data/min/fallback/supplement/co_v1/und.rs.data

This file was deleted.

2 changes: 0 additions & 2 deletions boa_icu_provider/data/min/fallback/supplement/mod.rs

This file was deleted.

67 changes: 14 additions & 53 deletions boa_icu_provider/data/min/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// @generated
#[clippy::msrv = "1.61"]
mod fallback;
#[clippy::msrv = "1.61"]
mod normalizer;
#[clippy::msrv = "1.61"]
mod props;
#[clippy::msrv = "1.61"]
use icu_provider::prelude::*;
/// Implement [`DataProvider<M>`] on the given struct using the data
/// hardcoded in this module. This allows the struct to be used with
Expand Down Expand Up @@ -96,63 +96,29 @@ macro_rules! impl_data_provider {
}
}
#[clippy::msrv = "1.61"]
impl DataProvider<::icu_provider_adapters::fallback::provider::CollationFallbackSupplementV1Marker> for $provider {
fn load(
&self,
req: DataRequest,
) -> Result<DataResponse<::icu_provider_adapters::fallback::provider::CollationFallbackSupplementV1Marker>, DataError> {
fallback::supplement::co_v1::lookup(&req.locale)
.map(zerofrom::ZeroFrom::zero_from)
.map(DataPayload::from_owned)
.map(|payload| DataResponse {
metadata: Default::default(),
payload: Some(payload),
})
.ok_or_else(|| {
DataErrorKind::MissingLocale.with_req(
::icu_provider_adapters::fallback::provider::CollationFallbackSupplementV1Marker::KEY,
req,
)
})
}
}
#[clippy::msrv = "1.61"]
impl DataProvider<::icu_provider_adapters::fallback::provider::LocaleFallbackLikelySubtagsV1Marker> for $provider {
fn load(
&self,
req: DataRequest,
) -> Result<DataResponse<::icu_provider_adapters::fallback::provider::LocaleFallbackLikelySubtagsV1Marker>, DataError> {
fallback::likelysubtags_v1::lookup(&req.locale)
impl DataProvider<::icu_properties::provider::IdContinueV1Marker> for $provider {
fn load(&self, req: DataRequest) -> Result<DataResponse<::icu_properties::provider::IdContinueV1Marker>, DataError> {
props::idc_v1::lookup(&req.locale)
.map(zerofrom::ZeroFrom::zero_from)
.map(DataPayload::from_owned)
.map(|payload| DataResponse {
metadata: Default::default(),
payload: Some(payload),
})
.ok_or_else(|| {
DataErrorKind::MissingLocale.with_req(
::icu_provider_adapters::fallback::provider::LocaleFallbackLikelySubtagsV1Marker::KEY,
req,
)
})
.ok_or_else(|| DataErrorKind::MissingLocale.with_req(::icu_properties::provider::IdContinueV1Marker::KEY, req))
}
}
#[clippy::msrv = "1.61"]
impl DataProvider<::icu_provider_adapters::fallback::provider::LocaleFallbackParentsV1Marker> for $provider {
fn load(
&self,
req: DataRequest,
) -> Result<DataResponse<::icu_provider_adapters::fallback::provider::LocaleFallbackParentsV1Marker>, DataError> {
fallback::parents_v1::lookup(&req.locale)
impl DataProvider<::icu_properties::provider::IdStartV1Marker> for $provider {
fn load(&self, req: DataRequest) -> Result<DataResponse<::icu_properties::provider::IdStartV1Marker>, DataError> {
props::ids_v1::lookup(&req.locale)
.map(zerofrom::ZeroFrom::zero_from)
.map(DataPayload::from_owned)
.map(|payload| DataResponse {
metadata: Default::default(),
payload: Some(payload),
})
.ok_or_else(|| {
DataErrorKind::MissingLocale.with_req(::icu_provider_adapters::fallback::provider::LocaleFallbackParentsV1Marker::KEY, req)
})
.ok_or_else(|| DataErrorKind::MissingLocale.with_req(::icu_properties::provider::IdStartV1Marker::KEY, req))
}
}
};
Expand Down Expand Up @@ -185,21 +151,16 @@ macro_rules! impl_any_provider {
::icu_normalizer::provider::CompatibilityDecompositionSupplementV1Marker::KEY.hashed();
const COMPATIBILITYDECOMPOSITIONTABLESV1MARKER: ::icu_provider::DataKeyHash =
::icu_normalizer::provider::CompatibilityDecompositionTablesV1Marker::KEY.hashed();
const COLLATIONFALLBACKSUPPLEMENTV1MARKER: ::icu_provider::DataKeyHash =
::icu_provider_adapters::fallback::provider::CollationFallbackSupplementV1Marker::KEY.hashed();
const LOCALEFALLBACKLIKELYSUBTAGSV1MARKER: ::icu_provider::DataKeyHash =
::icu_provider_adapters::fallback::provider::LocaleFallbackLikelySubtagsV1Marker::KEY.hashed();
const LOCALEFALLBACKPARENTSV1MARKER: ::icu_provider::DataKeyHash =
::icu_provider_adapters::fallback::provider::LocaleFallbackParentsV1Marker::KEY.hashed();
const IDCONTINUEV1MARKER: ::icu_provider::DataKeyHash = ::icu_properties::provider::IdContinueV1Marker::KEY.hashed();
const IDSTARTV1MARKER: ::icu_provider::DataKeyHash = ::icu_properties::provider::IdStartV1Marker::KEY.hashed();
match key.hashed() {
CANONICALCOMPOSITIONSV1MARKER => normalizer::comp_v1::lookup(&req.locale).map(AnyPayload::from_static_ref),
CANONICALDECOMPOSITIONDATAV1MARKER => normalizer::nfd_v1::lookup(&req.locale).map(AnyPayload::from_static_ref),
CANONICALDECOMPOSITIONTABLESV1MARKER => normalizer::nfdex_v1::lookup(&req.locale).map(AnyPayload::from_static_ref),
COMPATIBILITYDECOMPOSITIONSUPPLEMENTV1MARKER => normalizer::nfkd_v1::lookup(&req.locale).map(AnyPayload::from_static_ref),
COMPATIBILITYDECOMPOSITIONTABLESV1MARKER => normalizer::nfkdex_v1::lookup(&req.locale).map(AnyPayload::from_static_ref),
COLLATIONFALLBACKSUPPLEMENTV1MARKER => fallback::supplement::co_v1::lookup(&req.locale).map(AnyPayload::from_static_ref),
LOCALEFALLBACKLIKELYSUBTAGSV1MARKER => fallback::likelysubtags_v1::lookup(&req.locale).map(AnyPayload::from_static_ref),
LOCALEFALLBACKPARENTSV1MARKER => fallback::parents_v1::lookup(&req.locale).map(AnyPayload::from_static_ref),
IDCONTINUEV1MARKER => props::idc_v1::lookup(&req.locale).map(AnyPayload::from_static_ref),
IDSTARTV1MARKER => props::ids_v1::lookup(&req.locale).map(AnyPayload::from_static_ref),
_ => return Err(DataErrorKind::MissingDataKey.with_req(key, req)),
}
.map(|payload| AnyResponse {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @generated
type DataStruct = < :: icu_provider_adapters :: fallback :: provider :: LocaleFallbackParentsV1Marker as :: icu_provider :: DataMarker > :: Yokeable ;
type DataStruct =
<::icu_properties::provider::IdContinueV1Marker as ::icu_provider::DataMarker>::Yokeable;
pub fn lookup(locale: &icu_provider::DataLocale) -> Option<&'static DataStruct> {
locale.is_empty().then(|| &UND)
}
Expand Down
9 changes: 9 additions & 0 deletions boa_icu_provider/data/min/props/idc_v1/und.rs.data

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @generated
type DataStruct = < :: icu_provider_adapters :: fallback :: provider :: LocaleFallbackLikelySubtagsV1Marker as :: icu_provider :: DataMarker > :: Yokeable ;
type DataStruct =
<::icu_properties::provider::IdStartV1Marker as ::icu_provider::DataMarker>::Yokeable;
pub fn lookup(locale: &icu_provider::DataLocale) -> Option<&'static DataStruct> {
locale.is_empty().then(|| &UND)
}
Expand Down
Loading