Skip to content

Commit

Permalink
Use data marker attributes for time zone glue patterns (#5203)
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc authored Jul 9, 2024
1 parent d107e75 commit c19e941
Show file tree
Hide file tree
Showing 1,369 changed files with 1,235 additions and 13,747 deletions.
38 changes: 0 additions & 38 deletions components/datetime/src/calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ pub trait CldrCalendar: InternalCldrCalendar {
/// The data marker for loading month symbols for this calendar.
type MonthNamesV1Marker: DataMarker<Yokeable = MonthNamesV1<'static>>;

#[cfg(any(feature = "datagen", feature = "experimental"))]
/// The data marker for loading a single date pattern for this calendar.
type DatePatternV1Marker: DataMarker<Yokeable = DatePatternV1<'static>>;

#[cfg(any(feature = "datagen", feature = "experimental"))]
/// The data marker for loading skeleton patterns for this calendar.
type SkeletaV1Marker: DataMarker<Yokeable = PackedSkeletonDataV1<'static>>;
Expand Down Expand Up @@ -110,7 +106,6 @@ impl CldrCalendar for NeverCalendar {
type DateLengthsV1Marker = NeverMarker<DateLengthsV1<'static>>;
type YearNamesV1Marker = NeverMarker<YearNamesV1<'static>>;
type MonthNamesV1Marker = NeverMarker<MonthNamesV1<'static>>;
type DatePatternV1Marker = NeverMarker<DatePatternV1<'static>>;
type SkeletaV1Marker = NeverMarker<PackedSkeletonDataV1<'static>>;
}

Expand All @@ -123,8 +118,6 @@ impl CldrCalendar for Buddhist {
#[cfg(any(feature = "datagen", feature = "experimental"))]
type MonthNamesV1Marker = BuddhistMonthNamesV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type DatePatternV1Marker = BuddhistDatePatternV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type SkeletaV1Marker = BuddhistDateNeoSkeletonPatternsV1Marker;
}

Expand All @@ -137,8 +130,6 @@ impl CldrCalendar for Chinese {
#[cfg(any(feature = "datagen", feature = "experimental"))]
type MonthNamesV1Marker = ChineseMonthNamesV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type DatePatternV1Marker = ChineseDatePatternV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type SkeletaV1Marker = ChineseDateNeoSkeletonPatternsV1Marker;
}

Expand All @@ -151,8 +142,6 @@ impl CldrCalendar for Coptic {
#[cfg(any(feature = "datagen", feature = "experimental"))]
type MonthNamesV1Marker = CopticMonthNamesV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type DatePatternV1Marker = CopticDatePatternV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type SkeletaV1Marker = CopticDateNeoSkeletonPatternsV1Marker;
}

Expand All @@ -165,8 +154,6 @@ impl CldrCalendar for Dangi {
#[cfg(any(feature = "datagen", feature = "experimental"))]
type MonthNamesV1Marker = DangiMonthNamesV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type DatePatternV1Marker = DangiDatePatternV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type SkeletaV1Marker = DangiDateNeoSkeletonPatternsV1Marker;
}

Expand All @@ -179,8 +166,6 @@ impl CldrCalendar for Ethiopian {
#[cfg(any(feature = "datagen", feature = "experimental"))]
type MonthNamesV1Marker = EthiopianMonthNamesV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type DatePatternV1Marker = EthiopianDatePatternV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type SkeletaV1Marker = EthiopianDateNeoSkeletonPatternsV1Marker;
fn is_identifier_allowed_for_calendar(value: &Value) -> bool {
*value == value!("ethiopic") || *value == value!("ethioaa")
Expand All @@ -196,8 +181,6 @@ impl CldrCalendar for Gregorian {
#[cfg(any(feature = "datagen", feature = "experimental"))]
type MonthNamesV1Marker = GregorianMonthNamesV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type DatePatternV1Marker = GregorianDatePatternV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type SkeletaV1Marker = GregorianDateNeoSkeletonPatternsV1Marker;
}

Expand All @@ -210,8 +193,6 @@ impl CldrCalendar for Hebrew {
#[cfg(any(feature = "datagen", feature = "experimental"))]
type MonthNamesV1Marker = HebrewMonthNamesV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type DatePatternV1Marker = HebrewDatePatternV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type SkeletaV1Marker = HebrewDateNeoSkeletonPatternsV1Marker;
}

Expand All @@ -224,8 +205,6 @@ impl CldrCalendar for Indian {
#[cfg(any(feature = "datagen", feature = "experimental"))]
type MonthNamesV1Marker = IndianMonthNamesV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type DatePatternV1Marker = IndianDatePatternV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type SkeletaV1Marker = IndianDateNeoSkeletonPatternsV1Marker;
}

Expand All @@ -241,8 +220,6 @@ impl CldrCalendar for IslamicCivil {
#[cfg(any(feature = "datagen", feature = "experimental"))]
type MonthNamesV1Marker = IslamicMonthNamesV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type DatePatternV1Marker = IslamicDatePatternV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type SkeletaV1Marker = IslamicDateNeoSkeletonPatternsV1Marker;
fn is_identifier_allowed_for_calendar(value: &Value) -> bool {
*value == value!("islamicc") || is_islamic_subcal(value, subtag!("civil"))
Expand All @@ -258,8 +235,6 @@ impl CldrCalendar for IslamicObservational {
#[cfg(any(feature = "datagen", feature = "experimental"))]
type MonthNamesV1Marker = IslamicMonthNamesV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type DatePatternV1Marker = IslamicDatePatternV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type SkeletaV1Marker = IslamicDateNeoSkeletonPatternsV1Marker;
}

Expand All @@ -275,8 +250,6 @@ impl CldrCalendar for IslamicTabular {
#[cfg(any(feature = "datagen", feature = "experimental"))]
type MonthNamesV1Marker = IslamicMonthNamesV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type DatePatternV1Marker = IslamicDatePatternV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type SkeletaV1Marker = IslamicDateNeoSkeletonPatternsV1Marker;
fn is_identifier_allowed_for_calendar(value: &Value) -> bool {
is_islamic_subcal(value, subtag!("tbla"))
Expand All @@ -295,8 +268,6 @@ impl CldrCalendar for IslamicUmmAlQura {
#[cfg(any(feature = "datagen", feature = "experimental"))]
type MonthNamesV1Marker = IslamicMonthNamesV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type DatePatternV1Marker = IslamicDatePatternV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type SkeletaV1Marker = IslamicDateNeoSkeletonPatternsV1Marker;
fn is_identifier_allowed_for_calendar(value: &Value) -> bool {
is_islamic_subcal(value, subtag!("umalqura"))
Expand All @@ -312,8 +283,6 @@ impl CldrCalendar for Japanese {
#[cfg(any(feature = "datagen", feature = "experimental"))]
type MonthNamesV1Marker = JapaneseMonthNamesV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type DatePatternV1Marker = JapaneseDatePatternV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type SkeletaV1Marker = JapaneseDateNeoSkeletonPatternsV1Marker;
}

Expand All @@ -326,8 +295,6 @@ impl CldrCalendar for JapaneseExtended {
#[cfg(any(feature = "datagen", feature = "experimental"))]
type MonthNamesV1Marker = JapaneseExtendedMonthNamesV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type DatePatternV1Marker = JapaneseExtendedDatePatternV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type SkeletaV1Marker = JapaneseExtendedDateNeoSkeletonPatternsV1Marker;
}

Expand All @@ -340,8 +307,6 @@ impl CldrCalendar for Persian {
#[cfg(any(feature = "datagen", feature = "experimental"))]
type MonthNamesV1Marker = PersianMonthNamesV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type DatePatternV1Marker = PersianDatePatternV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type SkeletaV1Marker = PersianDateNeoSkeletonPatternsV1Marker;
}

Expand All @@ -354,8 +319,6 @@ impl CldrCalendar for Roc {
#[cfg(any(feature = "datagen", feature = "experimental"))]
type MonthNamesV1Marker = RocMonthNamesV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type DatePatternV1Marker = RocDatePatternV1Marker;
#[cfg(any(feature = "datagen", feature = "experimental"))]
type SkeletaV1Marker = RocDateNeoSkeletonPatternsV1Marker;
}

Expand Down Expand Up @@ -864,7 +827,6 @@ macro_rules! impl_load_any_calendar {

#[cfg(any(feature = "datagen", feature = "experimental"))]
impl_load_any_calendar!([
(DatePatternV1Marker, DatePatternV1Marker),
(YearNamesV1Marker, YearNamesV1Marker),
(MonthNamesV1Marker, MonthNamesV1Marker),
(SkeletaV1Marker, SkeletaV1Marker)
Expand Down
28 changes: 14 additions & 14 deletions components/datetime/src/neo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ macro_rules! gen_any_buffer_constructors_with_external_loader {
};
}

size_test!(TypedNeoFormatter<icu_calendar::Gregorian, crate::neo_marker::NeoYearMonthDayMarker>, typed_neo_year_month_day_formatter_size, 544);
size_test!(TypedNeoFormatter<icu_calendar::Gregorian, crate::neo_marker::NeoYearMonthDayMarker>, typed_neo_year_month_day_formatter_size, 504);

/// [`TypedNeoFormatter`] is a formatter capable of formatting dates and/or times from
/// a calendar selected at compile time.
Expand Down Expand Up @@ -226,7 +226,7 @@ impl<C: CldrCalendar, R: TypedNeoFormatterMarker<C>> TypedNeoFormatter<C, R> {
+ DataProvider<<R::Z as ZoneMarkers>::GenericShortV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificLongV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificShortV1Marker>
+ DataProvider<R::DateTimePatternV1Marker>,
+ DataProvider<R::GluePatternV1Marker>,
{
Self::try_new_internal(
&crate::provider::Baked,
Expand Down Expand Up @@ -267,7 +267,7 @@ impl<C: CldrCalendar, R: TypedNeoFormatterMarker<C>> TypedNeoFormatter<C, R> {
+ DataProvider<<R::Z as ZoneMarkers>::GenericShortV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificLongV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificShortV1Marker>
+ DataProvider<R::DateTimePatternV1Marker>
+ DataProvider<R::GluePatternV1Marker>
// FixedDecimalFormatter markers
+ DataProvider<DecimalSymbolsV1Marker>
// WeekCalculator markers
Expand Down Expand Up @@ -388,7 +388,7 @@ impl<C: CldrCalendar, R: TypedDateTimeMarkers<C> + IsRuntimeComponents> TypedNeo
+ DataProvider<<R::Z as ZoneMarkers>::GenericShortV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificLongV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificShortV1Marker>
+ DataProvider<R::DateTimePatternV1Marker>,
+ DataProvider<R::GluePatternV1Marker>,
{
Self::try_new_internal(
&crate::provider::Baked,
Expand Down Expand Up @@ -430,7 +430,7 @@ impl<C: CldrCalendar, R: TypedDateTimeMarkers<C> + IsRuntimeComponents> TypedNeo
+ DataProvider<<R::Z as ZoneMarkers>::GenericShortV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificLongV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificShortV1Marker>
+ DataProvider<R::DateTimePatternV1Marker>
+ DataProvider<R::GluePatternV1Marker>
// FixedDecimalFormatter markers
+ DataProvider<DecimalSymbolsV1Marker>
// WeekCalculator markers
Expand Down Expand Up @@ -469,13 +469,13 @@ impl<C: CldrCalendar, R: TypedDateTimeMarkers<C>> TypedNeoFormatter<C, R> {
+ DataProvider<<R::Z as ZoneMarkers>::GenericShortV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificLongV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificShortV1Marker>
+ DataProvider<R::DateTimePatternV1Marker>,
+ DataProvider<R::GluePatternV1Marker>,
L: FixedDecimalFormatterLoader + WeekCalculatorLoader,
{
let selection = DateTimeZonePatternSelectionData::try_new_with_skeleton(
&<R::D as TypedDateMarkers<C>>::DateSkeletonPatternsV1Marker::bind(provider),
&<R::T as TimeMarkers>::TimeSkeletonPatternsV1Marker::bind(provider),
&R::DateTimePatternV1Marker::bind(provider),
&R::GluePatternV1Marker::bind(provider),
locale,
length,
components,
Expand Down Expand Up @@ -581,7 +581,7 @@ impl<C: CldrCalendar, R: TypedDateTimeMarkers<C>> TypedNeoFormatter<C, R> {
size_test!(
NeoFormatter<crate::neo_marker::NeoYearMonthDayMarker>,
neo_year_month_day_formatter_size,
600
560
);

/// [`NeoFormatter`] is a formatter capable of formatting dates and/or times from
Expand Down Expand Up @@ -714,7 +714,7 @@ impl<R: NeoFormatterMarker> NeoFormatter<R> {
+ DataProvider<<R::Z as ZoneMarkers>::GenericShortV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificLongV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificShortV1Marker>
+ DataProvider<R::DateTimePatternV1Marker>,
+ DataProvider<R::GluePatternV1Marker>,
{
Self::try_new_internal(
&crate::provider::Baked,
Expand Down Expand Up @@ -803,7 +803,7 @@ impl<R: NeoFormatterMarker> NeoFormatter<R> {
+ DataProvider<<R::Z as ZoneMarkers>::GenericShortV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificLongV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificShortV1Marker>
+ DataProvider<R::DateTimePatternV1Marker>
+ DataProvider<R::GluePatternV1Marker>
// AnyCalendar constructor markers
+ DataProvider<ChineseCacheV1Marker>
+ DataProvider<DangiCacheV1Marker>
Expand Down Expand Up @@ -974,7 +974,7 @@ impl<R: DateTimeMarkers + IsRuntimeComponents> NeoFormatter<R> {
+ DataProvider<<R::Z as ZoneMarkers>::GenericShortV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificLongV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificShortV1Marker>
+ DataProvider<R::DateTimePatternV1Marker>
+ DataProvider<R::GluePatternV1Marker>
{
Self::try_new_internal(
&crate::provider::Baked,
Expand Down Expand Up @@ -1064,7 +1064,7 @@ impl<R: DateTimeMarkers + IsRuntimeComponents> NeoFormatter<R> {
+ DataProvider<<R::Z as ZoneMarkers>::GenericShortV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificLongV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificShortV1Marker>
+ DataProvider<R::DateTimePatternV1Marker>
+ DataProvider<R::GluePatternV1Marker>
// AnyCalendar constructor markers
+ DataProvider<ChineseCacheV1Marker>
+ DataProvider<DangiCacheV1Marker>
Expand Down Expand Up @@ -1158,15 +1158,15 @@ impl<R: DateTimeMarkers> NeoFormatter<R> {
+ DataProvider<<R::Z as ZoneMarkers>::GenericShortV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificLongV1Marker>
+ DataProvider<<R::Z as ZoneMarkers>::SpecificShortV1Marker>
+ DataProvider<R::DateTimePatternV1Marker>,
+ DataProvider<R::GluePatternV1Marker>,
L: FixedDecimalFormatterLoader + WeekCalculatorLoader + AnyCalendarLoader,
{
let calendar = AnyCalendarLoader::load(loader, locale).map_err(LoadError::Data)?;
let kind = calendar.kind();
let selection = DateTimeZonePatternSelectionData::try_new_with_skeleton(
&AnyCalendarProvider::<<R::D as DateMarkers>::Skel, _>::new(provider, kind),
&<R::T as TimeMarkers>::TimeSkeletonPatternsV1Marker::bind(provider),
&R::DateTimePatternV1Marker::bind(provider),
&R::GluePatternV1Marker::bind(provider),
locale,
length,
components,
Expand Down
Loading

0 comments on commit c19e941

Please sign in to comment.