diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..e856410e --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +pkgs/intl4x/lib/src/bindings linguist-generated=true diff --git a/.github/workflows/intl4x_artifacts.yml b/.github/workflows/intl4x_artifacts.yml index ae6f7a4f..4cecc7ab 100644 --- a/.github/workflows/intl4x_artifacts.yml +++ b/.github/workflows/intl4x_artifacts.yml @@ -6,12 +6,14 @@ permissions: on: push: tags: - - 'intl4x-v.*' + - 'intl4x-icu*' + schedule: + - cron: '0 0 * * 0' # weekly workflow_dispatch: jobs: dart-libs: - name: "Build Dart binaries" + name: Build Dart binaries strategy: fail-fast: false matrix: @@ -21,7 +23,7 @@ jobs: steps: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 with: - submodules: 'true' + submodules: true - name: Install Rust toolchains run: | @@ -59,14 +61,14 @@ jobs: cd ffi/dart dart pub get cd ../.. - dart run ffi/dart/tool/build_libs.dart bin/android_arm android_arm - dart run ffi/dart/tool/build_libs.dart bin/android_arm64 android_arm64 - dart run ffi/dart/tool/build_libs.dart bin/android_ia32 android_ia32 - dart run ffi/dart/tool/build_libs.dart bin/android_x64 android_x64 - dart run ffi/dart/tool/build_libs.dart bin/linux_arm linux_arm - dart run ffi/dart/tool/build_libs.dart bin/linux_arm64 linux_arm64 - dart run ffi/dart/tool/build_libs.dart bin/linux_riscv64 linux_riscv64 - dart run ffi/dart/tool/build_libs.dart bin/linux_x64 linux_x64 + dart run ffi/dart/tool/build_libs.dart bin/android_arm android_arm dynamic default_components,experimental_components + dart run ffi/dart/tool/build_libs.dart bin/android_arm64 android_arm64 dynamic default_components,experimental_components + dart run ffi/dart/tool/build_libs.dart bin/android_ia32 android_ia32 dynamic default_components,experimental_components + dart run ffi/dart/tool/build_libs.dart bin/android_x64 android_x64 dynamic default_components,experimental_components + dart run ffi/dart/tool/build_libs.dart bin/linux_arm linux_arm dynamic default_components,experimental_components + dart run ffi/dart/tool/build_libs.dart bin/linux_arm64 linux_arm64 dynamic default_components,experimental_components + dart run ffi/dart/tool/build_libs.dart bin/linux_riscv64 linux_riscv64 dynamic default_components,experimental_components + dart run ffi/dart/tool/build_libs.dart bin/linux_x64 linux_x64 dynamic default_components,experimental_components cargo run -p icu_datagen -- --locales full --keys all --format blob --out bin/full.postcard @@ -93,11 +95,11 @@ jobs: cd ffi/dart dart pub get cd ../.. - dart run ffi/dart/tool/build_libs.dart bin/ios_arm ios_arm - dart run ffi/dart/tool/build_libs.dart bin/ios_arm64 ios_arm64 - dart run ffi/dart/tool/build_libs.dart bin/ios_x64 ios_x64 - dart run ffi/dart/tool/build_libs.dart bin/macos_arm64 macos_arm64 - dart run ffi/dart/tool/build_libs.dart bin/macos_x64 macos_x64 + dart run ffi/dart/tool/build_libs.dart bin/ios_arm ios_arm dynamic default_components,experimental_components + dart run ffi/dart/tool/build_libs.dart bin/ios_arm64 ios_arm64 dynamic default_components,experimental_components + dart run ffi/dart/tool/build_libs.dart bin/ios_x64 ios_x64 dynamic default_components,experimental_components + dart run ffi/dart/tool/build_libs.dart bin/macos_arm64 macos_arm64 dynamic default_components,experimental_components + dart run ffi/dart/tool/build_libs.dart bin/macos_x64 macos_x64 dynamic default_components,experimental_components cd provider/datagen # avoid global feature resolution rustup target add aarch64-apple-darwin @@ -119,9 +121,9 @@ jobs: cd ffi/dart dart pub get cd ../.. - dart run ffi/dart/tool/build_libs.dart bin/windows_arm64 windows_arm64 - dart run ffi/dart/tool/build_libs.dart bin/windows_ia32 windows_ia32 - dart run ffi/dart/tool/build_libs.dart bin/windows_x64 windows_x64 + dart run ffi/dart/tool/build_libs.dart bin/windows_arm64 windows_arm64 dynamic default_components,experimental_components + dart run ffi/dart/tool/build_libs.dart bin/windows_ia32 windows_ia32 dynamic default_components,experimental_components + dart run ffi/dart/tool/build_libs.dart bin/windows_x64 windows_x64 dynamic default_components,experimental_components cd provider/datagen # avoid global feature resolution rustup target add aarch64-pc-windows-msvc @@ -155,4 +157,4 @@ jobs: with: files: '**' fail_on_unmatched_files: true - body: "Build artifacts for `package:intl4x`, based on ICU4X at ref ${{ env.icu_version }}" + body: "Build artifacts for `package:intl4x`, based on ICU4X at ref ${{ github.ref_name }}" diff --git a/pkgs/intl4x/CHANGELOG.md b/pkgs/intl4x/CHANGELOG.md index 3d446163..64b06e3d 100644 --- a/pkgs/intl4x/CHANGELOG.md +++ b/pkgs/intl4x/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.9.2-wip + +- Copy files instead of symlinking, for easier upgrading. + ## 0.9.1 - Small fixes in imports diff --git a/pkgs/intl4x/lib/src/bindings/AnyCalendarKind.g.dart b/pkgs/intl4x/lib/src/bindings/AnyCalendarKind.g.dart deleted file mode 120000 index 17e72902..00000000 --- a/pkgs/intl4x/lib/src/bindings/AnyCalendarKind.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/AnyCalendarKind.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/AnyCalendarKind.g.dart b/pkgs/intl4x/lib/src/bindings/AnyCalendarKind.g.dart new file mode 100644 index 00000000..c6e32996 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/AnyCalendarKind.g.dart @@ -0,0 +1,128 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// The various calendar types currently supported by [`Calendar`] +/// +/// See the [Rust documentation for `AnyCalendarKind`](https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendarKind.html) for more information. +enum AnyCalendarKind { + /// The kind of an Iso calendar + iso, + + /// The kind of a Gregorian calendar + gregorian, + + /// The kind of a Buddhist calendar + buddhist, + + /// The kind of a Japanese calendar with modern eras + japanese, + + /// The kind of a Japanese calendar with modern and historic eras + japaneseExtended, + + /// The kind of an Ethiopian calendar, with Amete Mihret era + ethiopian, + + /// The kind of an Ethiopian calendar, with Amete Alem era + ethiopianAmeteAlem, + + /// The kind of a Indian calendar + indian, + + /// The kind of a Coptic calendar + coptic, + + /// The kind of a Dangi calendar + dangi, + + /// The kind of a Chinese calendar + chinese, + + /// The kind of a Hebrew calendar + hebrew, + + /// The kind of a Islamic civil calendar + islamicCivil, + + /// The kind of a Islamic observational calendar + islamicObservational, + + /// The kind of a Islamic tabular calendar + islamicTabular, + + /// The kind of a Islamic Umm al-Qura calendar + islamicUmmAlQura, + + /// The kind of a Persian calendar + persian, + + /// The kind of a Roc calendar + roc; + + /// Read the calendar type off of the -u-ca- extension on a locale. + /// + /// Returns nothing if there is no calendar on the locale or if the locale's calendar + /// is not known or supported. + /// + /// See the [Rust documentation for `get_for_locale`](https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendarKind.html#method.get_for_locale) for more information. + static AnyCalendarKind? getForLocale(Locale locale) { + final result = _ICU4XAnyCalendarKind_get_for_locale(locale._ffi); + if (!result.isOk) { + return null; + } + return AnyCalendarKind.values[result.union.ok]; + } + + /// Obtain the calendar type given a BCP-47 -u-ca- extension string. + /// + /// Returns nothing if the calendar is not known or supported. + /// + /// See the [Rust documentation for `get_for_bcp47_value`](https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendarKind.html#method.get_for_bcp47_value) for more information. + static AnyCalendarKind? getForBcp47(String s) { + final temp = ffi2.Arena(); + final sView = s.utf8View; + final result = + _ICU4XAnyCalendarKind_get_for_bcp47(sView.allocIn(temp), sView.length); + temp.releaseAll(); + if (!result.isOk) { + return null; + } + return AnyCalendarKind.values[result.union.ok]; + } + + /// Obtain the string suitable for use in the -u-ca- extension in a BCP47 locale. + /// + /// See the [Rust documentation for `as_bcp47_string`](https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendarKind.html#method.as_bcp47_string) for more information. + /// + /// Throws [Error] on failure. + String get bcp47 { + final writeable = _Writeable(); + final result = _ICU4XAnyCalendarKind_bcp47(index, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } +} + +@meta.ResourceIdentifier('ICU4XAnyCalendarKind_get_for_locale') +@ffi.Native<_ResultInt32Void Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XAnyCalendarKind_get_for_locale') +// ignore: non_constant_identifier_names +external _ResultInt32Void _ICU4XAnyCalendarKind_get_for_locale( + ffi.Pointer locale); + +@meta.ResourceIdentifier('ICU4XAnyCalendarKind_get_for_bcp47') +@ffi.Native<_ResultInt32Void Function(ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XAnyCalendarKind_get_for_bcp47') +// ignore: non_constant_identifier_names +external _ResultInt32Void _ICU4XAnyCalendarKind_get_for_bcp47( + ffi.Pointer sData, int sLength); + +@meta.ResourceIdentifier('ICU4XAnyCalendarKind_bcp47') +@ffi.Native<_ResultVoidInt32 Function(ffi.Int32, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XAnyCalendarKind_bcp47') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XAnyCalendarKind_bcp47( + int self, ffi.Pointer writeable); diff --git a/pkgs/intl4x/lib/src/bindings/Bcp47ToIanaMapper.g.dart b/pkgs/intl4x/lib/src/bindings/Bcp47ToIanaMapper.g.dart deleted file mode 120000 index 5c63dc36..00000000 --- a/pkgs/intl4x/lib/src/bindings/Bcp47ToIanaMapper.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/Bcp47ToIanaMapper.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/Bcp47ToIanaMapper.g.dart b/pkgs/intl4x/lib/src/bindings/Bcp47ToIanaMapper.g.dart new file mode 100644 index 00000000..60f3c545 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/Bcp47ToIanaMapper.g.dart @@ -0,0 +1,81 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An object capable of mapping from a BCP-47 time zone ID to an IANA ID. +/// +/// See the [Rust documentation for `IanaBcp47RoundTripMapper`](https://docs.rs/icu/latest/icu/timezone/struct.IanaBcp47RoundTripMapper.html) for more information. +final class Bcp47ToIanaMapper implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + Bcp47ToIanaMapper._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XBcp47ToIanaMapper_destroy)); + + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/timezone/struct.IanaBcp47RoundTripMapper.html#method.new) for more information. + /// + /// Throws [Error] on failure. + factory Bcp47ToIanaMapper(DataProvider provider) { + final result = _ICU4XBcp47ToIanaMapper_create(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return Bcp47ToIanaMapper._fromFfi(result.union.ok, []); + } + + /// Writes out the canonical IANA time zone ID corresponding to the given BCP-47 ID. + /// + /// See the [Rust documentation for `bcp47_to_iana`](https://docs.rs/icu/latest/icu/timezone/struct.IanaBcp47RoundTripMapperBorrowed.html#method.bcp47_to_iana) for more information. + /// + /// Throws [Error] on failure. + String operator [](String value) { + final temp = ffi2.Arena(); + final valueView = value.utf8View; + final writeable = _Writeable(); + final result = _ICU4XBcp47ToIanaMapper_get( + _ffi, valueView.allocIn(temp), valueView.length, writeable._ffi); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } +} + +@meta.ResourceIdentifier('ICU4XBcp47ToIanaMapper_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XBcp47ToIanaMapper_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XBcp47ToIanaMapper_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XBcp47ToIanaMapper_create') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XBcp47ToIanaMapper_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XBcp47ToIanaMapper_create( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XBcp47ToIanaMapper_get') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Size, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XBcp47ToIanaMapper_get') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XBcp47ToIanaMapper_get( + ffi.Pointer self, + ffi.Pointer valueData, + int valueLength, + ffi.Pointer writeable); diff --git a/pkgs/intl4x/lib/src/bindings/Bidi.g.dart b/pkgs/intl4x/lib/src/bindings/Bidi.g.dart deleted file mode 120000 index c4fc1297..00000000 --- a/pkgs/intl4x/lib/src/bindings/Bidi.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/Bidi.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/Bidi.g.dart b/pkgs/intl4x/lib/src/bindings/Bidi.g.dart new file mode 100644 index 00000000..d445de3f --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/Bidi.g.dart @@ -0,0 +1,170 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X Bidi object, containing loaded bidi data +/// +/// See the [Rust documentation for `BidiClassAdapter`](https://docs.rs/icu/latest/icu/properties/bidi/struct.BidiClassAdapter.html) for more information. +final class Bidi implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + Bidi._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XBidi_destroy)); + + /// Creates a new [`Bidi`] from locale data. + /// + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/properties/bidi/struct.BidiClassAdapter.html#method.new) for more information. + /// + /// Throws [Error] on failure. + factory Bidi(DataProvider provider) { + final result = _ICU4XBidi_create(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return Bidi._fromFfi(result.union.ok, []); + } + + /// Use the data loaded in this object to process a string and calculate bidi information + /// + /// Takes in a Level for the default level, if it is an invalid value it will default to LTR + /// + /// See the [Rust documentation for `new_with_data_source`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.BidiInfo.html#method.new_with_data_source) for more information. + BidiInfo forText(String text, int defaultLevel) { + final textView = text.utf8View; + final textArena = _FinalizedArena(); + // This lifetime edge depends on lifetimes: 'text + core.List textEdges = [textArena]; + final result = _ICU4XBidi_for_text( + _ffi, textView.allocIn(textArena.arena), textView.length, defaultLevel); + return BidiInfo._fromFfi(result, [], textEdges); + } + + /// Utility function for producing reorderings given a list of levels + /// + /// Produces a map saying which visual index maps to which source index. + /// + /// The levels array must not have values greater than 126 (this is the + /// Bidi maximum explicit depth plus one). + /// Failure to follow this invariant may lead to incorrect results, + /// but is still safe. + /// + /// See the [Rust documentation for `reorder_visual`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.BidiInfo.html#method.reorder_visual) for more information. + ReorderedIndexMap reorderVisual(core.List levels) { + final temp = ffi2.Arena(); + final levelsView = levels.uint8View; + final result = _ICU4XBidi_reorder_visual( + _ffi, levelsView.allocIn(temp), levelsView.length); + temp.releaseAll(); + return ReorderedIndexMap._fromFfi(result, []); + } + + /// Check if a Level returned by level_at is an RTL level. + /// + /// Invalid levels (numbers greater than 125) will be assumed LTR + /// + /// See the [Rust documentation for `is_rtl`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Level.html#method.is_rtl) for more information. + static bool levelIsRtl(int level) { + final result = _ICU4XBidi_level_is_rtl(level); + return result; + } + + /// Check if a Level returned by level_at is an LTR level. + /// + /// Invalid levels (numbers greater than 125) will be assumed LTR + /// + /// See the [Rust documentation for `is_ltr`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Level.html#method.is_ltr) for more information. + static bool levelIsLtr(int level) { + final result = _ICU4XBidi_level_is_ltr(level); + return result; + } + + /// Get a basic RTL Level value + /// + /// See the [Rust documentation for `rtl`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Level.html#method.rtl) for more information. + static int levelRtl() { + final result = _ICU4XBidi_level_rtl(); + return result; + } + + /// Get a simple LTR Level value + /// + /// See the [Rust documentation for `ltr`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Level.html#method.ltr) for more information. + static int levelLtr() { + final result = _ICU4XBidi_level_ltr(); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XBidi_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XBidi_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XBidi_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XBidi_create') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XBidi_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XBidi_create(ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XBidi_for_text') +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size, + ffi.Uint8)>(isLeaf: true, symbol: 'ICU4XBidi_for_text') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XBidi_for_text( + ffi.Pointer self, + ffi.Pointer textData, + int textLength, + int defaultLevel); + +@meta.ResourceIdentifier('ICU4XBidi_reorder_visual') +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size)>(isLeaf: true, symbol: 'ICU4XBidi_reorder_visual') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XBidi_reorder_visual( + ffi.Pointer self, + ffi.Pointer levelsData, + int levelsLength); + +@meta.ResourceIdentifier('ICU4XBidi_level_is_rtl') +@ffi.Native( + isLeaf: true, symbol: 'ICU4XBidi_level_is_rtl') +// ignore: non_constant_identifier_names +external bool _ICU4XBidi_level_is_rtl(int level); + +@meta.ResourceIdentifier('ICU4XBidi_level_is_ltr') +@ffi.Native( + isLeaf: true, symbol: 'ICU4XBidi_level_is_ltr') +// ignore: non_constant_identifier_names +external bool _ICU4XBidi_level_is_ltr(int level); + +@meta.ResourceIdentifier('ICU4XBidi_level_rtl') +@ffi.Native(isLeaf: true, symbol: 'ICU4XBidi_level_rtl') +// ignore: non_constant_identifier_names +external int _ICU4XBidi_level_rtl(); + +@meta.ResourceIdentifier('ICU4XBidi_level_ltr') +@ffi.Native(isLeaf: true, symbol: 'ICU4XBidi_level_ltr') +// ignore: non_constant_identifier_names +external int _ICU4XBidi_level_ltr(); diff --git a/pkgs/intl4x/lib/src/bindings/BidiDirection.g.dart b/pkgs/intl4x/lib/src/bindings/BidiDirection.g.dart deleted file mode 120000 index 9c547e57..00000000 --- a/pkgs/intl4x/lib/src/bindings/BidiDirection.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/BidiDirection.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/BidiDirection.g.dart b/pkgs/intl4x/lib/src/bindings/BidiDirection.g.dart new file mode 100644 index 00000000..a18133e6 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/BidiDirection.g.dart @@ -0,0 +1,11 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +enum BidiDirection { + ltr, + + rtl, + + mixed; +} diff --git a/pkgs/intl4x/lib/src/bindings/BidiInfo.g.dart b/pkgs/intl4x/lib/src/bindings/BidiInfo.g.dart deleted file mode 120000 index 791bc8ff..00000000 --- a/pkgs/intl4x/lib/src/bindings/BidiInfo.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/BidiInfo.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/BidiInfo.g.dart b/pkgs/intl4x/lib/src/bindings/BidiInfo.g.dart new file mode 100644 index 00000000..11f5de41 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/BidiInfo.g.dart @@ -0,0 +1,93 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An object containing bidi information for a given string, produced by `for_text()` on `Bidi` +/// +/// See the [Rust documentation for `BidiInfo`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.BidiInfo.html) for more information. +final class BidiInfo implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _textEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + BidiInfo._fromFfi(this._ffi, this._selfEdge, this._textEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XBidiInfo_destroy)); + + /// The number of paragraphs contained here + int get paragraphCount { + final result = _ICU4XBidiInfo_paragraph_count(_ffi); + return result; + } + + /// Get the nth paragraph, returning `None` if out of bounds + BidiParagraph? paragraphAt(int n) { + // This lifetime edge depends on lifetimes: 'text + core.List textEdges = [this]; + final result = _ICU4XBidiInfo_paragraph_at(_ffi, n); + return result.address == 0 + ? null + : BidiParagraph._fromFfi(result, [], textEdges); + } + + /// The number of bytes in this full text + int get size { + final result = _ICU4XBidiInfo_size(_ffi); + return result; + } + + /// Get the BIDI level at a particular byte index in the full text. + /// This integer is conceptually a `unicode_bidi::Level`, + /// and can be further inspected using the static methods on ICU4XBidi. + /// + /// Returns 0 (equivalent to `Level::ltr()`) on error + int levelAt(int pos) { + final result = _ICU4XBidiInfo_level_at(_ffi, pos); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XBidiInfo_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XBidiInfo_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XBidiInfo_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XBidiInfo_paragraph_count') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XBidiInfo_paragraph_count') +// ignore: non_constant_identifier_names +external int _ICU4XBidiInfo_paragraph_count(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XBidiInfo_paragraph_at') +@ffi.Native< + ffi.Pointer Function(ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XBidiInfo_paragraph_at') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XBidiInfo_paragraph_at( + ffi.Pointer self, int n); + +@meta.ResourceIdentifier('ICU4XBidiInfo_size') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XBidiInfo_size') +// ignore: non_constant_identifier_names +external int _ICU4XBidiInfo_size(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XBidiInfo_level_at') +@ffi.Native, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XBidiInfo_level_at') +// ignore: non_constant_identifier_names +external int _ICU4XBidiInfo_level_at(ffi.Pointer self, int pos); diff --git a/pkgs/intl4x/lib/src/bindings/BidiParagraph.g.dart b/pkgs/intl4x/lib/src/bindings/BidiParagraph.g.dart deleted file mode 120000 index 29b7658b..00000000 --- a/pkgs/intl4x/lib/src/bindings/BidiParagraph.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/BidiParagraph.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/BidiParagraph.g.dart b/pkgs/intl4x/lib/src/bindings/BidiParagraph.g.dart new file mode 100644 index 00000000..3d49b0d4 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/BidiParagraph.g.dart @@ -0,0 +1,153 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// Bidi information for a single processed paragraph +final class BidiParagraph implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _infoEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + BidiParagraph._fromFfi(this._ffi, this._selfEdge, this._infoEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XBidiParagraph_destroy)); + + /// Given a paragraph index `n` within the surrounding text, this sets this + /// object to the paragraph at that index. Returns `Error::OutOfBoundsError` when out of bounds. + /// + /// This is equivalent to calling `paragraph_at()` on `BidiInfo` but doesn't + /// create a new object + /// + /// Throws [Error] on failure. + void setParagraphInText(int n) { + final result = _ICU4XBidiParagraph_set_paragraph_in_text(_ffi, n); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// The primary direction of this paragraph + /// + /// See the [Rust documentation for `level_at`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Paragraph.html#method.level_at) for more information. + BidiDirection get direction { + final result = _ICU4XBidiParagraph_direction(_ffi); + return BidiDirection.values[result]; + } + + /// The number of bytes in this paragraph + /// + /// See the [Rust documentation for `len`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.ParagraphInfo.html#method.len) for more information. + int get size { + final result = _ICU4XBidiParagraph_size(_ffi); + return result; + } + + /// The start index of this paragraph within the source text + int get rangeStart { + final result = _ICU4XBidiParagraph_range_start(_ffi); + return result; + } + + /// The end index of this paragraph within the source text + int get rangeEnd { + final result = _ICU4XBidiParagraph_range_end(_ffi); + return result; + } + + /// Reorder a line based on display order. The ranges are specified relative to the source text and must be contained + /// within this paragraph's range. + /// + /// See the [Rust documentation for `level_at`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Paragraph.html#method.level_at) for more information. + /// + /// Throws [Error] on failure. + String reorderLine(int rangeStart, int rangeEnd) { + final writeable = _Writeable(); + final result = _ICU4XBidiParagraph_reorder_line( + _ffi, rangeStart, rangeEnd, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Get the BIDI level at a particular byte index in this paragraph. + /// This integer is conceptually a `unicode_bidi::Level`, + /// and can be further inspected using the static methods on ICU4XBidi. + /// + /// Returns 0 (equivalent to `Level::ltr()`) on error + /// + /// See the [Rust documentation for `level_at`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Paragraph.html#method.level_at) for more information. + int levelAt(int pos) { + final result = _ICU4XBidiParagraph_level_at(_ffi, pos); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XBidiParagraph_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XBidiParagraph_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XBidiParagraph_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XBidiParagraph_set_paragraph_in_text') +@ffi.Native<_ResultVoidInt32 Function(ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XBidiParagraph_set_paragraph_in_text') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XBidiParagraph_set_paragraph_in_text( + ffi.Pointer self, int n); + +@meta.ResourceIdentifier('ICU4XBidiParagraph_direction') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XBidiParagraph_direction') +// ignore: non_constant_identifier_names +external int _ICU4XBidiParagraph_direction(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XBidiParagraph_size') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XBidiParagraph_size') +// ignore: non_constant_identifier_names +external int _ICU4XBidiParagraph_size(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XBidiParagraph_range_start') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XBidiParagraph_range_start') +// ignore: non_constant_identifier_names +external int _ICU4XBidiParagraph_range_start(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XBidiParagraph_range_end') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XBidiParagraph_range_end') +// ignore: non_constant_identifier_names +external int _ICU4XBidiParagraph_range_end(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XBidiParagraph_reorder_line') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, ffi.Size, ffi.Size, + ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XBidiParagraph_reorder_line') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XBidiParagraph_reorder_line( + ffi.Pointer self, + int rangeStart, + int rangeEnd, + ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XBidiParagraph_level_at') +@ffi.Native, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XBidiParagraph_level_at') +// ignore: non_constant_identifier_names +external int _ICU4XBidiParagraph_level_at( + ffi.Pointer self, int pos); diff --git a/pkgs/intl4x/lib/src/bindings/Calendar.g.dart b/pkgs/intl4x/lib/src/bindings/Calendar.g.dart deleted file mode 120000 index c6e993d0..00000000 --- a/pkgs/intl4x/lib/src/bindings/Calendar.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/Calendar.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/Calendar.g.dart b/pkgs/intl4x/lib/src/bindings/Calendar.g.dart new file mode 100644 index 00000000..4bc1fb27 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/Calendar.g.dart @@ -0,0 +1,87 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `AnyCalendar`](https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendar.html) for more information. +final class Calendar implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + Calendar._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XCalendar_destroy)); + + /// Creates a new [`Calendar`] from the specified date and time. + /// + /// See the [Rust documentation for `new_for_locale`](https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendar.html#method.new_for_locale) for more information. + /// + /// Throws [Error] on failure. + factory Calendar.forLocale(DataProvider provider, Locale locale) { + final result = _ICU4XCalendar_create_for_locale(provider._ffi, locale._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return Calendar._fromFfi(result.union.ok, []); + } + + /// Creates a new [`Calendar`] from the specified date and time. + /// + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendar.html#method.new) for more information. + /// + /// Throws [Error] on failure. + factory Calendar.forKind(DataProvider provider, AnyCalendarKind kind) { + final result = _ICU4XCalendar_create_for_kind(provider._ffi, kind.index); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return Calendar._fromFfi(result.union.ok, []); + } + + /// Returns the kind of this calendar + /// + /// See the [Rust documentation for `kind`](https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendar.html#method.kind) for more information. + AnyCalendarKind get kind { + final result = _ICU4XCalendar_kind(_ffi); + return AnyCalendarKind.values[result]; + } +} + +@meta.ResourceIdentifier('ICU4XCalendar_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCalendar_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XCalendar_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCalendar_create_for_locale') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCalendar_create_for_locale') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCalendar_create_for_locale( + ffi.Pointer provider, ffi.Pointer locale); + +@meta.ResourceIdentifier('ICU4XCalendar_create_for_kind') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XCalendar_create_for_kind') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCalendar_create_for_kind( + ffi.Pointer provider, int kind); + +@meta.ResourceIdentifier('ICU4XCalendar_kind') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCalendar_kind') +// ignore: non_constant_identifier_names +external int _ICU4XCalendar_kind(ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/CanonicalCombiningClassMap.g.dart b/pkgs/intl4x/lib/src/bindings/CanonicalCombiningClassMap.g.dart deleted file mode 120000 index 4b2a1127..00000000 --- a/pkgs/intl4x/lib/src/bindings/CanonicalCombiningClassMap.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CanonicalCombiningClassMap.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CanonicalCombiningClassMap.g.dart b/pkgs/intl4x/lib/src/bindings/CanonicalCombiningClassMap.g.dart new file mode 100644 index 00000000..78c367c9 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CanonicalCombiningClassMap.g.dart @@ -0,0 +1,69 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// Lookup of the Canonical_Combining_Class Unicode property +/// +/// See the [Rust documentation for `CanonicalCombiningClassMap`](https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalCombiningClassMap.html) for more information. +final class CanonicalCombiningClassMap implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + CanonicalCombiningClassMap._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XCanonicalCombiningClassMap_destroy)); + + /// Construct a new ICU4XCanonicalCombiningClassMap instance for NFC + /// + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalCombiningClassMap.html#method.new) for more information. + /// + /// Throws [Error] on failure. + factory CanonicalCombiningClassMap(DataProvider provider) { + final result = _ICU4XCanonicalCombiningClassMap_create(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CanonicalCombiningClassMap._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `get`](https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalCombiningClassMap.html#method.get) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/properties/properties/struct.CanonicalCombiningClass.html) + int operator [](Rune ch) { + final result = _ICU4XCanonicalCombiningClassMap_get(_ffi, ch); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XCanonicalCombiningClassMap_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCanonicalCombiningClassMap_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XCanonicalCombiningClassMap_destroy( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCanonicalCombiningClassMap_create') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCanonicalCombiningClassMap_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCanonicalCombiningClassMap_create( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCanonicalCombiningClassMap_get') +@ffi.Native, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCanonicalCombiningClassMap_get') +// ignore: non_constant_identifier_names +external int _ICU4XCanonicalCombiningClassMap_get( + ffi.Pointer self, Rune ch); diff --git a/pkgs/intl4x/lib/src/bindings/CanonicalComposition.g.dart b/pkgs/intl4x/lib/src/bindings/CanonicalComposition.g.dart deleted file mode 120000 index 445efcb4..00000000 --- a/pkgs/intl4x/lib/src/bindings/CanonicalComposition.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CanonicalComposition.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CanonicalComposition.g.dart b/pkgs/intl4x/lib/src/bindings/CanonicalComposition.g.dart new file mode 100644 index 00000000..98aff8fc --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CanonicalComposition.g.dart @@ -0,0 +1,72 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// The raw canonical composition operation. +/// +/// Callers should generally use ICU4XComposingNormalizer unless they specifically need raw composition operations +/// +/// See the [Rust documentation for `CanonicalComposition`](https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalComposition.html) for more information. +final class CanonicalComposition implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + CanonicalComposition._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XCanonicalComposition_destroy)); + + /// Construct a new ICU4XCanonicalComposition instance for NFC + /// + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalComposition.html#method.new) for more information. + /// + /// Throws [Error] on failure. + factory CanonicalComposition(DataProvider provider) { + final result = _ICU4XCanonicalComposition_create(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CanonicalComposition._fromFfi(result.union.ok, []); + } + + /// Performs canonical composition (including Hangul) on a pair of characters + /// or returns NUL if these characters don’t compose. Composition exclusions are taken into account. + /// + /// See the [Rust documentation for `compose`](https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalComposition.html#method.compose) for more information. + Rune compose(Rune starter, Rune second) { + final result = _ICU4XCanonicalComposition_compose(_ffi, starter, second); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XCanonicalComposition_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCanonicalComposition_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XCanonicalComposition_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCanonicalComposition_create') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCanonicalComposition_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCanonicalComposition_create( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCanonicalComposition_compose') +@ffi.Native< + ffi.Uint32 Function(ffi.Pointer, ffi.Uint32, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCanonicalComposition_compose') +// ignore: non_constant_identifier_names +external Rune _ICU4XCanonicalComposition_compose( + ffi.Pointer self, Rune starter, Rune second); diff --git a/pkgs/intl4x/lib/src/bindings/CanonicalDecomposition.g.dart b/pkgs/intl4x/lib/src/bindings/CanonicalDecomposition.g.dart deleted file mode 120000 index b6b8809e..00000000 --- a/pkgs/intl4x/lib/src/bindings/CanonicalDecomposition.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CanonicalDecomposition.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CanonicalDecomposition.g.dart b/pkgs/intl4x/lib/src/bindings/CanonicalDecomposition.g.dart new file mode 100644 index 00000000..f027f348 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CanonicalDecomposition.g.dart @@ -0,0 +1,70 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// The raw (non-recursive) canonical decomposition operation. +/// +/// Callers should generally use ICU4XDecomposingNormalizer unless they specifically need raw composition operations +/// +/// See the [Rust documentation for `CanonicalDecomposition`](https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalDecomposition.html) for more information. +final class CanonicalDecomposition implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + CanonicalDecomposition._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XCanonicalDecomposition_destroy)); + + /// Construct a new ICU4XCanonicalDecomposition instance for NFC + /// + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalDecomposition.html#method.new) for more information. + /// + /// Throws [Error] on failure. + factory CanonicalDecomposition(DataProvider provider) { + final result = _ICU4XCanonicalDecomposition_create(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CanonicalDecomposition._fromFfi(result.union.ok, []); + } + + /// Performs non-recursive canonical decomposition (including for Hangul). + /// + /// See the [Rust documentation for `decompose`](https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalDecomposition.html#method.decompose) for more information. + Decomposed decompose(Rune c) { + final result = _ICU4XCanonicalDecomposition_decompose(_ffi, c); + return Decomposed._fromFfi(result); + } +} + +@meta.ResourceIdentifier('ICU4XCanonicalDecomposition_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCanonicalDecomposition_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XCanonicalDecomposition_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCanonicalDecomposition_create') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCanonicalDecomposition_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCanonicalDecomposition_create( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCanonicalDecomposition_decompose') +@ffi.Native<_DecomposedFfi Function(ffi.Pointer, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCanonicalDecomposition_decompose') +// ignore: non_constant_identifier_names +external _DecomposedFfi _ICU4XCanonicalDecomposition_decompose( + ffi.Pointer self, Rune c); diff --git a/pkgs/intl4x/lib/src/bindings/CaseMapCloser.g.dart b/pkgs/intl4x/lib/src/bindings/CaseMapCloser.g.dart deleted file mode 120000 index f2126f85..00000000 --- a/pkgs/intl4x/lib/src/bindings/CaseMapCloser.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CaseMapCloser.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CaseMapCloser.g.dart b/pkgs/intl4x/lib/src/bindings/CaseMapCloser.g.dart new file mode 100644 index 00000000..b2de635d --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CaseMapCloser.g.dart @@ -0,0 +1,95 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `CaseMapCloser`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapCloser.html) for more information. +final class CaseMapCloser implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + CaseMapCloser._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XCaseMapCloser_destroy)); + + /// Construct a new ICU4XCaseMapper instance + /// + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapCloser.html#method.new) for more information. + /// + /// Throws [Error] on failure. + factory CaseMapCloser(DataProvider provider) { + final result = _ICU4XCaseMapCloser_create(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CaseMapCloser._fromFfi(result.union.ok, []); + } + + /// Adds all simple case mappings and the full case folding for `c` to `builder`. + /// Also adds special case closure mappings. + /// + /// See the [Rust documentation for `add_case_closure_to`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapCloser.html#method.add_case_closure_to) for more information. + void addCaseClosureTo(Rune c, CodePointSetBuilder builder) { + _ICU4XCaseMapCloser_add_case_closure_to(_ffi, c, builder._ffi); + } + + /// Finds all characters and strings which may casemap to `s` as their full case folding string + /// and adds them to the set. + /// + /// Returns true if the string was found + /// + /// See the [Rust documentation for `add_string_case_closure_to`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapCloser.html#method.add_string_case_closure_to) for more information. + bool addStringCaseClosureTo(String s, CodePointSetBuilder builder) { + final temp = ffi2.Arena(); + final sView = s.utf8View; + final result = _ICU4XCaseMapCloser_add_string_case_closure_to( + _ffi, sView.allocIn(temp), sView.length, builder._ffi); + temp.releaseAll(); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XCaseMapCloser_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCaseMapCloser_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XCaseMapCloser_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCaseMapCloser_create') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCaseMapCloser_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCaseMapCloser_create( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCaseMapCloser_add_case_closure_to') +@ffi.Native< + ffi.Void Function( + ffi.Pointer, ffi.Uint32, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCaseMapCloser_add_case_closure_to') +// ignore: non_constant_identifier_names +external void _ICU4XCaseMapCloser_add_case_closure_to( + ffi.Pointer self, Rune c, ffi.Pointer builder); + +@meta.ResourceIdentifier('ICU4XCaseMapCloser_add_string_case_closure_to') +@ffi.Native< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Size, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCaseMapCloser_add_string_case_closure_to') +// ignore: non_constant_identifier_names +external bool _ICU4XCaseMapCloser_add_string_case_closure_to( + ffi.Pointer self, + ffi.Pointer sData, + int sLength, + ffi.Pointer builder); diff --git a/pkgs/intl4x/lib/src/bindings/CaseMapper.g.dart b/pkgs/intl4x/lib/src/bindings/CaseMapper.g.dart deleted file mode 120000 index 6b7d0d36..00000000 --- a/pkgs/intl4x/lib/src/bindings/CaseMapper.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CaseMapper.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CaseMapper.g.dart b/pkgs/intl4x/lib/src/bindings/CaseMapper.g.dart new file mode 100644 index 00000000..2f9b7014 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CaseMapper.g.dart @@ -0,0 +1,353 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `CaseMapper`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapper.html) for more information. +final class CaseMapper implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + CaseMapper._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XCaseMapper_destroy)); + + /// Construct a new ICU4XCaseMapper instance + /// + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapper.html#method.new) for more information. + /// + /// Throws [Error] on failure. + factory CaseMapper(DataProvider provider) { + final result = _ICU4XCaseMapper_create(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CaseMapper._fromFfi(result.union.ok, []); + } + + /// Returns the full lowercase mapping of the given string + /// + /// See the [Rust documentation for `lowercase`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapper.html#method.lowercase) for more information. + /// + /// Throws [Error] on failure. + String lowercase(String s, Locale locale) { + final temp = ffi2.Arena(); + final sView = s.utf8View; + final writeable = _Writeable(); + final result = _ICU4XCaseMapper_lowercase( + _ffi, sView.allocIn(temp), sView.length, locale._ffi, writeable._ffi); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Returns the full uppercase mapping of the given string + /// + /// See the [Rust documentation for `uppercase`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapper.html#method.uppercase) for more information. + /// + /// Throws [Error] on failure. + String uppercase(String s, Locale locale) { + final temp = ffi2.Arena(); + final sView = s.utf8View; + final writeable = _Writeable(); + final result = _ICU4XCaseMapper_uppercase( + _ffi, sView.allocIn(temp), sView.length, locale._ffi, writeable._ffi); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Returns the full titlecase mapping of the given string, performing head adjustment without + /// loading additional data. + /// (if head adjustment is enabled in the options) + /// + /// The `v1` refers to the version of the options struct, which may change as we add more options + /// + /// See the [Rust documentation for `titlecase_segment_with_only_case_data`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapper.html#method.titlecase_segment_with_only_case_data) for more information. + /// + /// Throws [Error] on failure. + String titlecaseSegmentWithOnlyCaseData( + String s, Locale locale, TitlecaseOptions options) { + final temp = ffi2.Arena(); + final sView = s.utf8View; + final writeable = _Writeable(); + final result = _ICU4XCaseMapper_titlecase_segment_with_only_case_data_v1( + _ffi, + sView.allocIn(temp), + sView.length, + locale._ffi, + options._toFfi(temp), + writeable._ffi); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Case-folds the characters in the given string + /// + /// See the [Rust documentation for `fold`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapper.html#method.fold) for more information. + /// + /// Throws [Error] on failure. + String fold(String s) { + final temp = ffi2.Arena(); + final sView = s.utf8View; + final writeable = _Writeable(); + final result = _ICU4XCaseMapper_fold( + _ffi, sView.allocIn(temp), sView.length, writeable._ffi); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Case-folds the characters in the given string + /// using Turkic (T) mappings for dotted/dotless I. + /// + /// See the [Rust documentation for `fold_turkic`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapper.html#method.fold_turkic) for more information. + /// + /// Throws [Error] on failure. + String foldTurkic(String s) { + final temp = ffi2.Arena(); + final sView = s.utf8View; + final writeable = _Writeable(); + final result = _ICU4XCaseMapper_fold_turkic( + _ffi, sView.allocIn(temp), sView.length, writeable._ffi); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Adds all simple case mappings and the full case folding for `c` to `builder`. + /// Also adds special case closure mappings. + /// + /// In other words, this adds all characters that this casemaps to, as + /// well as all characters that may casemap to this one. + /// + /// Note that since ICU4XCodePointSetBuilder does not contain strings, this will + /// ignore string mappings. + /// + /// Identical to the similarly named method on `CaseMapCloser`, use that if you + /// plan on using string case closure mappings too. + /// + /// See the [Rust documentation for `add_case_closure_to`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapper.html#method.add_case_closure_to) for more information. + void addCaseClosureTo(Rune c, CodePointSetBuilder builder) { + _ICU4XCaseMapper_add_case_closure_to(_ffi, c, builder._ffi); + } + + /// Returns the simple lowercase mapping of the given character. + /// + /// This function only implements simple and common mappings. + /// Full mappings, which can map one char to a string, are not included. + /// For full mappings, use `CaseMapper::lowercase`. + /// + /// See the [Rust documentation for `simple_lowercase`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapper.html#method.simple_lowercase) for more information. + Rune simpleLowercase(Rune ch) { + final result = _ICU4XCaseMapper_simple_lowercase(_ffi, ch); + return result; + } + + /// Returns the simple uppercase mapping of the given character. + /// + /// This function only implements simple and common mappings. + /// Full mappings, which can map one char to a string, are not included. + /// For full mappings, use `CaseMapper::uppercase`. + /// + /// See the [Rust documentation for `simple_uppercase`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapper.html#method.simple_uppercase) for more information. + Rune simpleUppercase(Rune ch) { + final result = _ICU4XCaseMapper_simple_uppercase(_ffi, ch); + return result; + } + + /// Returns the simple titlecase mapping of the given character. + /// + /// This function only implements simple and common mappings. + /// Full mappings, which can map one char to a string, are not included. + /// For full mappings, use `CaseMapper::titlecase_segment`. + /// + /// See the [Rust documentation for `simple_titlecase`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapper.html#method.simple_titlecase) for more information. + Rune simpleTitlecase(Rune ch) { + final result = _ICU4XCaseMapper_simple_titlecase(_ffi, ch); + return result; + } + + /// Returns the simple casefolding of the given character. + /// + /// This function only implements simple folding. + /// For full folding, use `CaseMapper::fold`. + /// + /// See the [Rust documentation for `simple_fold`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapper.html#method.simple_fold) for more information. + Rune simpleFold(Rune ch) { + final result = _ICU4XCaseMapper_simple_fold(_ffi, ch); + return result; + } + + /// Returns the simple casefolding of the given character in the Turkic locale + /// + /// This function only implements simple folding. + /// For full folding, use `CaseMapper::fold_turkic`. + /// + /// See the [Rust documentation for `simple_fold_turkic`](https://docs.rs/icu/latest/icu/casemap/struct.CaseMapper.html#method.simple_fold_turkic) for more information. + Rune simpleFoldTurkic(Rune ch) { + final result = _ICU4XCaseMapper_simple_fold_turkic(_ffi, ch); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XCaseMapper_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCaseMapper_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XCaseMapper_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCaseMapper_create') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCaseMapper_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCaseMapper_create( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCaseMapper_lowercase') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size, + ffi.Pointer, + ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCaseMapper_lowercase') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XCaseMapper_lowercase( + ffi.Pointer self, + ffi.Pointer sData, + int sLength, + ffi.Pointer locale, + ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XCaseMapper_uppercase') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size, + ffi.Pointer, + ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCaseMapper_uppercase') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XCaseMapper_uppercase( + ffi.Pointer self, + ffi.Pointer sData, + int sLength, + ffi.Pointer locale, + ffi.Pointer writeable); + +@meta.ResourceIdentifier( + 'ICU4XCaseMapper_titlecase_segment_with_only_case_data_v1') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size, + ffi.Pointer, + _TitlecaseOptionsFfi, + ffi.Pointer)>( + isLeaf: true, + symbol: 'ICU4XCaseMapper_titlecase_segment_with_only_case_data_v1') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 + _ICU4XCaseMapper_titlecase_segment_with_only_case_data_v1( + ffi.Pointer self, + ffi.Pointer sData, + int sLength, + ffi.Pointer locale, + _TitlecaseOptionsFfi options, + ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XCaseMapper_fold') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size, + ffi.Pointer)>(isLeaf: true, symbol: 'ICU4XCaseMapper_fold') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XCaseMapper_fold( + ffi.Pointer self, + ffi.Pointer sData, + int sLength, + ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XCaseMapper_fold_turkic') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Size, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCaseMapper_fold_turkic') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XCaseMapper_fold_turkic( + ffi.Pointer self, + ffi.Pointer sData, + int sLength, + ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XCaseMapper_add_case_closure_to') +@ffi.Native< + ffi.Void Function( + ffi.Pointer, ffi.Uint32, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCaseMapper_add_case_closure_to') +// ignore: non_constant_identifier_names +external void _ICU4XCaseMapper_add_case_closure_to( + ffi.Pointer self, Rune c, ffi.Pointer builder); + +@meta.ResourceIdentifier('ICU4XCaseMapper_simple_lowercase') +@ffi.Native, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCaseMapper_simple_lowercase') +// ignore: non_constant_identifier_names +external Rune _ICU4XCaseMapper_simple_lowercase( + ffi.Pointer self, Rune ch); + +@meta.ResourceIdentifier('ICU4XCaseMapper_simple_uppercase') +@ffi.Native, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCaseMapper_simple_uppercase') +// ignore: non_constant_identifier_names +external Rune _ICU4XCaseMapper_simple_uppercase( + ffi.Pointer self, Rune ch); + +@meta.ResourceIdentifier('ICU4XCaseMapper_simple_titlecase') +@ffi.Native, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCaseMapper_simple_titlecase') +// ignore: non_constant_identifier_names +external Rune _ICU4XCaseMapper_simple_titlecase( + ffi.Pointer self, Rune ch); + +@meta.ResourceIdentifier('ICU4XCaseMapper_simple_fold') +@ffi.Native, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCaseMapper_simple_fold') +// ignore: non_constant_identifier_names +external Rune _ICU4XCaseMapper_simple_fold( + ffi.Pointer self, Rune ch); + +@meta.ResourceIdentifier('ICU4XCaseMapper_simple_fold_turkic') +@ffi.Native, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCaseMapper_simple_fold_turkic') +// ignore: non_constant_identifier_names +external Rune _ICU4XCaseMapper_simple_fold_turkic( + ffi.Pointer self, Rune ch); diff --git a/pkgs/intl4x/lib/src/bindings/CodePointMapData16.g.dart b/pkgs/intl4x/lib/src/bindings/CodePointMapData16.g.dart deleted file mode 120000 index ebba7d40..00000000 --- a/pkgs/intl4x/lib/src/bindings/CodePointMapData16.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CodePointMapData16.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CodePointMapData16.g.dart b/pkgs/intl4x/lib/src/bindings/CodePointMapData16.g.dart new file mode 100644 index 00000000..9b736521 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CodePointMapData16.g.dart @@ -0,0 +1,128 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X Unicode Map Property object, capable of querying whether a code point (key) to obtain the Unicode property value, for a specific Unicode property. +/// +/// For properties whose values fit into 16 bits. +/// +/// See the [Rust documentation for `properties`](https://docs.rs/icu/latest/icu/properties/index.html) for more information. +/// +/// See the [Rust documentation for `CodePointMapData`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapData.html) for more information. +/// +/// See the [Rust documentation for `CodePointMapDataBorrowed`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html) for more information. +final class CodePointMapData16 implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + CodePointMapData16._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XCodePointMapData16_destroy)); + + /// Gets the value for a code point. + /// + /// See the [Rust documentation for `get`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.get) for more information. + int operator [](Rune cp) { + final result = _ICU4XCodePointMapData16_get(_ffi, cp); + return result; + } + + /// Produces an iterator over ranges of code points that map to `value` + /// + /// See the [Rust documentation for `iter_ranges_for_value`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.iter_ranges_for_value) for more information. + CodePointRangeIterator iterRangesForValue(int value) { + // This lifetime edge depends on lifetimes: 'a + core.List aEdges = [this]; + final result = _ICU4XCodePointMapData16_iter_ranges_for_value(_ffi, value); + return CodePointRangeIterator._fromFfi(result, [], aEdges); + } + + /// Produces an iterator over ranges of code points that do not map to `value` + /// + /// See the [Rust documentation for `iter_ranges_for_value_complemented`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.iter_ranges_for_value_complemented) for more information. + CodePointRangeIterator iterRangesForValueComplemented(int value) { + // This lifetime edge depends on lifetimes: 'a + core.List aEdges = [this]; + final result = _ICU4XCodePointMapData16_iter_ranges_for_value_complemented( + _ffi, value); + return CodePointRangeIterator._fromFfi(result, [], aEdges); + } + + /// Gets a [`CodePointSetData`] representing all entries in this map that map to the given value + /// + /// See the [Rust documentation for `get_set_for_value`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.get_set_for_value) for more information. + CodePointSetData getSetForValue(int value) { + final result = _ICU4XCodePointMapData16_get_set_for_value(_ffi, value); + return CodePointSetData._fromFfi(result, []); + } + + /// See the [Rust documentation for `script`](https://docs.rs/icu/latest/icu/properties/maps/fn.script.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointMapData16.script(DataProvider provider) { + final result = _ICU4XCodePointMapData16_load_script(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointMapData16._fromFfi(result.union.ok, []); + } +} + +@meta.ResourceIdentifier('ICU4XCodePointMapData16_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData16_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XCodePointMapData16_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCodePointMapData16_get') +@ffi.Native, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData16_get') +// ignore: non_constant_identifier_names +external int _ICU4XCodePointMapData16_get( + ffi.Pointer self, Rune cp); + +@meta.ResourceIdentifier('ICU4XCodePointMapData16_iter_ranges_for_value') +@ffi.Native< + ffi.Pointer Function(ffi.Pointer, ffi.Uint16)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData16_iter_ranges_for_value') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XCodePointMapData16_iter_ranges_for_value( + ffi.Pointer self, int value); + +@meta.ResourceIdentifier( + 'ICU4XCodePointMapData16_iter_ranges_for_value_complemented') +@ffi.Native< + ffi.Pointer Function(ffi.Pointer, ffi.Uint16)>( + isLeaf: true, + symbol: 'ICU4XCodePointMapData16_iter_ranges_for_value_complemented') +// ignore: non_constant_identifier_names +external ffi.Pointer + _ICU4XCodePointMapData16_iter_ranges_for_value_complemented( + ffi.Pointer self, int value); + +@meta.ResourceIdentifier('ICU4XCodePointMapData16_get_set_for_value') +@ffi.Native< + ffi.Pointer Function(ffi.Pointer, ffi.Uint16)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData16_get_set_for_value') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XCodePointMapData16_get_set_for_value( + ffi.Pointer self, int value); + +@meta.ResourceIdentifier('ICU4XCodePointMapData16_load_script') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData16_load_script') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointMapData16_load_script( + ffi.Pointer provider); diff --git a/pkgs/intl4x/lib/src/bindings/CodePointMapData8.g.dart b/pkgs/intl4x/lib/src/bindings/CodePointMapData8.g.dart deleted file mode 120000 index e9b2eec8..00000000 --- a/pkgs/intl4x/lib/src/bindings/CodePointMapData8.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CodePointMapData8.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CodePointMapData8.g.dart b/pkgs/intl4x/lib/src/bindings/CodePointMapData8.g.dart new file mode 100644 index 00000000..6d111262 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CodePointMapData8.g.dart @@ -0,0 +1,315 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X Unicode Map Property object, capable of querying whether a code point (key) to obtain the Unicode property value, for a specific Unicode property. +/// +/// For properties whose values fit into 8 bits. +/// +/// See the [Rust documentation for `properties`](https://docs.rs/icu/latest/icu/properties/index.html) for more information. +/// +/// See the [Rust documentation for `CodePointMapData`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapData.html) for more information. +/// +/// See the [Rust documentation for `CodePointMapDataBorrowed`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html) for more information. +final class CodePointMapData8 implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + CodePointMapData8._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XCodePointMapData8_destroy)); + + /// Gets the value for a code point. + /// + /// See the [Rust documentation for `get`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.get) for more information. + int operator [](Rune cp) { + final result = _ICU4XCodePointMapData8_get(_ffi, cp); + return result; + } + + /// Converts a general category to its corresponding mask value + /// + /// Nonexistent general categories will map to the empty mask + /// + /// See the [Rust documentation for `GeneralCategoryGroup`](https://docs.rs/icu/latest/icu/properties/struct.GeneralCategoryGroup.html) for more information. + static int generalCategoryToMask(int gc) { + final result = _ICU4XCodePointMapData8_general_category_to_mask(gc); + return result; + } + + /// Produces an iterator over ranges of code points that map to `value` + /// + /// See the [Rust documentation for `iter_ranges_for_value`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.iter_ranges_for_value) for more information. + CodePointRangeIterator iterRangesForValue(int value) { + // This lifetime edge depends on lifetimes: 'a + core.List aEdges = [this]; + final result = _ICU4XCodePointMapData8_iter_ranges_for_value(_ffi, value); + return CodePointRangeIterator._fromFfi(result, [], aEdges); + } + + /// Produces an iterator over ranges of code points that do not map to `value` + /// + /// See the [Rust documentation for `iter_ranges_for_value_complemented`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.iter_ranges_for_value_complemented) for more information. + CodePointRangeIterator iterRangesForValueComplemented(int value) { + // This lifetime edge depends on lifetimes: 'a + core.List aEdges = [this]; + final result = + _ICU4XCodePointMapData8_iter_ranges_for_value_complemented(_ffi, value); + return CodePointRangeIterator._fromFfi(result, [], aEdges); + } + + /// Given a mask value (the nth bit marks property value = n), produce an iterator over ranges of code points + /// whose property values are contained in the mask. + /// + /// The main mask property supported is that for General_Category, which can be obtained via `general_category_to_mask()` or + /// by using `GeneralCategoryNameToMaskMapper` + /// + /// Should only be used on maps for properties with values less than 32 (like Generak_Category), + /// other maps will have unpredictable results + /// + /// See the [Rust documentation for `iter_ranges_for_group`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.iter_ranges_for_group) for more information. + CodePointRangeIterator iterRangesForMask(int mask) { + // This lifetime edge depends on lifetimes: 'a + core.List aEdges = [this]; + final result = _ICU4XCodePointMapData8_iter_ranges_for_mask(_ffi, mask); + return CodePointRangeIterator._fromFfi(result, [], aEdges); + } + + /// Gets a [`CodePointSetData`] representing all entries in this map that map to the given value + /// + /// See the [Rust documentation for `get_set_for_value`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.get_set_for_value) for more information. + CodePointSetData getSetForValue(int value) { + final result = _ICU4XCodePointMapData8_get_set_for_value(_ffi, value); + return CodePointSetData._fromFfi(result, []); + } + + /// See the [Rust documentation for `general_category`](https://docs.rs/icu/latest/icu/properties/maps/fn.general_category.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointMapData8.generalCategory(DataProvider provider) { + final result = _ICU4XCodePointMapData8_load_general_category(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointMapData8._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `bidi_class`](https://docs.rs/icu/latest/icu/properties/maps/fn.bidi_class.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointMapData8.bidiClass(DataProvider provider) { + final result = _ICU4XCodePointMapData8_load_bidi_class(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointMapData8._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `east_asian_width`](https://docs.rs/icu/latest/icu/properties/maps/fn.east_asian_width.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointMapData8.eastAsianWidth(DataProvider provider) { + final result = _ICU4XCodePointMapData8_load_east_asian_width(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointMapData8._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `indic_syllabic_category`](https://docs.rs/icu/latest/icu/properties/maps/fn.indic_syllabic_category.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointMapData8.indicSyllabicCategory(DataProvider provider) { + final result = + _ICU4XCodePointMapData8_load_indic_syllabic_category(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointMapData8._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `line_break`](https://docs.rs/icu/latest/icu/properties/maps/fn.line_break.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointMapData8.lineBreak(DataProvider provider) { + final result = _ICU4XCodePointMapData8_load_line_break(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointMapData8._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `grapheme_cluster_break`](https://docs.rs/icu/latest/icu/properties/maps/fn.grapheme_cluster_break.html) for more information. + /// + /// Throws [Error] on failure. + static CodePointMapData8 tryGraphemeClusterBreak(DataProvider provider) { + final result = + _ICU4XCodePointMapData8_try_grapheme_cluster_break(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointMapData8._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `word_break`](https://docs.rs/icu/latest/icu/properties/maps/fn.word_break.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointMapData8.wordBreak(DataProvider provider) { + final result = _ICU4XCodePointMapData8_load_word_break(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointMapData8._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `sentence_break`](https://docs.rs/icu/latest/icu/properties/maps/fn.sentence_break.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointMapData8.sentenceBreak(DataProvider provider) { + final result = _ICU4XCodePointMapData8_load_sentence_break(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointMapData8._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `joining_type`](https://docs.rs/icu/latest/icu/properties/maps/fn.joining_type.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointMapData8.joiningType(DataProvider provider) { + final result = _ICU4XCodePointMapData8_load_joining_type(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointMapData8._fromFfi(result.union.ok, []); + } +} + +@meta.ResourceIdentifier('ICU4XCodePointMapData8_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData8_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XCodePointMapData8_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCodePointMapData8_get') +@ffi.Native, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData8_get') +// ignore: non_constant_identifier_names +external int _ICU4XCodePointMapData8_get(ffi.Pointer self, Rune cp); + +@meta.ResourceIdentifier('ICU4XCodePointMapData8_general_category_to_mask') +@ffi.Native( + isLeaf: true, symbol: 'ICU4XCodePointMapData8_general_category_to_mask') +// ignore: non_constant_identifier_names +external int _ICU4XCodePointMapData8_general_category_to_mask(int gc); + +@meta.ResourceIdentifier('ICU4XCodePointMapData8_iter_ranges_for_value') +@ffi.Native< + ffi.Pointer Function(ffi.Pointer, ffi.Uint8)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData8_iter_ranges_for_value') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XCodePointMapData8_iter_ranges_for_value( + ffi.Pointer self, int value); + +@meta.ResourceIdentifier( + 'ICU4XCodePointMapData8_iter_ranges_for_value_complemented') +@ffi.Native< + ffi.Pointer Function(ffi.Pointer, ffi.Uint8)>( + isLeaf: true, + symbol: 'ICU4XCodePointMapData8_iter_ranges_for_value_complemented') +// ignore: non_constant_identifier_names +external ffi.Pointer + _ICU4XCodePointMapData8_iter_ranges_for_value_complemented( + ffi.Pointer self, int value); + +@meta.ResourceIdentifier('ICU4XCodePointMapData8_iter_ranges_for_mask') +@ffi.Native< + ffi.Pointer Function(ffi.Pointer, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData8_iter_ranges_for_mask') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XCodePointMapData8_iter_ranges_for_mask( + ffi.Pointer self, int mask); + +@meta.ResourceIdentifier('ICU4XCodePointMapData8_get_set_for_value') +@ffi.Native< + ffi.Pointer Function(ffi.Pointer, ffi.Uint8)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData8_get_set_for_value') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XCodePointMapData8_get_set_for_value( + ffi.Pointer self, int value); + +@meta.ResourceIdentifier('ICU4XCodePointMapData8_load_general_category') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData8_load_general_category') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointMapData8_load_general_category( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointMapData8_load_bidi_class') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData8_load_bidi_class') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointMapData8_load_bidi_class( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointMapData8_load_east_asian_width') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData8_load_east_asian_width') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointMapData8_load_east_asian_width( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointMapData8_load_indic_syllabic_category') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData8_load_indic_syllabic_category') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XCodePointMapData8_load_indic_syllabic_category( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointMapData8_load_line_break') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData8_load_line_break') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointMapData8_load_line_break( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointMapData8_try_grapheme_cluster_break') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData8_try_grapheme_cluster_break') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointMapData8_try_grapheme_cluster_break( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointMapData8_load_word_break') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData8_load_word_break') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointMapData8_load_word_break( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointMapData8_load_sentence_break') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData8_load_sentence_break') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointMapData8_load_sentence_break( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointMapData8_load_joining_type') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointMapData8_load_joining_type') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointMapData8_load_joining_type( + ffi.Pointer provider); diff --git a/pkgs/intl4x/lib/src/bindings/CodePointRangeIterator.g.dart b/pkgs/intl4x/lib/src/bindings/CodePointRangeIterator.g.dart deleted file mode 120000 index 41ce5dcd..00000000 --- a/pkgs/intl4x/lib/src/bindings/CodePointRangeIterator.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CodePointRangeIterator.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CodePointRangeIterator.g.dart b/pkgs/intl4x/lib/src/bindings/CodePointRangeIterator.g.dart new file mode 100644 index 00000000..7cde79d4 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CodePointRangeIterator.g.dart @@ -0,0 +1,49 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An iterator over code point ranges, produced by `CodePointSetData` or +/// one of the `CodePointMapData` types +final class CodePointRangeIterator implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _aEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + CodePointRangeIterator._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_CodePointRangeIterator_destroy)); + + /// Advance the iterator by one and return the next range. + /// + /// If the iterator is out of items, `done` will be true + CodePointRangeIteratorResult next() { + final result = _CodePointRangeIterator_next(_ffi); + return CodePointRangeIteratorResult._fromFfi(result); + } +} + +@meta.ResourceIdentifier('CodePointRangeIterator_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'CodePointRangeIterator_destroy') +// ignore: non_constant_identifier_names +external void _CodePointRangeIterator_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('CodePointRangeIterator_next') +@ffi.Native<_CodePointRangeIteratorResultFfi Function(ffi.Pointer)>( + isLeaf: true, symbol: 'CodePointRangeIterator_next') +// ignore: non_constant_identifier_names +external _CodePointRangeIteratorResultFfi _CodePointRangeIterator_next( + ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/CodePointRangeIteratorResult.g.dart b/pkgs/intl4x/lib/src/bindings/CodePointRangeIteratorResult.g.dart deleted file mode 120000 index ca40c652..00000000 --- a/pkgs/intl4x/lib/src/bindings/CodePointRangeIteratorResult.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CodePointRangeIteratorResult.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CodePointRangeIteratorResult.g.dart b/pkgs/intl4x/lib/src/bindings/CodePointRangeIteratorResult.g.dart new file mode 100644 index 00000000..a874291f --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CodePointRangeIteratorResult.g.dart @@ -0,0 +1,59 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +final class _CodePointRangeIteratorResultFfi extends ffi.Struct { + @ffi.Uint32() + external int start; + @ffi.Uint32() + external int end; + @ffi.Bool() + external bool done; +} + +/// Result of a single iteration of [`CodePointRangeIterator`]. +/// Logically can be considered to be an `Option>`, +/// +/// `start` and `end` represent an inclusive range of code points [start, end], +/// and `done` will be true if the iterator has already finished. The last contentful +/// iteration will NOT produce a range done=true, in other words `start` and `end` are useful +/// values if and only if `done=false`. +final class CodePointRangeIteratorResult { + final int start; + final int end; + final bool done; + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + CodePointRangeIteratorResult._fromFfi(_CodePointRangeIteratorResultFfi ffi) + : start = ffi.start, + end = ffi.end, + done = ffi.done; + + // ignore: unused_element + _CodePointRangeIteratorResultFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_CodePointRangeIteratorResultFfi>(); + struct.start = start; + struct.end = end; + struct.done = done; + return struct; + } + + @override + bool operator ==(Object other) => + other is CodePointRangeIteratorResult && + other.start == start && + other.end == end && + other.done == done; + + @override + int get hashCode => Object.hashAll([ + start, + end, + done, + ]); +} diff --git a/pkgs/intl4x/lib/src/bindings/CodePointSetBuilder.g.dart b/pkgs/intl4x/lib/src/bindings/CodePointSetBuilder.g.dart deleted file mode 120000 index 642e172a..00000000 --- a/pkgs/intl4x/lib/src/bindings/CodePointSetBuilder.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CodePointSetBuilder.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CodePointSetBuilder.g.dart b/pkgs/intl4x/lib/src/bindings/CodePointSetBuilder.g.dart new file mode 100644 index 00000000..83963298 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CodePointSetBuilder.g.dart @@ -0,0 +1,270 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `CodePointInversionListBuilder`](https://docs.rs/icu/latest/icu/collections/codepointinvlist/struct.CodePointInversionListBuilder.html) for more information. +final class CodePointSetBuilder implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + CodePointSetBuilder._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XCodePointSetBuilder_destroy)); + + /// Make a new set builder containing nothing + /// + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/collections/codepointinvlist/struct.CodePointInversionListBuilder.html#method.new) for more information. + factory CodePointSetBuilder() { + final result = _ICU4XCodePointSetBuilder_create(); + return CodePointSetBuilder._fromFfi(result, []); + } + + /// Build this into a set + /// + /// This object is repopulated with an empty builder + /// + /// See the [Rust documentation for `build`](https://docs.rs/icu/latest/icu/collections/codepointinvlist/struct.CodePointInversionListBuilder.html#method.build) for more information. + CodePointSetData build() { + final result = _ICU4XCodePointSetBuilder_build(_ffi); + return CodePointSetData._fromFfi(result, []); + } + + /// Complements this set + /// + /// (Elements in this set are removed and vice versa) + /// + /// See the [Rust documentation for `complement`](https://docs.rs/icu/latest/icu/collections/codepointinvlist/struct.CodePointInversionListBuilder.html#method.complement) for more information. + void complement() { + _ICU4XCodePointSetBuilder_complement(_ffi); + } + + /// Returns whether this set is empty + /// + /// See the [Rust documentation for `is_empty`](https://docs.rs/icu/latest/icu/collections/codepointinvlist/struct.CodePointInversionListBuilder.html#method.is_empty) for more information. + bool get isEmpty { + final result = _ICU4XCodePointSetBuilder_is_empty(_ffi); + return result; + } + + /// Add a single character to the set + /// + /// See the [Rust documentation for `add_char`](https://docs.rs/icu/latest/icu/collections/codepointinvlist/struct.CodePointInversionListBuilder.html#method.add_char) for more information. + void addChar(Rune ch) { + _ICU4XCodePointSetBuilder_add_char(_ffi, ch); + } + + /// Add an inclusive range of characters to the set + /// + /// See the [Rust documentation for `add_range`](https://docs.rs/icu/latest/icu/collections/codepointinvlist/struct.CodePointInversionListBuilder.html#method.add_range) for more information. + void addInclusiveRange(Rune start, Rune end) { + _ICU4XCodePointSetBuilder_add_inclusive_range(_ffi, start, end); + } + + /// Add all elements that belong to the provided set to the set + /// + /// See the [Rust documentation for `add_set`](https://docs.rs/icu/latest/icu/collections/codepointinvlist/struct.CodePointInversionListBuilder.html#method.add_set) for more information. + void addSet(CodePointSetData data) { + _ICU4XCodePointSetBuilder_add_set(_ffi, data._ffi); + } + + /// Remove a single character to the set + /// + /// See the [Rust documentation for `remove_char`](https://docs.rs/icu/latest/icu/collections/codepointinvlist/struct.CodePointInversionListBuilder.html#method.remove_char) for more information. + void removeChar(Rune ch) { + _ICU4XCodePointSetBuilder_remove_char(_ffi, ch); + } + + /// Remove an inclusive range of characters from the set + /// + /// See the [Rust documentation for `remove_range`](https://docs.rs/icu/latest/icu/collections/codepointinvlist/struct.CodePointInversionListBuilder.html#method.remove_range) for more information. + void removeInclusiveRange(Rune start, Rune end) { + _ICU4XCodePointSetBuilder_remove_inclusive_range(_ffi, start, end); + } + + /// Remove all elements that belong to the provided set from the set + /// + /// See the [Rust documentation for `remove_set`](https://docs.rs/icu/latest/icu/collections/codepointinvlist/struct.CodePointInversionListBuilder.html#method.remove_set) for more information. + void removeSet(CodePointSetData data) { + _ICU4XCodePointSetBuilder_remove_set(_ffi, data._ffi); + } + + /// Removes all elements from the set except a single character + /// + /// See the [Rust documentation for `retain_char`](https://docs.rs/icu/latest/icu/collections/codepointinvlist/struct.CodePointInversionListBuilder.html#method.retain_char) for more information. + void retainChar(Rune ch) { + _ICU4XCodePointSetBuilder_retain_char(_ffi, ch); + } + + /// Removes all elements from the set except an inclusive range of characters f + /// + /// See the [Rust documentation for `retain_range`](https://docs.rs/icu/latest/icu/collections/codepointinvlist/struct.CodePointInversionListBuilder.html#method.retain_range) for more information. + void retainInclusiveRange(Rune start, Rune end) { + _ICU4XCodePointSetBuilder_retain_inclusive_range(_ffi, start, end); + } + + /// Removes all elements from the set except all elements in the provided set + /// + /// See the [Rust documentation for `retain_set`](https://docs.rs/icu/latest/icu/collections/codepointinvlist/struct.CodePointInversionListBuilder.html#method.retain_set) for more information. + void retainSet(CodePointSetData data) { + _ICU4XCodePointSetBuilder_retain_set(_ffi, data._ffi); + } + + /// Complement a single character to the set + /// + /// (Characters which are in this set are removed and vice versa) + /// + /// See the [Rust documentation for `complement_char`](https://docs.rs/icu/latest/icu/collections/codepointinvlist/struct.CodePointInversionListBuilder.html#method.complement_char) for more information. + void complementChar(Rune ch) { + _ICU4XCodePointSetBuilder_complement_char(_ffi, ch); + } + + /// Complement an inclusive range of characters from the set + /// + /// (Characters which are in this set are removed and vice versa) + /// + /// See the [Rust documentation for `complement_range`](https://docs.rs/icu/latest/icu/collections/codepointinvlist/struct.CodePointInversionListBuilder.html#method.complement_range) for more information. + void complementInclusiveRange(Rune start, Rune end) { + _ICU4XCodePointSetBuilder_complement_inclusive_range(_ffi, start, end); + } + + /// Complement all elements that belong to the provided set from the set + /// + /// (Characters which are in this set are removed and vice versa) + /// + /// See the [Rust documentation for `complement_set`](https://docs.rs/icu/latest/icu/collections/codepointinvlist/struct.CodePointInversionListBuilder.html#method.complement_set) for more information. + void complementSet(CodePointSetData data) { + _ICU4XCodePointSetBuilder_complement_set(_ffi, data._ffi); + } +} + +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCodePointSetBuilder_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XCodePointSetBuilder_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_create') +@ffi.Native Function()>( + isLeaf: true, symbol: 'ICU4XCodePointSetBuilder_create') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XCodePointSetBuilder_create(); + +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_build') +@ffi.Native Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetBuilder_build') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XCodePointSetBuilder_build( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_complement') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCodePointSetBuilder_complement') +// ignore: non_constant_identifier_names +external void _ICU4XCodePointSetBuilder_complement( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_is_empty') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCodePointSetBuilder_is_empty') +// ignore: non_constant_identifier_names +external bool _ICU4XCodePointSetBuilder_is_empty(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_add_char') +@ffi.Native, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCodePointSetBuilder_add_char') +// ignore: non_constant_identifier_names +external void _ICU4XCodePointSetBuilder_add_char( + ffi.Pointer self, Rune ch); + +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_add_inclusive_range') +@ffi.Native, ffi.Uint32, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCodePointSetBuilder_add_inclusive_range') +// ignore: non_constant_identifier_names +external void _ICU4XCodePointSetBuilder_add_inclusive_range( + ffi.Pointer self, Rune start, Rune end); + +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_add_set') +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetBuilder_add_set') +// ignore: non_constant_identifier_names +external void _ICU4XCodePointSetBuilder_add_set( + ffi.Pointer self, ffi.Pointer data); + +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_remove_char') +@ffi.Native, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCodePointSetBuilder_remove_char') +// ignore: non_constant_identifier_names +external void _ICU4XCodePointSetBuilder_remove_char( + ffi.Pointer self, Rune ch); + +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_remove_inclusive_range') +@ffi.Native, ffi.Uint32, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCodePointSetBuilder_remove_inclusive_range') +// ignore: non_constant_identifier_names +external void _ICU4XCodePointSetBuilder_remove_inclusive_range( + ffi.Pointer self, Rune start, Rune end); + +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_remove_set') +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetBuilder_remove_set') +// ignore: non_constant_identifier_names +external void _ICU4XCodePointSetBuilder_remove_set( + ffi.Pointer self, ffi.Pointer data); + +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_retain_char') +@ffi.Native, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCodePointSetBuilder_retain_char') +// ignore: non_constant_identifier_names +external void _ICU4XCodePointSetBuilder_retain_char( + ffi.Pointer self, Rune ch); + +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_retain_inclusive_range') +@ffi.Native, ffi.Uint32, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCodePointSetBuilder_retain_inclusive_range') +// ignore: non_constant_identifier_names +external void _ICU4XCodePointSetBuilder_retain_inclusive_range( + ffi.Pointer self, Rune start, Rune end); + +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_retain_set') +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetBuilder_retain_set') +// ignore: non_constant_identifier_names +external void _ICU4XCodePointSetBuilder_retain_set( + ffi.Pointer self, ffi.Pointer data); + +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_complement_char') +@ffi.Native, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCodePointSetBuilder_complement_char') +// ignore: non_constant_identifier_names +external void _ICU4XCodePointSetBuilder_complement_char( + ffi.Pointer self, Rune ch); + +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_complement_inclusive_range') +@ffi.Native, ffi.Uint32, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCodePointSetBuilder_complement_inclusive_range') +// ignore: non_constant_identifier_names +external void _ICU4XCodePointSetBuilder_complement_inclusive_range( + ffi.Pointer self, Rune start, Rune end); + +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_complement_set') +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetBuilder_complement_set') +// ignore: non_constant_identifier_names +external void _ICU4XCodePointSetBuilder_complement_set( + ffi.Pointer self, ffi.Pointer data); diff --git a/pkgs/intl4x/lib/src/bindings/CodePointSetData.g.dart b/pkgs/intl4x/lib/src/bindings/CodePointSetData.g.dart deleted file mode 120000 index 5c7ad408..00000000 --- a/pkgs/intl4x/lib/src/bindings/CodePointSetData.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CodePointSetData.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CodePointSetData.g.dart b/pkgs/intl4x/lib/src/bindings/CodePointSetData.g.dart new file mode 100644 index 00000000..d114bfce --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CodePointSetData.g.dart @@ -0,0 +1,1349 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X Unicode Set Property object, capable of querying whether a code point is contained in a set based on a Unicode property. +/// +/// See the [Rust documentation for `properties`](https://docs.rs/icu/latest/icu/properties/index.html) for more information. +/// +/// See the [Rust documentation for `CodePointSetData`](https://docs.rs/icu/latest/icu/properties/sets/struct.CodePointSetData.html) for more information. +/// +/// See the [Rust documentation for `CodePointSetDataBorrowed`](https://docs.rs/icu/latest/icu/properties/sets/struct.CodePointSetDataBorrowed.html) for more information. +final class CodePointSetData implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + CodePointSetData._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XCodePointSetData_destroy)); + + /// Checks whether the code point is in the set. + /// + /// See the [Rust documentation for `contains`](https://docs.rs/icu/latest/icu/properties/sets/struct.CodePointSetDataBorrowed.html#method.contains) for more information. + bool contains(Rune cp) { + final result = _ICU4XCodePointSetData_contains(_ffi, cp); + return result; + } + + /// Produces an iterator over ranges of code points contained in this set + /// + /// See the [Rust documentation for `iter_ranges`](https://docs.rs/icu/latest/icu/properties/sets/struct.CodePointSetDataBorrowed.html#method.iter_ranges) for more information. + CodePointRangeIterator iterRanges() { + // This lifetime edge depends on lifetimes: 'a + core.List aEdges = [this]; + final result = _ICU4XCodePointSetData_iter_ranges(_ffi); + return CodePointRangeIterator._fromFfi(result, [], aEdges); + } + + /// Produces an iterator over ranges of code points not contained in this set + /// + /// See the [Rust documentation for `iter_ranges_complemented`](https://docs.rs/icu/latest/icu/properties/sets/struct.CodePointSetDataBorrowed.html#method.iter_ranges_complemented) for more information. + CodePointRangeIterator iterRangesComplemented() { + // This lifetime edge depends on lifetimes: 'a + core.List aEdges = [this]; + final result = _ICU4XCodePointSetData_iter_ranges_complemented(_ffi); + return CodePointRangeIterator._fromFfi(result, [], aEdges); + } + + /// which is a mask with the same format as the `U_GC_XX_MASK` mask in ICU4C + /// + /// See the [Rust documentation for `for_general_category_group`](https://docs.rs/icu/latest/icu/properties/sets/fn.for_general_category_group.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.forGeneralCategoryGroup( + DataProvider provider, int group) { + final result = _ICU4XCodePointSetData_load_for_general_category_group( + provider._ffi, group); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `ascii_hex_digit`](https://docs.rs/icu/latest/icu/properties/sets/fn.ascii_hex_digit.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.asciiHexDigit(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_ascii_hex_digit(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `alnum`](https://docs.rs/icu/latest/icu/properties/sets/fn.alnum.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.alnum(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_alnum(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `alphabetic`](https://docs.rs/icu/latest/icu/properties/sets/fn.alphabetic.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.alphabetic(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_alphabetic(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `bidi_control`](https://docs.rs/icu/latest/icu/properties/sets/fn.bidi_control.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.bidiControl(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_bidi_control(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `bidi_mirrored`](https://docs.rs/icu/latest/icu/properties/sets/fn.bidi_mirrored.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.bidiMirrored(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_bidi_mirrored(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `blank`](https://docs.rs/icu/latest/icu/properties/sets/fn.blank.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.blank(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_blank(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `cased`](https://docs.rs/icu/latest/icu/properties/sets/fn.cased.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.cased(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_cased(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `case_ignorable`](https://docs.rs/icu/latest/icu/properties/sets/fn.case_ignorable.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.caseIgnorable(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_case_ignorable(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `full_composition_exclusion`](https://docs.rs/icu/latest/icu/properties/sets/fn.full_composition_exclusion.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.fullCompositionExclusion(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_full_composition_exclusion(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `changes_when_casefolded`](https://docs.rs/icu/latest/icu/properties/sets/fn.changes_when_casefolded.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.changesWhenCasefolded(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_changes_when_casefolded(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `changes_when_casemapped`](https://docs.rs/icu/latest/icu/properties/sets/fn.changes_when_casemapped.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.changesWhenCasemapped(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_changes_when_casemapped(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `changes_when_nfkc_casefolded`](https://docs.rs/icu/latest/icu/properties/sets/fn.changes_when_nfkc_casefolded.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.changesWhenNfkcCasefolded(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_changes_when_nfkc_casefolded(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `changes_when_lowercased`](https://docs.rs/icu/latest/icu/properties/sets/fn.changes_when_lowercased.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.changesWhenLowercased(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_changes_when_lowercased(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `changes_when_titlecased`](https://docs.rs/icu/latest/icu/properties/sets/fn.changes_when_titlecased.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.changesWhenTitlecased(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_changes_when_titlecased(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `changes_when_uppercased`](https://docs.rs/icu/latest/icu/properties/sets/fn.changes_when_uppercased.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.changesWhenUppercased(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_changes_when_uppercased(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `dash`](https://docs.rs/icu/latest/icu/properties/sets/fn.dash.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.dash(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_dash(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `deprecated`](https://docs.rs/icu/latest/icu/properties/sets/fn.deprecated.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.deprecated(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_deprecated(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `default_ignorable_code_point`](https://docs.rs/icu/latest/icu/properties/sets/fn.default_ignorable_code_point.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.defaultIgnorableCodePoint(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_default_ignorable_code_point(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `diacritic`](https://docs.rs/icu/latest/icu/properties/sets/fn.diacritic.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.diacritic(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_diacritic(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `emoji_modifier_base`](https://docs.rs/icu/latest/icu/properties/sets/fn.emoji_modifier_base.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.emojiModifierBase(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_emoji_modifier_base(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `emoji_component`](https://docs.rs/icu/latest/icu/properties/sets/fn.emoji_component.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.emojiComponent(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_emoji_component(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `emoji_modifier`](https://docs.rs/icu/latest/icu/properties/sets/fn.emoji_modifier.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.emojiModifier(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_emoji_modifier(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `emoji`](https://docs.rs/icu/latest/icu/properties/sets/fn.emoji.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.emoji(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_emoji(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `emoji_presentation`](https://docs.rs/icu/latest/icu/properties/sets/fn.emoji_presentation.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.emojiPresentation(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_emoji_presentation(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `extender`](https://docs.rs/icu/latest/icu/properties/sets/fn.extender.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.extender(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_extender(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `extended_pictographic`](https://docs.rs/icu/latest/icu/properties/sets/fn.extended_pictographic.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.extendedPictographic(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_extended_pictographic(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `graph`](https://docs.rs/icu/latest/icu/properties/sets/fn.graph.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.graph(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_graph(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `grapheme_base`](https://docs.rs/icu/latest/icu/properties/sets/fn.grapheme_base.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.graphemeBase(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_grapheme_base(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `grapheme_extend`](https://docs.rs/icu/latest/icu/properties/sets/fn.grapheme_extend.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.graphemeExtend(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_grapheme_extend(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `grapheme_link`](https://docs.rs/icu/latest/icu/properties/sets/fn.grapheme_link.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.graphemeLink(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_grapheme_link(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `hex_digit`](https://docs.rs/icu/latest/icu/properties/sets/fn.hex_digit.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.hexDigit(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_hex_digit(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `hyphen`](https://docs.rs/icu/latest/icu/properties/sets/fn.hyphen.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.hyphen(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_hyphen(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `id_continue`](https://docs.rs/icu/latest/icu/properties/sets/fn.id_continue.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.idContinue(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_id_continue(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `ideographic`](https://docs.rs/icu/latest/icu/properties/sets/fn.ideographic.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.ideographic(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_ideographic(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `id_start`](https://docs.rs/icu/latest/icu/properties/sets/fn.id_start.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.idStart(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_id_start(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `ids_binary_operator`](https://docs.rs/icu/latest/icu/properties/sets/fn.ids_binary_operator.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.idsBinaryOperator(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_ids_binary_operator(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `ids_trinary_operator`](https://docs.rs/icu/latest/icu/properties/sets/fn.ids_trinary_operator.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.idsTrinaryOperator(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_ids_trinary_operator(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `join_control`](https://docs.rs/icu/latest/icu/properties/sets/fn.join_control.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.joinControl(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_join_control(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `logical_order_exception`](https://docs.rs/icu/latest/icu/properties/sets/fn.logical_order_exception.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.logicalOrderException(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_logical_order_exception(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `lowercase`](https://docs.rs/icu/latest/icu/properties/sets/fn.lowercase.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.lowercase(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_lowercase(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `math`](https://docs.rs/icu/latest/icu/properties/sets/fn.math.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.math(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_math(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `noncharacter_code_point`](https://docs.rs/icu/latest/icu/properties/sets/fn.noncharacter_code_point.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.noncharacterCodePoint(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_noncharacter_code_point(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `nfc_inert`](https://docs.rs/icu/latest/icu/properties/sets/fn.nfc_inert.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.nfcInert(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_nfc_inert(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `nfd_inert`](https://docs.rs/icu/latest/icu/properties/sets/fn.nfd_inert.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.nfdInert(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_nfd_inert(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `nfkc_inert`](https://docs.rs/icu/latest/icu/properties/sets/fn.nfkc_inert.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.nfkcInert(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_nfkc_inert(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `nfkd_inert`](https://docs.rs/icu/latest/icu/properties/sets/fn.nfkd_inert.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.nfkdInert(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_nfkd_inert(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `pattern_syntax`](https://docs.rs/icu/latest/icu/properties/sets/fn.pattern_syntax.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.patternSyntax(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_pattern_syntax(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `pattern_white_space`](https://docs.rs/icu/latest/icu/properties/sets/fn.pattern_white_space.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.patternWhiteSpace(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_pattern_white_space(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `prepended_concatenation_mark`](https://docs.rs/icu/latest/icu/properties/sets/fn.prepended_concatenation_mark.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.prependedConcatenationMark(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_prepended_concatenation_mark(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `print`](https://docs.rs/icu/latest/icu/properties/sets/fn.print.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.print(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_print(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `quotation_mark`](https://docs.rs/icu/latest/icu/properties/sets/fn.quotation_mark.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.quotationMark(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_quotation_mark(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `radical`](https://docs.rs/icu/latest/icu/properties/sets/fn.radical.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.radical(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_radical(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `regional_indicator`](https://docs.rs/icu/latest/icu/properties/sets/fn.regional_indicator.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.regionalIndicator(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_regional_indicator(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `soft_dotted`](https://docs.rs/icu/latest/icu/properties/sets/fn.soft_dotted.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.softDotted(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_soft_dotted(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `segment_starter`](https://docs.rs/icu/latest/icu/properties/sets/fn.segment_starter.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.segmentStarter(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_segment_starter(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `case_sensitive`](https://docs.rs/icu/latest/icu/properties/sets/fn.case_sensitive.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.caseSensitive(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_case_sensitive(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `sentence_terminal`](https://docs.rs/icu/latest/icu/properties/sets/fn.sentence_terminal.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.sentenceTerminal(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_sentence_terminal(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `terminal_punctuation`](https://docs.rs/icu/latest/icu/properties/sets/fn.terminal_punctuation.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.terminalPunctuation(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_terminal_punctuation(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `unified_ideograph`](https://docs.rs/icu/latest/icu/properties/sets/fn.unified_ideograph.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.unifiedIdeograph(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_unified_ideograph(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `uppercase`](https://docs.rs/icu/latest/icu/properties/sets/fn.uppercase.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.uppercase(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_uppercase(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `variation_selector`](https://docs.rs/icu/latest/icu/properties/sets/fn.variation_selector.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.variationSelector(DataProvider provider) { + final result = + _ICU4XCodePointSetData_load_variation_selector(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `white_space`](https://docs.rs/icu/latest/icu/properties/sets/fn.white_space.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.whiteSpace(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_white_space(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `xdigit`](https://docs.rs/icu/latest/icu/properties/sets/fn.xdigit.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.xdigit(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_xdigit(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `xid_continue`](https://docs.rs/icu/latest/icu/properties/sets/fn.xid_continue.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.xidContinue(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_xid_continue(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `xid_start`](https://docs.rs/icu/latest/icu/properties/sets/fn.xid_start.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.xidStart(DataProvider provider) { + final result = _ICU4XCodePointSetData_load_xid_start(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } + + /// Loads data for a property specified as a string as long as it is one of the + /// [ECMA-262 binary properties][ecma] (not including Any, ASCII, and Assigned pseudoproperties). + /// + /// Returns `Error::PropertyUnexpectedPropertyNameError` in case the string does not + /// match any property in the list + /// + /// [ecma]: https://tc39.es/ecma262/#table-binary-unicode-properties + /// + /// See the [Rust documentation for `for_ecma262`](https://docs.rs/icu/latest/icu/properties/sets/fn.for_ecma262.html) for more information. + /// + /// Throws [Error] on failure. + factory CodePointSetData.forEcma262( + DataProvider provider, String propertyName) { + final temp = ffi2.Arena(); + final propertyNameView = propertyName.utf8View; + final result = _ICU4XCodePointSetData_load_for_ecma262( + provider._ffi, propertyNameView.allocIn(temp), propertyNameView.length); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CodePointSetData._fromFfi(result.union.ok, []); + } +} + +@meta.ResourceIdentifier('ICU4XCodePointSetData_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XCodePointSetData_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_contains') +@ffi.Native, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_contains') +// ignore: non_constant_identifier_names +external bool _ICU4XCodePointSetData_contains( + ffi.Pointer self, Rune cp); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_iter_ranges') +@ffi.Native Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_iter_ranges') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XCodePointSetData_iter_ranges( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_iter_ranges_complemented') +@ffi.Native Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_iter_ranges_complemented') +// ignore: non_constant_identifier_names +external ffi.Pointer + _ICU4XCodePointSetData_iter_ranges_complemented( + ffi.Pointer self); + +@meta + .ResourceIdentifier('ICU4XCodePointSetData_load_for_general_category_group') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer, ffi.Uint32)>( + isLeaf: true, + symbol: 'ICU4XCodePointSetData_load_for_general_category_group') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XCodePointSetData_load_for_general_category_group( + ffi.Pointer provider, int group); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_ascii_hex_digit') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_ascii_hex_digit') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_ascii_hex_digit( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_alnum') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_alnum') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_alnum( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_alphabetic') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_alphabetic') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_alphabetic( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_bidi_control') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_bidi_control') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_bidi_control( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_bidi_mirrored') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_bidi_mirrored') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_bidi_mirrored( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_blank') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_blank') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_blank( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_cased') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_cased') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_cased( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_case_ignorable') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_case_ignorable') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_case_ignorable( + ffi.Pointer provider); + +@meta + .ResourceIdentifier('ICU4XCodePointSetData_load_full_composition_exclusion') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, + symbol: 'ICU4XCodePointSetData_load_full_composition_exclusion') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XCodePointSetData_load_full_composition_exclusion( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_changes_when_casefolded') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_changes_when_casefolded') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_changes_when_casefolded( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_changes_when_casemapped') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_changes_when_casemapped') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_changes_when_casemapped( + ffi.Pointer provider); + +@meta.ResourceIdentifier( + 'ICU4XCodePointSetData_load_changes_when_nfkc_casefolded') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, + symbol: 'ICU4XCodePointSetData_load_changes_when_nfkc_casefolded') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XCodePointSetData_load_changes_when_nfkc_casefolded( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_changes_when_lowercased') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_changes_when_lowercased') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_changes_when_lowercased( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_changes_when_titlecased') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_changes_when_titlecased') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_changes_when_titlecased( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_changes_when_uppercased') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_changes_when_uppercased') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_changes_when_uppercased( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_dash') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_dash') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_dash( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_deprecated') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_deprecated') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_deprecated( + ffi.Pointer provider); + +@meta.ResourceIdentifier( + 'ICU4XCodePointSetData_load_default_ignorable_code_point') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, + symbol: 'ICU4XCodePointSetData_load_default_ignorable_code_point') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XCodePointSetData_load_default_ignorable_code_point( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_diacritic') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_diacritic') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_diacritic( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_emoji_modifier_base') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_emoji_modifier_base') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_emoji_modifier_base( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_emoji_component') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_emoji_component') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_emoji_component( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_emoji_modifier') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_emoji_modifier') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_emoji_modifier( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_emoji') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_emoji') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_emoji( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_emoji_presentation') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_emoji_presentation') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_emoji_presentation( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_extender') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_extender') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_extender( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_extended_pictographic') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_extended_pictographic') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_extended_pictographic( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_graph') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_graph') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_graph( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_grapheme_base') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_grapheme_base') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_grapheme_base( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_grapheme_extend') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_grapheme_extend') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_grapheme_extend( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_grapheme_link') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_grapheme_link') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_grapheme_link( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_hex_digit') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_hex_digit') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_hex_digit( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_hyphen') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_hyphen') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_hyphen( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_id_continue') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_id_continue') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_id_continue( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_ideographic') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_ideographic') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_ideographic( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_id_start') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_id_start') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_id_start( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_ids_binary_operator') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_ids_binary_operator') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_ids_binary_operator( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_ids_trinary_operator') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_ids_trinary_operator') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_ids_trinary_operator( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_join_control') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_join_control') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_join_control( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_logical_order_exception') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_logical_order_exception') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_logical_order_exception( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_lowercase') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_lowercase') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_lowercase( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_math') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_math') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_math( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_noncharacter_code_point') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_noncharacter_code_point') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_noncharacter_code_point( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_nfc_inert') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_nfc_inert') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_nfc_inert( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_nfd_inert') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_nfd_inert') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_nfd_inert( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_nfkc_inert') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_nfkc_inert') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_nfkc_inert( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_nfkd_inert') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_nfkd_inert') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_nfkd_inert( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_pattern_syntax') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_pattern_syntax') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_pattern_syntax( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_pattern_white_space') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_pattern_white_space') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_pattern_white_space( + ffi.Pointer provider); + +@meta.ResourceIdentifier( + 'ICU4XCodePointSetData_load_prepended_concatenation_mark') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, + symbol: 'ICU4XCodePointSetData_load_prepended_concatenation_mark') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XCodePointSetData_load_prepended_concatenation_mark( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_print') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_print') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_print( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_quotation_mark') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_quotation_mark') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_quotation_mark( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_radical') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_radical') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_radical( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_regional_indicator') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_regional_indicator') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_regional_indicator( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_soft_dotted') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_soft_dotted') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_soft_dotted( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_segment_starter') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_segment_starter') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_segment_starter( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_case_sensitive') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_case_sensitive') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_case_sensitive( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_sentence_terminal') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_sentence_terminal') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_sentence_terminal( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_terminal_punctuation') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_terminal_punctuation') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_terminal_punctuation( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_unified_ideograph') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_unified_ideograph') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_unified_ideograph( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_uppercase') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_uppercase') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_uppercase( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_variation_selector') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_variation_selector') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_variation_selector( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_white_space') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_white_space') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_white_space( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_xdigit') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_xdigit') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_xdigit( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_xid_continue') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_xid_continue') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_xid_continue( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_xid_start') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_xid_start') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_xid_start( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XCodePointSetData_load_for_ecma262') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XCodePointSetData_load_for_ecma262') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCodePointSetData_load_for_ecma262( + ffi.Pointer provider, + ffi.Pointer propertyNameData, + int propertyNameLength); diff --git a/pkgs/intl4x/lib/src/bindings/Collator.g.dart b/pkgs/intl4x/lib/src/bindings/Collator.g.dart deleted file mode 120000 index ff0994f6..00000000 --- a/pkgs/intl4x/lib/src/bindings/Collator.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/Collator.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/Collator.g.dart b/pkgs/intl4x/lib/src/bindings/Collator.g.dart new file mode 100644 index 00000000..48848a37 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/Collator.g.dart @@ -0,0 +1,109 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `Collator`](https://docs.rs/icu/latest/icu/collator/struct.Collator.html) for more information. +final class Collator implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + Collator._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XCollator_destroy)); + + /// Construct a new Collator instance. + /// + /// See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/collator/struct.Collator.html#method.try_new) for more information. + /// + /// Throws [Error] on failure. + factory Collator( + DataProvider provider, Locale locale, CollatorOptions options) { + final temp = ffi2.Arena(); + final result = _ICU4XCollator_create_v1( + provider._ffi, locale._ffi, options._toFfi(temp)); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return Collator._fromFfi(result.union.ok, []); + } + + /// Compare two strings. + /// + /// Ill-formed input is treated as if errors had been replaced with REPLACEMENT CHARACTERs according + /// to the WHATWG Encoding Standard. + /// + /// See the [Rust documentation for `compare_utf16`](https://docs.rs/icu/latest/icu/collator/struct.Collator.html#method.compare_utf16) for more information. + int compare(String left, String right) { + final temp = ffi2.Arena(); + final leftView = left.utf16View; + final rightView = right.utf16View; + final result = _ICU4XCollator_compare_utf16_(_ffi, leftView.allocIn(temp), + leftView.length, rightView.allocIn(temp), rightView.length); + temp.releaseAll(); + return result; + } + + /// The resolved options showing how the default options, the requested options, + /// and the options from locale data were combined. None of the struct fields + /// will have `Auto` as the value. + /// + /// See the [Rust documentation for `resolved_options`](https://docs.rs/icu/latest/icu/collator/struct.Collator.html#method.resolved_options) for more information. + ResolvedCollatorOptions get resolvedOptions { + final result = _ICU4XCollator_resolved_options(_ffi); + return ResolvedCollatorOptions._fromFfi(result); + } +} + +@meta.ResourceIdentifier('ICU4XCollator_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCollator_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XCollator_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCollator_create_v1') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, + ffi.Pointer, + _CollatorOptionsFfi)>(isLeaf: true, symbol: 'ICU4XCollator_create_v1') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCollator_create_v1( + ffi.Pointer provider, + ffi.Pointer locale, + _CollatorOptionsFfi options); + +@meta.ResourceIdentifier('ICU4XCollator_compare_utf16_') +@ffi.Native< + ffi.Int8 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size, + ffi.Pointer, + ffi.Size)>(isLeaf: true, symbol: 'ICU4XCollator_compare_utf16_') +// ignore: non_constant_identifier_names +external int _ICU4XCollator_compare_utf16_( + ffi.Pointer self, + ffi.Pointer leftData, + int leftLength, + ffi.Pointer rightData, + int rightLength); + +@meta.ResourceIdentifier('ICU4XCollator_resolved_options') +@ffi.Native<_ResolvedCollatorOptionsFfi Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCollator_resolved_options') +// ignore: non_constant_identifier_names +external _ResolvedCollatorOptionsFfi _ICU4XCollator_resolved_options( + ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/CollatorAlternateHandling.g.dart b/pkgs/intl4x/lib/src/bindings/CollatorAlternateHandling.g.dart deleted file mode 120000 index 0bdfdb57..00000000 --- a/pkgs/intl4x/lib/src/bindings/CollatorAlternateHandling.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CollatorAlternateHandling.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CollatorAlternateHandling.g.dart b/pkgs/intl4x/lib/src/bindings/CollatorAlternateHandling.g.dart new file mode 100644 index 00000000..3f4d20ef --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CollatorAlternateHandling.g.dart @@ -0,0 +1,12 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `AlternateHandling`](https://docs.rs/icu/latest/icu/collator/enum.AlternateHandling.html) for more information. +enum CollatorAlternateHandling { + auto, + + nonIgnorable, + + shifted; +} diff --git a/pkgs/intl4x/lib/src/bindings/CollatorBackwardSecondLevel.g.dart b/pkgs/intl4x/lib/src/bindings/CollatorBackwardSecondLevel.g.dart deleted file mode 120000 index a6e27f89..00000000 --- a/pkgs/intl4x/lib/src/bindings/CollatorBackwardSecondLevel.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CollatorBackwardSecondLevel.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CollatorBackwardSecondLevel.g.dart b/pkgs/intl4x/lib/src/bindings/CollatorBackwardSecondLevel.g.dart new file mode 100644 index 00000000..aeb1fee5 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CollatorBackwardSecondLevel.g.dart @@ -0,0 +1,12 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `BackwardSecondLevel`](https://docs.rs/icu/latest/icu/collator/enum.BackwardSecondLevel.html) for more information. +enum CollatorBackwardSecondLevel { + auto, + + off, + + on; +} diff --git a/pkgs/intl4x/lib/src/bindings/CollatorCaseFirst.g.dart b/pkgs/intl4x/lib/src/bindings/CollatorCaseFirst.g.dart deleted file mode 120000 index 7462732d..00000000 --- a/pkgs/intl4x/lib/src/bindings/CollatorCaseFirst.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CollatorCaseFirst.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CollatorCaseFirst.g.dart b/pkgs/intl4x/lib/src/bindings/CollatorCaseFirst.g.dart new file mode 100644 index 00000000..7e93127f --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CollatorCaseFirst.g.dart @@ -0,0 +1,14 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `CaseFirst`](https://docs.rs/icu/latest/icu/collator/enum.CaseFirst.html) for more information. +enum CollatorCaseFirst { + auto, + + off, + + lowerFirst, + + upperFirst; +} diff --git a/pkgs/intl4x/lib/src/bindings/CollatorCaseLevel.g.dart b/pkgs/intl4x/lib/src/bindings/CollatorCaseLevel.g.dart deleted file mode 120000 index 7797c971..00000000 --- a/pkgs/intl4x/lib/src/bindings/CollatorCaseLevel.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CollatorCaseLevel.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CollatorCaseLevel.g.dart b/pkgs/intl4x/lib/src/bindings/CollatorCaseLevel.g.dart new file mode 100644 index 00000000..aa5d5056 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CollatorCaseLevel.g.dart @@ -0,0 +1,12 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `CaseLevel`](https://docs.rs/icu/latest/icu/collator/enum.CaseLevel.html) for more information. +enum CollatorCaseLevel { + auto, + + off, + + on; +} diff --git a/pkgs/intl4x/lib/src/bindings/CollatorMaxVariable.g.dart b/pkgs/intl4x/lib/src/bindings/CollatorMaxVariable.g.dart deleted file mode 120000 index 0213d811..00000000 --- a/pkgs/intl4x/lib/src/bindings/CollatorMaxVariable.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CollatorMaxVariable.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CollatorMaxVariable.g.dart b/pkgs/intl4x/lib/src/bindings/CollatorMaxVariable.g.dart new file mode 100644 index 00000000..bdfdf984 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CollatorMaxVariable.g.dart @@ -0,0 +1,16 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `MaxVariable`](https://docs.rs/icu/latest/icu/collator/enum.MaxVariable.html) for more information. +enum CollatorMaxVariable { + auto, + + space, + + punctuation, + + symbol, + + currency; +} diff --git a/pkgs/intl4x/lib/src/bindings/CollatorNumeric.g.dart b/pkgs/intl4x/lib/src/bindings/CollatorNumeric.g.dart deleted file mode 120000 index 26d6ea94..00000000 --- a/pkgs/intl4x/lib/src/bindings/CollatorNumeric.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CollatorNumeric.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CollatorNumeric.g.dart b/pkgs/intl4x/lib/src/bindings/CollatorNumeric.g.dart new file mode 100644 index 00000000..99f5ff34 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CollatorNumeric.g.dart @@ -0,0 +1,12 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `Numeric`](https://docs.rs/icu/latest/icu/collator/enum.Numeric.html) for more information. +enum CollatorNumeric { + auto, + + off, + + on; +} diff --git a/pkgs/intl4x/lib/src/bindings/CollatorOptions.g.dart b/pkgs/intl4x/lib/src/bindings/CollatorOptions.g.dart deleted file mode 120000 index b7f55830..00000000 --- a/pkgs/intl4x/lib/src/bindings/CollatorOptions.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CollatorOptions.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CollatorOptions.g.dart b/pkgs/intl4x/lib/src/bindings/CollatorOptions.g.dart new file mode 100644 index 00000000..34b9d4cc --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CollatorOptions.g.dart @@ -0,0 +1,92 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +final class _CollatorOptionsFfi extends ffi.Struct { + @ffi.Int32() + external int strength; + @ffi.Int32() + external int alternateHandling; + @ffi.Int32() + external int caseFirst; + @ffi.Int32() + external int maxVariable; + @ffi.Int32() + external int caseLevel; + @ffi.Int32() + external int numeric; + @ffi.Int32() + external int backwardSecondLevel; +} + +/// See the [Rust documentation for `CollatorOptions`](https://docs.rs/icu/latest/icu/collator/struct.CollatorOptions.html) for more information. +final class CollatorOptions { + CollatorStrength strength; + CollatorAlternateHandling alternateHandling; + CollatorCaseFirst caseFirst; + CollatorMaxVariable maxVariable; + CollatorCaseLevel caseLevel; + CollatorNumeric numeric; + CollatorBackwardSecondLevel backwardSecondLevel; + + CollatorOptions( + {required this.strength, + required this.alternateHandling, + required this.caseFirst, + required this.maxVariable, + required this.caseLevel, + required this.numeric, + required this.backwardSecondLevel}); + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + CollatorOptions._fromFfi(_CollatorOptionsFfi ffi) + : strength = CollatorStrength.values[ffi.strength], + alternateHandling = + CollatorAlternateHandling.values[ffi.alternateHandling], + caseFirst = CollatorCaseFirst.values[ffi.caseFirst], + maxVariable = CollatorMaxVariable.values[ffi.maxVariable], + caseLevel = CollatorCaseLevel.values[ffi.caseLevel], + numeric = CollatorNumeric.values[ffi.numeric], + backwardSecondLevel = + CollatorBackwardSecondLevel.values[ffi.backwardSecondLevel]; + + // ignore: unused_element + _CollatorOptionsFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_CollatorOptionsFfi>(); + struct.strength = strength.index; + struct.alternateHandling = alternateHandling.index; + struct.caseFirst = caseFirst.index; + struct.maxVariable = maxVariable.index; + struct.caseLevel = caseLevel.index; + struct.numeric = numeric.index; + struct.backwardSecondLevel = backwardSecondLevel.index; + return struct; + } + + @override + bool operator ==(Object other) => + other is CollatorOptions && + other.strength == strength && + other.alternateHandling == alternateHandling && + other.caseFirst == caseFirst && + other.maxVariable == maxVariable && + other.caseLevel == caseLevel && + other.numeric == numeric && + other.backwardSecondLevel == backwardSecondLevel; + + @override + int get hashCode => Object.hashAll([ + strength, + alternateHandling, + caseFirst, + maxVariable, + caseLevel, + numeric, + backwardSecondLevel, + ]); +} diff --git a/pkgs/intl4x/lib/src/bindings/CollatorStrength.g.dart b/pkgs/intl4x/lib/src/bindings/CollatorStrength.g.dart deleted file mode 120000 index fee3edae..00000000 --- a/pkgs/intl4x/lib/src/bindings/CollatorStrength.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CollatorStrength.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CollatorStrength.g.dart b/pkgs/intl4x/lib/src/bindings/CollatorStrength.g.dart new file mode 100644 index 00000000..dbf12c7a --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CollatorStrength.g.dart @@ -0,0 +1,18 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `Strength`](https://docs.rs/icu/latest/icu/collator/enum.Strength.html) for more information. +enum CollatorStrength { + auto, + + primary, + + secondary, + + tertiary, + + quaternary, + + identical; +} diff --git a/pkgs/intl4x/lib/src/bindings/ComposingNormalizer.g.dart b/pkgs/intl4x/lib/src/bindings/ComposingNormalizer.g.dart deleted file mode 120000 index 8b3b82a3..00000000 --- a/pkgs/intl4x/lib/src/bindings/ComposingNormalizer.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/ComposingNormalizer.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/ComposingNormalizer.g.dart b/pkgs/intl4x/lib/src/bindings/ComposingNormalizer.g.dart new file mode 100644 index 00000000..648572e8 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/ComposingNormalizer.g.dart @@ -0,0 +1,128 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `ComposingNormalizer`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html) for more information. +final class ComposingNormalizer implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + ComposingNormalizer._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XComposingNormalizer_destroy)); + + /// Construct a new ICU4XComposingNormalizer instance for NFC + /// + /// See the [Rust documentation for `new_nfc`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html#method.new_nfc) for more information. + /// + /// Throws [Error] on failure. + factory ComposingNormalizer.nfc(DataProvider provider) { + final result = _ICU4XComposingNormalizer_create_nfc(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return ComposingNormalizer._fromFfi(result.union.ok, []); + } + + /// Construct a new ICU4XComposingNormalizer instance for NFKC + /// + /// See the [Rust documentation for `new_nfkc`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html#method.new_nfkc) for more information. + /// + /// Throws [Error] on failure. + factory ComposingNormalizer.nfkc(DataProvider provider) { + final result = _ICU4XComposingNormalizer_create_nfkc(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return ComposingNormalizer._fromFfi(result.union.ok, []); + } + + /// Normalize a string + /// + /// Ill-formed input is treated as if errors had been replaced with REPLACEMENT CHARACTERs according + /// to the WHATWG Encoding Standard. + /// + /// See the [Rust documentation for `normalize_utf8`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html#method.normalize_utf8) for more information. + /// + /// Throws [Error] on failure. + String normalize(String s) { + final temp = ffi2.Arena(); + final sView = s.utf8View; + final writeable = _Writeable(); + final result = _ICU4XComposingNormalizer_normalize( + _ffi, sView.allocIn(temp), sView.length, writeable._ffi); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Check if a string is normalized + /// + /// Ill-formed input is treated as if errors had been replaced with REPLACEMENT CHARACTERs according + /// to the WHATWG Encoding Standard. + /// + /// See the [Rust documentation for `is_normalized_utf8`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html#method.is_normalized_utf8) for more information. + bool isNormalized(String s) { + final temp = ffi2.Arena(); + final sView = s.utf8View; + final result = _ICU4XComposingNormalizer_is_normalized( + _ffi, sView.allocIn(temp), sView.length); + temp.releaseAll(); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XComposingNormalizer_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XComposingNormalizer_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XComposingNormalizer_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XComposingNormalizer_create_nfc') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XComposingNormalizer_create_nfc') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XComposingNormalizer_create_nfc( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XComposingNormalizer_create_nfkc') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XComposingNormalizer_create_nfkc') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XComposingNormalizer_create_nfkc( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XComposingNormalizer_normalize') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Size, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XComposingNormalizer_normalize') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XComposingNormalizer_normalize( + ffi.Pointer self, + ffi.Pointer sData, + int sLength, + ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XComposingNormalizer_is_normalized') +@ffi.Native< + ffi.Bool Function( + ffi.Pointer, ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XComposingNormalizer_is_normalized') +// ignore: non_constant_identifier_names +external bool _ICU4XComposingNormalizer_is_normalized( + ffi.Pointer self, ffi.Pointer sData, int sLength); diff --git a/pkgs/intl4x/lib/src/bindings/CustomTimeZone.g.dart b/pkgs/intl4x/lib/src/bindings/CustomTimeZone.g.dart deleted file mode 120000 index 6cfcaf54..00000000 --- a/pkgs/intl4x/lib/src/bindings/CustomTimeZone.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/CustomTimeZone.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/CustomTimeZone.g.dart b/pkgs/intl4x/lib/src/bindings/CustomTimeZone.g.dart new file mode 100644 index 00000000..4bdc9b64 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/CustomTimeZone.g.dart @@ -0,0 +1,584 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `CustomTimeZone`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html) for more information. +final class CustomTimeZone implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + CustomTimeZone._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XCustomTimeZone_destroy)); + + /// Creates a time zone from an offset string. + /// + /// See the [Rust documentation for `from_str`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.from_str) for more information. + /// + /// Throws [Error] on failure. + factory CustomTimeZone.fromString(String s) { + final temp = ffi2.Arena(); + final sView = s.utf8View; + final result = _ICU4XCustomTimeZone_create_from_string( + sView.allocIn(temp), sView.length); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return CustomTimeZone._fromFfi(result.union.ok, []); + } + + /// Creates a time zone with no information. + /// + /// See the [Rust documentation for `new_empty`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.new_empty) for more information. + factory CustomTimeZone.empty() { + final result = _ICU4XCustomTimeZone_create_empty(); + return CustomTimeZone._fromFfi(result, []); + } + + /// Creates a time zone for UTC. + /// + /// See the [Rust documentation for `utc`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.utc) for more information. + factory CustomTimeZone.utc() { + final result = _ICU4XCustomTimeZone_create_utc(); + return CustomTimeZone._fromFfi(result, []); + } + + /// Sets the `gmt_offset` field from offset seconds. + /// + /// Errors if the offset seconds are out of range. + /// + /// See the [Rust documentation for `try_from_offset_seconds`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.try_from_offset_seconds) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html) + /// + /// Throws [Error] on failure. + void trySetGmtOffsetSeconds(int offsetSeconds) { + final result = + _ICU4XCustomTimeZone_try_set_gmt_offset_seconds(_ffi, offsetSeconds); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// Clears the `gmt_offset` field. + /// + /// See the [Rust documentation for `offset_seconds`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.offset_seconds) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html) + void clearGmtOffset() { + _ICU4XCustomTimeZone_clear_gmt_offset(_ffi); + } + + /// Returns the value of the `gmt_offset` field as offset seconds. + /// + /// Errors if the `gmt_offset` field is empty. + /// + /// See the [Rust documentation for `offset_seconds`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.offset_seconds) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html) + /// + /// Throws [Error] on failure. + int get gmtOffsetSeconds { + final result = _ICU4XCustomTimeZone_gmt_offset_seconds(_ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return result.union.ok; + } + + /// Returns whether the `gmt_offset` field is positive. + /// + /// Errors if the `gmt_offset` field is empty. + /// + /// See the [Rust documentation for `is_positive`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.is_positive) for more information. + /// + /// Throws [Error] on failure. + bool get isGmtOffsetPositive { + final result = _ICU4XCustomTimeZone_is_gmt_offset_positive(_ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return result.union.ok; + } + + /// Returns whether the `gmt_offset` field is zero. + /// + /// Errors if the `gmt_offset` field is empty (which is not the same as zero). + /// + /// See the [Rust documentation for `is_zero`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.is_zero) for more information. + /// + /// Throws [Error] on failure. + bool get isGmtOffsetZero { + final result = _ICU4XCustomTimeZone_is_gmt_offset_zero(_ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return result.union.ok; + } + + /// Returns whether the `gmt_offset` field has nonzero minutes. + /// + /// Errors if the `gmt_offset` field is empty. + /// + /// See the [Rust documentation for `has_minutes`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.has_minutes) for more information. + /// + /// Throws [Error] on failure. + bool get gmtOffsetHasMinutes { + final result = _ICU4XCustomTimeZone_gmt_offset_has_minutes(_ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return result.union.ok; + } + + /// Returns whether the `gmt_offset` field has nonzero seconds. + /// + /// Errors if the `gmt_offset` field is empty. + /// + /// See the [Rust documentation for `has_seconds`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.has_seconds) for more information. + /// + /// Throws [Error] on failure. + bool get gmtOffsetHasSeconds { + final result = _ICU4XCustomTimeZone_gmt_offset_has_seconds(_ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return result.union.ok; + } + + /// Sets the `time_zone_id` field from a BCP-47 string. + /// + /// Errors if the string is not a valid BCP-47 time zone ID. + /// + /// See the [Rust documentation for `time_zone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.time_zone_id) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneBcp47Id.html) + /// + /// Throws [Error] on failure. + void trySetTimeZoneId(String id) { + final temp = ffi2.Arena(); + final idView = id.utf8View; + final result = _ICU4XCustomTimeZone_try_set_time_zone_id( + _ffi, idView.allocIn(temp), idView.length); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// Sets the `time_zone_id` field from an IANA string by looking up + /// the corresponding BCP-47 string. + /// + /// Errors if the string is not a valid BCP-47 time zone ID. + /// + /// See the [Rust documentation for `get`](https://docs.rs/icu/latest/icu/timezone/struct.IanaToBcp47MapperBorrowed.html#method.get) for more information. + /// + /// Throws [Error] on failure. + void trySetIanaTimeZoneId(IanaToBcp47Mapper mapper, String id) { + final temp = ffi2.Arena(); + final idView = id.utf8View; + final result = _ICU4XCustomTimeZone_try_set_iana_time_zone_id( + _ffi, mapper._ffi, idView.allocIn(temp), idView.length); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// Clears the `time_zone_id` field. + /// + /// See the [Rust documentation for `time_zone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.time_zone_id) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneBcp47Id.html) + void clearTimeZoneId() { + _ICU4XCustomTimeZone_clear_time_zone_id(_ffi); + } + + /// Writes the value of the `time_zone_id` field as a string. + /// + /// Errors if the `time_zone_id` field is empty. + /// + /// See the [Rust documentation for `time_zone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.time_zone_id) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneBcp47Id.html) + /// + /// Throws [Error] on failure. + String get timeZoneId { + final writeable = _Writeable(); + final result = _ICU4XCustomTimeZone_time_zone_id(_ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Sets the `metazone_id` field from a string. + /// + /// Errors if the string is not a valid BCP-47 metazone ID. + /// + /// See the [Rust documentation for `metazone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.metazone_id) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneId.html) + /// + /// Throws [Error] on failure. + void trySetMetazoneId(String id) { + final temp = ffi2.Arena(); + final idView = id.utf8View; + final result = _ICU4XCustomTimeZone_try_set_metazone_id( + _ffi, idView.allocIn(temp), idView.length); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// Clears the `metazone_id` field. + /// + /// See the [Rust documentation for `metazone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.metazone_id) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneId.html) + void clearMetazoneId() { + _ICU4XCustomTimeZone_clear_metazone_id(_ffi); + } + + /// Writes the value of the `metazone_id` field as a string. + /// + /// Errors if the `metazone_id` field is empty. + /// + /// See the [Rust documentation for `metazone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.metazone_id) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneId.html) + /// + /// Throws [Error] on failure. + String get metazoneId { + final writeable = _Writeable(); + final result = _ICU4XCustomTimeZone_metazone_id(_ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Sets the `zone_variant` field from a string. + /// + /// Errors if the string is not a valid zone variant. + /// + /// See the [Rust documentation for `zone_variant`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html) + /// + /// Throws [Error] on failure. + void trySetZoneVariant(String id) { + final temp = ffi2.Arena(); + final idView = id.utf8View; + final result = _ICU4XCustomTimeZone_try_set_zone_variant( + _ffi, idView.allocIn(temp), idView.length); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// Clears the `zone_variant` field. + /// + /// See the [Rust documentation for `zone_variant`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html) + void clearZoneVariant() { + _ICU4XCustomTimeZone_clear_zone_variant(_ffi); + } + + /// Writes the value of the `zone_variant` field as a string. + /// + /// Errors if the `zone_variant` field is empty. + /// + /// See the [Rust documentation for `zone_variant`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html) + /// + /// Throws [Error] on failure. + String get zoneVariant { + final writeable = _Writeable(); + final result = _ICU4XCustomTimeZone_zone_variant(_ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Sets the `zone_variant` field to standard time. + /// + /// See the [Rust documentation for `standard`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.standard) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) + void setStandardTime() { + _ICU4XCustomTimeZone_set_standard_time(_ffi); + } + + /// Sets the `zone_variant` field to daylight time. + /// + /// See the [Rust documentation for `daylight`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.daylight) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) + void setDaylightTime() { + _ICU4XCustomTimeZone_set_daylight_time(_ffi); + } + + /// Returns whether the `zone_variant` field is standard time. + /// + /// Errors if the `zone_variant` field is empty. + /// + /// See the [Rust documentation for `standard`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.standard) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) + /// + /// Throws [Error] on failure. + bool get isStandardTime { + final result = _ICU4XCustomTimeZone_is_standard_time(_ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return result.union.ok; + } + + /// Returns whether the `zone_variant` field is daylight time. + /// + /// Errors if the `zone_variant` field is empty. + /// + /// See the [Rust documentation for `daylight`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.daylight) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) + /// + /// Throws [Error] on failure. + bool get isDaylightTime { + final result = _ICU4XCustomTimeZone_is_daylight_time(_ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return result.union.ok; + } + + /// Sets the metazone based on the time zone and the local timestamp. + /// + /// See the [Rust documentation for `maybe_calculate_metazone`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.maybe_calculate_metazone) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneCalculator.html#method.compute_metazone_from_time_zone) + void maybeCalculateMetazone( + MetazoneCalculator metazoneCalculator, IsoDateTime localDatetime) { + _ICU4XCustomTimeZone_maybe_calculate_metazone( + _ffi, metazoneCalculator._ffi, localDatetime._ffi); + } +} + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XCustomTimeZone_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_create_from_string') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_create_from_string') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XCustomTimeZone_create_from_string( + ffi.Pointer sData, int sLength); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_create_empty') +@ffi.Native Function()>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_create_empty') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XCustomTimeZone_create_empty(); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_create_utc') +@ffi.Native Function()>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_create_utc') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XCustomTimeZone_create_utc(); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_try_set_gmt_offset_seconds') +@ffi.Native<_ResultVoidInt32 Function(ffi.Pointer, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_try_set_gmt_offset_seconds') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XCustomTimeZone_try_set_gmt_offset_seconds( + ffi.Pointer self, int offsetSeconds); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_clear_gmt_offset') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_clear_gmt_offset') +// ignore: non_constant_identifier_names +external void _ICU4XCustomTimeZone_clear_gmt_offset( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_gmt_offset_seconds') +@ffi.Native<_ResultInt32Int32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_gmt_offset_seconds') +// ignore: non_constant_identifier_names +external _ResultInt32Int32 _ICU4XCustomTimeZone_gmt_offset_seconds( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_is_gmt_offset_positive') +@ffi.Native<_ResultBoolInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_is_gmt_offset_positive') +// ignore: non_constant_identifier_names +external _ResultBoolInt32 _ICU4XCustomTimeZone_is_gmt_offset_positive( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_is_gmt_offset_zero') +@ffi.Native<_ResultBoolInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_is_gmt_offset_zero') +// ignore: non_constant_identifier_names +external _ResultBoolInt32 _ICU4XCustomTimeZone_is_gmt_offset_zero( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_gmt_offset_has_minutes') +@ffi.Native<_ResultBoolInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_gmt_offset_has_minutes') +// ignore: non_constant_identifier_names +external _ResultBoolInt32 _ICU4XCustomTimeZone_gmt_offset_has_minutes( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_gmt_offset_has_seconds') +@ffi.Native<_ResultBoolInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_gmt_offset_has_seconds') +// ignore: non_constant_identifier_names +external _ResultBoolInt32 _ICU4XCustomTimeZone_gmt_offset_has_seconds( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_try_set_time_zone_id') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_try_set_time_zone_id') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XCustomTimeZone_try_set_time_zone_id( + ffi.Pointer self, ffi.Pointer idData, int idLength); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_try_set_iana_time_zone_id') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_try_set_iana_time_zone_id') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XCustomTimeZone_try_set_iana_time_zone_id( + ffi.Pointer self, + ffi.Pointer mapper, + ffi.Pointer idData, + int idLength); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_clear_time_zone_id') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_clear_time_zone_id') +// ignore: non_constant_identifier_names +external void _ICU4XCustomTimeZone_clear_time_zone_id( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_time_zone_id') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_time_zone_id') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XCustomTimeZone_time_zone_id( + ffi.Pointer self, ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_try_set_metazone_id') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_try_set_metazone_id') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XCustomTimeZone_try_set_metazone_id( + ffi.Pointer self, ffi.Pointer idData, int idLength); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_clear_metazone_id') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_clear_metazone_id') +// ignore: non_constant_identifier_names +external void _ICU4XCustomTimeZone_clear_metazone_id( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_metazone_id') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_metazone_id') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XCustomTimeZone_metazone_id( + ffi.Pointer self, ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_try_set_zone_variant') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_try_set_zone_variant') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XCustomTimeZone_try_set_zone_variant( + ffi.Pointer self, ffi.Pointer idData, int idLength); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_clear_zone_variant') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_clear_zone_variant') +// ignore: non_constant_identifier_names +external void _ICU4XCustomTimeZone_clear_zone_variant( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_zone_variant') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_zone_variant') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XCustomTimeZone_zone_variant( + ffi.Pointer self, ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_set_standard_time') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_set_standard_time') +// ignore: non_constant_identifier_names +external void _ICU4XCustomTimeZone_set_standard_time( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_set_daylight_time') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_set_daylight_time') +// ignore: non_constant_identifier_names +external void _ICU4XCustomTimeZone_set_daylight_time( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_is_standard_time') +@ffi.Native<_ResultBoolInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_is_standard_time') +// ignore: non_constant_identifier_names +external _ResultBoolInt32 _ICU4XCustomTimeZone_is_standard_time( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_is_daylight_time') +@ffi.Native<_ResultBoolInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_is_daylight_time') +// ignore: non_constant_identifier_names +external _ResultBoolInt32 _ICU4XCustomTimeZone_is_daylight_time( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XCustomTimeZone_maybe_calculate_metazone') +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XCustomTimeZone_maybe_calculate_metazone') +// ignore: non_constant_identifier_names +external void _ICU4XCustomTimeZone_maybe_calculate_metazone( + ffi.Pointer self, + ffi.Pointer metazoneCalculator, + ffi.Pointer localDatetime); diff --git a/pkgs/intl4x/lib/src/bindings/DataProvider.g.dart b/pkgs/intl4x/lib/src/bindings/DataProvider.g.dart deleted file mode 120000 index 720eb504..00000000 --- a/pkgs/intl4x/lib/src/bindings/DataProvider.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/DataProvider.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/DataProvider.g.dart b/pkgs/intl4x/lib/src/bindings/DataProvider.g.dart new file mode 100644 index 00000000..e9c7e067 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/DataProvider.g.dart @@ -0,0 +1,182 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X data provider, capable of loading ICU4X data keys from some source. +/// +/// See the [Rust documentation for `icu_provider`](https://docs.rs/icu_provider/latest/icu_provider/index.html) for more information. +final class DataProvider implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + DataProvider._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XDataProvider_destroy)); + + /// Constructs an [`DataProvider`] that uses compiled data. + /// + /// Requires the `compiled_data` feature. + /// + /// This provider cannot be modified or combined with other providers, so `enable_fallback`, + /// `enabled_fallback_with`, `fork_by_locale`, and `fork_by_key` will return `Err`s. + factory DataProvider.compiled() { + final result = _ICU4XDataProvider_create_compiled(); + return DataProvider._fromFfi(result, []); + } + + /// Constructs a `BlobDataProvider` and returns it as an [`DataProvider`]. + /// + /// See the [Rust documentation for `BlobDataProvider`](https://docs.rs/icu_provider_blob/latest/icu_provider_blob/struct.BlobDataProvider.html) for more information. + /// + /// Throws [Error] on failure. + factory DataProvider.fromByteSlice(ByteBuffer blob) { + final temp = ffi2.Arena(); + final blobView = blob; + final result = _ICU4XDataProvider_create_from_byte_slice( + blobView.allocIn(temp), blobView.length); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return DataProvider._fromFfi(result.union.ok, []); + } + + /// Constructs an empty [`DataProvider`]. + /// + /// See the [Rust documentation for `EmptyDataProvider`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/empty/struct.EmptyDataProvider.html) for more information. + factory DataProvider.empty() { + final result = _ICU4XDataProvider_create_empty(); + return DataProvider._fromFfi(result, []); + } + + /// Creates a provider that tries the current provider and then, if the current provider + /// doesn't support the data key, another provider `other`. + /// + /// This takes ownership of the `other` provider, leaving an empty provider in its place. + /// + /// The providers must be the same type (Any or Buffer). This condition is satisfied if + /// both providers originate from the same constructor, such as `create_from_byte_slice` + /// or `create_fs`. If the condition is not upheld, a runtime error occurs. + /// + /// See the [Rust documentation for `ForkByKeyProvider`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fork/type.ForkByKeyProvider.html) for more information. + /// + /// Throws [Error] on failure. + void forkByKey(DataProvider other) { + final result = _ICU4XDataProvider_fork_by_key(_ffi, other._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// Same as `fork_by_key` but forks by locale instead of key. + /// + /// See the [Rust documentation for `MissingLocalePredicate`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fork/predicates/struct.MissingLocalePredicate.html) for more information. + /// + /// Throws [Error] on failure. + void forkByLocale(DataProvider other) { + final result = _ICU4XDataProvider_fork_by_locale(_ffi, other._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// Enables locale fallbacking for data requests made to this provider. + /// + /// Note that the test provider (from `create_test`) already has fallbacking enabled. + /// + /// See the [Rust documentation for `try_new`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html#method.try_new) for more information. + /// + /// Additional information: [1](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html) + /// + /// Throws [Error] on failure. + void enableLocaleFallback() { + final result = _ICU4XDataProvider_enable_locale_fallback(_ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// See the [Rust documentation for `new_with_fallbacker`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html#method.new_with_fallbacker) for more information. + /// + /// Additional information: [1](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html) + /// + /// Throws [Error] on failure. + void enableLocaleFallbackWith(LocaleFallbacker fallbacker) { + final result = + _ICU4XDataProvider_enable_locale_fallback_with(_ffi, fallbacker._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } +} + +@meta.ResourceIdentifier('ICU4XDataProvider_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDataProvider_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XDataProvider_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDataProvider_create_compiled') +@ffi.Native Function()>( + isLeaf: true, symbol: 'ICU4XDataProvider_create_compiled') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XDataProvider_create_compiled(); + +@meta.ResourceIdentifier('ICU4XDataProvider_create_from_byte_slice') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XDataProvider_create_from_byte_slice') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XDataProvider_create_from_byte_slice( + ffi.Pointer blobData, int blobLength); + +@meta.ResourceIdentifier('ICU4XDataProvider_create_empty') +@ffi.Native Function()>( + isLeaf: true, symbol: 'ICU4XDataProvider_create_empty') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XDataProvider_create_empty(); + +@meta.ResourceIdentifier('ICU4XDataProvider_fork_by_key') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDataProvider_fork_by_key') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XDataProvider_fork_by_key( + ffi.Pointer self, ffi.Pointer other); + +@meta.ResourceIdentifier('ICU4XDataProvider_fork_by_locale') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDataProvider_fork_by_locale') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XDataProvider_fork_by_locale( + ffi.Pointer self, ffi.Pointer other); + +@meta.ResourceIdentifier('ICU4XDataProvider_enable_locale_fallback') +@ffi.Native<_ResultVoidInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDataProvider_enable_locale_fallback') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XDataProvider_enable_locale_fallback( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDataProvider_enable_locale_fallback_with') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDataProvider_enable_locale_fallback_with') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XDataProvider_enable_locale_fallback_with( + ffi.Pointer self, ffi.Pointer fallbacker); diff --git a/pkgs/intl4x/lib/src/bindings/Date.g.dart b/pkgs/intl4x/lib/src/bindings/Date.g.dart deleted file mode 120000 index f7a5ff56..00000000 --- a/pkgs/intl4x/lib/src/bindings/Date.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/Date.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/Date.g.dart b/pkgs/intl4x/lib/src/bindings/Date.g.dart new file mode 100644 index 00000000..db72664b --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/Date.g.dart @@ -0,0 +1,339 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X Date object capable of containing a date and time for any calendar. +/// +/// See the [Rust documentation for `Date`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html) for more information. +final class Date implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + Date._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XDate_destroy)); + + /// Creates a new [`Date`] representing the ISO date and time + /// given but in a given calendar + /// + /// See the [Rust documentation for `new_from_iso`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.new_from_iso) for more information. + /// + /// Throws [Error] on failure. + factory Date.fromIsoInCalendar( + int year, int month, int day, Calendar calendar) { + final result = + _ICU4XDate_create_from_iso_in_calendar(year, month, day, calendar._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return Date._fromFfi(result.union.ok, []); + } + + /// Creates a new [`Date`] from the given codes, which are interpreted in the given calendar system + /// + /// See the [Rust documentation for `try_new_from_codes`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.try_new_from_codes) for more information. + /// + /// Throws [Error] on failure. + factory Date.fromCodesInCalendar( + String eraCode, int year, String monthCode, int day, Calendar calendar) { + final temp = ffi2.Arena(); + final eraCodeView = eraCode.utf8View; + final monthCodeView = monthCode.utf8View; + final result = _ICU4XDate_create_from_codes_in_calendar( + eraCodeView.allocIn(temp), + eraCodeView.length, + year, + monthCodeView.allocIn(temp), + monthCodeView.length, + day, + calendar._ffi); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return Date._fromFfi(result.union.ok, []); + } + + /// Convert this date to one in a different calendar + /// + /// See the [Rust documentation for `to_calendar`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.to_calendar) for more information. + Date toCalendar(Calendar calendar) { + final result = _ICU4XDate_to_calendar(_ffi, calendar._ffi); + return Date._fromFfi(result, []); + } + + /// Converts this date to ISO + /// + /// See the [Rust documentation for `to_iso`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.to_iso) for more information. + IsoDate toIso() { + final result = _ICU4XDate_to_iso(_ffi); + return IsoDate._fromFfi(result, []); + } + + /// Returns the 1-indexed day in the month for this date + /// + /// See the [Rust documentation for `day_of_month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_month) for more information. + int get dayOfMonth { + final result = _ICU4XDate_day_of_month(_ffi); + return result; + } + + /// Returns the day in the week for this day + /// + /// See the [Rust documentation for `day_of_week`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_week) for more information. + IsoWeekday get dayOfWeek { + final result = _ICU4XDate_day_of_week(_ffi); + return IsoWeekday.values.firstWhere((v) => v._ffi == result); + } + + /// Returns the week number in this month, 1-indexed, based on what + /// is considered the first day of the week (often a locale preference). + /// + /// `first_weekday` can be obtained via `first_weekday()` on [`WeekCalculator`] + /// + /// See the [Rust documentation for `week_of_month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_month) for more information. + int weekOfMonth(IsoWeekday firstWeekday) { + final result = _ICU4XDate_week_of_month(_ffi, firstWeekday._ffi); + return result; + } + + /// Returns the week number in this year, using week data + /// + /// See the [Rust documentation for `week_of_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_year) for more information. + /// + /// Throws [Error] on failure. + WeekOf weekOfYear(WeekCalculator calculator) { + final result = _ICU4XDate_week_of_year(_ffi, calculator._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return WeekOf._fromFfi(result.union.ok); + } + + /// Returns 1-indexed number of the month of this date in its year + /// + /// Note that for lunar calendars this may not lead to the same month + /// having the same ordinal month across years; use month_code if you care + /// about month identity. + /// + /// See the [Rust documentation for `month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month) for more information. + int get ordinalMonth { + final result = _ICU4XDate_ordinal_month(_ffi); + return result; + } + + /// Returns the month code for this date. Typically something + /// like "M01", "M02", but can be more complicated for lunar calendars. + /// + /// See the [Rust documentation for `month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month) for more information. + /// + /// Throws [Error] on failure. + String get monthCode { + final writeable = _Writeable(); + final result = _ICU4XDate_month_code(_ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Returns the year number in the current era for this date + /// + /// See the [Rust documentation for `year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year) for more information. + int get yearInEra { + final result = _ICU4XDate_year_in_era(_ffi); + return result; + } + + /// Returns the era for this date, + /// + /// See the [Rust documentation for `year`](https://docs.rs/icu/latest/icu/struct.Date.html#method.year) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/types/struct.Era.html) + /// + /// Throws [Error] on failure. + String get era { + final writeable = _Writeable(); + final result = _ICU4XDate_era(_ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Returns the number of months in the year represented by this date + /// + /// See the [Rust documentation for `months_in_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.months_in_year) for more information. + int get monthsInYear { + final result = _ICU4XDate_months_in_year(_ffi); + return result; + } + + /// Returns the number of days in the month represented by this date + /// + /// See the [Rust documentation for `days_in_month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_month) for more information. + int get daysInMonth { + final result = _ICU4XDate_days_in_month(_ffi); + return result; + } + + /// Returns the number of days in the year represented by this date + /// + /// See the [Rust documentation for `days_in_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_year) for more information. + int get daysInYear { + final result = _ICU4XDate_days_in_year(_ffi); + return result; + } + + /// Returns the [`Calendar`] object backing this date + /// + /// See the [Rust documentation for `calendar`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.calendar) for more information. + Calendar get calendar { + final result = _ICU4XDate_calendar(_ffi); + return Calendar._fromFfi(result, []); + } +} + +@meta.ResourceIdentifier('ICU4XDate_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDate_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XDate_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDate_create_from_iso_in_calendar') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Int32, ffi.Uint8, ffi.Uint8, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDate_create_from_iso_in_calendar') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XDate_create_from_iso_in_calendar( + int year, int month, int day, ffi.Pointer calendar); + +@meta.ResourceIdentifier('ICU4XDate_create_from_codes_in_calendar') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, + ffi.Size, + ffi.Int32, + ffi.Pointer, + ffi.Size, + ffi.Uint8, + ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDate_create_from_codes_in_calendar') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XDate_create_from_codes_in_calendar( + ffi.Pointer eraCodeData, + int eraCodeLength, + int year, + ffi.Pointer monthCodeData, + int monthCodeLength, + int day, + ffi.Pointer calendar); + +@meta.ResourceIdentifier('ICU4XDate_to_calendar') +@ffi.Native< + ffi.Pointer Function(ffi.Pointer, + ffi.Pointer)>(isLeaf: true, symbol: 'ICU4XDate_to_calendar') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XDate_to_calendar( + ffi.Pointer self, ffi.Pointer calendar); + +@meta.ResourceIdentifier('ICU4XDate_to_iso') +@ffi.Native Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDate_to_iso') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XDate_to_iso( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDate_day_of_month') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDate_day_of_month') +// ignore: non_constant_identifier_names +external int _ICU4XDate_day_of_month(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDate_day_of_week') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDate_day_of_week') +// ignore: non_constant_identifier_names +external int _ICU4XDate_day_of_week(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDate_week_of_month') +@ffi.Native, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XDate_week_of_month') +// ignore: non_constant_identifier_names +external int _ICU4XDate_week_of_month( + ffi.Pointer self, int firstWeekday); + +@meta.ResourceIdentifier('ICU4XDate_week_of_year') +@ffi.Native< + _ResultWeekOfFfiInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDate_week_of_year') +// ignore: non_constant_identifier_names +external _ResultWeekOfFfiInt32 _ICU4XDate_week_of_year( + ffi.Pointer self, ffi.Pointer calculator); + +@meta.ResourceIdentifier('ICU4XDate_ordinal_month') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDate_ordinal_month') +// ignore: non_constant_identifier_names +external int _ICU4XDate_ordinal_month(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDate_month_code') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer)>(isLeaf: true, symbol: 'ICU4XDate_month_code') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XDate_month_code( + ffi.Pointer self, ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XDate_year_in_era') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDate_year_in_era') +// ignore: non_constant_identifier_names +external int _ICU4XDate_year_in_era(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDate_era') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer)>(isLeaf: true, symbol: 'ICU4XDate_era') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XDate_era( + ffi.Pointer self, ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XDate_months_in_year') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDate_months_in_year') +// ignore: non_constant_identifier_names +external int _ICU4XDate_months_in_year(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDate_days_in_month') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDate_days_in_month') +// ignore: non_constant_identifier_names +external int _ICU4XDate_days_in_month(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDate_days_in_year') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDate_days_in_year') +// ignore: non_constant_identifier_names +external int _ICU4XDate_days_in_year(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDate_calendar') +@ffi.Native Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDate_calendar') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XDate_calendar( + ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/DateFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/DateFormatter.g.dart deleted file mode 120000 index 99e37e09..00000000 --- a/pkgs/intl4x/lib/src/bindings/DateFormatter.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/DateFormatter.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/DateFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/DateFormatter.g.dart new file mode 100644 index 00000000..0dd7c6ab --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/DateFormatter.g.dart @@ -0,0 +1,168 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X DateFormatter object capable of formatting a [`Date`] as a string, +/// using some calendar specified at runtime in the locale. +/// +/// See the [Rust documentation for `DateFormatter`](https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html) for more information. +final class DateFormatter implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + DateFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XDateFormatter_destroy)); + + /// Creates a new [`DateFormatter`] from locale data. + /// + /// See the [Rust documentation for `try_new_with_length`](https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.try_new_with_length) for more information. + /// + /// Throws [Error] on failure. + factory DateFormatter.withLength( + DataProvider provider, Locale locale, DateLength dateLength) { + final result = _ICU4XDateFormatter_create_with_length( + provider._ffi, locale._ffi, dateLength.index); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return DateFormatter._fromFfi(result.union.ok, []); + } + + /// Formats a [`Date`] to a string. + /// + /// See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.format) for more information. + /// + /// Throws [Error] on failure. + String formatDate(Date value) { + final writeable = _Writeable(); + final result = + _ICU4XDateFormatter_format_date(_ffi, value._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Formats a [`IsoDate`] to a string. + /// + /// Will convert to this formatter's calendar first + /// + /// See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.format) for more information. + /// + /// Throws [Error] on failure. + String formatIsoDate(IsoDate value) { + final writeable = _Writeable(); + final result = + _ICU4XDateFormatter_format_iso_date(_ffi, value._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Formats a [`DateTime`] to a string. + /// + /// See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.format) for more information. + /// + /// Throws [Error] on failure. + String formatDatetime(DateTime value) { + final writeable = _Writeable(); + final result = + _ICU4XDateFormatter_format_datetime(_ffi, value._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Formats a [`IsoDateTime`] to a string. + /// + /// Will convert to this formatter's calendar first + /// + /// See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.format) for more information. + /// + /// Throws [Error] on failure. + String formatIsoDatetime(IsoDateTime value) { + final writeable = _Writeable(); + final result = _ICU4XDateFormatter_format_iso_datetime( + _ffi, value._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } +} + +@meta.ResourceIdentifier('ICU4XDateFormatter_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDateFormatter_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XDateFormatter_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDateFormatter_create_with_length') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XDateFormatter_create_with_length') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XDateFormatter_create_with_length( + ffi.Pointer provider, + ffi.Pointer locale, + int dateLength); + +@meta.ResourceIdentifier('ICU4XDateFormatter_format_date') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDateFormatter_format_date') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XDateFormatter_format_date( + ffi.Pointer self, + ffi.Pointer value, + ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XDateFormatter_format_iso_date') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDateFormatter_format_iso_date') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XDateFormatter_format_iso_date( + ffi.Pointer self, + ffi.Pointer value, + ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XDateFormatter_format_datetime') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDateFormatter_format_datetime') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XDateFormatter_format_datetime( + ffi.Pointer self, + ffi.Pointer value, + ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XDateFormatter_format_iso_datetime') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDateFormatter_format_iso_datetime') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XDateFormatter_format_iso_datetime( + ffi.Pointer self, + ffi.Pointer value, + ffi.Pointer writeable); diff --git a/pkgs/intl4x/lib/src/bindings/DateLength.g.dart b/pkgs/intl4x/lib/src/bindings/DateLength.g.dart deleted file mode 120000 index 99540b88..00000000 --- a/pkgs/intl4x/lib/src/bindings/DateLength.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/DateLength.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/DateLength.g.dart b/pkgs/intl4x/lib/src/bindings/DateLength.g.dart new file mode 100644 index 00000000..f4644220 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/DateLength.g.dart @@ -0,0 +1,14 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `Date`](https://docs.rs/icu/latest/icu/datetime/options/length/enum.Date.html) for more information. +enum DateLength { + full, + + long, + + medium, + + short; +} diff --git a/pkgs/intl4x/lib/src/bindings/DateTime.g.dart b/pkgs/intl4x/lib/src/bindings/DateTime.g.dart deleted file mode 120000 index acd736ce..00000000 --- a/pkgs/intl4x/lib/src/bindings/DateTime.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/DateTime.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/DateTime.g.dart b/pkgs/intl4x/lib/src/bindings/DateTime.g.dart new file mode 100644 index 00000000..e4f41303 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/DateTime.g.dart @@ -0,0 +1,470 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X DateTime object capable of containing a date and time for any calendar. +/// +/// See the [Rust documentation for `DateTime`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html) for more information. +final class DateTime implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + DateTime._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XDateTime_destroy)); + + /// Creates a new [`DateTime`] representing the ISO date and time + /// given but in a given calendar + /// + /// See the [Rust documentation for `new_from_iso`](https://docs.rs/icu/latest/icu/struct.DateTime.html#method.new_from_iso) for more information. + /// + /// Throws [Error] on failure. + factory DateTime.fromIsoInCalendar(int year, int month, int day, int hour, + int minute, int second, int nanosecond, Calendar calendar) { + final result = _ICU4XDateTime_create_from_iso_in_calendar( + year, month, day, hour, minute, second, nanosecond, calendar._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return DateTime._fromFfi(result.union.ok, []); + } + + /// Creates a new [`DateTime`] from the given codes, which are interpreted in the given calendar system + /// + /// See the [Rust documentation for `try_new_from_codes`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.try_new_from_codes) for more information. + /// + /// Throws [Error] on failure. + factory DateTime.fromCodesInCalendar( + String eraCode, + int year, + String monthCode, + int day, + int hour, + int minute, + int second, + int nanosecond, + Calendar calendar) { + final temp = ffi2.Arena(); + final eraCodeView = eraCode.utf8View; + final monthCodeView = monthCode.utf8View; + final result = _ICU4XDateTime_create_from_codes_in_calendar( + eraCodeView.allocIn(temp), + eraCodeView.length, + year, + monthCodeView.allocIn(temp), + monthCodeView.length, + day, + hour, + minute, + second, + nanosecond, + calendar._ffi); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return DateTime._fromFfi(result.union.ok, []); + } + + /// Creates a new [`DateTime`] from an [`Date`] and [`Time`] object + /// + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.new) for more information. + factory DateTime.fromDateAndTime(Date date, Time time) { + final result = + _ICU4XDateTime_create_from_date_and_time(date._ffi, time._ffi); + return DateTime._fromFfi(result, []); + } + + /// Gets a copy of the date contained in this object + /// + /// See the [Rust documentation for `date`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#structfield.date) for more information. + Date get date { + final result = _ICU4XDateTime_date(_ffi); + return Date._fromFfi(result, []); + } + + /// Gets the time contained in this object + /// + /// See the [Rust documentation for `time`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#structfield.time) for more information. + Time get time { + final result = _ICU4XDateTime_time(_ffi); + return Time._fromFfi(result, []); + } + + /// Converts this date to ISO + /// + /// See the [Rust documentation for `to_iso`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.to_iso) for more information. + IsoDateTime toIso() { + final result = _ICU4XDateTime_to_iso(_ffi); + return IsoDateTime._fromFfi(result, []); + } + + /// Convert this datetime to one in a different calendar + /// + /// See the [Rust documentation for `to_calendar`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.to_calendar) for more information. + DateTime toCalendar(Calendar calendar) { + final result = _ICU4XDateTime_to_calendar(_ffi, calendar._ffi); + return DateTime._fromFfi(result, []); + } + + /// Returns the hour in this time + /// + /// See the [Rust documentation for `hour`](https://docs.rs/icu/latest/icu/calendar/struct.Time.html#structfield.hour) for more information. + int get hour { + final result = _ICU4XDateTime_hour(_ffi); + return result; + } + + /// Returns the minute in this time + /// + /// See the [Rust documentation for `minute`](https://docs.rs/icu/latest/icu/calendar/struct.Time.html#structfield.minute) for more information. + int get minute { + final result = _ICU4XDateTime_minute(_ffi); + return result; + } + + /// Returns the second in this time + /// + /// See the [Rust documentation for `second`](https://docs.rs/icu/latest/icu/calendar/struct.Time.html#structfield.second) for more information. + int get second { + final result = _ICU4XDateTime_second(_ffi); + return result; + } + + /// Returns the nanosecond in this time + /// + /// See the [Rust documentation for `nanosecond`](https://docs.rs/icu/latest/icu/calendar/struct.Time.html#structfield.nanosecond) for more information. + int get nanosecond { + final result = _ICU4XDateTime_nanosecond(_ffi); + return result; + } + + /// Returns the 1-indexed day in the month for this date + /// + /// See the [Rust documentation for `day_of_month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_month) for more information. + int get dayOfMonth { + final result = _ICU4XDateTime_day_of_month(_ffi); + return result; + } + + /// Returns the day in the week for this day + /// + /// See the [Rust documentation for `day_of_week`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_week) for more information. + IsoWeekday get dayOfWeek { + final result = _ICU4XDateTime_day_of_week(_ffi); + return IsoWeekday.values.firstWhere((v) => v._ffi == result); + } + + /// Returns the week number in this month, 1-indexed, based on what + /// is considered the first day of the week (often a locale preference). + /// + /// `first_weekday` can be obtained via `first_weekday()` on [`WeekCalculator`] + /// + /// See the [Rust documentation for `week_of_month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_month) for more information. + int weekOfMonth(IsoWeekday firstWeekday) { + final result = _ICU4XDateTime_week_of_month(_ffi, firstWeekday._ffi); + return result; + } + + /// Returns the week number in this year, using week data + /// + /// See the [Rust documentation for `week_of_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_year) for more information. + /// + /// Throws [Error] on failure. + WeekOf weekOfYear(WeekCalculator calculator) { + final result = _ICU4XDateTime_week_of_year(_ffi, calculator._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return WeekOf._fromFfi(result.union.ok); + } + + /// Returns 1-indexed number of the month of this date in its year + /// + /// Note that for lunar calendars this may not lead to the same month + /// having the same ordinal month across years; use month_code if you care + /// about month identity. + /// + /// See the [Rust documentation for `month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month) for more information. + int get ordinalMonth { + final result = _ICU4XDateTime_ordinal_month(_ffi); + return result; + } + + /// Returns the month code for this date. Typically something + /// like "M01", "M02", but can be more complicated for lunar calendars. + /// + /// See the [Rust documentation for `month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month) for more information. + /// + /// Throws [Error] on failure. + String get monthCode { + final writeable = _Writeable(); + final result = _ICU4XDateTime_month_code(_ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Returns the year number in the current era for this date + /// + /// See the [Rust documentation for `year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year) for more information. + int get yearInEra { + final result = _ICU4XDateTime_year_in_era(_ffi); + return result; + } + + /// Returns the era for this date, + /// + /// See the [Rust documentation for `year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year) for more information. + /// + /// Throws [Error] on failure. + String get era { + final writeable = _Writeable(); + final result = _ICU4XDateTime_era(_ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Returns the number of months in the year represented by this date + /// + /// See the [Rust documentation for `months_in_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.months_in_year) for more information. + int get monthsInYear { + final result = _ICU4XDateTime_months_in_year(_ffi); + return result; + } + + /// Returns the number of days in the month represented by this date + /// + /// See the [Rust documentation for `days_in_month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_month) for more information. + int get daysInMonth { + final result = _ICU4XDateTime_days_in_month(_ffi); + return result; + } + + /// Returns the number of days in the year represented by this date + /// + /// See the [Rust documentation for `days_in_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_year) for more information. + int get daysInYear { + final result = _ICU4XDateTime_days_in_year(_ffi); + return result; + } + + /// Returns the [`Calendar`] object backing this date + /// + /// See the [Rust documentation for `calendar`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.calendar) for more information. + Calendar get calendar { + final result = _ICU4XDateTime_calendar(_ffi); + return Calendar._fromFfi(result, []); + } +} + +@meta.ResourceIdentifier('ICU4XDateTime_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDateTime_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XDateTime_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDateTime_create_from_iso_in_calendar') +@ffi.Native< + _ResultOpaqueInt32 Function(ffi.Int32, ffi.Uint8, ffi.Uint8, ffi.Uint8, + ffi.Uint8, ffi.Uint8, ffi.Uint32, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDateTime_create_from_iso_in_calendar') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XDateTime_create_from_iso_in_calendar( + int year, + int month, + int day, + int hour, + int minute, + int second, + int nanosecond, + ffi.Pointer calendar); + +@meta.ResourceIdentifier('ICU4XDateTime_create_from_codes_in_calendar') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, + ffi.Size, + ffi.Int32, + ffi.Pointer, + ffi.Size, + ffi.Uint8, + ffi.Uint8, + ffi.Uint8, + ffi.Uint8, + ffi.Uint32, + ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDateTime_create_from_codes_in_calendar') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XDateTime_create_from_codes_in_calendar( + ffi.Pointer eraCodeData, + int eraCodeLength, + int year, + ffi.Pointer monthCodeData, + int monthCodeLength, + int day, + int hour, + int minute, + int second, + int nanosecond, + ffi.Pointer calendar); + +@meta.ResourceIdentifier('ICU4XDateTime_create_from_date_and_time') +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDateTime_create_from_date_and_time') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XDateTime_create_from_date_and_time( + ffi.Pointer date, ffi.Pointer time); + +@meta.ResourceIdentifier('ICU4XDateTime_date') +@ffi.Native Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDateTime_date') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XDateTime_date( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDateTime_time') +@ffi.Native Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDateTime_time') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XDateTime_time( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDateTime_to_iso') +@ffi.Native Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDateTime_to_iso') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XDateTime_to_iso( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDateTime_to_calendar') +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDateTime_to_calendar') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XDateTime_to_calendar( + ffi.Pointer self, ffi.Pointer calendar); + +@meta.ResourceIdentifier('ICU4XDateTime_hour') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDateTime_hour') +// ignore: non_constant_identifier_names +external int _ICU4XDateTime_hour(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDateTime_minute') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDateTime_minute') +// ignore: non_constant_identifier_names +external int _ICU4XDateTime_minute(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDateTime_second') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDateTime_second') +// ignore: non_constant_identifier_names +external int _ICU4XDateTime_second(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDateTime_nanosecond') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDateTime_nanosecond') +// ignore: non_constant_identifier_names +external int _ICU4XDateTime_nanosecond(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDateTime_day_of_month') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDateTime_day_of_month') +// ignore: non_constant_identifier_names +external int _ICU4XDateTime_day_of_month(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDateTime_day_of_week') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDateTime_day_of_week') +// ignore: non_constant_identifier_names +external int _ICU4XDateTime_day_of_week(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDateTime_week_of_month') +@ffi.Native, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XDateTime_week_of_month') +// ignore: non_constant_identifier_names +external int _ICU4XDateTime_week_of_month( + ffi.Pointer self, int firstWeekday); + +@meta.ResourceIdentifier('ICU4XDateTime_week_of_year') +@ffi.Native< + _ResultWeekOfFfiInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDateTime_week_of_year') +// ignore: non_constant_identifier_names +external _ResultWeekOfFfiInt32 _ICU4XDateTime_week_of_year( + ffi.Pointer self, ffi.Pointer calculator); + +@meta.ResourceIdentifier('ICU4XDateTime_ordinal_month') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDateTime_ordinal_month') +// ignore: non_constant_identifier_names +external int _ICU4XDateTime_ordinal_month(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDateTime_month_code') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDateTime_month_code') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XDateTime_month_code( + ffi.Pointer self, ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XDateTime_year_in_era') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDateTime_year_in_era') +// ignore: non_constant_identifier_names +external int _ICU4XDateTime_year_in_era(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDateTime_era') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer)>(isLeaf: true, symbol: 'ICU4XDateTime_era') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XDateTime_era( + ffi.Pointer self, ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XDateTime_months_in_year') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDateTime_months_in_year') +// ignore: non_constant_identifier_names +external int _ICU4XDateTime_months_in_year(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDateTime_days_in_month') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDateTime_days_in_month') +// ignore: non_constant_identifier_names +external int _ICU4XDateTime_days_in_month(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDateTime_days_in_year') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDateTime_days_in_year') +// ignore: non_constant_identifier_names +external int _ICU4XDateTime_days_in_year(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDateTime_calendar') +@ffi.Native Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDateTime_calendar') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XDateTime_calendar( + ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/DateTimeFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/DateTimeFormatter.g.dart deleted file mode 120000 index d6698347..00000000 --- a/pkgs/intl4x/lib/src/bindings/DateTimeFormatter.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/DateTimeFormatter.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/DateTimeFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/DateTimeFormatter.g.dart new file mode 100644 index 00000000..7a61da31 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/DateTimeFormatter.g.dart @@ -0,0 +1,115 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X DateFormatter object capable of formatting a [`DateTime`] as a string, +/// using some calendar specified at runtime in the locale. +/// +/// See the [Rust documentation for `DateTimeFormatter`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html) for more information. +final class DateTimeFormatter implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + DateTimeFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XDateTimeFormatter_destroy)); + + /// Creates a new [`DateTimeFormatter`] from locale data. + /// + /// See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new) for more information. + /// + /// Throws [Error] on failure. + factory DateTimeFormatter.withLengths(DataProvider provider, Locale locale, + DateLength dateLength, TimeLength timeLength) { + final result = _ICU4XDateTimeFormatter_create_with_lengths( + provider._ffi, locale._ffi, dateLength.index, timeLength.index); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return DateTimeFormatter._fromFfi(result.union.ok, []); + } + + /// Formats a [`DateTime`] to a string. + /// + /// See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.format) for more information. + /// + /// Throws [Error] on failure. + String formatDatetime(DateTime value) { + final writeable = _Writeable(); + final result = _ICU4XDateTimeFormatter_format_datetime( + _ffi, value._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Formats a [`IsoDateTime`] to a string. + /// + /// Will convert to this formatter's calendar first + /// + /// See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.format) for more information. + /// + /// Throws [Error] on failure. + String formatIsoDatetime(IsoDateTime value) { + final writeable = _Writeable(); + final result = _ICU4XDateTimeFormatter_format_iso_datetime( + _ffi, value._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } +} + +@meta.ResourceIdentifier('ICU4XDateTimeFormatter_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDateTimeFormatter_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XDateTimeFormatter_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDateTimeFormatter_create_with_lengths') +@ffi.Native< + _ResultOpaqueInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Int32, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XDateTimeFormatter_create_with_lengths') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XDateTimeFormatter_create_with_lengths( + ffi.Pointer provider, + ffi.Pointer locale, + int dateLength, + int timeLength); + +@meta.ResourceIdentifier('ICU4XDateTimeFormatter_format_datetime') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDateTimeFormatter_format_datetime') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XDateTimeFormatter_format_datetime( + ffi.Pointer self, + ffi.Pointer value, + ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XDateTimeFormatter_format_iso_datetime') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDateTimeFormatter_format_iso_datetime') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XDateTimeFormatter_format_iso_datetime( + ffi.Pointer self, + ffi.Pointer value, + ffi.Pointer writeable); diff --git a/pkgs/intl4x/lib/src/bindings/Decomposed.g.dart b/pkgs/intl4x/lib/src/bindings/Decomposed.g.dart deleted file mode 120000 index c727ea0e..00000000 --- a/pkgs/intl4x/lib/src/bindings/Decomposed.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/Decomposed.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/Decomposed.g.dart b/pkgs/intl4x/lib/src/bindings/Decomposed.g.dart new file mode 100644 index 00000000..955766a1 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/Decomposed.g.dart @@ -0,0 +1,48 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +final class _DecomposedFfi extends ffi.Struct { + @ffi.Uint32() + external Rune first; + @ffi.Uint32() + external Rune second; +} + +/// The outcome of non-recursive canonical decomposition of a character. +/// `second` will be NUL when the decomposition expands to a single character +/// (which may or may not be the original one) +/// +/// See the [Rust documentation for `Decomposed`](https://docs.rs/icu/latest/icu/normalizer/properties/enum.Decomposed.html) for more information. +final class Decomposed { + final Rune first; + final Rune second; + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + Decomposed._fromFfi(_DecomposedFfi ffi) + : first = ffi.first, + second = ffi.second; + + // ignore: unused_element + _DecomposedFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_DecomposedFfi>(); + struct.first = first; + struct.second = second; + return struct; + } + + @override + bool operator ==(Object other) => + other is Decomposed && other.first == first && other.second == second; + + @override + int get hashCode => Object.hashAll([ + first, + second, + ]); +} diff --git a/pkgs/intl4x/lib/src/bindings/DecomposingNormalizer.g.dart b/pkgs/intl4x/lib/src/bindings/DecomposingNormalizer.g.dart deleted file mode 120000 index f0b10530..00000000 --- a/pkgs/intl4x/lib/src/bindings/DecomposingNormalizer.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/DecomposingNormalizer.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/DecomposingNormalizer.g.dart b/pkgs/intl4x/lib/src/bindings/DecomposingNormalizer.g.dart new file mode 100644 index 00000000..cced0ed0 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/DecomposingNormalizer.g.dart @@ -0,0 +1,128 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `DecomposingNormalizer`](https://docs.rs/icu/latest/icu/normalizer/struct.DecomposingNormalizer.html) for more information. +final class DecomposingNormalizer implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + DecomposingNormalizer._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XDecomposingNormalizer_destroy)); + + /// Construct a new ICU4XDecomposingNormalizer instance for NFC + /// + /// See the [Rust documentation for `new_nfd`](https://docs.rs/icu/latest/icu/normalizer/struct.DecomposingNormalizer.html#method.new_nfd) for more information. + /// + /// Throws [Error] on failure. + factory DecomposingNormalizer.nfd(DataProvider provider) { + final result = _ICU4XDecomposingNormalizer_create_nfd(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return DecomposingNormalizer._fromFfi(result.union.ok, []); + } + + /// Construct a new ICU4XDecomposingNormalizer instance for NFKC + /// + /// See the [Rust documentation for `new_nfkd`](https://docs.rs/icu/latest/icu/normalizer/struct.DecomposingNormalizer.html#method.new_nfkd) for more information. + /// + /// Throws [Error] on failure. + factory DecomposingNormalizer.nfkd(DataProvider provider) { + final result = _ICU4XDecomposingNormalizer_create_nfkd(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return DecomposingNormalizer._fromFfi(result.union.ok, []); + } + + /// Normalize a string + /// + /// Ill-formed input is treated as if errors had been replaced with REPLACEMENT CHARACTERs according + /// to the WHATWG Encoding Standard. + /// + /// See the [Rust documentation for `normalize_utf8`](https://docs.rs/icu/latest/icu/normalizer/struct.DecomposingNormalizer.html#method.normalize_utf8) for more information. + /// + /// Throws [Error] on failure. + String normalize(String s) { + final temp = ffi2.Arena(); + final sView = s.utf8View; + final writeable = _Writeable(); + final result = _ICU4XDecomposingNormalizer_normalize( + _ffi, sView.allocIn(temp), sView.length, writeable._ffi); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Check if a string is normalized + /// + /// Ill-formed input is treated as if errors had been replaced with REPLACEMENT CHARACTERs according + /// to the WHATWG Encoding Standard. + /// + /// See the [Rust documentation for `is_normalized_utf8`](https://docs.rs/icu/latest/icu/normalizer/struct.DecomposingNormalizer.html#method.is_normalized_utf8) for more information. + bool isNormalized(String s) { + final temp = ffi2.Arena(); + final sView = s.utf8View; + final result = _ICU4XDecomposingNormalizer_is_normalized( + _ffi, sView.allocIn(temp), sView.length); + temp.releaseAll(); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XDecomposingNormalizer_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XDecomposingNormalizer_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XDecomposingNormalizer_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XDecomposingNormalizer_create_nfd') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDecomposingNormalizer_create_nfd') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XDecomposingNormalizer_create_nfd( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XDecomposingNormalizer_create_nfkd') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDecomposingNormalizer_create_nfkd') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XDecomposingNormalizer_create_nfkd( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XDecomposingNormalizer_normalize') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Size, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XDecomposingNormalizer_normalize') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XDecomposingNormalizer_normalize( + ffi.Pointer self, + ffi.Pointer sData, + int sLength, + ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XDecomposingNormalizer_is_normalized') +@ffi.Native< + ffi.Bool Function( + ffi.Pointer, ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XDecomposingNormalizer_is_normalized') +// ignore: non_constant_identifier_names +external bool _ICU4XDecomposingNormalizer_is_normalized( + ffi.Pointer self, ffi.Pointer sData, int sLength); diff --git a/pkgs/intl4x/lib/src/bindings/DisplayNamesFallback.g.dart b/pkgs/intl4x/lib/src/bindings/DisplayNamesFallback.g.dart deleted file mode 120000 index 92701242..00000000 --- a/pkgs/intl4x/lib/src/bindings/DisplayNamesFallback.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/DisplayNamesFallback.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/DisplayNamesFallback.g.dart b/pkgs/intl4x/lib/src/bindings/DisplayNamesFallback.g.dart new file mode 100644 index 00000000..18d4a960 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/DisplayNamesFallback.g.dart @@ -0,0 +1,10 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `Fallback`](https://docs.rs/icu/latest/icu/displaynames/options/enum.Fallback.html) for more information. +enum DisplayNamesFallback { + code, + + none; +} diff --git a/pkgs/intl4x/lib/src/bindings/DisplayNamesOptions.g.dart b/pkgs/intl4x/lib/src/bindings/DisplayNamesOptions.g.dart deleted file mode 120000 index 097a83eb..00000000 --- a/pkgs/intl4x/lib/src/bindings/DisplayNamesOptions.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/DisplayNamesOptions.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/DisplayNamesOptions.g.dart b/pkgs/intl4x/lib/src/bindings/DisplayNamesOptions.g.dart new file mode 100644 index 00000000..f9d46d1e --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/DisplayNamesOptions.g.dart @@ -0,0 +1,58 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +final class _DisplayNamesOptionsFfi extends ffi.Struct { + @ffi.Int32() + external int style; + @ffi.Int32() + external int fallback; + @ffi.Int32() + external int languageDisplay; +} + +/// See the [Rust documentation for `DisplayNamesOptions`](https://docs.rs/icu/latest/icu/displaynames/options/struct.DisplayNamesOptions.html) for more information. +final class DisplayNamesOptions { + DisplayNamesStyle style; + DisplayNamesFallback fallback; + LanguageDisplay languageDisplay; + + DisplayNamesOptions( + {required this.style, + required this.fallback, + required this.languageDisplay}); + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + DisplayNamesOptions._fromFfi(_DisplayNamesOptionsFfi ffi) + : style = DisplayNamesStyle.values[ffi.style], + fallback = DisplayNamesFallback.values[ffi.fallback], + languageDisplay = LanguageDisplay.values[ffi.languageDisplay]; + + // ignore: unused_element + _DisplayNamesOptionsFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_DisplayNamesOptionsFfi>(); + struct.style = style.index; + struct.fallback = fallback.index; + struct.languageDisplay = languageDisplay.index; + return struct; + } + + @override + bool operator ==(Object other) => + other is DisplayNamesOptions && + other.style == style && + other.fallback == fallback && + other.languageDisplay == languageDisplay; + + @override + int get hashCode => Object.hashAll([ + style, + fallback, + languageDisplay, + ]); +} diff --git a/pkgs/intl4x/lib/src/bindings/DisplayNamesStyle.g.dart b/pkgs/intl4x/lib/src/bindings/DisplayNamesStyle.g.dart deleted file mode 120000 index bec4f646..00000000 --- a/pkgs/intl4x/lib/src/bindings/DisplayNamesStyle.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/DisplayNamesStyle.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/DisplayNamesStyle.g.dart b/pkgs/intl4x/lib/src/bindings/DisplayNamesStyle.g.dart new file mode 100644 index 00000000..052b6131 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/DisplayNamesStyle.g.dart @@ -0,0 +1,16 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `Style`](https://docs.rs/icu/latest/icu/displaynames/options/enum.Style.html) for more information. +enum DisplayNamesStyle { + auto, + + narrow, + + short, + + long, + + menu; +} diff --git a/pkgs/intl4x/lib/src/bindings/Error.g.dart b/pkgs/intl4x/lib/src/bindings/Error.g.dart deleted file mode 120000 index b42967ba..00000000 --- a/pkgs/intl4x/lib/src/bindings/Error.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/Error.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/Error.g.dart b/pkgs/intl4x/lib/src/bindings/Error.g.dart new file mode 100644 index 00000000..8f18a7e6 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/Error.g.dart @@ -0,0 +1,243 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// A common enum for errors that ICU4X may return, organized by API +/// +/// The error names are stable and can be checked against as strings in the JS API +/// +/// Additional information: [1](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.FixedDecimalError.html), [2](https://docs.rs/icu/latest/icu/calendar/enum.CalendarError.html), [3](https://docs.rs/icu/latest/icu/collator/enum.CollatorError.html), [4](https://docs.rs/icu/latest/icu/datetime/enum.DateTimeError.html), [5](https://docs.rs/icu/latest/icu/decimal/enum.DecimalError.html), [6](https://docs.rs/icu/latest/icu/list/enum.ListError.html), [7](https://docs.rs/icu/latest/icu/locid/enum.ParserError.html), [8](https://docs.rs/icu/latest/icu/locid_transform/enum.LocaleTransformError.html), [9](https://docs.rs/icu/latest/icu/normalizer/enum.NormalizerError.html), [10](https://docs.rs/icu/latest/icu/plurals/enum.PluralsError.html), [11](https://docs.rs/icu/latest/icu/properties/enum.PropertiesError.html), [12](https://docs.rs/icu/latest/icu/provider/struct.DataError.html), [13](https://docs.rs/icu/latest/icu/provider/enum.DataErrorKind.html), [14](https://docs.rs/icu/latest/icu/segmenter/enum.SegmenterError.html), [15](https://docs.rs/icu/latest/icu/timezone/enum.TimeZoneError.html) +enum Error { + /// The error is not currently categorized as ICU4XError. + /// Please file a bug + unknownError, + + /// An error arising from writing to a string + /// Typically found when not enough space is allocated + /// Most APIs that return a string may return this error + writeableError, + + outOfBoundsError, + + dataMissingDataKeyError, + + dataMissingVariantError, + + dataMissingLocaleError, + + dataNeedsVariantError, + + dataNeedsLocaleError, + + dataExtraneousLocaleError, + + dataFilteredResourceError, + + dataMismatchedTypeError, + + dataMissingPayloadError, + + dataInvalidStateError, + + dataCustomError, + + dataIoError, + + dataUnavailableBufferFormatError, + + dataMismatchedAnyBufferError, + + /// The subtag being requested was not set + localeUndefinedSubtagError, + + /// The locale or subtag string failed to parse + localeParserLanguageError, + + localeParserSubtagError, + + localeParserExtensionError, + + /// Attempted to construct an invalid data struct + dataStructValidityError, + + propertyUnknownScriptIdError, + + propertyUnknownGeneralCategoryGroupError, + + propertyUnexpectedPropertyNameError, + + fixedDecimalLimitError, + + fixedDecimalSyntaxError, + + pluralsParserError, + + calendarParseError, + + calendarOverflowError, + + calendarUnderflowError, + + calendarOutOfRangeError, + + calendarUnknownEraError, + + calendarUnknownMonthCodeError, + + calendarMissingInputError, + + calendarUnknownKindError, + + calendarMissingError, + + dateTimePatternError, + + dateTimeMissingInputFieldError, + + dateTimeSkeletonError, + + dateTimeUnsupportedFieldError, + + dateTimeUnsupportedOptionsError, + + dateTimeMissingWeekdaySymbolError, + + dateTimeMissingMonthSymbolError, + + dateTimeFixedDecimalError, + + dateTimeMismatchedCalendarError, + + tinyStrTooLargeError, + + tinyStrContainsNullError, + + tinyStrNonAsciiError, + + timeZoneOffsetOutOfBoundsError, + + timeZoneInvalidOffsetError, + + timeZoneMissingInputError, + + timeZoneInvalidIdError, + + normalizerFutureExtensionError, + + normalizerValidationError; + + int get _ffi { + switch (this) { + case unknownError: + return 0; + case writeableError: + return 1; + case outOfBoundsError: + return 2; + case dataMissingDataKeyError: + return 256; + case dataMissingVariantError: + return 257; + case dataMissingLocaleError: + return 258; + case dataNeedsVariantError: + return 259; + case dataNeedsLocaleError: + return 260; + case dataExtraneousLocaleError: + return 261; + case dataFilteredResourceError: + return 262; + case dataMismatchedTypeError: + return 263; + case dataMissingPayloadError: + return 264; + case dataInvalidStateError: + return 265; + case dataCustomError: + return 266; + case dataIoError: + return 267; + case dataUnavailableBufferFormatError: + return 268; + case dataMismatchedAnyBufferError: + return 269; + case localeUndefinedSubtagError: + return 512; + case localeParserLanguageError: + return 513; + case localeParserSubtagError: + return 514; + case localeParserExtensionError: + return 515; + case dataStructValidityError: + return 768; + case propertyUnknownScriptIdError: + return 1024; + case propertyUnknownGeneralCategoryGroupError: + return 1025; + case propertyUnexpectedPropertyNameError: + return 1026; + case fixedDecimalLimitError: + return 1280; + case fixedDecimalSyntaxError: + return 1281; + case pluralsParserError: + return 1536; + case calendarParseError: + return 1792; + case calendarOverflowError: + return 1793; + case calendarUnderflowError: + return 1794; + case calendarOutOfRangeError: + return 1795; + case calendarUnknownEraError: + return 1796; + case calendarUnknownMonthCodeError: + return 1797; + case calendarMissingInputError: + return 1798; + case calendarUnknownKindError: + return 1799; + case calendarMissingError: + return 1800; + case dateTimePatternError: + return 2048; + case dateTimeMissingInputFieldError: + return 2049; + case dateTimeSkeletonError: + return 2050; + case dateTimeUnsupportedFieldError: + return 2051; + case dateTimeUnsupportedOptionsError: + return 2052; + case dateTimeMissingWeekdaySymbolError: + return 2053; + case dateTimeMissingMonthSymbolError: + return 2054; + case dateTimeFixedDecimalError: + return 2055; + case dateTimeMismatchedCalendarError: + return 2056; + case tinyStrTooLargeError: + return 2304; + case tinyStrContainsNullError: + return 2305; + case tinyStrNonAsciiError: + return 2306; + case timeZoneOffsetOutOfBoundsError: + return 2560; + case timeZoneInvalidOffsetError: + return 2561; + case timeZoneMissingInputError: + return 2562; + case timeZoneInvalidIdError: + return 2563; + case normalizerFutureExtensionError: + return 2816; + case normalizerValidationError: + return 2817; + } + } +} diff --git a/pkgs/intl4x/lib/src/bindings/FixedDecimal.g.dart b/pkgs/intl4x/lib/src/bindings/FixedDecimal.g.dart deleted file mode 120000 index 1ed862c2..00000000 --- a/pkgs/intl4x/lib/src/bindings/FixedDecimal.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/FixedDecimal.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/FixedDecimal.g.dart b/pkgs/intl4x/lib/src/bindings/FixedDecimal.g.dart new file mode 100644 index 00000000..f5243d9a --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/FixedDecimal.g.dart @@ -0,0 +1,595 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `FixedDecimal`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html) for more information. +final class FixedDecimal implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + FixedDecimal._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XFixedDecimal_destroy)); + + /// Construct an [`FixedDecimal`] from an integer. + /// + /// See the [Rust documentation for `FixedDecimal`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html) for more information. + factory FixedDecimal.fromInt(int v) { + final result = _ICU4XFixedDecimal_create_from_i64(v); + return FixedDecimal._fromFfi(result, []); + } + + /// Construct an [`FixedDecimal`] from an float, with a given power of 10 for the lower magnitude + /// + /// See the [Rust documentation for `try_from_f64`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.try_from_f64) for more information. + /// + /// See the [Rust documentation for `FloatPrecision`](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.FloatPrecision.html) for more information. + /// + /// Throws [Error] on failure. + factory FixedDecimal.fromDoubleWithLowerMagnitude(double f, int magnitude) { + final result = + _ICU4XFixedDecimal_create_from_f64_with_lower_magnitude(f, magnitude); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return FixedDecimal._fromFfi(result.union.ok, []); + } + + /// Construct an [`FixedDecimal`] from an float, for a given number of significant digits + /// + /// See the [Rust documentation for `try_from_f64`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.try_from_f64) for more information. + /// + /// See the [Rust documentation for `FloatPrecision`](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.FloatPrecision.html) for more information. + /// + /// Throws [Error] on failure. + factory FixedDecimal.fromDoubleWithSignificantDigits(double f, int digits) { + final result = + _ICU4XFixedDecimal_create_from_f64_with_significant_digits(f, digits); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return FixedDecimal._fromFfi(result.union.ok, []); + } + + /// Construct an [`FixedDecimal`] from an float, with enough digits to recover + /// the original floating point in IEEE 754 without needing trailing zeros + /// + /// See the [Rust documentation for `try_from_f64`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.try_from_f64) for more information. + /// + /// See the [Rust documentation for `FloatPrecision`](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.FloatPrecision.html) for more information. + /// + /// Throws [Error] on failure. + factory FixedDecimal.fromDoubleWithDoublePrecision(double f) { + final result = + _ICU4XFixedDecimal_create_from_f64_with_floating_precision(f); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return FixedDecimal._fromFfi(result.union.ok, []); + } + + /// Construct an [`FixedDecimal`] from a string. + /// + /// See the [Rust documentation for `from_str`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.from_str) for more information. + /// + /// Throws [Error] on failure. + factory FixedDecimal.fromString(String v) { + final temp = ffi2.Arena(); + final vView = v.utf8View; + final result = _ICU4XFixedDecimal_create_from_string( + vView.allocIn(temp), vView.length); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return FixedDecimal._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `digit_at`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.digit_at) for more information. + int digitAt(int magnitude) { + final result = _ICU4XFixedDecimal_digit_at(_ffi, magnitude); + return result; + } + + /// See the [Rust documentation for `magnitude_range`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.magnitude_range) for more information. + int get magnitudeStart { + final result = _ICU4XFixedDecimal_magnitude_start(_ffi); + return result; + } + + /// See the [Rust documentation for `magnitude_range`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.magnitude_range) for more information. + int get magnitudeEnd { + final result = _ICU4XFixedDecimal_magnitude_end(_ffi); + return result; + } + + /// See the [Rust documentation for `nonzero_magnitude_start`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.nonzero_magnitude_start) for more information. + int get nonzeroMagnitudeStart { + final result = _ICU4XFixedDecimal_nonzero_magnitude_start(_ffi); + return result; + } + + /// See the [Rust documentation for `nonzero_magnitude_end`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.nonzero_magnitude_end) for more information. + int get nonzeroMagnitudeEnd { + final result = _ICU4XFixedDecimal_nonzero_magnitude_end(_ffi); + return result; + } + + /// See the [Rust documentation for `is_zero`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.is_zero) for more information. + bool get isZero { + final result = _ICU4XFixedDecimal_is_zero(_ffi); + return result; + } + + /// Multiply the [`FixedDecimal`] by a given power of ten. + /// + /// See the [Rust documentation for `multiply_pow10`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.multiply_pow10) for more information. + void multiplyPow10(int power) { + _ICU4XFixedDecimal_multiply_pow10(_ffi, power); + } + + /// See the [Rust documentation for `sign`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.sign) for more information. + FixedDecimalSign get sign { + final result = _ICU4XFixedDecimal_sign(_ffi); + return FixedDecimalSign.values[result]; + } + + /// Set the sign of the [`FixedDecimal`]. + /// + /// See the [Rust documentation for `set_sign`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.set_sign) for more information. + set sign(FixedDecimalSign sign) { + _ICU4XFixedDecimal_set_sign(_ffi, sign.index); + } + + /// See the [Rust documentation for `apply_sign_display`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.apply_sign_display) for more information. + void applySignDisplay(FixedDecimalSignDisplay signDisplay) { + _ICU4XFixedDecimal_apply_sign_display(_ffi, signDisplay.index); + } + + /// See the [Rust documentation for `trim_start`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.trim_start) for more information. + void trimStart() { + _ICU4XFixedDecimal_trim_start(_ffi); + } + + /// See the [Rust documentation for `trim_end`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.trim_end) for more information. + void trimEnd() { + _ICU4XFixedDecimal_trim_end(_ffi); + } + + /// Zero-pad the [`FixedDecimal`] on the left to a particular position + /// + /// See the [Rust documentation for `pad_start`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.pad_start) for more information. + void padStart(int position) { + _ICU4XFixedDecimal_pad_start(_ffi, position); + } + + /// Zero-pad the [`FixedDecimal`] on the right to a particular position + /// + /// See the [Rust documentation for `pad_end`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.pad_end) for more information. + void padEnd(int position) { + _ICU4XFixedDecimal_pad_end(_ffi, position); + } + + /// Truncate the [`FixedDecimal`] on the left to a particular position, deleting digits if necessary. This is useful for, e.g. abbreviating years + /// ("2022" -> "22") + /// + /// See the [Rust documentation for `set_max_position`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.set_max_position) for more information. + void setMaxPosition(int position) { + _ICU4XFixedDecimal_set_max_position(_ffi, position); + } + + /// See the [Rust documentation for `trunc`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.trunc) for more information. + void trunc(int position) { + _ICU4XFixedDecimal_trunc(_ffi, position); + } + + /// See the [Rust documentation for `trunc_to_increment`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.trunc_to_increment) for more information. + void truncToIncrement(int position, RoundingIncrement increment) { + _ICU4XFixedDecimal_trunc_to_increment(_ffi, position, increment.index); + } + + /// See the [Rust documentation for `half_trunc`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_trunc) for more information. + void halfTrunc(int position) { + _ICU4XFixedDecimal_half_trunc(_ffi, position); + } + + /// See the [Rust documentation for `half_trunc_to_increment`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_trunc_to_increment) for more information. + void halfTruncToIncrement(int position, RoundingIncrement increment) { + _ICU4XFixedDecimal_half_trunc_to_increment(_ffi, position, increment.index); + } + + /// See the [Rust documentation for `expand`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.expand) for more information. + void expand(int position) { + _ICU4XFixedDecimal_expand(_ffi, position); + } + + /// See the [Rust documentation for `expand_to_increment`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.expand_to_increment) for more information. + void expandToIncrement(int position, RoundingIncrement increment) { + _ICU4XFixedDecimal_expand_to_increment(_ffi, position, increment.index); + } + + /// See the [Rust documentation for `half_expand`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_expand) for more information. + void halfExpand(int position) { + _ICU4XFixedDecimal_half_expand(_ffi, position); + } + + /// See the [Rust documentation for `half_expand_to_increment`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_expand_to_increment) for more information. + void halfExpandToIncrement(int position, RoundingIncrement increment) { + _ICU4XFixedDecimal_half_expand_to_increment( + _ffi, position, increment.index); + } + + /// See the [Rust documentation for `ceil`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.ceil) for more information. + void ceil(int position) { + _ICU4XFixedDecimal_ceil(_ffi, position); + } + + /// See the [Rust documentation for `ceil_to_increment`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.ceil_to_increment) for more information. + void ceilToIncrement(int position, RoundingIncrement increment) { + _ICU4XFixedDecimal_ceil_to_increment(_ffi, position, increment.index); + } + + /// See the [Rust documentation for `half_ceil`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_ceil) for more information. + void halfCeil(int position) { + _ICU4XFixedDecimal_half_ceil(_ffi, position); + } + + /// See the [Rust documentation for `half_ceil_to_increment`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_ceil_to_increment) for more information. + void halfCeilToIncrement(int position, RoundingIncrement increment) { + _ICU4XFixedDecimal_half_ceil_to_increment(_ffi, position, increment.index); + } + + /// See the [Rust documentation for `floor`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.floor) for more information. + void floor(int position) { + _ICU4XFixedDecimal_floor(_ffi, position); + } + + /// See the [Rust documentation for `floor_to_increment`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.floor_to_increment) for more information. + void floorToIncrement(int position, RoundingIncrement increment) { + _ICU4XFixedDecimal_floor_to_increment(_ffi, position, increment.index); + } + + /// See the [Rust documentation for `half_floor`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_floor) for more information. + void halfFloor(int position) { + _ICU4XFixedDecimal_half_floor(_ffi, position); + } + + /// See the [Rust documentation for `half_floor_to_increment`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_floor_to_increment) for more information. + void halfFloorToIncrement(int position, RoundingIncrement increment) { + _ICU4XFixedDecimal_half_floor_to_increment(_ffi, position, increment.index); + } + + /// See the [Rust documentation for `half_even`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_even) for more information. + void halfEven(int position) { + _ICU4XFixedDecimal_half_even(_ffi, position); + } + + /// See the [Rust documentation for `half_even_to_increment`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_even_to_increment) for more information. + void halfEvenToIncrement(int position, RoundingIncrement increment) { + _ICU4XFixedDecimal_half_even_to_increment(_ffi, position, increment.index); + } + + /// Concatenates `other` to the end of `self`. + /// + /// If successful, `other` will be set to 0 and a successful status is returned. + /// + /// If not successful, `other` will be unchanged and an error is returned. + /// + /// See the [Rust documentation for `concatenate_end`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.concatenate_end) for more information. + bool concatenateEnd(FixedDecimal other) { + final result = _ICU4XFixedDecimal_concatenate_end(_ffi, other._ffi); + return result.isOk; + } + + /// Format the [`FixedDecimal`] as a string. + /// + /// See the [Rust documentation for `write_to`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.write_to) for more information. + @override + String toString() { + final writeable = _Writeable(); + _ICU4XFixedDecimal_to_string(_ffi, writeable._ffi); + return writeable.finalize(); + } +} + +@meta.ResourceIdentifier('ICU4XFixedDecimal_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_create_from_i64') +@ffi.Native Function(ffi.Int64)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_create_from_i64') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XFixedDecimal_create_from_i64(int v); + +@meta.ResourceIdentifier( + 'ICU4XFixedDecimal_create_from_f64_with_lower_magnitude') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Double, ffi.Int16)>( + isLeaf: true, + symbol: 'ICU4XFixedDecimal_create_from_f64_with_lower_magnitude') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XFixedDecimal_create_from_f64_with_lower_magnitude( + double f, int magnitude); + +@meta.ResourceIdentifier( + 'ICU4XFixedDecimal_create_from_f64_with_significant_digits') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Double, ffi.Uint8)>( + isLeaf: true, + symbol: 'ICU4XFixedDecimal_create_from_f64_with_significant_digits') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XFixedDecimal_create_from_f64_with_significant_digits( + double f, int digits); + +@meta.ResourceIdentifier( + 'ICU4XFixedDecimal_create_from_f64_with_floating_precision') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Double)>( + isLeaf: true, + symbol: 'ICU4XFixedDecimal_create_from_f64_with_floating_precision') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XFixedDecimal_create_from_f64_with_floating_precision(double f); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_create_from_string') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_create_from_string') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XFixedDecimal_create_from_string( + ffi.Pointer vData, int vLength); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_digit_at') +@ffi.Native, ffi.Int16)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_digit_at') +// ignore: non_constant_identifier_names +external int _ICU4XFixedDecimal_digit_at( + ffi.Pointer self, int magnitude); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_magnitude_start') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_magnitude_start') +// ignore: non_constant_identifier_names +external int _ICU4XFixedDecimal_magnitude_start(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_magnitude_end') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_magnitude_end') +// ignore: non_constant_identifier_names +external int _ICU4XFixedDecimal_magnitude_end(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_nonzero_magnitude_start') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_nonzero_magnitude_start') +// ignore: non_constant_identifier_names +external int _ICU4XFixedDecimal_nonzero_magnitude_start( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_nonzero_magnitude_end') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_nonzero_magnitude_end') +// ignore: non_constant_identifier_names +external int _ICU4XFixedDecimal_nonzero_magnitude_end( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_is_zero') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_is_zero') +// ignore: non_constant_identifier_names +external bool _ICU4XFixedDecimal_is_zero(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_multiply_pow10') +@ffi.Native, ffi.Int16)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_multiply_pow10') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_multiply_pow10( + ffi.Pointer self, int power); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_sign') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_sign') +// ignore: non_constant_identifier_names +external int _ICU4XFixedDecimal_sign(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_set_sign') +@ffi.Native, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_set_sign') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_set_sign( + ffi.Pointer self, int sign); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_apply_sign_display') +@ffi.Native, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_apply_sign_display') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_apply_sign_display( + ffi.Pointer self, int signDisplay); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_trim_start') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_trim_start') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_trim_start(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_trim_end') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_trim_end') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_trim_end(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_pad_start') +@ffi.Native, ffi.Int16)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_pad_start') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_pad_start( + ffi.Pointer self, int position); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_pad_end') +@ffi.Native, ffi.Int16)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_pad_end') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_pad_end( + ffi.Pointer self, int position); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_set_max_position') +@ffi.Native, ffi.Int16)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_set_max_position') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_set_max_position( + ffi.Pointer self, int position); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_trunc') +@ffi.Native, ffi.Int16)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_trunc') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_trunc( + ffi.Pointer self, int position); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_trunc_to_increment') +@ffi.Native, ffi.Int16, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_trunc_to_increment') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_trunc_to_increment( + ffi.Pointer self, int position, int increment); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_half_trunc') +@ffi.Native, ffi.Int16)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_half_trunc') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_half_trunc( + ffi.Pointer self, int position); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_half_trunc_to_increment') +@ffi.Native, ffi.Int16, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_half_trunc_to_increment') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_half_trunc_to_increment( + ffi.Pointer self, int position, int increment); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_expand') +@ffi.Native, ffi.Int16)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_expand') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_expand( + ffi.Pointer self, int position); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_expand_to_increment') +@ffi.Native, ffi.Int16, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_expand_to_increment') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_expand_to_increment( + ffi.Pointer self, int position, int increment); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_half_expand') +@ffi.Native, ffi.Int16)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_half_expand') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_half_expand( + ffi.Pointer self, int position); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_half_expand_to_increment') +@ffi.Native, ffi.Int16, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_half_expand_to_increment') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_half_expand_to_increment( + ffi.Pointer self, int position, int increment); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_ceil') +@ffi.Native, ffi.Int16)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_ceil') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_ceil( + ffi.Pointer self, int position); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_ceil_to_increment') +@ffi.Native, ffi.Int16, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_ceil_to_increment') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_ceil_to_increment( + ffi.Pointer self, int position, int increment); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_half_ceil') +@ffi.Native, ffi.Int16)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_half_ceil') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_half_ceil( + ffi.Pointer self, int position); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_half_ceil_to_increment') +@ffi.Native, ffi.Int16, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_half_ceil_to_increment') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_half_ceil_to_increment( + ffi.Pointer self, int position, int increment); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_floor') +@ffi.Native, ffi.Int16)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_floor') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_floor( + ffi.Pointer self, int position); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_floor_to_increment') +@ffi.Native, ffi.Int16, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_floor_to_increment') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_floor_to_increment( + ffi.Pointer self, int position, int increment); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_half_floor') +@ffi.Native, ffi.Int16)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_half_floor') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_half_floor( + ffi.Pointer self, int position); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_half_floor_to_increment') +@ffi.Native, ffi.Int16, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_half_floor_to_increment') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_half_floor_to_increment( + ffi.Pointer self, int position, int increment); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_half_even') +@ffi.Native, ffi.Int16)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_half_even') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_half_even( + ffi.Pointer self, int position); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_half_even_to_increment') +@ffi.Native, ffi.Int16, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_half_even_to_increment') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_half_even_to_increment( + ffi.Pointer self, int position, int increment); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_concatenate_end') +@ffi.Native< + _ResultVoidVoid Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_concatenate_end') +// ignore: non_constant_identifier_names +external _ResultVoidVoid _ICU4XFixedDecimal_concatenate_end( + ffi.Pointer self, ffi.Pointer other); + +@meta.ResourceIdentifier('ICU4XFixedDecimal_to_string') +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XFixedDecimal_to_string') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimal_to_string( + ffi.Pointer self, ffi.Pointer writeable); diff --git a/pkgs/intl4x/lib/src/bindings/FixedDecimalFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/FixedDecimalFormatter.g.dart deleted file mode 120000 index 25d1cb55..00000000 --- a/pkgs/intl4x/lib/src/bindings/FixedDecimalFormatter.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/FixedDecimalFormatter.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/FixedDecimalFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/FixedDecimalFormatter.g.dart new file mode 100644 index 00000000..5a9313f0 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/FixedDecimalFormatter.g.dart @@ -0,0 +1,88 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X Fixed Decimal Format object, capable of formatting a [`FixedDecimal`] as a string. +/// +/// See the [Rust documentation for `FixedDecimalFormatter`](https://docs.rs/icu/latest/icu/decimal/struct.FixedDecimalFormatter.html) for more information. +final class FixedDecimalFormatter implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + FixedDecimalFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XFixedDecimalFormatter_destroy)); + + /// Creates a new [`FixedDecimalFormatter`] from locale data. + /// + /// See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/decimal/struct.FixedDecimalFormatter.html#method.try_new) for more information. + /// + /// Throws [Error] on failure. + factory FixedDecimalFormatter.withGroupingStrategy(DataProvider provider, + Locale locale, FixedDecimalGroupingStrategy groupingStrategy) { + final result = _ICU4XFixedDecimalFormatter_create_with_grouping_strategy( + provider._ffi, locale._ffi, groupingStrategy.index); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return FixedDecimalFormatter._fromFfi(result.union.ok, []); + } + + /// Formats a [`FixedDecimal`] to a string. + /// + /// See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/decimal/struct.FixedDecimalFormatter.html#method.format) for more information. + /// + /// Throws [Error] on failure. + String format(FixedDecimal value) { + final writeable = _Writeable(); + final result = + _ICU4XFixedDecimalFormatter_format(_ffi, value._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } +} + +@meta.ResourceIdentifier('ICU4XFixedDecimalFormatter_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XFixedDecimalFormatter_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XFixedDecimalFormatter_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier( + 'ICU4XFixedDecimalFormatter_create_with_grouping_strategy') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer, ffi.Int32)>( + isLeaf: true, + symbol: 'ICU4XFixedDecimalFormatter_create_with_grouping_strategy') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XFixedDecimalFormatter_create_with_grouping_strategy( + ffi.Pointer provider, + ffi.Pointer locale, + int groupingStrategy); + +@meta.ResourceIdentifier('ICU4XFixedDecimalFormatter_format') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XFixedDecimalFormatter_format') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XFixedDecimalFormatter_format( + ffi.Pointer self, + ffi.Pointer value, + ffi.Pointer writeable); diff --git a/pkgs/intl4x/lib/src/bindings/FixedDecimalGroupingStrategy.g.dart b/pkgs/intl4x/lib/src/bindings/FixedDecimalGroupingStrategy.g.dart deleted file mode 120000 index 63e3cda4..00000000 --- a/pkgs/intl4x/lib/src/bindings/FixedDecimalGroupingStrategy.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/FixedDecimalGroupingStrategy.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/FixedDecimalGroupingStrategy.g.dart b/pkgs/intl4x/lib/src/bindings/FixedDecimalGroupingStrategy.g.dart new file mode 100644 index 00000000..982929a5 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/FixedDecimalGroupingStrategy.g.dart @@ -0,0 +1,14 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `GroupingStrategy`](https://docs.rs/icu/latest/icu/decimal/options/enum.GroupingStrategy.html) for more information. +enum FixedDecimalGroupingStrategy { + auto, + + never, + + always, + + min2; +} diff --git a/pkgs/intl4x/lib/src/bindings/FixedDecimalSign.g.dart b/pkgs/intl4x/lib/src/bindings/FixedDecimalSign.g.dart deleted file mode 120000 index 08693c78..00000000 --- a/pkgs/intl4x/lib/src/bindings/FixedDecimalSign.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/FixedDecimalSign.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/FixedDecimalSign.g.dart b/pkgs/intl4x/lib/src/bindings/FixedDecimalSign.g.dart new file mode 100644 index 00000000..0aa5a9df --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/FixedDecimalSign.g.dart @@ -0,0 +1,17 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// The sign of a FixedDecimal, as shown in formatting. +/// +/// See the [Rust documentation for `Sign`](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.Sign.html) for more information. +enum FixedDecimalSign { + /// No sign (implicitly positive, e.g., 1729). + none, + + /// A negative sign, e.g., -1729. + negative, + + /// An explicit positive sign, e.g., +1729. + positive; +} diff --git a/pkgs/intl4x/lib/src/bindings/FixedDecimalSignDisplay.g.dart b/pkgs/intl4x/lib/src/bindings/FixedDecimalSignDisplay.g.dart deleted file mode 120000 index c6ac8d9b..00000000 --- a/pkgs/intl4x/lib/src/bindings/FixedDecimalSignDisplay.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/FixedDecimalSignDisplay.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/FixedDecimalSignDisplay.g.dart b/pkgs/intl4x/lib/src/bindings/FixedDecimalSignDisplay.g.dart new file mode 100644 index 00000000..244008ed --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/FixedDecimalSignDisplay.g.dart @@ -0,0 +1,18 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// ECMA-402 compatible sign display preference. +/// +/// See the [Rust documentation for `SignDisplay`](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.SignDisplay.html) for more information. +enum FixedDecimalSignDisplay { + auto, + + never, + + always, + + exceptZero, + + negative; +} diff --git a/pkgs/intl4x/lib/src/bindings/GeneralCategoryNameToMaskMapper.g.dart b/pkgs/intl4x/lib/src/bindings/GeneralCategoryNameToMaskMapper.g.dart deleted file mode 120000 index e21a791b..00000000 --- a/pkgs/intl4x/lib/src/bindings/GeneralCategoryNameToMaskMapper.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/GeneralCategoryNameToMaskMapper.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/GeneralCategoryNameToMaskMapper.g.dart b/pkgs/intl4x/lib/src/bindings/GeneralCategoryNameToMaskMapper.g.dart new file mode 100644 index 00000000..b2c74513 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/GeneralCategoryNameToMaskMapper.g.dart @@ -0,0 +1,100 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// A type capable of looking up General Category mask values from a string name. +/// +/// See the [Rust documentation for `get_name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.GeneralCategoryGroup.html#method.get_name_to_enum_mapper) for more information. +/// +/// See the [Rust documentation for `PropertyValueNameToEnumMapper`](https://docs.rs/icu/latest/icu/properties/names/struct.PropertyValueNameToEnumMapper.html) for more information. +final class GeneralCategoryNameToMaskMapper implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + GeneralCategoryNameToMaskMapper._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XGeneralCategoryNameToMaskMapper_destroy)); + + /// Get the mask value matching the given name, using strict matching + /// + /// Returns 0 if the name is unknown for this property + int getStrict(String name) { + final temp = ffi2.Arena(); + final nameView = name.utf8View; + final result = _ICU4XGeneralCategoryNameToMaskMapper_get_strict( + _ffi, nameView.allocIn(temp), nameView.length); + temp.releaseAll(); + return result; + } + + /// Get the mask value matching the given name, using loose matching + /// + /// Returns 0 if the name is unknown for this property + int getLoose(String name) { + final temp = ffi2.Arena(); + final nameView = name.utf8View; + final result = _ICU4XGeneralCategoryNameToMaskMapper_get_loose( + _ffi, nameView.allocIn(temp), nameView.length); + temp.releaseAll(); + return result; + } + + /// See the [Rust documentation for `get_name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.GeneralCategoryGroup.html#method.get_name_to_enum_mapper) for more information. + /// + /// Throws [Error] on failure. + factory GeneralCategoryNameToMaskMapper(DataProvider provider) { + final result = _ICU4XGeneralCategoryNameToMaskMapper_load(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return GeneralCategoryNameToMaskMapper._fromFfi(result.union.ok, []); + } +} + +@meta.ResourceIdentifier('ICU4XGeneralCategoryNameToMaskMapper_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XGeneralCategoryNameToMaskMapper_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XGeneralCategoryNameToMaskMapper_destroy( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XGeneralCategoryNameToMaskMapper_get_strict') +@ffi.Native< + ffi.Uint32 Function( + ffi.Pointer, ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XGeneralCategoryNameToMaskMapper_get_strict') +// ignore: non_constant_identifier_names +external int _ICU4XGeneralCategoryNameToMaskMapper_get_strict( + ffi.Pointer self, + ffi.Pointer nameData, + int nameLength); + +@meta.ResourceIdentifier('ICU4XGeneralCategoryNameToMaskMapper_get_loose') +@ffi.Native< + ffi.Uint32 Function( + ffi.Pointer, ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XGeneralCategoryNameToMaskMapper_get_loose') +// ignore: non_constant_identifier_names +external int _ICU4XGeneralCategoryNameToMaskMapper_get_loose( + ffi.Pointer self, + ffi.Pointer nameData, + int nameLength); + +@meta.ResourceIdentifier('ICU4XGeneralCategoryNameToMaskMapper_load') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XGeneralCategoryNameToMaskMapper_load') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XGeneralCategoryNameToMaskMapper_load( + ffi.Pointer provider); diff --git a/pkgs/intl4x/lib/src/bindings/GraphemeClusterBreakIteratorLatin1.g.dart b/pkgs/intl4x/lib/src/bindings/GraphemeClusterBreakIteratorLatin1.g.dart deleted file mode 120000 index ba31374c..00000000 --- a/pkgs/intl4x/lib/src/bindings/GraphemeClusterBreakIteratorLatin1.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/GraphemeClusterBreakIteratorLatin1.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/GraphemeClusterBreakIteratorLatin1.g.dart b/pkgs/intl4x/lib/src/bindings/GraphemeClusterBreakIteratorLatin1.g.dart new file mode 100644 index 00000000..9a7f6f73 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/GraphemeClusterBreakIteratorLatin1.g.dart @@ -0,0 +1,51 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `GraphemeClusterBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterBreakIterator.html) for more information. +final class GraphemeClusterBreakIteratorLatin1 implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _aEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + GraphemeClusterBreakIteratorLatin1._fromFfi( + this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XGraphemeClusterBreakIteratorLatin1_destroy)); + + /// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + /// out of range of a 32-bit signed integer. + /// + /// See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterBreakIterator.html#method.next) for more information. + int next() { + final result = _ICU4XGraphemeClusterBreakIteratorLatin1_next(_ffi); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XGraphemeClusterBreakIteratorLatin1_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XGraphemeClusterBreakIteratorLatin1_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XGraphemeClusterBreakIteratorLatin1_destroy( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XGraphemeClusterBreakIteratorLatin1_next') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XGraphemeClusterBreakIteratorLatin1_next') +// ignore: non_constant_identifier_names +external int _ICU4XGraphemeClusterBreakIteratorLatin1_next( + ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/GraphemeClusterBreakIteratorUtf16.g.dart b/pkgs/intl4x/lib/src/bindings/GraphemeClusterBreakIteratorUtf16.g.dart deleted file mode 120000 index 593ddc97..00000000 --- a/pkgs/intl4x/lib/src/bindings/GraphemeClusterBreakIteratorUtf16.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/GraphemeClusterBreakIteratorUtf16.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/GraphemeClusterBreakIteratorUtf16.g.dart b/pkgs/intl4x/lib/src/bindings/GraphemeClusterBreakIteratorUtf16.g.dart new file mode 100644 index 00000000..8894f7dc --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/GraphemeClusterBreakIteratorUtf16.g.dart @@ -0,0 +1,51 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `GraphemeClusterBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterBreakIterator.html) for more information. +final class GraphemeClusterBreakIteratorUtf16 implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _aEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + GraphemeClusterBreakIteratorUtf16._fromFfi( + this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XGraphemeClusterBreakIteratorUtf16_destroy)); + + /// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + /// out of range of a 32-bit signed integer. + /// + /// See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterBreakIterator.html#method.next) for more information. + int next() { + final result = _ICU4XGraphemeClusterBreakIteratorUtf16_next(_ffi); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XGraphemeClusterBreakIteratorUtf16_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XGraphemeClusterBreakIteratorUtf16_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XGraphemeClusterBreakIteratorUtf16_destroy( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XGraphemeClusterBreakIteratorUtf16_next') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XGraphemeClusterBreakIteratorUtf16_next') +// ignore: non_constant_identifier_names +external int _ICU4XGraphemeClusterBreakIteratorUtf16_next( + ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/GraphemeClusterBreakIteratorUtf8.g.dart b/pkgs/intl4x/lib/src/bindings/GraphemeClusterBreakIteratorUtf8.g.dart deleted file mode 120000 index 2770377a..00000000 --- a/pkgs/intl4x/lib/src/bindings/GraphemeClusterBreakIteratorUtf8.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/GraphemeClusterBreakIteratorUtf8.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/GraphemeClusterBreakIteratorUtf8.g.dart b/pkgs/intl4x/lib/src/bindings/GraphemeClusterBreakIteratorUtf8.g.dart new file mode 100644 index 00000000..2e0ce350 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/GraphemeClusterBreakIteratorUtf8.g.dart @@ -0,0 +1,51 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `GraphemeClusterBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterBreakIterator.html) for more information. +final class GraphemeClusterBreakIteratorUtf8 implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _aEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + GraphemeClusterBreakIteratorUtf8._fromFfi( + this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XGraphemeClusterBreakIteratorUtf8_destroy)); + + /// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + /// out of range of a 32-bit signed integer. + /// + /// See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterBreakIterator.html#method.next) for more information. + int next() { + final result = _ICU4XGraphemeClusterBreakIteratorUtf8_next(_ffi); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XGraphemeClusterBreakIteratorUtf8_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XGraphemeClusterBreakIteratorUtf8_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XGraphemeClusterBreakIteratorUtf8_destroy( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XGraphemeClusterBreakIteratorUtf8_next') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XGraphemeClusterBreakIteratorUtf8_next') +// ignore: non_constant_identifier_names +external int _ICU4XGraphemeClusterBreakIteratorUtf8_next( + ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/GraphemeClusterSegmenter.g.dart b/pkgs/intl4x/lib/src/bindings/GraphemeClusterSegmenter.g.dart deleted file mode 120000 index b2f5bf03..00000000 --- a/pkgs/intl4x/lib/src/bindings/GraphemeClusterSegmenter.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/GraphemeClusterSegmenter.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/GraphemeClusterSegmenter.g.dart b/pkgs/intl4x/lib/src/bindings/GraphemeClusterSegmenter.g.dart new file mode 100644 index 00000000..0f936e87 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/GraphemeClusterSegmenter.g.dart @@ -0,0 +1,82 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X grapheme-cluster-break segmenter, capable of finding grapheme cluster breakpoints +/// in strings. +/// +/// See the [Rust documentation for `GraphemeClusterSegmenter`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterSegmenter.html) for more information. +final class GraphemeClusterSegmenter implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + GraphemeClusterSegmenter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XGraphemeClusterSegmenter_destroy)); + + /// Construct an [`GraphemeClusterSegmenter`]. + /// + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterSegmenter.html#method.new) for more information. + /// + /// Throws [Error] on failure. + factory GraphemeClusterSegmenter(DataProvider provider) { + final result = _ICU4XGraphemeClusterSegmenter_create(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return GraphemeClusterSegmenter._fromFfi(result.union.ok, []); + } + + /// Segments a string. + /// + /// Ill-formed input is treated as if errors had been replaced with REPLACEMENT CHARACTERs according + /// to the WHATWG Encoding Standard. + /// + /// See the [Rust documentation for `segment_utf16`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterSegmenter.html#method.segment_utf16) for more information. + GraphemeClusterBreakIteratorUtf16 segment(String input) { + final inputView = input.utf16View; + final inputArena = _FinalizedArena(); + // This lifetime edge depends on lifetimes: 'a + core.List aEdges = [this, inputArena]; + final result = _ICU4XGraphemeClusterSegmenter_segment_utf16( + _ffi, inputView.allocIn(inputArena.arena), inputView.length); + return GraphemeClusterBreakIteratorUtf16._fromFfi(result, [], aEdges); + } +} + +@meta.ResourceIdentifier('ICU4XGraphemeClusterSegmenter_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XGraphemeClusterSegmenter_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XGraphemeClusterSegmenter_destroy( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XGraphemeClusterSegmenter_create') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XGraphemeClusterSegmenter_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XGraphemeClusterSegmenter_create( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XGraphemeClusterSegmenter_segment_utf16') +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XGraphemeClusterSegmenter_segment_utf16') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XGraphemeClusterSegmenter_segment_utf16( + ffi.Pointer self, + ffi.Pointer inputData, + int inputLength); diff --git a/pkgs/intl4x/lib/src/bindings/GregorianDateFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/GregorianDateFormatter.g.dart deleted file mode 120000 index f23d82d1..00000000 --- a/pkgs/intl4x/lib/src/bindings/GregorianDateFormatter.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/GregorianDateFormatter.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/GregorianDateFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/GregorianDateFormatter.g.dart new file mode 100644 index 00000000..aebb225e --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/GregorianDateFormatter.g.dart @@ -0,0 +1,112 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X TypedDateFormatter object capable of formatting a [`IsoDateTime`] as a string, +/// using the Gregorian Calendar. +/// +/// See the [Rust documentation for `TypedDateFormatter`](https://docs.rs/icu/latest/icu/datetime/struct.TypedDateFormatter.html) for more information. +final class GregorianDateFormatter implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + GregorianDateFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XGregorianDateFormatter_destroy)); + + /// Creates a new [`GregorianDateFormatter`] from locale data. + /// + /// See the [Rust documentation for `try_new_with_length`](https://docs.rs/icu/latest/icu/datetime/struct.TypedDateFormatter.html#method.try_new_with_length) for more information. + /// + /// Throws [Error] on failure. + factory GregorianDateFormatter.withLength( + DataProvider provider, Locale locale, DateLength length) { + final result = _ICU4XGregorianDateFormatter_create_with_length( + provider._ffi, locale._ffi, length.index); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return GregorianDateFormatter._fromFfi(result.union.ok, []); + } + + /// Formats a [`IsoDate`] to a string. + /// + /// See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TypedDateFormatter.html#method.format) for more information. + /// + /// Throws [Error] on failure. + String formatIsoDate(IsoDate value) { + final writeable = _Writeable(); + final result = _ICU4XGregorianDateFormatter_format_iso_date( + _ffi, value._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Formats a [`IsoDateTime`] to a string. + /// + /// See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TypedDateFormatter.html#method.format) for more information. + /// + /// Throws [Error] on failure. + String formatIsoDatetime(IsoDateTime value) { + final writeable = _Writeable(); + final result = _ICU4XGregorianDateFormatter_format_iso_datetime( + _ffi, value._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } +} + +@meta.ResourceIdentifier('ICU4XGregorianDateFormatter_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XGregorianDateFormatter_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XGregorianDateFormatter_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XGregorianDateFormatter_create_with_length') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XGregorianDateFormatter_create_with_length') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XGregorianDateFormatter_create_with_length( + ffi.Pointer provider, + ffi.Pointer locale, + int length); + +@meta.ResourceIdentifier('ICU4XGregorianDateFormatter_format_iso_date') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XGregorianDateFormatter_format_iso_date') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XGregorianDateFormatter_format_iso_date( + ffi.Pointer self, + ffi.Pointer value, + ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XGregorianDateFormatter_format_iso_datetime') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XGregorianDateFormatter_format_iso_datetime') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XGregorianDateFormatter_format_iso_datetime( + ffi.Pointer self, + ffi.Pointer value, + ffi.Pointer writeable); diff --git a/pkgs/intl4x/lib/src/bindings/GregorianDateTimeFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/GregorianDateTimeFormatter.g.dart deleted file mode 120000 index ec6c4873..00000000 --- a/pkgs/intl4x/lib/src/bindings/GregorianDateTimeFormatter.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/GregorianDateTimeFormatter.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/GregorianDateTimeFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/GregorianDateTimeFormatter.g.dart new file mode 100644 index 00000000..ad7ce2f3 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/GregorianDateTimeFormatter.g.dart @@ -0,0 +1,89 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X TypedDateTimeFormatter object capable of formatting a [`IsoDateTime`] as a string, +/// using the Gregorian Calendar. +/// +/// See the [Rust documentation for `TypedDateTimeFormatter`](https://docs.rs/icu/latest/icu/datetime/struct.TypedDateTimeFormatter.html) for more information. +final class GregorianDateTimeFormatter implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + GregorianDateTimeFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XGregorianDateTimeFormatter_destroy)); + + /// Creates a new [`GregorianDateFormatter`] from locale data. + /// + /// See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.TypedDateTimeFormatter.html#method.try_new) for more information. + /// + /// Throws [Error] on failure. + factory GregorianDateTimeFormatter.withLengths(DataProvider provider, + Locale locale, DateLength dateLength, TimeLength timeLength) { + final result = _ICU4XGregorianDateTimeFormatter_create_with_lengths( + provider._ffi, locale._ffi, dateLength.index, timeLength.index); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return GregorianDateTimeFormatter._fromFfi(result.union.ok, []); + } + + /// Formats a [`IsoDateTime`] to a string. + /// + /// See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TypedDateTimeFormatter.html#method.format) for more information. + /// + /// Throws [Error] on failure. + String formatIsoDatetime(IsoDateTime value) { + final writeable = _Writeable(); + final result = _ICU4XGregorianDateTimeFormatter_format_iso_datetime( + _ffi, value._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } +} + +@meta.ResourceIdentifier('ICU4XGregorianDateTimeFormatter_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XGregorianDateTimeFormatter_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XGregorianDateTimeFormatter_destroy( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XGregorianDateTimeFormatter_create_with_lengths') +@ffi.Native< + _ResultOpaqueInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Int32, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XGregorianDateTimeFormatter_create_with_lengths') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XGregorianDateTimeFormatter_create_with_lengths( + ffi.Pointer provider, + ffi.Pointer locale, + int dateLength, + int timeLength); + +@meta.ResourceIdentifier('ICU4XGregorianDateTimeFormatter_format_iso_datetime') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XGregorianDateTimeFormatter_format_iso_datetime') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XGregorianDateTimeFormatter_format_iso_datetime( + ffi.Pointer self, + ffi.Pointer value, + ffi.Pointer writeable); diff --git a/pkgs/intl4x/lib/src/bindings/GregorianZonedDateTimeFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/GregorianZonedDateTimeFormatter.g.dart deleted file mode 120000 index d14da4ac..00000000 --- a/pkgs/intl4x/lib/src/bindings/GregorianZonedDateTimeFormatter.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/GregorianZonedDateTimeFormatter.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/GregorianZonedDateTimeFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/GregorianZonedDateTimeFormatter.g.dart new file mode 100644 index 00000000..3f3ca8a3 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/GregorianZonedDateTimeFormatter.g.dart @@ -0,0 +1,153 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An object capable of formatting a date time with time zone to a string. +/// +/// See the [Rust documentation for `TypedZonedDateTimeFormatter`](https://docs.rs/icu/latest/icu/datetime/struct.TypedZonedDateTimeFormatter.html) for more information. +final class GregorianZonedDateTimeFormatter implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + GregorianZonedDateTimeFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XGregorianZonedDateTimeFormatter_destroy)); + + /// Creates a new [`GregorianZonedDateTimeFormatter`] from locale data. + /// + /// This function has `date_length` and `time_length` arguments and uses default options + /// for the time zone. + /// + /// See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.TypedZonedDateTimeFormatter.html#method.try_new) for more information. + /// + /// Throws [Error] on failure. + factory GregorianZonedDateTimeFormatter.withLengths(DataProvider provider, + Locale locale, DateLength dateLength, TimeLength timeLength) { + final result = _ICU4XGregorianZonedDateTimeFormatter_create_with_lengths( + provider._ffi, locale._ffi, dateLength.index, timeLength.index); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return GregorianZonedDateTimeFormatter._fromFfi(result.union.ok, []); + } + + /// Creates a new [`GregorianZonedDateTimeFormatter`] from locale data. + /// + /// This function has `date_length` and `time_length` arguments and uses an ISO-8601 style + /// fallback for the time zone with the given configurations. + /// + /// See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.TypedZonedDateTimeFormatter.html#method.try_new) for more information. + /// + /// Throws [Error] on failure. + factory GregorianZonedDateTimeFormatter.withLengthsAndIso8601TimeZoneFallback( + DataProvider provider, + Locale locale, + DateLength dateLength, + TimeLength timeLength, + IsoTimeZoneOptions zoneOptions) { + final temp = ffi2.Arena(); + final result = + _ICU4XGregorianZonedDateTimeFormatter_create_with_lengths_and_iso_8601_time_zone_fallback( + provider._ffi, + locale._ffi, + dateLength.index, + timeLength.index, + zoneOptions._toFfi(temp)); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return GregorianZonedDateTimeFormatter._fromFfi(result.union.ok, []); + } + + /// Formats a [`IsoDateTime`] and [`CustomTimeZone`] to a string. + /// + /// See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TypedZonedDateTimeFormatter.html#method.format) for more information. + /// + /// Throws [Error] on failure. + String formatIsoDatetimeWithCustomTimeZone( + IsoDateTime datetime, CustomTimeZone timeZone) { + final writeable = _Writeable(); + final result = + _ICU4XGregorianZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone( + _ffi, datetime._ffi, timeZone._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } +} + +@meta.ResourceIdentifier('ICU4XGregorianZonedDateTimeFormatter_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XGregorianZonedDateTimeFormatter_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XGregorianZonedDateTimeFormatter_destroy( + ffi.Pointer self); + +@meta.ResourceIdentifier( + 'ICU4XGregorianZonedDateTimeFormatter_create_with_lengths') +@ffi.Native< + _ResultOpaqueInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Int32, ffi.Int32)>( + isLeaf: true, + symbol: 'ICU4XGregorianZonedDateTimeFormatter_create_with_lengths') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XGregorianZonedDateTimeFormatter_create_with_lengths( + ffi.Pointer provider, + ffi.Pointer locale, + int dateLength, + int timeLength); + +@meta.ResourceIdentifier( + 'ICU4XGregorianZonedDateTimeFormatter_create_with_lengths_and_iso_8601_time_zone_fallback') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Int32, + _IsoTimeZoneOptionsFfi)>( + isLeaf: true, + symbol: + 'ICU4XGregorianZonedDateTimeFormatter_create_with_lengths_and_iso_8601_time_zone_fallback') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XGregorianZonedDateTimeFormatter_create_with_lengths_and_iso_8601_time_zone_fallback( + ffi.Pointer provider, + ffi.Pointer locale, + int dateLength, + int timeLength, + _IsoTimeZoneOptionsFfi zoneOptions); + +@meta.ResourceIdentifier( + 'ICU4XGregorianZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>( + isLeaf: true, + symbol: + 'ICU4XGregorianZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 + _ICU4XGregorianZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone( + ffi.Pointer self, + ffi.Pointer datetime, + ffi.Pointer timeZone, + ffi.Pointer writeable); diff --git a/pkgs/intl4x/lib/src/bindings/IanaToBcp47Mapper.g.dart b/pkgs/intl4x/lib/src/bindings/IanaToBcp47Mapper.g.dart deleted file mode 120000 index f1d318f7..00000000 --- a/pkgs/intl4x/lib/src/bindings/IanaToBcp47Mapper.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/IanaToBcp47Mapper.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/IanaToBcp47Mapper.g.dart b/pkgs/intl4x/lib/src/bindings/IanaToBcp47Mapper.g.dart new file mode 100644 index 00000000..40550aad --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/IanaToBcp47Mapper.g.dart @@ -0,0 +1,85 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An object capable of mapping from an IANA time zone ID to a BCP-47 ID. +/// +/// This can be used via `try_set_iana_time_zone_id()` on [`CustomTimeZone`]. +/// +/// [`CustomTimeZone`]: crate::timezone::ffi::ICU4XCustomTimeZone +/// +/// See the [Rust documentation for `IanaToBcp47Mapper`](https://docs.rs/icu/latest/icu/timezone/struct.IanaToBcp47Mapper.html) for more information. +final class IanaToBcp47Mapper implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + IanaToBcp47Mapper._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XIanaToBcp47Mapper_destroy)); + + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/timezone/struct.IanaToBcp47Mapper.html#method.new) for more information. + /// + /// Throws [Error] on failure. + factory IanaToBcp47Mapper(DataProvider provider) { + final result = _ICU4XIanaToBcp47Mapper_create(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return IanaToBcp47Mapper._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `get`](https://docs.rs/icu/latest/icu/timezone/struct.IanaToBcp47MapperBorrowed.html#method.get) for more information. + /// + /// See the [Rust documentation for `iana_to_bcp47`](https://docs.rs/icu/latest/icu/timezone/struct.IanaBcp47RoundTripMapperBorrowed.html#method.iana_to_bcp47) for more information. + /// + /// Throws [Error] on failure. + String operator [](String value) { + final temp = ffi2.Arena(); + final valueView = value.utf8View; + final writeable = _Writeable(); + final result = _ICU4XIanaToBcp47Mapper_get( + _ffi, valueView.allocIn(temp), valueView.length, writeable._ffi); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } +} + +@meta.ResourceIdentifier('ICU4XIanaToBcp47Mapper_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIanaToBcp47Mapper_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XIanaToBcp47Mapper_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIanaToBcp47Mapper_create') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XIanaToBcp47Mapper_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XIanaToBcp47Mapper_create( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XIanaToBcp47Mapper_get') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Size, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XIanaToBcp47Mapper_get') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XIanaToBcp47Mapper_get( + ffi.Pointer self, + ffi.Pointer valueData, + int valueLength, + ffi.Pointer writeable); diff --git a/pkgs/intl4x/lib/src/bindings/IsoDate.g.dart b/pkgs/intl4x/lib/src/bindings/IsoDate.g.dart deleted file mode 120000 index c71ad177..00000000 --- a/pkgs/intl4x/lib/src/bindings/IsoDate.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/IsoDate.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/IsoDate.g.dart b/pkgs/intl4x/lib/src/bindings/IsoDate.g.dart new file mode 100644 index 00000000..3bef0034 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/IsoDate.g.dart @@ -0,0 +1,248 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X Date object capable of containing a ISO-8601 date +/// +/// See the [Rust documentation for `Date`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html) for more information. +final class IsoDate implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + IsoDate._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XIsoDate_destroy)); + + /// Creates a new [`IsoDate`] from the specified date and time. + /// + /// See the [Rust documentation for `try_new_iso_date`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.try_new_iso_date) for more information. + /// + /// Throws [Error] on failure. + factory IsoDate(int year, int month, int day) { + final result = _ICU4XIsoDate_create(year, month, day); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return IsoDate._fromFfi(result.union.ok, []); + } + + /// Creates a new [`IsoDate`] representing January 1, 1970. + /// + /// See the [Rust documentation for `unix_epoch`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.unix_epoch) for more information. + factory IsoDate.forUnixEpoch() { + final result = _ICU4XIsoDate_create_for_unix_epoch(); + return IsoDate._fromFfi(result, []); + } + + /// Convert this date to one in a different calendar + /// + /// See the [Rust documentation for `to_calendar`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.to_calendar) for more information. + Date toCalendar(Calendar calendar) { + final result = _ICU4XIsoDate_to_calendar(_ffi, calendar._ffi); + return Date._fromFfi(result, []); + } + + /// See the [Rust documentation for `to_any`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.to_any) for more information. + Date toAny() { + final result = _ICU4XIsoDate_to_any(_ffi); + return Date._fromFfi(result, []); + } + + /// Returns the 1-indexed day in the month for this date + /// + /// See the [Rust documentation for `day_of_month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_month) for more information. + int get dayOfMonth { + final result = _ICU4XIsoDate_day_of_month(_ffi); + return result; + } + + /// Returns the day in the week for this day + /// + /// See the [Rust documentation for `day_of_week`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_week) for more information. + IsoWeekday get dayOfWeek { + final result = _ICU4XIsoDate_day_of_week(_ffi); + return IsoWeekday.values.firstWhere((v) => v._ffi == result); + } + + /// Returns the week number in this month, 1-indexed, based on what + /// is considered the first day of the week (often a locale preference). + /// + /// `first_weekday` can be obtained via `first_weekday()` on [`WeekCalculator`] + /// + /// See the [Rust documentation for `week_of_month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_month) for more information. + int weekOfMonth(IsoWeekday firstWeekday) { + final result = _ICU4XIsoDate_week_of_month(_ffi, firstWeekday._ffi); + return result; + } + + /// Returns the week number in this year, using week data + /// + /// See the [Rust documentation for `week_of_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_year) for more information. + /// + /// Throws [Error] on failure. + WeekOf weekOfYear(WeekCalculator calculator) { + final result = _ICU4XIsoDate_week_of_year(_ffi, calculator._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return WeekOf._fromFfi(result.union.ok); + } + + /// Returns 1-indexed number of the month of this date in its year + /// + /// See the [Rust documentation for `month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month) for more information. + int get month { + final result = _ICU4XIsoDate_month(_ffi); + return result; + } + + /// Returns the year number for this date + /// + /// See the [Rust documentation for `year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year) for more information. + int get year { + final result = _ICU4XIsoDate_year(_ffi); + return result; + } + + /// Returns if the year is a leap year for this date + /// + /// See the [Rust documentation for `is_in_leap_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.is_in_leap_year) for more information. + bool get isInLeapYear { + final result = _ICU4XIsoDate_is_in_leap_year(_ffi); + return result; + } + + /// Returns the number of months in the year represented by this date + /// + /// See the [Rust documentation for `months_in_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.months_in_year) for more information. + int get monthsInYear { + final result = _ICU4XIsoDate_months_in_year(_ffi); + return result; + } + + /// Returns the number of days in the month represented by this date + /// + /// See the [Rust documentation for `days_in_month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_month) for more information. + int get daysInMonth { + final result = _ICU4XIsoDate_days_in_month(_ffi); + return result; + } + + /// Returns the number of days in the year represented by this date + /// + /// See the [Rust documentation for `days_in_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_year) for more information. + int get daysInYear { + final result = _ICU4XIsoDate_days_in_year(_ffi); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XIsoDate_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDate_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XIsoDate_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDate_create') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Int32, ffi.Uint8, ffi.Uint8)>( + isLeaf: true, symbol: 'ICU4XIsoDate_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XIsoDate_create(int year, int month, int day); + +@meta.ResourceIdentifier('ICU4XIsoDate_create_for_unix_epoch') +@ffi.Native Function()>( + isLeaf: true, symbol: 'ICU4XIsoDate_create_for_unix_epoch') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XIsoDate_create_for_unix_epoch(); + +@meta.ResourceIdentifier('ICU4XIsoDate_to_calendar') +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XIsoDate_to_calendar') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XIsoDate_to_calendar( + ffi.Pointer self, ffi.Pointer calendar); + +@meta.ResourceIdentifier('ICU4XIsoDate_to_any') +@ffi.Native Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XIsoDate_to_any') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XIsoDate_to_any( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDate_day_of_month') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDate_day_of_month') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDate_day_of_month(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDate_day_of_week') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDate_day_of_week') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDate_day_of_week(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDate_week_of_month') +@ffi.Native, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XIsoDate_week_of_month') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDate_week_of_month( + ffi.Pointer self, int firstWeekday); + +@meta.ResourceIdentifier('ICU4XIsoDate_week_of_year') +@ffi.Native< + _ResultWeekOfFfiInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XIsoDate_week_of_year') +// ignore: non_constant_identifier_names +external _ResultWeekOfFfiInt32 _ICU4XIsoDate_week_of_year( + ffi.Pointer self, ffi.Pointer calculator); + +@meta.ResourceIdentifier('ICU4XIsoDate_month') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDate_month') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDate_month(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDate_year') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDate_year') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDate_year(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDate_is_in_leap_year') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDate_is_in_leap_year') +// ignore: non_constant_identifier_names +external bool _ICU4XIsoDate_is_in_leap_year(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDate_months_in_year') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDate_months_in_year') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDate_months_in_year(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDate_days_in_month') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDate_days_in_month') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDate_days_in_month(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDate_days_in_year') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDate_days_in_year') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDate_days_in_year(ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/IsoDateTime.g.dart b/pkgs/intl4x/lib/src/bindings/IsoDateTime.g.dart deleted file mode 120000 index 83ee0e4e..00000000 --- a/pkgs/intl4x/lib/src/bindings/IsoDateTime.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/IsoDateTime.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/IsoDateTime.g.dart b/pkgs/intl4x/lib/src/bindings/IsoDateTime.g.dart new file mode 100644 index 00000000..4835abab --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/IsoDateTime.g.dart @@ -0,0 +1,398 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X DateTime object capable of containing a ISO-8601 date and time. +/// +/// See the [Rust documentation for `DateTime`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html) for more information. +final class IsoDateTime implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + IsoDateTime._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XIsoDateTime_destroy)); + + /// Creates a new [`IsoDateTime`] from the specified date and time. + /// + /// See the [Rust documentation for `try_new_iso_datetime`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.try_new_iso_datetime) for more information. + /// + /// Throws [Error] on failure. + factory IsoDateTime(int year, int month, int day, int hour, int minute, + int second, int nanosecond) { + final result = _ICU4XIsoDateTime_create( + year, month, day, hour, minute, second, nanosecond); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return IsoDateTime._fromFfi(result.union.ok, []); + } + + /// Creates a new [`IsoDateTime`] from an [`IsoDate`] and [`Time`] object + /// + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.new) for more information. + factory IsoDateTime.fromDateAndTime(IsoDate date, Time time) { + final result = + _ICU4XIsoDateTime_crate_from_date_and_time(date._ffi, time._ffi); + return IsoDateTime._fromFfi(result, []); + } + + /// Creates a new [`IsoDateTime`] of midnight on January 1, 1970 + /// + /// See the [Rust documentation for `local_unix_epoch`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.local_unix_epoch) for more information. + factory IsoDateTime.localUnixEpoch() { + final result = _ICU4XIsoDateTime_local_unix_epoch(); + return IsoDateTime._fromFfi(result, []); + } + + /// Construct from the minutes since the local unix epoch for this date (Jan 1 1970, 00:00) + /// + /// See the [Rust documentation for `from_minutes_since_local_unix_epoch`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.from_minutes_since_local_unix_epoch) for more information. + factory IsoDateTime.fromMinutesSinceLocalUnixEpoch(int minutes) { + final result = + _ICU4XIsoDateTime_create_from_minutes_since_local_unix_epoch(minutes); + return IsoDateTime._fromFfi(result, []); + } + + /// Gets the date contained in this object + /// + /// See the [Rust documentation for `date`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#structfield.date) for more information. + IsoDate get date { + final result = _ICU4XIsoDateTime_date(_ffi); + return IsoDate._fromFfi(result, []); + } + + /// Gets the time contained in this object + /// + /// See the [Rust documentation for `time`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#structfield.time) for more information. + Time get time { + final result = _ICU4XIsoDateTime_time(_ffi); + return Time._fromFfi(result, []); + } + + /// Converts this to an [`DateTime`] capable of being mixed with dates of + /// other calendars + /// + /// See the [Rust documentation for `to_any`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.to_any) for more information. + DateTime toAny() { + final result = _ICU4XIsoDateTime_to_any(_ffi); + return DateTime._fromFfi(result, []); + } + + /// Gets the minutes since the local unix epoch for this date (Jan 1 1970, 00:00) + /// + /// See the [Rust documentation for `minutes_since_local_unix_epoch`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.minutes_since_local_unix_epoch) for more information. + int get minutesSinceLocalUnixEpoch { + final result = _ICU4XIsoDateTime_minutes_since_local_unix_epoch(_ffi); + return result; + } + + /// Convert this datetime to one in a different calendar + /// + /// See the [Rust documentation for `to_calendar`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.to_calendar) for more information. + DateTime toCalendar(Calendar calendar) { + final result = _ICU4XIsoDateTime_to_calendar(_ffi, calendar._ffi); + return DateTime._fromFfi(result, []); + } + + /// Returns the hour in this time + /// + /// See the [Rust documentation for `hour`](https://docs.rs/icu/latest/icu/calendar/struct.Time.html#structfield.hour) for more information. + int get hour { + final result = _ICU4XIsoDateTime_hour(_ffi); + return result; + } + + /// Returns the minute in this time + /// + /// See the [Rust documentation for `minute`](https://docs.rs/icu/latest/icu/calendar/struct.Time.html#structfield.minute) for more information. + int get minute { + final result = _ICU4XIsoDateTime_minute(_ffi); + return result; + } + + /// Returns the second in this time + /// + /// See the [Rust documentation for `second`](https://docs.rs/icu/latest/icu/calendar/struct.Time.html#structfield.second) for more information. + int get second { + final result = _ICU4XIsoDateTime_second(_ffi); + return result; + } + + /// Returns the nanosecond in this time + /// + /// See the [Rust documentation for `nanosecond`](https://docs.rs/icu/latest/icu/calendar/struct.Time.html#structfield.nanosecond) for more information. + int get nanosecond { + final result = _ICU4XIsoDateTime_nanosecond(_ffi); + return result; + } + + /// Returns the 1-indexed day in the month for this date + /// + /// See the [Rust documentation for `day_of_month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_month) for more information. + int get dayOfMonth { + final result = _ICU4XIsoDateTime_day_of_month(_ffi); + return result; + } + + /// Returns the day in the week for this day + /// + /// See the [Rust documentation for `day_of_week`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_week) for more information. + IsoWeekday get dayOfWeek { + final result = _ICU4XIsoDateTime_day_of_week(_ffi); + return IsoWeekday.values.firstWhere((v) => v._ffi == result); + } + + /// Returns the week number in this month, 1-indexed, based on what + /// is considered the first day of the week (often a locale preference). + /// + /// `first_weekday` can be obtained via `first_weekday()` on [`WeekCalculator`] + /// + /// See the [Rust documentation for `week_of_month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_month) for more information. + int weekOfMonth(IsoWeekday firstWeekday) { + final result = _ICU4XIsoDateTime_week_of_month(_ffi, firstWeekday._ffi); + return result; + } + + /// Returns the week number in this year, using week data + /// + /// See the [Rust documentation for `week_of_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_year) for more information. + /// + /// Throws [Error] on failure. + WeekOf weekOfYear(WeekCalculator calculator) { + final result = _ICU4XIsoDateTime_week_of_year(_ffi, calculator._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return WeekOf._fromFfi(result.union.ok); + } + + /// Returns 1-indexed number of the month of this date in its year + /// + /// See the [Rust documentation for `month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month) for more information. + int get month { + final result = _ICU4XIsoDateTime_month(_ffi); + return result; + } + + /// Returns the year number for this date + /// + /// See the [Rust documentation for `year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year) for more information. + int get year { + final result = _ICU4XIsoDateTime_year(_ffi); + return result; + } + + /// Returns whether this date is in a leap year + /// + /// See the [Rust documentation for `is_in_leap_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.is_in_leap_year) for more information. + bool get isInLeapYear { + final result = _ICU4XIsoDateTime_is_in_leap_year(_ffi); + return result; + } + + /// Returns the number of months in the year represented by this date + /// + /// See the [Rust documentation for `months_in_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.months_in_year) for more information. + int get monthsInYear { + final result = _ICU4XIsoDateTime_months_in_year(_ffi); + return result; + } + + /// Returns the number of days in the month represented by this date + /// + /// See the [Rust documentation for `days_in_month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_month) for more information. + int get daysInMonth { + final result = _ICU4XIsoDateTime_days_in_month(_ffi); + return result; + } + + /// Returns the number of days in the year represented by this date + /// + /// See the [Rust documentation for `days_in_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_year) for more information. + int get daysInYear { + final result = _ICU4XIsoDateTime_days_in_year(_ffi); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XIsoDateTime_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XIsoDateTime_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_create') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Int32, + ffi.Uint8, + ffi.Uint8, + ffi.Uint8, + ffi.Uint8, + ffi.Uint8, + ffi.Uint32)>(isLeaf: true, symbol: 'ICU4XIsoDateTime_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XIsoDateTime_create(int year, int month, + int day, int hour, int minute, int second, int nanosecond); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_crate_from_date_and_time') +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_crate_from_date_and_time') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XIsoDateTime_crate_from_date_and_time( + ffi.Pointer date, ffi.Pointer time); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_local_unix_epoch') +@ffi.Native Function()>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_local_unix_epoch') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XIsoDateTime_local_unix_epoch(); + +@meta.ResourceIdentifier( + 'ICU4XIsoDateTime_create_from_minutes_since_local_unix_epoch') +@ffi.Native Function(ffi.Int32)>( + isLeaf: true, + symbol: 'ICU4XIsoDateTime_create_from_minutes_since_local_unix_epoch') +// ignore: non_constant_identifier_names +external ffi.Pointer + _ICU4XIsoDateTime_create_from_minutes_since_local_unix_epoch(int minutes); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_date') +@ffi.Native Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_date') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XIsoDateTime_date( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_time') +@ffi.Native Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_time') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XIsoDateTime_time( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_to_any') +@ffi.Native Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_to_any') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XIsoDateTime_to_any( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_minutes_since_local_unix_epoch') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_minutes_since_local_unix_epoch') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDateTime_minutes_since_local_unix_epoch( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_to_calendar') +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_to_calendar') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XIsoDateTime_to_calendar( + ffi.Pointer self, ffi.Pointer calendar); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_hour') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_hour') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDateTime_hour(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_minute') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_minute') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDateTime_minute(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_second') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_second') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDateTime_second(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_nanosecond') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_nanosecond') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDateTime_nanosecond(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_day_of_month') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_day_of_month') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDateTime_day_of_month(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_day_of_week') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_day_of_week') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDateTime_day_of_week(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_week_of_month') +@ffi.Native, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_week_of_month') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDateTime_week_of_month( + ffi.Pointer self, int firstWeekday); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_week_of_year') +@ffi.Native< + _ResultWeekOfFfiInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_week_of_year') +// ignore: non_constant_identifier_names +external _ResultWeekOfFfiInt32 _ICU4XIsoDateTime_week_of_year( + ffi.Pointer self, ffi.Pointer calculator); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_month') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_month') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDateTime_month(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_year') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_year') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDateTime_year(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_is_in_leap_year') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_is_in_leap_year') +// ignore: non_constant_identifier_names +external bool _ICU4XIsoDateTime_is_in_leap_year(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_months_in_year') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_months_in_year') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDateTime_months_in_year(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_days_in_month') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_days_in_month') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDateTime_days_in_month(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XIsoDateTime_days_in_year') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XIsoDateTime_days_in_year') +// ignore: non_constant_identifier_names +external int _ICU4XIsoDateTime_days_in_year(ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/IsoTimeZoneFormat.g.dart b/pkgs/intl4x/lib/src/bindings/IsoTimeZoneFormat.g.dart deleted file mode 120000 index fc4faf2a..00000000 --- a/pkgs/intl4x/lib/src/bindings/IsoTimeZoneFormat.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/IsoTimeZoneFormat.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/IsoTimeZoneFormat.g.dart b/pkgs/intl4x/lib/src/bindings/IsoTimeZoneFormat.g.dart new file mode 100644 index 00000000..eeb90ca3 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/IsoTimeZoneFormat.g.dart @@ -0,0 +1,14 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `IsoFormat`](https://docs.rs/icu/latest/icu/datetime/time_zone/enum.IsoFormat.html) for more information. +enum IsoTimeZoneFormat { + basic, + + extended, + + utcBasic, + + utcExtended; +} diff --git a/pkgs/intl4x/lib/src/bindings/IsoTimeZoneMinuteDisplay.g.dart b/pkgs/intl4x/lib/src/bindings/IsoTimeZoneMinuteDisplay.g.dart deleted file mode 120000 index 7bc7dc43..00000000 --- a/pkgs/intl4x/lib/src/bindings/IsoTimeZoneMinuteDisplay.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/IsoTimeZoneMinuteDisplay.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/IsoTimeZoneMinuteDisplay.g.dart b/pkgs/intl4x/lib/src/bindings/IsoTimeZoneMinuteDisplay.g.dart new file mode 100644 index 00000000..fa3c67cf --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/IsoTimeZoneMinuteDisplay.g.dart @@ -0,0 +1,10 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `IsoMinutes`](https://docs.rs/icu/latest/icu/datetime/time_zone/enum.IsoMinutes.html) for more information. +enum IsoTimeZoneMinuteDisplay { + required, + + optional; +} diff --git a/pkgs/intl4x/lib/src/bindings/IsoTimeZoneOptions.g.dart b/pkgs/intl4x/lib/src/bindings/IsoTimeZoneOptions.g.dart deleted file mode 120000 index 15a12e68..00000000 --- a/pkgs/intl4x/lib/src/bindings/IsoTimeZoneOptions.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/IsoTimeZoneOptions.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/IsoTimeZoneOptions.g.dart b/pkgs/intl4x/lib/src/bindings/IsoTimeZoneOptions.g.dart new file mode 100644 index 00000000..9a35fd71 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/IsoTimeZoneOptions.g.dart @@ -0,0 +1,55 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +final class _IsoTimeZoneOptionsFfi extends ffi.Struct { + @ffi.Int32() + external int format; + @ffi.Int32() + external int minutes; + @ffi.Int32() + external int seconds; +} + +final class IsoTimeZoneOptions { + IsoTimeZoneFormat format; + IsoTimeZoneMinuteDisplay minutes; + IsoTimeZoneSecondDisplay seconds; + + IsoTimeZoneOptions( + {required this.format, required this.minutes, required this.seconds}); + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + IsoTimeZoneOptions._fromFfi(_IsoTimeZoneOptionsFfi ffi) + : format = IsoTimeZoneFormat.values[ffi.format], + minutes = IsoTimeZoneMinuteDisplay.values[ffi.minutes], + seconds = IsoTimeZoneSecondDisplay.values[ffi.seconds]; + + // ignore: unused_element + _IsoTimeZoneOptionsFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_IsoTimeZoneOptionsFfi>(); + struct.format = format.index; + struct.minutes = minutes.index; + struct.seconds = seconds.index; + return struct; + } + + @override + bool operator ==(Object other) => + other is IsoTimeZoneOptions && + other.format == format && + other.minutes == minutes && + other.seconds == seconds; + + @override + int get hashCode => Object.hashAll([ + format, + minutes, + seconds, + ]); +} diff --git a/pkgs/intl4x/lib/src/bindings/IsoTimeZoneSecondDisplay.g.dart b/pkgs/intl4x/lib/src/bindings/IsoTimeZoneSecondDisplay.g.dart deleted file mode 120000 index 90f5a1c6..00000000 --- a/pkgs/intl4x/lib/src/bindings/IsoTimeZoneSecondDisplay.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/IsoTimeZoneSecondDisplay.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/IsoTimeZoneSecondDisplay.g.dart b/pkgs/intl4x/lib/src/bindings/IsoTimeZoneSecondDisplay.g.dart new file mode 100644 index 00000000..d5be53e5 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/IsoTimeZoneSecondDisplay.g.dart @@ -0,0 +1,10 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `IsoSeconds`](https://docs.rs/icu/latest/icu/datetime/time_zone/enum.IsoSeconds.html) for more information. +enum IsoTimeZoneSecondDisplay { + optional, + + never; +} diff --git a/pkgs/intl4x/lib/src/bindings/IsoWeekday.g.dart b/pkgs/intl4x/lib/src/bindings/IsoWeekday.g.dart deleted file mode 120000 index 66616bc3..00000000 --- a/pkgs/intl4x/lib/src/bindings/IsoWeekday.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/IsoWeekday.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/IsoWeekday.g.dart b/pkgs/intl4x/lib/src/bindings/IsoWeekday.g.dart new file mode 100644 index 00000000..094bb083 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/IsoWeekday.g.dart @@ -0,0 +1,38 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +enum IsoWeekday { + monday, + + tuesday, + + wednesday, + + thursday, + + friday, + + saturday, + + sunday; + + int get _ffi { + switch (this) { + case monday: + return 1; + case tuesday: + return 2; + case wednesday: + return 3; + case thursday: + return 4; + case friday: + return 5; + case saturday: + return 6; + case sunday: + return 7; + } + } +} diff --git a/pkgs/intl4x/lib/src/bindings/LanguageDisplay.g.dart b/pkgs/intl4x/lib/src/bindings/LanguageDisplay.g.dart deleted file mode 120000 index e6c54f61..00000000 --- a/pkgs/intl4x/lib/src/bindings/LanguageDisplay.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LanguageDisplay.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LanguageDisplay.g.dart b/pkgs/intl4x/lib/src/bindings/LanguageDisplay.g.dart new file mode 100644 index 00000000..c5129314 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LanguageDisplay.g.dart @@ -0,0 +1,10 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `LanguageDisplay`](https://docs.rs/icu/latest/icu/displaynames/options/enum.LanguageDisplay.html) for more information. +enum LanguageDisplay { + dialect, + + standard; +} diff --git a/pkgs/intl4x/lib/src/bindings/LeadingAdjustment.g.dart b/pkgs/intl4x/lib/src/bindings/LeadingAdjustment.g.dart deleted file mode 120000 index c9e2bb7b..00000000 --- a/pkgs/intl4x/lib/src/bindings/LeadingAdjustment.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LeadingAdjustment.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LeadingAdjustment.g.dart b/pkgs/intl4x/lib/src/bindings/LeadingAdjustment.g.dart new file mode 100644 index 00000000..460421c1 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LeadingAdjustment.g.dart @@ -0,0 +1,12 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `LeadingAdjustment`](https://docs.rs/icu/latest/icu/casemap/titlecase/enum.LeadingAdjustment.html) for more information. +enum LeadingAdjustment { + auto, + + none, + + toCased; +} diff --git a/pkgs/intl4x/lib/src/bindings/LineBreakIteratorLatin1.g.dart b/pkgs/intl4x/lib/src/bindings/LineBreakIteratorLatin1.g.dart deleted file mode 120000 index 96a7f438..00000000 --- a/pkgs/intl4x/lib/src/bindings/LineBreakIteratorLatin1.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LineBreakIteratorLatin1.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LineBreakIteratorLatin1.g.dart b/pkgs/intl4x/lib/src/bindings/LineBreakIteratorLatin1.g.dart new file mode 100644 index 00000000..10d08d46 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LineBreakIteratorLatin1.g.dart @@ -0,0 +1,50 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `LineBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakIterator.html) for more information. +/// +/// Additional information: [1](https://docs.rs/icu/latest/icu/segmenter/type.LineBreakIteratorLatin1.html) +final class LineBreakIteratorLatin1 implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _aEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + LineBreakIteratorLatin1._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XLineBreakIteratorLatin1_destroy)); + + /// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + /// out of range of a 32-bit signed integer. + /// + /// See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakIterator.html#method.next) for more information. + int next() { + final result = _ICU4XLineBreakIteratorLatin1_next(_ffi); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XLineBreakIteratorLatin1_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XLineBreakIteratorLatin1_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XLineBreakIteratorLatin1_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XLineBreakIteratorLatin1_next') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XLineBreakIteratorLatin1_next') +// ignore: non_constant_identifier_names +external int _ICU4XLineBreakIteratorLatin1_next(ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/LineBreakIteratorUtf16.g.dart b/pkgs/intl4x/lib/src/bindings/LineBreakIteratorUtf16.g.dart deleted file mode 120000 index 36eaedca..00000000 --- a/pkgs/intl4x/lib/src/bindings/LineBreakIteratorUtf16.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LineBreakIteratorUtf16.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LineBreakIteratorUtf16.g.dart b/pkgs/intl4x/lib/src/bindings/LineBreakIteratorUtf16.g.dart new file mode 100644 index 00000000..d7d506a1 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LineBreakIteratorUtf16.g.dart @@ -0,0 +1,50 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `LineBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakIterator.html) for more information. +/// +/// Additional information: [1](https://docs.rs/icu/latest/icu/segmenter/type.LineBreakIteratorUtf16.html) +final class LineBreakIteratorUtf16 implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _aEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + LineBreakIteratorUtf16._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XLineBreakIteratorUtf16_destroy)); + + /// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + /// out of range of a 32-bit signed integer. + /// + /// See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakIterator.html#method.next) for more information. + int next() { + final result = _ICU4XLineBreakIteratorUtf16_next(_ffi); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XLineBreakIteratorUtf16_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XLineBreakIteratorUtf16_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XLineBreakIteratorUtf16_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XLineBreakIteratorUtf16_next') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XLineBreakIteratorUtf16_next') +// ignore: non_constant_identifier_names +external int _ICU4XLineBreakIteratorUtf16_next(ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/LineBreakIteratorUtf8.g.dart b/pkgs/intl4x/lib/src/bindings/LineBreakIteratorUtf8.g.dart deleted file mode 120000 index 05ed01ee..00000000 --- a/pkgs/intl4x/lib/src/bindings/LineBreakIteratorUtf8.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LineBreakIteratorUtf8.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LineBreakIteratorUtf8.g.dart b/pkgs/intl4x/lib/src/bindings/LineBreakIteratorUtf8.g.dart new file mode 100644 index 00000000..4a2db823 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LineBreakIteratorUtf8.g.dart @@ -0,0 +1,50 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `LineBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakIterator.html) for more information. +/// +/// Additional information: [1](https://docs.rs/icu/latest/icu/segmenter/type.LineBreakIteratorPotentiallyIllFormedUtf8.html) +final class LineBreakIteratorUtf8 implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _aEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + LineBreakIteratorUtf8._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XLineBreakIteratorUtf8_destroy)); + + /// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + /// out of range of a 32-bit signed integer. + /// + /// See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakIterator.html#method.next) for more information. + int next() { + final result = _ICU4XLineBreakIteratorUtf8_next(_ffi); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XLineBreakIteratorUtf8_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XLineBreakIteratorUtf8_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XLineBreakIteratorUtf8_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XLineBreakIteratorUtf8_next') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XLineBreakIteratorUtf8_next') +// ignore: non_constant_identifier_names +external int _ICU4XLineBreakIteratorUtf8_next(ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/LineBreakOptions.g.dart b/pkgs/intl4x/lib/src/bindings/LineBreakOptions.g.dart deleted file mode 120000 index f9159097..00000000 --- a/pkgs/intl4x/lib/src/bindings/LineBreakOptions.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LineBreakOptions.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LineBreakOptions.g.dart b/pkgs/intl4x/lib/src/bindings/LineBreakOptions.g.dart new file mode 100644 index 00000000..ab5ce434 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LineBreakOptions.g.dart @@ -0,0 +1,56 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +final class _LineBreakOptionsFfi extends ffi.Struct { + @ffi.Int32() + external int strictness; + @ffi.Int32() + external int wordOption; + @ffi.Bool() + external bool jaZh; +} + +/// See the [Rust documentation for `LineBreakOptions`](https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakOptions.html) for more information. +final class LineBreakOptions { + LineBreakStrictness strictness; + LineBreakWordOption wordOption; + bool jaZh; + + LineBreakOptions( + {required this.strictness, required this.wordOption, required this.jaZh}); + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + LineBreakOptions._fromFfi(_LineBreakOptionsFfi ffi) + : strictness = LineBreakStrictness.values[ffi.strictness], + wordOption = LineBreakWordOption.values[ffi.wordOption], + jaZh = ffi.jaZh; + + // ignore: unused_element + _LineBreakOptionsFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_LineBreakOptionsFfi>(); + struct.strictness = strictness.index; + struct.wordOption = wordOption.index; + struct.jaZh = jaZh; + return struct; + } + + @override + bool operator ==(Object other) => + other is LineBreakOptions && + other.strictness == strictness && + other.wordOption == wordOption && + other.jaZh == jaZh; + + @override + int get hashCode => Object.hashAll([ + strictness, + wordOption, + jaZh, + ]); +} diff --git a/pkgs/intl4x/lib/src/bindings/LineBreakStrictness.g.dart b/pkgs/intl4x/lib/src/bindings/LineBreakStrictness.g.dart deleted file mode 120000 index 704f2ee7..00000000 --- a/pkgs/intl4x/lib/src/bindings/LineBreakStrictness.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LineBreakStrictness.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LineBreakStrictness.g.dart b/pkgs/intl4x/lib/src/bindings/LineBreakStrictness.g.dart new file mode 100644 index 00000000..decea691 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LineBreakStrictness.g.dart @@ -0,0 +1,14 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `LineBreakStrictness`](https://docs.rs/icu/latest/icu/segmenter/enum.LineBreakStrictness.html) for more information. +enum LineBreakStrictness { + loose, + + normal, + + strict, + + anywhere; +} diff --git a/pkgs/intl4x/lib/src/bindings/LineBreakWordOption.g.dart b/pkgs/intl4x/lib/src/bindings/LineBreakWordOption.g.dart deleted file mode 120000 index 55927a84..00000000 --- a/pkgs/intl4x/lib/src/bindings/LineBreakWordOption.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LineBreakWordOption.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LineBreakWordOption.g.dart b/pkgs/intl4x/lib/src/bindings/LineBreakWordOption.g.dart new file mode 100644 index 00000000..bd0d522f --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LineBreakWordOption.g.dart @@ -0,0 +1,12 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `LineBreakWordOption`](https://docs.rs/icu/latest/icu/segmenter/enum.LineBreakWordOption.html) for more information. +enum LineBreakWordOption { + normal, + + breakAll, + + keepAll; +} diff --git a/pkgs/intl4x/lib/src/bindings/LineSegmenter.g.dart b/pkgs/intl4x/lib/src/bindings/LineSegmenter.g.dart deleted file mode 120000 index bd91aebd..00000000 --- a/pkgs/intl4x/lib/src/bindings/LineSegmenter.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LineSegmenter.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LineSegmenter.g.dart b/pkgs/intl4x/lib/src/bindings/LineSegmenter.g.dart new file mode 100644 index 00000000..1b171d6a --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LineSegmenter.g.dart @@ -0,0 +1,207 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X line-break segmenter, capable of finding breakpoints in strings. +/// +/// See the [Rust documentation for `LineSegmenter`](https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html) for more information. +final class LineSegmenter implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + LineSegmenter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XLineSegmenter_destroy)); + + /// Construct a [`LineSegmenter`] with default options. It automatically loads the best + /// available payload data for Burmese, Khmer, Lao, and Thai. + /// + /// See the [Rust documentation for `new_auto`](https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.new_auto) for more information. + /// + /// Throws [Error] on failure. + factory LineSegmenter.auto(DataProvider provider) { + final result = _ICU4XLineSegmenter_create_auto(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return LineSegmenter._fromFfi(result.union.ok, []); + } + + /// Construct a [`LineSegmenter`] with default options and LSTM payload data for + /// Burmese, Khmer, Lao, and Thai. + /// + /// See the [Rust documentation for `new_lstm`](https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.new_lstm) for more information. + /// + /// Throws [Error] on failure. + factory LineSegmenter.lstm(DataProvider provider) { + final result = _ICU4XLineSegmenter_create_lstm(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return LineSegmenter._fromFfi(result.union.ok, []); + } + + /// Construct a [`LineSegmenter`] with default options and dictionary payload data for + /// Burmese, Khmer, Lao, and Thai.. + /// + /// See the [Rust documentation for `new_dictionary`](https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.new_dictionary) for more information. + /// + /// Throws [Error] on failure. + factory LineSegmenter.dictionary(DataProvider provider) { + final result = _ICU4XLineSegmenter_create_dictionary(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return LineSegmenter._fromFfi(result.union.ok, []); + } + + /// Construct a [`LineSegmenter`] with custom options. It automatically loads the best + /// available payload data for Burmese, Khmer, Lao, and Thai. + /// + /// See the [Rust documentation for `new_auto_with_options`](https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.new_auto_with_options) for more information. + /// + /// Throws [Error] on failure. + factory LineSegmenter.autoWithOptions( + DataProvider provider, LineBreakOptions options) { + final temp = ffi2.Arena(); + final result = _ICU4XLineSegmenter_create_auto_with_options_v1( + provider._ffi, options._toFfi(temp)); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return LineSegmenter._fromFfi(result.union.ok, []); + } + + /// Construct a [`LineSegmenter`] with custom options and LSTM payload data for + /// Burmese, Khmer, Lao, and Thai. + /// + /// See the [Rust documentation for `new_lstm_with_options`](https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.new_lstm_with_options) for more information. + /// + /// Throws [Error] on failure. + factory LineSegmenter.lstmWithOptions( + DataProvider provider, LineBreakOptions options) { + final temp = ffi2.Arena(); + final result = _ICU4XLineSegmenter_create_lstm_with_options_v1( + provider._ffi, options._toFfi(temp)); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return LineSegmenter._fromFfi(result.union.ok, []); + } + + /// Construct a [`LineSegmenter`] with custom options and dictionary payload data for + /// Burmese, Khmer, Lao, and Thai. + /// + /// See the [Rust documentation for `new_dictionary_with_options`](https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.new_dictionary_with_options) for more information. + /// + /// Throws [Error] on failure. + factory LineSegmenter.dictionaryWithOptions( + DataProvider provider, LineBreakOptions options) { + final temp = ffi2.Arena(); + final result = _ICU4XLineSegmenter_create_dictionary_with_options_v1( + provider._ffi, options._toFfi(temp)); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return LineSegmenter._fromFfi(result.union.ok, []); + } + + /// Segments a string. + /// + /// Ill-formed input is treated as if errors had been replaced with REPLACEMENT CHARACTERs according + /// to the WHATWG Encoding Standard. + /// + /// See the [Rust documentation for `segment_utf16`](https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.segment_utf16) for more information. + LineBreakIteratorUtf16 segment(String input) { + final inputView = input.utf16View; + final inputArena = _FinalizedArena(); + // This lifetime edge depends on lifetimes: 'a + core.List aEdges = [this, inputArena]; + final result = _ICU4XLineSegmenter_segment_utf16( + _ffi, inputView.allocIn(inputArena.arena), inputView.length); + return LineBreakIteratorUtf16._fromFfi(result, [], aEdges); + } +} + +@meta.ResourceIdentifier('ICU4XLineSegmenter_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XLineSegmenter_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XLineSegmenter_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XLineSegmenter_create_auto') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLineSegmenter_create_auto') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XLineSegmenter_create_auto( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XLineSegmenter_create_lstm') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLineSegmenter_create_lstm') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XLineSegmenter_create_lstm( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XLineSegmenter_create_dictionary') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLineSegmenter_create_dictionary') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XLineSegmenter_create_dictionary( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XLineSegmenter_create_auto_with_options_v1') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, _LineBreakOptionsFfi)>( + isLeaf: true, symbol: 'ICU4XLineSegmenter_create_auto_with_options_v1') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XLineSegmenter_create_auto_with_options_v1( + ffi.Pointer provider, _LineBreakOptionsFfi options); + +@meta.ResourceIdentifier('ICU4XLineSegmenter_create_lstm_with_options_v1') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, _LineBreakOptionsFfi)>( + isLeaf: true, symbol: 'ICU4XLineSegmenter_create_lstm_with_options_v1') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XLineSegmenter_create_lstm_with_options_v1( + ffi.Pointer provider, _LineBreakOptionsFfi options); + +@meta.ResourceIdentifier('ICU4XLineSegmenter_create_dictionary_with_options_v1') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, _LineBreakOptionsFfi)>( + isLeaf: true, + symbol: 'ICU4XLineSegmenter_create_dictionary_with_options_v1') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XLineSegmenter_create_dictionary_with_options_v1( + ffi.Pointer provider, _LineBreakOptionsFfi options); + +@meta.ResourceIdentifier('ICU4XLineSegmenter_segment_utf16') +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size)>(isLeaf: true, symbol: 'ICU4XLineSegmenter_segment_utf16') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XLineSegmenter_segment_utf16( + ffi.Pointer self, + ffi.Pointer inputData, + int inputLength); diff --git a/pkgs/intl4x/lib/src/bindings/ListFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/ListFormatter.g.dart deleted file mode 120000 index 6babee68..00000000 --- a/pkgs/intl4x/lib/src/bindings/ListFormatter.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/ListFormatter.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/ListFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/ListFormatter.g.dart new file mode 100644 index 00000000..8edf8517 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/ListFormatter.g.dart @@ -0,0 +1,137 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `ListFormatter`](https://docs.rs/icu/latest/icu/list/struct.ListFormatter.html) for more information. +final class ListFormatter implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + ListFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XListFormatter_destroy)); + + /// Construct a new ICU4XListFormatter instance for And patterns + /// + /// See the [Rust documentation for `try_new_and_with_length`](https://docs.rs/icu/latest/icu/list/struct.ListFormatter.html#method.try_new_and_with_length) for more information. + /// + /// Throws [Error] on failure. + factory ListFormatter.andWithLength( + DataProvider provider, Locale locale, ListLength length) { + final result = _ICU4XListFormatter_create_and_with_length( + provider._ffi, locale._ffi, length.index); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return ListFormatter._fromFfi(result.union.ok, []); + } + + /// Construct a new ICU4XListFormatter instance for And patterns + /// + /// See the [Rust documentation for `try_new_or_with_length`](https://docs.rs/icu/latest/icu/list/struct.ListFormatter.html#method.try_new_or_with_length) for more information. + /// + /// Throws [Error] on failure. + factory ListFormatter.orWithLength( + DataProvider provider, Locale locale, ListLength length) { + final result = _ICU4XListFormatter_create_or_with_length( + provider._ffi, locale._ffi, length.index); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return ListFormatter._fromFfi(result.union.ok, []); + } + + /// Construct a new ICU4XListFormatter instance for And patterns + /// + /// See the [Rust documentation for `try_new_unit_with_length`](https://docs.rs/icu/latest/icu/list/struct.ListFormatter.html#method.try_new_unit_with_length) for more information. + /// + /// Throws [Error] on failure. + factory ListFormatter.unitWithLength( + DataProvider provider, Locale locale, ListLength length) { + final result = _ICU4XListFormatter_create_unit_with_length( + provider._ffi, locale._ffi, length.index); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return ListFormatter._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/list/struct.ListFormatter.html#method.format) for more information. + /// + /// Throws [Error] on failure. + String format(core.List list) { + final temp = ffi2.Arena(); + final listView = list.utf16View; + final writeable = _Writeable(); + final result = _ICU4XListFormatter_format_utf16( + _ffi, listView.allocIn(temp), listView.length, writeable._ffi); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } +} + +@meta.ResourceIdentifier('ICU4XListFormatter_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XListFormatter_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XListFormatter_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XListFormatter_create_and_with_length') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XListFormatter_create_and_with_length') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XListFormatter_create_and_with_length( + ffi.Pointer provider, + ffi.Pointer locale, + int length); + +@meta.ResourceIdentifier('ICU4XListFormatter_create_or_with_length') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XListFormatter_create_or_with_length') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XListFormatter_create_or_with_length( + ffi.Pointer provider, + ffi.Pointer locale, + int length); + +@meta.ResourceIdentifier('ICU4XListFormatter_create_unit_with_length') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XListFormatter_create_unit_with_length') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XListFormatter_create_unit_with_length( + ffi.Pointer provider, + ffi.Pointer locale, + int length); + +@meta.ResourceIdentifier('ICU4XListFormatter_format_utf16') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer<_SliceUtf16>, ffi.Size, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XListFormatter_format_utf16') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XListFormatter_format_utf16( + ffi.Pointer self, + ffi.Pointer<_SliceUtf16> listData, + int listLength, + ffi.Pointer writeable); diff --git a/pkgs/intl4x/lib/src/bindings/ListLength.g.dart b/pkgs/intl4x/lib/src/bindings/ListLength.g.dart deleted file mode 120000 index 463aa395..00000000 --- a/pkgs/intl4x/lib/src/bindings/ListLength.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/ListLength.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/ListLength.g.dart b/pkgs/intl4x/lib/src/bindings/ListLength.g.dart new file mode 100644 index 00000000..47cb4d88 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/ListLength.g.dart @@ -0,0 +1,12 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `ListLength`](https://docs.rs/icu/latest/icu/list/enum.ListLength.html) for more information. +enum ListLength { + wide, + + short, + + narrow; +} diff --git a/pkgs/intl4x/lib/src/bindings/Locale.g.dart b/pkgs/intl4x/lib/src/bindings/Locale.g.dart deleted file mode 120000 index d8f1cdda..00000000 --- a/pkgs/intl4x/lib/src/bindings/Locale.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/Locale.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/Locale.g.dart b/pkgs/intl4x/lib/src/bindings/Locale.g.dart new file mode 100644 index 00000000..9720511f --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/Locale.g.dart @@ -0,0 +1,393 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X Locale, capable of representing strings like `"en-US"`. +/// +/// See the [Rust documentation for `Locale`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html) for more information. +final class Locale implements ffi.Finalizable, core.Comparable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + Locale._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XLocale_destroy)); + + /// Construct an [`Locale`] from an locale identifier. + /// + /// This will run the complete locale parsing algorithm. If code size and + /// performance are critical and the locale is of a known shape (such as + /// `aa-BB`) use `create_und`, `set_language`, `set_script`, and `set_region`. + /// + /// See the [Rust documentation for `try_from_bytes`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.try_from_bytes) for more information. + /// + /// Throws [Error] on failure. + factory Locale.fromString(String name) { + final temp = ffi2.Arena(); + final nameView = name.utf8View; + final result = _ICU4XLocale_create_from_string( + nameView.allocIn(temp), nameView.length); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return Locale._fromFfi(result.union.ok, []); + } + + /// Construct a default undefined [`Locale`] "und". + /// + /// See the [Rust documentation for `UND`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#associatedconstant.UND) for more information. + factory Locale.und() { + final result = _ICU4XLocale_create_und(); + return Locale._fromFfi(result, []); + } + + /// Clones the [`Locale`]. + /// + /// See the [Rust documentation for `Locale`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html) for more information. + Locale clone() { + final result = _ICU4XLocale_clone(_ffi); + return Locale._fromFfi(result, []); + } + + /// Write a string representation of the `LanguageIdentifier` part of + /// [`Locale`] to `write`. + /// + /// See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.id) for more information. + /// + /// Throws [Error] on failure. + String get basename { + final writeable = _Writeable(); + final result = _ICU4XLocale_basename(_ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Write a string representation of the unicode extension to `write` + /// + /// See the [Rust documentation for `extensions`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.extensions) for more information. + /// + /// Throws [Error] on failure. + String getUnicodeExtension(String bytes) { + final temp = ffi2.Arena(); + final bytesView = bytes.utf8View; + final writeable = _Writeable(); + final result = _ICU4XLocale_get_unicode_extension( + _ffi, bytesView.allocIn(temp), bytesView.length, writeable._ffi); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Write a string representation of [`Locale`] language to `write` + /// + /// See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.id) for more information. + /// + /// Throws [Error] on failure. + String get language { + final writeable = _Writeable(); + final result = _ICU4XLocale_language(_ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Set the language part of the [`Locale`]. + /// + /// See the [Rust documentation for `try_from_bytes`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.try_from_bytes) for more information. + /// + /// Throws [Error] on failure. + set language(String bytes) { + final temp = ffi2.Arena(); + final bytesView = bytes.utf8View; + final result = _ICU4XLocale_set_language( + _ffi, bytesView.allocIn(temp), bytesView.length); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// Write a string representation of [`Locale`] region to `write` + /// + /// See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.id) for more information. + /// + /// Throws [Error] on failure. + String get region { + final writeable = _Writeable(); + final result = _ICU4XLocale_region(_ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Set the region part of the [`Locale`]. + /// + /// See the [Rust documentation for `try_from_bytes`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.try_from_bytes) for more information. + /// + /// Throws [Error] on failure. + set region(String bytes) { + final temp = ffi2.Arena(); + final bytesView = bytes.utf8View; + final result = _ICU4XLocale_set_region( + _ffi, bytesView.allocIn(temp), bytesView.length); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// Write a string representation of [`Locale`] script to `write` + /// + /// See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.id) for more information. + /// + /// Throws [Error] on failure. + String get script { + final writeable = _Writeable(); + final result = _ICU4XLocale_script(_ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Set the script part of the [`Locale`]. Pass an empty string to remove the script. + /// + /// See the [Rust documentation for `try_from_bytes`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.try_from_bytes) for more information. + /// + /// Throws [Error] on failure. + set script(String bytes) { + final temp = ffi2.Arena(); + final bytesView = bytes.utf8View; + final result = _ICU4XLocale_set_script( + _ffi, bytesView.allocIn(temp), bytesView.length); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// Best effort locale canonicalizer that doesn't need any data + /// + /// Use ICU4XLocaleCanonicalizer for better control and functionality + /// + /// See the [Rust documentation for `canonicalize`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.canonicalize) for more information. + /// + /// Throws [Error] on failure. + static String canonicalize(String bytes) { + final temp = ffi2.Arena(); + final bytesView = bytes.utf8View; + final writeable = _Writeable(); + final result = _ICU4XLocale_canonicalize( + bytesView.allocIn(temp), bytesView.length, writeable._ffi); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Write a string representation of [`Locale`] to `write` + /// + /// See the [Rust documentation for `write_to`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.write_to) for more information. + /// + /// Throws [Error] on failure. + @override + String toString() { + final writeable = _Writeable(); + final result = _ICU4XLocale_to_string(_ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// See the [Rust documentation for `normalizing_eq`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.normalizing_eq) for more information. + bool normalizingEq(String other) { + final temp = ffi2.Arena(); + final otherView = other.utf8View; + final result = _ICU4XLocale_normalizing_eq( + _ffi, otherView.allocIn(temp), otherView.length); + temp.releaseAll(); + return result; + } + + /// See the [Rust documentation for `strict_cmp`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.strict_cmp) for more information. + int compareToString(String other) { + final temp = ffi2.Arena(); + final otherView = other.utf8View; + final result = _ICU4XLocale_strict_cmp_( + _ffi, otherView.allocIn(temp), otherView.length); + temp.releaseAll(); + return result; + } + + /// See the [Rust documentation for `total_cmp`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.total_cmp) for more information. + int compareTo(Locale other) { + final result = _ICU4XLocale_total_cmp_(_ffi, other._ffi); + return result; + } + + @override + bool operator ==(Object other) => other is Locale && compareTo(other) == 0; + @override + int get hashCode => + 42; // Cannot get hash from Rust, so a constant is the only correct impl +} + +@meta.ResourceIdentifier('ICU4XLocale_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XLocale_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XLocale_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XLocale_create_from_string') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XLocale_create_from_string') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XLocale_create_from_string( + ffi.Pointer nameData, int nameLength); + +@meta.ResourceIdentifier('ICU4XLocale_create_und') +@ffi.Native Function()>( + isLeaf: true, symbol: 'ICU4XLocale_create_und') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XLocale_create_und(); + +@meta.ResourceIdentifier('ICU4XLocale_clone') +@ffi.Native Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocale_clone') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XLocale_clone( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XLocale_basename') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer)>(isLeaf: true, symbol: 'ICU4XLocale_basename') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XLocale_basename( + ffi.Pointer self, ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XLocale_get_unicode_extension') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Size, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocale_get_unicode_extension') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XLocale_get_unicode_extension( + ffi.Pointer self, + ffi.Pointer bytesData, + int bytesLength, + ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XLocale_language') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer)>(isLeaf: true, symbol: 'ICU4XLocale_language') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XLocale_language( + ffi.Pointer self, ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XLocale_set_language') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, ffi.Pointer, + ffi.Size)>(isLeaf: true, symbol: 'ICU4XLocale_set_language') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XLocale_set_language( + ffi.Pointer self, + ffi.Pointer bytesData, + int bytesLength); + +@meta.ResourceIdentifier('ICU4XLocale_region') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer)>(isLeaf: true, symbol: 'ICU4XLocale_region') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XLocale_region( + ffi.Pointer self, ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XLocale_set_region') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, ffi.Pointer, + ffi.Size)>(isLeaf: true, symbol: 'ICU4XLocale_set_region') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XLocale_set_region(ffi.Pointer self, + ffi.Pointer bytesData, int bytesLength); + +@meta.ResourceIdentifier('ICU4XLocale_script') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer)>(isLeaf: true, symbol: 'ICU4XLocale_script') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XLocale_script( + ffi.Pointer self, ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XLocale_set_script') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, ffi.Pointer, + ffi.Size)>(isLeaf: true, symbol: 'ICU4XLocale_set_script') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XLocale_set_script(ffi.Pointer self, + ffi.Pointer bytesData, int bytesLength); + +@meta.ResourceIdentifier('ICU4XLocale_canonicalize') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, ffi.Size, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocale_canonicalize') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XLocale_canonicalize( + ffi.Pointer bytesData, + int bytesLength, + ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XLocale_to_string') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer)>(isLeaf: true, symbol: 'ICU4XLocale_to_string') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XLocale_to_string( + ffi.Pointer self, ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XLocale_normalizing_eq') +@ffi.Native< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Size)>(isLeaf: true, symbol: 'ICU4XLocale_normalizing_eq') +// ignore: non_constant_identifier_names +external bool _ICU4XLocale_normalizing_eq(ffi.Pointer self, + ffi.Pointer otherData, int otherLength); + +@meta.ResourceIdentifier('ICU4XLocale_strict_cmp_') +@ffi.Native< + ffi.Int8 Function(ffi.Pointer, ffi.Pointer, + ffi.Size)>(isLeaf: true, symbol: 'ICU4XLocale_strict_cmp_') +// ignore: non_constant_identifier_names +external int _ICU4XLocale_strict_cmp_(ffi.Pointer self, + ffi.Pointer otherData, int otherLength); + +@meta.ResourceIdentifier('ICU4XLocale_total_cmp_') +@ffi.Native< + ffi.Int8 Function(ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocale_total_cmp_') +// ignore: non_constant_identifier_names +external int _ICU4XLocale_total_cmp_( + ffi.Pointer self, ffi.Pointer other); diff --git a/pkgs/intl4x/lib/src/bindings/LocaleCanonicalizer.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleCanonicalizer.g.dart deleted file mode 120000 index 4a371c91..00000000 --- a/pkgs/intl4x/lib/src/bindings/LocaleCanonicalizer.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LocaleCanonicalizer.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LocaleCanonicalizer.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleCanonicalizer.g.dart new file mode 100644 index 00000000..2c0bbc74 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LocaleCanonicalizer.g.dart @@ -0,0 +1,87 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// A locale canonicalizer. +/// +/// See the [Rust documentation for `LocaleCanonicalizer`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleCanonicalizer.html) for more information. +final class LocaleCanonicalizer implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + LocaleCanonicalizer._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XLocaleCanonicalizer_destroy)); + + /// Create a new [`LocaleCanonicalizer`]. + /// + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleCanonicalizer.html#method.new) for more information. + /// + /// Throws [Error] on failure. + factory LocaleCanonicalizer(DataProvider provider) { + final result = _ICU4XLocaleCanonicalizer_create(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return LocaleCanonicalizer._fromFfi(result.union.ok, []); + } + + /// Create a new [`LocaleCanonicalizer`] with extended data. + /// + /// See the [Rust documentation for `new_with_expander`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleCanonicalizer.html#method.new_with_expander) for more information. + /// + /// Throws [Error] on failure. + factory LocaleCanonicalizer.extended(DataProvider provider) { + final result = _ICU4XLocaleCanonicalizer_create_extended(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return LocaleCanonicalizer._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `canonicalize`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleCanonicalizer.html#method.canonicalize) for more information. + TransformResult canonicalize(Locale locale) { + final result = _ICU4XLocaleCanonicalizer_canonicalize(_ffi, locale._ffi); + return TransformResult.values[result]; + } +} + +@meta.ResourceIdentifier('ICU4XLocaleCanonicalizer_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XLocaleCanonicalizer_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XLocaleCanonicalizer_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XLocaleCanonicalizer_create') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocaleCanonicalizer_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XLocaleCanonicalizer_create( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XLocaleCanonicalizer_create_extended') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocaleCanonicalizer_create_extended') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XLocaleCanonicalizer_create_extended( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XLocaleCanonicalizer_canonicalize') +@ffi.Native< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocaleCanonicalizer_canonicalize') +// ignore: non_constant_identifier_names +external int _ICU4XLocaleCanonicalizer_canonicalize( + ffi.Pointer self, ffi.Pointer locale); diff --git a/pkgs/intl4x/lib/src/bindings/LocaleDirection.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleDirection.g.dart deleted file mode 120000 index 1d6fa0f8..00000000 --- a/pkgs/intl4x/lib/src/bindings/LocaleDirection.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LocaleDirection.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LocaleDirection.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleDirection.g.dart new file mode 100644 index 00000000..b2fb05f6 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LocaleDirection.g.dart @@ -0,0 +1,12 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `Direction`](https://docs.rs/icu/latest/icu/locid_transform/enum.Direction.html) for more information. +enum LocaleDirection { + leftToRight, + + rightToLeft, + + unknown; +} diff --git a/pkgs/intl4x/lib/src/bindings/LocaleDirectionality.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleDirectionality.g.dart deleted file mode 120000 index 37838f3f..00000000 --- a/pkgs/intl4x/lib/src/bindings/LocaleDirectionality.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LocaleDirectionality.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LocaleDirectionality.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleDirectionality.g.dart new file mode 100644 index 00000000..93e9bf4b --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LocaleDirectionality.g.dart @@ -0,0 +1,119 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `LocaleDirectionality`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleDirectionality.html) for more information. +final class LocaleDirectionality implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + LocaleDirectionality._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XLocaleDirectionality_destroy)); + + /// Construct a new ICU4XLocaleDirectionality instance + /// + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleDirectionality.html#method.new) for more information. + /// + /// Throws [Error] on failure. + factory LocaleDirectionality(DataProvider provider) { + final result = _ICU4XLocaleDirectionality_create(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return LocaleDirectionality._fromFfi(result.union.ok, []); + } + + /// Construct a new ICU4XLocaleDirectionality instance with a custom expander + /// + /// See the [Rust documentation for `new_with_expander`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleDirectionality.html#method.new_with_expander) for more information. + /// + /// Throws [Error] on failure. + factory LocaleDirectionality.withExpander( + DataProvider provider, LocaleExpander expander) { + final result = _ICU4XLocaleDirectionality_create_with_expander( + provider._ffi, expander._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return LocaleDirectionality._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `get`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleDirectionality.html#method.get) for more information. + LocaleDirection operator [](Locale locale) { + final result = _ICU4XLocaleDirectionality_get(_ffi, locale._ffi); + return LocaleDirection.values[result]; + } + + /// See the [Rust documentation for `is_left_to_right`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleDirectionality.html#method.is_left_to_right) for more information. + bool isLeftToRight(Locale locale) { + final result = + _ICU4XLocaleDirectionality_is_left_to_right(_ffi, locale._ffi); + return result; + } + + /// See the [Rust documentation for `is_right_to_left`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleDirectionality.html#method.is_right_to_left) for more information. + bool isRightToLeft(Locale locale) { + final result = + _ICU4XLocaleDirectionality_is_right_to_left(_ffi, locale._ffi); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XLocaleDirectionality_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XLocaleDirectionality_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XLocaleDirectionality_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XLocaleDirectionality_create') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocaleDirectionality_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XLocaleDirectionality_create( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XLocaleDirectionality_create_with_expander') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocaleDirectionality_create_with_expander') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XLocaleDirectionality_create_with_expander( + ffi.Pointer provider, ffi.Pointer expander); + +@meta.ResourceIdentifier('ICU4XLocaleDirectionality_get') +@ffi.Native< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocaleDirectionality_get') +// ignore: non_constant_identifier_names +external int _ICU4XLocaleDirectionality_get( + ffi.Pointer self, ffi.Pointer locale); + +@meta.ResourceIdentifier('ICU4XLocaleDirectionality_is_left_to_right') +@ffi.Native< + ffi.Bool Function(ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocaleDirectionality_is_left_to_right') +// ignore: non_constant_identifier_names +external bool _ICU4XLocaleDirectionality_is_left_to_right( + ffi.Pointer self, ffi.Pointer locale); + +@meta.ResourceIdentifier('ICU4XLocaleDirectionality_is_right_to_left') +@ffi.Native< + ffi.Bool Function(ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocaleDirectionality_is_right_to_left') +// ignore: non_constant_identifier_names +external bool _ICU4XLocaleDirectionality_is_right_to_left( + ffi.Pointer self, ffi.Pointer locale); diff --git a/pkgs/intl4x/lib/src/bindings/LocaleDisplayNamesFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleDisplayNamesFormatter.g.dart deleted file mode 120000 index 7858d023..00000000 --- a/pkgs/intl4x/lib/src/bindings/LocaleDisplayNamesFormatter.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LocaleDisplayNamesFormatter.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LocaleDisplayNamesFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleDisplayNamesFormatter.g.dart new file mode 100644 index 00000000..72231e10 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LocaleDisplayNamesFormatter.g.dart @@ -0,0 +1,86 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `LocaleDisplayNamesFormatter`](https://docs.rs/icu/latest/icu/displaynames/struct.LocaleDisplayNamesFormatter.html) for more information. +final class LocaleDisplayNamesFormatter implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + LocaleDisplayNamesFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XLocaleDisplayNamesFormatter_destroy)); + + /// Creates a new `LocaleDisplayNamesFormatter` from locale data and an options bag. + /// + /// See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/displaynames/struct.LocaleDisplayNamesFormatter.html#method.try_new) for more information. + /// + /// Throws [Error] on failure. + factory LocaleDisplayNamesFormatter( + DataProvider provider, Locale locale, DisplayNamesOptions options) { + final temp = ffi2.Arena(); + final result = _ICU4XLocaleDisplayNamesFormatter_create( + provider._ffi, locale._ffi, options._toFfi(temp)); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return LocaleDisplayNamesFormatter._fromFfi(result.union.ok, []); + } + + /// Returns the locale-specific display name of a locale. + /// + /// See the [Rust documentation for `of`](https://docs.rs/icu/latest/icu/displaynames/struct.LocaleDisplayNamesFormatter.html#method.of) for more information. + /// + /// Throws [Error] on failure. + String of(Locale locale) { + final writeable = _Writeable(); + final result = + _ICU4XLocaleDisplayNamesFormatter_of(_ffi, locale._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } +} + +@meta.ResourceIdentifier('ICU4XLocaleDisplayNamesFormatter_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XLocaleDisplayNamesFormatter_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XLocaleDisplayNamesFormatter_destroy( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XLocaleDisplayNamesFormatter_create') +@ffi.Native< + _ResultOpaqueInt32 Function(ffi.Pointer, + ffi.Pointer, _DisplayNamesOptionsFfi)>( + isLeaf: true, symbol: 'ICU4XLocaleDisplayNamesFormatter_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XLocaleDisplayNamesFormatter_create( + ffi.Pointer provider, + ffi.Pointer locale, + _DisplayNamesOptionsFfi options); + +@meta.ResourceIdentifier('ICU4XLocaleDisplayNamesFormatter_of') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocaleDisplayNamesFormatter_of') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XLocaleDisplayNamesFormatter_of( + ffi.Pointer self, + ffi.Pointer locale, + ffi.Pointer writeable); diff --git a/pkgs/intl4x/lib/src/bindings/LocaleExpander.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleExpander.g.dart deleted file mode 120000 index c149ba01..00000000 --- a/pkgs/intl4x/lib/src/bindings/LocaleExpander.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LocaleExpander.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LocaleExpander.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleExpander.g.dart new file mode 100644 index 00000000..5c825eac --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LocaleExpander.g.dart @@ -0,0 +1,116 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// A locale expander. +/// +/// See the [Rust documentation for `LocaleExpander`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html) for more information. +final class LocaleExpander implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + LocaleExpander._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XLocaleExpander_destroy)); + + /// Create a new [`LocaleExpander`]. + /// + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html#method.new) for more information. + /// + /// Throws [Error] on failure. + factory LocaleExpander(DataProvider provider) { + final result = _ICU4XLocaleExpander_create(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return LocaleExpander._fromFfi(result.union.ok, []); + } + + /// Create a new [`LocaleExpander`] with extended data. + /// + /// See the [Rust documentation for `new_extended`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html#method.new_extended) for more information. + /// + /// Throws [Error] on failure. + factory LocaleExpander.extended(DataProvider provider) { + final result = _ICU4XLocaleExpander_create_extended(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return LocaleExpander._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `maximize`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html#method.maximize) for more information. + TransformResult maximize(Locale locale) { + final result = _ICU4XLocaleExpander_maximize(_ffi, locale._ffi); + return TransformResult.values[result]; + } + + /// See the [Rust documentation for `minimize`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html#method.minimize) for more information. + TransformResult minimize(Locale locale) { + final result = _ICU4XLocaleExpander_minimize(_ffi, locale._ffi); + return TransformResult.values[result]; + } + + /// See the [Rust documentation for `minimize_favor_script`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html#method.minimize_favor_script) for more information. + TransformResult minimizeFavorScript(Locale locale) { + final result = + _ICU4XLocaleExpander_minimize_favor_script(_ffi, locale._ffi); + return TransformResult.values[result]; + } +} + +@meta.ResourceIdentifier('ICU4XLocaleExpander_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XLocaleExpander_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XLocaleExpander_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XLocaleExpander_create') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocaleExpander_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XLocaleExpander_create( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XLocaleExpander_create_extended') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocaleExpander_create_extended') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XLocaleExpander_create_extended( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XLocaleExpander_maximize') +@ffi.Native< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocaleExpander_maximize') +// ignore: non_constant_identifier_names +external int _ICU4XLocaleExpander_maximize( + ffi.Pointer self, ffi.Pointer locale); + +@meta.ResourceIdentifier('ICU4XLocaleExpander_minimize') +@ffi.Native< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocaleExpander_minimize') +// ignore: non_constant_identifier_names +external int _ICU4XLocaleExpander_minimize( + ffi.Pointer self, ffi.Pointer locale); + +@meta.ResourceIdentifier('ICU4XLocaleExpander_minimize_favor_script') +@ffi.Native< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocaleExpander_minimize_favor_script') +// ignore: non_constant_identifier_names +external int _ICU4XLocaleExpander_minimize_favor_script( + ffi.Pointer self, ffi.Pointer locale); diff --git a/pkgs/intl4x/lib/src/bindings/LocaleFallbackConfig.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleFallbackConfig.g.dart deleted file mode 120000 index 6a57b6e3..00000000 --- a/pkgs/intl4x/lib/src/bindings/LocaleFallbackConfig.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LocaleFallbackConfig.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LocaleFallbackConfig.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleFallbackConfig.g.dart new file mode 100644 index 00000000..ff2d81c7 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LocaleFallbackConfig.g.dart @@ -0,0 +1,73 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +final class _LocaleFallbackConfigFfi extends ffi.Struct { + @ffi.Int32() + external int priority; + external _SliceUtf8 extensionKey; + @ffi.Int32() + external int fallbackSupplement; +} + +/// Collection of configurations for the ICU4X fallback algorithm. +/// +/// See the [Rust documentation for `LocaleFallbackConfig`](https://docs.rs/icu/latest/icu/locid_transform/fallback/struct.LocaleFallbackConfig.html) for more information. +final class LocaleFallbackConfig { + LocaleFallbackPriority priority; + String extensionKey; + LocaleFallbackSupplement fallbackSupplement; + + LocaleFallbackConfig( + {required this.priority, + required this.extensionKey, + required this.fallbackSupplement}); + + // ignore: unused_element + LocaleFallbackConfig._fromFfi( + _LocaleFallbackConfigFfi ffi, core.List aEdges) + : priority = LocaleFallbackPriority.values[ffi.priority], + extensionKey = ffi.extensionKey._toDart(aEdges), + fallbackSupplement = + LocaleFallbackSupplement.values[ffi.fallbackSupplement]; + + // If this struct contains any slices, their lifetime-edge-relevant objects (typically _FinalizedArenas) will only + // be constructed here, and can be appended to any relevant lifetime arrays here. AppendArray accepts a list + // of arrays for each lifetime to do so. It accepts multiple lists per lifetime in case the caller needs to tie a lifetime to multiple + // output arrays. Null is equivalent to an empty list: this lifetime is not being borrowed from. + // ignore: unused_element + _LocaleFallbackConfigFfi _toFfi(ffi.Allocator temp, + {core.List> aAppendArray = const []}) { + final struct = ffi.Struct.create<_LocaleFallbackConfigFfi>(); + struct.priority = priority.index; + final extensionKeyView = extensionKey.utf8View; + struct.extensionKey._length = extensionKeyView.length; + struct.extensionKey._data = extensionKeyView.allocIn(aAppendArray.isNotEmpty + ? _FinalizedArena.withLifetime(aAppendArray).arena + : temp); + struct.fallbackSupplement = fallbackSupplement.index; + return struct; + } + + @override + bool operator ==(Object other) => + other is LocaleFallbackConfig && + other.priority == priority && + other.extensionKey == extensionKey && + other.fallbackSupplement == fallbackSupplement; + + @override + int get hashCode => Object.hashAll([ + priority, + extensionKey, + fallbackSupplement, + ]); + + // Return all fields corresponding to lifetime `'a` + // without handling lifetime dependencies (this is the job of the caller) + // This is all fields that may be borrowed from if borrowing `'a`, + // assuming that there are no `'other: a`. bounds. In case of such bounds, + // the caller should take care to also call _fieldsForLifetimeOther + // ignore: unused_element + core.List get _fieldsForLifetimeA => [extensionKey]; +} diff --git a/pkgs/intl4x/lib/src/bindings/LocaleFallbackIterator.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleFallbackIterator.g.dart deleted file mode 120000 index d86e7334..00000000 --- a/pkgs/intl4x/lib/src/bindings/LocaleFallbackIterator.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LocaleFallbackIterator.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LocaleFallbackIterator.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleFallbackIterator.g.dart new file mode 100644 index 00000000..91aa763a --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LocaleFallbackIterator.g.dart @@ -0,0 +1,59 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An iterator over the locale under fallback. +/// +/// See the [Rust documentation for `LocaleFallbackIterator`](https://docs.rs/icu/latest/icu/locid_transform/fallback/struct.LocaleFallbackIterator.html) for more information. +final class LocaleFallbackIterator + implements ffi.Finalizable, core.Iterator { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _aEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + LocaleFallbackIterator._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XLocaleFallbackIterator_destroy)); + + Locale? _current; + + Locale get current => _current!; + + bool moveNext() { + _current = _iteratorNext(); + return _current != null; + } + + /// A combination of `get` and `step`. Returns the value that `get` would return + /// and advances the iterator until hitting `und`. + Locale? _iteratorNext() { + final result = _ICU4XLocaleFallbackIterator_next(_ffi); + return result.address == 0 ? null : Locale._fromFfi(result, []); + } +} + +@meta.ResourceIdentifier('ICU4XLocaleFallbackIterator_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XLocaleFallbackIterator_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XLocaleFallbackIterator_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XLocaleFallbackIterator_next') +@ffi.Native Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocaleFallbackIterator_next') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XLocaleFallbackIterator_next( + ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/LocaleFallbackPriority.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleFallbackPriority.g.dart deleted file mode 120000 index ea7c34ea..00000000 --- a/pkgs/intl4x/lib/src/bindings/LocaleFallbackPriority.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LocaleFallbackPriority.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LocaleFallbackPriority.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleFallbackPriority.g.dart new file mode 100644 index 00000000..16037422 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LocaleFallbackPriority.g.dart @@ -0,0 +1,14 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// Priority mode for the ICU4X fallback algorithm. +/// +/// See the [Rust documentation for `LocaleFallbackPriority`](https://docs.rs/icu/latest/icu/locid_transform/fallback/enum.LocaleFallbackPriority.html) for more information. +enum LocaleFallbackPriority { + language, + + region, + + collation; +} diff --git a/pkgs/intl4x/lib/src/bindings/LocaleFallbackSupplement.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleFallbackSupplement.g.dart deleted file mode 120000 index 888daff8..00000000 --- a/pkgs/intl4x/lib/src/bindings/LocaleFallbackSupplement.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LocaleFallbackSupplement.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LocaleFallbackSupplement.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleFallbackSupplement.g.dart new file mode 100644 index 00000000..b74d815a --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LocaleFallbackSupplement.g.dart @@ -0,0 +1,12 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// What additional data is required to load when performing fallback. +/// +/// See the [Rust documentation for `LocaleFallbackSupplement`](https://docs.rs/icu/latest/icu/locid_transform/fallback/enum.LocaleFallbackSupplement.html) for more information. +enum LocaleFallbackSupplement { + none, + + collation; +} diff --git a/pkgs/intl4x/lib/src/bindings/LocaleFallbacker.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleFallbacker.g.dart deleted file mode 120000 index 4e1cbd3f..00000000 --- a/pkgs/intl4x/lib/src/bindings/LocaleFallbacker.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LocaleFallbacker.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LocaleFallbacker.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleFallbacker.g.dart new file mode 100644 index 00000000..7fc24d61 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LocaleFallbacker.g.dart @@ -0,0 +1,93 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An object that runs the ICU4X locale fallback algorithm. +/// +/// See the [Rust documentation for `LocaleFallbacker`](https://docs.rs/icu/latest/icu/locid_transform/fallback/struct.LocaleFallbacker.html) for more information. +final class LocaleFallbacker implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + LocaleFallbacker._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XLocaleFallbacker_destroy)); + + /// Creates a new `LocaleFallbacker` from a data provider. + /// + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/locid_transform/fallback/struct.LocaleFallbacker.html#method.new) for more information. + /// + /// Throws [Error] on failure. + factory LocaleFallbacker(DataProvider provider) { + final result = _ICU4XLocaleFallbacker_create(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return LocaleFallbacker._fromFfi(result.union.ok, []); + } + + /// Creates a new `LocaleFallbacker` without data for limited functionality. + /// + /// See the [Rust documentation for `new_without_data`](https://docs.rs/icu/latest/icu/locid_transform/fallback/struct.LocaleFallbacker.html#method.new_without_data) for more information. + factory LocaleFallbacker.withoutData() { + final result = _ICU4XLocaleFallbacker_create_without_data(); + return LocaleFallbacker._fromFfi(result, []); + } + + /// Associates this `LocaleFallbacker` with configuration options. + /// + /// See the [Rust documentation for `for_config`](https://docs.rs/icu/latest/icu/locid_transform/fallback/struct.LocaleFallbacker.html#method.for_config) for more information. + /// + /// Throws [Error] on failure. + LocaleFallbackerWithConfig forConfig(LocaleFallbackConfig config) { + final temp = ffi2.Arena(); + // This lifetime edge depends on lifetimes: 'a + core.List aEdges = [this]; + final result = _ICU4XLocaleFallbacker_for_config(_ffi, config._toFfi(temp)); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return LocaleFallbackerWithConfig._fromFfi(result.union.ok, [], aEdges); + } +} + +@meta.ResourceIdentifier('ICU4XLocaleFallbacker_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XLocaleFallbacker_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XLocaleFallbacker_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XLocaleFallbacker_create') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocaleFallbacker_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XLocaleFallbacker_create( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XLocaleFallbacker_create_without_data') +@ffi.Native Function()>( + isLeaf: true, symbol: 'ICU4XLocaleFallbacker_create_without_data') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XLocaleFallbacker_create_without_data(); + +@meta.ResourceIdentifier('ICU4XLocaleFallbacker_for_config') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, _LocaleFallbackConfigFfi)>( + isLeaf: true, symbol: 'ICU4XLocaleFallbacker_for_config') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XLocaleFallbacker_for_config( + ffi.Pointer self, _LocaleFallbackConfigFfi config); diff --git a/pkgs/intl4x/lib/src/bindings/LocaleFallbackerWithConfig.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleFallbackerWithConfig.g.dart deleted file mode 120000 index 57fb23fc..00000000 --- a/pkgs/intl4x/lib/src/bindings/LocaleFallbackerWithConfig.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/LocaleFallbackerWithConfig.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/LocaleFallbackerWithConfig.g.dart b/pkgs/intl4x/lib/src/bindings/LocaleFallbackerWithConfig.g.dart new file mode 100644 index 00000000..b84a7a1e --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/LocaleFallbackerWithConfig.g.dart @@ -0,0 +1,59 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An object that runs the ICU4X locale fallback algorithm with specific configurations. +/// +/// See the [Rust documentation for `LocaleFallbacker`](https://docs.rs/icu/latest/icu/locid_transform/fallback/struct.LocaleFallbacker.html) for more information. +/// +/// See the [Rust documentation for `LocaleFallbackerWithConfig`](https://docs.rs/icu/latest/icu/locid_transform/fallback/struct.LocaleFallbackerWithConfig.html) for more information. +final class LocaleFallbackerWithConfig implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _aEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + LocaleFallbackerWithConfig._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XLocaleFallbackerWithConfig_destroy)); + + /// Creates an iterator from a locale with each step of fallback. + /// + /// See the [Rust documentation for `fallback_for`](https://docs.rs/icu/latest/icu/locid_transform/fallback/struct.LocaleFallbacker.html#method.fallback_for) for more information. + LocaleFallbackIterator fallbackForLocale(Locale locale) { + // This lifetime edge depends on lifetimes: 'a, 'b + core.List aEdges = [this]; + final result = + _ICU4XLocaleFallbackerWithConfig_fallback_for_locale(_ffi, locale._ffi); + return LocaleFallbackIterator._fromFfi(result, [], aEdges); + } +} + +@meta.ResourceIdentifier('ICU4XLocaleFallbackerWithConfig_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XLocaleFallbackerWithConfig_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XLocaleFallbackerWithConfig_destroy( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XLocaleFallbackerWithConfig_fallback_for_locale') +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XLocaleFallbackerWithConfig_fallback_for_locale') +// ignore: non_constant_identifier_names +external ffi.Pointer + _ICU4XLocaleFallbackerWithConfig_fallback_for_locale( + ffi.Pointer self, ffi.Pointer locale); diff --git a/pkgs/intl4x/lib/src/bindings/Logger.g.dart b/pkgs/intl4x/lib/src/bindings/Logger.g.dart deleted file mode 120000 index a02d0fec..00000000 --- a/pkgs/intl4x/lib/src/bindings/Logger.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/Logger.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/Logger.g.dart b/pkgs/intl4x/lib/src/bindings/Logger.g.dart new file mode 100644 index 00000000..93a94aa3 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/Logger.g.dart @@ -0,0 +1,59 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An object allowing control over the logging used +final class Logger implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + Logger._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XLogger_destroy)); + + /// Initialize the logger using `simple_logger` + /// + /// Requires the `simple_logger` Cargo feature. + /// + /// Returns `false` if there was already a logger set. + static bool initSimpleLogger() { + final result = _ICU4XLogger_init_simple_logger(); + return result; + } + + /// Deprecated: since ICU4X 1.4, this now happens automatically if the `log` feature is enabled. + static bool initConsoleLogger() { + final result = _ICU4XLogger_init_console_logger(); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XLogger_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XLogger_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XLogger_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XLogger_init_simple_logger') +@ffi.Native( + isLeaf: true, symbol: 'ICU4XLogger_init_simple_logger') +// ignore: non_constant_identifier_names +external bool _ICU4XLogger_init_simple_logger(); + +@meta.ResourceIdentifier('ICU4XLogger_init_console_logger') +@ffi.Native( + isLeaf: true, symbol: 'ICU4XLogger_init_console_logger') +// ignore: non_constant_identifier_names +external bool _ICU4XLogger_init_console_logger(); diff --git a/pkgs/intl4x/lib/src/bindings/MetazoneCalculator.g.dart b/pkgs/intl4x/lib/src/bindings/MetazoneCalculator.g.dart deleted file mode 120000 index d9c169ad..00000000 --- a/pkgs/intl4x/lib/src/bindings/MetazoneCalculator.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/MetazoneCalculator.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/MetazoneCalculator.g.dart b/pkgs/intl4x/lib/src/bindings/MetazoneCalculator.g.dart new file mode 100644 index 00000000..00bd4436 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/MetazoneCalculator.g.dart @@ -0,0 +1,55 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An object capable of computing the metazone from a timezone. +/// +/// This can be used via `maybe_calculate_metazone()` on [`CustomTimeZone`]. +/// +/// [`CustomTimeZone`]: crate::timezone::ffi::ICU4XCustomTimeZone +/// +/// See the [Rust documentation for `MetazoneCalculator`](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneCalculator.html) for more information. +final class MetazoneCalculator implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + MetazoneCalculator._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XMetazoneCalculator_destroy)); + + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneCalculator.html#method.new) for more information. + /// + /// Throws [Error] on failure. + factory MetazoneCalculator(DataProvider provider) { + final result = _ICU4XMetazoneCalculator_create(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return MetazoneCalculator._fromFfi(result.union.ok, []); + } +} + +@meta.ResourceIdentifier('ICU4XMetazoneCalculator_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XMetazoneCalculator_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XMetazoneCalculator_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XMetazoneCalculator_create') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XMetazoneCalculator_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XMetazoneCalculator_create( + ffi.Pointer provider); diff --git a/pkgs/intl4x/lib/src/bindings/PluralCategories.g.dart b/pkgs/intl4x/lib/src/bindings/PluralCategories.g.dart deleted file mode 120000 index b5a59383..00000000 --- a/pkgs/intl4x/lib/src/bindings/PluralCategories.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/PluralCategories.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/PluralCategories.g.dart b/pkgs/intl4x/lib/src/bindings/PluralCategories.g.dart new file mode 100644 index 00000000..7400f81c --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/PluralCategories.g.dart @@ -0,0 +1,73 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +final class _PluralCategoriesFfi extends ffi.Struct { + @ffi.Bool() + external bool zero; + @ffi.Bool() + external bool one; + @ffi.Bool() + external bool two; + @ffi.Bool() + external bool few; + @ffi.Bool() + external bool many; + @ffi.Bool() + external bool other; +} + +final class PluralCategories { + final bool zero; + final bool one; + final bool two; + final bool few; + final bool many; + final bool other; + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + PluralCategories._fromFfi(_PluralCategoriesFfi ffi) + : zero = ffi.zero, + one = ffi.one, + two = ffi.two, + few = ffi.few, + many = ffi.many, + other = ffi.other; + + // ignore: unused_element + _PluralCategoriesFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_PluralCategoriesFfi>(); + struct.zero = zero; + struct.one = one; + struct.two = two; + struct.few = few; + struct.many = many; + struct.other = other; + return struct; + } + + @override + bool operator ==(Object other) => + other is PluralCategories && + other.zero == zero && + other.one == one && + other.two == two && + other.few == few && + other.many == many && + other.other == this.other; + + @override + int get hashCode => Object.hashAll([ + zero, + one, + two, + few, + many, + other, + ]); +} diff --git a/pkgs/intl4x/lib/src/bindings/PluralCategory.g.dart b/pkgs/intl4x/lib/src/bindings/PluralCategory.g.dart deleted file mode 120000 index 0a1afc4d..00000000 --- a/pkgs/intl4x/lib/src/bindings/PluralCategory.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/PluralCategory.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/PluralCategory.g.dart b/pkgs/intl4x/lib/src/bindings/PluralCategory.g.dart new file mode 100644 index 00000000..d26000c4 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/PluralCategory.g.dart @@ -0,0 +1,43 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `PluralCategory`](https://docs.rs/icu/latest/icu/plurals/enum.PluralCategory.html) for more information. +enum PluralCategory { + zero, + + one, + + two, + + few, + + many, + + other; + + /// Construct from a string in the format + /// [specified in TR35](https://unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rules) + /// + /// See the [Rust documentation for `get_for_cldr_string`](https://docs.rs/icu/latest/icu/plurals/enum.PluralCategory.html#method.get_for_cldr_string) for more information. + /// + /// See the [Rust documentation for `get_for_cldr_bytes`](https://docs.rs/icu/latest/icu/plurals/enum.PluralCategory.html#method.get_for_cldr_bytes) for more information. + static PluralCategory? getForCldrString(String s) { + final temp = ffi2.Arena(); + final sView = s.utf8View; + final result = _ICU4XPluralCategory_get_for_cldr_string( + sView.allocIn(temp), sView.length); + temp.releaseAll(); + if (!result.isOk) { + return null; + } + return PluralCategory.values[result.union.ok]; + } +} + +@meta.ResourceIdentifier('ICU4XPluralCategory_get_for_cldr_string') +@ffi.Native<_ResultInt32Void Function(ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XPluralCategory_get_for_cldr_string') +// ignore: non_constant_identifier_names +external _ResultInt32Void _ICU4XPluralCategory_get_for_cldr_string( + ffi.Pointer sData, int sLength); diff --git a/pkgs/intl4x/lib/src/bindings/PluralOperands.g.dart b/pkgs/intl4x/lib/src/bindings/PluralOperands.g.dart deleted file mode 120000 index c79c2de4..00000000 --- a/pkgs/intl4x/lib/src/bindings/PluralOperands.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/PluralOperands.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/PluralOperands.g.dart b/pkgs/intl4x/lib/src/bindings/PluralOperands.g.dart new file mode 100644 index 00000000..a660de27 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/PluralOperands.g.dart @@ -0,0 +1,70 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `PluralOperands`](https://docs.rs/icu/latest/icu/plurals/struct.PluralOperands.html) for more information. +final class PluralOperands implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + PluralOperands._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XPluralOperands_destroy)); + + /// Construct for a given string representing a number + /// + /// See the [Rust documentation for `from_str`](https://docs.rs/icu/latest/icu/plurals/struct.PluralOperands.html#method.from_str) for more information. + /// + /// Throws [Error] on failure. + factory PluralOperands.fromString(String s) { + final temp = ffi2.Arena(); + final sView = s.utf8View; + final result = _ICU4XPluralOperands_create_from_string( + sView.allocIn(temp), sView.length); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return PluralOperands._fromFfi(result.union.ok, []); + } + + /// Construct from a FixedDecimal + /// + /// Retains at most 18 digits each from the integer and fraction parts. + factory PluralOperands.fromFixedDecimal(FixedDecimal x) { + final result = _ICU4XPluralOperands_create_from_fixed_decimal(x._ffi); + return PluralOperands._fromFfi(result, []); + } +} + +@meta.ResourceIdentifier('ICU4XPluralOperands_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XPluralOperands_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XPluralOperands_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XPluralOperands_create_from_string') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XPluralOperands_create_from_string') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XPluralOperands_create_from_string( + ffi.Pointer sData, int sLength); + +@meta.ResourceIdentifier('ICU4XPluralOperands_create_from_fixed_decimal') +@ffi.Native Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XPluralOperands_create_from_fixed_decimal') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XPluralOperands_create_from_fixed_decimal( + ffi.Pointer x); diff --git a/pkgs/intl4x/lib/src/bindings/PluralRules.g.dart b/pkgs/intl4x/lib/src/bindings/PluralRules.g.dart deleted file mode 120000 index c6c27b5c..00000000 --- a/pkgs/intl4x/lib/src/bindings/PluralRules.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/PluralRules.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/PluralRules.g.dart b/pkgs/intl4x/lib/src/bindings/PluralRules.g.dart new file mode 100644 index 00000000..af7d39a7 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/PluralRules.g.dart @@ -0,0 +1,107 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `PluralRules`](https://docs.rs/icu/latest/icu/plurals/struct.PluralRules.html) for more information. +final class PluralRules implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + PluralRules._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XPluralRules_destroy)); + + /// Construct an [`PluralRules`] for the given locale, for cardinal numbers + /// + /// See the [Rust documentation for `try_new_cardinal`](https://docs.rs/icu/latest/icu/plurals/struct.PluralRules.html#method.try_new_cardinal) for more information. + /// + /// Throws [Error] on failure. + factory PluralRules.cardinal(DataProvider provider, Locale locale) { + final result = + _ICU4XPluralRules_create_cardinal(provider._ffi, locale._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return PluralRules._fromFfi(result.union.ok, []); + } + + /// Construct an [`PluralRules`] for the given locale, for ordinal numbers + /// + /// See the [Rust documentation for `try_new_ordinal`](https://docs.rs/icu/latest/icu/plurals/struct.PluralRules.html#method.try_new_ordinal) for more information. + /// + /// Throws [Error] on failure. + factory PluralRules.ordinal(DataProvider provider, Locale locale) { + final result = _ICU4XPluralRules_create_ordinal(provider._ffi, locale._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return PluralRules._fromFfi(result.union.ok, []); + } + + /// Get the category for a given number represented as operands + /// + /// See the [Rust documentation for `category_for`](https://docs.rs/icu/latest/icu/plurals/struct.PluralRules.html#method.category_for) for more information. + PluralCategory categoryFor(PluralOperands op) { + final result = _ICU4XPluralRules_category_for(_ffi, op._ffi); + return PluralCategory.values[result]; + } + + /// Get all of the categories needed in the current locale + /// + /// See the [Rust documentation for `categories`](https://docs.rs/icu/latest/icu/plurals/struct.PluralRules.html#method.categories) for more information. + PluralCategories get categories { + final result = _ICU4XPluralRules_categories(_ffi); + return PluralCategories._fromFfi(result); + } +} + +@meta.ResourceIdentifier('ICU4XPluralRules_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XPluralRules_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XPluralRules_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XPluralRules_create_cardinal') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XPluralRules_create_cardinal') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XPluralRules_create_cardinal( + ffi.Pointer provider, ffi.Pointer locale); + +@meta.ResourceIdentifier('ICU4XPluralRules_create_ordinal') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XPluralRules_create_ordinal') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XPluralRules_create_ordinal( + ffi.Pointer provider, ffi.Pointer locale); + +@meta.ResourceIdentifier('ICU4XPluralRules_category_for') +@ffi.Native< + ffi.Int32 Function(ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XPluralRules_category_for') +// ignore: non_constant_identifier_names +external int _ICU4XPluralRules_category_for( + ffi.Pointer self, ffi.Pointer op); + +@meta.ResourceIdentifier('ICU4XPluralRules_categories') +@ffi.Native<_PluralCategoriesFfi Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XPluralRules_categories') +// ignore: non_constant_identifier_names +external _PluralCategoriesFfi _ICU4XPluralRules_categories( + ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/PropertyValueNameToEnumMapper.g.dart b/pkgs/intl4x/lib/src/bindings/PropertyValueNameToEnumMapper.g.dart deleted file mode 120000 index 12ccea21..00000000 --- a/pkgs/intl4x/lib/src/bindings/PropertyValueNameToEnumMapper.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/PropertyValueNameToEnumMapper.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/PropertyValueNameToEnumMapper.g.dart b/pkgs/intl4x/lib/src/bindings/PropertyValueNameToEnumMapper.g.dart new file mode 100644 index 00000000..ed2786f7 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/PropertyValueNameToEnumMapper.g.dart @@ -0,0 +1,276 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// A type capable of looking up a property value from a string name. +/// +/// See the [Rust documentation for `PropertyValueNameToEnumMapper`](https://docs.rs/icu/latest/icu/properties/names/struct.PropertyValueNameToEnumMapper.html) for more information. +/// +/// See the [Rust documentation for `PropertyValueNameToEnumMapperBorrowed`](https://docs.rs/icu/latest/icu/properties/names/struct.PropertyValueNameToEnumMapperBorrowed.html) for more information. +final class PropertyValueNameToEnumMapper implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + PropertyValueNameToEnumMapper._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XPropertyValueNameToEnumMapper_destroy)); + + /// Get the property value matching the given name, using strict matching + /// + /// Returns -1 if the name is unknown for this property + /// + /// See the [Rust documentation for `get_strict`](https://docs.rs/icu/latest/icu/properties/names/struct.PropertyValueNameToEnumMapperBorrowed.html#method.get_strict) for more information. + int getStrict(String name) { + final temp = ffi2.Arena(); + final nameView = name.utf8View; + final result = _ICU4XPropertyValueNameToEnumMapper_get_strict( + _ffi, nameView.allocIn(temp), nameView.length); + temp.releaseAll(); + return result; + } + + /// Get the property value matching the given name, using loose matching + /// + /// Returns -1 if the name is unknown for this property + /// + /// See the [Rust documentation for `get_loose`](https://docs.rs/icu/latest/icu/properties/names/struct.PropertyValueNameToEnumMapperBorrowed.html#method.get_loose) for more information. + int getLoose(String name) { + final temp = ffi2.Arena(); + final nameView = name.utf8View; + final result = _ICU4XPropertyValueNameToEnumMapper_get_loose( + _ffi, nameView.allocIn(temp), nameView.length); + temp.releaseAll(); + return result; + } + + /// See the [Rust documentation for `get_name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.GeneralCategory.html#method.get_name_to_enum_mapper) for more information. + /// + /// Throws [Error] on failure. + factory PropertyValueNameToEnumMapper.generalCategory(DataProvider provider) { + final result = _ICU4XPropertyValueNameToEnumMapper_load_general_category( + provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return PropertyValueNameToEnumMapper._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.BidiClass.html#method.name_to_enum_mapper) for more information. + /// + /// Throws [Error] on failure. + factory PropertyValueNameToEnumMapper.bidiClass(DataProvider provider) { + final result = + _ICU4XPropertyValueNameToEnumMapper_load_bidi_class(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return PropertyValueNameToEnumMapper._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.EastAsianWidth.html#method.name_to_enum_mapper) for more information. + /// + /// Throws [Error] on failure. + factory PropertyValueNameToEnumMapper.eastAsianWidth(DataProvider provider) { + final result = _ICU4XPropertyValueNameToEnumMapper_load_east_asian_width( + provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return PropertyValueNameToEnumMapper._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.IndicSyllabicCategory.html#method.name_to_enum_mapper) for more information. + /// + /// Throws [Error] on failure. + factory PropertyValueNameToEnumMapper.indicSyllabicCategory( + DataProvider provider) { + final result = + _ICU4XPropertyValueNameToEnumMapper_load_indic_syllabic_category( + provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return PropertyValueNameToEnumMapper._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.LineBreak.html#method.name_to_enum_mapper) for more information. + /// + /// Throws [Error] on failure. + factory PropertyValueNameToEnumMapper.lineBreak(DataProvider provider) { + final result = + _ICU4XPropertyValueNameToEnumMapper_load_line_break(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return PropertyValueNameToEnumMapper._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `get_name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.GraphemeClusterBreak.html#method.get_name_to_enum_mapper) for more information. + /// + /// Throws [Error] on failure. + factory PropertyValueNameToEnumMapper.graphemeClusterBreak( + DataProvider provider) { + final result = + _ICU4XPropertyValueNameToEnumMapper_load_grapheme_cluster_break( + provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return PropertyValueNameToEnumMapper._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.WordBreak.html#method.name_to_enum_mapper) for more information. + /// + /// Throws [Error] on failure. + factory PropertyValueNameToEnumMapper.wordBreak(DataProvider provider) { + final result = + _ICU4XPropertyValueNameToEnumMapper_load_word_break(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return PropertyValueNameToEnumMapper._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.SentenceBreak.html#method.name_to_enum_mapper) for more information. + /// + /// Throws [Error] on failure. + factory PropertyValueNameToEnumMapper.sentenceBreak(DataProvider provider) { + final result = + _ICU4XPropertyValueNameToEnumMapper_load_sentence_break(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return PropertyValueNameToEnumMapper._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.Script.html#method.name_to_enum_mapper) for more information. + /// + /// Throws [Error] on failure. + factory PropertyValueNameToEnumMapper.script(DataProvider provider) { + final result = + _ICU4XPropertyValueNameToEnumMapper_load_script(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return PropertyValueNameToEnumMapper._fromFfi(result.union.ok, []); + } +} + +@meta.ResourceIdentifier('ICU4XPropertyValueNameToEnumMapper_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XPropertyValueNameToEnumMapper_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XPropertyValueNameToEnumMapper_destroy( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XPropertyValueNameToEnumMapper_get_strict') +@ffi.Native< + ffi.Int16 Function( + ffi.Pointer, ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XPropertyValueNameToEnumMapper_get_strict') +// ignore: non_constant_identifier_names +external int _ICU4XPropertyValueNameToEnumMapper_get_strict( + ffi.Pointer self, + ffi.Pointer nameData, + int nameLength); + +@meta.ResourceIdentifier('ICU4XPropertyValueNameToEnumMapper_get_loose') +@ffi.Native< + ffi.Int16 Function( + ffi.Pointer, ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XPropertyValueNameToEnumMapper_get_loose') +// ignore: non_constant_identifier_names +external int _ICU4XPropertyValueNameToEnumMapper_get_loose( + ffi.Pointer self, + ffi.Pointer nameData, + int nameLength); + +@meta.ResourceIdentifier( + 'ICU4XPropertyValueNameToEnumMapper_load_general_category') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, + symbol: 'ICU4XPropertyValueNameToEnumMapper_load_general_category') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XPropertyValueNameToEnumMapper_load_general_category( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XPropertyValueNameToEnumMapper_load_bidi_class') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XPropertyValueNameToEnumMapper_load_bidi_class') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XPropertyValueNameToEnumMapper_load_bidi_class( + ffi.Pointer provider); + +@meta.ResourceIdentifier( + 'ICU4XPropertyValueNameToEnumMapper_load_east_asian_width') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, + symbol: 'ICU4XPropertyValueNameToEnumMapper_load_east_asian_width') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XPropertyValueNameToEnumMapper_load_east_asian_width( + ffi.Pointer provider); + +@meta.ResourceIdentifier( + 'ICU4XPropertyValueNameToEnumMapper_load_indic_syllabic_category') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, + symbol: 'ICU4XPropertyValueNameToEnumMapper_load_indic_syllabic_category') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XPropertyValueNameToEnumMapper_load_indic_syllabic_category( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XPropertyValueNameToEnumMapper_load_line_break') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XPropertyValueNameToEnumMapper_load_line_break') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XPropertyValueNameToEnumMapper_load_line_break( + ffi.Pointer provider); + +@meta.ResourceIdentifier( + 'ICU4XPropertyValueNameToEnumMapper_load_grapheme_cluster_break') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, + symbol: 'ICU4XPropertyValueNameToEnumMapper_load_grapheme_cluster_break') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XPropertyValueNameToEnumMapper_load_grapheme_cluster_break( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XPropertyValueNameToEnumMapper_load_word_break') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XPropertyValueNameToEnumMapper_load_word_break') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XPropertyValueNameToEnumMapper_load_word_break( + ffi.Pointer provider); + +@meta.ResourceIdentifier( + 'ICU4XPropertyValueNameToEnumMapper_load_sentence_break') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, + symbol: 'ICU4XPropertyValueNameToEnumMapper_load_sentence_break') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XPropertyValueNameToEnumMapper_load_sentence_break( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XPropertyValueNameToEnumMapper_load_script') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XPropertyValueNameToEnumMapper_load_script') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XPropertyValueNameToEnumMapper_load_script( + ffi.Pointer provider); diff --git a/pkgs/intl4x/lib/src/bindings/RegionDisplayNames.g.dart b/pkgs/intl4x/lib/src/bindings/RegionDisplayNames.g.dart deleted file mode 120000 index b672f8ca..00000000 --- a/pkgs/intl4x/lib/src/bindings/RegionDisplayNames.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/RegionDisplayNames.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/RegionDisplayNames.g.dart b/pkgs/intl4x/lib/src/bindings/RegionDisplayNames.g.dart new file mode 100644 index 00000000..56112b82 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/RegionDisplayNames.g.dart @@ -0,0 +1,85 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `RegionDisplayNames`](https://docs.rs/icu/latest/icu/displaynames/struct.RegionDisplayNames.html) for more information. +final class RegionDisplayNames implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + RegionDisplayNames._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XRegionDisplayNames_destroy)); + + /// Creates a new `RegionDisplayNames` from locale data and an options bag. + /// + /// See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/displaynames/struct.RegionDisplayNames.html#method.try_new) for more information. + /// + /// Throws [Error] on failure. + factory RegionDisplayNames(DataProvider provider, Locale locale) { + final result = _ICU4XRegionDisplayNames_create(provider._ffi, locale._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return RegionDisplayNames._fromFfi(result.union.ok, []); + } + + /// Returns the locale specific display name of a region. + /// Note that the function returns an empty string in case the display name for a given + /// region code is not found. + /// + /// See the [Rust documentation for `of`](https://docs.rs/icu/latest/icu/displaynames/struct.RegionDisplayNames.html#method.of) for more information. + /// + /// Throws [Error] on failure. + String of(String region) { + final temp = ffi2.Arena(); + final regionView = region.utf8View; + final writeable = _Writeable(); + final result = _ICU4XRegionDisplayNames_of( + _ffi, regionView.allocIn(temp), regionView.length, writeable._ffi); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } +} + +@meta.ResourceIdentifier('ICU4XRegionDisplayNames_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XRegionDisplayNames_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XRegionDisplayNames_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XRegionDisplayNames_create') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XRegionDisplayNames_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XRegionDisplayNames_create( + ffi.Pointer provider, ffi.Pointer locale); + +@meta.ResourceIdentifier('ICU4XRegionDisplayNames_of') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Size, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XRegionDisplayNames_of') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XRegionDisplayNames_of( + ffi.Pointer self, + ffi.Pointer regionData, + int regionLength, + ffi.Pointer writeable); diff --git a/pkgs/intl4x/lib/src/bindings/ReorderedIndexMap.g.dart b/pkgs/intl4x/lib/src/bindings/ReorderedIndexMap.g.dart deleted file mode 120000 index 68b9d347..00000000 --- a/pkgs/intl4x/lib/src/bindings/ReorderedIndexMap.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/ReorderedIndexMap.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/ReorderedIndexMap.g.dart b/pkgs/intl4x/lib/src/bindings/ReorderedIndexMap.g.dart new file mode 100644 index 00000000..98de277f --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/ReorderedIndexMap.g.dart @@ -0,0 +1,89 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// Thin wrapper around a vector that maps visual indices to source indices +/// +/// `map[visualIndex] = sourceIndex` +/// +/// Produced by `reorder_visual()` on [`Bidi`]. +final class ReorderedIndexMap implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + ReorderedIndexMap._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XReorderedIndexMap_destroy)); + + /// Get this as a slice/array of indices + core.List get asSlice { + // This lifetime edge depends on lifetimes: 'a + core.List aEdges = [this]; + final result = _ICU4XReorderedIndexMap_as_slice(_ffi); + return result._toDart(aEdges); + } + + /// The length of this map + int get length { + final result = _ICU4XReorderedIndexMap_len(_ffi); + return result; + } + + /// Whether this map is empty + bool get isEmpty { + final result = _ICU4XReorderedIndexMap_is_empty(_ffi); + return result; + } + + /// Get element at `index`. Returns 0 when out of bounds + /// (note that 0 is also a valid in-bounds value, please use `len()` + /// to avoid out-of-bounds) + int operator [](int index) { + final result = _ICU4XReorderedIndexMap_get(_ffi, index); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XReorderedIndexMap_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XReorderedIndexMap_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XReorderedIndexMap_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XReorderedIndexMap_as_slice') +@ffi.Native<_SliceUsize Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XReorderedIndexMap_as_slice') +// ignore: non_constant_identifier_names +external _SliceUsize _ICU4XReorderedIndexMap_as_slice( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XReorderedIndexMap_len') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XReorderedIndexMap_len') +// ignore: non_constant_identifier_names +external int _ICU4XReorderedIndexMap_len(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XReorderedIndexMap_is_empty') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XReorderedIndexMap_is_empty') +// ignore: non_constant_identifier_names +external bool _ICU4XReorderedIndexMap_is_empty(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XReorderedIndexMap_get') +@ffi.Native, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XReorderedIndexMap_get') +// ignore: non_constant_identifier_names +external int _ICU4XReorderedIndexMap_get( + ffi.Pointer self, int index); diff --git a/pkgs/intl4x/lib/src/bindings/ResolvedCollatorOptions.g.dart b/pkgs/intl4x/lib/src/bindings/ResolvedCollatorOptions.g.dart deleted file mode 120000 index 214e3f44..00000000 --- a/pkgs/intl4x/lib/src/bindings/ResolvedCollatorOptions.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/ResolvedCollatorOptions.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/ResolvedCollatorOptions.g.dart b/pkgs/intl4x/lib/src/bindings/ResolvedCollatorOptions.g.dart new file mode 100644 index 00000000..78e2ee5e --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/ResolvedCollatorOptions.g.dart @@ -0,0 +1,83 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +final class _ResolvedCollatorOptionsFfi extends ffi.Struct { + @ffi.Int32() + external int strength; + @ffi.Int32() + external int alternateHandling; + @ffi.Int32() + external int caseFirst; + @ffi.Int32() + external int maxVariable; + @ffi.Int32() + external int caseLevel; + @ffi.Int32() + external int numeric; + @ffi.Int32() + external int backwardSecondLevel; +} + +/// See the [Rust documentation for `ResolvedCollatorOptions`](https://docs.rs/icu/latest/icu/collator/struct.ResolvedCollatorOptions.html) for more information. +final class ResolvedCollatorOptions { + final CollatorStrength strength; + final CollatorAlternateHandling alternateHandling; + final CollatorCaseFirst caseFirst; + final CollatorMaxVariable maxVariable; + final CollatorCaseLevel caseLevel; + final CollatorNumeric numeric; + final CollatorBackwardSecondLevel backwardSecondLevel; + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + ResolvedCollatorOptions._fromFfi(_ResolvedCollatorOptionsFfi ffi) + : strength = CollatorStrength.values[ffi.strength], + alternateHandling = + CollatorAlternateHandling.values[ffi.alternateHandling], + caseFirst = CollatorCaseFirst.values[ffi.caseFirst], + maxVariable = CollatorMaxVariable.values[ffi.maxVariable], + caseLevel = CollatorCaseLevel.values[ffi.caseLevel], + numeric = CollatorNumeric.values[ffi.numeric], + backwardSecondLevel = + CollatorBackwardSecondLevel.values[ffi.backwardSecondLevel]; + + // ignore: unused_element + _ResolvedCollatorOptionsFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_ResolvedCollatorOptionsFfi>(); + struct.strength = strength.index; + struct.alternateHandling = alternateHandling.index; + struct.caseFirst = caseFirst.index; + struct.maxVariable = maxVariable.index; + struct.caseLevel = caseLevel.index; + struct.numeric = numeric.index; + struct.backwardSecondLevel = backwardSecondLevel.index; + return struct; + } + + @override + bool operator ==(Object other) => + other is ResolvedCollatorOptions && + other.strength == strength && + other.alternateHandling == alternateHandling && + other.caseFirst == caseFirst && + other.maxVariable == maxVariable && + other.caseLevel == caseLevel && + other.numeric == numeric && + other.backwardSecondLevel == backwardSecondLevel; + + @override + int get hashCode => Object.hashAll([ + strength, + alternateHandling, + caseFirst, + maxVariable, + caseLevel, + numeric, + backwardSecondLevel, + ]); +} diff --git a/pkgs/intl4x/lib/src/bindings/RoundingIncrement.g.dart b/pkgs/intl4x/lib/src/bindings/RoundingIncrement.g.dart deleted file mode 120000 index eefaf89d..00000000 --- a/pkgs/intl4x/lib/src/bindings/RoundingIncrement.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/RoundingIncrement.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/RoundingIncrement.g.dart b/pkgs/intl4x/lib/src/bindings/RoundingIncrement.g.dart new file mode 100644 index 00000000..f52f8bf7 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/RoundingIncrement.g.dart @@ -0,0 +1,16 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// Increment used in a rounding operation. +/// +/// See the [Rust documentation for `RoundingIncrement`](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.RoundingIncrement.html) for more information. +enum RoundingIncrement { + multiplesOf1, + + multiplesOf2, + + multiplesOf5, + + multiplesOf25; +} diff --git a/pkgs/intl4x/lib/src/bindings/ScriptExtensionsSet.g.dart b/pkgs/intl4x/lib/src/bindings/ScriptExtensionsSet.g.dart deleted file mode 120000 index b2e59524..00000000 --- a/pkgs/intl4x/lib/src/bindings/ScriptExtensionsSet.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/ScriptExtensionsSet.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/ScriptExtensionsSet.g.dart b/pkgs/intl4x/lib/src/bindings/ScriptExtensionsSet.g.dart new file mode 100644 index 00000000..2324f088 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/ScriptExtensionsSet.g.dart @@ -0,0 +1,82 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An object that represents the Script_Extensions property for a single character +/// +/// See the [Rust documentation for `ScriptExtensionsSet`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html) for more information. +final class ScriptExtensionsSet implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _aEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + ScriptExtensionsSet._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XScriptExtensionsSet_destroy)); + + /// Check if the Script_Extensions property of the given code point covers the given script + /// + /// See the [Rust documentation for `contains`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html#method.contains) for more information. + bool contains(int script) { + final result = _ICU4XScriptExtensionsSet_contains(_ffi, script); + return result; + } + + /// Get the number of scripts contained in here + /// + /// See the [Rust documentation for `iter`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html#method.iter) for more information. + int get count { + final result = _ICU4XScriptExtensionsSet_count(_ffi); + return result; + } + + /// Get script at index + /// + /// See the [Rust documentation for `iter`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html#method.iter) for more information. + int? scriptAt(int index) { + final result = _ICU4XScriptExtensionsSet_script_at(_ffi, index); + if (!result.isOk) { + return null; + } + return result.union.ok; + } +} + +@meta.ResourceIdentifier('ICU4XScriptExtensionsSet_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XScriptExtensionsSet_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XScriptExtensionsSet_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XScriptExtensionsSet_contains') +@ffi.Native, ffi.Uint16)>( + isLeaf: true, symbol: 'ICU4XScriptExtensionsSet_contains') +// ignore: non_constant_identifier_names +external bool _ICU4XScriptExtensionsSet_contains( + ffi.Pointer self, int script); + +@meta.ResourceIdentifier('ICU4XScriptExtensionsSet_count') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XScriptExtensionsSet_count') +// ignore: non_constant_identifier_names +external int _ICU4XScriptExtensionsSet_count(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XScriptExtensionsSet_script_at') +@ffi.Native<_ResultUint16Void Function(ffi.Pointer, ffi.Size)>( + isLeaf: true, symbol: 'ICU4XScriptExtensionsSet_script_at') +// ignore: non_constant_identifier_names +external _ResultUint16Void _ICU4XScriptExtensionsSet_script_at( + ffi.Pointer self, int index); diff --git a/pkgs/intl4x/lib/src/bindings/ScriptWithExtensions.g.dart b/pkgs/intl4x/lib/src/bindings/ScriptWithExtensions.g.dart deleted file mode 120000 index 77e3a43d..00000000 --- a/pkgs/intl4x/lib/src/bindings/ScriptWithExtensions.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/ScriptWithExtensions.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/ScriptWithExtensions.g.dart b/pkgs/intl4x/lib/src/bindings/ScriptWithExtensions.g.dart new file mode 100644 index 00000000..16897afe --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/ScriptWithExtensions.g.dart @@ -0,0 +1,119 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X ScriptWithExtensions map object, capable of holding a map of codepoints to scriptextensions values +/// +/// See the [Rust documentation for `ScriptWithExtensions`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensions.html) for more information. +final class ScriptWithExtensions implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + ScriptWithExtensions._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XScriptWithExtensions_destroy)); + + /// See the [Rust documentation for `script_with_extensions`](https://docs.rs/icu/latest/icu/properties/script/fn.script_with_extensions.html) for more information. + /// + /// Throws [Error] on failure. + factory ScriptWithExtensions(DataProvider provider) { + final result = _ICU4XScriptWithExtensions_create(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return ScriptWithExtensions._fromFfi(result.union.ok, []); + } + + /// Get the Script property value for a code point + /// + /// See the [Rust documentation for `get_script_val`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.get_script_val) for more information. + int getScriptVal(int codePoint) { + final result = _ICU4XScriptWithExtensions_get_script_val(_ffi, codePoint); + return result; + } + + /// Check if the Script_Extensions property of the given code point covers the given script + /// + /// See the [Rust documentation for `has_script`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.has_script) for more information. + bool hasScript(int codePoint, int script) { + final result = + _ICU4XScriptWithExtensions_has_script(_ffi, codePoint, script); + return result; + } + + /// Borrow this object for a slightly faster variant with more operations + /// + /// See the [Rust documentation for `as_borrowed`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensions.html#method.as_borrowed) for more information. + ScriptWithExtensionsBorrowed get asBorrowed { + // This lifetime edge depends on lifetimes: 'a + core.List aEdges = [this]; + final result = _ICU4XScriptWithExtensions_as_borrowed(_ffi); + return ScriptWithExtensionsBorrowed._fromFfi(result, [], aEdges); + } + + /// Get a list of ranges of code points that contain this script in their Script_Extensions values + /// + /// See the [Rust documentation for `get_script_extensions_ranges`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.get_script_extensions_ranges) for more information. + CodePointRangeIterator iterRangesForScript(int script) { + // This lifetime edge depends on lifetimes: 'a + core.List aEdges = [this]; + final result = + _ICU4XScriptWithExtensions_iter_ranges_for_script(_ffi, script); + return CodePointRangeIterator._fromFfi(result, [], aEdges); + } +} + +@meta.ResourceIdentifier('ICU4XScriptWithExtensions_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XScriptWithExtensions_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XScriptWithExtensions_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XScriptWithExtensions_create') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XScriptWithExtensions_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XScriptWithExtensions_create( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XScriptWithExtensions_get_script_val') +@ffi.Native, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XScriptWithExtensions_get_script_val') +// ignore: non_constant_identifier_names +external int _ICU4XScriptWithExtensions_get_script_val( + ffi.Pointer self, int codePoint); + +@meta.ResourceIdentifier('ICU4XScriptWithExtensions_has_script') +@ffi.Native, ffi.Uint32, ffi.Uint16)>( + isLeaf: true, symbol: 'ICU4XScriptWithExtensions_has_script') +// ignore: non_constant_identifier_names +external bool _ICU4XScriptWithExtensions_has_script( + ffi.Pointer self, int codePoint, int script); + +@meta.ResourceIdentifier('ICU4XScriptWithExtensions_as_borrowed') +@ffi.Native Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XScriptWithExtensions_as_borrowed') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XScriptWithExtensions_as_borrowed( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XScriptWithExtensions_iter_ranges_for_script') +@ffi.Native< + ffi.Pointer Function(ffi.Pointer, ffi.Uint16)>( + isLeaf: true, symbol: 'ICU4XScriptWithExtensions_iter_ranges_for_script') +// ignore: non_constant_identifier_names +external ffi.Pointer + _ICU4XScriptWithExtensions_iter_ranges_for_script( + ffi.Pointer self, int script); diff --git a/pkgs/intl4x/lib/src/bindings/ScriptWithExtensionsBorrowed.g.dart b/pkgs/intl4x/lib/src/bindings/ScriptWithExtensionsBorrowed.g.dart deleted file mode 120000 index 50610ad3..00000000 --- a/pkgs/intl4x/lib/src/bindings/ScriptWithExtensionsBorrowed.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/ScriptWithExtensionsBorrowed.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/ScriptWithExtensionsBorrowed.g.dart b/pkgs/intl4x/lib/src/bindings/ScriptWithExtensionsBorrowed.g.dart new file mode 100644 index 00000000..ce206b6c --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/ScriptWithExtensionsBorrowed.g.dart @@ -0,0 +1,112 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// A slightly faster ICU4XScriptWithExtensions object +/// +/// See the [Rust documentation for `ScriptWithExtensionsBorrowed`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html) for more information. +final class ScriptWithExtensionsBorrowed implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _aEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + ScriptWithExtensionsBorrowed._fromFfi( + this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XScriptWithExtensionsBorrowed_destroy)); + + /// Get the Script property value for a code point + /// + /// See the [Rust documentation for `get_script_val`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.get_script_val) for more information. + int getScriptVal(int codePoint) { + final result = + _ICU4XScriptWithExtensionsBorrowed_get_script_val(_ffi, codePoint); + return result; + } + + /// Get the Script property value for a code point + /// + /// See the [Rust documentation for `get_script_extensions_val`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.get_script_extensions_val) for more information. + ScriptExtensionsSet getScriptExtensionsVal(int codePoint) { + // This lifetime edge depends on lifetimes: 'a + core.List aEdges = [this]; + final result = _ICU4XScriptWithExtensionsBorrowed_get_script_extensions_val( + _ffi, codePoint); + return ScriptExtensionsSet._fromFfi(result, [], aEdges); + } + + /// Check if the Script_Extensions property of the given code point covers the given script + /// + /// See the [Rust documentation for `has_script`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.has_script) for more information. + bool hasScript(int codePoint, int script) { + final result = + _ICU4XScriptWithExtensionsBorrowed_has_script(_ffi, codePoint, script); + return result; + } + + /// Build the CodePointSetData corresponding to a codepoints matching a particular script + /// in their Script_Extensions + /// + /// See the [Rust documentation for `get_script_extensions_set`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.get_script_extensions_set) for more information. + CodePointSetData getScriptExtensionsSet(int script) { + final result = _ICU4XScriptWithExtensionsBorrowed_get_script_extensions_set( + _ffi, script); + return CodePointSetData._fromFfi(result, []); + } +} + +@meta.ResourceIdentifier('ICU4XScriptWithExtensionsBorrowed_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XScriptWithExtensionsBorrowed_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XScriptWithExtensionsBorrowed_destroy( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XScriptWithExtensionsBorrowed_get_script_val') +@ffi.Native, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XScriptWithExtensionsBorrowed_get_script_val') +// ignore: non_constant_identifier_names +external int _ICU4XScriptWithExtensionsBorrowed_get_script_val( + ffi.Pointer self, int codePoint); + +@meta.ResourceIdentifier( + 'ICU4XScriptWithExtensionsBorrowed_get_script_extensions_val') +@ffi.Native< + ffi.Pointer Function(ffi.Pointer, ffi.Uint32)>( + isLeaf: true, + symbol: 'ICU4XScriptWithExtensionsBorrowed_get_script_extensions_val') +// ignore: non_constant_identifier_names +external ffi.Pointer + _ICU4XScriptWithExtensionsBorrowed_get_script_extensions_val( + ffi.Pointer self, int codePoint); + +@meta.ResourceIdentifier('ICU4XScriptWithExtensionsBorrowed_has_script') +@ffi.Native, ffi.Uint32, ffi.Uint16)>( + isLeaf: true, symbol: 'ICU4XScriptWithExtensionsBorrowed_has_script') +// ignore: non_constant_identifier_names +external bool _ICU4XScriptWithExtensionsBorrowed_has_script( + ffi.Pointer self, int codePoint, int script); + +@meta.ResourceIdentifier( + 'ICU4XScriptWithExtensionsBorrowed_get_script_extensions_set') +@ffi.Native< + ffi.Pointer Function(ffi.Pointer, ffi.Uint16)>( + isLeaf: true, + symbol: 'ICU4XScriptWithExtensionsBorrowed_get_script_extensions_set') +// ignore: non_constant_identifier_names +external ffi.Pointer + _ICU4XScriptWithExtensionsBorrowed_get_script_extensions_set( + ffi.Pointer self, int script); diff --git a/pkgs/intl4x/lib/src/bindings/SegmenterWordType.g.dart b/pkgs/intl4x/lib/src/bindings/SegmenterWordType.g.dart deleted file mode 120000 index 34a5631b..00000000 --- a/pkgs/intl4x/lib/src/bindings/SegmenterWordType.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/SegmenterWordType.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/SegmenterWordType.g.dart b/pkgs/intl4x/lib/src/bindings/SegmenterWordType.g.dart new file mode 100644 index 00000000..7237dc02 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/SegmenterWordType.g.dart @@ -0,0 +1,24 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `WordType`](https://docs.rs/icu/latest/icu/segmenter/enum.WordType.html) for more information. +enum SegmenterWordType { + none, + + number, + + letter; + + /// See the [Rust documentation for `is_word_like`](https://docs.rs/icu/latest/icu/segmenter/enum.WordType.html#method.is_word_like) for more information. + bool get isWordLike { + final result = _ICU4XSegmenterWordType_is_word_like(index); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XSegmenterWordType_is_word_like') +@ffi.Native( + isLeaf: true, symbol: 'ICU4XSegmenterWordType_is_word_like') +// ignore: non_constant_identifier_names +external bool _ICU4XSegmenterWordType_is_word_like(int self); diff --git a/pkgs/intl4x/lib/src/bindings/SentenceBreakIteratorLatin1.g.dart b/pkgs/intl4x/lib/src/bindings/SentenceBreakIteratorLatin1.g.dart deleted file mode 120000 index 03dd2ed4..00000000 --- a/pkgs/intl4x/lib/src/bindings/SentenceBreakIteratorLatin1.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/SentenceBreakIteratorLatin1.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/SentenceBreakIteratorLatin1.g.dart b/pkgs/intl4x/lib/src/bindings/SentenceBreakIteratorLatin1.g.dart new file mode 100644 index 00000000..8ccdaf5f --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/SentenceBreakIteratorLatin1.g.dart @@ -0,0 +1,50 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `SentenceBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceBreakIterator.html) for more information. +final class SentenceBreakIteratorLatin1 implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _aEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + SentenceBreakIteratorLatin1._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XSentenceBreakIteratorLatin1_destroy)); + + /// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + /// out of range of a 32-bit signed integer. + /// + /// See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceBreakIterator.html#method.next) for more information. + int next() { + final result = _ICU4XSentenceBreakIteratorLatin1_next(_ffi); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XSentenceBreakIteratorLatin1_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XSentenceBreakIteratorLatin1_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XSentenceBreakIteratorLatin1_destroy( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XSentenceBreakIteratorLatin1_next') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XSentenceBreakIteratorLatin1_next') +// ignore: non_constant_identifier_names +external int _ICU4XSentenceBreakIteratorLatin1_next( + ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/SentenceBreakIteratorUtf16.g.dart b/pkgs/intl4x/lib/src/bindings/SentenceBreakIteratorUtf16.g.dart deleted file mode 120000 index 24147b77..00000000 --- a/pkgs/intl4x/lib/src/bindings/SentenceBreakIteratorUtf16.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/SentenceBreakIteratorUtf16.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/SentenceBreakIteratorUtf16.g.dart b/pkgs/intl4x/lib/src/bindings/SentenceBreakIteratorUtf16.g.dart new file mode 100644 index 00000000..17a807db --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/SentenceBreakIteratorUtf16.g.dart @@ -0,0 +1,50 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `SentenceBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceBreakIterator.html) for more information. +final class SentenceBreakIteratorUtf16 implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _aEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + SentenceBreakIteratorUtf16._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XSentenceBreakIteratorUtf16_destroy)); + + /// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + /// out of range of a 32-bit signed integer. + /// + /// See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceBreakIterator.html#method.next) for more information. + int next() { + final result = _ICU4XSentenceBreakIteratorUtf16_next(_ffi); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XSentenceBreakIteratorUtf16_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XSentenceBreakIteratorUtf16_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XSentenceBreakIteratorUtf16_destroy( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XSentenceBreakIteratorUtf16_next') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XSentenceBreakIteratorUtf16_next') +// ignore: non_constant_identifier_names +external int _ICU4XSentenceBreakIteratorUtf16_next( + ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/SentenceBreakIteratorUtf8.g.dart b/pkgs/intl4x/lib/src/bindings/SentenceBreakIteratorUtf8.g.dart deleted file mode 120000 index f2e64578..00000000 --- a/pkgs/intl4x/lib/src/bindings/SentenceBreakIteratorUtf8.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/SentenceBreakIteratorUtf8.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/SentenceBreakIteratorUtf8.g.dart b/pkgs/intl4x/lib/src/bindings/SentenceBreakIteratorUtf8.g.dart new file mode 100644 index 00000000..684ffbfc --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/SentenceBreakIteratorUtf8.g.dart @@ -0,0 +1,49 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `SentenceBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceBreakIterator.html) for more information. +final class SentenceBreakIteratorUtf8 implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _aEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + SentenceBreakIteratorUtf8._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XSentenceBreakIteratorUtf8_destroy)); + + /// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + /// out of range of a 32-bit signed integer. + /// + /// See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceBreakIterator.html#method.next) for more information. + int next() { + final result = _ICU4XSentenceBreakIteratorUtf8_next(_ffi); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XSentenceBreakIteratorUtf8_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XSentenceBreakIteratorUtf8_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XSentenceBreakIteratorUtf8_destroy( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XSentenceBreakIteratorUtf8_next') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XSentenceBreakIteratorUtf8_next') +// ignore: non_constant_identifier_names +external int _ICU4XSentenceBreakIteratorUtf8_next(ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/SentenceSegmenter.g.dart b/pkgs/intl4x/lib/src/bindings/SentenceSegmenter.g.dart deleted file mode 120000 index 66e73b34..00000000 --- a/pkgs/intl4x/lib/src/bindings/SentenceSegmenter.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/SentenceSegmenter.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/SentenceSegmenter.g.dart b/pkgs/intl4x/lib/src/bindings/SentenceSegmenter.g.dart new file mode 100644 index 00000000..c29962e2 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/SentenceSegmenter.g.dart @@ -0,0 +1,81 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X sentence-break segmenter, capable of finding sentence breakpoints in strings. +/// +/// See the [Rust documentation for `SentenceSegmenter`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceSegmenter.html) for more information. +final class SentenceSegmenter implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + SentenceSegmenter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XSentenceSegmenter_destroy)); + + /// Construct an [`SentenceSegmenter`]. + /// + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceSegmenter.html#method.new) for more information. + /// + /// Throws [Error] on failure. + factory SentenceSegmenter(DataProvider provider) { + final result = _ICU4XSentenceSegmenter_create(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return SentenceSegmenter._fromFfi(result.union.ok, []); + } + + /// Segments a string. + /// + /// Ill-formed input is treated as if errors had been replaced with REPLACEMENT CHARACTERs according + /// to the WHATWG Encoding Standard. + /// + /// See the [Rust documentation for `segment_utf16`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceSegmenter.html#method.segment_utf16) for more information. + SentenceBreakIteratorUtf16 segment(String input) { + final inputView = input.utf16View; + final inputArena = _FinalizedArena(); + // This lifetime edge depends on lifetimes: 'a + core.List aEdges = [this, inputArena]; + final result = _ICU4XSentenceSegmenter_segment_utf16( + _ffi, inputView.allocIn(inputArena.arena), inputView.length); + return SentenceBreakIteratorUtf16._fromFfi(result, [], aEdges); + } +} + +@meta.ResourceIdentifier('ICU4XSentenceSegmenter_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XSentenceSegmenter_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XSentenceSegmenter_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XSentenceSegmenter_create') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XSentenceSegmenter_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XSentenceSegmenter_create( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XSentenceSegmenter_segment_utf16') +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size)>(isLeaf: true, symbol: 'ICU4XSentenceSegmenter_segment_utf16') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XSentenceSegmenter_segment_utf16( + ffi.Pointer self, + ffi.Pointer inputData, + int inputLength); diff --git a/pkgs/intl4x/lib/src/bindings/Time.g.dart b/pkgs/intl4x/lib/src/bindings/Time.g.dart deleted file mode 120000 index 493594ef..00000000 --- a/pkgs/intl4x/lib/src/bindings/Time.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/Time.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/Time.g.dart b/pkgs/intl4x/lib/src/bindings/Time.g.dart new file mode 100644 index 00000000..5b569625 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/Time.g.dart @@ -0,0 +1,129 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X Time object representing a time in terms of hour, minute, second, nanosecond +/// +/// See the [Rust documentation for `Time`](https://docs.rs/icu/latest/icu/calendar/struct.Time.html) for more information. +final class Time implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + Time._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XTime_destroy)); + + /// Creates a new [`Time`] given field values + /// + /// See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/calendar/struct.Time.html#method.try_new) for more information. + /// + /// Throws [Error] on failure. + factory Time(int hour, int minute, int second, int nanosecond) { + final result = _ICU4XTime_create(hour, minute, second, nanosecond); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return Time._fromFfi(result.union.ok, []); + } + + /// Creates a new [`Time`] representing midnight (00:00.000). + /// + /// See the [Rust documentation for `midnight`](https://docs.rs/icu/latest/icu/calendar/struct.Time.html#method.midnight) for more information. + /// + /// Throws [Error] on failure. + factory Time.midnight() { + final result = _ICU4XTime_create_midnight(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return Time._fromFfi(result.union.ok, []); + } + + /// Returns the hour in this time + /// + /// See the [Rust documentation for `hour`](https://docs.rs/icu/latest/icu/calendar/struct.Time.html#structfield.hour) for more information. + int get hour { + final result = _ICU4XTime_hour(_ffi); + return result; + } + + /// Returns the minute in this time + /// + /// See the [Rust documentation for `minute`](https://docs.rs/icu/latest/icu/calendar/struct.Time.html#structfield.minute) for more information. + int get minute { + final result = _ICU4XTime_minute(_ffi); + return result; + } + + /// Returns the second in this time + /// + /// See the [Rust documentation for `second`](https://docs.rs/icu/latest/icu/calendar/struct.Time.html#structfield.second) for more information. + int get second { + final result = _ICU4XTime_second(_ffi); + return result; + } + + /// Returns the nanosecond in this time + /// + /// See the [Rust documentation for `nanosecond`](https://docs.rs/icu/latest/icu/calendar/struct.Time.html#structfield.nanosecond) for more information. + int get nanosecond { + final result = _ICU4XTime_nanosecond(_ffi); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XTime_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XTime_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XTime_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XTime_create') +@ffi.Native< + _ResultOpaqueInt32 Function(ffi.Uint8, ffi.Uint8, ffi.Uint8, + ffi.Uint32)>(isLeaf: true, symbol: 'ICU4XTime_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XTime_create( + int hour, int minute, int second, int nanosecond); + +@meta.ResourceIdentifier('ICU4XTime_create_midnight') +@ffi.Native<_ResultOpaqueInt32 Function()>( + isLeaf: true, symbol: 'ICU4XTime_create_midnight') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XTime_create_midnight(); + +@meta.ResourceIdentifier('ICU4XTime_hour') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XTime_hour') +// ignore: non_constant_identifier_names +external int _ICU4XTime_hour(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XTime_minute') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XTime_minute') +// ignore: non_constant_identifier_names +external int _ICU4XTime_minute(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XTime_second') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XTime_second') +// ignore: non_constant_identifier_names +external int _ICU4XTime_second(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XTime_nanosecond') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XTime_nanosecond') +// ignore: non_constant_identifier_names +external int _ICU4XTime_nanosecond(ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/TimeFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/TimeFormatter.g.dart deleted file mode 120000 index d772827c..00000000 --- a/pkgs/intl4x/lib/src/bindings/TimeFormatter.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/TimeFormatter.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/TimeFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/TimeFormatter.g.dart new file mode 100644 index 00000000..f65dc920 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/TimeFormatter.g.dart @@ -0,0 +1,137 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X TimeFormatter object capable of formatting an [`Time`] type (and others) as a string +/// +/// See the [Rust documentation for `TimeFormatter`](https://docs.rs/icu/latest/icu/datetime/struct.TimeFormatter.html) for more information. +final class TimeFormatter implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + TimeFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XTimeFormatter_destroy)); + + /// Creates a new [`TimeFormatter`] from locale data. + /// + /// See the [Rust documentation for `try_new_with_length`](https://docs.rs/icu/latest/icu/datetime/struct.TimeFormatter.html#method.try_new_with_length) for more information. + /// + /// Throws [Error] on failure. + factory TimeFormatter.withLength( + DataProvider provider, Locale locale, TimeLength length) { + final result = _ICU4XTimeFormatter_create_with_length( + provider._ffi, locale._ffi, length.index); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return TimeFormatter._fromFfi(result.union.ok, []); + } + + /// Formats a [`Time`] to a string. + /// + /// See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TimeFormatter.html#method.format) for more information. + /// + /// Throws [Error] on failure. + String formatTime(Time value) { + final writeable = _Writeable(); + final result = + _ICU4XTimeFormatter_format_time(_ffi, value._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Formats a [`DateTime`] to a string. + /// + /// See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TimeFormatter.html#method.format) for more information. + /// + /// Throws [Error] on failure. + String formatDatetime(DateTime value) { + final writeable = _Writeable(); + final result = + _ICU4XTimeFormatter_format_datetime(_ffi, value._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Formats a [`IsoDateTime`] to a string. + /// + /// See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TimeFormatter.html#method.format) for more information. + /// + /// Throws [Error] on failure. + String formatIsoDatetime(IsoDateTime value) { + final writeable = _Writeable(); + final result = _ICU4XTimeFormatter_format_iso_datetime( + _ffi, value._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } +} + +@meta.ResourceIdentifier('ICU4XTimeFormatter_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XTimeFormatter_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XTimeFormatter_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XTimeFormatter_create_with_length') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XTimeFormatter_create_with_length') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XTimeFormatter_create_with_length( + ffi.Pointer provider, + ffi.Pointer locale, + int length); + +@meta.ResourceIdentifier('ICU4XTimeFormatter_format_time') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XTimeFormatter_format_time') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XTimeFormatter_format_time( + ffi.Pointer self, + ffi.Pointer value, + ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XTimeFormatter_format_datetime') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XTimeFormatter_format_datetime') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XTimeFormatter_format_datetime( + ffi.Pointer self, + ffi.Pointer value, + ffi.Pointer writeable); + +@meta.ResourceIdentifier('ICU4XTimeFormatter_format_iso_datetime') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XTimeFormatter_format_iso_datetime') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XTimeFormatter_format_iso_datetime( + ffi.Pointer self, + ffi.Pointer value, + ffi.Pointer writeable); diff --git a/pkgs/intl4x/lib/src/bindings/TimeLength.g.dart b/pkgs/intl4x/lib/src/bindings/TimeLength.g.dart deleted file mode 120000 index 1c91cf8e..00000000 --- a/pkgs/intl4x/lib/src/bindings/TimeLength.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/TimeLength.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/TimeLength.g.dart b/pkgs/intl4x/lib/src/bindings/TimeLength.g.dart new file mode 100644 index 00000000..e9557092 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/TimeLength.g.dart @@ -0,0 +1,14 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `Time`](https://docs.rs/icu/latest/icu/datetime/options/length/enum.Time.html) for more information. +enum TimeLength { + full, + + long, + + medium, + + short; +} diff --git a/pkgs/intl4x/lib/src/bindings/TimeZoneFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/TimeZoneFormatter.g.dart deleted file mode 120000 index a0c61ea7..00000000 --- a/pkgs/intl4x/lib/src/bindings/TimeZoneFormatter.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/TimeZoneFormatter.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/TimeZoneFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/TimeZoneFormatter.g.dart new file mode 100644 index 00000000..a9314728 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/TimeZoneFormatter.g.dart @@ -0,0 +1,320 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X TimeZoneFormatter object capable of formatting an [`CustomTimeZone`] type (and others) as a string +/// +/// See the [Rust documentation for `TimeZoneFormatter`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html) for more information. +final class TimeZoneFormatter implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + TimeZoneFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XTimeZoneFormatter_destroy)); + + /// Creates a new [`TimeZoneFormatter`] from locale data. + /// + /// Uses localized GMT as the fallback format. + /// + /// See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.try_new) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/datetime/time_zone/enum.FallbackFormat.html) + /// + /// Throws [Error] on failure. + factory TimeZoneFormatter.withLocalizedGmtFallback( + DataProvider provider, Locale locale) { + final result = _ICU4XTimeZoneFormatter_create_with_localized_gmt_fallback( + provider._ffi, locale._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return TimeZoneFormatter._fromFfi(result.union.ok, []); + } + + /// Creates a new [`TimeZoneFormatter`] from locale data. + /// + /// Uses ISO-8601 as the fallback format. + /// + /// See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.try_new) for more information. + /// + /// Additional information: [1](https://docs.rs/icu/latest/icu/datetime/time_zone/enum.FallbackFormat.html) + /// + /// Throws [Error] on failure. + factory TimeZoneFormatter.withIso8601Fallback( + DataProvider provider, Locale locale, IsoTimeZoneOptions options) { + final temp = ffi2.Arena(); + final result = _ICU4XTimeZoneFormatter_create_with_iso_8601_fallback( + provider._ffi, locale._ffi, options._toFfi(temp)); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return TimeZoneFormatter._fromFfi(result.union.ok, []); + } + + /// Loads generic non-location long format. Example: "Pacific Time" + /// + /// See the [Rust documentation for `include_generic_non_location_long`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.include_generic_non_location_long) for more information. + /// + /// Throws [Error] on failure. + void loadGenericNonLocationLong(DataProvider provider) { + final result = _ICU4XTimeZoneFormatter_load_generic_non_location_long( + _ffi, provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// Loads generic non-location short format. Example: "PT" + /// + /// See the [Rust documentation for `include_generic_non_location_short`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.include_generic_non_location_short) for more information. + /// + /// Throws [Error] on failure. + void loadGenericNonLocationShort(DataProvider provider) { + final result = _ICU4XTimeZoneFormatter_load_generic_non_location_short( + _ffi, provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// Loads specific non-location long format. Example: "Pacific Standard Time" + /// + /// See the [Rust documentation for `include_specific_non_location_long`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.include_specific_non_location_long) for more information. + /// + /// Throws [Error] on failure. + void loadSpecificNonLocationLong(DataProvider provider) { + final result = _ICU4XTimeZoneFormatter_load_specific_non_location_long( + _ffi, provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// Loads specific non-location short format. Example: "PST" + /// + /// See the [Rust documentation for `include_specific_non_location_short`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.include_specific_non_location_short) for more information. + /// + /// Throws [Error] on failure. + void loadSpecificNonLocationShort(DataProvider provider) { + final result = _ICU4XTimeZoneFormatter_load_specific_non_location_short( + _ffi, provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// Loads generic location format. Example: "Los Angeles Time" + /// + /// See the [Rust documentation for `include_generic_location_format`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.include_generic_location_format) for more information. + /// + /// Throws [Error] on failure. + void loadGenericLocationFormat(DataProvider provider) { + final result = _ICU4XTimeZoneFormatter_load_generic_location_format( + _ffi, provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// Loads localized GMT format. Example: "GMT-07:00" + /// + /// See the [Rust documentation for `include_localized_gmt_format`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.include_localized_gmt_format) for more information. + /// + /// Throws [Error] on failure. + void includeLocalizedGmtFormat() { + final result = _ICU4XTimeZoneFormatter_include_localized_gmt_format(_ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// Loads ISO-8601 format. Example: "-07:00" + /// + /// See the [Rust documentation for `include_iso_8601_format`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.include_iso_8601_format) for more information. + /// + /// Throws [Error] on failure. + void loadIso8601Format(IsoTimeZoneOptions options) { + final temp = ffi2.Arena(); + final result = _ICU4XTimeZoneFormatter_load_iso_8601_format( + _ffi, options._toFfi(temp)); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + } + + /// Formats a [`CustomTimeZone`] to a string. + /// + /// See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.format) for more information. + /// + /// See the [Rust documentation for `format_to_string`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.format_to_string) for more information. + /// + /// Throws [Error] on failure. + String formatCustomTimeZone(CustomTimeZone value) { + final writeable = _Writeable(); + final result = _ICU4XTimeZoneFormatter_format_custom_time_zone( + _ffi, value._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Formats a [`CustomTimeZone`] to a string, performing no fallback + /// + /// See the [Rust documentation for `write_no_fallback`](https://docs.rs/icu/latest/icu/datetime/struct.FormattedTimeZone.html#method.write_no_fallback) for more information. + /// + /// Throws [Error] on failure. + String formatCustomTimeZoneNoFallback(CustomTimeZone value) { + final writeable = _Writeable(); + final result = _ICU4XTimeZoneFormatter_format_custom_time_zone_no_fallback( + _ffi, value._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } +} + +@meta.ResourceIdentifier('ICU4XTimeZoneFormatter_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XTimeZoneFormatter_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XTimeZoneFormatter_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier( + 'ICU4XTimeZoneFormatter_create_with_localized_gmt_fallback') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, + symbol: 'ICU4XTimeZoneFormatter_create_with_localized_gmt_fallback') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XTimeZoneFormatter_create_with_localized_gmt_fallback( + ffi.Pointer provider, ffi.Pointer locale); + +@meta.ResourceIdentifier('ICU4XTimeZoneFormatter_create_with_iso_8601_fallback') +@ffi.Native< + _ResultOpaqueInt32 Function(ffi.Pointer, + ffi.Pointer, _IsoTimeZoneOptionsFfi)>( + isLeaf: true, + symbol: 'ICU4XTimeZoneFormatter_create_with_iso_8601_fallback') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XTimeZoneFormatter_create_with_iso_8601_fallback( + ffi.Pointer provider, + ffi.Pointer locale, + _IsoTimeZoneOptionsFfi options); + +@meta + .ResourceIdentifier('ICU4XTimeZoneFormatter_load_generic_non_location_long') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, + symbol: 'ICU4XTimeZoneFormatter_load_generic_non_location_long') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 + _ICU4XTimeZoneFormatter_load_generic_non_location_long( + ffi.Pointer self, ffi.Pointer provider); + +@meta.ResourceIdentifier( + 'ICU4XTimeZoneFormatter_load_generic_non_location_short') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, + symbol: 'ICU4XTimeZoneFormatter_load_generic_non_location_short') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 + _ICU4XTimeZoneFormatter_load_generic_non_location_short( + ffi.Pointer self, ffi.Pointer provider); + +@meta.ResourceIdentifier( + 'ICU4XTimeZoneFormatter_load_specific_non_location_long') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, + symbol: 'ICU4XTimeZoneFormatter_load_specific_non_location_long') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 + _ICU4XTimeZoneFormatter_load_specific_non_location_long( + ffi.Pointer self, ffi.Pointer provider); + +@meta.ResourceIdentifier( + 'ICU4XTimeZoneFormatter_load_specific_non_location_short') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, + symbol: 'ICU4XTimeZoneFormatter_load_specific_non_location_short') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 + _ICU4XTimeZoneFormatter_load_specific_non_location_short( + ffi.Pointer self, ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XTimeZoneFormatter_load_generic_location_format') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XTimeZoneFormatter_load_generic_location_format') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XTimeZoneFormatter_load_generic_location_format( + ffi.Pointer self, ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XTimeZoneFormatter_include_localized_gmt_format') +@ffi.Native<_ResultVoidInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XTimeZoneFormatter_include_localized_gmt_format') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XTimeZoneFormatter_include_localized_gmt_format( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XTimeZoneFormatter_load_iso_8601_format') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, _IsoTimeZoneOptionsFfi)>( + isLeaf: true, symbol: 'ICU4XTimeZoneFormatter_load_iso_8601_format') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XTimeZoneFormatter_load_iso_8601_format( + ffi.Pointer self, _IsoTimeZoneOptionsFfi options); + +@meta.ResourceIdentifier('ICU4XTimeZoneFormatter_format_custom_time_zone') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XTimeZoneFormatter_format_custom_time_zone') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XTimeZoneFormatter_format_custom_time_zone( + ffi.Pointer self, + ffi.Pointer value, + ffi.Pointer writeable); + +@meta.ResourceIdentifier( + 'ICU4XTimeZoneFormatter_format_custom_time_zone_no_fallback') +@ffi.Native< + _ResultVoidInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, + symbol: 'ICU4XTimeZoneFormatter_format_custom_time_zone_no_fallback') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 + _ICU4XTimeZoneFormatter_format_custom_time_zone_no_fallback( + ffi.Pointer self, + ffi.Pointer value, + ffi.Pointer writeable); diff --git a/pkgs/intl4x/lib/src/bindings/TitlecaseMapper.g.dart b/pkgs/intl4x/lib/src/bindings/TitlecaseMapper.g.dart deleted file mode 120000 index 944c40c1..00000000 --- a/pkgs/intl4x/lib/src/bindings/TitlecaseMapper.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/TitlecaseMapper.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/TitlecaseMapper.g.dart b/pkgs/intl4x/lib/src/bindings/TitlecaseMapper.g.dart new file mode 100644 index 00000000..8aa3d365 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/TitlecaseMapper.g.dart @@ -0,0 +1,95 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `TitlecaseMapper`](https://docs.rs/icu/latest/icu/casemap/struct.TitlecaseMapper.html) for more information. +final class TitlecaseMapper implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + TitlecaseMapper._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XTitlecaseMapper_destroy)); + + /// Construct a new `TitlecaseMapper` instance + /// + /// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/casemap/struct.TitlecaseMapper.html#method.new) for more information. + /// + /// Throws [Error] on failure. + factory TitlecaseMapper(DataProvider provider) { + final result = _ICU4XTitlecaseMapper_create(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return TitlecaseMapper._fromFfi(result.union.ok, []); + } + + /// Returns the full titlecase mapping of the given string + /// + /// The `v1` refers to the version of the options struct, which may change as we add more options + /// + /// See the [Rust documentation for `titlecase_segment`](https://docs.rs/icu/latest/icu/casemap/struct.TitlecaseMapper.html#method.titlecase_segment) for more information. + /// + /// Throws [Error] on failure. + String titlecaseSegment(String s, Locale locale, TitlecaseOptions options) { + final temp = ffi2.Arena(); + final sView = s.utf8View; + final writeable = _Writeable(); + final result = _ICU4XTitlecaseMapper_titlecase_segment_v1( + _ffi, + sView.allocIn(temp), + sView.length, + locale._ffi, + options._toFfi(temp), + writeable._ffi); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } +} + +@meta.ResourceIdentifier('ICU4XTitlecaseMapper_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XTitlecaseMapper_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XTitlecaseMapper_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XTitlecaseMapper_create') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XTitlecaseMapper_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XTitlecaseMapper_create( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XTitlecaseMapper_titlecase_segment_v1') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size, + ffi.Pointer, + _TitlecaseOptionsFfi, + ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XTitlecaseMapper_titlecase_segment_v1') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 _ICU4XTitlecaseMapper_titlecase_segment_v1( + ffi.Pointer self, + ffi.Pointer sData, + int sLength, + ffi.Pointer locale, + _TitlecaseOptionsFfi options, + ffi.Pointer writeable); diff --git a/pkgs/intl4x/lib/src/bindings/TitlecaseOptions.g.dart b/pkgs/intl4x/lib/src/bindings/TitlecaseOptions.g.dart deleted file mode 120000 index 1667c4bd..00000000 --- a/pkgs/intl4x/lib/src/bindings/TitlecaseOptions.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/TitlecaseOptions.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/TitlecaseOptions.g.dart b/pkgs/intl4x/lib/src/bindings/TitlecaseOptions.g.dart new file mode 100644 index 00000000..ce16b2bb --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/TitlecaseOptions.g.dart @@ -0,0 +1,66 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +final class _TitlecaseOptionsFfi extends ffi.Struct { + @ffi.Int32() + external int leadingAdjustment; + @ffi.Int32() + external int trailingCase; +} + +/// See the [Rust documentation for `TitlecaseOptions`](https://docs.rs/icu/latest/icu/casemap/titlecase/struct.TitlecaseOptions.html) for more information. +final class TitlecaseOptions { + LeadingAdjustment leadingAdjustment; + TrailingCase trailingCase; + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + TitlecaseOptions._fromFfi(_TitlecaseOptionsFfi ffi) + : leadingAdjustment = LeadingAdjustment.values[ffi.leadingAdjustment], + trailingCase = TrailingCase.values[ffi.trailingCase]; + + // ignore: unused_element + _TitlecaseOptionsFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_TitlecaseOptionsFfi>(); + struct.leadingAdjustment = leadingAdjustment.index; + struct.trailingCase = trailingCase.index; + return struct; + } + + /// See the [Rust documentation for `default`](https://docs.rs/icu/latest/icu/casemap/titlecase/struct.TitlecaseOptions.html#method.default) for more information. + factory TitlecaseOptions( + {LeadingAdjustment? leadingAdjustment, TrailingCase? trailingCase}) { + final result = _ICU4XTitlecaseOptionsV1_default_options(); + final dart = TitlecaseOptions._fromFfi(result); + if (leadingAdjustment != null) { + dart.leadingAdjustment = leadingAdjustment; + } + if (trailingCase != null) { + dart.trailingCase = trailingCase; + } + return dart; + } + + @override + bool operator ==(Object other) => + other is TitlecaseOptions && + other.leadingAdjustment == leadingAdjustment && + other.trailingCase == trailingCase; + + @override + int get hashCode => Object.hashAll([ + leadingAdjustment, + trailingCase, + ]); +} + +@meta.ResourceIdentifier('ICU4XTitlecaseOptionsV1_default_options') +@ffi.Native<_TitlecaseOptionsFfi Function()>( + isLeaf: true, symbol: 'ICU4XTitlecaseOptionsV1_default_options') +// ignore: non_constant_identifier_names +external _TitlecaseOptionsFfi _ICU4XTitlecaseOptionsV1_default_options(); diff --git a/pkgs/intl4x/lib/src/bindings/TrailingCase.g.dart b/pkgs/intl4x/lib/src/bindings/TrailingCase.g.dart deleted file mode 120000 index caf5eb52..00000000 --- a/pkgs/intl4x/lib/src/bindings/TrailingCase.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/TrailingCase.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/TrailingCase.g.dart b/pkgs/intl4x/lib/src/bindings/TrailingCase.g.dart new file mode 100644 index 00000000..d85cd105 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/TrailingCase.g.dart @@ -0,0 +1,10 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `TrailingCase`](https://docs.rs/icu/latest/icu/casemap/titlecase/enum.TrailingCase.html) for more information. +enum TrailingCase { + lower, + + unchanged; +} diff --git a/pkgs/intl4x/lib/src/bindings/TransformResult.g.dart b/pkgs/intl4x/lib/src/bindings/TransformResult.g.dart deleted file mode 120000 index 28f525e7..00000000 --- a/pkgs/intl4x/lib/src/bindings/TransformResult.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/TransformResult.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/TransformResult.g.dart b/pkgs/intl4x/lib/src/bindings/TransformResult.g.dart new file mode 100644 index 00000000..0786961a --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/TransformResult.g.dart @@ -0,0 +1,10 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `TransformResult`](https://docs.rs/icu/latest/icu/locid_transform/enum.TransformResult.html) for more information. +enum TransformResult { + modified, + + unmodified; +} diff --git a/pkgs/intl4x/lib/src/bindings/UnicodeSetData.g.dart b/pkgs/intl4x/lib/src/bindings/UnicodeSetData.g.dart deleted file mode 120000 index 74e549d2..00000000 --- a/pkgs/intl4x/lib/src/bindings/UnicodeSetData.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/UnicodeSetData.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/UnicodeSetData.g.dart b/pkgs/intl4x/lib/src/bindings/UnicodeSetData.g.dart new file mode 100644 index 00000000..3b27151f --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/UnicodeSetData.g.dart @@ -0,0 +1,198 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X Unicode Set Property object, capable of querying whether a code point is contained in a set based on a Unicode property. +/// +/// See the [Rust documentation for `properties`](https://docs.rs/icu/latest/icu/properties/index.html) for more information. +/// +/// See the [Rust documentation for `UnicodeSetData`](https://docs.rs/icu/latest/icu/properties/sets/struct.UnicodeSetData.html) for more information. +/// +/// See the [Rust documentation for `UnicodeSetDataBorrowed`](https://docs.rs/icu/latest/icu/properties/sets/struct.UnicodeSetDataBorrowed.html) for more information. +final class UnicodeSetData implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + UnicodeSetData._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XUnicodeSetData_destroy)); + + /// Checks whether the string is in the set. + /// + /// See the [Rust documentation for `contains`](https://docs.rs/icu/latest/icu/properties/sets/struct.UnicodeSetDataBorrowed.html#method.contains) for more information. + bool contains(String s) { + final temp = ffi2.Arena(); + final sView = s.utf8View; + final result = + _ICU4XUnicodeSetData_contains(_ffi, sView.allocIn(temp), sView.length); + temp.releaseAll(); + return result; + } + + /// Checks whether the code point is in the set. + /// + /// See the [Rust documentation for `contains_char`](https://docs.rs/icu/latest/icu/properties/sets/struct.UnicodeSetDataBorrowed.html#method.contains_char) for more information. + bool containsChar(Rune cp) { + final result = _ICU4XUnicodeSetData_contains_char(_ffi, cp); + return result; + } + + /// See the [Rust documentation for `basic_emoji`](https://docs.rs/icu/latest/icu/properties/sets/fn.basic_emoji.html) for more information. + /// + /// Throws [Error] on failure. + factory UnicodeSetData.basicEmoji(DataProvider provider) { + final result = _ICU4XUnicodeSetData_load_basic_emoji(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return UnicodeSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `exemplars_main`](https://docs.rs/icu/latest/icu/properties/exemplar_chars/fn.exemplars_main.html) for more information. + /// + /// Throws [Error] on failure. + factory UnicodeSetData.exemplarsMain(DataProvider provider, Locale locale) { + final result = + _ICU4XUnicodeSetData_load_exemplars_main(provider._ffi, locale._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return UnicodeSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `exemplars_auxiliary`](https://docs.rs/icu/latest/icu/properties/exemplar_chars/fn.exemplars_auxiliary.html) for more information. + /// + /// Throws [Error] on failure. + factory UnicodeSetData.exemplarsAuxiliary( + DataProvider provider, Locale locale) { + final result = _ICU4XUnicodeSetData_load_exemplars_auxiliary( + provider._ffi, locale._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return UnicodeSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `exemplars_punctuation`](https://docs.rs/icu/latest/icu/properties/exemplar_chars/fn.exemplars_punctuation.html) for more information. + /// + /// Throws [Error] on failure. + factory UnicodeSetData.exemplarsPunctuation( + DataProvider provider, Locale locale) { + final result = _ICU4XUnicodeSetData_load_exemplars_punctuation( + provider._ffi, locale._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return UnicodeSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `exemplars_numbers`](https://docs.rs/icu/latest/icu/properties/exemplar_chars/fn.exemplars_numbers.html) for more information. + /// + /// Throws [Error] on failure. + factory UnicodeSetData.exemplarsNumbers( + DataProvider provider, Locale locale) { + final result = + _ICU4XUnicodeSetData_load_exemplars_numbers(provider._ffi, locale._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return UnicodeSetData._fromFfi(result.union.ok, []); + } + + /// See the [Rust documentation for `exemplars_index`](https://docs.rs/icu/latest/icu/properties/exemplar_chars/fn.exemplars_index.html) for more information. + /// + /// Throws [Error] on failure. + factory UnicodeSetData.exemplarsIndex(DataProvider provider, Locale locale) { + final result = + _ICU4XUnicodeSetData_load_exemplars_index(provider._ffi, locale._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return UnicodeSetData._fromFfi(result.union.ok, []); + } +} + +@meta.ResourceIdentifier('ICU4XUnicodeSetData_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XUnicodeSetData_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XUnicodeSetData_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XUnicodeSetData_contains') +@ffi.Native< + ffi.Bool Function(ffi.Pointer, ffi.Pointer, + ffi.Size)>(isLeaf: true, symbol: 'ICU4XUnicodeSetData_contains') +// ignore: non_constant_identifier_names +external bool _ICU4XUnicodeSetData_contains( + ffi.Pointer self, ffi.Pointer sData, int sLength); + +@meta.ResourceIdentifier('ICU4XUnicodeSetData_contains_char') +@ffi.Native, ffi.Uint32)>( + isLeaf: true, symbol: 'ICU4XUnicodeSetData_contains_char') +// ignore: non_constant_identifier_names +external bool _ICU4XUnicodeSetData_contains_char( + ffi.Pointer self, Rune cp); + +@meta.ResourceIdentifier('ICU4XUnicodeSetData_load_basic_emoji') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XUnicodeSetData_load_basic_emoji') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XUnicodeSetData_load_basic_emoji( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XUnicodeSetData_load_exemplars_main') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XUnicodeSetData_load_exemplars_main') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XUnicodeSetData_load_exemplars_main( + ffi.Pointer provider, ffi.Pointer locale); + +@meta.ResourceIdentifier('ICU4XUnicodeSetData_load_exemplars_auxiliary') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XUnicodeSetData_load_exemplars_auxiliary') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XUnicodeSetData_load_exemplars_auxiliary( + ffi.Pointer provider, ffi.Pointer locale); + +@meta.ResourceIdentifier('ICU4XUnicodeSetData_load_exemplars_punctuation') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XUnicodeSetData_load_exemplars_punctuation') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XUnicodeSetData_load_exemplars_punctuation( + ffi.Pointer provider, ffi.Pointer locale); + +@meta.ResourceIdentifier('ICU4XUnicodeSetData_load_exemplars_numbers') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XUnicodeSetData_load_exemplars_numbers') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XUnicodeSetData_load_exemplars_numbers( + ffi.Pointer provider, ffi.Pointer locale); + +@meta.ResourceIdentifier('ICU4XUnicodeSetData_load_exemplars_index') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XUnicodeSetData_load_exemplars_index') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XUnicodeSetData_load_exemplars_index( + ffi.Pointer provider, ffi.Pointer locale); diff --git a/pkgs/intl4x/lib/src/bindings/WeekCalculator.g.dart b/pkgs/intl4x/lib/src/bindings/WeekCalculator.g.dart deleted file mode 120000 index 96f5e7db..00000000 --- a/pkgs/intl4x/lib/src/bindings/WeekCalculator.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/WeekCalculator.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/WeekCalculator.g.dart b/pkgs/intl4x/lib/src/bindings/WeekCalculator.g.dart new file mode 100644 index 00000000..7c1f2f12 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/WeekCalculator.g.dart @@ -0,0 +1,117 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// A Week calculator, useful to be passed in to `week_of_year()` on Date and DateTime types +/// +/// See the [Rust documentation for `WeekCalculator`](https://docs.rs/icu/latest/icu/calendar/week/struct.WeekCalculator.html) for more information. +final class WeekCalculator implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + WeekCalculator._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XWeekCalculator_destroy)); + + /// Creates a new [`WeekCalculator`] from locale data. + /// + /// See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/calendar/week/struct.WeekCalculator.html#method.try_new) for more information. + /// + /// Throws [Error] on failure. + factory WeekCalculator(DataProvider provider, Locale locale) { + final result = _ICU4XWeekCalculator_create(provider._ffi, locale._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return WeekCalculator._fromFfi(result.union.ok, []); + } + + /// Additional information: [1](https://docs.rs/icu/latest/icu/calendar/week/struct.WeekCalculator.html#structfield.first_weekday), [2](https://docs.rs/icu/latest/icu/calendar/week/struct.WeekCalculator.html#structfield.min_week_days) + factory WeekCalculator.fromFirstDayOfWeekAndMinWeekDays( + IsoWeekday firstWeekday, int minWeekDays) { + final result = + _ICU4XWeekCalculator_create_from_first_day_of_week_and_min_week_days( + firstWeekday._ffi, minWeekDays); + return WeekCalculator._fromFfi(result, []); + } + + /// Returns the weekday that starts the week for this object's locale + /// + /// See the [Rust documentation for `first_weekday`](https://docs.rs/icu/latest/icu/calendar/week/struct.WeekCalculator.html#structfield.first_weekday) for more information. + IsoWeekday get firstWeekday { + final result = _ICU4XWeekCalculator_first_weekday(_ffi); + return IsoWeekday.values.firstWhere((v) => v._ffi == result); + } + + /// The minimum number of days overlapping a year required for a week to be + /// considered part of that year + /// + /// See the [Rust documentation for `min_week_days`](https://docs.rs/icu/latest/icu/calendar/week/struct.WeekCalculator.html#structfield.min_week_days) for more information. + int get minWeekDays { + final result = _ICU4XWeekCalculator_min_week_days(_ffi); + return result; + } + + /// See the [Rust documentation for `weekend`](https://docs.rs/icu/latest/icu/calendar/week/struct.WeekCalculator.html#method.weekend) for more information. + WeekendContainsDay get weekend { + final result = _ICU4XWeekCalculator_weekend(_ffi); + return WeekendContainsDay._fromFfi(result); + } +} + +@meta.ResourceIdentifier('ICU4XWeekCalculator_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XWeekCalculator_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XWeekCalculator_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XWeekCalculator_create') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XWeekCalculator_create') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XWeekCalculator_create( + ffi.Pointer provider, ffi.Pointer locale); + +@meta.ResourceIdentifier( + 'ICU4XWeekCalculator_create_from_first_day_of_week_and_min_week_days') +@ffi.Native Function(ffi.Int32, ffi.Uint8)>( + isLeaf: true, + symbol: + 'ICU4XWeekCalculator_create_from_first_day_of_week_and_min_week_days') +// ignore: non_constant_identifier_names +external ffi.Pointer + _ICU4XWeekCalculator_create_from_first_day_of_week_and_min_week_days( + int firstWeekday, int minWeekDays); + +@meta.ResourceIdentifier('ICU4XWeekCalculator_first_weekday') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XWeekCalculator_first_weekday') +// ignore: non_constant_identifier_names +external int _ICU4XWeekCalculator_first_weekday(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XWeekCalculator_min_week_days') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XWeekCalculator_min_week_days') +// ignore: non_constant_identifier_names +external int _ICU4XWeekCalculator_min_week_days(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XWeekCalculator_weekend') +@ffi.Native<_WeekendContainsDayFfi Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XWeekCalculator_weekend') +// ignore: non_constant_identifier_names +external _WeekendContainsDayFfi _ICU4XWeekCalculator_weekend( + ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/WeekOf.g.dart b/pkgs/intl4x/lib/src/bindings/WeekOf.g.dart deleted file mode 120000 index 39577a0b..00000000 --- a/pkgs/intl4x/lib/src/bindings/WeekOf.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/WeekOf.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/WeekOf.g.dart b/pkgs/intl4x/lib/src/bindings/WeekOf.g.dart new file mode 100644 index 00000000..062c2015 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/WeekOf.g.dart @@ -0,0 +1,44 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +final class _WeekOfFfi extends ffi.Struct { + @ffi.Uint16() + external int week; + @ffi.Int32() + external int unit; +} + +/// See the [Rust documentation for `WeekOf`](https://docs.rs/icu/latest/icu/calendar/week/struct.WeekOf.html) for more information. +final class WeekOf { + final int week; + final WeekRelativeUnit unit; + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + WeekOf._fromFfi(_WeekOfFfi ffi) + : week = ffi.week, + unit = WeekRelativeUnit.values[ffi.unit]; + + // ignore: unused_element + _WeekOfFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_WeekOfFfi>(); + struct.week = week; + struct.unit = unit.index; + return struct; + } + + @override + bool operator ==(Object other) => + other is WeekOf && other.week == week && other.unit == unit; + + @override + int get hashCode => Object.hashAll([ + week, + unit, + ]); +} diff --git a/pkgs/intl4x/lib/src/bindings/WeekRelativeUnit.g.dart b/pkgs/intl4x/lib/src/bindings/WeekRelativeUnit.g.dart deleted file mode 120000 index afc00638..00000000 --- a/pkgs/intl4x/lib/src/bindings/WeekRelativeUnit.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/WeekRelativeUnit.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/WeekRelativeUnit.g.dart b/pkgs/intl4x/lib/src/bindings/WeekRelativeUnit.g.dart new file mode 100644 index 00000000..a77fb9c0 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/WeekRelativeUnit.g.dart @@ -0,0 +1,12 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `RelativeUnit`](https://docs.rs/icu/latest/icu/calendar/week/enum.RelativeUnit.html) for more information. +enum WeekRelativeUnit { + previous, + + current, + + next; +} diff --git a/pkgs/intl4x/lib/src/bindings/WeekendContainsDay.g.dart b/pkgs/intl4x/lib/src/bindings/WeekendContainsDay.g.dart deleted file mode 120000 index b2d5bc61..00000000 --- a/pkgs/intl4x/lib/src/bindings/WeekendContainsDay.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/WeekendContainsDay.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/WeekendContainsDay.g.dart b/pkgs/intl4x/lib/src/bindings/WeekendContainsDay.g.dart new file mode 100644 index 00000000..9a5d9eb3 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/WeekendContainsDay.g.dart @@ -0,0 +1,92 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +final class _WeekendContainsDayFfi extends ffi.Struct { + @ffi.Bool() + external bool monday; + @ffi.Bool() + external bool tuesday; + @ffi.Bool() + external bool wednesday; + @ffi.Bool() + external bool thursday; + @ffi.Bool() + external bool friday; + @ffi.Bool() + external bool saturday; + @ffi.Bool() + external bool sunday; +} + +/// Documents which days of the week are considered to be a part of the weekend +/// +/// See the [Rust documentation for `weekend`](https://docs.rs/icu/latest/icu/calendar/week/struct.WeekCalculator.html#method.weekend) for more information. +final class WeekendContainsDay { + bool monday; + bool tuesday; + bool wednesday; + bool thursday; + bool friday; + bool saturday; + bool sunday; + + WeekendContainsDay( + {required this.monday, + required this.tuesday, + required this.wednesday, + required this.thursday, + required this.friday, + required this.saturday, + required this.sunday}); + + // This struct contains borrowed fields, so this takes in a list of + // "edges" corresponding to where each lifetime's data may have been borrowed from + // and passes it down to individual fields containing the borrow. + // This method does not attempt to handle any dependencies between lifetimes, the caller + // should handle this when constructing edge arrays. + // ignore: unused_element + WeekendContainsDay._fromFfi(_WeekendContainsDayFfi ffi) + : monday = ffi.monday, + tuesday = ffi.tuesday, + wednesday = ffi.wednesday, + thursday = ffi.thursday, + friday = ffi.friday, + saturday = ffi.saturday, + sunday = ffi.sunday; + + // ignore: unused_element + _WeekendContainsDayFfi _toFfi(ffi.Allocator temp) { + final struct = ffi.Struct.create<_WeekendContainsDayFfi>(); + struct.monday = monday; + struct.tuesday = tuesday; + struct.wednesday = wednesday; + struct.thursday = thursday; + struct.friday = friday; + struct.saturday = saturday; + struct.sunday = sunday; + return struct; + } + + @override + bool operator ==(Object other) => + other is WeekendContainsDay && + other.monday == monday && + other.tuesday == tuesday && + other.wednesday == wednesday && + other.thursday == thursday && + other.friday == friday && + other.saturday == saturday && + other.sunday == sunday; + + @override + int get hashCode => Object.hashAll([ + monday, + tuesday, + wednesday, + thursday, + friday, + saturday, + sunday, + ]); +} diff --git a/pkgs/intl4x/lib/src/bindings/WordBreakIteratorLatin1.g.dart b/pkgs/intl4x/lib/src/bindings/WordBreakIteratorLatin1.g.dart deleted file mode 120000 index 399aabbc..00000000 --- a/pkgs/intl4x/lib/src/bindings/WordBreakIteratorLatin1.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/WordBreakIteratorLatin1.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/WordBreakIteratorLatin1.g.dart b/pkgs/intl4x/lib/src/bindings/WordBreakIteratorLatin1.g.dart new file mode 100644 index 00000000..1c394487 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/WordBreakIteratorLatin1.g.dart @@ -0,0 +1,78 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `WordBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html) for more information. +final class WordBreakIteratorLatin1 implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _aEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + WordBreakIteratorLatin1._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XWordBreakIteratorLatin1_destroy)); + + /// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + /// out of range of a 32-bit signed integer. + /// + /// See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.next) for more information. + int next() { + final result = _ICU4XWordBreakIteratorLatin1_next(_ffi); + return result; + } + + /// Return the status value of break boundary. + /// + /// See the [Rust documentation for `word_type`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.word_type) for more information. + SegmenterWordType get wordType { + final result = _ICU4XWordBreakIteratorLatin1_word_type(_ffi); + return SegmenterWordType.values[result]; + } + + /// Return true when break boundary is word-like such as letter/number/CJK + /// + /// See the [Rust documentation for `is_word_like`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.is_word_like) for more information. + bool get isWordLike { + final result = _ICU4XWordBreakIteratorLatin1_is_word_like(_ffi); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XWordBreakIteratorLatin1_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XWordBreakIteratorLatin1_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XWordBreakIteratorLatin1_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XWordBreakIteratorLatin1_next') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XWordBreakIteratorLatin1_next') +// ignore: non_constant_identifier_names +external int _ICU4XWordBreakIteratorLatin1_next(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XWordBreakIteratorLatin1_word_type') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XWordBreakIteratorLatin1_word_type') +// ignore: non_constant_identifier_names +external int _ICU4XWordBreakIteratorLatin1_word_type( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XWordBreakIteratorLatin1_is_word_like') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XWordBreakIteratorLatin1_is_word_like') +// ignore: non_constant_identifier_names +external bool _ICU4XWordBreakIteratorLatin1_is_word_like( + ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/WordBreakIteratorUtf16.g.dart b/pkgs/intl4x/lib/src/bindings/WordBreakIteratorUtf16.g.dart deleted file mode 120000 index 154ff303..00000000 --- a/pkgs/intl4x/lib/src/bindings/WordBreakIteratorUtf16.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/WordBreakIteratorUtf16.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/WordBreakIteratorUtf16.g.dart b/pkgs/intl4x/lib/src/bindings/WordBreakIteratorUtf16.g.dart new file mode 100644 index 00000000..37ee1d92 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/WordBreakIteratorUtf16.g.dart @@ -0,0 +1,78 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `WordBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html) for more information. +final class WordBreakIteratorUtf16 implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _aEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + WordBreakIteratorUtf16._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XWordBreakIteratorUtf16_destroy)); + + /// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + /// out of range of a 32-bit signed integer. + /// + /// See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.next) for more information. + int next() { + final result = _ICU4XWordBreakIteratorUtf16_next(_ffi); + return result; + } + + /// Return the status value of break boundary. + /// + /// See the [Rust documentation for `word_type`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.word_type) for more information. + SegmenterWordType get wordType { + final result = _ICU4XWordBreakIteratorUtf16_word_type(_ffi); + return SegmenterWordType.values[result]; + } + + /// Return true when break boundary is word-like such as letter/number/CJK + /// + /// See the [Rust documentation for `is_word_like`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.is_word_like) for more information. + bool get isWordLike { + final result = _ICU4XWordBreakIteratorUtf16_is_word_like(_ffi); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XWordBreakIteratorUtf16_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XWordBreakIteratorUtf16_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XWordBreakIteratorUtf16_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XWordBreakIteratorUtf16_next') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XWordBreakIteratorUtf16_next') +// ignore: non_constant_identifier_names +external int _ICU4XWordBreakIteratorUtf16_next(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XWordBreakIteratorUtf16_word_type') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XWordBreakIteratorUtf16_word_type') +// ignore: non_constant_identifier_names +external int _ICU4XWordBreakIteratorUtf16_word_type( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XWordBreakIteratorUtf16_is_word_like') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XWordBreakIteratorUtf16_is_word_like') +// ignore: non_constant_identifier_names +external bool _ICU4XWordBreakIteratorUtf16_is_word_like( + ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/WordBreakIteratorUtf8.g.dart b/pkgs/intl4x/lib/src/bindings/WordBreakIteratorUtf8.g.dart deleted file mode 120000 index fa1587d5..00000000 --- a/pkgs/intl4x/lib/src/bindings/WordBreakIteratorUtf8.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/WordBreakIteratorUtf8.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/WordBreakIteratorUtf8.g.dart b/pkgs/intl4x/lib/src/bindings/WordBreakIteratorUtf8.g.dart new file mode 100644 index 00000000..8460986d --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/WordBreakIteratorUtf8.g.dart @@ -0,0 +1,78 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// See the [Rust documentation for `WordBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html) for more information. +final class WordBreakIteratorUtf8 implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + // ignore: unused_field + final core.List _aEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + WordBreakIteratorUtf8._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XWordBreakIteratorUtf8_destroy)); + + /// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + /// out of range of a 32-bit signed integer. + /// + /// See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.next) for more information. + int next() { + final result = _ICU4XWordBreakIteratorUtf8_next(_ffi); + return result; + } + + /// Return the status value of break boundary. + /// + /// See the [Rust documentation for `word_type`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.word_type) for more information. + SegmenterWordType get wordType { + final result = _ICU4XWordBreakIteratorUtf8_word_type(_ffi); + return SegmenterWordType.values[result]; + } + + /// Return true when break boundary is word-like such as letter/number/CJK + /// + /// See the [Rust documentation for `is_word_like`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.is_word_like) for more information. + bool get isWordLike { + final result = _ICU4XWordBreakIteratorUtf8_is_word_like(_ffi); + return result; + } +} + +@meta.ResourceIdentifier('ICU4XWordBreakIteratorUtf8_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XWordBreakIteratorUtf8_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XWordBreakIteratorUtf8_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XWordBreakIteratorUtf8_next') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XWordBreakIteratorUtf8_next') +// ignore: non_constant_identifier_names +external int _ICU4XWordBreakIteratorUtf8_next(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XWordBreakIteratorUtf8_word_type') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XWordBreakIteratorUtf8_word_type') +// ignore: non_constant_identifier_names +external int _ICU4XWordBreakIteratorUtf8_word_type( + ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XWordBreakIteratorUtf8_is_word_like') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XWordBreakIteratorUtf8_is_word_like') +// ignore: non_constant_identifier_names +external bool _ICU4XWordBreakIteratorUtf8_is_word_like( + ffi.Pointer self); diff --git a/pkgs/intl4x/lib/src/bindings/WordSegmenter.g.dart b/pkgs/intl4x/lib/src/bindings/WordSegmenter.g.dart deleted file mode 120000 index c4c5faee..00000000 --- a/pkgs/intl4x/lib/src/bindings/WordSegmenter.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/WordSegmenter.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/WordSegmenter.g.dart b/pkgs/intl4x/lib/src/bindings/WordSegmenter.g.dart new file mode 100644 index 00000000..fa104a78 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/WordSegmenter.g.dart @@ -0,0 +1,130 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An ICU4X word-break segmenter, capable of finding word breakpoints in strings. +/// +/// See the [Rust documentation for `WordSegmenter`](https://docs.rs/icu/latest/icu/segmenter/struct.WordSegmenter.html) for more information. +final class WordSegmenter implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + WordSegmenter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = + ffi.NativeFinalizer(ffi.Native.addressOf(_ICU4XWordSegmenter_destroy)); + + /// Construct an [`WordSegmenter`] with automatically selecting the best available LSTM + /// or dictionary payload data. + /// + /// Note: currently, it uses dictionary for Chinese and Japanese, and LSTM for Burmese, + /// Khmer, Lao, and Thai. + /// + /// See the [Rust documentation for `new_auto`](https://docs.rs/icu/latest/icu/segmenter/struct.WordSegmenter.html#method.new_auto) for more information. + /// + /// Throws [Error] on failure. + factory WordSegmenter.auto(DataProvider provider) { + final result = _ICU4XWordSegmenter_create_auto(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return WordSegmenter._fromFfi(result.union.ok, []); + } + + /// Construct an [`WordSegmenter`] with LSTM payload data for Burmese, Khmer, Lao, and + /// Thai. + /// + /// Warning: [`WordSegmenter`] created by this function doesn't handle Chinese or + /// Japanese. + /// + /// See the [Rust documentation for `new_lstm`](https://docs.rs/icu/latest/icu/segmenter/struct.WordSegmenter.html#method.new_lstm) for more information. + /// + /// Throws [Error] on failure. + factory WordSegmenter.lstm(DataProvider provider) { + final result = _ICU4XWordSegmenter_create_lstm(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return WordSegmenter._fromFfi(result.union.ok, []); + } + + /// Construct an [`WordSegmenter`] with dictionary payload data for Chinese, Japanese, + /// Burmese, Khmer, Lao, and Thai. + /// + /// See the [Rust documentation for `new_dictionary`](https://docs.rs/icu/latest/icu/segmenter/struct.WordSegmenter.html#method.new_dictionary) for more information. + /// + /// Throws [Error] on failure. + factory WordSegmenter.dictionary(DataProvider provider) { + final result = _ICU4XWordSegmenter_create_dictionary(provider._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return WordSegmenter._fromFfi(result.union.ok, []); + } + + /// Segments a string. + /// + /// Ill-formed input is treated as if errors had been replaced with REPLACEMENT CHARACTERs according + /// to the WHATWG Encoding Standard. + /// + /// See the [Rust documentation for `segment_utf16`](https://docs.rs/icu/latest/icu/segmenter/struct.WordSegmenter.html#method.segment_utf16) for more information. + WordBreakIteratorUtf16 segment(String input) { + final inputView = input.utf16View; + final inputArena = _FinalizedArena(); + // This lifetime edge depends on lifetimes: 'a + core.List aEdges = [this, inputArena]; + final result = _ICU4XWordSegmenter_segment_utf16( + _ffi, inputView.allocIn(inputArena.arena), inputView.length); + return WordBreakIteratorUtf16._fromFfi(result, [], aEdges); + } +} + +@meta.ResourceIdentifier('ICU4XWordSegmenter_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XWordSegmenter_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XWordSegmenter_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XWordSegmenter_create_auto') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XWordSegmenter_create_auto') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XWordSegmenter_create_auto( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XWordSegmenter_create_lstm') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XWordSegmenter_create_lstm') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XWordSegmenter_create_lstm( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XWordSegmenter_create_dictionary') +@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer)>( + isLeaf: true, symbol: 'ICU4XWordSegmenter_create_dictionary') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XWordSegmenter_create_dictionary( + ffi.Pointer provider); + +@meta.ResourceIdentifier('ICU4XWordSegmenter_segment_utf16') +@ffi.Native< + ffi.Pointer Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size)>(isLeaf: true, symbol: 'ICU4XWordSegmenter_segment_utf16') +// ignore: non_constant_identifier_names +external ffi.Pointer _ICU4XWordSegmenter_segment_utf16( + ffi.Pointer self, + ffi.Pointer inputData, + int inputLength); diff --git a/pkgs/intl4x/lib/src/bindings/ZonedDateTimeFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/ZonedDateTimeFormatter.g.dart deleted file mode 120000 index fc1cfc80..00000000 --- a/pkgs/intl4x/lib/src/bindings/ZonedDateTimeFormatter.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/ZonedDateTimeFormatter.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/ZonedDateTimeFormatter.g.dart b/pkgs/intl4x/lib/src/bindings/ZonedDateTimeFormatter.g.dart new file mode 100644 index 00000000..a25b8fe4 --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/ZonedDateTimeFormatter.g.dart @@ -0,0 +1,184 @@ +// generated by diplomat-tool + +part of 'lib.g.dart'; + +/// An object capable of formatting a date time with time zone to a string. +/// +/// See the [Rust documentation for `ZonedDateTimeFormatter`](https://docs.rs/icu/latest/icu/datetime/struct.ZonedDateTimeFormatter.html) for more information. +final class ZonedDateTimeFormatter implements ffi.Finalizable { + final ffi.Pointer _ffi; + + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; + + // This takes in a list of lifetime edges (including for &self borrows) + // corresponding to data this may borrow from. These should be flat arrays containing + // references to objects, and this object will hold on to them to keep them alive and + // maintain borrow validity. + ZonedDateTimeFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); + } + } + + static final _finalizer = ffi.NativeFinalizer( + ffi.Native.addressOf(_ICU4XZonedDateTimeFormatter_destroy)); + + /// Creates a new [`ZonedDateTimeFormatter`] from locale data. + /// + /// This function has `date_length` and `time_length` arguments and uses default options + /// for the time zone. + /// + /// See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.ZonedDateTimeFormatter.html#method.try_new) for more information. + /// + /// Throws [Error] on failure. + factory ZonedDateTimeFormatter.withLengths(DataProvider provider, + Locale locale, DateLength dateLength, TimeLength timeLength) { + final result = _ICU4XZonedDateTimeFormatter_create_with_lengths( + provider._ffi, locale._ffi, dateLength.index, timeLength.index); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return ZonedDateTimeFormatter._fromFfi(result.union.ok, []); + } + + /// Creates a new [`ZonedDateTimeFormatter`] from locale data. + /// + /// This function has `date_length` and `time_length` arguments and uses an ISO-8601 style + /// fallback for the time zone with the given configurations. + /// + /// See the [Rust documentation for `try_new`](https://docs.rs/icu/latest/icu/datetime/struct.ZonedDateTimeFormatter.html#method.try_new) for more information. + /// + /// Throws [Error] on failure. + factory ZonedDateTimeFormatter.withLengthsAndIso8601TimeZoneFallback( + DataProvider provider, + Locale locale, + DateLength dateLength, + TimeLength timeLength, + IsoTimeZoneOptions zoneOptions) { + final temp = ffi2.Arena(); + final result = + _ICU4XZonedDateTimeFormatter_create_with_lengths_and_iso_8601_time_zone_fallback( + provider._ffi, + locale._ffi, + dateLength.index, + timeLength.index, + zoneOptions._toFfi(temp)); + temp.releaseAll(); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return ZonedDateTimeFormatter._fromFfi(result.union.ok, []); + } + + /// Formats a [`DateTime`] and [`CustomTimeZone`] to a string. + /// + /// See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.ZonedDateTimeFormatter.html#method.format) for more information. + /// + /// Throws [Error] on failure. + String formatDatetimeWithCustomTimeZone( + DateTime datetime, CustomTimeZone timeZone) { + final writeable = _Writeable(); + final result = + _ICU4XZonedDateTimeFormatter_format_datetime_with_custom_time_zone( + _ffi, datetime._ffi, timeZone._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } + + /// Formats a [`IsoDateTime`] and [`CustomTimeZone`] to a string. + /// + /// See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.ZonedDateTimeFormatter.html#method.format) for more information. + /// + /// Throws [Error] on failure. + String formatIsoDatetimeWithCustomTimeZone( + IsoDateTime datetime, CustomTimeZone timeZone) { + final writeable = _Writeable(); + final result = + _ICU4XZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone( + _ffi, datetime._ffi, timeZone._ffi, writeable._ffi); + if (!result.isOk) { + throw Error.values.firstWhere((v) => v._ffi == result.union.err); + } + return writeable.finalize(); + } +} + +@meta.ResourceIdentifier('ICU4XZonedDateTimeFormatter_destroy') +@ffi.Native)>( + isLeaf: true, symbol: 'ICU4XZonedDateTimeFormatter_destroy') +// ignore: non_constant_identifier_names +external void _ICU4XZonedDateTimeFormatter_destroy(ffi.Pointer self); + +@meta.ResourceIdentifier('ICU4XZonedDateTimeFormatter_create_with_lengths') +@ffi.Native< + _ResultOpaqueInt32 Function(ffi.Pointer, + ffi.Pointer, ffi.Int32, ffi.Int32)>( + isLeaf: true, symbol: 'ICU4XZonedDateTimeFormatter_create_with_lengths') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 _ICU4XZonedDateTimeFormatter_create_with_lengths( + ffi.Pointer provider, + ffi.Pointer locale, + int dateLength, + int timeLength); + +@meta.ResourceIdentifier( + 'ICU4XZonedDateTimeFormatter_create_with_lengths_and_iso_8601_time_zone_fallback') +@ffi.Native< + _ResultOpaqueInt32 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int32, + ffi.Int32, + _IsoTimeZoneOptionsFfi)>( + isLeaf: true, + symbol: + 'ICU4XZonedDateTimeFormatter_create_with_lengths_and_iso_8601_time_zone_fallback') +// ignore: non_constant_identifier_names +external _ResultOpaqueInt32 + _ICU4XZonedDateTimeFormatter_create_with_lengths_and_iso_8601_time_zone_fallback( + ffi.Pointer provider, + ffi.Pointer locale, + int dateLength, + int timeLength, + _IsoTimeZoneOptionsFfi zoneOptions); + +@meta.ResourceIdentifier( + 'ICU4XZonedDateTimeFormatter_format_datetime_with_custom_time_zone') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>( + isLeaf: true, + symbol: 'ICU4XZonedDateTimeFormatter_format_datetime_with_custom_time_zone') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 + _ICU4XZonedDateTimeFormatter_format_datetime_with_custom_time_zone( + ffi.Pointer self, + ffi.Pointer datetime, + ffi.Pointer timeZone, + ffi.Pointer writeable); + +@meta.ResourceIdentifier( + 'ICU4XZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone') +@ffi.Native< + _ResultVoidInt32 Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Pointer)>( + isLeaf: true, + symbol: + 'ICU4XZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone') +// ignore: non_constant_identifier_names +external _ResultVoidInt32 + _ICU4XZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone( + ffi.Pointer self, + ffi.Pointer datetime, + ffi.Pointer timeZone, + ffi.Pointer writeable); diff --git a/pkgs/intl4x/lib/src/bindings/lib.g.dart b/pkgs/intl4x/lib/src/bindings/lib.g.dart deleted file mode 120000 index 69d6313b..00000000 --- a/pkgs/intl4x/lib/src/bindings/lib.g.dart +++ /dev/null @@ -1 +0,0 @@ -../../../../../submodules/icu4x/ffi/capi/bindings/dart/lib.g.dart \ No newline at end of file diff --git a/pkgs/intl4x/lib/src/bindings/lib.g.dart b/pkgs/intl4x/lib/src/bindings/lib.g.dart new file mode 100644 index 00000000..3b27dc8c --- /dev/null +++ b/pkgs/intl4x/lib/src/bindings/lib.g.dart @@ -0,0 +1,787 @@ +// generated by diplomat-tool + +import 'dart:convert'; +import 'dart:core' as core; +import 'dart:core' show int, double, bool, String, Object, override; +import 'dart:ffi' as ffi; +import 'dart:math'; +import 'dart:typed_data'; +import 'package:ffi/ffi.dart' as ffi2 show Arena, calloc; +import 'package:meta/meta.dart' as meta; +part 'AnyCalendarKind.g.dart'; +part 'Bcp47ToIanaMapper.g.dart'; +part 'Bidi.g.dart'; +part 'BidiDirection.g.dart'; +part 'BidiInfo.g.dart'; +part 'BidiParagraph.g.dart'; +part 'Calendar.g.dart'; +part 'CanonicalCombiningClassMap.g.dart'; +part 'CanonicalComposition.g.dart'; +part 'CanonicalDecomposition.g.dart'; +part 'CaseMapCloser.g.dart'; +part 'CaseMapper.g.dart'; +part 'CodePointMapData16.g.dart'; +part 'CodePointMapData8.g.dart'; +part 'CodePointRangeIterator.g.dart'; +part 'CodePointRangeIteratorResult.g.dart'; +part 'CodePointSetBuilder.g.dart'; +part 'CodePointSetData.g.dart'; +part 'Collator.g.dart'; +part 'CollatorAlternateHandling.g.dart'; +part 'CollatorBackwardSecondLevel.g.dart'; +part 'CollatorCaseFirst.g.dart'; +part 'CollatorCaseLevel.g.dart'; +part 'CollatorMaxVariable.g.dart'; +part 'CollatorNumeric.g.dart'; +part 'CollatorOptions.g.dart'; +part 'CollatorStrength.g.dart'; +part 'ComposingNormalizer.g.dart'; +part 'CustomTimeZone.g.dart'; +part 'DataProvider.g.dart'; +part 'Date.g.dart'; +part 'DateFormatter.g.dart'; +part 'DateLength.g.dart'; +part 'DateTime.g.dart'; +part 'DateTimeFormatter.g.dart'; +part 'Decomposed.g.dart'; +part 'DecomposingNormalizer.g.dart'; +part 'DisplayNamesFallback.g.dart'; +part 'DisplayNamesOptions.g.dart'; +part 'DisplayNamesStyle.g.dart'; +part 'Error.g.dart'; +part 'FixedDecimal.g.dart'; +part 'FixedDecimalFormatter.g.dart'; +part 'FixedDecimalGroupingStrategy.g.dart'; +part 'FixedDecimalSign.g.dart'; +part 'FixedDecimalSignDisplay.g.dart'; +part 'GeneralCategoryNameToMaskMapper.g.dart'; +part 'GraphemeClusterBreakIteratorLatin1.g.dart'; +part 'GraphemeClusterBreakIteratorUtf16.g.dart'; +part 'GraphemeClusterBreakIteratorUtf8.g.dart'; +part 'GraphemeClusterSegmenter.g.dart'; +part 'GregorianDateFormatter.g.dart'; +part 'GregorianDateTimeFormatter.g.dart'; +part 'GregorianZonedDateTimeFormatter.g.dart'; +part 'IanaToBcp47Mapper.g.dart'; +part 'IsoDate.g.dart'; +part 'IsoDateTime.g.dart'; +part 'IsoTimeZoneFormat.g.dart'; +part 'IsoTimeZoneMinuteDisplay.g.dart'; +part 'IsoTimeZoneOptions.g.dart'; +part 'IsoTimeZoneSecondDisplay.g.dart'; +part 'IsoWeekday.g.dart'; +part 'LanguageDisplay.g.dart'; +part 'LeadingAdjustment.g.dart'; +part 'LineBreakIteratorLatin1.g.dart'; +part 'LineBreakIteratorUtf16.g.dart'; +part 'LineBreakIteratorUtf8.g.dart'; +part 'LineBreakOptions.g.dart'; +part 'LineBreakStrictness.g.dart'; +part 'LineBreakWordOption.g.dart'; +part 'LineSegmenter.g.dart'; +part 'ListFormatter.g.dart'; +part 'ListLength.g.dart'; +part 'Locale.g.dart'; +part 'LocaleCanonicalizer.g.dart'; +part 'LocaleDirection.g.dart'; +part 'LocaleDirectionality.g.dart'; +part 'LocaleDisplayNamesFormatter.g.dart'; +part 'LocaleExpander.g.dart'; +part 'LocaleFallbackConfig.g.dart'; +part 'LocaleFallbackIterator.g.dart'; +part 'LocaleFallbackPriority.g.dart'; +part 'LocaleFallbackSupplement.g.dart'; +part 'LocaleFallbacker.g.dart'; +part 'LocaleFallbackerWithConfig.g.dart'; +part 'Logger.g.dart'; +part 'MetazoneCalculator.g.dart'; +part 'PluralCategories.g.dart'; +part 'PluralCategory.g.dart'; +part 'PluralOperands.g.dart'; +part 'PluralRules.g.dart'; +part 'PropertyValueNameToEnumMapper.g.dart'; +part 'RegionDisplayNames.g.dart'; +part 'ReorderedIndexMap.g.dart'; +part 'ResolvedCollatorOptions.g.dart'; +part 'RoundingIncrement.g.dart'; +part 'ScriptExtensionsSet.g.dart'; +part 'ScriptWithExtensions.g.dart'; +part 'ScriptWithExtensionsBorrowed.g.dart'; +part 'SegmenterWordType.g.dart'; +part 'SentenceBreakIteratorLatin1.g.dart'; +part 'SentenceBreakIteratorUtf16.g.dart'; +part 'SentenceBreakIteratorUtf8.g.dart'; +part 'SentenceSegmenter.g.dart'; +part 'Time.g.dart'; +part 'TimeFormatter.g.dart'; +part 'TimeLength.g.dart'; +part 'TimeZoneFormatter.g.dart'; +part 'TitlecaseMapper.g.dart'; +part 'TitlecaseOptions.g.dart'; +part 'TrailingCase.g.dart'; +part 'TransformResult.g.dart'; +part 'UnicodeSetData.g.dart'; +part 'WeekCalculator.g.dart'; +part 'WeekOf.g.dart'; +part 'WeekRelativeUnit.g.dart'; +part 'WeekendContainsDay.g.dart'; +part 'WordBreakIteratorLatin1.g.dart'; +part 'WordBreakIteratorUtf16.g.dart'; +part 'WordBreakIteratorUtf8.g.dart'; +part 'WordSegmenter.g.dart'; +part 'ZonedDateTimeFormatter.g.dart'; + +/// A [Rune] is a Unicode code point, such as `a`, or `💡`. +/// +/// The recommended way to obtain a [Rune] is to create it from a +/// [String], which is conceptually a list of [Runes]. For example, +/// `'a'.runes.first` is equal to the [Rune] `a`. +/// +/// Dart does not have a character/rune literal, so integer literals +/// need to be used. For example the Unicode code point U+1F4A1, `💡`, +/// can be represented by `0x1F4A1`. Note that only values in the ranges +/// `0x0..0xD7FF` and `0xE000..0x10FFFF` (both inclusive) are Unicode +/// code points, and hence valid [Rune]s. +/// +/// A [String] can be constructed from a [Rune] using [String.fromCharCode]. +typedef Rune = int; + +// ignore: unused_element +final _callocFree = core.Finalizer(ffi2.calloc.free); + +// ignore: unused_element +final _nopFree = core.Finalizer((nothing) => {}); + +// ignore: unused_element +final _rustFree = core.Finalizer( + (({ffi.Pointer pointer, int bytes, int align}) record) => + _diplomat_free(record.pointer, record.bytes, record.align)); + +final class _RustAlloc implements ffi.Allocator { + @override + ffi.Pointer allocate(int byteCount, + {int? alignment}) { + return _diplomat_alloc(byteCount, alignment ?? 1).cast(); + } + + void free(ffi.Pointer pointer) { + throw 'Internal error: should not deallocate in Rust memory'; + } +} + +@meta.ResourceIdentifier('diplomat_alloc') +@ffi.Native Function(ffi.Size, ffi.Size)>( + symbol: 'diplomat_alloc', isLeaf: true) +// ignore: non_constant_identifier_names +external ffi.Pointer _diplomat_alloc(int len, int align); + +@meta.ResourceIdentifier('diplomat_free') +@ffi.Native, ffi.Size, ffi.Size)>( + symbol: 'diplomat_free', isLeaf: true) +// ignore: non_constant_identifier_names +external int _diplomat_free(ffi.Pointer ptr, int len, int align); + +// ignore: unused_element +class _FinalizedArena { + final ffi2.Arena arena; + static final core.Finalizer _finalizer = + core.Finalizer((arena) => arena.releaseAll()); + + // ignore: unused_element + _FinalizedArena() : arena = ffi2.Arena() { + _finalizer.attach(this, arena); + } + + // ignore: unused_element + _FinalizedArena.withLifetime(core.List> lifetimeAppendArray) + : arena = ffi2.Arena() { + _finalizer.attach(this, arena); + for (final edge in lifetimeAppendArray) { + edge.add(this); + } + } +} + +extension on ByteBuffer { + // ignore: unused_element + ffi.Pointer allocIn(ffi.Allocator alloc) { + return alloc(length) + ..asTypedList(length).setRange(0, length, asUint8List()); + } + + int get length => lengthInBytes; +} + +extension on String { + // ignore: unused_element + _Utf8View get utf8View => _Utf8View(this); + // ignore: unused_element + _Utf16View get utf16View => _Utf16View(this); +} + +extension on core.List { + // ignore: unused_element + _ListUtf8View get utf8View => _ListUtf8View(this); + // ignore: unused_element + _ListUtf16View get utf16View => _ListUtf16View(this); +} + +extension on core.List { + // ignore: unused_element + _BoolListView get boolView => _BoolListView(this); +} + +extension on core.List { + // ignore: unused_element + _Int8ListView get int8View => _Int8ListView(this); + // ignore: unused_element + _Int16ListView get int16View => _Int16ListView(this); + // ignore: unused_element + _Int32ListView get int32View => _Int32ListView(this); + // ignore: unused_element + _Int64ListView get int64View => _Int64ListView(this); + // ignore: unused_element + _IsizeListView get isizeView => _IsizeListView(this); + // ignore: unused_element + _Uint8ListView get uint8View => _Uint8ListView(this); + // ignore: unused_element + _Uint16ListView get uint16View => _Uint16ListView(this); + // ignore: unused_element + _Uint32ListView get uint32View => _Uint32ListView(this); + // ignore: unused_element + _Uint64ListView get uint64View => _Uint64ListView(this); + // ignore: unused_element + _UsizeListView get usizeView => _UsizeListView(this); +} + +extension on core.List { + // ignore: unused_element + _Float32ListView get float32View => _Float32ListView(this); + // ignore: unused_element + _Float64ListView get float64View => _Float64ListView(this); +} + +// ignore: unused_element +class _Utf8View { + final Uint8List _codeUnits; + + // Copies + _Utf8View(String string) : _codeUnits = Utf8Encoder().convert(string); + + ffi.Pointer allocIn(ffi.Allocator alloc) { + // Copies + return alloc(length) + ..asTypedList(length).setRange(0, length, _codeUnits); + } + + int get length => _codeUnits.length; +} + +// ignore: unused_element +class _Utf16View { + final core.List _codeUnits; + + _Utf16View(String string) : _codeUnits = string.codeUnits; + + ffi.Pointer allocIn(ffi.Allocator alloc) { + // Copies + return alloc(length) + ..asTypedList(length).setRange(0, length, _codeUnits); + } + + int get length => _codeUnits.length; +} + +// ignore: unused_element +class _ListUtf8View { + final core.List _strings; + + // Copies + _ListUtf8View(this._strings); + + ffi.Pointer<_SliceUtf8> allocIn(ffi.Allocator alloc) { + final slice = alloc<_SliceUtf8>(length); + for (var i = 0; i < length; i++) { + final codeUnits = Utf8Encoder().convert(_strings[i]); + final str = alloc(codeUnits.length) + ..asTypedList(codeUnits.length) + .setRange(0, codeUnits.length, codeUnits); + slice[i]._data = str; + slice[i]._length = codeUnits.length; + } + return slice; + } + + int get length => _strings.length; +} + +// ignore: unused_element +class _ListUtf16View { + final core.List _strings; + + _ListUtf16View(this._strings); + + ffi.Pointer<_SliceUtf16> allocIn(ffi.Allocator alloc) { + final slice = alloc<_SliceUtf16>(length); + for (var i = 0; i < length; i++) { + final codeUnits = _strings[i].codeUnits; + final str = alloc(codeUnits.length) + ..asTypedList(codeUnits.length) + .setRange(0, codeUnits.length, codeUnits); + slice[i]._data = str; + slice[i]._length = codeUnits.length; + } + return slice; + } + + int get length => _strings.length; +} + +// ignore: unused_element +class _BoolListView { + final core.List _values; + + _BoolListView(this._values); + + // Copies + ffi.Pointer allocIn(ffi.Allocator alloc) { + final pointer = alloc(_values.length); + for (var i = 0; i < _values.length; i++) { + pointer[i] = _values[i]; + } + return pointer; + } + + int get length => _values.length; +} + +class _Int8ListView { + final core.List _values; + + _Int8ListView(this._values); + + // ignore: unused_element + ffi.Pointer allocIn(ffi.Allocator alloc) { + return alloc(length) + ..asTypedList(length).setRange(0, length, _values); + } + + int get length => _values.length; +} + +class _Int16ListView { + final core.List _values; + + _Int16ListView(this._values); + + // ignore: unused_element + ffi.Pointer allocIn(ffi.Allocator alloc) { + return alloc(length) + ..asTypedList(length).setRange(0, length, _values); + } + + int get length => _values.length; +} + +class _Int32ListView { + final core.List _values; + + _Int32ListView(this._values); + + // ignore: unused_element + ffi.Pointer allocIn(ffi.Allocator alloc) { + return alloc(length) + ..asTypedList(length).setRange(0, length, _values); + } + + int get length => _values.length; +} + +class _Int64ListView { + final core.List _values; + + _Int64ListView(this._values); + + // ignore: unused_element + ffi.Pointer allocIn(ffi.Allocator alloc) { + return alloc(length) + ..asTypedList(length).setRange(0, length, _values); + } + + int get length => _values.length; +} + +// ignore: unused_element +class _IsizeListView { + final core.List _values; + + _IsizeListView(this._values); + + // Copies + ffi.Pointer allocIn(ffi.Allocator alloc) { + final pointer = alloc(_values.length); + for (var i = 0; i < _values.length; i++) { + pointer[i] = _values[i]; + } + return pointer; + } + + int get length => _values.length; +} + +class _Uint8ListView { + final core.List _values; + + _Uint8ListView(this._values); + + // ignore: unused_element + ffi.Pointer allocIn(ffi.Allocator alloc) { + final pointer = alloc(_values.length); + for (var i = 0; i < _values.length; i++) { + pointer[i] = min(255, max(0, _values[i])); + } + return pointer; + } + + int get length => _values.length; +} + +class _Uint16ListView { + final core.List _values; + + _Uint16ListView(this._values); + + // ignore: unused_element + ffi.Pointer allocIn(ffi.Allocator alloc) { + final pointer = alloc(_values.length); + for (var i = 0; i < _values.length; i++) { + pointer[i] = min(65535, max(0, _values[i])); + } + return pointer; + } + + int get length => _values.length; +} + +class _Uint32ListView { + final core.List _values; + + _Uint32ListView(this._values); + + // ignore: unused_element + ffi.Pointer allocIn(ffi.Allocator alloc) { + final pointer = alloc(_values.length); + for (var i = 0; i < _values.length; i++) { + pointer[i] = min(4294967295, max(0, _values[i])); + } + return pointer; + } + + int get length => _values.length; +} + +class _Uint64ListView { + final core.List _values; + + _Uint64ListView(this._values); + + // ignore: unused_element + ffi.Pointer allocIn(ffi.Allocator alloc) { + final pointer = alloc(_values.length); + for (var i = 0; i < _values.length; i++) { + pointer[i] = max(0, _values[i]); + } + return pointer; + } + + int get length => _values.length; +} + +// ignore: unused_element +class _UsizeListView { + final core.List _values; + + _UsizeListView(this._values); + + // Copies + ffi.Pointer allocIn(ffi.Allocator alloc) { + final pointer = alloc(_values.length); + for (var i = 0; i < _values.length; i++) { + pointer[i] = max(0, _values[i]); + } + return pointer; + } + + int get length => _values.length; +} + +class _Float32ListView { + final core.List _values; + + _Float32ListView(this._values); + + // ignore: unused_element + ffi.Pointer allocIn(ffi.Allocator alloc) { + return alloc(length) + ..asTypedList(length).setRange(0, length, _values); + } + + int get length => _values.length; +} + +class _Float64ListView { + final core.List _values; + + _Float64ListView(this._values); + + // ignore: unused_element + ffi.Pointer allocIn(ffi.Allocator alloc) { + return alloc(length) + ..asTypedList(length).setRange(0, length, _values); + } + + int get length => _values.length; +} + +final class _ResultBoolInt32Union extends ffi.Union { + @ffi.Bool() + external bool ok; + + @ffi.Int32() + external int err; +} + +final class _ResultBoolInt32 extends ffi.Struct { + external _ResultBoolInt32Union union; + + @ffi.Bool() + external bool isOk; +} + +final class _ResultInt32Int32Union extends ffi.Union { + @ffi.Int32() + external int ok; + + @ffi.Int32() + external int err; +} + +final class _ResultInt32Int32 extends ffi.Struct { + external _ResultInt32Int32Union union; + + @ffi.Bool() + external bool isOk; +} + +final class _ResultInt32VoidUnion extends ffi.Union { + @ffi.Int32() + external int ok; +} + +final class _ResultInt32Void extends ffi.Struct { + external _ResultInt32VoidUnion union; + + @ffi.Bool() + external bool isOk; +} + +final class _ResultOpaqueInt32Union extends ffi.Union { + external ffi.Pointer ok; + + @ffi.Int32() + external int err; +} + +final class _ResultOpaqueInt32 extends ffi.Struct { + external _ResultOpaqueInt32Union union; + + @ffi.Bool() + external bool isOk; +} + +final class _ResultUint16VoidUnion extends ffi.Union { + @ffi.Uint16() + external int ok; +} + +final class _ResultUint16Void extends ffi.Struct { + external _ResultUint16VoidUnion union; + + @ffi.Bool() + external bool isOk; +} + +final class _ResultVoidInt32Union extends ffi.Union { + @ffi.Int32() + external int err; +} + +final class _ResultVoidInt32 extends ffi.Struct { + external _ResultVoidInt32Union union; + + @ffi.Bool() + external bool isOk; +} + +final class _ResultVoidVoid extends ffi.Struct { + @ffi.Bool() + external bool isOk; +} + +final class _ResultWeekOfFfiInt32Union extends ffi.Union { + external _WeekOfFfi ok; + + @ffi.Int32() + external int err; +} + +final class _ResultWeekOfFfiInt32 extends ffi.Struct { + external _ResultWeekOfFfiInt32Union union; + + @ffi.Bool() + external bool isOk; +} + +final class _SliceUsize extends ffi.Struct { + external ffi.Pointer _data; + + @ffi.Size() + external int _length; + + // This is expensive + @override + bool operator ==(Object other) { + if (other is! _SliceUsize || other._length != _length) { + return false; + } + + for (var i = 0; i < _length; i++) { + if (other._data[i] != _data[i]) { + return false; + } + } + return true; + } + + // This is cheap + @override + int get hashCode => _length.hashCode; + + core.List _toDart(core.List lifetimeEdges) { + final r = core.Iterable.generate(_length) + .map((i) => _data[i]) + .toList(growable: false); + if (lifetimeEdges.isEmpty) { + _diplomat_free(_data.cast(), _length * ffi.sizeOf(), + ffi.sizeOf()); + } + return r; + } +} + +final class _SliceUtf16 extends ffi.Struct { + external ffi.Pointer _data; + + @ffi.Size() + external int _length; + + // This is expensive + @override + bool operator ==(Object other) { + if (other is! _SliceUtf16 || other._length != _length) { + return false; + } + + for (var i = 0; i < _length; i++) { + if (other._data[i] != _data[i]) { + return false; + } + } + return true; + } + + // This is cheap + @override + int get hashCode => _length.hashCode; + + String _toDart(core.List lifetimeEdges) { + final r = core.String.fromCharCodes(_data.asTypedList(_length)); + if (lifetimeEdges.isEmpty) { + _diplomat_free(_data.cast(), _length * 2, 2); + } + return r; + } +} + +final class _SliceUtf8 extends ffi.Struct { + external ffi.Pointer _data; + + @ffi.Size() + external int _length; + + // This is expensive + @override + bool operator ==(Object other) { + if (other is! _SliceUtf8 || other._length != _length) { + return false; + } + + for (var i = 0; i < _length; i++) { + if (other._data[i] != _data[i]) { + return false; + } + } + return true; + } + + // This is cheap + @override + int get hashCode => _length.hashCode; + + String _toDart(core.List lifetimeEdges) { + final r = Utf8Decoder().convert(_data.asTypedList(_length)); + if (lifetimeEdges.isEmpty) { + _diplomat_free(_data.cast(), _length, 1); + } + return r; + } +} + +final class _Writeable { + final ffi.Pointer _ffi; + + _Writeable() : _ffi = _diplomat_buffer_writeable_create(0); + + String finalize() { + final string = Utf8Decoder().convert( + _diplomat_buffer_writeable_get_bytes(_ffi) + .asTypedList(_diplomat_buffer_writeable_len(_ffi))); + _diplomat_buffer_writeable_destroy(_ffi); + return string; + } +} + +@meta.ResourceIdentifier('diplomat_buffer_writeable_create') +@ffi.Native Function(ffi.Size)>( + symbol: 'diplomat_buffer_writeable_create', isLeaf: true) +// ignore: non_constant_identifier_names +external ffi.Pointer _diplomat_buffer_writeable_create(int len); + +@meta.ResourceIdentifier('diplomat_buffer_writeable_len') +@ffi.Native)>( + symbol: 'diplomat_buffer_writeable_len', isLeaf: true) +// ignore: non_constant_identifier_names +external int _diplomat_buffer_writeable_len(ffi.Pointer ptr); + +@meta.ResourceIdentifier('diplomat_buffer_writeable_get_bytes') +@ffi.Native Function(ffi.Pointer)>( + symbol: 'diplomat_buffer_writeable_get_bytes', isLeaf: true) +// ignore: non_constant_identifier_names +external ffi.Pointer _diplomat_buffer_writeable_get_bytes( + ffi.Pointer ptr); + +@meta.ResourceIdentifier('diplomat_buffer_writeable_destroy') +@ffi.Native)>( + symbol: 'diplomat_buffer_writeable_destroy', isLeaf: true) +// ignore: non_constant_identifier_names +external void _diplomat_buffer_writeable_destroy(ffi.Pointer ptr); diff --git a/pkgs/intl4x/pubspec.yaml b/pkgs/intl4x/pubspec.yaml index 85647277..0b875615 100644 --- a/pkgs/intl4x/pubspec.yaml +++ b/pkgs/intl4x/pubspec.yaml @@ -1,7 +1,7 @@ name: intl4x description: >- A lightweight modular library for internationalization (i18n) functionality. -version: 0.9.1 +version: 0.9.2-wip repository: https://github.com/dart-lang/i18n/tree/main/pkgs/intl4x platforms: web: diff --git a/submodules/icu4x b/submodules/icu4x index 9b905e2f..fb38fc8d 160000 --- a/submodules/icu4x +++ b/submodules/icu4x @@ -1 +1 @@ -Subproject commit 9b905e2f1e85453e39c0eb23e68145f7d4aa8553 +Subproject commit fb38fc8d01a5c181de6eca523dedf28bc74fd1e9 diff --git a/tools/regenerate_bindings.sh b/tools/regenerate_bindings.sh index 62680783..d9645131 100644 --- a/tools/regenerate_bindings.sh +++ b/tools/regenerate_bindings.sh @@ -1,3 +1,4 @@ rm pkgs/intl4x/lib/src/bindings/* cd pkgs/intl4x/lib/src/bindings/ -ln -s ../../../../../submodules/icu4x/ffi/capi/bindings/dart/*.dart . +cp -a ../../../../../submodules/icu4x/ffi/capi/bindings/dart/*.dart . +dart format . \ No newline at end of file