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

capi Dart todos #4235

Closed
4 tasks done
robertbastian opened this issue Oct 27, 2023 · 9 comments
Closed
4 tasks done

capi Dart todos #4235

robertbastian opened this issue Oct 27, 2023 · 9 comments
Assignees
Labels
U-flutter User: Flutter Engine or Dart SDK

Comments

@robertbastian
Copy link
Member

robertbastian commented Oct 27, 2023

Just collecting some notes:

  • ICU4XReorderedIndexMap::as_slice returns a &[usize]. I need to figure out how to port this to Dart
  • ICU4XDataStruct::create_decimal_symbols_v1 accepts &[char]. There's no char type in Dart, it allows code point iteration but the items are strings. We could use List<String> or List<int> for this
  • Dart is native Utf-16, but in Diplomat we don't know if a given &[u16] is a string or not, so currently I have to put Uint16List on the API
  • Some apis return Result<_, ()>. This is fine in C++, but we want something to throw in Dart. Check what JS does.
@robertbastian robertbastian added the U-flutter User: Flutter Engine or Dart SDK label Oct 27, 2023
@robertbastian robertbastian self-assigned this Oct 27, 2023
@robertbastian
Copy link
Member Author

cc @Manishearth

@Manishearth
Copy link
Member

For the utf-16 stuff we have a separate issue: rust-diplomat/diplomat#240 and getting a DiplomatWriteable16 . These don't exist right now.

Dart is native Utf-16, but in Diplomat we don't know if a given &[u16] is a string or not, so currently I have to put Uint16List on the API

I'm confused, you'd be converting these at the boundary, yes?

There's no char type in Dart

Not uint32_t type either?

Check what JS does

JS throws.

@robertbastian
Copy link
Member Author

I'm confused, you'd be converting these at the boundary, yes?

I'm confused. The question here is if we can use the String type, because we don't want Uint16List on the API if it's actually a string.

Not uint32_t type either?

No, there's only int, which is platform dependent, 64 bits on the VM, and 54 bits on web.

JS throws.

But what does it throw?

@Manishearth
Copy link
Member

I believe JS throws an FFIError type that wraps the internal error type.

I'm confused. The question here is if we can use the String type, because we don't want Uint16List on the API if it's actually a string.

We should use native dart types in the final interface, yes. That's different from what we use under the hood.

@robertbastian
Copy link
Member Author

I believe JS throws an FFIError type that wraps the internal error type.

The linked API throws a () error.

@Manishearth
Copy link
Member

I believe those are just FFIErrors with nothing inside them

@robertbastian
Copy link
Member Author

We should use native dart types in the final interface, yes. That's different from what we use under the hood.

The problem is that we cannot tell whether it should be a String, i.e. valid UTF-16, or a Uint16Array, which could be anything, because on the Rust side it's just &[u16].

@Manishearth
Copy link
Member

yeah we need to add a UTF16String type to diplomat.

@Manishearth
Copy link
Member

For now I would diplomat::skip UTF16 dart things and only handle the more expensive utf8 ones

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
U-flutter User: Flutter Engine or Dart SDK
Projects
None yet
Development

No branches or pull requests

2 participants