From 2687786b816720a286be4b7f337b7dc69e354178 Mon Sep 17 00:00:00 2001 From: Robert Bastian <4706271+robertbastian@users.noreply.github.com> Date: Fri, 8 Mar 2024 14:21:44 +0100 Subject: [PATCH] Bump diplomat (#4671) And fix some Dart renames --- .github/workflows/artifacts-build.yml | 2 +- .github/workflows/build-test.yml | 2 +- Cargo.lock | 8 +- Cargo.toml | 8 +- ffi/capi/bindings/dart/AnyCalendarKind.g.dart | 17 +- .../bindings/dart/Bcp47ToIanaMapper.g.dart | 35 +- ffi/capi/bindings/dart/Bidi.g.dart | 49 +- ffi/capi/bindings/dart/BidiDirection.g.dart | 3 - ffi/capi/bindings/dart/BidiInfo.g.dart | 42 +- ffi/capi/bindings/dart/BidiParagraph.g.dart | 56 +- ffi/capi/bindings/dart/Calendar.g.dart | 41 +- .../dart/CanonicalCombiningClassMap.g.dart | 33 +- .../bindings/dart/CanonicalComposition.g.dart | 33 +- .../dart/CanonicalDecomposition.g.dart | 35 +- ffi/capi/bindings/dart/CaseMapCloser.g.dart | 37 +- ffi/capi/bindings/dart/CaseMapper.g.dart | 85 ++- .../bindings/dart/CodePointMapData16.g.dart | 51 +- .../bindings/dart/CodePointMapData8.g.dart | 123 ++-- .../dart/CodePointRangeIterator.g.dart | 30 +- .../dart/CodePointRangeIteratorResult.g.dart | 38 +- .../bindings/dart/CodePointSetBuilder.g.dart | 87 ++- .../bindings/dart/CodePointSetData.g.dart | 573 +++++++++--------- ffi/capi/bindings/dart/Collator.g.dart | 41 +- .../dart/CollatorAlternateHandling.g.dart | 3 - .../dart/CollatorBackwardSecondLevel.g.dart | 3 - .../bindings/dart/CollatorCaseFirst.g.dart | 3 - .../bindings/dart/CollatorCaseLevel.g.dart | 3 - .../bindings/dart/CollatorMaxVariable.g.dart | 3 - ffi/capi/bindings/dart/CollatorNumeric.g.dart | 3 - ffi/capi/bindings/dart/CollatorOptions.g.dart | 70 +-- .../bindings/dart/CollatorStrength.g.dart | 3 - .../bindings/dart/ComposingNormalizer.g.dart | 47 +- ffi/capi/bindings/dart/CustomTimeZone.g.dart | 155 +++-- ffi/capi/bindings/dart/DataProvider.g.dart | 61 +- ffi/capi/bindings/dart/Date.g.dart | 109 ++-- ffi/capi/bindings/dart/DateFormatter.g.dart | 53 +- ffi/capi/bindings/dart/DateLength.g.dart | 3 - ffi/capi/bindings/dart/DateTime.g.dart | 143 +++-- .../bindings/dart/DateTimeFormatter.g.dart | 41 +- ffi/capi/bindings/dart/Decomposed.g.dart | 30 +- .../dart/DecomposingNormalizer.g.dart | 47 +- .../bindings/dart/DisplayNamesFallback.g.dart | 3 - .../bindings/dart/DisplayNamesOptions.g.dart | 38 +- .../bindings/dart/DisplayNamesStyle.g.dart | 3 - ffi/capi/bindings/dart/Error.g.dart | 5 +- ffi/capi/bindings/dart/FixedDecimal.g.dart | 191 +++--- .../dart/FixedDecimalFormatter.g.dart | 35 +- .../dart/FixedDecimalGroupingStrategy.g.dart | 3 - .../bindings/dart/FixedDecimalSign.g.dart | 3 - .../dart/FixedDecimalSignDisplay.g.dart | 3 - .../GeneralCategoryNameToMaskMapper.g.dart | 37 +- .../GraphemeClusterBreakIteratorLatin1.g.dart | 28 +- .../GraphemeClusterBreakIteratorUtf16.g.dart | 28 +- .../GraphemeClusterBreakIteratorUtf8.g.dart | 28 +- .../dart/GraphemeClusterSegmenter.g.dart | 35 +- .../dart/GregorianDateFormatter.g.dart | 41 +- .../dart/GregorianDateTimeFormatter.g.dart | 35 +- .../GregorianZonedDateTimeFormatter.g.dart | 43 +- .../bindings/dart/IanaToBcp47Mapper.g.dart | 29 +- ffi/capi/bindings/dart/IsoDate.g.dart | 89 ++- ffi/capi/bindings/dart/IsoDateTime.g.dart | 131 ++-- .../bindings/dart/IsoTimeZoneFormat.g.dart | 3 - .../dart/IsoTimeZoneMinuteDisplay.g.dart | 3 - .../bindings/dart/IsoTimeZoneOptions.g.dart | 38 +- .../dart/IsoTimeZoneSecondDisplay.g.dart | 3 - ffi/capi/bindings/dart/IsoWeekday.g.dart | 5 +- ffi/capi/bindings/dart/LanguageDisplay.g.dart | 3 - .../bindings/dart/LeadingAdjustment.g.dart | 3 - .../dart/LineBreakIteratorLatin1.g.dart | 28 +- .../dart/LineBreakIteratorUtf16.g.dart | 28 +- .../dart/LineBreakIteratorUtf8.g.dart | 28 +- .../bindings/dart/LineBreakOptions.g.dart | 38 +- .../bindings/dart/LineBreakStrictness.g.dart | 3 - .../bindings/dart/LineBreakWordOption.g.dart | 3 - ffi/capi/bindings/dart/LineSegmenter.g.dart | 75 ++- ffi/capi/bindings/dart/List.g.dart | 41 +- ffi/capi/bindings/dart/ListFormatter.g.dart | 51 +- ffi/capi/bindings/dart/ListLength.g.dart | 3 - ffi/capi/bindings/dart/Locale.g.dart | 115 ++-- .../bindings/dart/LocaleCanonicalizer.g.dart | 41 +- ffi/capi/bindings/dart/LocaleDirection.g.dart | 3 - .../bindings/dart/LocaleDirectionality.g.dart | 49 +- .../dart/LocaleDisplayNamesFormatter.g.dart | 35 +- ffi/capi/bindings/dart/LocaleExpander.g.dart | 45 +- .../bindings/dart/LocaleFallbackConfig.g.dart | 51 +- .../dart/LocaleFallbackIterator.g.dart | 34 +- .../dart/LocaleFallbackPriority.g.dart | 3 - .../dart/LocaleFallbackSupplement.g.dart | 3 - .../bindings/dart/LocaleFallbacker.g.dart | 41 +- .../dart/LocaleFallbackerWithConfig.g.dart | 30 +- ffi/capi/bindings/dart/Logger.g.dart | 25 +- .../bindings/dart/MetazoneCalculator.g.dart | 29 +- ffi/capi/bindings/dart/Ordering.g.dart | 5 +- .../bindings/dart/PluralCategories.g.dart | 60 +- ffi/capi/bindings/dart/PluralCategory.g.dart | 7 +- ffi/capi/bindings/dart/PluralOperands.g.dart | 29 +- ffi/capi/bindings/dart/PluralRules.g.dart | 47 +- .../dart/PropertyValueNameToEnumMapper.g.dart | 101 ++- .../bindings/dart/RegionDisplayNames.g.dart | 35 +- .../bindings/dart/ReorderedIndexMap.g.dart | 39 +- .../dart/ResolvedCollatorOptions.g.dart | 70 +-- .../bindings/dart/RoundingIncrement.g.dart | 3 - .../bindings/dart/ScriptExtensionsSet.g.dart | 36 +- .../bindings/dart/ScriptWithExtensions.g.dart | 49 +- .../dart/ScriptWithExtensionsBorrowed.g.dart | 44 +- .../bindings/dart/SegmenterWordType.g.dart | 3 - .../dart/SentenceBreakIteratorLatin1.g.dart | 28 +- .../dart/SentenceBreakIteratorUtf16.g.dart | 28 +- .../dart/SentenceBreakIteratorUtf8.g.dart | 28 +- .../bindings/dart/SentenceSegmenter.g.dart | 35 +- ffi/capi/bindings/dart/Time.g.dart | 49 +- ffi/capi/bindings/dart/TimeFormatter.g.dart | 47 +- ffi/capi/bindings/dart/TimeLength.g.dart | 3 - .../bindings/dart/TimeZoneFormatter.g.dart | 85 ++- ffi/capi/bindings/dart/TitlecaseMapper.g.dart | 37 +- .../bindings/dart/TitlecaseOptions.g.dart | 34 +- ffi/capi/bindings/dart/TrailingCase.g.dart | 3 - ffi/capi/bindings/dart/TransformResult.g.dart | 3 - ffi/capi/bindings/dart/UnicodeSetData.g.dart | 77 ++- ffi/capi/bindings/dart/WeekCalculator.g.dart | 45 +- ffi/capi/bindings/dart/WeekOf.g.dart | 30 +- .../bindings/dart/WeekRelativeUnit.g.dart | 3 - .../dart/WordBreakIteratorLatin1.g.dart | 36 +- .../dart/WordBreakIteratorUtf16.g.dart | 36 +- .../dart/WordBreakIteratorUtf8.g.dart | 36 +- ffi/capi/bindings/dart/WordSegmenter.g.dart | 51 +- .../dart/ZonedDateTimeFormatter.g.dart | 49 +- ffi/capi/bindings/dart/lib.g.dart | 116 ++-- ffi/capi/src/casemap.rs | 4 +- ffi/dart/build.dart | 3 +- ffi/dart/pubspec.yaml | 4 +- 131 files changed, 2462 insertions(+), 2813 deletions(-) diff --git a/.github/workflows/artifacts-build.yml b/.github/workflows/artifacts-build.yml index 4b7fc892a73..65959759a60 100644 --- a/.github/workflows/artifacts-build.yml +++ b/.github/workflows/artifacts-build.yml @@ -229,7 +229,7 @@ jobs: - name: Install Dart uses: dart-lang/setup-dart@v1 with: - sdk: 3.3.0-279.1.beta + sdk: 3.4.0-204.0.dev - name: Build docs run: | diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 42895ec8348..82ebe253bb2 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -396,7 +396,7 @@ jobs: # Job-specific dependencies - uses: dart-lang/setup-dart@v1 with: - sdk: 3.3.0-279.1.beta + sdk: 3.4.0-204.0.dev # Actual job - name: Run `cargo make ci-job-test-dart` diff --git a/Cargo.lock b/Cargo.lock index 94483fd05ab..7224aa0c1c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -729,7 +729,7 @@ dependencies = [ [[package]] name = "diplomat" version = "0.7.0" -source = "git+https://github.com/rust-diplomat/diplomat.git?rev=8e2fa9ac70f1269a30e934e6d21e16cad0d8440f#8e2fa9ac70f1269a30e934e6d21e16cad0d8440f" +source = "git+https://github.com/rust-diplomat/diplomat.git?rev=99ab75d8054b9ddca7fd1def0902f7a43bd68259#99ab75d8054b9ddca7fd1def0902f7a43bd68259" dependencies = [ "diplomat_core", "proc-macro2", @@ -747,7 +747,7 @@ dependencies = [ [[package]] name = "diplomat-runtime" version = "0.7.0" -source = "git+https://github.com/rust-diplomat/diplomat.git?rev=8e2fa9ac70f1269a30e934e6d21e16cad0d8440f#8e2fa9ac70f1269a30e934e6d21e16cad0d8440f" +source = "git+https://github.com/rust-diplomat/diplomat.git?rev=99ab75d8054b9ddca7fd1def0902f7a43bd68259#99ab75d8054b9ddca7fd1def0902f7a43bd68259" dependencies = [ "log", ] @@ -755,7 +755,7 @@ dependencies = [ [[package]] name = "diplomat-tool" version = "0.7.0" -source = "git+https://github.com/rust-diplomat/diplomat.git?rev=8e2fa9ac70f1269a30e934e6d21e16cad0d8440f#8e2fa9ac70f1269a30e934e6d21e16cad0d8440f" +source = "git+https://github.com/rust-diplomat/diplomat.git?rev=99ab75d8054b9ddca7fd1def0902f7a43bd68259#99ab75d8054b9ddca7fd1def0902f7a43bd68259" dependencies = [ "askama", "clap 3.2.25", @@ -775,7 +775,7 @@ dependencies = [ [[package]] name = "diplomat_core" version = "0.7.0" -source = "git+https://github.com/rust-diplomat/diplomat.git?rev=8e2fa9ac70f1269a30e934e6d21e16cad0d8440f#8e2fa9ac70f1269a30e934e6d21e16cad0d8440f" +source = "git+https://github.com/rust-diplomat/diplomat.git?rev=99ab75d8054b9ddca7fd1def0902f7a43bd68259#99ab75d8054b9ddca7fd1def0902f7a43bd68259" dependencies = [ "displaydoc", "either", diff --git a/Cargo.toml b/Cargo.toml index ae4de4416ce..c81f52bfe2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -204,10 +204,10 @@ icu_benchmark_macros = { path = "tools/benchmark/macros" } # The version here can either be a `version = ".."` spec or `git = "https://github.com/rust-diplomat/diplomat", rev = ".."` # Diplomat must be published preceding a new ICU4X release but may use git versions in between -diplomat = { git = "https://github.com/rust-diplomat/diplomat.git", rev = "8e2fa9ac70f1269a30e934e6d21e16cad0d8440f" } -diplomat-runtime = { git = "https://github.com/rust-diplomat/diplomat.git", rev = "8e2fa9ac70f1269a30e934e6d21e16cad0d8440f" } -diplomat_core = { git = "https://github.com/rust-diplomat/diplomat.git", rev = "8e2fa9ac70f1269a30e934e6d21e16cad0d8440f" } -diplomat-tool = { git = "https://github.com/rust-diplomat/diplomat.git", rev = "8e2fa9ac70f1269a30e934e6d21e16cad0d8440f" } +diplomat = { git = "https://github.com/rust-diplomat/diplomat.git", rev = "99ab75d8054b9ddca7fd1def0902f7a43bd68259" } +diplomat-runtime = { git = "https://github.com/rust-diplomat/diplomat.git", rev = "99ab75d8054b9ddca7fd1def0902f7a43bd68259" } +diplomat_core = { git = "https://github.com/rust-diplomat/diplomat.git", rev = "99ab75d8054b9ddca7fd1def0902f7a43bd68259" } +diplomat-tool = { git = "https://github.com/rust-diplomat/diplomat.git", rev = "99ab75d8054b9ddca7fd1def0902f7a43bd68259" } # Size optimized builds [profile.release-opt-size] diff --git a/ffi/capi/bindings/dart/AnyCalendarKind.g.dart b/ffi/capi/bindings/dart/AnyCalendarKind.g.dart index 54a4933bc6e..d4844d58dbe 100644 --- a/ffi/capi/bindings/dart/AnyCalendarKind.g.dart +++ b/ffi/capi/bindings/dart/AnyCalendarKind.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// The various calendar types currently supported by [`Calendar`] @@ -70,7 +67,7 @@ enum AnyCalendarKind { /// /// 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._underlying); + final result = _ICU4XAnyCalendarKind_get_for_locale(locale._ffi); if (!result.isOk) { return null; } @@ -85,7 +82,7 @@ enum AnyCalendarKind { static AnyCalendarKind? getForBcp47(String s) { final temp = ffi2.Arena(); final sView = s.utf8View; - final result = _ICU4XAnyCalendarKind_get_for_bcp47(sView.pointer(temp), sView.length); + final result = _ICU4XAnyCalendarKind_get_for_bcp47(sView.allocIn(temp), sView.length); temp.releaseAll(); if (!result.isOk) { return null; @@ -100,25 +97,25 @@ enum AnyCalendarKind { /// Throws [Error] on failure. String get bcp47 { final writeable = _Writeable(); - final result = _ICU4XAnyCalendarKind_bcp47(index, writeable._underlying); + final result = _ICU4XAnyCalendarKind_bcp47(index, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } } -@meta.ResourceIdentifier() +@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() +@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() +@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/ffi/capi/bindings/dart/Bcp47ToIanaMapper.g.dart b/ffi/capi/bindings/dart/Bcp47ToIanaMapper.g.dart index c509fe1ea95..2f0bc56ac61 100644 --- a/ffi/capi/bindings/dart/Bcp47ToIanaMapper.g.dart +++ b/ffi/capi/bindings/dart/Bcp47ToIanaMapper.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + Bcp47ToIanaMapper._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,11 +28,11 @@ final class Bcp47ToIanaMapper implements ffi.Finalizable { /// /// Throws [Error] on failure. factory Bcp47ToIanaMapper(DataProvider provider) { - final result = _ICU4XBcp47ToIanaMapper_create(provider._underlying); + final result = _ICU4XBcp47ToIanaMapper_create(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return Bcp47ToIanaMapper._(result.union.ok, true, []); + return Bcp47ToIanaMapper._fromFfi(result.union.ok, []); } /// Writes out the canonical IANA time zone ID corresponding to the given BCP-47 ID. @@ -47,26 +44,26 @@ final class Bcp47ToIanaMapper implements ffi.Finalizable { final temp = ffi2.Arena(); final valueView = value.utf8View; final writeable = _Writeable(); - final result = _ICU4XBcp47ToIanaMapper_get(_underlying, valueView.pointer(temp), valueView.length, writeable._underlying); + final result = _ICU4XBcp47ToIanaMapper_get(_ffi, valueView.allocIn(temp), valueView.length, writeable._ffi); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } } -@meta.ResourceIdentifier() +@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() +@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() +@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/ffi/capi/bindings/dart/Bidi.g.dart b/ffi/capi/bindings/dart/Bidi.g.dart index 84956f191c0..79a435e67c6 100644 --- a/ffi/capi/bindings/dart/Bidi.g.dart +++ b/ffi/capi/bindings/dart/Bidi.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + Bidi._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -33,11 +30,11 @@ final class Bidi implements ffi.Finalizable { /// /// Throws [Error] on failure. factory Bidi(DataProvider provider) { - final result = _ICU4XBidi_create(provider._underlying); + final result = _ICU4XBidi_create(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return Bidi._(result.union.ok, true, []); + return Bidi._fromFfi(result.union.ok, []); } /// Use the data loaded in this object to process a string and calculate bidi information @@ -50,8 +47,8 @@ final class Bidi implements ffi.Finalizable { final textArena = _FinalizedArena(); // This lifetime edge depends on lifetimes: 'text core.List textEdges = [textArena]; - final result = _ICU4XBidi_for_text(_underlying, textView.pointer(textArena.arena), textView.length, defaultLevel); - return BidiInfo._(result, true, [], textEdges); + 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 @@ -67,9 +64,9 @@ final class Bidi implements ffi.Finalizable { ReorderedIndexMap reorderVisual(core.List levels) { final temp = ffi2.Arena(); final levelsView = levels.uint8View; - final result = _ICU4XBidi_reorder_visual(_underlying, levelsView.pointer(temp), levelsView.length); + final result = _ICU4XBidi_reorder_visual(_ffi, levelsView.allocIn(temp), levelsView.length); temp.releaseAll(); - return ReorderedIndexMap._(result, true, []); + return ReorderedIndexMap._fromFfi(result, []); } /// Check if a Level returned by level_at is an RTL level. @@ -109,42 +106,42 @@ final class Bidi implements ffi.Finalizable { }(); } -@meta.ResourceIdentifier() +@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() +@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() +@meta.ResourceIdentifier('ICU4XBidi_for_text') @ffi.Native 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() +@meta.ResourceIdentifier('ICU4XBidi_reorder_visual') @ffi.Native 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() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/BidiDirection.g.dart b/ffi/capi/bindings/dart/BidiDirection.g.dart index c7c4b413f42..a18133e66fd 100644 --- a/ffi/capi/bindings/dart/BidiDirection.g.dart +++ b/ffi/capi/bindings/dart/BidiDirection.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; enum BidiDirection { diff --git a/ffi/capi/bindings/dart/BidiInfo.g.dart b/ffi/capi/bindings/dart/BidiInfo.g.dart index 17f1766d519..abc93f35f4d 100644 --- a/ffi/capi/bindings/dart/BidiInfo.g.dart +++ b/ffi/capi/bindings/dart/BidiInfo.g.dart @@ -1,28 +1,26 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_text; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_text) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + BidiInfo._fromFfi(this._ffi, this._selfEdge, this._textEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -30,7 +28,7 @@ final class BidiInfo implements ffi.Finalizable { /// The number of paragraphs contained here int get paragraphCount { - final result = _ICU4XBidiInfo_paragraph_count(_underlying); + final result = _ICU4XBidiInfo_paragraph_count(_ffi); return result; } @@ -38,13 +36,13 @@ final class BidiInfo implements ffi.Finalizable { BidiParagraph? paragraphAt(int n) { // This lifetime edge depends on lifetimes: 'text core.List textEdges = [this]; - final result = _ICU4XBidiInfo_paragraph_at(_underlying, n); - return result.address == 0 ? null : BidiParagraph._(result, true, [], textEdges); + 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(_underlying); + final result = _ICU4XBidiInfo_size(_ffi); return result; } @@ -54,32 +52,32 @@ final class BidiInfo implements ffi.Finalizable { /// /// Returns 0 (equivalent to `Level::ltr()`) on error int levelAt(int pos) { - final result = _ICU4XBidiInfo_level_at(_underlying, pos); + final result = _ICU4XBidiInfo_level_at(_ffi, pos); return result; } } -@meta.ResourceIdentifier() +@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() +@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() +@meta.ResourceIdentifier('ICU4XBidiInfo_paragraph_at') @ffi.Native 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() +@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() +@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/ffi/capi/bindings/dart/BidiParagraph.g.dart b/ffi/capi/bindings/dart/BidiParagraph.g.dart index c6dcfe7af80..54e9aeb4259 100644 --- a/ffi/capi/bindings/dart/BidiParagraph.g.dart +++ b/ffi/capi/bindings/dart/BidiParagraph.g.dart @@ -1,26 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// Bidi information for a single processed paragraph final class BidiParagraph implements ffi.Finalizable { - final ffi.Pointer _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_info; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_info) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + BidiParagraph._fromFfi(this._ffi, this._selfEdge, this._infoEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -34,9 +32,9 @@ final class BidiParagraph implements ffi.Finalizable { /// /// Throws [Error] on failure. void setParagraphInText(int n) { - final result = _ICU4XBidiParagraph_set_paragraph_in_text(_underlying, n); + final result = _ICU4XBidiParagraph_set_paragraph_in_text(_ffi, n); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -45,7 +43,7 @@ final class BidiParagraph implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XBidiParagraph_direction(_ffi); return BidiDirection.values[result]; } @@ -53,19 +51,19 @@ final class BidiParagraph implements ffi.Finalizable { /// /// 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(_underlying); + 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(_underlying); + 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(_underlying); + final result = _ICU4XBidiParagraph_range_end(_ffi); return result; } @@ -77,9 +75,9 @@ final class BidiParagraph implements ffi.Finalizable { /// Throws [Error] on failure. String reorderLine(int rangeStart, int rangeEnd) { final writeable = _Writeable(); - final result = _ICU4XBidiParagraph_reorder_line(_underlying, rangeStart, rangeEnd, writeable._underlying); + final result = _ICU4XBidiParagraph_reorder_line(_ffi, rangeStart, rangeEnd, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -92,47 +90,47 @@ final class BidiParagraph implements ffi.Finalizable { /// /// 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(_underlying, pos); + final result = _ICU4XBidiParagraph_level_at(_ffi, pos); return result; } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/Calendar.g.dart b/ffi/capi/bindings/dart/Calendar.g.dart index 437f0e0d7c6..23c9a47a490 100644 --- a/ffi/capi/bindings/dart/Calendar.g.dart +++ b/ffi/capi/bindings/dart/Calendar.g.dart @@ -1,25 +1,22 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + Calendar._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,11 +28,11 @@ final class Calendar implements ffi.Finalizable { /// /// Throws [Error] on failure. factory Calendar.forLocale(DataProvider provider, Locale locale) { - final result = _ICU4XCalendar_create_for_locale(provider._underlying, locale._underlying); + final result = _ICU4XCalendar_create_for_locale(provider._ffi, locale._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return Calendar._(result.union.ok, true, []); + return Calendar._fromFfi(result.union.ok, []); } /// Creates a new [`Calendar`] from the specified date and time. @@ -44,38 +41,38 @@ final class Calendar implements ffi.Finalizable { /// /// Throws [Error] on failure. factory Calendar.forKind(DataProvider provider, AnyCalendarKind kind) { - final result = _ICU4XCalendar_create_for_kind(provider._underlying, kind.index); + final result = _ICU4XCalendar_create_for_kind(provider._ffi, kind.index); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return Calendar._(result.union.ok, true, []); + 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(_underlying); + final result = _ICU4XCalendar_kind(_ffi); return AnyCalendarKind.values[result]; } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/CanonicalCombiningClassMap.g.dart b/ffi/capi/bindings/dart/CanonicalCombiningClassMap.g.dart index b50288a7d95..4415aa722e3 100644 --- a/ffi/capi/bindings/dart/CanonicalCombiningClassMap.g.dart +++ b/ffi/capi/bindings/dart/CanonicalCombiningClassMap.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + CanonicalCombiningClassMap._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -33,33 +30,33 @@ final class CanonicalCombiningClassMap implements ffi.Finalizable { /// /// Throws [Error] on failure. factory CanonicalCombiningClassMap(DataProvider provider) { - final result = _ICU4XCanonicalCombiningClassMap_create(provider._underlying); + final result = _ICU4XCanonicalCombiningClassMap_create(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CanonicalCombiningClassMap._(result.union.ok, true, []); + 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(_underlying, ch); + final result = _ICU4XCanonicalCombiningClassMap_get(_ffi, ch); return result; } } -@meta.ResourceIdentifier() +@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() +@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() +@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/ffi/capi/bindings/dart/CanonicalComposition.g.dart b/ffi/capi/bindings/dart/CanonicalComposition.g.dart index 0ca2d72c5ff..831d29dee73 100644 --- a/ffi/capi/bindings/dart/CanonicalComposition.g.dart +++ b/ffi/capi/bindings/dart/CanonicalComposition.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// The raw canonical composition operation. @@ -11,19 +8,19 @@ part of 'lib.g.dart'; /// /// 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + CanonicalComposition._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -35,11 +32,11 @@ final class CanonicalComposition implements ffi.Finalizable { /// /// Throws [Error] on failure. factory CanonicalComposition(DataProvider provider) { - final result = _ICU4XCanonicalComposition_create(provider._underlying); + final result = _ICU4XCanonicalComposition_create(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CanonicalComposition._(result.union.ok, true, []); + return CanonicalComposition._fromFfi(result.union.ok, []); } /// Performs canonical composition (including Hangul) on a pair of characters @@ -47,22 +44,22 @@ final class CanonicalComposition implements ffi.Finalizable { /// /// 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(_underlying, starter, second); + final result = _ICU4XCanonicalComposition_compose(_ffi, starter, second); return result; } } -@meta.ResourceIdentifier() +@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() +@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() +@meta.ResourceIdentifier('ICU4XCanonicalComposition_compose') @ffi.Native, 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/ffi/capi/bindings/dart/CanonicalDecomposition.g.dart b/ffi/capi/bindings/dart/CanonicalDecomposition.g.dart index 98344b0c646..0d26b3fc3eb 100644 --- a/ffi/capi/bindings/dart/CanonicalDecomposition.g.dart +++ b/ffi/capi/bindings/dart/CanonicalDecomposition.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// The raw (non-recursive) canonical decomposition operation. @@ -11,19 +8,19 @@ part of 'lib.g.dart'; /// /// 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + CanonicalDecomposition._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -35,33 +32,33 @@ final class CanonicalDecomposition implements ffi.Finalizable { /// /// Throws [Error] on failure. factory CanonicalDecomposition(DataProvider provider) { - final result = _ICU4XCanonicalDecomposition_create(provider._underlying); + final result = _ICU4XCanonicalDecomposition_create(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CanonicalDecomposition._(result.union.ok, true, []); + 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(_underlying, c); - return Decomposed._(result); + final result = _ICU4XCanonicalDecomposition_decompose(_ffi, c); + return Decomposed._fromFfi(result); } } -@meta.ResourceIdentifier() +@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() +@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() +@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/ffi/capi/bindings/dart/CaseMapCloser.g.dart b/ffi/capi/bindings/dart/CaseMapCloser.g.dart index 8ba9679fd63..e1c5e836ffa 100644 --- a/ffi/capi/bindings/dart/CaseMapCloser.g.dart +++ b/ffi/capi/bindings/dart/CaseMapCloser.g.dart @@ -1,25 +1,22 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + CaseMapCloser._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,11 +28,11 @@ final class CaseMapCloser implements ffi.Finalizable { /// /// Throws [Error] on failure. factory CaseMapCloser(DataProvider provider) { - final result = _ICU4XCaseMapCloser_create(provider._underlying); + final result = _ICU4XCaseMapCloser_create(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CaseMapCloser._(result.union.ok, true, []); + return CaseMapCloser._fromFfi(result.union.ok, []); } /// Adds all simple case mappings and the full case folding for `c` to `builder`. @@ -43,7 +40,7 @@ final class CaseMapCloser implements ffi.Finalizable { /// /// 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(_underlying, c, builder._underlying); + _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 @@ -55,28 +52,28 @@ final class CaseMapCloser implements ffi.Finalizable { bool addStringCaseClosureTo(String s, CodePointSetBuilder builder) { final temp = ffi2.Arena(); final sView = s.utf8View; - final result = _ICU4XCaseMapCloser_add_string_case_closure_to(_underlying, sView.pointer(temp), sView.length, builder._underlying); + final result = _ICU4XCaseMapCloser_add_string_case_closure_to(_ffi, sView.allocIn(temp), sView.length, builder._ffi); temp.releaseAll(); return result; } } -@meta.ResourceIdentifier() +@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() +@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() +@meta.ResourceIdentifier('ICU4XCaseMapCloser_add_case_closure_to') @ffi.Native, 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() +@meta.ResourceIdentifier('ICU4XCaseMapCloser_add_string_case_closure_to') @ffi.Native, 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/ffi/capi/bindings/dart/CaseMapper.g.dart b/ffi/capi/bindings/dart/CaseMapper.g.dart index 6be5354b7de..6f809529ff8 100644 --- a/ffi/capi/bindings/dart/CaseMapper.g.dart +++ b/ffi/capi/bindings/dart/CaseMapper.g.dart @@ -1,25 +1,22 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + CaseMapper._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,11 +28,11 @@ final class CaseMapper implements ffi.Finalizable { /// /// Throws [Error] on failure. factory CaseMapper(DataProvider provider) { - final result = _ICU4XCaseMapper_create(provider._underlying); + final result = _ICU4XCaseMapper_create(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CaseMapper._(result.union.ok, true, []); + return CaseMapper._fromFfi(result.union.ok, []); } /// Returns the full lowercase mapping of the given string @@ -47,10 +44,10 @@ final class CaseMapper implements ffi.Finalizable { final temp = ffi2.Arena(); final sView = s.utf8View; final writeable = _Writeable(); - final result = _ICU4XCaseMapper_lowercase(_underlying, sView.pointer(temp), sView.length, locale._underlying, writeable._underlying); + 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -64,10 +61,10 @@ final class CaseMapper implements ffi.Finalizable { final temp = ffi2.Arena(); final sView = s.utf8View; final writeable = _Writeable(); - final result = _ICU4XCaseMapper_uppercase(_underlying, sView.pointer(temp), sView.length, locale._underlying, writeable._underlying); + 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -81,14 +78,14 @@ final class CaseMapper implements ffi.Finalizable { /// 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 titlecase_segment_with_only_case_data(String s, Locale locale, TitlecaseOptions options) { + 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(_underlying, sView.pointer(temp), sView.length, locale._underlying, options._pointer(temp), writeable._underlying); + 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -102,10 +99,10 @@ final class CaseMapper implements ffi.Finalizable { final temp = ffi2.Arena(); final sView = s.utf8View; final writeable = _Writeable(); - final result = _ICU4XCaseMapper_fold(_underlying, sView.pointer(temp), sView.length, writeable._underlying); + final result = _ICU4XCaseMapper_fold(_ffi, sView.allocIn(temp), sView.length, writeable._ffi); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -120,10 +117,10 @@ final class CaseMapper implements ffi.Finalizable { final temp = ffi2.Arena(); final sView = s.utf8View; final writeable = _Writeable(); - final result = _ICU4XCaseMapper_fold_turkic(_underlying, sView.pointer(temp), sView.length, writeable._underlying); + final result = _ICU4XCaseMapper_fold_turkic(_ffi, sView.allocIn(temp), sView.length, writeable._ffi); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -142,7 +139,7 @@ final class CaseMapper implements ffi.Finalizable { /// /// 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(_underlying, c, builder._underlying); + _ICU4XCaseMapper_add_case_closure_to(_ffi, c, builder._ffi); } /// Returns the simple lowercase mapping of the given character. @@ -153,7 +150,7 @@ final class CaseMapper implements ffi.Finalizable { /// /// 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(_underlying, ch); + final result = _ICU4XCaseMapper_simple_lowercase(_ffi, ch); return result; } @@ -165,7 +162,7 @@ final class CaseMapper implements ffi.Finalizable { /// /// 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(_underlying, ch); + final result = _ICU4XCaseMapper_simple_uppercase(_ffi, ch); return result; } @@ -177,7 +174,7 @@ final class CaseMapper implements ffi.Finalizable { /// /// 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(_underlying, ch); + final result = _ICU4XCaseMapper_simple_titlecase(_ffi, ch); return result; } @@ -188,7 +185,7 @@ final class CaseMapper implements ffi.Finalizable { /// /// 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(_underlying, ch); + final result = _ICU4XCaseMapper_simple_fold(_ffi, ch); return result; } @@ -199,72 +196,72 @@ final class CaseMapper implements ffi.Finalizable { /// /// 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(_underlying, ch); + final result = _ICU4XCaseMapper_simple_fold_turkic(_ffi, ch); return result; } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XCaseMapper_add_case_closure_to') @ffi.Native, 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() +@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() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/CodePointMapData16.g.dart b/ffi/capi/bindings/dart/CodePointMapData16.g.dart index 4ee6d1135c3..6d38b47ef19 100644 --- a/ffi/capi/bindings/dart/CodePointMapData16.g.dart +++ b/ffi/capi/bindings/dart/CodePointMapData16.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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. @@ -15,19 +12,19 @@ part of 'lib.g.dart'; /// /// 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + CodePointMapData16._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -37,7 +34,7 @@ final class CodePointMapData16 implements ffi.Finalizable { /// /// 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(_underlying, cp); + final result = _ICU4XCodePointMapData16_get(_ffi, cp); return result; } @@ -47,8 +44,8 @@ final class CodePointMapData16 implements ffi.Finalizable { CodePointRangeIterator iterRangesForValue(int value) { // This lifetime edge depends on lifetimes: 'a core.List aEdges = [this]; - final result = _ICU4XCodePointMapData16_iter_ranges_for_value(_underlying, value); - return CodePointRangeIterator._(result, true, [], aEdges); + 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` @@ -57,56 +54,56 @@ final class CodePointMapData16 implements ffi.Finalizable { CodePointRangeIterator iterRangesForValueComplemented(int value) { // This lifetime edge depends on lifetimes: 'a core.List aEdges = [this]; - final result = _ICU4XCodePointMapData16_iter_ranges_for_value_complemented(_underlying, value); - return CodePointRangeIterator._(result, true, [], aEdges); + 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(_underlying, value); - return CodePointSetData._(result, true, []); + 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.loadScript(DataProvider provider) { - final result = _ICU4XCodePointMapData16_load_script(provider._underlying); + final result = _ICU4XCodePointMapData16_load_script(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointMapData16._(result.union.ok, true, []); + return CodePointMapData16._fromFfi(result.union.ok, []); } } -@meta.ResourceIdentifier() +@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() +@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() +@meta.ResourceIdentifier('ICU4XCodePointMapData16_iter_ranges_for_value') @ffi.Native 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() +@meta.ResourceIdentifier('ICU4XCodePointMapData16_iter_ranges_for_value_complemented') @ffi.Native 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() +@meta.ResourceIdentifier('ICU4XCodePointMapData16_get_set_for_value') @ffi.Native 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() +@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/ffi/capi/bindings/dart/CodePointMapData8.g.dart b/ffi/capi/bindings/dart/CodePointMapData8.g.dart index edef241e270..fc762e077a2 100644 --- a/ffi/capi/bindings/dart/CodePointMapData8.g.dart +++ b/ffi/capi/bindings/dart/CodePointMapData8.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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. @@ -15,19 +12,19 @@ part of 'lib.g.dart'; /// /// 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + CodePointMapData8._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -37,7 +34,7 @@ final class CodePointMapData8 implements ffi.Finalizable { /// /// 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(_underlying, cp); + final result = _ICU4XCodePointMapData8_get(_ffi, cp); return result; } @@ -57,8 +54,8 @@ final class CodePointMapData8 implements ffi.Finalizable { CodePointRangeIterator iterRangesForValue(int value) { // This lifetime edge depends on lifetimes: 'a core.List aEdges = [this]; - final result = _ICU4XCodePointMapData8_iter_ranges_for_value(_underlying, value); - return CodePointRangeIterator._(result, true, [], aEdges); + 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` @@ -67,8 +64,8 @@ final class CodePointMapData8 implements ffi.Finalizable { CodePointRangeIterator iterRangesForValueComplemented(int value) { // This lifetime edge depends on lifetimes: 'a core.List aEdges = [this]; - final result = _ICU4XCodePointMapData8_iter_ranges_for_value_complemented(_underlying, value); - return CodePointRangeIterator._(result, true, [], aEdges); + 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 @@ -84,194 +81,194 @@ final class CodePointMapData8 implements ffi.Finalizable { CodePointRangeIterator iterRangesForMask(int mask) { // This lifetime edge depends on lifetimes: 'a core.List aEdges = [this]; - final result = _ICU4XCodePointMapData8_iter_ranges_for_mask(_underlying, mask); - return CodePointRangeIterator._(result, true, [], aEdges); + 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(_underlying, value); - return CodePointSetData._(result, true, []); + 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.loadGeneralCategory(DataProvider provider) { - final result = _ICU4XCodePointMapData8_load_general_category(provider._underlying); + final result = _ICU4XCodePointMapData8_load_general_category(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointMapData8._(result.union.ok, true, []); + 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.loadBidiClass(DataProvider provider) { - final result = _ICU4XCodePointMapData8_load_bidi_class(provider._underlying); + final result = _ICU4XCodePointMapData8_load_bidi_class(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointMapData8._(result.union.ok, true, []); + 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.loadEastAsianWidth(DataProvider provider) { - final result = _ICU4XCodePointMapData8_load_east_asian_width(provider._underlying); + final result = _ICU4XCodePointMapData8_load_east_asian_width(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointMapData8._(result.union.ok, true, []); + 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.loadIndicSyllabicCategory(DataProvider provider) { - final result = _ICU4XCodePointMapData8_load_indic_syllabic_category(provider._underlying); + final result = _ICU4XCodePointMapData8_load_indic_syllabic_category(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointMapData8._(result.union.ok, true, []); + 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.loadLineBreak(DataProvider provider) { - final result = _ICU4XCodePointMapData8_load_line_break(provider._underlying); + final result = _ICU4XCodePointMapData8_load_line_break(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointMapData8._(result.union.ok, true, []); + 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. factory CodePointMapData8.graphemeClusterBreak(DataProvider provider) { - final result = _ICU4XCodePointMapData8_try_grapheme_cluster_break(provider._underlying); + final result = _ICU4XCodePointMapData8_try_grapheme_cluster_break(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointMapData8._(result.union.ok, true, []); + 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.loadWordBreak(DataProvider provider) { - final result = _ICU4XCodePointMapData8_load_word_break(provider._underlying); + final result = _ICU4XCodePointMapData8_load_word_break(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointMapData8._(result.union.ok, true, []); + 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.loadSentenceBreak(DataProvider provider) { - final result = _ICU4XCodePointMapData8_load_sentence_break(provider._underlying); + final result = _ICU4XCodePointMapData8_load_sentence_break(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointMapData8._(result.union.ok, true, []); + 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.loadJoiningType(DataProvider provider) { - final result = _ICU4XCodePointMapData8_load_joining_type(provider._underlying); + final result = _ICU4XCodePointMapData8_load_joining_type(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointMapData8._(result.union.ok, true, []); + return CodePointMapData8._fromFfi(result.union.ok, []); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XCodePointMapData8_iter_ranges_for_value') @ffi.Native 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() +@meta.ResourceIdentifier('ICU4XCodePointMapData8_iter_ranges_for_value_complemented') @ffi.Native 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() +@meta.ResourceIdentifier('ICU4XCodePointMapData8_iter_ranges_for_mask') @ffi.Native 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() +@meta.ResourceIdentifier('ICU4XCodePointMapData8_get_set_for_value') @ffi.Native 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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/CodePointRangeIterator.g.dart b/ffi/capi/bindings/dart/CodePointRangeIterator.g.dart index 065eca78f2c..655b3af9f5e 100644 --- a/ffi/capi/bindings/dart/CodePointRangeIterator.g.dart +++ b/ffi/capi/bindings/dart/CodePointRangeIterator.g.dart @@ -1,27 +1,25 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_a; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_a) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + CodePointRangeIterator._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,17 +29,17 @@ final class CodePointRangeIterator implements ffi.Finalizable { /// /// If the iterator is out of items, `done` will be true CodePointRangeIteratorResult next() { - final result = _CodePointRangeIterator_next(_underlying); - return CodePointRangeIteratorResult._(result); + final result = _CodePointRangeIterator_next(_ffi); + return CodePointRangeIteratorResult._fromFfi(result); } } -@meta.ResourceIdentifier() +@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() +@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/ffi/capi/bindings/dart/CodePointRangeIteratorResult.g.dart b/ffi/capi/bindings/dart/CodePointRangeIteratorResult.g.dart index 18c3c662347..650ac4b0ca5 100644 --- a/ffi/capi/bindings/dart/CodePointRangeIteratorResult.g.dart +++ b/ffi/capi/bindings/dart/CodePointRangeIteratorResult.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; final class _CodePointRangeIteratorResultFfi extends ffi.Struct { @@ -26,38 +23,37 @@ final class CodePointRangeIteratorResult { final int end; final bool done; - // ignore: unused_element - // Internal constructor from FFI. // 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. - CodePointRangeIteratorResult._(_CodePointRangeIteratorResultFfi underlying) : - start = underlying.start, - end = underlying.end, - done = underlying.done; + // ignore: unused_element + CodePointRangeIteratorResult._fromFfi(_CodePointRangeIteratorResultFfi ffi) : + start = ffi.start, + end = ffi.end, + done = ffi.done; // ignore: unused_element - _CodePointRangeIteratorResultFfi _pointer(ffi.Allocator temp) { - final pointer = temp<_CodePointRangeIteratorResultFfi>(); - pointer.ref.start = start; - pointer.ref.end = end; - pointer.ref.done = done; - return pointer.ref; + _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 == this.start && - other.end == this.end && - other.done == this.done; + other.start == start && + other.end == end && + other.done == done; @override int get hashCode => Object.hashAll([ - this.start, - this.end, - this.done, + start, + end, + done, ]); } diff --git a/ffi/capi/bindings/dart/CodePointSetBuilder.g.dart b/ffi/capi/bindings/dart/CodePointSetBuilder.g.dart index 43b2036c96e..68441f39f10 100644 --- a/ffi/capi/bindings/dart/CodePointSetBuilder.g.dart +++ b/ffi/capi/bindings/dart/CodePointSetBuilder.g.dart @@ -1,25 +1,22 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + CodePointSetBuilder._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -30,7 +27,7 @@ final class CodePointSetBuilder implements ffi.Finalizable { /// 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._(result, true, []); + return CodePointSetBuilder._fromFfi(result, []); } /// Build this into a set @@ -39,8 +36,8 @@ final class CodePointSetBuilder implements ffi.Finalizable { /// /// 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(_underlying); - return CodePointSetData._(result, true, []); + final result = _ICU4XCodePointSetBuilder_build(_ffi); + return CodePointSetData._fromFfi(result, []); } /// Complements this set @@ -49,14 +46,14 @@ final class CodePointSetBuilder implements ffi.Finalizable { /// /// 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(_underlying); + _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(_underlying); + final result = _ICU4XCodePointSetBuilder_is_empty(_ffi); return result; } @@ -64,63 +61,63 @@ final class CodePointSetBuilder implements ffi.Finalizable { /// /// 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(_underlying, 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(_underlying, start, 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(_underlying, data._underlying); + _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(_underlying, 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(_underlying, start, 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(_underlying, data._underlying); + _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(_underlying, 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(_underlying, start, 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(_underlying, data._underlying); + _ICU4XCodePointSetBuilder_retain_set(_ffi, data._ffi); } /// Complement a single character to the set @@ -129,7 +126,7 @@ final class CodePointSetBuilder implements ffi.Finalizable { /// /// 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(_underlying, ch); + _ICU4XCodePointSetBuilder_complement_char(_ffi, ch); } /// Complement an inclusive range of characters from the set @@ -138,7 +135,7 @@ final class CodePointSetBuilder implements ffi.Finalizable { /// /// 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(_underlying, start, end); + _ICU4XCodePointSetBuilder_complement_inclusive_range(_ffi, start, end); } /// Complement all elements that belong to the provided set from the set @@ -147,91 +144,91 @@ final class CodePointSetBuilder implements ffi.Finalizable { /// /// 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(_underlying, data._underlying); + _ICU4XCodePointSetBuilder_complement_set(_ffi, data._ffi); } } -@meta.ResourceIdentifier() +@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() +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_create') @ffi.Native Function()>(isLeaf: true, symbol: 'ICU4XCodePointSetBuilder_create') // ignore: non_constant_identifier_names external ffi.Pointer _ICU4XCodePointSetBuilder_create(); -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_add_set') @ffi.Native, 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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_remove_set') @ffi.Native, 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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_retain_set') @ffi.Native, 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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XCodePointSetBuilder_complement_set') @ffi.Native, 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/ffi/capi/bindings/dart/CodePointSetData.g.dart b/ffi/capi/bindings/dart/CodePointSetData.g.dart index d89dbf53c73..438f48b868d 100644 --- a/ffi/capi/bindings/dart/CodePointSetData.g.dart +++ b/ffi/capi/bindings/dart/CodePointSetData.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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. @@ -13,19 +10,19 @@ part of 'lib.g.dart'; /// /// 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + CodePointSetData._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -35,7 +32,7 @@ final class CodePointSetData implements ffi.Finalizable { /// /// 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(_underlying, cp); + final result = _ICU4XCodePointSetData_contains(_ffi, cp); return result; } @@ -45,8 +42,8 @@ final class CodePointSetData implements ffi.Finalizable { CodePointRangeIterator get iterRanges { // This lifetime edge depends on lifetimes: 'a core.List aEdges = [this]; - final result = _ICU4XCodePointSetData_iter_ranges(_underlying); - return CodePointRangeIterator._(result, true, [], aEdges); + final result = _ICU4XCodePointSetData_iter_ranges(_ffi); + return CodePointRangeIterator._fromFfi(result, [], aEdges); } /// Produces an iterator over ranges of code points not contained in this set @@ -55,8 +52,8 @@ final class CodePointSetData implements ffi.Finalizable { CodePointRangeIterator get iterRangesComplemented { // This lifetime edge depends on lifetimes: 'a core.List aEdges = [this]; - final result = _ICU4XCodePointSetData_iter_ranges_complemented(_underlying); - return CodePointRangeIterator._(result, true, [], aEdges); + 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 @@ -65,726 +62,726 @@ final class CodePointSetData implements ffi.Finalizable { /// /// Throws [Error] on failure. factory CodePointSetData.loadForGeneralCategoryGroup(DataProvider provider, int group) { - final result = _ICU4XCodePointSetData_load_for_general_category_group(provider._underlying, group); + final result = _ICU4XCodePointSetData_load_for_general_category_group(provider._ffi, group); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadAsciiHexDigit(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_ascii_hex_digit(provider._underlying); + final result = _ICU4XCodePointSetData_load_ascii_hex_digit(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadAlnum(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_alnum(provider._underlying); + final result = _ICU4XCodePointSetData_load_alnum(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadAlphabetic(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_alphabetic(provider._underlying); + final result = _ICU4XCodePointSetData_load_alphabetic(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadBidiControl(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_bidi_control(provider._underlying); + final result = _ICU4XCodePointSetData_load_bidi_control(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadBidiMirrored(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_bidi_mirrored(provider._underlying); + final result = _ICU4XCodePointSetData_load_bidi_mirrored(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadBlank(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_blank(provider._underlying); + final result = _ICU4XCodePointSetData_load_blank(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadCased(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_cased(provider._underlying); + final result = _ICU4XCodePointSetData_load_cased(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadCaseIgnorable(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_case_ignorable(provider._underlying); + final result = _ICU4XCodePointSetData_load_case_ignorable(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadFullCompositionExclusion(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_full_composition_exclusion(provider._underlying); + final result = _ICU4XCodePointSetData_load_full_composition_exclusion(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadChangesWhenCasefolded(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_changes_when_casefolded(provider._underlying); + final result = _ICU4XCodePointSetData_load_changes_when_casefolded(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadChangesWhenCasemapped(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_changes_when_casemapped(provider._underlying); + final result = _ICU4XCodePointSetData_load_changes_when_casemapped(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadChangesWhenNfkcCasefolded(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_changes_when_nfkc_casefolded(provider._underlying); + final result = _ICU4XCodePointSetData_load_changes_when_nfkc_casefolded(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadChangesWhenLowercased(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_changes_when_lowercased(provider._underlying); + final result = _ICU4XCodePointSetData_load_changes_when_lowercased(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadChangesWhenTitlecased(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_changes_when_titlecased(provider._underlying); + final result = _ICU4XCodePointSetData_load_changes_when_titlecased(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadChangesWhenUppercased(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_changes_when_uppercased(provider._underlying); + final result = _ICU4XCodePointSetData_load_changes_when_uppercased(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadDash(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_dash(provider._underlying); + final result = _ICU4XCodePointSetData_load_dash(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadDeprecated(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_deprecated(provider._underlying); + final result = _ICU4XCodePointSetData_load_deprecated(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadDefaultIgnorableCodePoint(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_default_ignorable_code_point(provider._underlying); + final result = _ICU4XCodePointSetData_load_default_ignorable_code_point(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadDiacritic(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_diacritic(provider._underlying); + final result = _ICU4XCodePointSetData_load_diacritic(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadEmojiModifierBase(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_emoji_modifier_base(provider._underlying); + final result = _ICU4XCodePointSetData_load_emoji_modifier_base(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadEmojiComponent(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_emoji_component(provider._underlying); + final result = _ICU4XCodePointSetData_load_emoji_component(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadEmojiModifier(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_emoji_modifier(provider._underlying); + final result = _ICU4XCodePointSetData_load_emoji_modifier(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadEmoji(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_emoji(provider._underlying); + final result = _ICU4XCodePointSetData_load_emoji(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadEmojiPresentation(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_emoji_presentation(provider._underlying); + final result = _ICU4XCodePointSetData_load_emoji_presentation(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadExtender(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_extender(provider._underlying); + final result = _ICU4XCodePointSetData_load_extender(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadExtendedPictographic(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_extended_pictographic(provider._underlying); + final result = _ICU4XCodePointSetData_load_extended_pictographic(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadGraph(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_graph(provider._underlying); + final result = _ICU4XCodePointSetData_load_graph(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadGraphemeBase(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_grapheme_base(provider._underlying); + final result = _ICU4XCodePointSetData_load_grapheme_base(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadGraphemeExtend(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_grapheme_extend(provider._underlying); + final result = _ICU4XCodePointSetData_load_grapheme_extend(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadGraphemeLink(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_grapheme_link(provider._underlying); + final result = _ICU4XCodePointSetData_load_grapheme_link(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadHexDigit(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_hex_digit(provider._underlying); + final result = _ICU4XCodePointSetData_load_hex_digit(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadHyphen(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_hyphen(provider._underlying); + final result = _ICU4XCodePointSetData_load_hyphen(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadIdContinue(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_id_continue(provider._underlying); + final result = _ICU4XCodePointSetData_load_id_continue(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadIdeographic(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_ideographic(provider._underlying); + final result = _ICU4XCodePointSetData_load_ideographic(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadIdStart(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_id_start(provider._underlying); + final result = _ICU4XCodePointSetData_load_id_start(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadIdsBinaryOperator(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_ids_binary_operator(provider._underlying); + final result = _ICU4XCodePointSetData_load_ids_binary_operator(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadIdsTrinaryOperator(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_ids_trinary_operator(provider._underlying); + final result = _ICU4XCodePointSetData_load_ids_trinary_operator(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadJoinControl(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_join_control(provider._underlying); + final result = _ICU4XCodePointSetData_load_join_control(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadLogicalOrderException(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_logical_order_exception(provider._underlying); + final result = _ICU4XCodePointSetData_load_logical_order_exception(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadLowercase(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_lowercase(provider._underlying); + final result = _ICU4XCodePointSetData_load_lowercase(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadMath(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_math(provider._underlying); + final result = _ICU4XCodePointSetData_load_math(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadNoncharacterCodePoint(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_noncharacter_code_point(provider._underlying); + final result = _ICU4XCodePointSetData_load_noncharacter_code_point(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadNfcInert(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_nfc_inert(provider._underlying); + final result = _ICU4XCodePointSetData_load_nfc_inert(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadNfdInert(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_nfd_inert(provider._underlying); + final result = _ICU4XCodePointSetData_load_nfd_inert(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadNfkcInert(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_nfkc_inert(provider._underlying); + final result = _ICU4XCodePointSetData_load_nfkc_inert(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadNfkdInert(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_nfkd_inert(provider._underlying); + final result = _ICU4XCodePointSetData_load_nfkd_inert(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadPatternSyntax(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_pattern_syntax(provider._underlying); + final result = _ICU4XCodePointSetData_load_pattern_syntax(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadPatternWhiteSpace(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_pattern_white_space(provider._underlying); + final result = _ICU4XCodePointSetData_load_pattern_white_space(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadPrependedConcatenationMark(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_prepended_concatenation_mark(provider._underlying); + final result = _ICU4XCodePointSetData_load_prepended_concatenation_mark(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadPrint(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_print(provider._underlying); + final result = _ICU4XCodePointSetData_load_print(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadQuotationMark(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_quotation_mark(provider._underlying); + final result = _ICU4XCodePointSetData_load_quotation_mark(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadRadical(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_radical(provider._underlying); + final result = _ICU4XCodePointSetData_load_radical(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadRegionalIndicator(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_regional_indicator(provider._underlying); + final result = _ICU4XCodePointSetData_load_regional_indicator(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadSoftDotted(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_soft_dotted(provider._underlying); + final result = _ICU4XCodePointSetData_load_soft_dotted(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadSegmentStarter(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_segment_starter(provider._underlying); + final result = _ICU4XCodePointSetData_load_segment_starter(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadCaseSensitive(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_case_sensitive(provider._underlying); + final result = _ICU4XCodePointSetData_load_case_sensitive(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadSentenceTerminal(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_sentence_terminal(provider._underlying); + final result = _ICU4XCodePointSetData_load_sentence_terminal(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadTerminalPunctuation(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_terminal_punctuation(provider._underlying); + final result = _ICU4XCodePointSetData_load_terminal_punctuation(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadUnifiedIdeograph(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_unified_ideograph(provider._underlying); + final result = _ICU4XCodePointSetData_load_unified_ideograph(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadUppercase(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_uppercase(provider._underlying); + final result = _ICU4XCodePointSetData_load_uppercase(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadVariationSelector(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_variation_selector(provider._underlying); + final result = _ICU4XCodePointSetData_load_variation_selector(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadWhiteSpace(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_white_space(provider._underlying); + final result = _ICU4XCodePointSetData_load_white_space(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadXdigit(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_xdigit(provider._underlying); + final result = _ICU4XCodePointSetData_load_xdigit(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadXidContinue(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_xid_continue(provider._underlying); + final result = _ICU4XCodePointSetData_load_xid_continue(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + 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.loadXidStart(DataProvider provider) { - final result = _ICU4XCodePointSetData_load_xid_start(provider._underlying); + final result = _ICU4XCodePointSetData_load_xid_start(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + return CodePointSetData._fromFfi(result.union.ok, []); } /// Loads data for a property specified as a string as long as it is one of the @@ -801,366 +798,366 @@ final class CodePointSetData implements ffi.Finalizable { factory CodePointSetData.loadForEcma262(DataProvider provider, String propertyName) { final temp = ffi2.Arena(); final propertyNameView = propertyName.utf8View; - final result = _ICU4XCodePointSetData_load_for_ecma262(provider._underlying, propertyNameView.pointer(temp), propertyNameView.length); + final result = _ICU4XCodePointSetData_load_for_ecma262(provider._ffi, propertyNameView.allocIn(temp), propertyNameView.length); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CodePointSetData._(result.union.ok, true, []); + return CodePointSetData._fromFfi(result.union.ok, []); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/Collator.g.dart b/ffi/capi/bindings/dart/Collator.g.dart index 1f119c6d5ab..39b7265172b 100644 --- a/ffi/capi/bindings/dart/Collator.g.dart +++ b/ffi/capi/bindings/dart/Collator.g.dart @@ -1,25 +1,22 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + Collator._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -32,12 +29,12 @@ final class Collator implements ffi.Finalizable { /// Throws [Error] on failure. factory Collator(DataProvider provider, Locale locale, CollatorOptions options) { final temp = ffi2.Arena(); - final result = _ICU4XCollator_create_v1(provider._underlying, locale._underlying, options._pointer(temp)); + final result = _ICU4XCollator_create_v1(provider._ffi, locale._ffi, options._toFfi(temp)); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return Collator._(result.union.ok, true, []); + return Collator._fromFfi(result.union.ok, []); } /// Compare two strings. @@ -50,9 +47,9 @@ final class Collator implements ffi.Finalizable { final temp = ffi2.Arena(); final leftView = left.utf16View; final rightView = right.utf16View; - final result = _ICU4XCollator_compare_utf16(_underlying, leftView.pointer(temp), leftView.length, rightView.pointer(temp), rightView.length); + final result = _ICU4XCollator_compare_utf16(_ffi, leftView.allocIn(temp), leftView.length, rightView.allocIn(temp), rightView.length); temp.releaseAll(); - return Ordering.values.firstWhere((v) => v._underlying == result); + return Ordering.values.firstWhere((v) => v._ffi == result); } /// The resolved options showing how the default options, the requested options, @@ -61,27 +58,27 @@ final class Collator implements ffi.Finalizable { /// /// 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(_underlying); - return ResolvedCollatorOptions._(result); + final result = _ICU4XCollator_resolved_options(_ffi); + return ResolvedCollatorOptions._fromFfi(result); } } -@meta.ResourceIdentifier() +@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() +@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() +@meta.ResourceIdentifier('ICU4XCollator_compare_utf16') @ffi.Native, 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() +@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/ffi/capi/bindings/dart/CollatorAlternateHandling.g.dart b/ffi/capi/bindings/dart/CollatorAlternateHandling.g.dart index ecef6449a34..3f4d20effa7 100644 --- a/ffi/capi/bindings/dart/CollatorAlternateHandling.g.dart +++ b/ffi/capi/bindings/dart/CollatorAlternateHandling.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// See the [Rust documentation for `AlternateHandling`](https://docs.rs/icu/latest/icu/collator/enum.AlternateHandling.html) for more information. diff --git a/ffi/capi/bindings/dart/CollatorBackwardSecondLevel.g.dart b/ffi/capi/bindings/dart/CollatorBackwardSecondLevel.g.dart index 2f081542749..aeb1fee5bb6 100644 --- a/ffi/capi/bindings/dart/CollatorBackwardSecondLevel.g.dart +++ b/ffi/capi/bindings/dart/CollatorBackwardSecondLevel.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// See the [Rust documentation for `BackwardSecondLevel`](https://docs.rs/icu/latest/icu/collator/enum.BackwardSecondLevel.html) for more information. diff --git a/ffi/capi/bindings/dart/CollatorCaseFirst.g.dart b/ffi/capi/bindings/dart/CollatorCaseFirst.g.dart index caca571135c..7e93127f762 100644 --- a/ffi/capi/bindings/dart/CollatorCaseFirst.g.dart +++ b/ffi/capi/bindings/dart/CollatorCaseFirst.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// See the [Rust documentation for `CaseFirst`](https://docs.rs/icu/latest/icu/collator/enum.CaseFirst.html) for more information. diff --git a/ffi/capi/bindings/dart/CollatorCaseLevel.g.dart b/ffi/capi/bindings/dart/CollatorCaseLevel.g.dart index 033e9db670b..aa5d5056b56 100644 --- a/ffi/capi/bindings/dart/CollatorCaseLevel.g.dart +++ b/ffi/capi/bindings/dart/CollatorCaseLevel.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// See the [Rust documentation for `CaseLevel`](https://docs.rs/icu/latest/icu/collator/enum.CaseLevel.html) for more information. diff --git a/ffi/capi/bindings/dart/CollatorMaxVariable.g.dart b/ffi/capi/bindings/dart/CollatorMaxVariable.g.dart index 51b071b46c0..bdfdf984b00 100644 --- a/ffi/capi/bindings/dart/CollatorMaxVariable.g.dart +++ b/ffi/capi/bindings/dart/CollatorMaxVariable.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// See the [Rust documentation for `MaxVariable`](https://docs.rs/icu/latest/icu/collator/enum.MaxVariable.html) for more information. diff --git a/ffi/capi/bindings/dart/CollatorNumeric.g.dart b/ffi/capi/bindings/dart/CollatorNumeric.g.dart index fac5b71df63..99f5ff34cfa 100644 --- a/ffi/capi/bindings/dart/CollatorNumeric.g.dart +++ b/ffi/capi/bindings/dart/CollatorNumeric.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// See the [Rust documentation for `Numeric`](https://docs.rs/icu/latest/icu/collator/enum.Numeric.html) for more information. diff --git a/ffi/capi/bindings/dart/CollatorOptions.g.dart b/ffi/capi/bindings/dart/CollatorOptions.g.dart index a8093ff42f5..f57b397eb7f 100644 --- a/ffi/capi/bindings/dart/CollatorOptions.g.dart +++ b/ffi/capi/bindings/dart/CollatorOptions.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; final class _CollatorOptionsFfi extends ffi.Struct { @@ -34,54 +31,53 @@ final class CollatorOptions { CollatorOptions({required this.strength, required this.alternateHandling, required this.caseFirst, required this.maxVariable, required this.caseLevel, required this.numeric, required this.backwardSecondLevel}); - // ignore: unused_element - // Internal constructor from FFI. // 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. - CollatorOptions._(_CollatorOptionsFfi underlying) : - strength = CollatorStrength.values[underlying.strength], - alternateHandling = CollatorAlternateHandling.values[underlying.alternateHandling], - caseFirst = CollatorCaseFirst.values[underlying.caseFirst], - maxVariable = CollatorMaxVariable.values[underlying.maxVariable], - caseLevel = CollatorCaseLevel.values[underlying.caseLevel], - numeric = CollatorNumeric.values[underlying.numeric], - backwardSecondLevel = CollatorBackwardSecondLevel.values[underlying.backwardSecondLevel]; + // 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 _pointer(ffi.Allocator temp) { - final pointer = temp<_CollatorOptionsFfi>(); - pointer.ref.strength = strength.index; - pointer.ref.alternateHandling = alternateHandling.index; - pointer.ref.caseFirst = caseFirst.index; - pointer.ref.maxVariable = maxVariable.index; - pointer.ref.caseLevel = caseLevel.index; - pointer.ref.numeric = numeric.index; - pointer.ref.backwardSecondLevel = backwardSecondLevel.index; - return pointer.ref; + _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 == this.strength && - other.alternateHandling == this.alternateHandling && - other.caseFirst == this.caseFirst && - other.maxVariable == this.maxVariable && - other.caseLevel == this.caseLevel && - other.numeric == this.numeric && - other.backwardSecondLevel == this.backwardSecondLevel; + 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([ - this.strength, - this.alternateHandling, - this.caseFirst, - this.maxVariable, - this.caseLevel, - this.numeric, - this.backwardSecondLevel, + strength, + alternateHandling, + caseFirst, + maxVariable, + caseLevel, + numeric, + backwardSecondLevel, ]); } diff --git a/ffi/capi/bindings/dart/CollatorStrength.g.dart b/ffi/capi/bindings/dart/CollatorStrength.g.dart index e9bc7435a71..dbf12c7aabf 100644 --- a/ffi/capi/bindings/dart/CollatorStrength.g.dart +++ b/ffi/capi/bindings/dart/CollatorStrength.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// See the [Rust documentation for `Strength`](https://docs.rs/icu/latest/icu/collator/enum.Strength.html) for more information. diff --git a/ffi/capi/bindings/dart/ComposingNormalizer.g.dart b/ffi/capi/bindings/dart/ComposingNormalizer.g.dart index ead48fbd975..f2c4a674082 100644 --- a/ffi/capi/bindings/dart/ComposingNormalizer.g.dart +++ b/ffi/capi/bindings/dart/ComposingNormalizer.g.dart @@ -1,25 +1,22 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + ComposingNormalizer._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,11 +28,11 @@ final class ComposingNormalizer implements ffi.Finalizable { /// /// Throws [Error] on failure. factory ComposingNormalizer.nfc(DataProvider provider) { - final result = _ICU4XComposingNormalizer_create_nfc(provider._underlying); + final result = _ICU4XComposingNormalizer_create_nfc(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return ComposingNormalizer._(result.union.ok, true, []); + return ComposingNormalizer._fromFfi(result.union.ok, []); } /// Construct a new ICU4XComposingNormalizer instance for NFKC @@ -44,11 +41,11 @@ final class ComposingNormalizer implements ffi.Finalizable { /// /// Throws [Error] on failure. factory ComposingNormalizer.nfkc(DataProvider provider) { - final result = _ICU4XComposingNormalizer_create_nfkc(provider._underlying); + final result = _ICU4XComposingNormalizer_create_nfkc(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return ComposingNormalizer._(result.union.ok, true, []); + return ComposingNormalizer._fromFfi(result.union.ok, []); } /// Normalize a string @@ -63,10 +60,10 @@ final class ComposingNormalizer implements ffi.Finalizable { final temp = ffi2.Arena(); final sView = s.utf8View; final writeable = _Writeable(); - final result = _ICU4XComposingNormalizer_normalize(_underlying, sView.pointer(temp), sView.length, writeable._underlying); + final result = _ICU4XComposingNormalizer_normalize(_ffi, sView.allocIn(temp), sView.length, writeable._ffi); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -80,33 +77,33 @@ final class ComposingNormalizer implements ffi.Finalizable { bool isNormalized(String s) { final temp = ffi2.Arena(); final sView = s.utf8View; - final result = _ICU4XComposingNormalizer_is_normalized(_underlying, sView.pointer(temp), sView.length); + final result = _ICU4XComposingNormalizer_is_normalized(_ffi, sView.allocIn(temp), sView.length); temp.releaseAll(); return result; } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XComposingNormalizer_is_normalized') @ffi.Native, 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/ffi/capi/bindings/dart/CustomTimeZone.g.dart b/ffi/capi/bindings/dart/CustomTimeZone.g.dart index afbaf1634be..21a7f4b2ae6 100644 --- a/ffi/capi/bindings/dart/CustomTimeZone.g.dart +++ b/ffi/capi/bindings/dart/CustomTimeZone.g.dart @@ -1,25 +1,22 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + CustomTimeZone._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -33,12 +30,12 @@ final class CustomTimeZone implements ffi.Finalizable { factory CustomTimeZone.fromString(String s) { final temp = ffi2.Arena(); final sView = s.utf8View; - final result = _ICU4XCustomTimeZone_create_from_string(sView.pointer(temp), sView.length); + final result = _ICU4XCustomTimeZone_create_from_string(sView.allocIn(temp), sView.length); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return CustomTimeZone._(result.union.ok, true, []); + return CustomTimeZone._fromFfi(result.union.ok, []); } /// Creates a time zone with no information. @@ -46,7 +43,7 @@ final class CustomTimeZone implements ffi.Finalizable { /// 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._(result, true, []); + return CustomTimeZone._fromFfi(result, []); } /// Creates a time zone for UTC. @@ -54,7 +51,7 @@ final class CustomTimeZone implements ffi.Finalizable { /// 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._(result, true, []); + return CustomTimeZone._fromFfi(result, []); } /// Sets the `gmt_offset` field from offset seconds. @@ -67,9 +64,9 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Throws [Error] on failure. void trySetGmtOffsetSeconds(int offsetSeconds) { - final result = _ICU4XCustomTimeZone_try_set_gmt_offset_seconds(_underlying, offsetSeconds); + final result = _ICU4XCustomTimeZone_try_set_gmt_offset_seconds(_ffi, offsetSeconds); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -80,7 +77,7 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html) void clearGmtOffset() { - _ICU4XCustomTimeZone_clear_gmt_offset(_underlying); + _ICU4XCustomTimeZone_clear_gmt_offset(_ffi); } /// Returns the value of the `gmt_offset` field as offset seconds. @@ -93,9 +90,9 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Throws [Error] on failure. int get gmtOffsetSeconds { - final result = _ICU4XCustomTimeZone_gmt_offset_seconds(_underlying); + final result = _ICU4XCustomTimeZone_gmt_offset_seconds(_ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return result.union.ok; } @@ -108,9 +105,9 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Throws [Error] on failure. bool get isGmtOffsetPositive { - final result = _ICU4XCustomTimeZone_is_gmt_offset_positive(_underlying); + final result = _ICU4XCustomTimeZone_is_gmt_offset_positive(_ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return result.union.ok; } @@ -123,9 +120,9 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Throws [Error] on failure. bool get isGmtOffsetZero { - final result = _ICU4XCustomTimeZone_is_gmt_offset_zero(_underlying); + final result = _ICU4XCustomTimeZone_is_gmt_offset_zero(_ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return result.union.ok; } @@ -138,9 +135,9 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Throws [Error] on failure. bool gmtOffsetHasMinutes() { - final result = _ICU4XCustomTimeZone_gmt_offset_has_minutes(_underlying); + final result = _ICU4XCustomTimeZone_gmt_offset_has_minutes(_ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return result.union.ok; } @@ -153,9 +150,9 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Throws [Error] on failure. bool gmtOffsetHasSeconds() { - final result = _ICU4XCustomTimeZone_gmt_offset_has_seconds(_underlying); + final result = _ICU4XCustomTimeZone_gmt_offset_has_seconds(_ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return result.union.ok; } @@ -172,10 +169,10 @@ final class CustomTimeZone implements ffi.Finalizable { void trySetTimeZoneId(String id) { final temp = ffi2.Arena(); final idView = id.utf8View; - final result = _ICU4XCustomTimeZone_try_set_time_zone_id(_underlying, idView.pointer(temp), idView.length); + 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -191,10 +188,10 @@ final class CustomTimeZone implements ffi.Finalizable { void trySetIanaTimeZoneId(IanaToBcp47Mapper mapper, String id) { final temp = ffi2.Arena(); final idView = id.utf8View; - final result = _ICU4XCustomTimeZone_try_set_iana_time_zone_id(_underlying, mapper._underlying, idView.pointer(temp), idView.length); + 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -205,7 +202,7 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneBcp47Id.html) void clearTimeZoneId() { - _ICU4XCustomTimeZone_clear_time_zone_id(_underlying); + _ICU4XCustomTimeZone_clear_time_zone_id(_ffi); } /// Writes the value of the `time_zone_id` field as a string. @@ -219,9 +216,9 @@ final class CustomTimeZone implements ffi.Finalizable { /// Throws [Error] on failure. String get timeZoneId { final writeable = _Writeable(); - final result = _ICU4XCustomTimeZone_time_zone_id(_underlying, writeable._underlying); + final result = _ICU4XCustomTimeZone_time_zone_id(_ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -238,10 +235,10 @@ final class CustomTimeZone implements ffi.Finalizable { void trySetMetazoneId(String id) { final temp = ffi2.Arena(); final idView = id.utf8View; - final result = _ICU4XCustomTimeZone_try_set_metazone_id(_underlying, idView.pointer(temp), idView.length); + final result = _ICU4XCustomTimeZone_try_set_metazone_id(_ffi, idView.allocIn(temp), idView.length); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -252,7 +249,7 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneId.html) void clearMetazoneId() { - _ICU4XCustomTimeZone_clear_metazone_id(_underlying); + _ICU4XCustomTimeZone_clear_metazone_id(_ffi); } /// Writes the value of the `metazone_id` field as a string. @@ -266,9 +263,9 @@ final class CustomTimeZone implements ffi.Finalizable { /// Throws [Error] on failure. String get metazoneId { final writeable = _Writeable(); - final result = _ICU4XCustomTimeZone_metazone_id(_underlying, writeable._underlying); + final result = _ICU4XCustomTimeZone_metazone_id(_ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -285,10 +282,10 @@ final class CustomTimeZone implements ffi.Finalizable { void trySetZoneVariant(String id) { final temp = ffi2.Arena(); final idView = id.utf8View; - final result = _ICU4XCustomTimeZone_try_set_zone_variant(_underlying, idView.pointer(temp), idView.length); + final result = _ICU4XCustomTimeZone_try_set_zone_variant(_ffi, idView.allocIn(temp), idView.length); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -299,7 +296,7 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html) void clearZoneVariant() { - _ICU4XCustomTimeZone_clear_zone_variant(_underlying); + _ICU4XCustomTimeZone_clear_zone_variant(_ffi); } /// Writes the value of the `zone_variant` field as a string. @@ -313,9 +310,9 @@ final class CustomTimeZone implements ffi.Finalizable { /// Throws [Error] on failure. String get zoneVariant { final writeable = _Writeable(); - final result = _ICU4XCustomTimeZone_zone_variant(_underlying, writeable._underlying); + final result = _ICU4XCustomTimeZone_zone_variant(_ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -326,7 +323,7 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) void setStandardTime() { - _ICU4XCustomTimeZone_set_standard_time(_underlying); + _ICU4XCustomTimeZone_set_standard_time(_ffi); } /// Sets the `zone_variant` field to daylight time. @@ -335,7 +332,7 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) void setDaylightTime() { - _ICU4XCustomTimeZone_set_daylight_time(_underlying); + _ICU4XCustomTimeZone_set_daylight_time(_ffi); } /// Returns whether the `zone_variant` field is standard time. @@ -348,9 +345,9 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Throws [Error] on failure. bool get isStandardTime { - final result = _ICU4XCustomTimeZone_is_standard_time(_underlying); + final result = _ICU4XCustomTimeZone_is_standard_time(_ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return result.union.ok; } @@ -365,9 +362,9 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// Throws [Error] on failure. bool get isDaylightTime { - final result = _ICU4XCustomTimeZone_is_daylight_time(_underlying); + final result = _ICU4XCustomTimeZone_is_daylight_time(_ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return result.union.ok; } @@ -378,136 +375,136 @@ final class CustomTimeZone implements ffi.Finalizable { /// /// 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(_underlying, metazoneCalculator._underlying, localDatetime._underlying); + _ICU4XCustomTimeZone_maybe_calculate_metazone(_ffi, metazoneCalculator._ffi, localDatetime._ffi); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XCustomTimeZone_maybe_calculate_metazone') @ffi.Native, 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/ffi/capi/bindings/dart/DataProvider.g.dart b/ffi/capi/bindings/dart/DataProvider.g.dart index e23814b4b25..626f387e1d9 100644 --- a/ffi/capi/bindings/dart/DataProvider.g.dart +++ b/ffi/capi/bindings/dart/DataProvider.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + DataProvider._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -35,7 +32,7 @@ final class DataProvider implements ffi.Finalizable { /// `enabled_fallback_with`, `fork_by_locale`, and `fork_by_key` will return `Err`s. factory DataProvider.compiled() { final result = _ICU4XDataProvider_create_compiled(); - return DataProvider._(result, true, []); + return DataProvider._fromFfi(result, []); } /// Constructs a `BlobDataProvider` and returns it as an [`DataProvider`]. @@ -46,12 +43,12 @@ final class DataProvider implements ffi.Finalizable { factory DataProvider.fromByteSlice(ByteBuffer blob) { final temp = ffi2.Arena(); final blobView = blob; - final result = _ICU4XDataProvider_create_from_byte_slice(blobView.pointer(temp), blobView.length); + final result = _ICU4XDataProvider_create_from_byte_slice(blobView.allocIn(temp), blobView.length); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return DataProvider._(result.union.ok, true, []); + return DataProvider._fromFfi(result.union.ok, []); } /// Constructs an empty [`DataProvider`]. @@ -59,7 +56,7 @@ final class DataProvider implements ffi.Finalizable { /// 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._(result, true, []); + return DataProvider._fromFfi(result, []); } /// Creates a provider that tries the current provider and then, if the current provider @@ -75,9 +72,9 @@ final class DataProvider implements ffi.Finalizable { /// /// Throws [Error] on failure. void forkByKey(DataProvider other) { - final result = _ICU4XDataProvider_fork_by_key(_underlying, other._underlying); + final result = _ICU4XDataProvider_fork_by_key(_ffi, other._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -88,9 +85,9 @@ final class DataProvider implements ffi.Finalizable { /// /// Throws [Error] on failure. void forkByLocale(DataProvider other) { - final result = _ICU4XDataProvider_fork_by_locale(_underlying, other._underlying); + final result = _ICU4XDataProvider_fork_by_locale(_ffi, other._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -105,9 +102,9 @@ final class DataProvider implements ffi.Finalizable { /// /// Throws [Error] on failure. void enableLocaleFallback() { - final result = _ICU4XDataProvider_enable_locale_fallback(_underlying); + final result = _ICU4XDataProvider_enable_locale_fallback(_ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -118,50 +115,50 @@ final class DataProvider implements ffi.Finalizable { /// /// Throws [Error] on failure. void enableLocaleFallbackWith(LocaleFallbacker fallbacker) { - final result = _ICU4XDataProvider_enable_locale_fallback_with(_underlying, fallbacker._underlying); + final result = _ICU4XDataProvider_enable_locale_fallback_with(_ffi, fallbacker._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/Date.g.dart b/ffi/capi/bindings/dart/Date.g.dart index 455fbfefb37..b9ba4140b10 100644 --- a/ffi/capi/bindings/dart/Date.g.dart +++ b/ffi/capi/bindings/dart/Date.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + Date._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -34,11 +31,11 @@ final class Date implements ffi.Finalizable { /// /// 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._underlying); + final result = _ICU4XDate_create_from_iso_in_calendar(year, month, day, calendar._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return Date._(result.union.ok, true, []); + return Date._fromFfi(result.union.ok, []); } /// Creates a new [`Date`] from the given codes, which are interpreted in the given calendar system @@ -50,35 +47,35 @@ final class Date implements ffi.Finalizable { final temp = ffi2.Arena(); final eraCodeView = eraCode.utf8View; final monthCodeView = monthCode.utf8View; - final result = _ICU4XDate_create_from_codes_in_calendar(eraCodeView.pointer(temp), eraCodeView.length, year, monthCodeView.pointer(temp), monthCodeView.length, day, calendar._underlying); + 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return Date._(result.union.ok, true, []); + 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(_underlying, calendar._underlying); - return Date._(result, true, []); + 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(_underlying); - return IsoDate._(result, true, []); + 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(_underlying); + final result = _ICU4XDate_day_of_month(_ffi); return result; } @@ -86,8 +83,8 @@ final class Date implements ffi.Finalizable { /// /// 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(_underlying); - return IsoWeekday.values.firstWhere((v) => v._underlying == result); + 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 @@ -97,7 +94,7 @@ final class Date implements ffi.Finalizable { /// /// 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(_underlying, firstWeekday._underlying); + final result = _ICU4XDate_week_of_month(_ffi, firstWeekday._ffi); return result; } @@ -107,11 +104,11 @@ final class Date implements ffi.Finalizable { /// /// Throws [Error] on failure. WeekOf weekOfYear(WeekCalculator calculator) { - final result = _ICU4XDate_week_of_year(_underlying, calculator._underlying); + final result = _ICU4XDate_week_of_year(_ffi, calculator._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return WeekOf._(result.union.ok); + return WeekOf._fromFfi(result.union.ok); } /// Returns 1-indexed number of the month of this date in its year @@ -122,7 +119,7 @@ final class Date implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XDate_ordinal_month(_ffi); return result; } @@ -134,9 +131,9 @@ final class Date implements ffi.Finalizable { /// Throws [Error] on failure. String get monthCode { final writeable = _Writeable(); - final result = _ICU4XDate_month_code(_underlying, writeable._underlying); + final result = _ICU4XDate_month_code(_ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -145,7 +142,7 @@ final class Date implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XDate_year_in_era(_ffi); return result; } @@ -158,9 +155,9 @@ final class Date implements ffi.Finalizable { /// Throws [Error] on failure. String get era { final writeable = _Writeable(); - final result = _ICU4XDate_era(_underlying, writeable._underlying); + final result = _ICU4XDate_era(_ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -169,7 +166,7 @@ final class Date implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XDate_months_in_year(_ffi); return result; } @@ -177,7 +174,7 @@ final class Date implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XDate_days_in_month(_ffi); return result; } @@ -185,7 +182,7 @@ final class Date implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XDate_days_in_year(_ffi); return result; } @@ -193,92 +190,92 @@ final class Date implements ffi.Finalizable { /// /// 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(_underlying); - return Calendar._(result, true, []); + final result = _ICU4XDate_calendar(_ffi); + return Calendar._fromFfi(result, []); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XDate_to_calendar') @ffi.Native 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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/DateFormatter.g.dart b/ffi/capi/bindings/dart/DateFormatter.g.dart index 07182019bd2..037dfccfe2d 100644 --- a/ffi/capi/bindings/dart/DateFormatter.g.dart +++ b/ffi/capi/bindings/dart/DateFormatter.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// An ICU4X DateFormatter object capable of formatting a [`Date`] as a string, @@ -10,19 +7,19 @@ part of 'lib.g.dart'; /// /// 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + DateFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -34,11 +31,11 @@ final class DateFormatter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory DateFormatter.withLength(DataProvider provider, Locale locale, DateLength dateLength) { - final result = _ICU4XDateFormatter_create_with_length(provider._underlying, locale._underlying, dateLength.index); + final result = _ICU4XDateFormatter_create_with_length(provider._ffi, locale._ffi, dateLength.index); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return DateFormatter._(result.union.ok, true, []); + return DateFormatter._fromFfi(result.union.ok, []); } /// Formats a [`Date`] to a string. @@ -48,9 +45,9 @@ final class DateFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String formatDate(Date value) { final writeable = _Writeable(); - final result = _ICU4XDateFormatter_format_date(_underlying, value._underlying, writeable._underlying); + final result = _ICU4XDateFormatter_format_date(_ffi, value._ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -64,9 +61,9 @@ final class DateFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String formatIsoDate(IsoDate value) { final writeable = _Writeable(); - final result = _ICU4XDateFormatter_format_iso_date(_underlying, value._underlying, writeable._underlying); + final result = _ICU4XDateFormatter_format_iso_date(_ffi, value._ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -78,9 +75,9 @@ final class DateFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String formatDatetime(DateTime value) { final writeable = _Writeable(); - final result = _ICU4XDateFormatter_format_datetime(_underlying, value._underlying, writeable._underlying); + final result = _ICU4XDateFormatter_format_datetime(_ffi, value._ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -94,40 +91,40 @@ final class DateFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String formatIsoDatetime(IsoDateTime value) { final writeable = _Writeable(); - final result = _ICU4XDateFormatter_format_iso_datetime(_underlying, value._underlying, writeable._underlying); + final result = _ICU4XDateFormatter_format_iso_datetime(_ffi, value._ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/DateLength.g.dart b/ffi/capi/bindings/dart/DateLength.g.dart index 2ef92c67b85..f464422006d 100644 --- a/ffi/capi/bindings/dart/DateLength.g.dart +++ b/ffi/capi/bindings/dart/DateLength.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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. diff --git a/ffi/capi/bindings/dart/DateTime.g.dart b/ffi/capi/bindings/dart/DateTime.g.dart index 1f4075213e7..42b9a1f81d1 100644 --- a/ffi/capi/bindings/dart/DateTime.g.dart +++ b/ffi/capi/bindings/dart/DateTime.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + DateTime._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -34,11 +31,11 @@ final class DateTime implements ffi.Finalizable { /// /// 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._underlying); + 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return DateTime._(result.union.ok, true, []); + return DateTime._fromFfi(result.union.ok, []); } /// Creates a new [`DateTime`] from the given codes, which are interpreted in the given calendar system @@ -50,59 +47,59 @@ final class DateTime implements ffi.Finalizable { final temp = ffi2.Arena(); final eraCodeView = eraCode.utf8View; final monthCodeView = monthCode.utf8View; - final result = _ICU4XDateTime_create_from_codes_in_calendar(eraCodeView.pointer(temp), eraCodeView.length, year, monthCodeView.pointer(temp), monthCodeView.length, day, hour, minute, second, nanosecond, calendar._underlying); + 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return DateTime._(result.union.ok, true, []); + 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._underlying, time._underlying); - return DateTime._(result, true, []); + 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(_underlying); - return Date._(result, true, []); + 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(_underlying); - return Time._(result, true, []); + 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(_underlying); - return IsoDateTime._(result, true, []); + 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(_underlying, calendar._underlying); - return DateTime._(result, true, []); + 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/types/struct.Time.html#structfield.hour) for more information. int get hour { - final result = _ICU4XDateTime_hour(_underlying); + final result = _ICU4XDateTime_hour(_ffi); return result; } @@ -110,7 +107,7 @@ final class DateTime implements ffi.Finalizable { /// /// See the [Rust documentation for `minute`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.minute) for more information. int get minute { - final result = _ICU4XDateTime_minute(_underlying); + final result = _ICU4XDateTime_minute(_ffi); return result; } @@ -118,7 +115,7 @@ final class DateTime implements ffi.Finalizable { /// /// See the [Rust documentation for `second`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.second) for more information. int get second { - final result = _ICU4XDateTime_second(_underlying); + final result = _ICU4XDateTime_second(_ffi); return result; } @@ -126,7 +123,7 @@ final class DateTime implements ffi.Finalizable { /// /// See the [Rust documentation for `nanosecond`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.nanosecond) for more information. int get nanosecond { - final result = _ICU4XDateTime_nanosecond(_underlying); + final result = _ICU4XDateTime_nanosecond(_ffi); return result; } @@ -134,7 +131,7 @@ final class DateTime implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XDateTime_day_of_month(_ffi); return result; } @@ -142,8 +139,8 @@ final class DateTime implements ffi.Finalizable { /// /// 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(_underlying); - return IsoWeekday.values.firstWhere((v) => v._underlying == result); + 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 @@ -153,7 +150,7 @@ final class DateTime implements ffi.Finalizable { /// /// 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(_underlying, firstWeekday._underlying); + final result = _ICU4XDateTime_week_of_month(_ffi, firstWeekday._ffi); return result; } @@ -163,11 +160,11 @@ final class DateTime implements ffi.Finalizable { /// /// Throws [Error] on failure. WeekOf weekOfYear(WeekCalculator calculator) { - final result = _ICU4XDateTime_week_of_year(_underlying, calculator._underlying); + final result = _ICU4XDateTime_week_of_year(_ffi, calculator._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return WeekOf._(result.union.ok); + return WeekOf._fromFfi(result.union.ok); } /// Returns 1-indexed number of the month of this date in its year @@ -178,7 +175,7 @@ final class DateTime implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XDateTime_ordinal_month(_ffi); return result; } @@ -190,9 +187,9 @@ final class DateTime implements ffi.Finalizable { /// Throws [Error] on failure. String get monthCode { final writeable = _Writeable(); - final result = _ICU4XDateTime_month_code(_underlying, writeable._underlying); + final result = _ICU4XDateTime_month_code(_ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -201,7 +198,7 @@ final class DateTime implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XDateTime_year_in_era(_ffi); return result; } @@ -212,9 +209,9 @@ final class DateTime implements ffi.Finalizable { /// Throws [Error] on failure. String get era { final writeable = _Writeable(); - final result = _ICU4XDateTime_era(_underlying, writeable._underlying); + final result = _ICU4XDateTime_era(_ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -223,7 +220,7 @@ final class DateTime implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XDateTime_months_in_year(_ffi); return result; } @@ -231,7 +228,7 @@ final class DateTime implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XDateTime_days_in_month(_ffi); return result; } @@ -239,7 +236,7 @@ final class DateTime implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XDateTime_days_in_year(_ffi); return result; } @@ -247,127 +244,127 @@ final class DateTime implements ffi.Finalizable { /// /// 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(_underlying); - return Calendar._(result, true, []); + final result = _ICU4XDateTime_calendar(_ffi); + return Calendar._fromFfi(result, []); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XDateTime_create_from_date_and_time') @ffi.Native 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() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XDateTime_to_calendar') @ffi.Native 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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/DateTimeFormatter.g.dart b/ffi/capi/bindings/dart/DateTimeFormatter.g.dart index 3ffda8ea770..8954c4be6a2 100644 --- a/ffi/capi/bindings/dart/DateTimeFormatter.g.dart +++ b/ffi/capi/bindings/dart/DateTimeFormatter.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// An ICU4X DateFormatter object capable of formatting a [`DateTime`] as a string, @@ -10,19 +7,19 @@ part of 'lib.g.dart'; /// /// 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + DateTimeFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -34,11 +31,11 @@ final class DateTimeFormatter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory DateTimeFormatter.withLengths(DataProvider provider, Locale locale, DateLength dateLength, TimeLength timeLength) { - final result = _ICU4XDateTimeFormatter_create_with_lengths(provider._underlying, locale._underlying, dateLength.index, timeLength.index); + final result = _ICU4XDateTimeFormatter_create_with_lengths(provider._ffi, locale._ffi, dateLength.index, timeLength.index); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return DateTimeFormatter._(result.union.ok, true, []); + return DateTimeFormatter._fromFfi(result.union.ok, []); } /// Formats a [`DateTime`] to a string. @@ -48,9 +45,9 @@ final class DateTimeFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String formatDatetime(DateTime value) { final writeable = _Writeable(); - final result = _ICU4XDateTimeFormatter_format_datetime(_underlying, value._underlying, writeable._underlying); + final result = _ICU4XDateTimeFormatter_format_datetime(_ffi, value._ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -64,30 +61,30 @@ final class DateTimeFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String formatIsoDatetime(IsoDateTime value) { final writeable = _Writeable(); - final result = _ICU4XDateTimeFormatter_format_iso_datetime(_underlying, value._underlying, writeable._underlying); + final result = _ICU4XDateTimeFormatter_format_iso_datetime(_ffi, value._ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/Decomposed.g.dart b/ffi/capi/bindings/dart/Decomposed.g.dart index 4aa398c3e11..eb57d321d24 100644 --- a/ffi/capi/bindings/dart/Decomposed.g.dart +++ b/ffi/capi/bindings/dart/Decomposed.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; final class _DecomposedFfi extends ffi.Struct { @@ -21,34 +18,33 @@ final class Decomposed { final Rune first; final Rune second; - // ignore: unused_element - // Internal constructor from FFI. // 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. - Decomposed._(_DecomposedFfi underlying) : - first = underlying.first, - second = underlying.second; + // ignore: unused_element + Decomposed._fromFfi(_DecomposedFfi ffi) : + first = ffi.first, + second = ffi.second; // ignore: unused_element - _DecomposedFfi _pointer(ffi.Allocator temp) { - final pointer = temp<_DecomposedFfi>(); - pointer.ref.first = first; - pointer.ref.second = second; - return pointer.ref; + _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 == this.first && - other.second == this.second; + other.first == first && + other.second == second; @override int get hashCode => Object.hashAll([ - this.first, - this.second, + first, + second, ]); } diff --git a/ffi/capi/bindings/dart/DecomposingNormalizer.g.dart b/ffi/capi/bindings/dart/DecomposingNormalizer.g.dart index e76ed03ffc1..d672c4f421b 100644 --- a/ffi/capi/bindings/dart/DecomposingNormalizer.g.dart +++ b/ffi/capi/bindings/dart/DecomposingNormalizer.g.dart @@ -1,25 +1,22 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + DecomposingNormalizer._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,11 +28,11 @@ final class DecomposingNormalizer implements ffi.Finalizable { /// /// Throws [Error] on failure. factory DecomposingNormalizer.nfd(DataProvider provider) { - final result = _ICU4XDecomposingNormalizer_create_nfd(provider._underlying); + final result = _ICU4XDecomposingNormalizer_create_nfd(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return DecomposingNormalizer._(result.union.ok, true, []); + return DecomposingNormalizer._fromFfi(result.union.ok, []); } /// Construct a new ICU4XDecomposingNormalizer instance for NFKC @@ -44,11 +41,11 @@ final class DecomposingNormalizer implements ffi.Finalizable { /// /// Throws [Error] on failure. factory DecomposingNormalizer.nfkd(DataProvider provider) { - final result = _ICU4XDecomposingNormalizer_create_nfkd(provider._underlying); + final result = _ICU4XDecomposingNormalizer_create_nfkd(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return DecomposingNormalizer._(result.union.ok, true, []); + return DecomposingNormalizer._fromFfi(result.union.ok, []); } /// Normalize a string @@ -63,10 +60,10 @@ final class DecomposingNormalizer implements ffi.Finalizable { final temp = ffi2.Arena(); final sView = s.utf8View; final writeable = _Writeable(); - final result = _ICU4XDecomposingNormalizer_normalize(_underlying, sView.pointer(temp), sView.length, writeable._underlying); + final result = _ICU4XDecomposingNormalizer_normalize(_ffi, sView.allocIn(temp), sView.length, writeable._ffi); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -80,33 +77,33 @@ final class DecomposingNormalizer implements ffi.Finalizable { bool isNormalized(String s) { final temp = ffi2.Arena(); final sView = s.utf8View; - final result = _ICU4XDecomposingNormalizer_is_normalized(_underlying, sView.pointer(temp), sView.length); + final result = _ICU4XDecomposingNormalizer_is_normalized(_ffi, sView.allocIn(temp), sView.length); temp.releaseAll(); return result; } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XDecomposingNormalizer_is_normalized') @ffi.Native, 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/ffi/capi/bindings/dart/DisplayNamesFallback.g.dart b/ffi/capi/bindings/dart/DisplayNamesFallback.g.dart index baa65196e07..18d4a960e15 100644 --- a/ffi/capi/bindings/dart/DisplayNamesFallback.g.dart +++ b/ffi/capi/bindings/dart/DisplayNamesFallback.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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. diff --git a/ffi/capi/bindings/dart/DisplayNamesOptions.g.dart b/ffi/capi/bindings/dart/DisplayNamesOptions.g.dart index 4d7d3d27b2c..b68cbc06d29 100644 --- a/ffi/capi/bindings/dart/DisplayNamesOptions.g.dart +++ b/ffi/capi/bindings/dart/DisplayNamesOptions.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; final class _DisplayNamesOptionsFfi extends ffi.Struct { @@ -22,38 +19,37 @@ final class DisplayNamesOptions { DisplayNamesOptions({required this.style, required this.fallback, required this.languageDisplay}); - // ignore: unused_element - // Internal constructor from FFI. // 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. - DisplayNamesOptions._(_DisplayNamesOptionsFfi underlying) : - style = DisplayNamesStyle.values[underlying.style], - fallback = DisplayNamesFallback.values[underlying.fallback], - languageDisplay = LanguageDisplay.values[underlying.languageDisplay]; + // 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 _pointer(ffi.Allocator temp) { - final pointer = temp<_DisplayNamesOptionsFfi>(); - pointer.ref.style = style.index; - pointer.ref.fallback = fallback.index; - pointer.ref.languageDisplay = languageDisplay.index; - return pointer.ref; + _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 == this.style && - other.fallback == this.fallback && - other.languageDisplay == this.languageDisplay; + other.style == style && + other.fallback == fallback && + other.languageDisplay == languageDisplay; @override int get hashCode => Object.hashAll([ - this.style, - this.fallback, - this.languageDisplay, + style, + fallback, + languageDisplay, ]); } diff --git a/ffi/capi/bindings/dart/DisplayNamesStyle.g.dart b/ffi/capi/bindings/dart/DisplayNamesStyle.g.dart index 6c10b5c255e..052b61311a0 100644 --- a/ffi/capi/bindings/dart/DisplayNamesStyle.g.dart +++ b/ffi/capi/bindings/dart/DisplayNamesStyle.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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. diff --git a/ffi/capi/bindings/dart/Error.g.dart b/ffi/capi/bindings/dart/Error.g.dart index b6b544d8827..8f18a7e6a27 100644 --- a/ffi/capi/bindings/dart/Error.g.dart +++ b/ffi/capi/bindings/dart/Error.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// A common enum for errors that ICU4X may return, organized by API @@ -129,7 +126,7 @@ enum Error { normalizerValidationError; - int get _underlying { + int get _ffi { switch (this) { case unknownError: return 0; diff --git a/ffi/capi/bindings/dart/FixedDecimal.g.dart b/ffi/capi/bindings/dart/FixedDecimal.g.dart index 83a652bda8e..3ec44337e18 100644 --- a/ffi/capi/bindings/dart/FixedDecimal.g.dart +++ b/ffi/capi/bindings/dart/FixedDecimal.g.dart @@ -1,25 +1,22 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + FixedDecimal._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -30,7 +27,7 @@ final class FixedDecimal implements ffi.Finalizable { /// 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._(result, true, []); + return FixedDecimal._fromFfi(result, []); } /// Construct an [`FixedDecimal`] from an float, with a given power of 10 for the lower magnitude @@ -43,9 +40,9 @@ final class FixedDecimal implements ffi.Finalizable { 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return FixedDecimal._(result.union.ok, true, []); + return FixedDecimal._fromFfi(result.union.ok, []); } /// Construct an [`FixedDecimal`] from an float, for a given number of significant digits @@ -58,9 +55,9 @@ final class FixedDecimal implements ffi.Finalizable { 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return FixedDecimal._(result.union.ok, true, []); + return FixedDecimal._fromFfi(result.union.ok, []); } /// Construct an [`FixedDecimal`] from an float, with enough digits to recover @@ -74,9 +71,9 @@ final class FixedDecimal implements ffi.Finalizable { factory FixedDecimal.fromDoubleWithDoublePrecision(double f) { final result = _ICU4XFixedDecimal_create_from_f64_with_floating_precision(f); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return FixedDecimal._(result.union.ok, true, []); + return FixedDecimal._fromFfi(result.union.ok, []); } /// Construct an [`FixedDecimal`] from a string. @@ -87,47 +84,47 @@ final class FixedDecimal implements ffi.Finalizable { factory FixedDecimal.fromString(String v) { final temp = ffi2.Arena(); final vView = v.utf8View; - final result = _ICU4XFixedDecimal_create_from_string(vView.pointer(temp), vView.length); + final result = _ICU4XFixedDecimal_create_from_string(vView.allocIn(temp), vView.length); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return FixedDecimal._(result.union.ok, true, []); + 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(_underlying, 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(_underlying); + 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(_underlying); + 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(_underlying); + 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(_underlying); + 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(_underlying); + final result = _ICU4XFixedDecimal_is_zero(_ffi); return result; } @@ -135,12 +132,12 @@ final class FixedDecimal implements ffi.Finalizable { /// /// 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(_underlying, 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(_underlying); + final result = _ICU4XFixedDecimal_sign(_ffi); return FixedDecimalSign.values[result]; } @@ -148,36 +145,36 @@ final class FixedDecimal implements ffi.Finalizable { /// /// 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(_underlying, sign.index); + _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(_underlying, signDisplay.index); + _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(_underlying); + _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(_underlying); + _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(_underlying, 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(_underlying, 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 @@ -185,97 +182,97 @@ final class FixedDecimal implements ffi.Finalizable { /// /// 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(_underlying, 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(_underlying, 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(_underlying, position, increment.index); + _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(_underlying, 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(_underlying, position, increment.index); + _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(_underlying, 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(_underlying, position, increment.index); + _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(_underlying, 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(_underlying, position, increment.index); + _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(_underlying, 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(_underlying, position, increment.index); + _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(_underlying, 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(_underlying, position, increment.index); + _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(_underlying, 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(_underlying, position, increment.index); + _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(_underlying, 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(_underlying, position, increment.index); + _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(_underlying, 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(_underlying, position, increment.index); + _ICU4XFixedDecimal_half_even_to_increment(_ffi, position, increment.index); } /// Concatenates `other` to the end of `self`. @@ -286,7 +283,7 @@ final class FixedDecimal implements ffi.Finalizable { /// /// 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(_underlying, other._underlying); + final result = _ICU4XFixedDecimal_concatenate_end(_ffi, other._ffi); return result.isOk; } @@ -296,212 +293,212 @@ final class FixedDecimal implements ffi.Finalizable { @override String toString() { final writeable = _Writeable(); - _ICU4XFixedDecimal_to_string(_underlying, writeable._underlying); + _ICU4XFixedDecimal_to_string(_ffi, writeable._ffi); return writeable.finalize(); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XFixedDecimal_to_string') @ffi.Native, 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/ffi/capi/bindings/dart/FixedDecimalFormatter.g.dart b/ffi/capi/bindings/dart/FixedDecimalFormatter.g.dart index 2c16b2dfd23..b077a837860 100644 --- a/ffi/capi/bindings/dart/FixedDecimalFormatter.g.dart +++ b/ffi/capi/bindings/dart/FixedDecimalFormatter.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + FixedDecimalFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -33,11 +30,11 @@ final class FixedDecimalFormatter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory FixedDecimalFormatter.withGroupingStrategy(DataProvider provider, Locale locale, FixedDecimalGroupingStrategy groupingStrategy) { - final result = _ICU4XFixedDecimalFormatter_create_with_grouping_strategy(provider._underlying, locale._underlying, groupingStrategy.index); + final result = _ICU4XFixedDecimalFormatter_create_with_grouping_strategy(provider._ffi, locale._ffi, groupingStrategy.index); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return FixedDecimalFormatter._(result.union.ok, true, []); + return FixedDecimalFormatter._fromFfi(result.union.ok, []); } /// Formats a [`FixedDecimal`] to a string. @@ -47,25 +44,25 @@ final class FixedDecimalFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String format(FixedDecimal value) { final writeable = _Writeable(); - final result = _ICU4XFixedDecimalFormatter_format(_underlying, value._underlying, writeable._underlying); + final result = _ICU4XFixedDecimalFormatter_format(_ffi, value._ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } } -@meta.ResourceIdentifier() +@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() +@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() +@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/ffi/capi/bindings/dart/FixedDecimalGroupingStrategy.g.dart b/ffi/capi/bindings/dart/FixedDecimalGroupingStrategy.g.dart index 40bf429f4b4..982929a5af1 100644 --- a/ffi/capi/bindings/dart/FixedDecimalGroupingStrategy.g.dart +++ b/ffi/capi/bindings/dart/FixedDecimalGroupingStrategy.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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. diff --git a/ffi/capi/bindings/dart/FixedDecimalSign.g.dart b/ffi/capi/bindings/dart/FixedDecimalSign.g.dart index da6cc6b7662..0aa5a9dfe05 100644 --- a/ffi/capi/bindings/dart/FixedDecimalSign.g.dart +++ b/ffi/capi/bindings/dart/FixedDecimalSign.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// The sign of a FixedDecimal, as shown in formatting. diff --git a/ffi/capi/bindings/dart/FixedDecimalSignDisplay.g.dart b/ffi/capi/bindings/dart/FixedDecimalSignDisplay.g.dart index a3e46b5a080..244008ed5b6 100644 --- a/ffi/capi/bindings/dart/FixedDecimalSignDisplay.g.dart +++ b/ffi/capi/bindings/dart/FixedDecimalSignDisplay.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// ECMA-402 compatible sign display preference. diff --git a/ffi/capi/bindings/dart/GeneralCategoryNameToMaskMapper.g.dart b/ffi/capi/bindings/dart/GeneralCategoryNameToMaskMapper.g.dart index 8a332a1c0ff..edf746118c2 100644 --- a/ffi/capi/bindings/dart/GeneralCategoryNameToMaskMapper.g.dart +++ b/ffi/capi/bindings/dart/GeneralCategoryNameToMaskMapper.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// A type capable of looking up General Category mask values from a string name. @@ -11,19 +8,19 @@ part of 'lib.g.dart'; /// /// 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + GeneralCategoryNameToMaskMapper._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -35,7 +32,7 @@ final class GeneralCategoryNameToMaskMapper implements ffi.Finalizable { int getStrict(String name) { final temp = ffi2.Arena(); final nameView = name.utf8View; - final result = _ICU4XGeneralCategoryNameToMaskMapper_get_strict(_underlying, nameView.pointer(temp), nameView.length); + final result = _ICU4XGeneralCategoryNameToMaskMapper_get_strict(_ffi, nameView.allocIn(temp), nameView.length); temp.releaseAll(); return result; } @@ -46,7 +43,7 @@ final class GeneralCategoryNameToMaskMapper implements ffi.Finalizable { int getLoose(String name) { final temp = ffi2.Arena(); final nameView = name.utf8View; - final result = _ICU4XGeneralCategoryNameToMaskMapper_get_loose(_underlying, nameView.pointer(temp), nameView.length); + final result = _ICU4XGeneralCategoryNameToMaskMapper_get_loose(_ffi, nameView.allocIn(temp), nameView.length); temp.releaseAll(); return result; } @@ -55,30 +52,30 @@ final class GeneralCategoryNameToMaskMapper implements ffi.Finalizable { /// /// Throws [Error] on failure. factory GeneralCategoryNameToMaskMapper.load(DataProvider provider) { - final result = _ICU4XGeneralCategoryNameToMaskMapper_load(provider._underlying); + final result = _ICU4XGeneralCategoryNameToMaskMapper_load(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return GeneralCategoryNameToMaskMapper._(result.union.ok, true, []); + return GeneralCategoryNameToMaskMapper._fromFfi(result.union.ok, []); } } -@meta.ResourceIdentifier() +@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() +@meta.ResourceIdentifier('ICU4XGeneralCategoryNameToMaskMapper_get_strict') @ffi.Native, 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() +@meta.ResourceIdentifier('ICU4XGeneralCategoryNameToMaskMapper_get_loose') @ffi.Native, 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() +@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/ffi/capi/bindings/dart/GraphemeClusterBreakIteratorLatin1.g.dart b/ffi/capi/bindings/dart/GraphemeClusterBreakIteratorLatin1.g.dart index 154fc250e2e..33339f5fea7 100644 --- a/ffi/capi/bindings/dart/GraphemeClusterBreakIteratorLatin1.g.dart +++ b/ffi/capi/bindings/dart/GraphemeClusterBreakIteratorLatin1.g.dart @@ -1,26 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_a; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_a) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + GraphemeClusterBreakIteratorLatin1._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,17 +29,17 @@ final class GraphemeClusterBreakIteratorLatin1 implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XGraphemeClusterBreakIteratorLatin1_next(_ffi); return result; } } -@meta.ResourceIdentifier() +@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() +@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/ffi/capi/bindings/dart/GraphemeClusterBreakIteratorUtf16.g.dart b/ffi/capi/bindings/dart/GraphemeClusterBreakIteratorUtf16.g.dart index fb5e67975ca..a37f85660c3 100644 --- a/ffi/capi/bindings/dart/GraphemeClusterBreakIteratorUtf16.g.dart +++ b/ffi/capi/bindings/dart/GraphemeClusterBreakIteratorUtf16.g.dart @@ -1,26 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_a; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_a) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + GraphemeClusterBreakIteratorUtf16._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,17 +29,17 @@ final class GraphemeClusterBreakIteratorUtf16 implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XGraphemeClusterBreakIteratorUtf16_next(_ffi); return result; } } -@meta.ResourceIdentifier() +@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() +@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/ffi/capi/bindings/dart/GraphemeClusterBreakIteratorUtf8.g.dart b/ffi/capi/bindings/dart/GraphemeClusterBreakIteratorUtf8.g.dart index 21c37c909e2..a801fefeeb5 100644 --- a/ffi/capi/bindings/dart/GraphemeClusterBreakIteratorUtf8.g.dart +++ b/ffi/capi/bindings/dart/GraphemeClusterBreakIteratorUtf8.g.dart @@ -1,26 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_a; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_a) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + GraphemeClusterBreakIteratorUtf8._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,17 +29,17 @@ final class GraphemeClusterBreakIteratorUtf8 implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XGraphemeClusterBreakIteratorUtf8_next(_ffi); return result; } } -@meta.ResourceIdentifier() +@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() +@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/ffi/capi/bindings/dart/GraphemeClusterSegmenter.g.dart b/ffi/capi/bindings/dart/GraphemeClusterSegmenter.g.dart index 48ffb6346a6..2aa34245c82 100644 --- a/ffi/capi/bindings/dart/GraphemeClusterSegmenter.g.dart +++ b/ffi/capi/bindings/dart/GraphemeClusterSegmenter.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// An ICU4X grapheme-cluster-break segmenter, capable of finding grapheme cluster breakpoints @@ -10,19 +7,19 @@ part of 'lib.g.dart'; /// /// 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + GraphemeClusterSegmenter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -34,11 +31,11 @@ final class GraphemeClusterSegmenter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory GraphemeClusterSegmenter(DataProvider provider) { - final result = _ICU4XGraphemeClusterSegmenter_create(provider._underlying); + final result = _ICU4XGraphemeClusterSegmenter_create(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return GraphemeClusterSegmenter._(result.union.ok, true, []); + return GraphemeClusterSegmenter._fromFfi(result.union.ok, []); } /// Segments a string. @@ -52,22 +49,22 @@ final class GraphemeClusterSegmenter implements ffi.Finalizable { final inputArena = _FinalizedArena(); // This lifetime edge depends on lifetimes: 'a core.List aEdges = [this, inputArena]; - final result = _ICU4XGraphemeClusterSegmenter_segment_utf16(_underlying, inputView.pointer(inputArena.arena), inputView.length); - return GraphemeClusterBreakIteratorUtf16._(result, true, [], aEdges); + final result = _ICU4XGraphemeClusterSegmenter_segment_utf16(_ffi, inputView.allocIn(inputArena.arena), inputView.length); + return GraphemeClusterBreakIteratorUtf16._fromFfi(result, [], aEdges); } } -@meta.ResourceIdentifier() +@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() +@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() +@meta.ResourceIdentifier('ICU4XGraphemeClusterSegmenter_segment_utf16') @ffi.Native 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/ffi/capi/bindings/dart/GregorianDateFormatter.g.dart b/ffi/capi/bindings/dart/GregorianDateFormatter.g.dart index 6bf40dbd9f6..0e4a0fddb39 100644 --- a/ffi/capi/bindings/dart/GregorianDateFormatter.g.dart +++ b/ffi/capi/bindings/dart/GregorianDateFormatter.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// An ICU4X TypedDateFormatter object capable of formatting a [`IsoDateTime`] as a string, @@ -10,19 +7,19 @@ part of 'lib.g.dart'; /// /// 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + GregorianDateFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -34,11 +31,11 @@ final class GregorianDateFormatter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory GregorianDateFormatter.withLength(DataProvider provider, Locale locale, DateLength length) { - final result = _ICU4XGregorianDateFormatter_create_with_length(provider._underlying, locale._underlying, length.index); + final result = _ICU4XGregorianDateFormatter_create_with_length(provider._ffi, locale._ffi, length.index); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return GregorianDateFormatter._(result.union.ok, true, []); + return GregorianDateFormatter._fromFfi(result.union.ok, []); } /// Formats a [`IsoDate`] to a string. @@ -48,9 +45,9 @@ final class GregorianDateFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String formatIsoDate(IsoDate value) { final writeable = _Writeable(); - final result = _ICU4XGregorianDateFormatter_format_iso_date(_underlying, value._underlying, writeable._underlying); + final result = _ICU4XGregorianDateFormatter_format_iso_date(_ffi, value._ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -62,30 +59,30 @@ final class GregorianDateFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String formatIsoDatetime(IsoDateTime value) { final writeable = _Writeable(); - final result = _ICU4XGregorianDateFormatter_format_iso_datetime(_underlying, value._underlying, writeable._underlying); + final result = _ICU4XGregorianDateFormatter_format_iso_datetime(_ffi, value._ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/GregorianDateTimeFormatter.g.dart b/ffi/capi/bindings/dart/GregorianDateTimeFormatter.g.dart index 1844f41e0eb..af535acf4d3 100644 --- a/ffi/capi/bindings/dart/GregorianDateTimeFormatter.g.dart +++ b/ffi/capi/bindings/dart/GregorianDateTimeFormatter.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// An ICU4X TypedDateTimeFormatter object capable of formatting a [`IsoDateTime`] as a string, @@ -10,19 +7,19 @@ part of 'lib.g.dart'; /// /// 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + GregorianDateTimeFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -34,11 +31,11 @@ final class GregorianDateTimeFormatter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory GregorianDateTimeFormatter.withLengths(DataProvider provider, Locale locale, DateLength dateLength, TimeLength timeLength) { - final result = _ICU4XGregorianDateTimeFormatter_create_with_lengths(provider._underlying, locale._underlying, dateLength.index, timeLength.index); + final result = _ICU4XGregorianDateTimeFormatter_create_with_lengths(provider._ffi, locale._ffi, dateLength.index, timeLength.index); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return GregorianDateTimeFormatter._(result.union.ok, true, []); + return GregorianDateTimeFormatter._fromFfi(result.union.ok, []); } /// Formats a [`IsoDateTime`] to a string. @@ -48,25 +45,25 @@ final class GregorianDateTimeFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String formatIsoDatetime(IsoDateTime value) { final writeable = _Writeable(); - final result = _ICU4XGregorianDateTimeFormatter_format_iso_datetime(_underlying, value._underlying, writeable._underlying); + final result = _ICU4XGregorianDateTimeFormatter_format_iso_datetime(_ffi, value._ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } } -@meta.ResourceIdentifier() +@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() +@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() +@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/ffi/capi/bindings/dart/GregorianZonedDateTimeFormatter.g.dart b/ffi/capi/bindings/dart/GregorianZonedDateTimeFormatter.g.dart index 91a141c83a2..e9644ffeb48 100644 --- a/ffi/capi/bindings/dart/GregorianZonedDateTimeFormatter.g.dart +++ b/ffi/capi/bindings/dart/GregorianZonedDateTimeFormatter.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + GregorianZonedDateTimeFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -36,11 +33,11 @@ final class GregorianZonedDateTimeFormatter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory GregorianZonedDateTimeFormatter.withLengths(DataProvider provider, Locale locale, DateLength dateLength, TimeLength timeLength) { - final result = _ICU4XGregorianZonedDateTimeFormatter_create_with_lengths(provider._underlying, locale._underlying, dateLength.index, timeLength.index); + final result = _ICU4XGregorianZonedDateTimeFormatter_create_with_lengths(provider._ffi, locale._ffi, dateLength.index, timeLength.index); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return GregorianZonedDateTimeFormatter._(result.union.ok, true, []); + return GregorianZonedDateTimeFormatter._fromFfi(result.union.ok, []); } /// Creates a new [`GregorianZonedDateTimeFormatter`] from locale data. @@ -53,12 +50,12 @@ final class GregorianZonedDateTimeFormatter implements ffi.Finalizable { /// 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._underlying, locale._underlying, dateLength.index, timeLength.index, zoneOptions._pointer(temp)); + 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return GregorianZonedDateTimeFormatter._(result.union.ok, true, []); + return GregorianZonedDateTimeFormatter._fromFfi(result.union.ok, []); } /// Formats a [`IsoDateTime`] and [`CustomTimeZone`] to a string. @@ -68,30 +65,30 @@ final class GregorianZonedDateTimeFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String formatIsoDatetimeWithCustomTimeZone(IsoDateTime datetime, CustomTimeZone timeZone) { final writeable = _Writeable(); - final result = _ICU4XGregorianZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone(_underlying, datetime._underlying, timeZone._underlying, writeable._underlying); + 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/IanaToBcp47Mapper.g.dart b/ffi/capi/bindings/dart/IanaToBcp47Mapper.g.dart index 0efd86479dc..5928d250c61 100644 --- a/ffi/capi/bindings/dart/IanaToBcp47Mapper.g.dart +++ b/ffi/capi/bindings/dart/IanaToBcp47Mapper.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// An object capable of mapping from an IANA time zone ID to a BCP-47 ID. @@ -13,19 +10,19 @@ part of 'lib.g.dart'; /// /// 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + IanaToBcp47Mapper._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -35,20 +32,20 @@ final class IanaToBcp47Mapper implements ffi.Finalizable { /// /// Throws [Error] on failure. factory IanaToBcp47Mapper(DataProvider provider) { - final result = _ICU4XIanaToBcp47Mapper_create(provider._underlying); + final result = _ICU4XIanaToBcp47Mapper_create(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return IanaToBcp47Mapper._(result.union.ok, true, []); + return IanaToBcp47Mapper._fromFfi(result.union.ok, []); } } -@meta.ResourceIdentifier() +@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() +@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); diff --git a/ffi/capi/bindings/dart/IsoDate.g.dart b/ffi/capi/bindings/dart/IsoDate.g.dart index b454826382f..393b0b3e2a1 100644 --- a/ffi/capi/bindings/dart/IsoDate.g.dart +++ b/ffi/capi/bindings/dart/IsoDate.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + IsoDate._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -35,9 +32,9 @@ final class IsoDate implements ffi.Finalizable { factory IsoDate(int year, int month, int day) { final result = _ICU4XIsoDate_create(year, month, day); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return IsoDate._(result.union.ok, true, []); + return IsoDate._fromFfi(result.union.ok, []); } /// Creates a new [`IsoDate`] representing January 1, 1970. @@ -45,28 +42,28 @@ final class IsoDate implements ffi.Finalizable { /// 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._(result, true, []); + 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(_underlying, calendar._underlying); - return Date._(result, true, []); + 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(_underlying); - return Date._(result, true, []); + 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(_underlying); + final result = _ICU4XIsoDate_day_of_month(_ffi); return result; } @@ -74,8 +71,8 @@ final class IsoDate implements ffi.Finalizable { /// /// 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(_underlying); - return IsoWeekday.values.firstWhere((v) => v._underlying == result); + 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 @@ -85,7 +82,7 @@ final class IsoDate implements ffi.Finalizable { /// /// 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(_underlying, firstWeekday._underlying); + final result = _ICU4XIsoDate_week_of_month(_ffi, firstWeekday._ffi); return result; } @@ -95,18 +92,18 @@ final class IsoDate implements ffi.Finalizable { /// /// Throws [Error] on failure. WeekOf weekOfYear(WeekCalculator calculator) { - final result = _ICU4XIsoDate_week_of_year(_underlying, calculator._underlying); + final result = _ICU4XIsoDate_week_of_year(_ffi, calculator._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return WeekOf._(result.union.ok); + 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(_underlying); + final result = _ICU4XIsoDate_month(_ffi); return result; } @@ -114,7 +111,7 @@ final class IsoDate implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XIsoDate_year(_ffi); return result; } @@ -122,7 +119,7 @@ final class IsoDate implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XIsoDate_is_in_leap_year(_ffi); return result; } @@ -130,7 +127,7 @@ final class IsoDate implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XIsoDate_months_in_year(_ffi); return result; } @@ -138,7 +135,7 @@ final class IsoDate implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XIsoDate_days_in_month(_ffi); return result; } @@ -146,82 +143,82 @@ final class IsoDate implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XIsoDate_days_in_year(_ffi); return result; } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XIsoDate_to_calendar') @ffi.Native 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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/IsoDateTime.g.dart b/ffi/capi/bindings/dart/IsoDateTime.g.dart index c5156a56791..6ff6b88830c 100644 --- a/ffi/capi/bindings/dart/IsoDateTime.g.dart +++ b/ffi/capi/bindings/dart/IsoDateTime.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + IsoDateTime._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -35,17 +32,17 @@ final class IsoDateTime implements ffi.Finalizable { 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return IsoDateTime._(result.union.ok, true, []); + 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._underlying, time._underlying); - return IsoDateTime._(result, true, []); + 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 @@ -53,7 +50,7 @@ final class IsoDateTime implements ffi.Finalizable { /// 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._(result, true, []); + return IsoDateTime._fromFfi(result, []); } /// Construct from the minutes since the local unix epoch for this date (Jan 1 1970, 00:00) @@ -61,23 +58,23 @@ final class IsoDateTime implements ffi.Finalizable { /// 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._(result, true, []); + 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(_underlying); - return IsoDate._(result, true, []); + 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(_underlying); - return Time._(result, true, []); + final result = _ICU4XIsoDateTime_time(_ffi); + return Time._fromFfi(result, []); } /// Converts this to an [`DateTime`] capable of being mixed with dates of @@ -85,15 +82,15 @@ final class IsoDateTime implements ffi.Finalizable { /// /// 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(_underlying); - return DateTime._(result, true, []); + 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(_underlying); + final result = _ICU4XIsoDateTime_minutes_since_local_unix_epoch(_ffi); return result; } @@ -101,15 +98,15 @@ final class IsoDateTime implements ffi.Finalizable { /// /// 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(_underlying, calendar._underlying); - return DateTime._(result, true, []); + 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/types/struct.Time.html#structfield.hour) for more information. int get hour { - final result = _ICU4XIsoDateTime_hour(_underlying); + final result = _ICU4XIsoDateTime_hour(_ffi); return result; } @@ -117,7 +114,7 @@ final class IsoDateTime implements ffi.Finalizable { /// /// See the [Rust documentation for `minute`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.minute) for more information. int get minute { - final result = _ICU4XIsoDateTime_minute(_underlying); + final result = _ICU4XIsoDateTime_minute(_ffi); return result; } @@ -125,7 +122,7 @@ final class IsoDateTime implements ffi.Finalizable { /// /// See the [Rust documentation for `second`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.second) for more information. int get second { - final result = _ICU4XIsoDateTime_second(_underlying); + final result = _ICU4XIsoDateTime_second(_ffi); return result; } @@ -133,7 +130,7 @@ final class IsoDateTime implements ffi.Finalizable { /// /// See the [Rust documentation for `nanosecond`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.nanosecond) for more information. int get nanosecond { - final result = _ICU4XIsoDateTime_nanosecond(_underlying); + final result = _ICU4XIsoDateTime_nanosecond(_ffi); return result; } @@ -141,7 +138,7 @@ final class IsoDateTime implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XIsoDateTime_day_of_month(_ffi); return result; } @@ -149,8 +146,8 @@ final class IsoDateTime implements ffi.Finalizable { /// /// 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(_underlying); - return IsoWeekday.values.firstWhere((v) => v._underlying == result); + 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 @@ -160,7 +157,7 @@ final class IsoDateTime implements ffi.Finalizable { /// /// 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(_underlying, firstWeekday._underlying); + final result = _ICU4XIsoDateTime_week_of_month(_ffi, firstWeekday._ffi); return result; } @@ -170,18 +167,18 @@ final class IsoDateTime implements ffi.Finalizable { /// /// Throws [Error] on failure. WeekOf weekOfYear(WeekCalculator calculator) { - final result = _ICU4XIsoDateTime_week_of_year(_underlying, calculator._underlying); + final result = _ICU4XIsoDateTime_week_of_year(_ffi, calculator._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return WeekOf._(result.union.ok); + 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(_underlying); + final result = _ICU4XIsoDateTime_month(_ffi); return result; } @@ -189,7 +186,7 @@ final class IsoDateTime implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XIsoDateTime_year(_ffi); return result; } @@ -197,7 +194,7 @@ final class IsoDateTime implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XIsoDateTime_is_in_leap_year(_ffi); return result; } @@ -205,7 +202,7 @@ final class IsoDateTime implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XIsoDateTime_months_in_year(_ffi); return result; } @@ -213,7 +210,7 @@ final class IsoDateTime implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XIsoDateTime_days_in_month(_ffi); return result; } @@ -221,127 +218,127 @@ final class IsoDateTime implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XIsoDateTime_days_in_year(_ffi); return result; } } -@meta.ResourceIdentifier() +@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() +@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() +@meta.ResourceIdentifier('ICU4XIsoDateTime_crate_from_date_and_time') @ffi.Native 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() +@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() +@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() +@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() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XIsoDateTime_to_calendar') @ffi.Native 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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/IsoTimeZoneFormat.g.dart b/ffi/capi/bindings/dart/IsoTimeZoneFormat.g.dart index 49d429b0982..eeb90ca31c6 100644 --- a/ffi/capi/bindings/dart/IsoTimeZoneFormat.g.dart +++ b/ffi/capi/bindings/dart/IsoTimeZoneFormat.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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. diff --git a/ffi/capi/bindings/dart/IsoTimeZoneMinuteDisplay.g.dart b/ffi/capi/bindings/dart/IsoTimeZoneMinuteDisplay.g.dart index 150a1915c91..fa3c67cf6b7 100644 --- a/ffi/capi/bindings/dart/IsoTimeZoneMinuteDisplay.g.dart +++ b/ffi/capi/bindings/dart/IsoTimeZoneMinuteDisplay.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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. diff --git a/ffi/capi/bindings/dart/IsoTimeZoneOptions.g.dart b/ffi/capi/bindings/dart/IsoTimeZoneOptions.g.dart index d0dfc74fbd3..a329ec9db75 100644 --- a/ffi/capi/bindings/dart/IsoTimeZoneOptions.g.dart +++ b/ffi/capi/bindings/dart/IsoTimeZoneOptions.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; final class _IsoTimeZoneOptionsFfi extends ffi.Struct { @@ -21,38 +18,37 @@ final class IsoTimeZoneOptions { IsoTimeZoneOptions({required this.format, required this.minutes, required this.seconds}); - // ignore: unused_element - // Internal constructor from FFI. // 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. - IsoTimeZoneOptions._(_IsoTimeZoneOptionsFfi underlying) : - format = IsoTimeZoneFormat.values[underlying.format], - minutes = IsoTimeZoneMinuteDisplay.values[underlying.minutes], - seconds = IsoTimeZoneSecondDisplay.values[underlying.seconds]; + // 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 _pointer(ffi.Allocator temp) { - final pointer = temp<_IsoTimeZoneOptionsFfi>(); - pointer.ref.format = format.index; - pointer.ref.minutes = minutes.index; - pointer.ref.seconds = seconds.index; - return pointer.ref; + _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 == this.format && - other.minutes == this.minutes && - other.seconds == this.seconds; + other.format == format && + other.minutes == minutes && + other.seconds == seconds; @override int get hashCode => Object.hashAll([ - this.format, - this.minutes, - this.seconds, + format, + minutes, + seconds, ]); } diff --git a/ffi/capi/bindings/dart/IsoTimeZoneSecondDisplay.g.dart b/ffi/capi/bindings/dart/IsoTimeZoneSecondDisplay.g.dart index 6792a42c3c8..d5be53e5be9 100644 --- a/ffi/capi/bindings/dart/IsoTimeZoneSecondDisplay.g.dart +++ b/ffi/capi/bindings/dart/IsoTimeZoneSecondDisplay.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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. diff --git a/ffi/capi/bindings/dart/IsoWeekday.g.dart b/ffi/capi/bindings/dart/IsoWeekday.g.dart index bd543822d98..094bb083876 100644 --- a/ffi/capi/bindings/dart/IsoWeekday.g.dart +++ b/ffi/capi/bindings/dart/IsoWeekday.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; enum IsoWeekday { @@ -20,7 +17,7 @@ enum IsoWeekday { sunday; - int get _underlying { + int get _ffi { switch (this) { case monday: return 1; diff --git a/ffi/capi/bindings/dart/LanguageDisplay.g.dart b/ffi/capi/bindings/dart/LanguageDisplay.g.dart index 2aad6e18952..c51293142d7 100644 --- a/ffi/capi/bindings/dart/LanguageDisplay.g.dart +++ b/ffi/capi/bindings/dart/LanguageDisplay.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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. diff --git a/ffi/capi/bindings/dart/LeadingAdjustment.g.dart b/ffi/capi/bindings/dart/LeadingAdjustment.g.dart index 8a3ec43c5aa..460421c172f 100644 --- a/ffi/capi/bindings/dart/LeadingAdjustment.g.dart +++ b/ffi/capi/bindings/dart/LeadingAdjustment.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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. diff --git a/ffi/capi/bindings/dart/LineBreakIteratorLatin1.g.dart b/ffi/capi/bindings/dart/LineBreakIteratorLatin1.g.dart index 29f50440861..a15468472cf 100644 --- a/ffi/capi/bindings/dart/LineBreakIteratorLatin1.g.dart +++ b/ffi/capi/bindings/dart/LineBreakIteratorLatin1.g.dart @@ -1,28 +1,26 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_a; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_a) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + LineBreakIteratorLatin1._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -33,17 +31,17 @@ final class LineBreakIteratorLatin1 implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XLineBreakIteratorLatin1_next(_ffi); return result; } } -@meta.ResourceIdentifier() +@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() +@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/ffi/capi/bindings/dart/LineBreakIteratorUtf16.g.dart b/ffi/capi/bindings/dart/LineBreakIteratorUtf16.g.dart index 335e4d1006b..6d48ffb6a77 100644 --- a/ffi/capi/bindings/dart/LineBreakIteratorUtf16.g.dart +++ b/ffi/capi/bindings/dart/LineBreakIteratorUtf16.g.dart @@ -1,28 +1,26 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_a; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_a) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + LineBreakIteratorUtf16._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -33,17 +31,17 @@ final class LineBreakIteratorUtf16 implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XLineBreakIteratorUtf16_next(_ffi); return result; } } -@meta.ResourceIdentifier() +@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() +@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/ffi/capi/bindings/dart/LineBreakIteratorUtf8.g.dart b/ffi/capi/bindings/dart/LineBreakIteratorUtf8.g.dart index ba7b8df38d9..7202f711f70 100644 --- a/ffi/capi/bindings/dart/LineBreakIteratorUtf8.g.dart +++ b/ffi/capi/bindings/dart/LineBreakIteratorUtf8.g.dart @@ -1,28 +1,26 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_a; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_a) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + LineBreakIteratorUtf8._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -33,17 +31,17 @@ final class LineBreakIteratorUtf8 implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XLineBreakIteratorUtf8_next(_ffi); return result; } } -@meta.ResourceIdentifier() +@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() +@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/ffi/capi/bindings/dart/LineBreakOptions.g.dart b/ffi/capi/bindings/dart/LineBreakOptions.g.dart index 043afee2b13..33bc19fecee 100644 --- a/ffi/capi/bindings/dart/LineBreakOptions.g.dart +++ b/ffi/capi/bindings/dart/LineBreakOptions.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; final class _LineBreakOptionsFfi extends ffi.Struct { @@ -22,38 +19,37 @@ final class LineBreakOptions { LineBreakOptions({required this.strictness, required this.wordOption, required this.jaZh}); - // ignore: unused_element - // Internal constructor from FFI. // 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. - LineBreakOptions._(_LineBreakOptionsFfi underlying) : - strictness = LineBreakStrictness.values[underlying.strictness], - wordOption = LineBreakWordOption.values[underlying.wordOption], - jaZh = underlying.jaZh; + // ignore: unused_element + LineBreakOptions._fromFfi(_LineBreakOptionsFfi ffi) : + strictness = LineBreakStrictness.values[ffi.strictness], + wordOption = LineBreakWordOption.values[ffi.wordOption], + jaZh = ffi.jaZh; // ignore: unused_element - _LineBreakOptionsFfi _pointer(ffi.Allocator temp) { - final pointer = temp<_LineBreakOptionsFfi>(); - pointer.ref.strictness = strictness.index; - pointer.ref.wordOption = wordOption.index; - pointer.ref.jaZh = jaZh; - return pointer.ref; + _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 == this.strictness && - other.wordOption == this.wordOption && - other.jaZh == this.jaZh; + other.strictness == strictness && + other.wordOption == wordOption && + other.jaZh == jaZh; @override int get hashCode => Object.hashAll([ - this.strictness, - this.wordOption, - this.jaZh, + strictness, + wordOption, + jaZh, ]); } diff --git a/ffi/capi/bindings/dart/LineBreakStrictness.g.dart b/ffi/capi/bindings/dart/LineBreakStrictness.g.dart index 9b9e9efd218..decea691434 100644 --- a/ffi/capi/bindings/dart/LineBreakStrictness.g.dart +++ b/ffi/capi/bindings/dart/LineBreakStrictness.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// See the [Rust documentation for `LineBreakStrictness`](https://docs.rs/icu/latest/icu/segmenter/enum.LineBreakStrictness.html) for more information. diff --git a/ffi/capi/bindings/dart/LineBreakWordOption.g.dart b/ffi/capi/bindings/dart/LineBreakWordOption.g.dart index a6a59f8e1ee..bd0d522f47a 100644 --- a/ffi/capi/bindings/dart/LineBreakWordOption.g.dart +++ b/ffi/capi/bindings/dart/LineBreakWordOption.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// See the [Rust documentation for `LineBreakWordOption`](https://docs.rs/icu/latest/icu/segmenter/enum.LineBreakWordOption.html) for more information. diff --git a/ffi/capi/bindings/dart/LineSegmenter.g.dart b/ffi/capi/bindings/dart/LineSegmenter.g.dart index 1e7b1cad254..01b4cde50e4 100644 --- a/ffi/capi/bindings/dart/LineSegmenter.g.dart +++ b/ffi/capi/bindings/dart/LineSegmenter.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + LineSegmenter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -34,11 +31,11 @@ final class LineSegmenter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory LineSegmenter.auto(DataProvider provider) { - final result = _ICU4XLineSegmenter_create_auto(provider._underlying); + final result = _ICU4XLineSegmenter_create_auto(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return LineSegmenter._(result.union.ok, true, []); + return LineSegmenter._fromFfi(result.union.ok, []); } /// Construct a [`LineSegmenter`] with default options and LSTM payload data for @@ -48,11 +45,11 @@ final class LineSegmenter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory LineSegmenter.lstm(DataProvider provider) { - final result = _ICU4XLineSegmenter_create_lstm(provider._underlying); + final result = _ICU4XLineSegmenter_create_lstm(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return LineSegmenter._(result.union.ok, true, []); + return LineSegmenter._fromFfi(result.union.ok, []); } /// Construct a [`LineSegmenter`] with default options and dictionary payload data for @@ -62,11 +59,11 @@ final class LineSegmenter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory LineSegmenter.dictionary(DataProvider provider) { - final result = _ICU4XLineSegmenter_create_dictionary(provider._underlying); + final result = _ICU4XLineSegmenter_create_dictionary(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return LineSegmenter._(result.union.ok, true, []); + return LineSegmenter._fromFfi(result.union.ok, []); } /// Construct a [`LineSegmenter`] with custom options. It automatically loads the best @@ -77,12 +74,12 @@ final class LineSegmenter implements ffi.Finalizable { /// Throws [Error] on failure. factory LineSegmenter.autoWithOptions(DataProvider provider, LineBreakOptions options) { final temp = ffi2.Arena(); - final result = _ICU4XLineSegmenter_create_auto_with_options_v1(provider._underlying, options._pointer(temp)); + final result = _ICU4XLineSegmenter_create_auto_with_options_v1(provider._ffi, options._toFfi(temp)); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return LineSegmenter._(result.union.ok, true, []); + return LineSegmenter._fromFfi(result.union.ok, []); } /// Construct a [`LineSegmenter`] with custom options and LSTM payload data for @@ -93,12 +90,12 @@ final class LineSegmenter implements ffi.Finalizable { /// Throws [Error] on failure. factory LineSegmenter.lstmWithOptions(DataProvider provider, LineBreakOptions options) { final temp = ffi2.Arena(); - final result = _ICU4XLineSegmenter_create_lstm_with_options_v1(provider._underlying, options._pointer(temp)); + final result = _ICU4XLineSegmenter_create_lstm_with_options_v1(provider._ffi, options._toFfi(temp)); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return LineSegmenter._(result.union.ok, true, []); + return LineSegmenter._fromFfi(result.union.ok, []); } /// Construct a [`LineSegmenter`] with custom options and dictionary payload data for @@ -109,12 +106,12 @@ final class LineSegmenter implements ffi.Finalizable { /// Throws [Error] on failure. factory LineSegmenter.dictionaryWithOptions(DataProvider provider, LineBreakOptions options) { final temp = ffi2.Arena(); - final result = _ICU4XLineSegmenter_create_dictionary_with_options_v1(provider._underlying, options._pointer(temp)); + final result = _ICU4XLineSegmenter_create_dictionary_with_options_v1(provider._ffi, options._toFfi(temp)); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return LineSegmenter._(result.union.ok, true, []); + return LineSegmenter._fromFfi(result.union.ok, []); } /// Segments a string. @@ -128,47 +125,47 @@ final class LineSegmenter implements ffi.Finalizable { final inputArena = _FinalizedArena(); // This lifetime edge depends on lifetimes: 'a core.List aEdges = [this, inputArena]; - final result = _ICU4XLineSegmenter_segment_utf16(_underlying, inputView.pointer(inputArena.arena), inputView.length); - return LineBreakIteratorUtf16._(result, true, [], aEdges); + final result = _ICU4XLineSegmenter_segment_utf16(_ffi, inputView.allocIn(inputArena.arena), inputView.length); + return LineBreakIteratorUtf16._fromFfi(result, [], aEdges); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XLineSegmenter_segment_utf16') @ffi.Native 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/ffi/capi/bindings/dart/List.g.dart b/ffi/capi/bindings/dart/List.g.dart index e391adb5e0f..052592ba4c2 100644 --- a/ffi/capi/bindings/dart/List.g.dart +++ b/ffi/capi/bindings/dart/List.g.dart @@ -1,25 +1,22 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// A list of strings final class List implements ffi.Finalizable { - final ffi.Pointer _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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. - List._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + List._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -28,14 +25,14 @@ final class List implements ffi.Finalizable { /// Create a new list of strings factory List() { final result = _ICU4XList_create(); - return List._(result, true, []); + return List._fromFfi(result, []); } /// Create a new list of strings with preallocated space to hold /// at least `capacity` elements factory List.withCapacity(int capacity) { final result = _ICU4XList_create_with_capacity(capacity); - return List._(result, true, []); + return List._fromFfi(result, []); } /// Push a string to the list @@ -45,49 +42,49 @@ final class List implements ffi.Finalizable { void push(String val) { final temp = ffi2.Arena(); final valView = val.utf8View; - _ICU4XList_push(_underlying, valView.pointer(temp), valView.length); + _ICU4XList_push(_ffi, valView.allocIn(temp), valView.length); temp.releaseAll(); } /// The number of elements in this list int get length { - final result = _ICU4XList_len(_underlying); + final result = _ICU4XList_len(_ffi); return result; } /// Whether this list is empty bool get isEmpty { - final result = _ICU4XList_is_empty(_underlying); + final result = _ICU4XList_is_empty(_ffi); return result; } } -@meta.ResourceIdentifier() +@meta.ResourceIdentifier('ICU4XList_destroy') @ffi.Native)>(isLeaf: true, symbol: 'ICU4XList_destroy') // ignore: non_constant_identifier_names external void _ICU4XList_destroy(ffi.Pointer self); -@meta.ResourceIdentifier() +@meta.ResourceIdentifier('ICU4XList_create') @ffi.Native Function()>(isLeaf: true, symbol: 'ICU4XList_create') // ignore: non_constant_identifier_names external ffi.Pointer _ICU4XList_create(); -@meta.ResourceIdentifier() +@meta.ResourceIdentifier('ICU4XList_create_with_capacity') @ffi.Native Function(ffi.Size)>(isLeaf: true, symbol: 'ICU4XList_create_with_capacity') // ignore: non_constant_identifier_names external ffi.Pointer _ICU4XList_create_with_capacity(int capacity); -@meta.ResourceIdentifier() +@meta.ResourceIdentifier('ICU4XList_push') @ffi.Native, ffi.Pointer, ffi.Size)>(isLeaf: true, symbol: 'ICU4XList_push') // ignore: non_constant_identifier_names external void _ICU4XList_push(ffi.Pointer self, ffi.Pointer valData, int valLength); -@meta.ResourceIdentifier() +@meta.ResourceIdentifier('ICU4XList_len') @ffi.Native)>(isLeaf: true, symbol: 'ICU4XList_len') // ignore: non_constant_identifier_names external int _ICU4XList_len(ffi.Pointer self); -@meta.ResourceIdentifier() +@meta.ResourceIdentifier('ICU4XList_is_empty') @ffi.Native)>(isLeaf: true, symbol: 'ICU4XList_is_empty') // ignore: non_constant_identifier_names external bool _ICU4XList_is_empty(ffi.Pointer self); diff --git a/ffi/capi/bindings/dart/ListFormatter.g.dart b/ffi/capi/bindings/dart/ListFormatter.g.dart index d0a046014a2..39057958844 100644 --- a/ffi/capi/bindings/dart/ListFormatter.g.dart +++ b/ffi/capi/bindings/dart/ListFormatter.g.dart @@ -1,25 +1,22 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + ListFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,11 +28,11 @@ final class ListFormatter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory ListFormatter.andWithLength(DataProvider provider, Locale locale, ListLength length) { - final result = _ICU4XListFormatter_create_and_with_length(provider._underlying, locale._underlying, length.index); + final result = _ICU4XListFormatter_create_and_with_length(provider._ffi, locale._ffi, length.index); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return ListFormatter._(result.union.ok, true, []); + return ListFormatter._fromFfi(result.union.ok, []); } /// Construct a new ICU4XListFormatter instance for And patterns @@ -44,11 +41,11 @@ final class ListFormatter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory ListFormatter.orWithLength(DataProvider provider, Locale locale, ListLength length) { - final result = _ICU4XListFormatter_create_or_with_length(provider._underlying, locale._underlying, length.index); + final result = _ICU4XListFormatter_create_or_with_length(provider._ffi, locale._ffi, length.index); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return ListFormatter._(result.union.ok, true, []); + return ListFormatter._fromFfi(result.union.ok, []); } /// Construct a new ICU4XListFormatter instance for And patterns @@ -57,11 +54,11 @@ final class ListFormatter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory ListFormatter.unitWithLength(DataProvider provider, Locale locale, ListLength length) { - final result = _ICU4XListFormatter_create_unit_with_length(provider._underlying, locale._underlying, length.index); + final result = _ICU4XListFormatter_create_unit_with_length(provider._ffi, locale._ffi, length.index); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return ListFormatter._(result.union.ok, true, []); + 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. @@ -69,35 +66,35 @@ final class ListFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String format(List list) { final writeable = _Writeable(); - final result = _ICU4XListFormatter_format(_underlying, list._underlying, writeable._underlying); + final result = _ICU4XListFormatter_format(_ffi, list._ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XListFormatter_format') @ffi.Native<_ResultVoidInt32 Function(ffi.Pointer, ffi.Pointer, ffi.Pointer)>(isLeaf: true, symbol: 'ICU4XListFormatter_format') // ignore: non_constant_identifier_names external _ResultVoidInt32 _ICU4XListFormatter_format(ffi.Pointer self, ffi.Pointer list, ffi.Pointer writeable); diff --git a/ffi/capi/bindings/dart/ListLength.g.dart b/ffi/capi/bindings/dart/ListLength.g.dart index c97bbc771c4..47cb4d884de 100644 --- a/ffi/capi/bindings/dart/ListLength.g.dart +++ b/ffi/capi/bindings/dart/ListLength.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// See the [Rust documentation for `ListLength`](https://docs.rs/icu/latest/icu/list/enum.ListLength.html) for more information. diff --git a/ffi/capi/bindings/dart/Locale.g.dart b/ffi/capi/bindings/dart/Locale.g.dart index 4579b959efd..738e7db2e7a 100644 --- a/ffi/capi/bindings/dart/Locale.g.dart +++ b/ffi/capi/bindings/dart/Locale.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 { - final ffi.Pointer _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + Locale._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -39,12 +36,12 @@ final class Locale implements ffi.Finalizable { factory Locale.fromString(String name) { final temp = ffi2.Arena(); final nameView = name.utf8View; - final result = _ICU4XLocale_create_from_string(nameView.pointer(temp), nameView.length); + final result = _ICU4XLocale_create_from_string(nameView.allocIn(temp), nameView.length); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return Locale._(result.union.ok, true, []); + return Locale._fromFfi(result.union.ok, []); } /// Construct a default undefined [`Locale`] "und". @@ -52,15 +49,15 @@ final class Locale implements ffi.Finalizable { /// 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._(result, true, []); + 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(_underlying); - return Locale._(result, true, []); + final result = _ICU4XLocale_clone(_ffi); + return Locale._fromFfi(result, []); } /// Write a string representation of the `LanguageIdentifier` part of @@ -71,9 +68,9 @@ final class Locale implements ffi.Finalizable { /// Throws [Error] on failure. String get basename { final writeable = _Writeable(); - final result = _ICU4XLocale_basename(_underlying, writeable._underlying); + final result = _ICU4XLocale_basename(_ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -87,10 +84,10 @@ final class Locale implements ffi.Finalizable { final temp = ffi2.Arena(); final bytesView = bytes.utf8View; final writeable = _Writeable(); - final result = _ICU4XLocale_get_unicode_extension(_underlying, bytesView.pointer(temp), bytesView.length, writeable._underlying); + 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -102,9 +99,9 @@ final class Locale implements ffi.Finalizable { /// Throws [Error] on failure. String get language { final writeable = _Writeable(); - final result = _ICU4XLocale_language(_underlying, writeable._underlying); + final result = _ICU4XLocale_language(_ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -117,10 +114,10 @@ final class Locale implements ffi.Finalizable { set language(String bytes) { final temp = ffi2.Arena(); final bytesView = bytes.utf8View; - final result = _ICU4XLocale_set_language(_underlying, bytesView.pointer(temp), bytesView.length); + final result = _ICU4XLocale_set_language(_ffi, bytesView.allocIn(temp), bytesView.length); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -132,9 +129,9 @@ final class Locale implements ffi.Finalizable { /// Throws [Error] on failure. String get region { final writeable = _Writeable(); - final result = _ICU4XLocale_region(_underlying, writeable._underlying); + final result = _ICU4XLocale_region(_ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -147,10 +144,10 @@ final class Locale implements ffi.Finalizable { set region(String bytes) { final temp = ffi2.Arena(); final bytesView = bytes.utf8View; - final result = _ICU4XLocale_set_region(_underlying, bytesView.pointer(temp), bytesView.length); + final result = _ICU4XLocale_set_region(_ffi, bytesView.allocIn(temp), bytesView.length); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -162,9 +159,9 @@ final class Locale implements ffi.Finalizable { /// Throws [Error] on failure. String get script { final writeable = _Writeable(); - final result = _ICU4XLocale_script(_underlying, writeable._underlying); + final result = _ICU4XLocale_script(_ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -177,10 +174,10 @@ final class Locale implements ffi.Finalizable { set script(String bytes) { final temp = ffi2.Arena(); final bytesView = bytes.utf8View; - final result = _ICU4XLocale_set_script(_underlying, bytesView.pointer(temp), bytesView.length); + final result = _ICU4XLocale_set_script(_ffi, bytesView.allocIn(temp), bytesView.length); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -196,10 +193,10 @@ final class Locale implements ffi.Finalizable { final temp = ffi2.Arena(); final bytesView = bytes.utf8View; final writeable = _Writeable(); - final result = _ICU4XLocale_canonicalize(bytesView.pointer(temp), bytesView.length, writeable._underlying); + final result = _ICU4XLocale_canonicalize(bytesView.allocIn(temp), bytesView.length, writeable._ffi); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -212,9 +209,9 @@ final class Locale implements ffi.Finalizable { @override String toString() { final writeable = _Writeable(); - final result = _ICU4XLocale_to_string(_underlying, writeable._underlying); + final result = _ICU4XLocale_to_string(_ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -223,7 +220,7 @@ final class Locale implements ffi.Finalizable { bool normalizingEq(String other) { final temp = ffi2.Arena(); final otherView = other.utf8View; - final result = _ICU4XLocale_normalizing_eq(_underlying, otherView.pointer(temp), otherView.length); + final result = _ICU4XLocale_normalizing_eq(_ffi, otherView.allocIn(temp), otherView.length); temp.releaseAll(); return result; } @@ -232,99 +229,99 @@ final class Locale implements ffi.Finalizable { Ordering strictCmp(String other) { final temp = ffi2.Arena(); final otherView = other.utf8View; - final result = _ICU4XLocale_strict_cmp(_underlying, otherView.pointer(temp), otherView.length); + final result = _ICU4XLocale_strict_cmp(_ffi, otherView.allocIn(temp), otherView.length); temp.releaseAll(); - return Ordering.values.firstWhere((v) => v._underlying == result); + return Ordering.values.firstWhere((v) => v._ffi == result); } /// See the [Rust documentation for `total_cmp`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.total_cmp) for more information. Ordering totalCmp(Locale other) { - final result = _ICU4XLocale_total_cmp(_underlying, other._underlying); - return Ordering.values.firstWhere((v) => v._underlying == result); + final result = _ICU4XLocale_total_cmp(_ffi, other._ffi); + return Ordering.values.firstWhere((v) => v._ffi == result); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XLocale_normalizing_eq') @ffi.Native, 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() +@meta.ResourceIdentifier('ICU4XLocale_strict_cmp') @ffi.Native, 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() +@meta.ResourceIdentifier('ICU4XLocale_total_cmp') @ffi.Native, 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/ffi/capi/bindings/dart/LocaleCanonicalizer.g.dart b/ffi/capi/bindings/dart/LocaleCanonicalizer.g.dart index 3a56b00e6bb..ac1f60d8465 100644 --- a/ffi/capi/bindings/dart/LocaleCanonicalizer.g.dart +++ b/ffi/capi/bindings/dart/LocaleCanonicalizer.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + LocaleCanonicalizer._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -33,11 +30,11 @@ final class LocaleCanonicalizer implements ffi.Finalizable { /// /// Throws [Error] on failure. factory LocaleCanonicalizer(DataProvider provider) { - final result = _ICU4XLocaleCanonicalizer_create(provider._underlying); + final result = _ICU4XLocaleCanonicalizer_create(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return LocaleCanonicalizer._(result.union.ok, true, []); + return LocaleCanonicalizer._fromFfi(result.union.ok, []); } /// Create a new [`LocaleCanonicalizer`] with extended data. @@ -46,36 +43,36 @@ final class LocaleCanonicalizer implements ffi.Finalizable { /// /// Throws [Error] on failure. factory LocaleCanonicalizer.extended(DataProvider provider) { - final result = _ICU4XLocaleCanonicalizer_create_extended(provider._underlying); + final result = _ICU4XLocaleCanonicalizer_create_extended(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return LocaleCanonicalizer._(result.union.ok, true, []); + 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(_underlying, locale._underlying); + final result = _ICU4XLocaleCanonicalizer_canonicalize(_ffi, locale._ffi); return TransformResult.values[result]; } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XLocaleCanonicalizer_canonicalize') @ffi.Native, 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/ffi/capi/bindings/dart/LocaleDirection.g.dart b/ffi/capi/bindings/dart/LocaleDirection.g.dart index 338eae42d8f..b2fb05f6555 100644 --- a/ffi/capi/bindings/dart/LocaleDirection.g.dart +++ b/ffi/capi/bindings/dart/LocaleDirection.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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. diff --git a/ffi/capi/bindings/dart/LocaleDirectionality.g.dart b/ffi/capi/bindings/dart/LocaleDirectionality.g.dart index 3f522586d31..e050072d81a 100644 --- a/ffi/capi/bindings/dart/LocaleDirectionality.g.dart +++ b/ffi/capi/bindings/dart/LocaleDirectionality.g.dart @@ -1,25 +1,22 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + LocaleDirectionality._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,11 +28,11 @@ final class LocaleDirectionality implements ffi.Finalizable { /// /// Throws [Error] on failure. factory LocaleDirectionality(DataProvider provider) { - final result = _ICU4XLocaleDirectionality_create(provider._underlying); + final result = _ICU4XLocaleDirectionality_create(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return LocaleDirectionality._(result.union.ok, true, []); + return LocaleDirectionality._fromFfi(result.union.ok, []); } /// Construct a new ICU4XLocaleDirectionality instance with a custom expander @@ -44,58 +41,58 @@ final class LocaleDirectionality implements ffi.Finalizable { /// /// Throws [Error] on failure. factory LocaleDirectionality.withExpander(DataProvider provider, LocaleExpander expander) { - final result = _ICU4XLocaleDirectionality_create_with_expander(provider._underlying, expander._underlying); + final result = _ICU4XLocaleDirectionality_create_with_expander(provider._ffi, expander._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return LocaleDirectionality._(result.union.ok, true, []); + 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(_underlying, locale._underlying); + 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(_underlying, locale._underlying); + 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(_underlying, locale._underlying); + final result = _ICU4XLocaleDirectionality_is_right_to_left(_ffi, locale._ffi); return result; } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XLocaleDirectionality_get') @ffi.Native, ffi.Pointer)>(isLeaf: true, symbol: 'ICU4XLocaleDirectionality_get') // ignore: non_constant_identifier_names external int _ICU4XLocaleDirectionality_get(ffi.Pointer self, ffi.Pointer locale); -@meta.ResourceIdentifier() +@meta.ResourceIdentifier('ICU4XLocaleDirectionality_is_left_to_right') @ffi.Native, 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() +@meta.ResourceIdentifier('ICU4XLocaleDirectionality_is_right_to_left') @ffi.Native, 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/ffi/capi/bindings/dart/LocaleDisplayNamesFormatter.g.dart b/ffi/capi/bindings/dart/LocaleDisplayNamesFormatter.g.dart index 58669ae2043..5020ae9c6c6 100644 --- a/ffi/capi/bindings/dart/LocaleDisplayNamesFormatter.g.dart +++ b/ffi/capi/bindings/dart/LocaleDisplayNamesFormatter.g.dart @@ -1,25 +1,22 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + LocaleDisplayNamesFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -32,12 +29,12 @@ final class LocaleDisplayNamesFormatter implements ffi.Finalizable { /// Throws [Error] on failure. factory LocaleDisplayNamesFormatter(DataProvider provider, Locale locale, DisplayNamesOptions options) { final temp = ffi2.Arena(); - final result = _ICU4XLocaleDisplayNamesFormatter_create(provider._underlying, locale._underlying, options._pointer(temp)); + final result = _ICU4XLocaleDisplayNamesFormatter_create(provider._ffi, locale._ffi, options._toFfi(temp)); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return LocaleDisplayNamesFormatter._(result.union.ok, true, []); + return LocaleDisplayNamesFormatter._fromFfi(result.union.ok, []); } /// Returns the locale-specific display name of a locale. @@ -47,25 +44,25 @@ final class LocaleDisplayNamesFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String of(Locale locale) { final writeable = _Writeable(); - final result = _ICU4XLocaleDisplayNamesFormatter_of(_underlying, locale._underlying, writeable._underlying); + final result = _ICU4XLocaleDisplayNamesFormatter_of(_ffi, locale._ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } } -@meta.ResourceIdentifier() +@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() +@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() +@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/ffi/capi/bindings/dart/LocaleExpander.g.dart b/ffi/capi/bindings/dart/LocaleExpander.g.dart index d5bd67568b2..5bb3e291a5e 100644 --- a/ffi/capi/bindings/dart/LocaleExpander.g.dart +++ b/ffi/capi/bindings/dart/LocaleExpander.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + LocaleExpander._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -33,11 +30,11 @@ final class LocaleExpander implements ffi.Finalizable { /// /// Throws [Error] on failure. factory LocaleExpander(DataProvider provider) { - final result = _ICU4XLocaleExpander_create(provider._underlying); + final result = _ICU4XLocaleExpander_create(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return LocaleExpander._(result.union.ok, true, []); + return LocaleExpander._fromFfi(result.union.ok, []); } /// Create a new [`LocaleExpander`] with extended data. @@ -46,47 +43,47 @@ final class LocaleExpander implements ffi.Finalizable { /// /// Throws [Error] on failure. factory LocaleExpander.extended(DataProvider provider) { - final result = _ICU4XLocaleExpander_create_extended(provider._underlying); + final result = _ICU4XLocaleExpander_create_extended(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return LocaleExpander._(result.union.ok, true, []); + 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(_underlying, locale._underlying); + 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(_underlying, locale._underlying); + final result = _ICU4XLocaleExpander_minimize(_ffi, locale._ffi); return TransformResult.values[result]; } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XLocaleExpander_maximize') @ffi.Native, ffi.Pointer)>(isLeaf: true, symbol: 'ICU4XLocaleExpander_maximize') // ignore: non_constant_identifier_names external int _ICU4XLocaleExpander_maximize(ffi.Pointer self, ffi.Pointer locale); -@meta.ResourceIdentifier() +@meta.ResourceIdentifier('ICU4XLocaleExpander_minimize') @ffi.Native, ffi.Pointer)>(isLeaf: true, symbol: 'ICU4XLocaleExpander_minimize') // ignore: non_constant_identifier_names external int _ICU4XLocaleExpander_minimize(ffi.Pointer self, ffi.Pointer locale); diff --git a/ffi/capi/bindings/dart/LocaleFallbackConfig.g.dart b/ffi/capi/bindings/dart/LocaleFallbackConfig.g.dart index f244f251b8c..b8761d1e998 100644 --- a/ffi/capi/bindings/dart/LocaleFallbackConfig.g.dart +++ b/ffi/capi/bindings/dart/LocaleFallbackConfig.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; final class _LocaleFallbackConfigFfi extends ffi.Struct { @@ -24,49 +21,45 @@ final class LocaleFallbackConfig { LocaleFallbackConfig({required this.priority, required this.extensionKey, required this.fallbackSupplement}); // ignore: unused_element - // Internal constructor from FFI. - LocaleFallbackConfig._(_LocaleFallbackConfigFfi underlying, core.List aEdges) : - priority = LocaleFallbackPriority.values[underlying.priority], - extensionKey = Utf8Decoder().convert(underlying.extensionKey._pointer.asTypedList(underlying.extensionKey._length)), - fallbackSupplement = LocaleFallbackSupplement.values[underlying.fallbackSupplement]; + LocaleFallbackConfig._fromFfi(_LocaleFallbackConfigFfi ffi, core.List aEdges) : + priority = LocaleFallbackPriority.values[ffi.priority], + extensionKey = ffi.extensionKey._toDart(aEdges), + fallbackSupplement = LocaleFallbackSupplement.values[ffi.fallbackSupplement]; - // ignore: unused_element // 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. - _LocaleFallbackConfigFfi _pointer(ffi.Allocator temp, {core.List>? aAppendArray}) { - final pointer = temp<_LocaleFallbackConfigFfi>(); - pointer.ref.priority = priority.index; + // 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; - pointer.ref.extensionKey._length = extensionKeyView.length; - final extensionKeyArena = (aAppendArray != null && !aAppendArray.isEmpty) ? _FinalizedArena.withLifetime(aAppendArray).arena : temp; - pointer.ref.extensionKey._pointer = extensionKeyView.pointer(extensionKeyArena); - pointer.ref.fallbackSupplement = fallbackSupplement.index; - return pointer.ref; + 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 == this.priority && - other.extensionKey == this.extensionKey && - other.fallbackSupplement == this.fallbackSupplement; + other.priority == priority && + other.extensionKey == extensionKey && + other.fallbackSupplement == fallbackSupplement; @override int get hashCode => Object.hashAll([ - this.priority, - this.extensionKey, - this.fallbackSupplement, + priority, + extensionKey, + fallbackSupplement, ]); - // ignore: unused element - // Append all fields corresponding to lifetime `'a` + // 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 _fields_for_lifetime_other() - core.List _fields_for_lifetime_a() { - return [extensionKey]; - } + // the caller should take care to also call _fieldsForLifetimeOther + // ignore: unused_element + core.List get _fieldsForLifetimeA => [extensionKey]; } diff --git a/ffi/capi/bindings/dart/LocaleFallbackIterator.g.dart b/ffi/capi/bindings/dart/LocaleFallbackIterator.g.dart index 500e42bd830..67b756bd612 100644 --- a/ffi/capi/bindings/dart/LocaleFallbackIterator.g.dart +++ b/ffi/capi/bindings/dart/LocaleFallbackIterator.g.dart @@ -1,28 +1,26 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 { - final ffi.Pointer _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_a; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_a) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + LocaleFallbackIterator._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -32,29 +30,29 @@ final class LocaleFallbackIterator implements ffi.Finalizable { /// /// See the [Rust documentation for `get`](https://docs.rs/icu/latest/icu/locid_transform/fallback/struct.LocaleFallbackIterator.html#method.get) for more information. Locale get get { - final result = _ICU4XLocaleFallbackIterator_get(_underlying); - return Locale._(result, true, []); + final result = _ICU4XLocaleFallbackIterator_get(_ffi); + return Locale._fromFfi(result, []); } /// Performs one step of the fallback algorithm, mutating the locale. /// /// See the [Rust documentation for `step`](https://docs.rs/icu/latest/icu/locid_transform/fallback/struct.LocaleFallbackIterator.html#method.step) for more information. void step() { - _ICU4XLocaleFallbackIterator_step(_underlying); + _ICU4XLocaleFallbackIterator_step(_ffi); } } -@meta.ResourceIdentifier() +@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() +@meta.ResourceIdentifier('ICU4XLocaleFallbackIterator_get') @ffi.Native Function(ffi.Pointer)>(isLeaf: true, symbol: 'ICU4XLocaleFallbackIterator_get') // ignore: non_constant_identifier_names external ffi.Pointer _ICU4XLocaleFallbackIterator_get(ffi.Pointer self); -@meta.ResourceIdentifier() +@meta.ResourceIdentifier('ICU4XLocaleFallbackIterator_step') @ffi.Native)>(isLeaf: true, symbol: 'ICU4XLocaleFallbackIterator_step') // ignore: non_constant_identifier_names external void _ICU4XLocaleFallbackIterator_step(ffi.Pointer self); diff --git a/ffi/capi/bindings/dart/LocaleFallbackPriority.g.dart b/ffi/capi/bindings/dart/LocaleFallbackPriority.g.dart index 3f617bae44c..16037422589 100644 --- a/ffi/capi/bindings/dart/LocaleFallbackPriority.g.dart +++ b/ffi/capi/bindings/dart/LocaleFallbackPriority.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// Priority mode for the ICU4X fallback algorithm. diff --git a/ffi/capi/bindings/dart/LocaleFallbackSupplement.g.dart b/ffi/capi/bindings/dart/LocaleFallbackSupplement.g.dart index e72e7e5c262..b74d815aca3 100644 --- a/ffi/capi/bindings/dart/LocaleFallbackSupplement.g.dart +++ b/ffi/capi/bindings/dart/LocaleFallbackSupplement.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// What additional data is required to load when performing fallback. diff --git a/ffi/capi/bindings/dart/LocaleFallbacker.g.dart b/ffi/capi/bindings/dart/LocaleFallbacker.g.dart index b3c3ac14d9c..5e0949da752 100644 --- a/ffi/capi/bindings/dart/LocaleFallbacker.g.dart +++ b/ffi/capi/bindings/dart/LocaleFallbacker.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + LocaleFallbacker._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -33,11 +30,11 @@ final class LocaleFallbacker implements ffi.Finalizable { /// /// Throws [Error] on failure. factory LocaleFallbacker(DataProvider provider) { - final result = _ICU4XLocaleFallbacker_create(provider._underlying); + final result = _ICU4XLocaleFallbacker_create(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return LocaleFallbacker._(result.union.ok, true, []); + return LocaleFallbacker._fromFfi(result.union.ok, []); } /// Creates a new `LocaleFallbacker` without data for limited functionality. @@ -45,7 +42,7 @@ final class LocaleFallbacker implements ffi.Finalizable { /// 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._(result, true, []); + return LocaleFallbacker._fromFfi(result, []); } /// Associates this `LocaleFallbacker` with configuration options. @@ -57,31 +54,31 @@ final class LocaleFallbacker implements ffi.Finalizable { final temp = ffi2.Arena(); // This lifetime edge depends on lifetimes: 'a core.List aEdges = [this]; - final result = _ICU4XLocaleFallbacker_for_config(_underlying, config._pointer(temp)); + final result = _ICU4XLocaleFallbacker_for_config(_ffi, config._toFfi(temp)); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return LocaleFallbackerWithConfig._(result.union.ok, true, [], aEdges); + return LocaleFallbackerWithConfig._fromFfi(result.union.ok, [], aEdges); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/LocaleFallbackerWithConfig.g.dart b/ffi/capi/bindings/dart/LocaleFallbackerWithConfig.g.dart index d8ad3933c84..2ec413301da 100644 --- a/ffi/capi/bindings/dart/LocaleFallbackerWithConfig.g.dart +++ b/ffi/capi/bindings/dart/LocaleFallbackerWithConfig.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// An object that runs the ICU4X locale fallback algorithm with specific configurations. @@ -11,20 +8,21 @@ part of 'lib.g.dart'; /// /// 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_a; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_a) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + LocaleFallbackerWithConfig._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -36,17 +34,17 @@ final class LocaleFallbackerWithConfig implements ffi.Finalizable { LocaleFallbackIterator fallbackForLocale(Locale locale) { // This lifetime edge depends on lifetimes: 'a, 'b core.List aEdges = [this]; - final result = _ICU4XLocaleFallbackerWithConfig_fallback_for_locale(_underlying, locale._underlying); - return LocaleFallbackIterator._(result, true, [], aEdges); + final result = _ICU4XLocaleFallbackerWithConfig_fallback_for_locale(_ffi, locale._ffi); + return LocaleFallbackIterator._fromFfi(result, [], aEdges); } } -@meta.ResourceIdentifier() +@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() +@meta.ResourceIdentifier('ICU4XLocaleFallbackerWithConfig_fallback_for_locale') @ffi.Native 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/ffi/capi/bindings/dart/Logger.g.dart b/ffi/capi/bindings/dart/Logger.g.dart index 34dd59461c0..ba7072f7d84 100644 --- a/ffi/capi/bindings/dart/Logger.g.dart +++ b/ffi/capi/bindings/dart/Logger.g.dart @@ -1,25 +1,22 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// An object allowing control over the logging used final class Logger implements ffi.Finalizable { - final ffi.Pointer _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + Logger._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -42,17 +39,17 @@ final class Logger implements ffi.Finalizable { } } -@meta.ResourceIdentifier() +@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() +@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() +@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/ffi/capi/bindings/dart/MetazoneCalculator.g.dart b/ffi/capi/bindings/dart/MetazoneCalculator.g.dart index 7b0a2959d5e..e88935f09f9 100644 --- a/ffi/capi/bindings/dart/MetazoneCalculator.g.dart +++ b/ffi/capi/bindings/dart/MetazoneCalculator.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// An object capable of computing the metazone from a timezone. @@ -13,19 +10,19 @@ part of 'lib.g.dart'; /// /// 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + MetazoneCalculator._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -35,20 +32,20 @@ final class MetazoneCalculator implements ffi.Finalizable { /// /// Throws [Error] on failure. factory MetazoneCalculator(DataProvider provider) { - final result = _ICU4XMetazoneCalculator_create(provider._underlying); + final result = _ICU4XMetazoneCalculator_create(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return MetazoneCalculator._(result.union.ok, true, []); + return MetazoneCalculator._fromFfi(result.union.ok, []); } } -@meta.ResourceIdentifier() +@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() +@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/ffi/capi/bindings/dart/Ordering.g.dart b/ffi/capi/bindings/dart/Ordering.g.dart index bfc2c9a418c..0b4ad1c6b51 100644 --- a/ffi/capi/bindings/dart/Ordering.g.dart +++ b/ffi/capi/bindings/dart/Ordering.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// See the [Rust documentation for `Ordering`](https://docs.rs/core/latest/core/cmp/enum.Ordering.html) for more information. @@ -13,7 +10,7 @@ enum Ordering { greater; - int get _underlying { + int get _ffi { switch (this) { case less: return -1; diff --git a/ffi/capi/bindings/dart/PluralCategories.g.dart b/ffi/capi/bindings/dart/PluralCategories.g.dart index 69a5c4f9697..c287f549799 100644 --- a/ffi/capi/bindings/dart/PluralCategories.g.dart +++ b/ffi/capi/bindings/dart/PluralCategories.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; final class _PluralCategoriesFfi extends ffi.Struct { @@ -28,50 +25,49 @@ final class PluralCategories { final bool many; final bool other; - // ignore: unused_element - // Internal constructor from FFI. // 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. - PluralCategories._(_PluralCategoriesFfi underlying) : - zero = underlying.zero, - one = underlying.one, - two = underlying.two, - few = underlying.few, - many = underlying.many, - other = underlying.other; + // 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 _pointer(ffi.Allocator temp) { - final pointer = temp<_PluralCategoriesFfi>(); - pointer.ref.zero = zero; - pointer.ref.one = one; - pointer.ref.two = two; - pointer.ref.few = few; - pointer.ref.many = many; - pointer.ref.other = other; - return pointer.ref; + _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 == this.zero && - other.one == this.one && - other.two == this.two && - other.few == this.few && - other.many == this.many && + 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([ - this.zero, - this.one, - this.two, - this.few, - this.many, - this.other, + zero, + one, + two, + few, + many, + other, ]); } diff --git a/ffi/capi/bindings/dart/PluralCategory.g.dart b/ffi/capi/bindings/dart/PluralCategory.g.dart index 9a1b520f111..e7d9fdc43e6 100644 --- a/ffi/capi/bindings/dart/PluralCategory.g.dart +++ b/ffi/capi/bindings/dart/PluralCategory.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// See the [Rust documentation for `PluralCategory`](https://docs.rs/icu/latest/icu/plurals/enum.PluralCategory.html) for more information. @@ -28,7 +25,7 @@ enum PluralCategory { static PluralCategory? getForCldrString(String s) { final temp = ffi2.Arena(); final sView = s.utf8View; - final result = _ICU4XPluralCategory_get_for_cldr_string(sView.pointer(temp), sView.length); + final result = _ICU4XPluralCategory_get_for_cldr_string(sView.allocIn(temp), sView.length); temp.releaseAll(); if (!result.isOk) { return null; @@ -37,7 +34,7 @@ enum PluralCategory { } } -@meta.ResourceIdentifier() +@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/ffi/capi/bindings/dart/PluralOperands.g.dart b/ffi/capi/bindings/dart/PluralOperands.g.dart index 62cda6c003b..9a38b722cb3 100644 --- a/ffi/capi/bindings/dart/PluralOperands.g.dart +++ b/ffi/capi/bindings/dart/PluralOperands.g.dart @@ -1,25 +1,22 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + PluralOperands._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -33,21 +30,21 @@ final class PluralOperands implements ffi.Finalizable { factory PluralOperands.fromString(String s) { final temp = ffi2.Arena(); final sView = s.utf8View; - final result = _ICU4XPluralOperands_create_from_string(sView.pointer(temp), sView.length); + final result = _ICU4XPluralOperands_create_from_string(sView.allocIn(temp), sView.length); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return PluralOperands._(result.union.ok, true, []); + return PluralOperands._fromFfi(result.union.ok, []); } } -@meta.ResourceIdentifier() +@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() +@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); diff --git a/ffi/capi/bindings/dart/PluralRules.g.dart b/ffi/capi/bindings/dart/PluralRules.g.dart index 86a43f85b65..bc9ecf86c33 100644 --- a/ffi/capi/bindings/dart/PluralRules.g.dart +++ b/ffi/capi/bindings/dart/PluralRules.g.dart @@ -1,25 +1,22 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + PluralRules._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,11 +28,11 @@ final class PluralRules implements ffi.Finalizable { /// /// Throws [Error] on failure. factory PluralRules.cardinal(DataProvider provider, Locale locale) { - final result = _ICU4XPluralRules_create_cardinal(provider._underlying, locale._underlying); + final result = _ICU4XPluralRules_create_cardinal(provider._ffi, locale._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return PluralRules._(result.union.ok, true, []); + return PluralRules._fromFfi(result.union.ok, []); } /// Construct an [`PluralRules`] for the given locale, for ordinal numbers @@ -44,18 +41,18 @@ final class PluralRules implements ffi.Finalizable { /// /// Throws [Error] on failure. factory PluralRules.ordinal(DataProvider provider, Locale locale) { - final result = _ICU4XPluralRules_create_ordinal(provider._underlying, locale._underlying); + final result = _ICU4XPluralRules_create_ordinal(provider._ffi, locale._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return PluralRules._(result.union.ok, true, []); + 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(_underlying, op._underlying); + final result = _ICU4XPluralRules_category_for(_ffi, op._ffi); return PluralCategory.values[result]; } @@ -63,32 +60,32 @@ final class PluralRules implements ffi.Finalizable { /// /// 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(_underlying); - return PluralCategories._(result); + final result = _ICU4XPluralRules_categories(_ffi); + return PluralCategories._fromFfi(result); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XPluralRules_category_for') @ffi.Native, 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() +@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/ffi/capi/bindings/dart/PropertyValueNameToEnumMapper.g.dart b/ffi/capi/bindings/dart/PropertyValueNameToEnumMapper.g.dart index 63f9e60bf7f..aac616ae8a7 100644 --- a/ffi/capi/bindings/dart/PropertyValueNameToEnumMapper.g.dart +++ b/ffi/capi/bindings/dart/PropertyValueNameToEnumMapper.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// A type capable of looking up a property value from a string name. @@ -11,19 +8,19 @@ part of 'lib.g.dart'; /// /// 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + PropertyValueNameToEnumMapper._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -37,7 +34,7 @@ final class PropertyValueNameToEnumMapper implements ffi.Finalizable { int getStrict(String name) { final temp = ffi2.Arena(); final nameView = name.utf8View; - final result = _ICU4XPropertyValueNameToEnumMapper_get_strict(_underlying, nameView.pointer(temp), nameView.length); + final result = _ICU4XPropertyValueNameToEnumMapper_get_strict(_ffi, nameView.allocIn(temp), nameView.length); temp.releaseAll(); return result; } @@ -50,7 +47,7 @@ final class PropertyValueNameToEnumMapper implements ffi.Finalizable { int getLoose(String name) { final temp = ffi2.Arena(); final nameView = name.utf8View; - final result = _ICU4XPropertyValueNameToEnumMapper_get_loose(_underlying, nameView.pointer(temp), nameView.length); + final result = _ICU4XPropertyValueNameToEnumMapper_get_loose(_ffi, nameView.allocIn(temp), nameView.length); temp.releaseAll(); return result; } @@ -59,158 +56,158 @@ final class PropertyValueNameToEnumMapper implements ffi.Finalizable { /// /// Throws [Error] on failure. factory PropertyValueNameToEnumMapper.loadGeneralCategory(DataProvider provider) { - final result = _ICU4XPropertyValueNameToEnumMapper_load_general_category(provider._underlying); + final result = _ICU4XPropertyValueNameToEnumMapper_load_general_category(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return PropertyValueNameToEnumMapper._(result.union.ok, true, []); + 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.loadBidiClass(DataProvider provider) { - final result = _ICU4XPropertyValueNameToEnumMapper_load_bidi_class(provider._underlying); + final result = _ICU4XPropertyValueNameToEnumMapper_load_bidi_class(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return PropertyValueNameToEnumMapper._(result.union.ok, true, []); + 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.loadEastAsianWidth(DataProvider provider) { - final result = _ICU4XPropertyValueNameToEnumMapper_load_east_asian_width(provider._underlying); + final result = _ICU4XPropertyValueNameToEnumMapper_load_east_asian_width(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return PropertyValueNameToEnumMapper._(result.union.ok, true, []); + 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.loadIndicSyllabicCategory(DataProvider provider) { - final result = _ICU4XPropertyValueNameToEnumMapper_load_indic_syllabic_category(provider._underlying); + final result = _ICU4XPropertyValueNameToEnumMapper_load_indic_syllabic_category(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return PropertyValueNameToEnumMapper._(result.union.ok, true, []); + 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.loadLineBreak(DataProvider provider) { - final result = _ICU4XPropertyValueNameToEnumMapper_load_line_break(provider._underlying); + final result = _ICU4XPropertyValueNameToEnumMapper_load_line_break(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return PropertyValueNameToEnumMapper._(result.union.ok, true, []); + 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.loadGraphemeClusterBreak(DataProvider provider) { - final result = _ICU4XPropertyValueNameToEnumMapper_load_grapheme_cluster_break(provider._underlying); + final result = _ICU4XPropertyValueNameToEnumMapper_load_grapheme_cluster_break(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return PropertyValueNameToEnumMapper._(result.union.ok, true, []); + 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.loadWordBreak(DataProvider provider) { - final result = _ICU4XPropertyValueNameToEnumMapper_load_word_break(provider._underlying); + final result = _ICU4XPropertyValueNameToEnumMapper_load_word_break(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return PropertyValueNameToEnumMapper._(result.union.ok, true, []); + 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.loadSentenceBreak(DataProvider provider) { - final result = _ICU4XPropertyValueNameToEnumMapper_load_sentence_break(provider._underlying); + final result = _ICU4XPropertyValueNameToEnumMapper_load_sentence_break(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return PropertyValueNameToEnumMapper._(result.union.ok, true, []); + 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.loadScript(DataProvider provider) { - final result = _ICU4XPropertyValueNameToEnumMapper_load_script(provider._underlying); + final result = _ICU4XPropertyValueNameToEnumMapper_load_script(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return PropertyValueNameToEnumMapper._(result.union.ok, true, []); + return PropertyValueNameToEnumMapper._fromFfi(result.union.ok, []); } } -@meta.ResourceIdentifier() +@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() +@meta.ResourceIdentifier('ICU4XPropertyValueNameToEnumMapper_get_strict') @ffi.Native, 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() +@meta.ResourceIdentifier('ICU4XPropertyValueNameToEnumMapper_get_loose') @ffi.Native, 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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/RegionDisplayNames.g.dart b/ffi/capi/bindings/dart/RegionDisplayNames.g.dart index 6ff83a63001..f51ac367ede 100644 --- a/ffi/capi/bindings/dart/RegionDisplayNames.g.dart +++ b/ffi/capi/bindings/dart/RegionDisplayNames.g.dart @@ -1,25 +1,22 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + RegionDisplayNames._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,11 +28,11 @@ final class RegionDisplayNames implements ffi.Finalizable { /// /// Throws [Error] on failure. factory RegionDisplayNames(DataProvider provider, Locale locale) { - final result = _ICU4XRegionDisplayNames_create(provider._underlying, locale._underlying); + final result = _ICU4XRegionDisplayNames_create(provider._ffi, locale._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return RegionDisplayNames._(result.union.ok, true, []); + return RegionDisplayNames._fromFfi(result.union.ok, []); } /// Returns the locale specific display name of a region. @@ -49,26 +46,26 @@ final class RegionDisplayNames implements ffi.Finalizable { final temp = ffi2.Arena(); final regionView = region.utf8View; final writeable = _Writeable(); - final result = _ICU4XRegionDisplayNames_of(_underlying, regionView.pointer(temp), regionView.length, writeable._underlying); + final result = _ICU4XRegionDisplayNames_of(_ffi, regionView.allocIn(temp), regionView.length, writeable._ffi); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } } -@meta.ResourceIdentifier() +@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() +@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() +@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/ffi/capi/bindings/dart/ReorderedIndexMap.g.dart b/ffi/capi/bindings/dart/ReorderedIndexMap.g.dart index 2c5d05fa0b9..c6b40a9f2ff 100644 --- a/ffi/capi/bindings/dart/ReorderedIndexMap.g.dart +++ b/ffi/capi/bindings/dart/ReorderedIndexMap.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// Thin wrapper around a vector that maps visual indices to source indices @@ -11,19 +8,19 @@ part of 'lib.g.dart'; /// /// Produced by `reorder_visual()` on [`Bidi`]. final class ReorderedIndexMap implements ffi.Finalizable { - final ffi.Pointer _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + ReorderedIndexMap._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -33,19 +30,19 @@ final class ReorderedIndexMap implements ffi.Finalizable { core.List get asSlice { // This lifetime edge depends on lifetimes: 'a core.List aEdges = [this]; - final result = _ICU4XReorderedIndexMap_as_slice(_underlying); - return core.Iterable.generate(result._length).map((i) => result._pointer[i]).toList(growable: false); + final result = _ICU4XReorderedIndexMap_as_slice(_ffi); + return result._toDart(aEdges); } /// The length of this map int get length { - final result = _ICU4XReorderedIndexMap_len(_underlying); + final result = _ICU4XReorderedIndexMap_len(_ffi); return result; } /// Whether this map is empty bool get isEmpty { - final result = _ICU4XReorderedIndexMap_is_empty(_underlying); + final result = _ICU4XReorderedIndexMap_is_empty(_ffi); return result; } @@ -53,32 +50,32 @@ final class ReorderedIndexMap implements ffi.Finalizable { /// (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(_underlying, index); + final result = _ICU4XReorderedIndexMap_get(_ffi, index); return result; } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/ResolvedCollatorOptions.g.dart b/ffi/capi/bindings/dart/ResolvedCollatorOptions.g.dart index e5dcaeb912c..ddf9328e1a7 100644 --- a/ffi/capi/bindings/dart/ResolvedCollatorOptions.g.dart +++ b/ffi/capi/bindings/dart/ResolvedCollatorOptions.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; final class _ResolvedCollatorOptionsFfi extends ffi.Struct { @@ -32,54 +29,53 @@ final class ResolvedCollatorOptions { final CollatorNumeric numeric; final CollatorBackwardSecondLevel backwardSecondLevel; - // ignore: unused_element - // Internal constructor from FFI. // 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. - ResolvedCollatorOptions._(_ResolvedCollatorOptionsFfi underlying) : - strength = CollatorStrength.values[underlying.strength], - alternateHandling = CollatorAlternateHandling.values[underlying.alternateHandling], - caseFirst = CollatorCaseFirst.values[underlying.caseFirst], - maxVariable = CollatorMaxVariable.values[underlying.maxVariable], - caseLevel = CollatorCaseLevel.values[underlying.caseLevel], - numeric = CollatorNumeric.values[underlying.numeric], - backwardSecondLevel = CollatorBackwardSecondLevel.values[underlying.backwardSecondLevel]; + // 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 _pointer(ffi.Allocator temp) { - final pointer = temp<_ResolvedCollatorOptionsFfi>(); - pointer.ref.strength = strength.index; - pointer.ref.alternateHandling = alternateHandling.index; - pointer.ref.caseFirst = caseFirst.index; - pointer.ref.maxVariable = maxVariable.index; - pointer.ref.caseLevel = caseLevel.index; - pointer.ref.numeric = numeric.index; - pointer.ref.backwardSecondLevel = backwardSecondLevel.index; - return pointer.ref; + _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 == this.strength && - other.alternateHandling == this.alternateHandling && - other.caseFirst == this.caseFirst && - other.maxVariable == this.maxVariable && - other.caseLevel == this.caseLevel && - other.numeric == this.numeric && - other.backwardSecondLevel == this.backwardSecondLevel; + 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([ - this.strength, - this.alternateHandling, - this.caseFirst, - this.maxVariable, - this.caseLevel, - this.numeric, - this.backwardSecondLevel, + strength, + alternateHandling, + caseFirst, + maxVariable, + caseLevel, + numeric, + backwardSecondLevel, ]); } diff --git a/ffi/capi/bindings/dart/RoundingIncrement.g.dart b/ffi/capi/bindings/dart/RoundingIncrement.g.dart index 4cb5e145761..f52f8bf766f 100644 --- a/ffi/capi/bindings/dart/RoundingIncrement.g.dart +++ b/ffi/capi/bindings/dart/RoundingIncrement.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// Increment used in a rounding operation. diff --git a/ffi/capi/bindings/dart/ScriptExtensionsSet.g.dart b/ffi/capi/bindings/dart/ScriptExtensionsSet.g.dart index ab6ca5f6b14..977e3333b80 100644 --- a/ffi/capi/bindings/dart/ScriptExtensionsSet.g.dart +++ b/ffi/capi/bindings/dart/ScriptExtensionsSet.g.dart @@ -1,28 +1,26 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_a; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_a) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + ScriptExtensionsSet._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -32,7 +30,7 @@ final class ScriptExtensionsSet implements ffi.Finalizable { /// /// 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(_underlying, script); + final result = _ICU4XScriptExtensionsSet_contains(_ffi, script); return result; } @@ -40,7 +38,7 @@ final class ScriptExtensionsSet implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XScriptExtensionsSet_count(_ffi); return result; } @@ -48,7 +46,7 @@ final class ScriptExtensionsSet implements ffi.Finalizable { /// /// 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(_underlying, index); + final result = _ICU4XScriptExtensionsSet_script_at(_ffi, index); if (!result.isOk) { return null; } @@ -56,22 +54,22 @@ final class ScriptExtensionsSet implements ffi.Finalizable { } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/ScriptWithExtensions.g.dart b/ffi/capi/bindings/dart/ScriptWithExtensions.g.dart index 08f0dcacdc3..cf52c4047ce 100644 --- a/ffi/capi/bindings/dart/ScriptWithExtensions.g.dart +++ b/ffi/capi/bindings/dart/ScriptWithExtensions.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + ScriptWithExtensions._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,18 +28,18 @@ final class ScriptWithExtensions implements ffi.Finalizable { /// /// Throws [Error] on failure. factory ScriptWithExtensions(DataProvider provider) { - final result = _ICU4XScriptWithExtensions_create(provider._underlying); + final result = _ICU4XScriptWithExtensions_create(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return ScriptWithExtensions._(result.union.ok, true, []); + 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(_underlying, codePoint); + final result = _ICU4XScriptWithExtensions_get_script_val(_ffi, codePoint); return result; } @@ -50,7 +47,7 @@ final class ScriptWithExtensions implements ffi.Finalizable { /// /// 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(_underlying, codePoint, script); + final result = _ICU4XScriptWithExtensions_has_script(_ffi, codePoint, script); return result; } @@ -60,8 +57,8 @@ final class ScriptWithExtensions implements ffi.Finalizable { ScriptWithExtensionsBorrowed get asBorrowed { // This lifetime edge depends on lifetimes: 'a core.List aEdges = [this]; - final result = _ICU4XScriptWithExtensions_as_borrowed(_underlying); - return ScriptWithExtensionsBorrowed._(result, true, [], aEdges); + 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 @@ -70,37 +67,37 @@ final class ScriptWithExtensions implements ffi.Finalizable { CodePointRangeIterator iterRangesForScript(int script) { // This lifetime edge depends on lifetimes: 'a core.List aEdges = [this]; - final result = _ICU4XScriptWithExtensions_iter_ranges_for_script(_underlying, script); - return CodePointRangeIterator._(result, true, [], aEdges); + final result = _ICU4XScriptWithExtensions_iter_ranges_for_script(_ffi, script); + return CodePointRangeIterator._fromFfi(result, [], aEdges); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XScriptWithExtensions_iter_ranges_for_script') @ffi.Native 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/ffi/capi/bindings/dart/ScriptWithExtensionsBorrowed.g.dart b/ffi/capi/bindings/dart/ScriptWithExtensionsBorrowed.g.dart index d440373807c..d7322a68f21 100644 --- a/ffi/capi/bindings/dart/ScriptWithExtensionsBorrowed.g.dart +++ b/ffi/capi/bindings/dart/ScriptWithExtensionsBorrowed.g.dart @@ -1,28 +1,26 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_a; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_a) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + ScriptWithExtensionsBorrowed._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -32,7 +30,7 @@ final class ScriptWithExtensionsBorrowed implements ffi.Finalizable { /// /// 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(_underlying, codePoint); + final result = _ICU4XScriptWithExtensionsBorrowed_get_script_val(_ffi, codePoint); return result; } @@ -42,15 +40,15 @@ final class ScriptWithExtensionsBorrowed implements ffi.Finalizable { ScriptExtensionsSet getScriptExtensionsVal(int codePoint) { // This lifetime edge depends on lifetimes: 'a core.List aEdges = [this]; - final result = _ICU4XScriptWithExtensionsBorrowed_get_script_extensions_val(_underlying, codePoint); - return ScriptExtensionsSet._(result, true, [], aEdges); + 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(_underlying, codePoint, script); + final result = _ICU4XScriptWithExtensionsBorrowed_has_script(_ffi, codePoint, script); return result; } @@ -59,32 +57,32 @@ final class ScriptWithExtensionsBorrowed implements ffi.Finalizable { /// /// 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(_underlying, script); - return CodePointSetData._(result, true, []); + final result = _ICU4XScriptWithExtensionsBorrowed_get_script_extensions_set(_ffi, script); + return CodePointSetData._fromFfi(result, []); } } -@meta.ResourceIdentifier() +@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() +@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() +@meta.ResourceIdentifier('ICU4XScriptWithExtensionsBorrowed_get_script_extensions_val') @ffi.Native 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() +@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() +@meta.ResourceIdentifier('ICU4XScriptWithExtensionsBorrowed_get_script_extensions_set') @ffi.Native 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/ffi/capi/bindings/dart/SegmenterWordType.g.dart b/ffi/capi/bindings/dart/SegmenterWordType.g.dart index ee2ae761777..33b28c08040 100644 --- a/ffi/capi/bindings/dart/SegmenterWordType.g.dart +++ b/ffi/capi/bindings/dart/SegmenterWordType.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; /// See the [Rust documentation for `WordType`](https://docs.rs/icu/latest/icu/segmenter/enum.WordType.html) for more information. diff --git a/ffi/capi/bindings/dart/SentenceBreakIteratorLatin1.g.dart b/ffi/capi/bindings/dart/SentenceBreakIteratorLatin1.g.dart index 216b0e5544f..2b817891128 100644 --- a/ffi/capi/bindings/dart/SentenceBreakIteratorLatin1.g.dart +++ b/ffi/capi/bindings/dart/SentenceBreakIteratorLatin1.g.dart @@ -1,26 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_a; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_a) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + SentenceBreakIteratorLatin1._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,17 +29,17 @@ final class SentenceBreakIteratorLatin1 implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XSentenceBreakIteratorLatin1_next(_ffi); return result; } } -@meta.ResourceIdentifier() +@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() +@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/ffi/capi/bindings/dart/SentenceBreakIteratorUtf16.g.dart b/ffi/capi/bindings/dart/SentenceBreakIteratorUtf16.g.dart index ba860f45ee3..629b2b831db 100644 --- a/ffi/capi/bindings/dart/SentenceBreakIteratorUtf16.g.dart +++ b/ffi/capi/bindings/dart/SentenceBreakIteratorUtf16.g.dart @@ -1,26 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_a; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_a) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + SentenceBreakIteratorUtf16._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,17 +29,17 @@ final class SentenceBreakIteratorUtf16 implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XSentenceBreakIteratorUtf16_next(_ffi); return result; } } -@meta.ResourceIdentifier() +@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() +@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/ffi/capi/bindings/dart/SentenceBreakIteratorUtf8.g.dart b/ffi/capi/bindings/dart/SentenceBreakIteratorUtf8.g.dart index de4a165f867..7350f8b18e1 100644 --- a/ffi/capi/bindings/dart/SentenceBreakIteratorUtf8.g.dart +++ b/ffi/capi/bindings/dart/SentenceBreakIteratorUtf8.g.dart @@ -1,26 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_a; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_a) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + SentenceBreakIteratorUtf8._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,17 +29,17 @@ final class SentenceBreakIteratorUtf8 implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XSentenceBreakIteratorUtf8_next(_ffi); return result; } } -@meta.ResourceIdentifier() +@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() +@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/ffi/capi/bindings/dart/SentenceSegmenter.g.dart b/ffi/capi/bindings/dart/SentenceSegmenter.g.dart index 0daed198b70..160d7d2a594 100644 --- a/ffi/capi/bindings/dart/SentenceSegmenter.g.dart +++ b/ffi/capi/bindings/dart/SentenceSegmenter.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + SentenceSegmenter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -33,11 +30,11 @@ final class SentenceSegmenter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory SentenceSegmenter(DataProvider provider) { - final result = _ICU4XSentenceSegmenter_create(provider._underlying); + final result = _ICU4XSentenceSegmenter_create(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return SentenceSegmenter._(result.union.ok, true, []); + return SentenceSegmenter._fromFfi(result.union.ok, []); } /// Segments a string. @@ -51,22 +48,22 @@ final class SentenceSegmenter implements ffi.Finalizable { final inputArena = _FinalizedArena(); // This lifetime edge depends on lifetimes: 'a core.List aEdges = [this, inputArena]; - final result = _ICU4XSentenceSegmenter_segment_utf16(_underlying, inputView.pointer(inputArena.arena), inputView.length); - return SentenceBreakIteratorUtf16._(result, true, [], aEdges); + final result = _ICU4XSentenceSegmenter_segment_utf16(_ffi, inputView.allocIn(inputArena.arena), inputView.length); + return SentenceBreakIteratorUtf16._fromFfi(result, [], aEdges); } } -@meta.ResourceIdentifier() +@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() +@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() +@meta.ResourceIdentifier('ICU4XSentenceSegmenter_segment_utf16') @ffi.Native 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/ffi/capi/bindings/dart/Time.g.dart b/ffi/capi/bindings/dart/Time.g.dart index 10531a31a9d..8bfa060b75a 100644 --- a/ffi/capi/bindings/dart/Time.g.dart +++ b/ffi/capi/bindings/dart/Time.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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/types/struct.Time.html) for more information. final class Time implements ffi.Finalizable { - final ffi.Pointer _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + Time._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -35,9 +32,9 @@ final class Time implements ffi.Finalizable { 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return Time._(result.union.ok, true, []); + return Time._fromFfi(result.union.ok, []); } /// Creates a new [`Time`] representing midnight (00:00.000). @@ -48,16 +45,16 @@ final class Time implements ffi.Finalizable { factory Time.midnight() { final result = _ICU4XTime_create_midnight(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return Time._(result.union.ok, true, []); + 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/types/struct.Time.html#structfield.hour) for more information. int get hour { - final result = _ICU4XTime_hour(_underlying); + final result = _ICU4XTime_hour(_ffi); return result; } @@ -65,7 +62,7 @@ final class Time implements ffi.Finalizable { /// /// See the [Rust documentation for `minute`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.minute) for more information. int get minute { - final result = _ICU4XTime_minute(_underlying); + final result = _ICU4XTime_minute(_ffi); return result; } @@ -73,7 +70,7 @@ final class Time implements ffi.Finalizable { /// /// See the [Rust documentation for `second`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.second) for more information. int get second { - final result = _ICU4XTime_second(_underlying); + final result = _ICU4XTime_second(_ffi); return result; } @@ -81,42 +78,42 @@ final class Time implements ffi.Finalizable { /// /// See the [Rust documentation for `nanosecond`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.nanosecond) for more information. int get nanosecond { - final result = _ICU4XTime_nanosecond(_underlying); + final result = _ICU4XTime_nanosecond(_ffi); return result; } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/TimeFormatter.g.dart b/ffi/capi/bindings/dart/TimeFormatter.g.dart index 3d161008f57..699bf7ecbe2 100644 --- a/ffi/capi/bindings/dart/TimeFormatter.g.dart +++ b/ffi/capi/bindings/dart/TimeFormatter.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + TimeFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -33,11 +30,11 @@ final class TimeFormatter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory TimeFormatter.withLength(DataProvider provider, Locale locale, TimeLength length) { - final result = _ICU4XTimeFormatter_create_with_length(provider._underlying, locale._underlying, length.index); + final result = _ICU4XTimeFormatter_create_with_length(provider._ffi, locale._ffi, length.index); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return TimeFormatter._(result.union.ok, true, []); + return TimeFormatter._fromFfi(result.union.ok, []); } /// Formats a [`Time`] to a string. @@ -47,9 +44,9 @@ final class TimeFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String formatTime(Time value) { final writeable = _Writeable(); - final result = _ICU4XTimeFormatter_format_time(_underlying, value._underlying, writeable._underlying); + final result = _ICU4XTimeFormatter_format_time(_ffi, value._ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -61,9 +58,9 @@ final class TimeFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String formatDatetime(DateTime value) { final writeable = _Writeable(); - final result = _ICU4XTimeFormatter_format_datetime(_underlying, value._underlying, writeable._underlying); + final result = _ICU4XTimeFormatter_format_datetime(_ffi, value._ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -75,35 +72,35 @@ final class TimeFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String formatIsoDatetime(IsoDateTime value) { final writeable = _Writeable(); - final result = _ICU4XTimeFormatter_format_iso_datetime(_underlying, value._underlying, writeable._underlying); + final result = _ICU4XTimeFormatter_format_iso_datetime(_ffi, value._ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/TimeLength.g.dart b/ffi/capi/bindings/dart/TimeLength.g.dart index 3ee335ab039..e9557092bce 100644 --- a/ffi/capi/bindings/dart/TimeLength.g.dart +++ b/ffi/capi/bindings/dart/TimeLength.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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. diff --git a/ffi/capi/bindings/dart/TimeZoneFormatter.g.dart b/ffi/capi/bindings/dart/TimeZoneFormatter.g.dart index 033eca4465b..6588529e9cb 100644 --- a/ffi/capi/bindings/dart/TimeZoneFormatter.g.dart +++ b/ffi/capi/bindings/dart/TimeZoneFormatter.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + TimeZoneFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -37,11 +34,11 @@ final class TimeZoneFormatter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory TimeZoneFormatter.withLocalizedGmtFallback(DataProvider provider, Locale locale) { - final result = _ICU4XTimeZoneFormatter_create_with_localized_gmt_fallback(provider._underlying, locale._underlying); + final result = _ICU4XTimeZoneFormatter_create_with_localized_gmt_fallback(provider._ffi, locale._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return TimeZoneFormatter._(result.union.ok, true, []); + return TimeZoneFormatter._fromFfi(result.union.ok, []); } /// Creates a new [`TimeZoneFormatter`] from locale data. @@ -55,12 +52,12 @@ final class TimeZoneFormatter implements ffi.Finalizable { /// 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._underlying, locale._underlying, options._pointer(temp)); + 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return TimeZoneFormatter._(result.union.ok, true, []); + return TimeZoneFormatter._fromFfi(result.union.ok, []); } /// Loads generic non-location long format. Example: "Pacific Time" @@ -69,9 +66,9 @@ final class TimeZoneFormatter implements ffi.Finalizable { /// /// Throws [Error] on failure. void loadGenericNonLocationLong(DataProvider provider) { - final result = _ICU4XTimeZoneFormatter_load_generic_non_location_long(_underlying, provider._underlying); + final result = _ICU4XTimeZoneFormatter_load_generic_non_location_long(_ffi, provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -82,9 +79,9 @@ final class TimeZoneFormatter implements ffi.Finalizable { /// /// Throws [Error] on failure. void loadGenericNonLocationShort(DataProvider provider) { - final result = _ICU4XTimeZoneFormatter_load_generic_non_location_short(_underlying, provider._underlying); + final result = _ICU4XTimeZoneFormatter_load_generic_non_location_short(_ffi, provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -95,9 +92,9 @@ final class TimeZoneFormatter implements ffi.Finalizable { /// /// Throws [Error] on failure. void loadSpecificNonLocationLong(DataProvider provider) { - final result = _ICU4XTimeZoneFormatter_load_specific_non_location_long(_underlying, provider._underlying); + final result = _ICU4XTimeZoneFormatter_load_specific_non_location_long(_ffi, provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -108,9 +105,9 @@ final class TimeZoneFormatter implements ffi.Finalizable { /// /// Throws [Error] on failure. void loadSpecificNonLocationShort(DataProvider provider) { - final result = _ICU4XTimeZoneFormatter_load_specific_non_location_short(_underlying, provider._underlying); + final result = _ICU4XTimeZoneFormatter_load_specific_non_location_short(_ffi, provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -121,9 +118,9 @@ final class TimeZoneFormatter implements ffi.Finalizable { /// /// Throws [Error] on failure. void loadGenericLocationFormat(DataProvider provider) { - final result = _ICU4XTimeZoneFormatter_load_generic_location_format(_underlying, provider._underlying); + final result = _ICU4XTimeZoneFormatter_load_generic_location_format(_ffi, provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -134,9 +131,9 @@ final class TimeZoneFormatter implements ffi.Finalizable { /// /// Throws [Error] on failure. void includeLocalizedGmtFormat() { - final result = _ICU4XTimeZoneFormatter_include_localized_gmt_format(_underlying); + final result = _ICU4XTimeZoneFormatter_include_localized_gmt_format(_ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -148,10 +145,10 @@ final class TimeZoneFormatter implements ffi.Finalizable { /// Throws [Error] on failure. void loadIso8601Format(IsoTimeZoneOptions options) { final temp = ffi2.Arena(); - final result = _ICU4XTimeZoneFormatter_load_iso_8601_format(_underlying, options._pointer(temp)); + final result = _ICU4XTimeZoneFormatter_load_iso_8601_format(_ffi, options._toFfi(temp)); temp.releaseAll(); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } } @@ -165,65 +162,65 @@ final class TimeZoneFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String formatCustomTimeZone(CustomTimeZone value) { final writeable = _Writeable(); - final result = _ICU4XTimeZoneFormatter_format_custom_time_zone(_underlying, value._underlying, writeable._underlying); + final result = _ICU4XTimeZoneFormatter_format_custom_time_zone(_ffi, value._ffi, writeable._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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() +@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); diff --git a/ffi/capi/bindings/dart/TitlecaseMapper.g.dart b/ffi/capi/bindings/dart/TitlecaseMapper.g.dart index f0f1e2df49c..ec271b9224d 100644 --- a/ffi/capi/bindings/dart/TitlecaseMapper.g.dart +++ b/ffi/capi/bindings/dart/TitlecaseMapper.g.dart @@ -1,25 +1,22 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + TitlecaseMapper._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,11 +28,11 @@ final class TitlecaseMapper implements ffi.Finalizable { /// /// Throws [Error] on failure. factory TitlecaseMapper(DataProvider provider) { - final result = _ICU4XTitlecaseMapper_create(provider._underlying); + final result = _ICU4XTitlecaseMapper_create(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return TitlecaseMapper._(result.union.ok, true, []); + return TitlecaseMapper._fromFfi(result.union.ok, []); } /// Returns the full titlecase mapping of the given string @@ -45,30 +42,30 @@ final class TitlecaseMapper implements ffi.Finalizable { /// 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 titlecase_segment(String s, Locale locale, TitlecaseOptions options) { + 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(_underlying, sView.pointer(temp), sView.length, locale._underlying, options._pointer(temp), writeable._underlying); + 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } } -@meta.ResourceIdentifier() +@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() +@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() +@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/ffi/capi/bindings/dart/TitlecaseOptions.g.dart b/ffi/capi/bindings/dart/TitlecaseOptions.g.dart index fe1342b6a39..18cef674e78 100644 --- a/ffi/capi/bindings/dart/TitlecaseOptions.g.dart +++ b/ffi/capi/bindings/dart/TitlecaseOptions.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; final class _TitlecaseOptionsFfi extends ffi.Struct { @@ -17,29 +14,28 @@ final class TitlecaseOptions { LeadingAdjustment leadingAdjustment; TrailingCase trailingCase; - // ignore: unused_element - // Internal constructor from FFI. // 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. - TitlecaseOptions._(_TitlecaseOptionsFfi underlying) : - leadingAdjustment = LeadingAdjustment.values[underlying.leadingAdjustment], - trailingCase = TrailingCase.values[underlying.trailingCase]; + // ignore: unused_element + TitlecaseOptions._fromFfi(_TitlecaseOptionsFfi ffi) : + leadingAdjustment = LeadingAdjustment.values[ffi.leadingAdjustment], + trailingCase = TrailingCase.values[ffi.trailingCase]; // ignore: unused_element - _TitlecaseOptionsFfi _pointer(ffi.Allocator temp) { - final pointer = temp<_TitlecaseOptionsFfi>(); - pointer.ref.leadingAdjustment = leadingAdjustment.index; - pointer.ref.trailingCase = trailingCase.index; - return pointer.ref; + _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._(result); + final dart = TitlecaseOptions._fromFfi(result); if (leadingAdjustment != null) { dart.leadingAdjustment = leadingAdjustment; } @@ -52,17 +48,17 @@ final class TitlecaseOptions { @override bool operator ==(Object other) => other is TitlecaseOptions && - other.leadingAdjustment == this.leadingAdjustment && - other.trailingCase == this.trailingCase; + other.leadingAdjustment == leadingAdjustment && + other.trailingCase == trailingCase; @override int get hashCode => Object.hashAll([ - this.leadingAdjustment, - this.trailingCase, + leadingAdjustment, + trailingCase, ]); } -@meta.ResourceIdentifier() +@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/ffi/capi/bindings/dart/TrailingCase.g.dart b/ffi/capi/bindings/dart/TrailingCase.g.dart index 87fe7b50756..d85cd1054d6 100644 --- a/ffi/capi/bindings/dart/TrailingCase.g.dart +++ b/ffi/capi/bindings/dart/TrailingCase.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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. diff --git a/ffi/capi/bindings/dart/TransformResult.g.dart b/ffi/capi/bindings/dart/TransformResult.g.dart index 32b278bf8b9..0786961a9d8 100644 --- a/ffi/capi/bindings/dart/TransformResult.g.dart +++ b/ffi/capi/bindings/dart/TransformResult.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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. diff --git a/ffi/capi/bindings/dart/UnicodeSetData.g.dart b/ffi/capi/bindings/dart/UnicodeSetData.g.dart index 543cf325ef6..aa4c39a4b5f 100644 --- a/ffi/capi/bindings/dart/UnicodeSetData.g.dart +++ b/ffi/capi/bindings/dart/UnicodeSetData.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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. @@ -13,19 +10,19 @@ part of 'lib.g.dart'; /// /// 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + UnicodeSetData._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -37,7 +34,7 @@ final class UnicodeSetData implements ffi.Finalizable { bool contains(String s) { final temp = ffi2.Arena(); final sView = s.utf8View; - final result = _ICU4XUnicodeSetData_contains(_underlying, sView.pointer(temp), sView.length); + final result = _ICU4XUnicodeSetData_contains(_ffi, sView.allocIn(temp), sView.length); temp.releaseAll(); return result; } @@ -46,7 +43,7 @@ final class UnicodeSetData implements ffi.Finalizable { /// /// 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(_underlying, cp); + final result = _ICU4XUnicodeSetData_contains_char(_ffi, cp); return result; } @@ -54,110 +51,110 @@ final class UnicodeSetData implements ffi.Finalizable { /// /// Throws [Error] on failure. factory UnicodeSetData.loadBasicEmoji(DataProvider provider) { - final result = _ICU4XUnicodeSetData_load_basic_emoji(provider._underlying); + final result = _ICU4XUnicodeSetData_load_basic_emoji(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return UnicodeSetData._(result.union.ok, true, []); + 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.loadExemplarsMain(DataProvider provider, Locale locale) { - final result = _ICU4XUnicodeSetData_load_exemplars_main(provider._underlying, locale._underlying); + final result = _ICU4XUnicodeSetData_load_exemplars_main(provider._ffi, locale._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return UnicodeSetData._(result.union.ok, true, []); + 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.loadExemplarsAuxiliary(DataProvider provider, Locale locale) { - final result = _ICU4XUnicodeSetData_load_exemplars_auxiliary(provider._underlying, locale._underlying); + final result = _ICU4XUnicodeSetData_load_exemplars_auxiliary(provider._ffi, locale._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return UnicodeSetData._(result.union.ok, true, []); + 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.loadExemplarsPunctuation(DataProvider provider, Locale locale) { - final result = _ICU4XUnicodeSetData_load_exemplars_punctuation(provider._underlying, locale._underlying); + final result = _ICU4XUnicodeSetData_load_exemplars_punctuation(provider._ffi, locale._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return UnicodeSetData._(result.union.ok, true, []); + 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.loadExemplarsNumbers(DataProvider provider, Locale locale) { - final result = _ICU4XUnicodeSetData_load_exemplars_numbers(provider._underlying, locale._underlying); + final result = _ICU4XUnicodeSetData_load_exemplars_numbers(provider._ffi, locale._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return UnicodeSetData._(result.union.ok, true, []); + 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.loadExemplarsIndex(DataProvider provider, Locale locale) { - final result = _ICU4XUnicodeSetData_load_exemplars_index(provider._underlying, locale._underlying); + final result = _ICU4XUnicodeSetData_load_exemplars_index(provider._ffi, locale._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return UnicodeSetData._(result.union.ok, true, []); + return UnicodeSetData._fromFfi(result.union.ok, []); } } -@meta.ResourceIdentifier() +@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() +@meta.ResourceIdentifier('ICU4XUnicodeSetData_contains') @ffi.Native, 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() +@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() +@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() +@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() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/WeekCalculator.g.dart b/ffi/capi/bindings/dart/WeekCalculator.g.dart index f449c6b2761..bed38b7bf5b 100644 --- a/ffi/capi/bindings/dart/WeekCalculator.g.dart +++ b/ffi/capi/bindings/dart/WeekCalculator.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + WeekCalculator._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -33,25 +30,25 @@ final class WeekCalculator implements ffi.Finalizable { /// /// Throws [Error] on failure. factory WeekCalculator(DataProvider provider, Locale locale) { - final result = _ICU4XWeekCalculator_create(provider._underlying, locale._underlying); + final result = _ICU4XWeekCalculator_create(provider._ffi, locale._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return WeekCalculator._(result.union.ok, true, []); + 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._underlying, minWeekDays); - return WeekCalculator._(result, true, []); + 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(_underlying); - return IsoWeekday.values.firstWhere((v) => v._underlying == result); + 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 @@ -59,32 +56,32 @@ final class WeekCalculator implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XWeekCalculator_min_week_days(_ffi); return result; } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@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); diff --git a/ffi/capi/bindings/dart/WeekOf.g.dart b/ffi/capi/bindings/dart/WeekOf.g.dart index c33445fb15c..91741832450 100644 --- a/ffi/capi/bindings/dart/WeekOf.g.dart +++ b/ffi/capi/bindings/dart/WeekOf.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - part of 'lib.g.dart'; final class _WeekOfFfi extends ffi.Struct { @@ -17,34 +14,33 @@ final class WeekOf { final int week; final WeekRelativeUnit unit; - // ignore: unused_element - // Internal constructor from FFI. // 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. - WeekOf._(_WeekOfFfi underlying) : - week = underlying.week, - unit = WeekRelativeUnit.values[underlying.unit]; + // ignore: unused_element + WeekOf._fromFfi(_WeekOfFfi ffi) : + week = ffi.week, + unit = WeekRelativeUnit.values[ffi.unit]; // ignore: unused_element - _WeekOfFfi _pointer(ffi.Allocator temp) { - final pointer = temp<_WeekOfFfi>(); - pointer.ref.week = week; - pointer.ref.unit = unit.index; - return pointer.ref; + _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 == this.week && - other.unit == this.unit; + other.week == week && + other.unit == unit; @override int get hashCode => Object.hashAll([ - this.week, - this.unit, + week, + unit, ]); } diff --git a/ffi/capi/bindings/dart/WeekRelativeUnit.g.dart b/ffi/capi/bindings/dart/WeekRelativeUnit.g.dart index 0f46b419772..a77fb9c042f 100644 --- a/ffi/capi/bindings/dart/WeekRelativeUnit.g.dart +++ b/ffi/capi/bindings/dart/WeekRelativeUnit.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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. diff --git a/ffi/capi/bindings/dart/WordBreakIteratorLatin1.g.dart b/ffi/capi/bindings/dart/WordBreakIteratorLatin1.g.dart index 05b050cff03..47a2d9f6795 100644 --- a/ffi/capi/bindings/dart/WordBreakIteratorLatin1.g.dart +++ b/ffi/capi/bindings/dart/WordBreakIteratorLatin1.g.dart @@ -1,26 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_a; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_a) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + WordBreakIteratorLatin1._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,7 +29,7 @@ final class WordBreakIteratorLatin1 implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XWordBreakIteratorLatin1_next(_ffi); return result; } @@ -39,7 +37,7 @@ final class WordBreakIteratorLatin1 implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XWordBreakIteratorLatin1_word_type(_ffi); return SegmenterWordType.values[result]; } @@ -47,27 +45,27 @@ final class WordBreakIteratorLatin1 implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XWordBreakIteratorLatin1_is_word_like(_ffi); return result; } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/WordBreakIteratorUtf16.g.dart b/ffi/capi/bindings/dart/WordBreakIteratorUtf16.g.dart index 9e5c2f99337..a050aaf6938 100644 --- a/ffi/capi/bindings/dart/WordBreakIteratorUtf16.g.dart +++ b/ffi/capi/bindings/dart/WordBreakIteratorUtf16.g.dart @@ -1,26 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_a; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_a) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + WordBreakIteratorUtf16._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,7 +29,7 @@ final class WordBreakIteratorUtf16 implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XWordBreakIteratorUtf16_next(_ffi); return result; } @@ -39,7 +37,7 @@ final class WordBreakIteratorUtf16 implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XWordBreakIteratorUtf16_word_type(_ffi); return SegmenterWordType.values[result]; } @@ -47,27 +45,27 @@ final class WordBreakIteratorUtf16 implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XWordBreakIteratorUtf16_is_word_like(_ffi); return result; } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/WordBreakIteratorUtf8.g.dart b/ffi/capi/bindings/dart/WordBreakIteratorUtf8.g.dart index 1d53aa1b254..48b148ac61f 100644 --- a/ffi/capi/bindings/dart/WordBreakIteratorUtf8.g.dart +++ b/ffi/capi/bindings/dart/WordBreakIteratorUtf8.g.dart @@ -1,26 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; - final core.List _edge_a; + // 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; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self, this._edge_a) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + WordBreakIteratorUtf8._fromFfi(this._ffi, this._selfEdge, this._aEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -31,7 +29,7 @@ final class WordBreakIteratorUtf8 implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XWordBreakIteratorUtf8_next(_ffi); return result; } @@ -39,7 +37,7 @@ final class WordBreakIteratorUtf8 implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XWordBreakIteratorUtf8_word_type(_ffi); return SegmenterWordType.values[result]; } @@ -47,27 +45,27 @@ final class WordBreakIteratorUtf8 implements ffi.Finalizable { /// /// 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(_underlying); + final result = _ICU4XWordBreakIteratorUtf8_is_word_like(_ffi); return result; } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/WordSegmenter.g.dart b/ffi/capi/bindings/dart/WordSegmenter.g.dart index c69a3215496..ad9eda20fce 100644 --- a/ffi/capi/bindings/dart/WordSegmenter.g.dart +++ b/ffi/capi/bindings/dart/WordSegmenter.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + WordSegmenter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -37,11 +34,11 @@ final class WordSegmenter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory WordSegmenter.auto(DataProvider provider) { - final result = _ICU4XWordSegmenter_create_auto(provider._underlying); + final result = _ICU4XWordSegmenter_create_auto(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return WordSegmenter._(result.union.ok, true, []); + return WordSegmenter._fromFfi(result.union.ok, []); } /// Construct an [`WordSegmenter`] with LSTM payload data for Burmese, Khmer, Lao, and @@ -54,11 +51,11 @@ final class WordSegmenter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory WordSegmenter.lstm(DataProvider provider) { - final result = _ICU4XWordSegmenter_create_lstm(provider._underlying); + final result = _ICU4XWordSegmenter_create_lstm(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return WordSegmenter._(result.union.ok, true, []); + return WordSegmenter._fromFfi(result.union.ok, []); } /// Construct an [`WordSegmenter`] with dictionary payload data for Chinese, Japanese, @@ -68,11 +65,11 @@ final class WordSegmenter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory WordSegmenter.dictionary(DataProvider provider) { - final result = _ICU4XWordSegmenter_create_dictionary(provider._underlying); + final result = _ICU4XWordSegmenter_create_dictionary(provider._ffi); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return WordSegmenter._(result.union.ok, true, []); + return WordSegmenter._fromFfi(result.union.ok, []); } /// Segments a string. @@ -86,32 +83,32 @@ final class WordSegmenter implements ffi.Finalizable { final inputArena = _FinalizedArena(); // This lifetime edge depends on lifetimes: 'a core.List aEdges = [this, inputArena]; - final result = _ICU4XWordSegmenter_segment_utf16(_underlying, inputView.pointer(inputArena.arena), inputView.length); - return WordBreakIteratorUtf16._(result, true, [], aEdges); + final result = _ICU4XWordSegmenter_segment_utf16(_ffi, inputView.allocIn(inputArena.arena), inputView.length); + return WordBreakIteratorUtf16._fromFfi(result, [], aEdges); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@meta.ResourceIdentifier('ICU4XWordSegmenter_segment_utf16') @ffi.Native 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/ffi/capi/bindings/dart/ZonedDateTimeFormatter.g.dart b/ffi/capi/bindings/dart/ZonedDateTimeFormatter.g.dart index 32f6c41ab1f..48acf0e3aa4 100644 --- a/ffi/capi/bindings/dart/ZonedDateTimeFormatter.g.dart +++ b/ffi/capi/bindings/dart/ZonedDateTimeFormatter.g.dart @@ -1,27 +1,24 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - 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 _underlying; + final ffi.Pointer _ffi; - final core.List _edge_self; + // These are "used" in the sense that they keep dependencies alive + // ignore: unused_field + final core.List _selfEdge; - // Internal constructor from FFI. - // isOwned is whether this is owned (has finalizer) or not - // This also takes in a list of lifetime edges (including for &self borrows) + // 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._(this._underlying, bool isOwned, this._edge_self) { - if (isOwned) { - _finalizer.attach(this, _underlying.cast()); + ZonedDateTimeFormatter._fromFfi(this._ffi, this._selfEdge) { + if (_selfEdge.isEmpty) { + _finalizer.attach(this, _ffi.cast()); } } @@ -36,11 +33,11 @@ final class ZonedDateTimeFormatter implements ffi.Finalizable { /// /// Throws [Error] on failure. factory ZonedDateTimeFormatter.withLengths(DataProvider provider, Locale locale, DateLength dateLength, TimeLength timeLength) { - final result = _ICU4XZonedDateTimeFormatter_create_with_lengths(provider._underlying, locale._underlying, dateLength.index, timeLength.index); + final result = _ICU4XZonedDateTimeFormatter_create_with_lengths(provider._ffi, locale._ffi, dateLength.index, timeLength.index); if (!result.isOk) { - throw Error.values.firstWhere((v) => v._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return ZonedDateTimeFormatter._(result.union.ok, true, []); + return ZonedDateTimeFormatter._fromFfi(result.union.ok, []); } /// Creates a new [`ZonedDateTimeFormatter`] from locale data. @@ -53,12 +50,12 @@ final class ZonedDateTimeFormatter implements ffi.Finalizable { /// 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._underlying, locale._underlying, dateLength.index, timeLength.index, zoneOptions._pointer(temp)); + 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } - return ZonedDateTimeFormatter._(result.union.ok, true, []); + return ZonedDateTimeFormatter._fromFfi(result.union.ok, []); } /// Formats a [`DateTime`] and [`CustomTimeZone`] to a string. @@ -68,9 +65,9 @@ final class ZonedDateTimeFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String formatDatetimeWithCustomTimeZone(DateTime datetime, CustomTimeZone timeZone) { final writeable = _Writeable(); - final result = _ICU4XZonedDateTimeFormatter_format_datetime_with_custom_time_zone(_underlying, datetime._underlying, timeZone._underlying, writeable._underlying); + 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } @@ -82,35 +79,35 @@ final class ZonedDateTimeFormatter implements ffi.Finalizable { /// Throws [Error] on failure. String formatIsoDatetimeWithCustomTimeZone(IsoDateTime datetime, CustomTimeZone timeZone) { final writeable = _Writeable(); - final result = _ICU4XZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone(_underlying, datetime._underlying, timeZone._underlying, writeable._underlying); + 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._underlying == result.union.err); + throw Error.values.firstWhere((v) => v._ffi == result.union.err); } return writeable.finalize(); } } -@meta.ResourceIdentifier() +@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() +@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() +@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() +@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() +@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/ffi/capi/bindings/dart/lib.g.dart b/ffi/capi/bindings/dart/lib.g.dart index b99f5b4ec94..b3408cd7fa0 100644 --- a/ffi/capi/bindings/dart/lib.g.dart +++ b/ffi/capi/bindings/dart/lib.g.dart @@ -1,8 +1,5 @@ // generated by diplomat-tool -// https://github.com/dart-lang/sdk/issues/53946 -// ignore_for_file: non_native_function_type_argument_to_pointer - import 'dart:convert'; import 'dart:core' as core; import 'dart:core' show int, double, bool, String, Object, override; @@ -153,28 +150,49 @@ typedef Rune = int; // ignore: unused_element final _callocFree = core.Finalizer(ffi2.calloc.free); -extension _View on ByteBuffer { +final _nopFree = core.Finalizer((nothing) => {}); + +// 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 pointer(ffi.Allocator alloc) { + ffi.Pointer allocIn(ffi.Allocator alloc) { return alloc(length)..asTypedList(length).setRange(0, length, asUint8List()); } int get length => lengthInBytes; } -extension _UtfViews on String { +extension on String { // ignore: unused_element _Utf8View get utf8View => _Utf8View(this); // ignore: unused_element _Utf16View get utf16View => _Utf16View(this); } -extension _NativeBoolViews on core.List { +extension on core.List { // ignore: unused_element _BoolListView get boolView => _BoolListView(this); } -extension _NativeIntViews on core.List { +extension on core.List { // ignore: unused_element _Int8ListView get int8View => _Int8ListView(this); // ignore: unused_element @@ -197,7 +215,7 @@ extension _NativeIntViews on core.List { _UsizeListView get usizeView => _UsizeListView(this); } -extension _NativeFloatViews on core.List { +extension on core.List { // ignore: unused_element _Float32ListView get float32View => _Float32ListView(this); // ignore: unused_element @@ -211,7 +229,7 @@ class _Utf8View { // Copies _Utf8View(String string) : _codeUnits = Utf8Encoder().convert(string); - ffi.Pointer pointer(ffi.Allocator alloc) { + ffi.Pointer allocIn(ffi.Allocator alloc) { // Copies return alloc(length)..asTypedList(length).setRange(0, length, _codeUnits); } @@ -225,7 +243,7 @@ class _Utf16View { _Utf16View(String string) : _codeUnits = string.codeUnits; - ffi.Pointer pointer(ffi.Allocator alloc) { + ffi.Pointer allocIn(ffi.Allocator alloc) { // Copies return alloc(length)..asTypedList(length).setRange(0, length, _codeUnits); } @@ -240,7 +258,7 @@ class _BoolListView{ _BoolListView(this._values); // Copies - ffi.Pointer pointer(ffi.Allocator alloc) { + ffi.Pointer allocIn(ffi.Allocator alloc) { final pointer = alloc(_values.length); for (var i = 0; i < _values.length; i++) { pointer[i] = _values[i]; @@ -257,7 +275,7 @@ class _Int8ListView { _Int8ListView(this._values); // ignore: unused_element - ffi.Pointer pointer(ffi.Allocator alloc) { + ffi.Pointer allocIn(ffi.Allocator alloc) { return alloc(length)..asTypedList(length).setRange(0, length, _values); } @@ -270,7 +288,7 @@ class _Int16ListView { _Int16ListView(this._values); // ignore: unused_element - ffi.Pointer pointer(ffi.Allocator alloc) { + ffi.Pointer allocIn(ffi.Allocator alloc) { return alloc(length)..asTypedList(length).setRange(0, length, _values); } @@ -283,7 +301,7 @@ class _Int32ListView { _Int32ListView(this._values); // ignore: unused_element - ffi.Pointer pointer(ffi.Allocator alloc) { + ffi.Pointer allocIn(ffi.Allocator alloc) { return alloc(length)..asTypedList(length).setRange(0, length, _values); } @@ -296,7 +314,7 @@ class _Int64ListView { _Int64ListView(this._values); // ignore: unused_element - ffi.Pointer pointer(ffi.Allocator alloc) { + ffi.Pointer allocIn(ffi.Allocator alloc) { return alloc(length)..asTypedList(length).setRange(0, length, _values); } @@ -310,7 +328,7 @@ class _IsizeListView { _IsizeListView(this._values); // Copies - ffi.Pointer pointer(ffi.Allocator alloc) { + ffi.Pointer allocIn(ffi.Allocator alloc) { final pointer = alloc(_values.length); for (var i = 0; i < _values.length; i++) { pointer[i] = _values[i]; @@ -327,7 +345,7 @@ class _Uint8ListView { _Uint8ListView(this._values); // ignore: unused_element - ffi.Pointer pointer(ffi.Allocator alloc) { + 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])); @@ -344,7 +362,7 @@ class _Uint16ListView { _Uint16ListView(this._values); // ignore: unused_element - ffi.Pointer pointer(ffi.Allocator alloc) { + 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])); @@ -361,7 +379,7 @@ class _Uint32ListView { _Uint32ListView(this._values); // ignore: unused_element - ffi.Pointer pointer(ffi.Allocator alloc) { + 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])); @@ -378,7 +396,7 @@ class _Uint64ListView { _Uint64ListView(this._values); // ignore: unused_element - ffi.Pointer pointer(ffi.Allocator alloc) { + 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]); @@ -396,7 +414,7 @@ class _UsizeListView { _UsizeListView(this._values); // Copies - ffi.Pointer pointer(ffi.Allocator alloc) { + 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]); @@ -413,7 +431,7 @@ class _Float32ListView { _Float32ListView(this._values); // ignore: unused_element - ffi.Pointer pointer(ffi.Allocator alloc) { + ffi.Pointer allocIn(ffi.Allocator alloc) { return alloc(length)..asTypedList(length).setRange(0, length, _values); } @@ -426,29 +444,13 @@ class _Float64ListView { _Float64ListView(this._values); // ignore: unused_element - ffi.Pointer pointer(ffi.Allocator alloc) { + ffi.Pointer allocIn(ffi.Allocator alloc) { return alloc(length)..asTypedList(length).setRange(0, length, _values); } int get length => _values.length; } -class _FinalizedArena { - final ffi2.Arena arena; - static final core.Finalizer _finalizer = core.Finalizer((arena) => arena.releaseAll()); - - _FinalizedArena() : this.arena = ffi2.Arena() { - _finalizer.attach(this, this.arena); - } - // Construct - _FinalizedArena.withLifetime(core.List> lifetimeAppendArray) : this.arena = ffi2.Arena() { - _finalizer.attach(this, this.arena); - for (final edge in lifetimeAppendArray) { - edge.add(this); - } - } -} - final class _ResultBoolInt32Union extends ffi.Union { @ffi.Bool() external bool ok; @@ -551,7 +553,7 @@ final class _ResultWeekOfFfiInt32 extends ffi.Struct { } final class _SliceUsize extends ffi.Struct { - external ffi.Pointer _pointer; + external ffi.Pointer _data; @ffi.Size() external int _length; @@ -564,7 +566,7 @@ final class _SliceUsize extends ffi.Struct { } for (var i = 0; i < _length; i++) { - if (other._pointer[i] != _pointer[i]) { + if (other._data[i] != _data[i]) { return false; } } @@ -574,10 +576,15 @@ final class _SliceUsize extends ffi.Struct { // This is cheap @override int get hashCode => _length.hashCode; + + core.List _toDart(core.List lifetimeEdges) { + // Do not have to keep lifetimeEdges alive, because this copies + return core.Iterable.generate(_length).map((i) => _data[i]).toList(growable: false); + } } final class _SliceUtf8 extends ffi.Struct { - external ffi.Pointer _pointer; + external ffi.Pointer _data; @ffi.Size() external int _length; @@ -590,7 +597,7 @@ final class _SliceUtf8 extends ffi.Struct { } for (var i = 0; i < _length; i++) { - if (other._pointer[i] != _pointer[i]) { + if (other._data[i] != _data[i]) { return false; } } @@ -600,37 +607,42 @@ final class _SliceUtf8 extends ffi.Struct { // This is cheap @override int get hashCode => _length.hashCode; + + String _toDart(core.List lifetimeEdges) { + // Do not have to keep lifetimeEdges alive, because this copies + return Utf8Decoder().convert(_data.asTypedList(_length)); + } } final class _Writeable { - final ffi.Pointer _underlying; + final ffi.Pointer _ffi; - _Writeable() : _underlying = _diplomat_buffer_writeable_create(0); + _Writeable() : _ffi = _diplomat_buffer_writeable_create(0); String finalize() { - final string = Utf8Decoder().convert(_diplomat_buffer_writeable_get_bytes(_underlying).asTypedList(_diplomat_buffer_writeable_len(_underlying))); - _diplomat_buffer_writeable_destroy(_underlying); + 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() +@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() +@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() +@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() +@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/ffi/capi/src/casemap.rs b/ffi/capi/src/casemap.rs index fcabcdb7b73..235f02500a3 100644 --- a/ffi/capi/src/casemap.rs +++ b/ffi/capi/src/casemap.rs @@ -110,7 +110,7 @@ pub mod ffi { FnInStruct, hidden )] - #[diplomat::attr(dart, rename = "titlecase_segment_with_only_case_data")] + #[diplomat::attr(dart, rename = "titlecaseSegmentWithOnlyCaseData")] pub fn titlecase_segment_with_only_case_data_v1( &self, s: &DiplomatStr, @@ -313,7 +313,7 @@ pub mod ffi { FnInStruct, hidden )] - #[diplomat::attr(dart, rename = "titlecase_segment")] + #[diplomat::attr(dart, rename = "titlecaseSegment")] pub fn titlecase_segment_v1( &self, s: &DiplomatStr, diff --git a/ffi/dart/build.dart b/ffi/dart/build.dart index 2d938bf5113..fc3316675f6 100644 --- a/ffi/dart/build.dart +++ b/ffi/dart/build.dart @@ -4,6 +4,7 @@ import 'package:native_assets_cli/native_assets_cli.dart'; import 'tool/build_libs.dart' show buildLib; +import 'dart:io'; void main(List args) async { final config = await BuildConfig.fromArgs(args); @@ -22,7 +23,7 @@ void main(List args) async { id: 'package:icu/src/lib.g.dart', linkMode: linkMode, target: target, - path: AssetRelativePath( + path: AssetAbsolutePath( Uri.file(await buildLib(target, linkMode, config.outDir.path)))) ], dependencies: Dependencies([config.packageRoot.resolve('build.rs')]), diff --git a/ffi/dart/pubspec.yaml b/ffi/dart/pubspec.yaml index b31ef687413..6b9601ae986 100644 --- a/ffi/dart/pubspec.yaml +++ b/ffi/dart/pubspec.yaml @@ -3,11 +3,11 @@ version: 0.0.0 repository: https://github.com/unicode-org/icu4x environment: - sdk: ^3.3.0-279.1.beta + sdk: ^3.4.0-204.0.dev dependencies: ffi: ^2.0.0 - native_assets_cli: ^0.3.2 + native_assets_cli: ^0.4.2 meta: ^1.12.0 dev_dependencies: