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

Make FFI DataProvider only support BufferProvider #5895

Merged
merged 13 commits into from
Dec 17, 2024

Conversation

Manishearth
Copy link
Member

@Manishearth Manishearth commented Dec 13, 2024

Fixes #4639

I still plan to do docs for this, please review the actual changes first.

"refactor" and "move usages to closures" are commits that are largely mechanical.

In the last two commits I attempt to get rid of the macro in favor of a closure based situation. Datetime uses a custom error so it's weird.

@Manishearth Manishearth requested a review from sffc December 13, 2024 00:16
@sffc sffc changed the title Make DataProvider only support BufferProvider Make FFI DataProvider only support BufferProvider Dec 13, 2024
@Manishearth
Copy link
Member Author

-Dwarnings on imports is a bit of a pain for this crate. We may wish to consider disabling the unused import warning for a crate with as many features as this has.

@Manishearth Manishearth force-pushed the provider-capi-simpler branch 2 times, most recently from 44a961c to 9bfe85f Compare December 14, 2024 03:17
@Manishearth Manishearth requested a review from a team as a code owner December 14, 2024 03:17
@Manishearth
Copy link
Member Author

finally all of the CFGs seem fixed. that took way too long, but with this landed I believe we're done with the tedious part of our FFI 2.0 fixes

@Manishearth Manishearth force-pushed the provider-capi-simpler branch from 9bfe85f to 1ea1fad Compare December 16, 2024 22:45
@Manishearth Manishearth force-pushed the provider-capi-simpler branch from 1ea1fad to f8bc3fd Compare December 17, 2024 01:12
Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Praise: This is much easier to review with the bindings changes split into the earlier PR.

@@ -30,6 +30,12 @@ pub enum DateTimeFormatterLoadError {
Data(DataError),
}

impl From<DataError> for DateTimeFormatterLoadError {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with this, but @robertbastian pushed back on adding the From impls for the fine-grained error types in this crate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm. we kind of need it to use the closure but we could also not use the closure and revive the macro instead for these few call sites.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm. we kind of need it to use the closure but we could also not use the closure and revive the macro instead for these few call sites.

Comment on lines +151 to 158
Ok(Box::new(Calendar(Arc::new(provider.call_constructor(
|provider| {
icu_calendar::AnyCalendar::try_new_for_kind_with_buffer_provider(
provider,
kind.into(),
)
},
)?))))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't specifically recall a discussion on changing the macro to a closure. It seems like it would be harder in the future to change the behavior back to supporting try_new_unstable and similar. But it's fine.

Copy link
Member Author

@Manishearth Manishearth Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, this wasn't discussed before: this PR was the discussion opportunity, and I can remove the last N commits if we don't want this.

But it should be easy enough to bring back when we need it.

I tend to consider macro use to be suboptimal, so if they can be removed without sacrificing anything I try to remove them. Here the complexity has not increased and the main downside is wanting to refactor again in the medium term.

icu_experimental::units::converter_factory::ConverterFactory::try_new_with_buffer_provider,
provider,
)?)))
Ok(Box::new(UnitsConverterFactory(provider.call_constructor(icu_experimental::units::converter_factory::ConverterFactory::try_new_with_buffer_provider)?)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought: lines like this look to me like they should be formatted.

@Manishearth Manishearth merged commit 4bad030 into unicode-org:main Dec 17, 2024
28 checks passed
@Manishearth Manishearth deleted the provider-capi-simpler branch December 17, 2024 05:04
@Manishearth
Copy link
Member Author

Merging, I will improve docs in a new PR. We can still discuss if we really want the closure and if the From impl is a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve compiled data FFI constructors
2 participants