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

Add initial neo datetime FFI #6035

Merged
merged 35 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7bbbe1c
Initial neo datetime FFI PoC
sffc Jan 25, 2025
e358bcd
Add YearStyle and YMDT field set
sffc Jan 25, 2025
8fc9ada
Fill in the date-and-time field sets
sffc Jan 25, 2025
55c26e8
Fix rust links
sffc Jan 25, 2025
a6d58be
Add FFI datetime builder API
sffc Jan 25, 2025
45f891b
Fix CI
sffc Jan 26, 2025
5a2022a
Remove the old FFI DateTimeFormatter
sffc Feb 5, 2025
18c806f
Remove neo prefixes
sffc Feb 5, 2025
f91132f
Update CPP test
sffc Feb 5, 2025
c624402
Fix constructor name
sffc Feb 5, 2025
55a2713
Add with_provider ctors
sffc Feb 5, 2025
ab6acf1
Add Dart example code
sffc Feb 5, 2025
780b1b3
fix dart
robertbastian Feb 5, 2025
8f39a79
Merge remote-tracking branch 'upstream/main' into neo-datetime-ffi
sffc Feb 6, 2025
7978272
Touch Cargo.lock
sffc Feb 6, 2025
8841acc
Fix feature
sffc Feb 6, 2025
a6906bf
diplomat-coverage
sffc Feb 6, 2025
6c03d60
Add more rust links
sffc Feb 6, 2025
af23e49
Make the enums have default values in Rust
sffc Feb 6, 2025
275f832
Make FFI use Option positional arguments
sffc Feb 6, 2025
bd185b1
Use std::optional in cpp test
sffc Feb 6, 2025
7e416e9
features
sffc Feb 6, 2025
aa85e53
Remove FieldSetBuilder (for now)
sffc Feb 6, 2025
01acd6e
fmt
sffc Feb 6, 2025
2844eff
Features
sffc Feb 7, 2025
2cc09da
Add DateTimeFormatterGregorian
sffc Feb 7, 2025
12e771b
rm GregorianDateTimeFormatter
sffc Feb 7, 2025
e26e6c7
std::nullopt
sffc Feb 7, 2025
ad46fa3
Add formatSameCalendar
sffc Feb 7, 2025
a8db34a
Rust links, diplomat-coverage, allowlist changes
sffc Feb 7, 2025
c29fafc
Ignore with_fset
sffc Feb 7, 2025
754a987
Ignore [try_]into_[typed_]formatter
sffc Feb 7, 2025
b99cbca
Merge remote-tracking branch 'upstream/main' into neo-datetime-ffi
sffc Feb 7, 2025
220ded9
diplomat-gen
sffc Feb 7, 2025
9e0aba5
features
sffc Feb 7, 2025
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
4 changes: 0 additions & 4 deletions components/datetime/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,6 @@ pub struct FieldSetBuilder {
pub year_style: Option<YearStyle>,
}

// This is the default length when the builder is used. This could have been defined in the macro
// that generates the `take_from_builder` fns, but it would be easily lost.
pub(crate) const DEFAULT_LENGTH: Length = Length::Medium;

enum DateOrCalendarPeriodFieldSet {
Date(DateFieldSet),
CalendarPeriod(CalendarPeriodFieldSet),
Expand Down
3 changes: 1 addition & 2 deletions components/datetime/src/fieldsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,12 @@ macro_rules! impl_marker_with_options {
}
}
/// Builds this field set, removing the needed options from the builder.
/// If length is needed but is None, falls back to `builder::DEFAULT_LENGTH`.
#[allow(unused)]
pub(crate) fn take_from_builder(
options: &mut builder::FieldSetBuilder
) -> Self {
Self {
$(length: yes_to!(options.length.take().unwrap_or(builder::DEFAULT_LENGTH), $sample_length),)?
$(length: yes_to!(options.length.take().unwrap_or_default(), $sample_length),)?
$(alignment: yes_to!(options.alignment.take(), $alignment_yes),)?
$(year_style: yes_to!(options.year_style.take(), $yearstyle_yes),)?
$(time_precision: yes_to!(options.time_precision.take(), $timeprecision_yes),)?
Expand Down
11 changes: 8 additions & 3 deletions components/datetime/src/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use crate::neo_serde::TimePrecisionSerde;
/// "January 1, 2000"
/// );
/// ```
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Default)]
#[cfg_attr(
all(feature = "serde", feature = "experimental"),
derive(serde::Serialize, serde::Deserialize)
Expand All @@ -73,6 +73,9 @@ pub enum Length {
/// A long date; typically spelled-out, as in “January 1, 2000”.
Long = 4,
/// A medium-sized date; typically abbreviated, as in “Jan. 1, 2000”.
///
/// This is the default.
#[default]
Medium = 3,
/// A short date; typically numeric, as in “1/1/2000”.
Short = 1,
Expand Down Expand Up @@ -128,7 +131,7 @@ impl IntoOption<Length> for Length {
/// "01/01/25"
/// );
/// ```
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Default)]
#[cfg_attr(
all(feature = "serde", feature = "experimental"),
derive(serde::Serialize, serde::Deserialize)
Expand All @@ -142,6 +145,7 @@ pub enum Alignment {
/// Align fields as the locale specifies them to be aligned.
///
/// This is the default option.
#[default]
Auto,
/// Align fields as appropriate for a column layout. For example:
///
Expand Down Expand Up @@ -257,7 +261,7 @@ impl IntoOption<Alignment> for Alignment {
/// "1/1/2025 AD"
/// );
/// ```
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Default)]
#[cfg_attr(
all(feature = "serde", feature = "experimental"),
derive(serde::Serialize, serde::Deserialize)
Expand All @@ -279,6 +283,7 @@ pub enum YearStyle {
/// - `77 AD`
/// - `1900`
/// - `'24`
#[default]
Auto,
/// Always display the century, and display the era when needed to
/// disambiguate the year, based on locale preferences.
Expand Down
5 changes: 3 additions & 2 deletions components/datetime/src/raw/neo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl DatePatternSelectionData {
pub(crate) fn select(&self, input: &ExtractedInput) -> DatePatternDataBorrowed {
match self {
DatePatternSelectionData::SkeletonDate { options, payload } => {
let year_style = options.year_style.unwrap_or(YearStyle::Auto);
let year_style = options.year_style.unwrap_or_default();
let variant = match (
year_style,
input
Expand Down Expand Up @@ -870,7 +870,8 @@ impl<'a> ItemsAndOptions<'a> {
#[allow(clippy::single_match)] // need `ref mut`, which doesn't work in `if let`?
match &mut pattern_item {
PatternItem::Field(ref mut field) => {
if matches!(self.alignment, Some(Alignment::Column))
let alignment = self.alignment.unwrap_or_default();
if matches!(alignment, Alignment::Column)
&& field.length == FieldLength::One
&& matches!(
field.symbol,
Expand Down
23 changes: 23 additions & 0 deletions ffi/capi/bindings/c/DateTimeAlignment.d.h

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

23 changes: 23 additions & 0 deletions ffi/capi/bindings/c/DateTimeAlignment.h

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

57 changes: 46 additions & 11 deletions ffi/capi/bindings/c/DateTimeFormatter.h

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

19 changes: 19 additions & 0 deletions ffi/capi/bindings/c/DateTimeFormatterGregorian.d.h

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

Loading
Loading