From 9fc41dc37ca5208056d2ac9b72ce0808092205b7 Mon Sep 17 00:00:00 2001 From: Makoto Kato Date: Mon, 7 Aug 2023 06:23:48 +0000 Subject: [PATCH] Bug 1719535 - Part 6. mach vendor rust for ICU4X crates. r=platform-i18n-reviewers,supply-chain-reviewers,firefox-build-system-reviewers,glandium,dminor Depends on D167675 Differential Revision: https://phabricator.services.mozilla.com/D167674 --- .cargo/config.in | 10 + Cargo.lock | 252 +- Cargo.toml | 7 + supply-chain/audits.toml | 160 + supply-chain/config.toml | 28 + supply-chain/imports.lock | 7 + .../diplomat-runtime/.cargo-checksum.json | 1 + third_party/rust/diplomat-runtime/Cargo.toml | 34 + .../rust/diplomat-runtime/LICENSE-APACHE | 201 + third_party/rust/diplomat-runtime/LICENSE-MIT | 27 + third_party/rust/diplomat-runtime/src/lib.rs | 33 + .../rust/diplomat-runtime/src/result.rs | 60 + .../rust/diplomat-runtime/src/wasm_glue.rs | 43 + .../rust/diplomat-runtime/src/writeable.rs | 189 + .../rust/diplomat/.cargo-checksum.json | 1 + third_party/rust/diplomat/Cargo.toml | 52 + third_party/rust/diplomat/LICENSE-APACHE | 201 + third_party/rust/diplomat/LICENSE-MIT | 27 + third_party/rust/diplomat/src/enum_convert.rs | 85 + third_party/rust/diplomat/src/lib.rs | 686 ++ .../diplomat__tests__cfgd_struct.snap | 23 + .../diplomat__tests__cfged_method-2.snap | 24 + .../diplomat__tests__cfged_method.snap | 22 + ...t__tests__method_taking_mutable_slice.snap | 20 + ...mat__tests__method_taking_mutable_str.snap | 26 + .../diplomat__tests__method_taking_slice.snap | 20 + .../diplomat__tests__method_taking_str.snap | 23 + .../diplomat__tests__mod_with_enum.snap | 23 + ...diplomat__tests__mod_with_rust_result.snap | 20 + ...mat__tests__mod_with_writeable_result.snap | 25 + .../diplomat__tests__multilevel_borrows.snap | 45 + .../diplomat__tests__self_params.snap | 22 + .../rust/diplomat/src/transparent_convert.rs | 30 + .../rust/diplomat_core/.cargo-checksum.json | 1 + third_party/rust/diplomat_core/Cargo.toml | 66 + third_party/rust/diplomat_core/LICENSE-APACHE | 201 + third_party/rust/diplomat_core/LICENSE-MIT | 27 + .../rust/diplomat_core/src/ast/attrs.rs | 10 + .../rust/diplomat_core/src/ast/docs.rs | 431 + .../rust/diplomat_core/src/ast/enums.rs | 112 + .../rust/diplomat_core/src/ast/idents.rs | 86 + .../rust/diplomat_core/src/ast/lifetimes.rs | 573 ++ .../rust/diplomat_core/src/ast/methods.rs | 592 ++ third_party/rust/diplomat_core/src/ast/mod.rs | 37 + .../rust/diplomat_core/src/ast/modules.rs | 406 + .../rust/diplomat_core/src/ast/paths.rs | 76 + ...e__ast__enums__tests__enum_with_discr.snap | 33 + ..._core__ast__enums__tests__simple_enum.snap | 25 + ...re__ast__methods__tests__cfged_method.snap | 32 + ...__methods__tests__nonstatic_methods-2.snap | 40 + ...st__methods__tests__nonstatic_methods.snap | 33 + ...ast__methods__tests__static_methods-2.snap | 32 + ...__ast__methods__tests__static_methods.snap | 31 + ...__import_in_non_diplomat_not_analyzed.snap | 27 + ...st__modules__tests__method_visibility.snap | 30 + ...core__ast__modules__tests__simple_mod.snap | 121 + ...e__ast__structs__tests__simple_struct.snap | 32 + ..._core__ast__types__tests__lifetimes-2.snap | 12 + ..._core__ast__types__tests__lifetimes-3.snap | 13 + ..._core__ast__types__tests__lifetimes-4.snap | 12 + ..._core__ast__types__tests__lifetimes-5.snap | 14 + ..._core__ast__types__tests__lifetimes-6.snap | 18 + ..._core__ast__types__tests__lifetimes-7.snap | 20 + ...at_core__ast__types__tests__lifetimes.snap | 12 + ...__ast__types__tests__typename_boxes-2.snap | 11 + ...re__ast__types__tests__typename_boxes.snap | 7 + ...re__ast__types__tests__typename_named.snap | 10 + ..._ast__types__tests__typename_option-2.snap | 11 + ...e__ast__types__tests__typename_option.snap | 7 + ...__types__tests__typename_primitives-2.snap | 6 + ...__types__tests__typename_primitives-3.snap | 6 + ...st__types__tests__typename_primitives.snap | 6 + ...__types__tests__typename_references-2.snap | 13 + ...st__types__tests__typename_references.snap | 9 + ..._ast__types__tests__typename_result-2.snap | 13 + ..._ast__types__tests__typename_result-3.snap | 13 + ..._ast__types__tests__typename_result-4.snap | 13 + ...e__ast__types__tests__typename_result.snap | 13 + ...ast__validity__tests__non_opaque_move.snap | 9 + ...dity__tests__opaque_checks_with_error.snap | 7 + ...y__tests__opaque_checks_with_safe_use.snap | 6 + ...ore__ast__validity__tests__opaque_ffi.snap | 7 + ..._ast__validity__tests__option_invalid.snap | 9 + ...e__ast__validity__tests__option_valid.snap | 5 + ..._ast__validity__tests__zst_non_opaque.snap | 7 + .../rust/diplomat_core/src/ast/structs.rs | 109 + .../rust/diplomat_core/src/ast/types.rs | 1219 +++ .../rust/diplomat_core/src/ast/validity.rs | 224 + .../rust/diplomat_core/src/environment.rs | 88 + .../rust/diplomat_core/src/hir/defs.rs | 166 + .../rust/diplomat_core/src/hir/elision.rs | 549 ++ .../rust/diplomat_core/src/hir/lifetimes.rs | 284 + .../rust/diplomat_core/src/hir/lowering.rs | 856 ++ .../rust/diplomat_core/src/hir/methods.rs | 489 ++ third_party/rust/diplomat_core/src/hir/mod.rs | 29 + .../rust/diplomat_core/src/hir/paths.rs | 167 + .../rust/diplomat_core/src/hir/primitives.rs | 128 + ...hir__elision__tests__borrowing_fields.snap | 25 + ...core__hir__elision__tests__simple_mod.snap | 208 + .../rust/diplomat_core/src/hir/ty_position.rs | 182 + .../diplomat_core/src/hir/type_context.rs | 254 + .../rust/diplomat_core/src/hir/types.rs | 99 + third_party/rust/diplomat_core/src/lib.rs | 14 + .../rust/icu_capi/.cargo-checksum.json | 1 + third_party/rust/icu_capi/Cargo.toml | 248 + third_party/rust/icu_capi/LICENSE | 51 + third_party/rust/icu_capi/README.md | 26 + third_party/rust/icu_capi/c/README.md | 18 + .../c/examples/fixeddecimal_tiny/README.md | 8 + .../c/include/CodePointRangeIterator.h | 30 + .../c/include/CodePointRangeIteratorResult.h | 32 + .../icu_capi/c/include/ICU4XAnyCalendarKind.h | 46 + .../rust/icu_capi/c/include/ICU4XBidi.h | 45 + .../icu_capi/c/include/ICU4XBidiDirection.h | 32 + .../rust/icu_capi/c/include/ICU4XBidiInfo.h | 36 + .../icu_capi/c/include/ICU4XBidiParagraph.h | 43 + .../rust/icu_capi/c/include/ICU4XCalendar.h | 37 + .../include/ICU4XCanonicalCombiningClassMap.h | 35 + .../c/include/ICU4XCanonicalComposition.h | 33 + .../c/include/ICU4XCanonicalDecomposition.h | 34 + .../c/include/ICU4XCodePointMapData16.h | 43 + .../c/include/ICU4XCodePointMapData8.h | 59 + .../c/include/ICU4XCodePointSetData.h | 172 + .../rust/icu_capi/c/include/ICU4XCollator.h | 40 + .../include/ICU4XCollatorAlternateHandling.h | 32 + .../ICU4XCollatorBackwardSecondLevel.h | 32 + .../c/include/ICU4XCollatorCaseFirst.h | 33 + .../c/include/ICU4XCollatorCaseLevel.h | 32 + .../c/include/ICU4XCollatorMaxVariable.h | 34 + .../icu_capi/c/include/ICU4XCollatorNumeric.h | 32 + .../c/include/ICU4XCollatorOptionsV1.h | 50 + .../c/include/ICU4XCollatorStrength.h | 35 + .../c/include/ICU4XComposingNormalizer.h | 38 + .../icu_capi/c/include/ICU4XCustomTimeZone.h | 81 + .../icu_capi/c/include/ICU4XDataProvider.h | 46 + .../rust/icu_capi/c/include/ICU4XDataStruct.h | 30 + .../rust/icu_capi/c/include/ICU4XDate.h | 66 + .../icu_capi/c/include/ICU4XDateFormatter.h | 46 + .../rust/icu_capi/c/include/ICU4XDateLength.h | 33 + .../rust/icu_capi/c/include/ICU4XDateTime.h | 82 + .../c/include/ICU4XDateTimeFormatter.h | 41 + .../rust/icu_capi/c/include/ICU4XDecomposed.h | 31 + .../c/include/ICU4XDecomposingNormalizer.h | 38 + .../c/include/ICU4XDisplayNamesFallback.h | 31 + .../c/include/ICU4XDisplayNamesOptionsV1.h | 38 + .../c/include/ICU4XDisplayNamesStyle.h | 34 + .../rust/icu_capi/c/include/ICU4XError.h | 83 + .../icu_capi/c/include/ICU4XFixedDecimal.h | 101 + .../c/include/ICU4XFixedDecimalFormatter.h | 40 + .../ICU4XFixedDecimalGroupingStrategy.h | 33 + .../c/include/ICU4XFixedDecimalSign.h | 32 + .../c/include/ICU4XFixedDecimalSignDisplay.h | 34 + .../ICU4XGeneralCategoryNameToMaskMapper.h | 35 + .../ICU4XGraphemeClusterBreakIteratorLatin1.h | 29 + .../ICU4XGraphemeClusterBreakIteratorUtf16.h | 29 + .../ICU4XGraphemeClusterBreakIteratorUtf8.h | 29 + .../c/include/ICU4XGraphemeClusterSegmenter.h | 40 + .../c/include/ICU4XGregorianDateFormatter.h | 40 + .../include/ICU4XGregorianDateTimeFormatter.h | 38 + .../ICU4XGregorianZonedDateTimeFormatter.h | 42 + .../rust/icu_capi/c/include/ICU4XIsoDate.h | 57 + .../icu_capi/c/include/ICU4XIsoDateTime.h | 77 + .../c/include/ICU4XIsoTimeZoneFormat.h | 33 + .../c/include/ICU4XIsoTimeZoneMinuteDisplay.h | 31 + .../c/include/ICU4XIsoTimeZoneOptions.h | 38 + .../c/include/ICU4XIsoTimeZoneSecondDisplay.h | 31 + .../rust/icu_capi/c/include/ICU4XIsoWeekday.h | 36 + .../icu_capi/c/include/ICU4XLanguageDisplay.h | 31 + .../c/include/ICU4XLineBreakIteratorLatin1.h | 29 + .../c/include/ICU4XLineBreakIteratorUtf16.h | 29 + .../c/include/ICU4XLineBreakIteratorUtf8.h | 29 + .../c/include/ICU4XLineBreakOptionsV1.h | 36 + .../c/include/ICU4XLineBreakStrictness.h | 33 + .../c/include/ICU4XLineBreakWordOption.h | 32 + .../icu_capi/c/include/ICU4XLineSegmenter.h | 51 + .../rust/icu_capi/c/include/ICU4XList.h | 35 + .../icu_capi/c/include/ICU4XListFormatter.h | 41 + .../rust/icu_capi/c/include/ICU4XListLength.h | 32 + .../rust/icu_capi/c/include/ICU4XLocale.h | 64 + .../c/include/ICU4XLocaleCanonicalizer.h | 37 + .../ICU4XLocaleDisplayNamesFormatter.h | 36 + .../icu_capi/c/include/ICU4XLocaleExpander.h | 39 + .../c/include/ICU4XLocaleFallbackConfig.h | 33 + .../c/include/ICU4XLocaleFallbackIterator.h | 32 + .../c/include/ICU4XLocaleFallbackPriority.h | 32 + .../c/include/ICU4XLocaleFallbacker.h | 37 + .../include/ICU4XLocaleFallbackerWithConfig.h | 31 + .../rust/icu_capi/c/include/ICU4XLogger.h | 29 + .../c/include/ICU4XMetazoneCalculator.h | 31 + .../rust/icu_capi/c/include/ICU4XOrdering.h | 32 + .../c/include/ICU4XPluralCategories.h | 35 + .../icu_capi/c/include/ICU4XPluralCategory.h | 37 + .../icu_capi/c/include/ICU4XPluralOperands.h | 30 + .../icu_capi/c/include/ICU4XPluralRules.h | 41 + .../ICU4XPropertyValueNameToEnumMapper.h | 49 + .../c/include/ICU4XRegionDisplayNames.h | 35 + .../c/include/ICU4XReorderedIndexMap.h | 33 + .../c/include/ICU4XScriptExtensionsSet.h | 34 + .../c/include/ICU4XScriptWithExtensions.h | 41 + .../ICU4XScriptWithExtensionsBorrowed.h | 34 + .../c/include/ICU4XSegmenterWordType.h | 32 + .../ICU4XSentenceBreakIteratorLatin1.h | 29 + .../include/ICU4XSentenceBreakIteratorUtf16.h | 29 + .../include/ICU4XSentenceBreakIteratorUtf8.h | 29 + .../c/include/ICU4XSentenceSegmenter.h | 40 + .../rust/icu_capi/c/include/ICU4XTime.h | 38 + .../icu_capi/c/include/ICU4XTimeFormatter.h | 43 + .../rust/icu_capi/c/include/ICU4XTimeLength.h | 33 + .../c/include/ICU4XTimeZoneFormatter.h | 53 + .../icu_capi/c/include/ICU4XTransformResult.h | 31 + .../icu_capi/c/include/ICU4XUnicodeSetData.h | 48 + .../icu_capi/c/include/ICU4XWeekCalculator.h | 39 + .../rust/icu_capi/c/include/ICU4XWeekOf.h | 33 + .../c/include/ICU4XWeekRelativeUnit.h | 32 + .../c/include/ICU4XWordBreakIteratorLatin1.h | 34 + .../c/include/ICU4XWordBreakIteratorUtf16.h | 34 + .../c/include/ICU4XWordBreakIteratorUtf8.h | 34 + .../icu_capi/c/include/ICU4XWordSegmenter.h | 44 + .../c/include/ICU4XZonedDateTimeFormatter.h | 45 + ...iplomat_result_ICU4XAnyCalendarKind_void.h | 24 + ...diplomat_result_ICU4XPluralCategory_void.h | 24 + .../diplomat_result_ICU4XWeekOf_ICU4XError.h | 26 + .../include/diplomat_result_bool_ICU4XError.h | 25 + ...diplomat_result_box_ICU4XBidi_ICU4XError.h | 26 + ...omat_result_box_ICU4XCalendar_ICU4XError.h | 26 + ...U4XCanonicalCombiningClassMap_ICU4XError.h | 26 + ...box_ICU4XCanonicalComposition_ICU4XError.h | 26 + ...x_ICU4XCanonicalDecomposition_ICU4XError.h | 26 + ...t_box_ICU4XCodePointMapData16_ICU4XError.h | 26 + ...lt_box_ICU4XCodePointMapData8_ICU4XError.h | 26 + ...ult_box_ICU4XCodePointSetData_ICU4XError.h | 26 + ...omat_result_box_ICU4XCollator_ICU4XError.h | 26 + ..._box_ICU4XComposingNormalizer_ICU4XError.h | 26 + ...esult_box_ICU4XCustomTimeZone_ICU4XError.h | 26 + ..._result_box_ICU4XDataProvider_ICU4XError.h | 26 + ...at_result_box_ICU4XDataStruct_ICU4XError.h | 26 + ...result_box_ICU4XDateFormatter_ICU4XError.h | 26 + ...lt_box_ICU4XDateTimeFormatter_ICU4XError.h | 26 + ...omat_result_box_ICU4XDateTime_ICU4XError.h | 26 + ...diplomat_result_box_ICU4XDate_ICU4XError.h | 26 + ...ox_ICU4XDecomposingNormalizer_ICU4XError.h | 26 + ...ox_ICU4XFixedDecimalFormatter_ICU4XError.h | 26 + ..._result_box_ICU4XFixedDecimal_ICU4XError.h | 26 + ...neralCategoryNameToMaskMapper_ICU4XError.h | 26 + ...ICU4XGraphemeClusterSegmenter_ICU4XError.h | 26 + ...x_ICU4XGregorianDateFormatter_ICU4XError.h | 26 + ...U4XGregorianDateTimeFormatter_ICU4XError.h | 26 + ...egorianZonedDateTimeFormatter_ICU4XError.h | 26 + ...t_result_box_ICU4XIsoDateTime_ICU4XError.h | 26 + ...lomat_result_box_ICU4XIsoDate_ICU4XError.h | 26 + ...result_box_ICU4XLineSegmenter_ICU4XError.h | 26 + ...result_box_ICU4XListFormatter_ICU4XError.h | 26 + ..._box_ICU4XLocaleCanonicalizer_ICU4XError.h | 26 + ...4XLocaleDisplayNamesFormatter_ICU4XError.h | 26 + ...esult_box_ICU4XLocaleExpander_ICU4XError.h | 26 + ...U4XLocaleFallbackerWithConfig_ICU4XError.h | 26 + ...ult_box_ICU4XLocaleFallbacker_ICU4XError.h | 26 + ...plomat_result_box_ICU4XLocale_ICU4XError.h | 26 + ...t_box_ICU4XMetazoneCalculator_ICU4XError.h | 26 + ...esult_box_ICU4XPluralOperands_ICU4XError.h | 26 + ...t_result_box_ICU4XPluralRules_ICU4XError.h | 26 + ...PropertyValueNameToEnumMapper_ICU4XError.h | 26 + ...t_box_ICU4XRegionDisplayNames_ICU4XError.h | 26 + ...box_ICU4XScriptWithExtensions_ICU4XError.h | 26 + ...lt_box_ICU4XSentenceSegmenter_ICU4XError.h | 26 + ...result_box_ICU4XTimeFormatter_ICU4XError.h | 26 + ...lt_box_ICU4XTimeZoneFormatter_ICU4XError.h | 26 + ...diplomat_result_box_ICU4XTime_ICU4XError.h | 26 + ...esult_box_ICU4XUnicodeSetData_ICU4XError.h | 26 + ...esult_box_ICU4XWeekCalculator_ICU4XError.h | 26 + ...result_box_ICU4XWordSegmenter_ICU4XError.h | 26 + ...x_ICU4XZonedDateTimeFormatter_ICU4XError.h | 26 + .../diplomat_result_int32_t_ICU4XError.h | 25 + .../c/include/diplomat_result_uint16_t_void.h | 23 + .../include/diplomat_result_void_ICU4XError.h | 24 + .../c/include/diplomat_result_void_void.h | 20 + .../icu_capi/c/include/diplomat_runtime.h | 70 + third_party/rust/icu_capi/cpp/README.md | 18 + .../cpp/include/CodePointRangeIterator.h | 30 + .../cpp/include/CodePointRangeIterator.hpp | 54 + .../include/CodePointRangeIteratorResult.h | 32 + .../include/CodePointRangeIteratorResult.hpp | 33 + .../cpp/include/ICU4XAnyCalendarKind.h | 46 + .../cpp/include/ICU4XAnyCalendarKind.hpp | 72 + .../rust/icu_capi/cpp/include/ICU4XBidi.h | 45 + .../rust/icu_capi/cpp/include/ICU4XBidi.hpp | 142 + .../icu_capi/cpp/include/ICU4XBidiDirection.h | 32 + .../cpp/include/ICU4XBidiDirection.hpp | 21 + .../rust/icu_capi/cpp/include/ICU4XBidiInfo.h | 36 + .../icu_capi/cpp/include/ICU4XBidiInfo.hpp | 89 + .../icu_capi/cpp/include/ICU4XBidiParagraph.h | 43 + .../cpp/include/ICU4XBidiParagraph.hpp | 150 + .../rust/icu_capi/cpp/include/ICU4XCalendar.h | 37 + .../icu_capi/cpp/include/ICU4XCalendar.hpp | 93 + .../include/ICU4XCanonicalCombiningClassMap.h | 35 + .../ICU4XCanonicalCombiningClassMap.hpp | 87 + .../cpp/include/ICU4XCanonicalComposition.h | 33 + .../cpp/include/ICU4XCanonicalComposition.hpp | 76 + .../cpp/include/ICU4XCanonicalDecomposition.h | 34 + .../include/ICU4XCanonicalDecomposition.hpp | 78 + .../cpp/include/ICU4XCodePointMapData16.h | 43 + .../cpp/include/ICU4XCodePointMapData16.hpp | 125 + .../cpp/include/ICU4XCodePointMapData8.h | 59 + .../cpp/include/ICU4XCodePointMapData8.hpp | 258 + .../cpp/include/ICU4XCodePointSetData.h | 172 + .../cpp/include/ICU4XCodePointSetData.hpp | 1239 +++ .../rust/icu_capi/cpp/include/ICU4XCollator.h | 40 + .../icu_capi/cpp/include/ICU4XCollator.hpp | 107 + .../include/ICU4XCollatorAlternateHandling.h | 32 + .../ICU4XCollatorAlternateHandling.hpp | 27 + .../ICU4XCollatorBackwardSecondLevel.h | 32 + .../ICU4XCollatorBackwardSecondLevel.hpp | 27 + .../cpp/include/ICU4XCollatorCaseFirst.h | 33 + .../cpp/include/ICU4XCollatorCaseFirst.hpp | 28 + .../cpp/include/ICU4XCollatorCaseLevel.h | 32 + .../cpp/include/ICU4XCollatorCaseLevel.hpp | 27 + .../cpp/include/ICU4XCollatorMaxVariable.h | 34 + .../cpp/include/ICU4XCollatorMaxVariable.hpp | 29 + .../cpp/include/ICU4XCollatorNumeric.h | 32 + .../cpp/include/ICU4XCollatorNumeric.hpp | 27 + .../cpp/include/ICU4XCollatorOptionsV1.h | 50 + .../cpp/include/ICU4XCollatorOptionsV1.hpp | 40 + .../cpp/include/ICU4XCollatorStrength.h | 35 + .../cpp/include/ICU4XCollatorStrength.hpp | 30 + .../cpp/include/ICU4XComposingNormalizer.h | 38 + .../cpp/include/ICU4XComposingNormalizer.hpp | 133 + .../cpp/include/ICU4XCustomTimeZone.h | 81 + .../cpp/include/ICU4XCustomTimeZone.hpp | 527 ++ .../icu_capi/cpp/include/ICU4XDataProvider.h | 46 + .../cpp/include/ICU4XDataProvider.hpp | 186 + .../icu_capi/cpp/include/ICU4XDataStruct.h | 30 + .../icu_capi/cpp/include/ICU4XDataStruct.hpp | 63 + .../rust/icu_capi/cpp/include/ICU4XDate.h | 66 + .../rust/icu_capi/cpp/include/ICU4XDate.hpp | 303 + .../icu_capi/cpp/include/ICU4XDateFormatter.h | 46 + .../cpp/include/ICU4XDateFormatter.hpp | 231 + .../icu_capi/cpp/include/ICU4XDateLength.h | 33 + .../icu_capi/cpp/include/ICU4XDateLength.hpp | 28 + .../rust/icu_capi/cpp/include/ICU4XDateTime.h | 82 + .../icu_capi/cpp/include/ICU4XDateTime.hpp | 373 + .../cpp/include/ICU4XDateTimeFormatter.h | 41 + .../cpp/include/ICU4XDateTimeFormatter.hpp | 150 + .../icu_capi/cpp/include/ICU4XDecomposed.h | 31 + .../icu_capi/cpp/include/ICU4XDecomposed.hpp | 30 + .../cpp/include/ICU4XDecomposingNormalizer.h | 38 + .../include/ICU4XDecomposingNormalizer.hpp | 133 + .../cpp/include/ICU4XDisplayNamesFallback.h | 31 + .../cpp/include/ICU4XDisplayNamesFallback.hpp | 26 + .../cpp/include/ICU4XDisplayNamesOptionsV1.h | 38 + .../include/ICU4XDisplayNamesOptionsV1.hpp | 45 + .../cpp/include/ICU4XDisplayNamesStyle.h | 34 + .../cpp/include/ICU4XDisplayNamesStyle.hpp | 29 + .../rust/icu_capi/cpp/include/ICU4XError.h | 83 + .../rust/icu_capi/cpp/include/ICU4XError.hpp | 103 + .../icu_capi/cpp/include/ICU4XFixedDecimal.h | 101 + .../cpp/include/ICU4XFixedDecimal.hpp | 466 + .../cpp/include/ICU4XFixedDecimalFormatter.h | 40 + .../include/ICU4XFixedDecimalFormatter.hpp | 126 + .../ICU4XFixedDecimalGroupingStrategy.h | 33 + .../ICU4XFixedDecimalGroupingStrategy.hpp | 28 + .../cpp/include/ICU4XFixedDecimalSign.h | 32 + .../cpp/include/ICU4XFixedDecimalSign.hpp | 39 + .../include/ICU4XFixedDecimalSignDisplay.h | 34 + .../include/ICU4XFixedDecimalSignDisplay.hpp | 29 + .../ICU4XGeneralCategoryNameToMaskMapper.h | 35 + .../ICU4XGeneralCategoryNameToMaskMapper.hpp | 85 + .../ICU4XGraphemeClusterBreakIteratorLatin1.h | 29 + ...CU4XGraphemeClusterBreakIteratorLatin1.hpp | 53 + .../ICU4XGraphemeClusterBreakIteratorUtf16.h | 29 + ...ICU4XGraphemeClusterBreakIteratorUtf16.hpp | 53 + .../ICU4XGraphemeClusterBreakIteratorUtf8.h | 29 + .../ICU4XGraphemeClusterBreakIteratorUtf8.hpp | 53 + .../include/ICU4XGraphemeClusterSegmenter.h | 40 + .../include/ICU4XGraphemeClusterSegmenter.hpp | 106 + .../cpp/include/ICU4XGregorianDateFormatter.h | 40 + .../include/ICU4XGregorianDateFormatter.hpp | 145 + .../include/ICU4XGregorianDateTimeFormatter.h | 38 + .../ICU4XGregorianDateTimeFormatter.hpp | 107 + .../ICU4XGregorianZonedDateTimeFormatter.h | 42 + .../ICU4XGregorianZonedDateTimeFormatter.hpp | 134 + .../rust/icu_capi/cpp/include/ICU4XIsoDate.h | 57 + .../icu_capi/cpp/include/ICU4XIsoDate.hpp | 191 + .../icu_capi/cpp/include/ICU4XIsoDateTime.h | 77 + .../icu_capi/cpp/include/ICU4XIsoDateTime.hpp | 286 + .../cpp/include/ICU4XIsoTimeZoneFormat.h | 33 + .../cpp/include/ICU4XIsoTimeZoneFormat.hpp | 28 + .../include/ICU4XIsoTimeZoneMinuteDisplay.h | 31 + .../include/ICU4XIsoTimeZoneMinuteDisplay.hpp | 26 + .../cpp/include/ICU4XIsoTimeZoneOptions.h | 38 + .../cpp/include/ICU4XIsoTimeZoneOptions.hpp | 26 + .../include/ICU4XIsoTimeZoneSecondDisplay.h | 31 + .../include/ICU4XIsoTimeZoneSecondDisplay.hpp | 26 + .../icu_capi/cpp/include/ICU4XIsoWeekday.h | 36 + .../icu_capi/cpp/include/ICU4XIsoWeekday.hpp | 25 + .../cpp/include/ICU4XLanguageDisplay.h | 31 + .../cpp/include/ICU4XLanguageDisplay.hpp | 26 + .../include/ICU4XLineBreakIteratorLatin1.h | 29 + .../include/ICU4XLineBreakIteratorLatin1.hpp | 55 + .../cpp/include/ICU4XLineBreakIteratorUtf16.h | 29 + .../include/ICU4XLineBreakIteratorUtf16.hpp | 55 + .../cpp/include/ICU4XLineBreakIteratorUtf8.h | 29 + .../include/ICU4XLineBreakIteratorUtf8.hpp | 55 + .../cpp/include/ICU4XLineBreakOptionsV1.h | 36 + .../cpp/include/ICU4XLineBreakOptionsV1.hpp | 31 + .../cpp/include/ICU4XLineBreakStrictness.h | 33 + .../cpp/include/ICU4XLineBreakStrictness.hpp | 28 + .../cpp/include/ICU4XLineBreakWordOption.h | 32 + .../cpp/include/ICU4XLineBreakWordOption.hpp | 27 + .../icu_capi/cpp/include/ICU4XLineSegmenter.h | 51 + .../cpp/include/ICU4XLineSegmenter.hpp | 201 + .../rust/icu_capi/cpp/include/ICU4XList.h | 35 + .../rust/icu_capi/cpp/include/ICU4XList.hpp | 77 + .../icu_capi/cpp/include/ICU4XListFormatter.h | 41 + .../cpp/include/ICU4XListFormatter.hpp | 139 + .../icu_capi/cpp/include/ICU4XListLength.h | 32 + .../icu_capi/cpp/include/ICU4XListLength.hpp | 27 + .../rust/icu_capi/cpp/include/ICU4XLocale.h | 64 + .../rust/icu_capi/cpp/include/ICU4XLocale.hpp | 444 + .../cpp/include/ICU4XLocaleCanonicalizer.h | 37 + .../cpp/include/ICU4XLocaleCanonicalizer.hpp | 93 + .../ICU4XLocaleDisplayNamesFormatter.h | 36 + .../ICU4XLocaleDisplayNamesFormatter.hpp | 105 + .../cpp/include/ICU4XLocaleExpander.h | 39 + .../cpp/include/ICU4XLocaleExpander.hpp | 103 + .../cpp/include/ICU4XLocaleFallbackConfig.h | 33 + .../cpp/include/ICU4XLocaleFallbackConfig.hpp | 37 + .../cpp/include/ICU4XLocaleFallbackIterator.h | 32 + .../include/ICU4XLocaleFallbackIterator.hpp | 64 + .../cpp/include/ICU4XLocaleFallbackPriority.h | 32 + .../include/ICU4XLocaleFallbackPriority.hpp | 27 + .../cpp/include/ICU4XLocaleFallbacker.h | 37 + .../cpp/include/ICU4XLocaleFallbacker.hpp | 97 + .../include/ICU4XLocaleFallbackerWithConfig.h | 31 + .../ICU4XLocaleFallbackerWithConfig.hpp | 58 + .../rust/icu_capi/cpp/include/ICU4XLogger.h | 29 + .../rust/icu_capi/cpp/include/ICU4XLogger.hpp | 50 + .../cpp/include/ICU4XMetazoneCalculator.h | 31 + .../cpp/include/ICU4XMetazoneCalculator.hpp | 67 + .../rust/icu_capi/cpp/include/ICU4XOrdering.h | 32 + .../icu_capi/cpp/include/ICU4XOrdering.hpp | 27 + .../cpp/include/ICU4XPluralCategories.h | 35 + .../cpp/include/ICU4XPluralCategories.hpp | 30 + .../cpp/include/ICU4XPluralCategory.h | 37 + .../cpp/include/ICU4XPluralCategory.hpp | 30 + .../cpp/include/ICU4XPluralOperands.h | 30 + .../cpp/include/ICU4XPluralOperands.hpp | 61 + .../icu_capi/cpp/include/ICU4XPluralRules.h | 41 + .../icu_capi/cpp/include/ICU4XPluralRules.hpp | 108 + .../ICU4XPropertyValueNameToEnumMapper.h | 49 + .../ICU4XPropertyValueNameToEnumMapper.hpp | 208 + .../cpp/include/ICU4XRegionDisplayNames.h | 35 + .../cpp/include/ICU4XRegionDisplayNames.hpp | 106 + .../cpp/include/ICU4XReorderedIndexMap.h | 33 + .../cpp/include/ICU4XReorderedIndexMap.hpp | 74 + .../cpp/include/ICU4XScriptExtensionsSet.h | 34 + .../cpp/include/ICU4XScriptExtensionsSet.hpp | 79 + .../cpp/include/ICU4XScriptWithExtensions.h | 41 + .../cpp/include/ICU4XScriptWithExtensions.hpp | 111 + .../ICU4XScriptWithExtensionsBorrowed.h | 34 + .../ICU4XScriptWithExtensionsBorrowed.hpp | 76 + .../cpp/include/ICU4XSegmenterWordType.h | 32 + .../cpp/include/ICU4XSegmenterWordType.hpp | 27 + .../ICU4XSentenceBreakIteratorLatin1.h | 29 + .../ICU4XSentenceBreakIteratorLatin1.hpp | 53 + .../include/ICU4XSentenceBreakIteratorUtf16.h | 29 + .../ICU4XSentenceBreakIteratorUtf16.hpp | 53 + .../include/ICU4XSentenceBreakIteratorUtf8.h | 29 + .../ICU4XSentenceBreakIteratorUtf8.hpp | 53 + .../cpp/include/ICU4XSentenceSegmenter.h | 40 + .../cpp/include/ICU4XSentenceSegmenter.hpp | 105 + .../rust/icu_capi/cpp/include/ICU4XTime.h | 38 + .../rust/icu_capi/cpp/include/ICU4XTime.hpp | 101 + .../icu_capi/cpp/include/ICU4XTimeFormatter.h | 43 + .../cpp/include/ICU4XTimeFormatter.hpp | 183 + .../icu_capi/cpp/include/ICU4XTimeLength.h | 33 + .../icu_capi/cpp/include/ICU4XTimeLength.hpp | 28 + .../cpp/include/ICU4XTimeZoneFormatter.h | 53 + .../cpp/include/ICU4XTimeZoneFormatter.hpp | 256 + .../cpp/include/ICU4XTransformResult.h | 31 + .../cpp/include/ICU4XTransformResult.hpp | 26 + .../cpp/include/ICU4XUnicodeSetData.h | 48 + .../cpp/include/ICU4XUnicodeSetData.hpp | 182 + .../cpp/include/ICU4XWeekCalculator.h | 39 + .../cpp/include/ICU4XWeekCalculator.hpp | 97 + .../rust/icu_capi/cpp/include/ICU4XWeekOf.h | 33 + .../rust/icu_capi/cpp/include/ICU4XWeekOf.hpp | 29 + .../cpp/include/ICU4XWeekRelativeUnit.h | 32 + .../cpp/include/ICU4XWeekRelativeUnit.hpp | 27 + .../include/ICU4XWordBreakIteratorLatin1.h | 34 + .../include/ICU4XWordBreakIteratorLatin1.hpp | 74 + .../cpp/include/ICU4XWordBreakIteratorUtf16.h | 34 + .../include/ICU4XWordBreakIteratorUtf16.hpp | 74 + .../cpp/include/ICU4XWordBreakIteratorUtf8.h | 34 + .../include/ICU4XWordBreakIteratorUtf8.hpp | 74 + .../icu_capi/cpp/include/ICU4XWordSegmenter.h | 44 + .../cpp/include/ICU4XWordSegmenter.hpp | 148 + .../cpp/include/ICU4XZonedDateTimeFormatter.h | 45 + .../include/ICU4XZonedDateTimeFormatter.hpp | 173 + ...iplomat_result_ICU4XAnyCalendarKind_void.h | 24 + ...diplomat_result_ICU4XPluralCategory_void.h | 24 + .../diplomat_result_ICU4XWeekOf_ICU4XError.h | 26 + .../include/diplomat_result_bool_ICU4XError.h | 25 + ...diplomat_result_box_ICU4XBidi_ICU4XError.h | 26 + ...omat_result_box_ICU4XCalendar_ICU4XError.h | 26 + ...U4XCanonicalCombiningClassMap_ICU4XError.h | 26 + ...box_ICU4XCanonicalComposition_ICU4XError.h | 26 + ...x_ICU4XCanonicalDecomposition_ICU4XError.h | 26 + ...t_box_ICU4XCodePointMapData16_ICU4XError.h | 26 + ...lt_box_ICU4XCodePointMapData8_ICU4XError.h | 26 + ...ult_box_ICU4XCodePointSetData_ICU4XError.h | 26 + ...omat_result_box_ICU4XCollator_ICU4XError.h | 26 + ..._box_ICU4XComposingNormalizer_ICU4XError.h | 26 + ...esult_box_ICU4XCustomTimeZone_ICU4XError.h | 26 + ..._result_box_ICU4XDataProvider_ICU4XError.h | 26 + ...at_result_box_ICU4XDataStruct_ICU4XError.h | 26 + ...result_box_ICU4XDateFormatter_ICU4XError.h | 26 + ...lt_box_ICU4XDateTimeFormatter_ICU4XError.h | 26 + ...omat_result_box_ICU4XDateTime_ICU4XError.h | 26 + ...diplomat_result_box_ICU4XDate_ICU4XError.h | 26 + ...ox_ICU4XDecomposingNormalizer_ICU4XError.h | 26 + ...ox_ICU4XFixedDecimalFormatter_ICU4XError.h | 26 + ..._result_box_ICU4XFixedDecimal_ICU4XError.h | 26 + ...neralCategoryNameToMaskMapper_ICU4XError.h | 26 + ...ICU4XGraphemeClusterSegmenter_ICU4XError.h | 26 + ...x_ICU4XGregorianDateFormatter_ICU4XError.h | 26 + ...U4XGregorianDateTimeFormatter_ICU4XError.h | 26 + ...egorianZonedDateTimeFormatter_ICU4XError.h | 26 + ...t_result_box_ICU4XIsoDateTime_ICU4XError.h | 26 + ...lomat_result_box_ICU4XIsoDate_ICU4XError.h | 26 + ...result_box_ICU4XLineSegmenter_ICU4XError.h | 26 + ...result_box_ICU4XListFormatter_ICU4XError.h | 26 + ..._box_ICU4XLocaleCanonicalizer_ICU4XError.h | 26 + ...4XLocaleDisplayNamesFormatter_ICU4XError.h | 26 + ...esult_box_ICU4XLocaleExpander_ICU4XError.h | 26 + ...U4XLocaleFallbackerWithConfig_ICU4XError.h | 26 + ...ult_box_ICU4XLocaleFallbacker_ICU4XError.h | 26 + ...plomat_result_box_ICU4XLocale_ICU4XError.h | 26 + ...t_box_ICU4XMetazoneCalculator_ICU4XError.h | 26 + ...esult_box_ICU4XPluralOperands_ICU4XError.h | 26 + ...t_result_box_ICU4XPluralRules_ICU4XError.h | 26 + ...PropertyValueNameToEnumMapper_ICU4XError.h | 26 + ...t_box_ICU4XRegionDisplayNames_ICU4XError.h | 26 + ...box_ICU4XScriptWithExtensions_ICU4XError.h | 26 + ...lt_box_ICU4XSentenceSegmenter_ICU4XError.h | 26 + ...result_box_ICU4XTimeFormatter_ICU4XError.h | 26 + ...lt_box_ICU4XTimeZoneFormatter_ICU4XError.h | 26 + ...diplomat_result_box_ICU4XTime_ICU4XError.h | 26 + ...esult_box_ICU4XUnicodeSetData_ICU4XError.h | 26 + ...esult_box_ICU4XWeekCalculator_ICU4XError.h | 26 + ...result_box_ICU4XWordSegmenter_ICU4XError.h | 26 + ...x_ICU4XZonedDateTimeFormatter_ICU4XError.h | 26 + .../diplomat_result_int32_t_ICU4XError.h | 25 + .../include/diplomat_result_uint16_t_void.h | 23 + .../include/diplomat_result_void_ICU4XError.h | 24 + .../cpp/include/diplomat_result_void_void.h | 20 + .../icu_capi/cpp/include/diplomat_runtime.h | 70 + .../icu_capi/cpp/include/diplomat_runtime.hpp | 160 + third_party/rust/icu_capi/js/README.md | 18 + .../icu_capi/js/examples/tinywasm/README.md | 1 + .../js/include/CodePointRangeIterator.d.ts | 16 + .../js/include/CodePointRangeIterator.js | 28 + .../include/CodePointRangeIteratorResult.d.ts | 13 + .../include/CodePointRangeIteratorResult.js | 10 + .../js/include/ICU4XAnyCalendarKind.d.ts | 57 + .../js/include/ICU4XAnyCalendarKind.js | 39 + .../rust/icu_capi/js/include/ICU4XBidi.d.ts | 82 + .../rust/icu_capi/js/include/ICU4XBidi.js | 65 + .../js/include/ICU4XBidiDirection.d.ts | 14 + .../icu_capi/js/include/ICU4XBidiDirection.js | 20 + .../icu_capi/js/include/ICU4XBidiInfo.d.ts | 37 + .../rust/icu_capi/js/include/ICU4XBidiInfo.js | 37 + .../js/include/ICU4XBidiParagraph.d.ts | 67 + .../icu_capi/js/include/ICU4XBidiParagraph.js | 75 + .../icu_capi/js/include/ICU4XCalendar.d.ts | 38 + .../rust/icu_capi/js/include/ICU4XCalendar.js | 57 + .../ICU4XCanonicalCombiningClassMap.d.ts | 38 + .../ICU4XCanonicalCombiningClassMap.js | 43 + .../js/include/ICU4XCanonicalComposition.d.ts | 32 + .../js/include/ICU4XCanonicalComposition.js | 39 + .../include/ICU4XCanonicalDecomposition.d.ts | 33 + .../js/include/ICU4XCanonicalDecomposition.js | 46 + .../js/include/ICU4XCodePointMapData16.d.ts | 66 + .../js/include/ICU4XCodePointMapData16.js | 57 + .../js/include/ICU4XCodePointMapData8.d.ts | 130 + .../js/include/ICU4XCodePointMapData8.js | 167 + .../js/include/ICU4XCodePointSetData.d.ts | 523 ++ .../js/include/ICU4XCodePointSetData.js | 1177 +++ .../icu_capi/js/include/ICU4XCollator.d.ts | 50 + .../rust/icu_capi/js/include/ICU4XCollator.js | 77 + .../ICU4XCollatorAlternateHandling.d.ts | 16 + .../include/ICU4XCollatorAlternateHandling.js | 20 + .../ICU4XCollatorBackwardSecondLevel.d.ts | 16 + .../ICU4XCollatorBackwardSecondLevel.js | 20 + .../js/include/ICU4XCollatorCaseFirst.d.ts | 19 + .../js/include/ICU4XCollatorCaseFirst.js | 23 + .../js/include/ICU4XCollatorCaseLevel.d.ts | 16 + .../js/include/ICU4XCollatorCaseLevel.js | 20 + .../js/include/ICU4XCollatorMaxVariable.d.ts | 22 + .../js/include/ICU4XCollatorMaxVariable.js | 26 + .../js/include/ICU4XCollatorNumeric.d.ts | 16 + .../js/include/ICU4XCollatorNumeric.js | 20 + .../js/include/ICU4XCollatorOptionsV1.d.ts | 21 + .../js/include/ICU4XCollatorOptionsV1.js | 21 + .../js/include/ICU4XCollatorStrength.d.ts | 25 + .../js/include/ICU4XCollatorStrength.js | 29 + .../js/include/ICU4XComposingNormalizer.d.ts | 49 + .../js/include/ICU4XComposingNormalizer.js | 81 + .../js/include/ICU4XCustomTimeZone.d.ts | 281 + .../js/include/ICU4XCustomTimeZone.js | 327 + .../js/include/ICU4XDataProvider.d.ts | 90 + .../icu_capi/js/include/ICU4XDataProvider.js | 134 + .../icu_capi/js/include/ICU4XDataStruct.d.ts | 23 + .../icu_capi/js/include/ICU4XDataStruct.js | 50 + .../rust/icu_capi/js/include/ICU4XDate.d.ts | 156 + .../rust/icu_capi/js/include/ICU4XDate.js | 161 + .../js/include/ICU4XDateFormatter.d.ts | 67 + .../icu_capi/js/include/ICU4XDateFormatter.js | 112 + .../icu_capi/js/include/ICU4XDateLength.d.ts | 19 + .../icu_capi/js/include/ICU4XDateLength.js | 23 + .../icu_capi/js/include/ICU4XDateTime.d.ts | 212 + .../rust/icu_capi/js/include/ICU4XDateTime.js | 191 + .../js/include/ICU4XDateTimeFormatter.d.ts | 46 + .../js/include/ICU4XDateTimeFormatter.js | 75 + .../icu_capi/js/include/ICU4XDecomposed.d.ts | 12 + .../icu_capi/js/include/ICU4XDecomposed.js | 9 + .../include/ICU4XDecomposingNormalizer.d.ts | 49 + .../js/include/ICU4XDecomposingNormalizer.js | 81 + .../js/include/ICU4XDisplayNamesFallback.d.ts | 13 + .../js/include/ICU4XDisplayNamesFallback.js | 17 + .../include/ICU4XDisplayNamesOptionsV1.d.ts | 13 + .../js/include/ICU4XDisplayNamesOptionsV1.js | 13 + .../js/include/ICU4XDisplayNamesStyle.d.ts | 22 + .../js/include/ICU4XDisplayNamesStyle.js | 26 + .../rust/icu_capi/js/include/ICU4XError.d.ts | 183 + .../rust/icu_capi/js/include/ICU4XError.js | 173 + .../js/include/ICU4XFixedDecimal.d.ts | 272 + .../icu_capi/js/include/ICU4XFixedDecimal.js | 235 + .../include/ICU4XFixedDecimalFormatter.d.ts | 43 + .../js/include/ICU4XFixedDecimalFormatter.js | 72 + .../ICU4XFixedDecimalGroupingStrategy.d.ts | 19 + .../ICU4XFixedDecimalGroupingStrategy.js | 23 + .../js/include/ICU4XFixedDecimalSign.d.ts | 24 + .../js/include/ICU4XFixedDecimalSign.js | 20 + .../include/ICU4XFixedDecimalSignDisplay.d.ts | 24 + .../include/ICU4XFixedDecimalSignDisplay.js | 26 + .../ICU4XGeneralCategoryNameToMaskMapper.d.ts | 38 + .../ICU4XGeneralCategoryNameToMaskMapper.js | 49 + ...U4XGraphemeClusterBreakIteratorLatin1.d.ts | 16 + ...ICU4XGraphemeClusterBreakIteratorLatin1.js | 21 + ...CU4XGraphemeClusterBreakIteratorUtf16.d.ts | 16 + .../ICU4XGraphemeClusterBreakIteratorUtf16.js | 21 + ...ICU4XGraphemeClusterBreakIteratorUtf8.d.ts | 16 + .../ICU4XGraphemeClusterBreakIteratorUtf8.js | 21 + .../ICU4XGraphemeClusterSegmenter.d.ts | 48 + .../include/ICU4XGraphemeClusterSegmenter.js | 53 + .../include/ICU4XGregorianDateFormatter.d.ts | 43 + .../js/include/ICU4XGregorianDateFormatter.js | 74 + .../ICU4XGregorianDateTimeFormatter.d.ts | 34 + .../ICU4XGregorianDateTimeFormatter.js | 56 + .../ICU4XGregorianZonedDateTimeFormatter.d.ts | 49 + .../ICU4XGregorianZonedDateTimeFormatter.js | 79 + .../icu_capi/js/include/ICU4XIsoDate.d.ts | 115 + .../rust/icu_capi/js/include/ICU4XIsoDate.js | 96 + .../icu_capi/js/include/ICU4XIsoDateTime.d.ts | 191 + .../icu_capi/js/include/ICU4XIsoDateTime.js | 134 + .../js/include/ICU4XIsoTimeZoneFormat.d.ts | 19 + .../js/include/ICU4XIsoTimeZoneFormat.js | 23 + .../ICU4XIsoTimeZoneMinuteDisplay.d.ts | 13 + .../include/ICU4XIsoTimeZoneMinuteDisplay.js | 17 + .../js/include/ICU4XIsoTimeZoneOptions.d.ts | 11 + .../js/include/ICU4XIsoTimeZoneOptions.js | 13 + .../ICU4XIsoTimeZoneSecondDisplay.d.ts | 13 + .../include/ICU4XIsoTimeZoneSecondDisplay.js | 17 + .../icu_capi/js/include/ICU4XIsoWeekday.d.ts | 26 + .../icu_capi/js/include/ICU4XIsoWeekday.js | 32 + .../js/include/ICU4XLanguageDisplay.d.ts | 13 + .../js/include/ICU4XLanguageDisplay.js | 17 + .../include/ICU4XLineBreakIteratorLatin1.d.ts | 18 + .../include/ICU4XLineBreakIteratorLatin1.js | 21 + .../include/ICU4XLineBreakIteratorUtf16.d.ts | 18 + .../js/include/ICU4XLineBreakIteratorUtf16.js | 21 + .../include/ICU4XLineBreakIteratorUtf8.d.ts | 18 + .../js/include/ICU4XLineBreakIteratorUtf8.js | 21 + .../js/include/ICU4XLineBreakOptionsV1.d.ts | 12 + .../js/include/ICU4XLineBreakOptionsV1.js | 12 + .../js/include/ICU4XLineBreakStrictness.d.ts | 19 + .../js/include/ICU4XLineBreakStrictness.js | 23 + .../js/include/ICU4XLineBreakWordOption.d.ts | 16 + .../js/include/ICU4XLineBreakWordOption.js | 20 + .../js/include/ICU4XLineSegmenter.d.ts | 94 + .../icu_capi/js/include/ICU4XLineSegmenter.js | 149 + .../rust/icu_capi/js/include/ICU4XList.d.ts | 34 + .../rust/icu_capi/js/include/ICU4XList.js | 35 + .../js/include/ICU4XListFormatter.d.ts | 47 + .../icu_capi/js/include/ICU4XListFormatter.js | 89 + .../icu_capi/js/include/ICU4XListLength.d.ts | 16 + .../icu_capi/js/include/ICU4XListLength.js | 20 + .../rust/icu_capi/js/include/ICU4XLocale.d.ts | 159 + .../rust/icu_capi/js/include/ICU4XLocale.js | 268 + .../js/include/ICU4XLocaleCanonicalizer.d.ts | 40 + .../js/include/ICU4XLocaleCanonicalizer.js | 57 + .../ICU4XLocaleDisplayNamesFormatter.d.ts | 30 + .../ICU4XLocaleDisplayNamesFormatter.js | 60 + .../js/include/ICU4XLocaleExpander.d.ts | 48 + .../js/include/ICU4XLocaleExpander.js | 61 + .../js/include/ICU4XLocaleFallbackConfig.d.ts | 12 + .../js/include/ICU4XLocaleFallbackConfig.js | 13 + .../include/ICU4XLocaleFallbackIterator.d.ts | 26 + .../js/include/ICU4XLocaleFallbackIterator.js | 26 + .../include/ICU4XLocaleFallbackPriority.d.ts | 18 + .../js/include/ICU4XLocaleFallbackPriority.js | 20 + .../js/include/ICU4XLocaleFallbacker.d.ts | 40 + .../js/include/ICU4XLocaleFallbacker.js | 63 + .../ICU4XLocaleFallbackerWithConfig.d.ts | 19 + .../ICU4XLocaleFallbackerWithConfig.js | 22 + .../rust/icu_capi/js/include/ICU4XLogger.d.ts | 13 + .../rust/icu_capi/js/include/ICU4XLogger.js | 21 + .../js/include/ICU4XMetazoneCalculator.d.ts | 21 + .../js/include/ICU4XMetazoneCalculator.js | 35 + .../icu_capi/js/include/ICU4XOrdering.d.ts | 16 + .../rust/icu_capi/js/include/ICU4XOrdering.js | 20 + .../js/include/ICU4XPluralCategories.d.ts | 13 + .../js/include/ICU4XPluralCategories.js | 13 + .../js/include/ICU4XPluralCategory.d.ts | 28 + .../js/include/ICU4XPluralCategory.js | 29 + .../js/include/ICU4XPluralOperands.d.ts | 20 + .../js/include/ICU4XPluralOperands.js | 38 + .../icu_capi/js/include/ICU4XPluralRules.d.ts | 50 + .../icu_capi/js/include/ICU4XPluralRules.js | 68 + .../ICU4XPropertyValueNameToEnumMapper.d.ts | 91 + .../ICU4XPropertyValueNameToEnumMapper.js | 168 + .../js/include/ICU4XRegionDisplayNames.d.ts | 29 + .../js/include/ICU4XRegionDisplayNames.js | 57 + .../js/include/ICU4XReorderedIndexMap.d.ts | 30 + .../js/include/ICU4XReorderedIndexMap.js | 35 + .../js/include/ICU4XScriptExtensionsSet.d.ts | 36 + .../js/include/ICU4XScriptExtensionsSet.js | 42 + .../js/include/ICU4XScriptWithExtensions.d.ts | 54 + .../js/include/ICU4XScriptWithExtensions.js | 53 + .../ICU4XScriptWithExtensionsBorrowed.d.ts | 35 + .../ICU4XScriptWithExtensionsBorrowed.js | 30 + .../js/include/ICU4XSegmenterWordType.d.ts | 16 + .../js/include/ICU4XSegmenterWordType.js | 20 + .../ICU4XSentenceBreakIteratorLatin1.d.ts | 16 + .../ICU4XSentenceBreakIteratorLatin1.js | 21 + .../ICU4XSentenceBreakIteratorUtf16.d.ts | 16 + .../ICU4XSentenceBreakIteratorUtf16.js | 21 + .../ICU4XSentenceBreakIteratorUtf8.d.ts | 16 + .../include/ICU4XSentenceBreakIteratorUtf8.js | 21 + .../js/include/ICU4XSentenceSegmenter.d.ts | 48 + .../js/include/ICU4XSentenceSegmenter.js | 53 + .../rust/icu_capi/js/include/ICU4XTime.d.ts | 53 + .../rust/icu_capi/js/include/ICU4XTime.js | 51 + .../js/include/ICU4XTimeFormatter.d.ts | 53 + .../icu_capi/js/include/ICU4XTimeFormatter.js | 93 + .../icu_capi/js/include/ICU4XTimeLength.d.ts | 19 + .../icu_capi/js/include/ICU4XTimeLength.js | 23 + .../js/include/ICU4XTimeZoneFormatter.d.ts | 115 + .../js/include/ICU4XTimeZoneFormatter.js | 199 + .../js/include/ICU4XTransformResult.d.ts | 15 + .../js/include/ICU4XTransformResult.js | 17 + .../js/include/ICU4XUnicodeSetData.d.ts | 82 + .../js/include/ICU4XUnicodeSetData.js | 135 + .../js/include/ICU4XWeekCalculator.d.ts | 46 + .../js/include/ICU4XWeekCalculator.js | 48 + .../rust/icu_capi/js/include/ICU4XWeekOf.d.ts | 11 + .../rust/icu_capi/js/include/ICU4XWeekOf.js | 10 + .../js/include/ICU4XWeekRelativeUnit.d.ts | 16 + .../js/include/ICU4XWeekRelativeUnit.js | 20 + .../include/ICU4XWordBreakIteratorLatin1.d.ts | 33 + .../include/ICU4XWordBreakIteratorLatin1.js | 30 + .../include/ICU4XWordBreakIteratorUtf16.d.ts | 33 + .../js/include/ICU4XWordBreakIteratorUtf16.js | 30 + .../include/ICU4XWordBreakIteratorUtf8.d.ts | 33 + .../js/include/ICU4XWordBreakIteratorUtf8.js | 30 + .../js/include/ICU4XWordSegmenter.d.ts | 70 + .../icu_capi/js/include/ICU4XWordSegmenter.js | 87 + .../include/ICU4XZonedDateTimeFormatter.d.ts | 59 + .../js/include/ICU4XZonedDateTimeFormatter.js | 98 + .../icu_capi/js/include/diplomat-runtime.d.ts | 20 + .../icu_capi/js/include/diplomat-runtime.js | 121 + .../icu_capi/js/include/diplomat-wasm.mjs | 35 + .../rust/icu_capi/js/include/index.d.ts | 111 + third_party/rust/icu_capi/js/include/index.js | 111 + third_party/rust/icu_capi/src/bidi.rs | 262 + third_party/rust/icu_capi/src/calendar.rs | 122 + third_party/rust/icu_capi/src/collator.rs | 232 + third_party/rust/icu_capi/src/common.rs | 16 + third_party/rust/icu_capi/src/data_struct.rs | 87 + third_party/rust/icu_capi/src/date.rs | 288 + third_party/rust/icu_capi/src/datetime.rs | 408 + .../rust/icu_capi/src/datetime_formatter.rs | 350 + third_party/rust/icu_capi/src/decimal.rs | 108 + third_party/rust/icu_capi/src/displaynames.rs | 147 + third_party/rust/icu_capi/src/errors.rs | 406 + third_party/rust/icu_capi/src/fallbacker.rs | 144 + .../rust/icu_capi/src/fixed_decimal.rs | 319 + third_party/rust/icu_capi/src/lib.rs | 137 + third_party/rust/icu_capi/src/list.rs | 129 + third_party/rust/icu_capi/src/locale.rs | 212 + .../rust/icu_capi/src/locid_transform.rs | 103 + third_party/rust/icu_capi/src/logging.rs | 24 + .../rust/icu_capi/src/metazone_calculator.rs | 31 + third_party/rust/icu_capi/src/normalizer.rs | 152 + .../icu_capi/src/normalizer_properties.rs | 139 + third_party/rust/icu_capi/src/pluralrules.rs | 136 + .../rust/icu_capi/src/properties_iter.rs | 48 + .../rust/icu_capi/src/properties_maps.rs | 263 + .../rust/icu_capi/src/properties_names.rs | 206 + .../rust/icu_capi/src/properties_sets.rs | 698 ++ .../rust/icu_capi/src/properties_unisets.rs | 118 + third_party/rust/icu_capi/src/provider.rs | 327 + third_party/rust/icu_capi/src/script.rs | 137 + .../rust/icu_capi/src/segmenter_grapheme.rs | 163 + .../rust/icu_capi/src/segmenter_line.rs | 333 + .../rust/icu_capi/src/segmenter_sentence.rs | 147 + .../rust/icu_capi/src/segmenter_word.rs | 244 + third_party/rust/icu_capi/src/time.rs | 61 + third_party/rust/icu_capi/src/timezone.rs | 309 + .../rust/icu_capi/src/timezone_formatter.rs | 219 + third_party/rust/icu_capi/src/wasm_glue.rs | 34 + third_party/rust/icu_capi/src/week.rs | 89 + .../rust/icu_capi/src/zoned_formatter.rs | 198 + .../rust/icu_capi/tests/missing_apis.txt | 37 + .../rust/icu_collections/.cargo-checksum.json | 1 + third_party/rust/icu_collections/Cargo.lock | 751 ++ third_party/rust/icu_collections/Cargo.toml | 123 + third_party/rust/icu_collections/LICENSE | 51 + third_party/rust/icu_collections/README.md | 23 + .../icu_collections/src/char16trie/LICENSE | 51 + .../icu_collections/src/char16trie/README.md | 40 + .../icu_collections/src/char16trie/mod.rs | 45 + .../src/char16trie/tests/test_util.rs | 38 + .../src/char16trie/tests/testdata/empty.toml | 11 + .../src/char16trie/tests/testdata/months.toml | 19 + .../src/char16trie/tests/testdata/test_a.toml | 11 + .../char16trie/tests/testdata/test_a_ab.toml | 11 + .../tests/testdata/test_branches.toml | 15 + .../tests/testdata/test_compact.toml | 16 + .../tests/testdata/test_long_branch.toml | 28 + .../tests/testdata/test_long_sequence.toml | 32 + .../tests/testdata/test_shortest_branch.toml | 11 + .../src/char16trie/tests/trie_tests.rs | 266 + .../icu_collections/src/char16trie/trie.rs | 492 ++ .../src/codepointinvlist/LICENSE | 51 + .../src/codepointinvlist/README.md | 49 + .../src/codepointinvlist/benches/inv_list.rs | 70 + .../src/codepointinvlist/builder.rs | 955 ++ .../src/codepointinvlist/conversions.rs | 186 + .../src/codepointinvlist/cpinvlist.rs | 1008 +++ .../examples/unicode_bmp_blocks_selector.rs | 87 + .../src/codepointinvlist/mod.rs | 88 + .../src/codepointinvlist/utils.rs | 110 + .../src/codepointinvliststringlist/mod.rs | 367 + .../icu_collections/src/codepointtrie/LICENSE | 51 + .../src/codepointtrie/README.md | 32 + .../codepointtrie/benches/codepointtrie.rs | 97 + .../src/codepointtrie/benches/iai_cpt.rs | 77 + .../codepointtrie/benches/tries/gc_fast.rs | 1123 +++ .../codepointtrie/benches/tries/gc_small.rs | 860 ++ .../src/codepointtrie/benches/tries/mod.rs | 7 + .../src/codepointtrie/cptrie.rs | 1282 +++ .../src/codepointtrie/error.rs | 26 + .../src/codepointtrie/impl_const.rs | 76 + .../icu_collections/src/codepointtrie/mod.rs | 54 + .../src/codepointtrie/planes.rs | 294 + .../src/codepointtrie/serde.rs | 52 + .../src/codepointtrie/tests/planes_test.rs | 83 + .../src/codepointtrie/tests/test_util.rs | 292 + .../tests/testdata/free-blocks.16.toml | 113 + .../tests/testdata/free-blocks.32.toml | 113 + .../tests/testdata/free-blocks.8.toml | 113 + .../tests/testdata/free-blocks.small16.toml | 53 + .../tests/testdata/grow-data.16.toml | 117 + .../tests/testdata/grow-data.32.toml | 113 + .../tests/testdata/grow-data.8.toml | 113 + .../tests/testdata/grow-data.small16.toml | 53 + .../codepointtrie/tests/testdata/planes.toml | 140 + .../tests/testdata/set-empty.16.toml | 101 + .../tests/testdata/set-empty.32.toml | 101 + .../tests/testdata/set-empty.8.toml | 101 + .../tests/testdata/set-empty.small16.toml | 41 + .../tests/testdata/set-single-value.16.toml | 101 + .../tests/testdata/set-single-value.32.toml | 101 + .../tests/testdata/set-single-value.8.toml | 101 + .../testdata/set-single-value.small16.toml | 41 + .../codepointtrie/tests/testdata/set1.16.toml | 138 + .../codepointtrie/tests/testdata/set1.32.toml | 138 + .../codepointtrie/tests/testdata/set1.8.toml | 138 + .../tests/testdata/set1.small16.toml | 81 + .../tests/testdata/set2-overlap.16.toml | 128 + .../tests/testdata/set2-overlap.32.toml | 128 + .../tests/testdata/set2-overlap.small16.toml | 73 + .../tests/testdata/set3-initial-9.16.toml | 128 + .../tests/testdata/set3-initial-9.32.toml | 128 + .../tests/testdata/set3-initial-9.8.toml | 128 + .../testdata/set3-initial-9.small16.toml | 72 + .../tests/testdata/short-all-same.16.toml | 321 + .../tests/testdata/short-all-same.8.toml | 385 + .../testdata/short-all-same.small16.toml | 321 + .../tests/testdata/small0-in-fast.16.toml | 116 + .../tests/testdata/small0-in-fast.32.toml | 116 + .../tests/testdata/small0-in-fast.8.toml | 116 + .../testdata/small0-in-fast.small16.toml | 63 + .../tests/trie_test_data_test.rs | 43 + .../icu_collections/src/codepointtrie/toml.rs | 124 + .../icu_collections/src/iterator_utils.rs | 260 + third_party/rust/icu_collections/src/lib.rs | 43 + .../rust/icu_locid/.cargo-checksum.json | 1 + third_party/rust/icu_locid/Cargo.lock | 716 ++ third_party/rust/icu_locid/Cargo.toml | 127 + third_party/rust/icu_locid/LICENSE | 51 + third_party/rust/icu_locid/README.md | 48 + .../icu_locid/benches/fixtures/langid.json | 48 + .../icu_locid/benches/fixtures/locale.json | 26 + .../rust/icu_locid/benches/fixtures/mod.rs | 25 + .../icu_locid/benches/fixtures/subtags.json | 18 + .../rust/icu_locid/benches/helpers/macros.rs | 110 + .../rust/icu_locid/benches/helpers/mod.rs | 17 + .../rust/icu_locid/benches/iai_langid.rs | 126 + third_party/rust/icu_locid/benches/langid.rs | 93 + third_party/rust/icu_locid/benches/locale.rs | 87 + third_party/rust/icu_locid/benches/subtags.rs | 39 + .../rust/icu_locid/examples/filter_langids.rs | 69 + .../syntatically_canonicalize_locales.rs | 54 + third_party/rust/icu_locid/src/databake.rs | 23 + .../rust/icu_locid/src/extensions/mod.rs | 324 + .../icu_locid/src/extensions/other/mod.rs | 180 + .../icu_locid/src/extensions/other/subtag.rs | 35 + .../icu_locid/src/extensions/private/mod.rs | 169 + .../icu_locid/src/extensions/private/other.rs | 31 + .../src/extensions/transform/fields.rs | 226 + .../icu_locid/src/extensions/transform/key.rs | 31 + .../icu_locid/src/extensions/transform/mod.rs | 236 + .../src/extensions/transform/value.rs | 130 + .../src/extensions/unicode/attribute.rs | 34 + .../src/extensions/unicode/attributes.rs | 116 + .../icu_locid/src/extensions/unicode/key.rs | 31 + .../src/extensions/unicode/keywords.rs | 405 + .../icu_locid/src/extensions/unicode/mod.rs | 239 + .../icu_locid/src/extensions/unicode/value.rs | 198 + third_party/rust/icu_locid/src/helpers.rs | 653 ++ third_party/rust/icu_locid/src/langid.rs | 506 ++ third_party/rust/icu_locid/src/lib.rs | 91 + third_party/rust/icu_locid/src/locale.rs | 509 ++ third_party/rust/icu_locid/src/macros.rs | 191 + third_party/rust/icu_locid/src/ordering.rs | 62 + .../rust/icu_locid/src/parser/errors.rs | 72 + .../rust/icu_locid/src/parser/langid.rs | 278 + .../rust/icu_locid/src/parser/locale.rs | 42 + third_party/rust/icu_locid/src/parser/mod.rs | 231 + third_party/rust/icu_locid/src/serde.rs | 135 + .../rust/icu_locid/src/subtags/language.rs | 106 + third_party/rust/icu_locid/src/subtags/mod.rs | 58 + .../rust/icu_locid/src/subtags/region.rs | 61 + .../rust/icu_locid/src/subtags/script.rs | 32 + .../rust/icu_locid/src/subtags/variant.rs | 34 + .../rust/icu_locid/src/subtags/variants.rs | 124 + third_party/rust/icu_locid/src/zerovec.rs | 132 + .../tests/fixtures/canonicalize.json | 18 + .../tests/fixtures/invalid-extensions.json | 152 + .../icu_locid/tests/fixtures/invalid.json | 134 + .../rust/icu_locid/tests/fixtures/langid.json | 167 + .../rust/icu_locid/tests/fixtures/locale.json | 298 + .../rust/icu_locid/tests/fixtures/mod.rs | 261 + .../rust/icu_locid/tests/helpers/mod.rs | 15 + third_party/rust/icu_locid/tests/langid.rs | 158 + third_party/rust/icu_locid/tests/locale.rs | 120 + .../rust/icu_provider/.cargo-checksum.json | 1 + third_party/rust/icu_provider/Cargo.toml | 138 + third_party/rust/icu_provider/LICENSE | 51 + third_party/rust/icu_provider/README.md | 122 + third_party/rust/icu_provider/src/any.rs | 491 ++ third_party/rust/icu_provider/src/buf.rs | 136 + .../rust/icu_provider/src/constructors.rs | 101 + .../rust/icu_provider/src/data_provider.rs | 331 + .../src/datagen/data_conversion.rs | 48 + .../rust/icu_provider/src/datagen/iter.rs | 35 + .../rust/icu_provider/src/datagen/mod.rs | 99 + .../rust/icu_provider/src/datagen/payload.rs | 146 + third_party/rust/icu_provider/src/dynutil.rs | 263 + third_party/rust/icu_provider/src/error.rs | 284 + .../rust/icu_provider/src/hello_world.rs | 316 + third_party/rust/icu_provider/src/helpers.rs | 309 + third_party/rust/icu_provider/src/key.rs | 654 ++ third_party/rust/icu_provider/src/lib.rs | 259 + third_party/rust/icu_provider/src/marker.rs | 86 + third_party/rust/icu_provider/src/request.rs | 514 ++ third_party/rust/icu_provider/src/response.rs | 635 ++ .../icu_provider/src/serde/borrow_de_utils.rs | 82 + .../rust/icu_provider/src/serde/mod.rs | 188 + .../.cargo-checksum.json | 1 + .../rust/icu_provider_adapters/Cargo.toml | 85 + .../rust/icu_provider_adapters/LICENSE | 51 + .../rust/icu_provider_adapters/README.md | 12 + .../icu_provider_adapters/src/any_payload.rs | 124 + .../rust/icu_provider_adapters/src/either.rs | 112 + .../rust/icu_provider_adapters/src/empty.rs | 112 + .../src/fallback/adapter.rs | 284 + .../src/fallback/algorithms.rs | 439 + .../icu_provider_adapters/src/fallback/mod.rs | 422 + .../src/fallback/provider.rs | 111 + .../icu_provider_adapters/src/filter/impls.rs | 216 + .../icu_provider_adapters/src/filter/mod.rs | 243 + .../src/fork/by_error.rs | 309 + .../icu_provider_adapters/src/fork/macros.rs | 71 + .../icu_provider_adapters/src/fork/mod.rs | 226 + .../src/fork/predicates.rs | 138 + .../rust/icu_provider_adapters/src/helpers.rs | 15 + .../rust/icu_provider_adapters/src/lib.rs | 36 + .../langtest/de/core/helloworld@1/de.json | 1 + .../tests/data/langtest/de/manifest.json | 3 + .../langtest/ro/core/helloworld@1/ro.json | 1 + .../tests/data/langtest/ro/manifest.json | 3 + .../icu_provider_macros/.cargo-checksum.json | 1 + .../rust/icu_provider_macros/Cargo.toml | 46 + third_party/rust/icu_provider_macros/LICENSE | 51 + .../rust/icu_provider_macros/README.md | 9 + .../rust/icu_provider_macros/src/lib.rs | 268 + .../rust/icu_provider_macros/src/tests.rs | 211 + .../rust/icu_segmenter/.cargo-checksum.json | 1 + third_party/rust/icu_segmenter/Cargo.toml | 123 + third_party/rust/icu_segmenter/LICENSE | 51 + third_party/rust/icu_segmenter/README.md | 110 + .../rust/icu_segmenter/benches/bench.rs | 158 + third_party/rust/icu_segmenter/src/complex.rs | 331 + .../rust/icu_segmenter/src/dictionary.rs | 306 + third_party/rust/icu_segmenter/src/error.rs | 27 + .../rust/icu_segmenter/src/grapheme.rs | 249 + third_party/rust/icu_segmenter/src/indices.rs | 129 + .../icu_segmenter/src/iterator_helpers.rs | 19 + .../rust/icu_segmenter/src/language.rs | 161 + third_party/rust/icu_segmenter/src/lib.rs | 189 + third_party/rust/icu_segmenter/src/line.rs | 1580 ++++ third_party/rust/icu_segmenter/src/lstm.rs | 393 + .../rust/icu_segmenter/src/math_helper.rs | 524 ++ .../rust/icu_segmenter/src/provider/lstm.rs | 366 + .../rust/icu_segmenter/src/provider/mod.rs | 162 + .../rust/icu_segmenter/src/rule_segmenter.rs | 355 + .../rust/icu_segmenter/src/sentence.rs | 197 + third_party/rust/icu_segmenter/src/symbols.rs | 141 + third_party/rust/icu_segmenter/src/word.rs | 559 ++ .../rust/icu_segmenter/tests/complex_word.rs | 165 + .../icu_segmenter/tests/css_line_break.rs | 317 + .../icu_segmenter/tests/css_word_break.rs | 199 + .../rust/icu_segmenter/tests/spec_test.rs | 246 + .../tests/testdata/GraphemeBreakTest.txt | 630 ++ .../tests/testdata/LineBreakTest.txt | 7686 +++++++++++++++++ .../tests/testdata/SentenceBreakExtraTest.txt | 8 + .../tests/testdata/SentenceBreakTest.txt | 530 ++ .../tests/testdata/WordBreakTest.txt | 1851 ++++ .../tests/testdata/provider/manifest.json | 3 + .../segmenter/dictionary/w_auto@1/ja.postcard | Bin 0 -> 2003393 bytes .../segmenter/dictionary/wl_ext@1/km.postcard | Bin 0 -> 798377 bytes .../segmenter/dictionary/wl_ext@1/lo.postcard | Bin 0 -> 292459 bytes .../segmenter/dictionary/wl_ext@1/my.postcard | Bin 0 -> 457267 bytes .../segmenter/dictionary/wl_ext@1/th.postcard | Bin 0 -> 224981 bytes .../segmenter/lstm/wl_auto@1/km.postcard | Bin 0 -> 74372 bytes .../segmenter/lstm/wl_auto@1/lo.postcard | Bin 0 -> 71867 bytes .../segmenter/lstm/wl_auto@1/my.postcard | Bin 0 -> 91074 bytes .../segmenter/lstm/wl_auto@1/th.postcard | Bin 0 -> 72034 bytes .../tests/testdata/test_text_codepoints.json | 32 + .../tests/testdata/test_text_graphclust.json | 32 + .../icu_segmenter/tests/word_rule_status.rs | 73 + third_party/rust/libm/.cargo-checksum.json | 1 + third_party/rust/libm/CHANGELOG.md | 123 + third_party/rust/libm/CONTRIBUTING.md | 95 + third_party/rust/libm/Cargo.toml | 41 + third_party/rust/libm/LICENSE-APACHE | 201 + third_party/rust/libm/LICENSE-MIT | 25 + third_party/rust/libm/README.md | 51 + third_party/rust/libm/build.rs | 463 + .../aarch64-unknown-linux-gnu/Dockerfile | 10 + .../arm-unknown-linux-gnueabi/Dockerfile | 9 + .../arm-unknown-linux-gnueabihf/Dockerfile | 9 + .../armv7-unknown-linux-gnueabihf/Dockerfile | 9 + .../docker/i686-unknown-linux-gnu/Dockerfile | 4 + .../docker/mips-unknown-linux-gnu/Dockerfile | 12 + .../mips64-unknown-linux-gnuabi64/Dockerfile | 15 + .../Dockerfile | 14 + .../mipsel-unknown-linux-gnu/Dockerfile | 12 + .../powerpc-unknown-linux-gnu/Dockerfile | 12 + .../powerpc64-unknown-linux-gnu/Dockerfile | 13 + .../powerpc64le-unknown-linux-gnu/Dockerfile | 13 + .../x86_64-unknown-linux-gnu/Dockerfile | 4 + third_party/rust/libm/ci/run-docker.sh | 37 + third_party/rust/libm/ci/run.sh | 21 + third_party/rust/libm/src/lib.rs | 57 + third_party/rust/libm/src/math/acos.rs | 112 + third_party/rust/libm/src/math/acosf.rs | 79 + third_party/rust/libm/src/math/acosh.rs | 27 + third_party/rust/libm/src/math/acoshf.rs | 26 + third_party/rust/libm/src/math/asin.rs | 119 + third_party/rust/libm/src/math/asinf.rs | 72 + third_party/rust/libm/src/math/asinh.rs | 40 + third_party/rust/libm/src/math/asinhf.rs | 39 + third_party/rust/libm/src/math/atan.rs | 184 + third_party/rust/libm/src/math/atan2.rs | 126 + third_party/rust/libm/src/math/atan2f.rs | 91 + third_party/rust/libm/src/math/atanf.rs | 112 + third_party/rust/libm/src/math/atanh.rs | 37 + third_party/rust/libm/src/math/atanhf.rs | 37 + third_party/rust/libm/src/math/cbrt.rs | 113 + third_party/rust/libm/src/math/cbrtf.rs | 75 + third_party/rust/libm/src/math/ceil.rs | 82 + third_party/rust/libm/src/math/ceilf.rs | 65 + third_party/rust/libm/src/math/copysign.rs | 12 + third_party/rust/libm/src/math/copysignf.rs | 12 + third_party/rust/libm/src/math/cos.rs | 73 + third_party/rust/libm/src/math/cosf.rs | 83 + third_party/rust/libm/src/math/cosh.rs | 38 + third_party/rust/libm/src/math/coshf.rs | 38 + third_party/rust/libm/src/math/erf.rs | 318 + third_party/rust/libm/src/math/erff.rs | 230 + third_party/rust/libm/src/math/exp.rs | 154 + third_party/rust/libm/src/math/exp10.rs | 22 + third_party/rust/libm/src/math/exp10f.rs | 22 + third_party/rust/libm/src/math/exp2.rs | 394 + third_party/rust/libm/src/math/exp2f.rs | 135 + third_party/rust/libm/src/math/expf.rs | 101 + third_party/rust/libm/src/math/expm1.rs | 144 + third_party/rust/libm/src/math/expm1f.rs | 134 + third_party/rust/libm/src/math/expo2.rs | 14 + third_party/rust/libm/src/math/fabs.rs | 41 + third_party/rust/libm/src/math/fabsf.rs | 41 + third_party/rust/libm/src/math/fdim.rs | 22 + third_party/rust/libm/src/math/fdimf.rs | 22 + third_party/rust/libm/src/math/fenv.rs | 27 + third_party/rust/libm/src/math/floor.rs | 81 + third_party/rust/libm/src/math/floorf.rs | 66 + third_party/rust/libm/src/math/fma.rs | 243 + third_party/rust/libm/src/math/fmaf.rs | 117 + third_party/rust/libm/src/math/fmax.rs | 12 + third_party/rust/libm/src/math/fmaxf.rs | 12 + third_party/rust/libm/src/math/fmin.rs | 12 + third_party/rust/libm/src/math/fminf.rs | 12 + third_party/rust/libm/src/math/fmod.rs | 80 + third_party/rust/libm/src/math/fmodf.rs | 89 + third_party/rust/libm/src/math/frexp.rs | 20 + third_party/rust/libm/src/math/frexpf.rs | 21 + third_party/rust/libm/src/math/hypot.rs | 74 + third_party/rust/libm/src/math/hypotf.rs | 43 + third_party/rust/libm/src/math/ilogb.rs | 32 + third_party/rust/libm/src/math/ilogbf.rs | 32 + third_party/rust/libm/src/math/j0.rs | 422 + third_party/rust/libm/src/math/j0f.rs | 359 + third_party/rust/libm/src/math/j1.rs | 414 + third_party/rust/libm/src/math/j1f.rs | 380 + third_party/rust/libm/src/math/jn.rs | 343 + third_party/rust/libm/src/math/jnf.rs | 259 + third_party/rust/libm/src/math/k_cos.rs | 62 + third_party/rust/libm/src/math/k_cosf.rs | 29 + third_party/rust/libm/src/math/k_expo2.rs | 14 + third_party/rust/libm/src/math/k_expo2f.rs | 14 + third_party/rust/libm/src/math/k_sin.rs | 57 + third_party/rust/libm/src/math/k_sinf.rs | 30 + third_party/rust/libm/src/math/k_tan.rs | 105 + third_party/rust/libm/src/math/k_tanf.rs | 46 + third_party/rust/libm/src/math/ldexp.rs | 4 + third_party/rust/libm/src/math/ldexpf.rs | 4 + third_party/rust/libm/src/math/lgamma.rs | 6 + third_party/rust/libm/src/math/lgamma_r.rs | 320 + third_party/rust/libm/src/math/lgammaf.rs | 6 + third_party/rust/libm/src/math/lgammaf_r.rs | 255 + third_party/rust/libm/src/math/log.rs | 117 + third_party/rust/libm/src/math/log10.rs | 117 + third_party/rust/libm/src/math/log10f.rs | 91 + third_party/rust/libm/src/math/log1p.rs | 143 + third_party/rust/libm/src/math/log1pf.rs | 98 + third_party/rust/libm/src/math/log2.rs | 106 + third_party/rust/libm/src/math/log2f.rs | 87 + third_party/rust/libm/src/math/logf.rs | 65 + third_party/rust/libm/src/math/mod.rs | 370 + third_party/rust/libm/src/math/modf.rs | 34 + third_party/rust/libm/src/math/modff.rs | 33 + third_party/rust/libm/src/math/nextafter.rs | 37 + third_party/rust/libm/src/math/nextafterf.rs | 37 + third_party/rust/libm/src/math/pow.rs | 637 ++ third_party/rust/libm/src/math/powf.rs | 342 + third_party/rust/libm/src/math/rem_pio2.rs | 233 + .../rust/libm/src/math/rem_pio2_large.rs | 470 + third_party/rust/libm/src/math/rem_pio2f.rs | 67 + third_party/rust/libm/src/math/remainder.rs | 5 + third_party/rust/libm/src/math/remainderf.rs | 5 + third_party/rust/libm/src/math/remquo.rs | 110 + third_party/rust/libm/src/math/remquof.rs | 97 + third_party/rust/libm/src/math/rint.rs | 48 + third_party/rust/libm/src/math/rintf.rs | 48 + third_party/rust/libm/src/math/round.rs | 28 + third_party/rust/libm/src/math/roundf.rs | 30 + third_party/rust/libm/src/math/scalbn.rs | 33 + third_party/rust/libm/src/math/scalbnf.rs | 29 + third_party/rust/libm/src/math/sin.rs | 88 + third_party/rust/libm/src/math/sincos.rs | 134 + third_party/rust/libm/src/math/sincosf.rs | 185 + third_party/rust/libm/src/math/sinf.rs | 93 + third_party/rust/libm/src/math/sinh.rs | 49 + third_party/rust/libm/src/math/sinhf.rs | 30 + third_party/rust/libm/src/math/sqrt.rs | 264 + third_party/rust/libm/src/math/sqrtf.rs | 154 + third_party/rust/libm/src/math/tan.rs | 70 + third_party/rust/libm/src/math/tanf.rs | 78 + third_party/rust/libm/src/math/tanh.rs | 53 + third_party/rust/libm/src/math/tanhf.rs | 39 + third_party/rust/libm/src/math/tgamma.rs | 208 + third_party/rust/libm/src/math/tgammaf.rs | 6 + third_party/rust/libm/src/math/trunc.rs | 40 + third_party/rust/libm/src/math/truncf.rs | 42 + third_party/rust/litemap/.cargo-checksum.json | 1 + third_party/rust/litemap/Cargo.lock | 814 ++ third_party/rust/litemap/Cargo.toml | 110 + third_party/rust/litemap/LICENSE | 51 + third_party/rust/litemap/README.md | 26 + .../litemap/benches/bin/litemap_bincode.rs | 66 + .../litemap/benches/bin/litemap_postcard.rs | 60 + third_party/rust/litemap/benches/litemap.rs | 134 + .../benches/testdata/large_litemap.postcard | 1 + .../examples/language_names_hash_map.rs | 47 + .../examples/language_names_lite_map.rs | 47 + third_party/rust/litemap/src/lib.rs | 57 + third_party/rust/litemap/src/map.rs | 658 ++ third_party/rust/litemap/src/serde.rs | 214 + third_party/rust/litemap/src/serde_helpers.rs | 168 + third_party/rust/litemap/src/store/mod.rs | 171 + .../rust/litemap/src/store/slice_impl.rs | 55 + .../rust/litemap/src/store/vec_impl.rs | 173 + third_party/rust/litemap/src/testing.rs | 240 + third_party/rust/litemap/tests/rkyv.rs | 83 + third_party/rust/litemap/tests/serde.rs | 22 + third_party/rust/litemap/tests/store.rs | 139 + third_party/rust/strck/.cargo-checksum.json | 1 + third_party/rust/strck/Cargo.toml | 47 + third_party/rust/strck/LICENSE | 8 + third_party/rust/strck/README.md | 103 + third_party/rust/strck/src/lib.rs | 508 ++ third_party/rust/strck/src/partial_eq.rs | 94 + third_party/rust/strck/src/serde.rs | 78 + .../rust/strck_ident/.cargo-checksum.json | 1 + third_party/rust/strck_ident/Cargo.toml | 46 + third_party/rust/strck_ident/LICENSE | 8 + third_party/rust/strck_ident/README.md | 26 + third_party/rust/strck_ident/src/lib.rs | 40 + third_party/rust/strck_ident/src/rust.rs | 136 + third_party/rust/strck_ident/src/unicode.rs | 145 + .../rust/unicode-bidi/.cargo-checksum.json | 2 +- third_party/rust/unicode-bidi/Cargo.toml | 7 +- .../rust/unicode-bidi/src/char_data/mod.rs | 18 +- .../rust/unicode-bidi/src/char_data/tables.rs | 311 +- .../rust/unicode-bidi/src/data_source.rs | 30 + .../rust/unicode-bidi/src/deprecated.rs | 4 +- third_party/rust/unicode-bidi/src/explicit.rs | 44 +- third_party/rust/unicode-bidi/src/implicit.rs | 533 +- third_party/rust/unicode-bidi/src/level.rs | 15 + third_party/rust/unicode-bidi/src/lib.rs | 156 +- third_party/rust/unicode-bidi/src/prepare.rs | 102 +- .../rust/utf8_iter/.cargo-checksum.json | 1 + third_party/rust/utf8_iter/COPYRIGHT | 42 + third_party/rust/utf8_iter/Cargo.toml | 34 + third_party/rust/utf8_iter/LICENSE-APACHE | 202 + third_party/rust/utf8_iter/LICENSE-MIT | 25 + third_party/rust/utf8_iter/README.md | 46 + third_party/rust/utf8_iter/src/indices.rs | 120 + third_party/rust/utf8_iter/src/lib.rs | 273 + .../rust/writeable/.cargo-checksum.json | 1 + third_party/rust/writeable/Cargo.lock | 649 ++ third_party/rust/writeable/Cargo.toml | 56 + third_party/rust/writeable/LICENSE | 51 + third_party/rust/writeable/README.md | 52 + .../rust/writeable/benches/writeable.rs | 162 + .../writeable/examples/writeable_message.rs | 60 + third_party/rust/writeable/src/impls.rs | 220 + third_party/rust/writeable/src/lib.rs | 438 + third_party/rust/writeable/src/ops.rs | 294 + third_party/rust/writeable/tests/writeable.rs | 34 + .../rust/yoke-derive/.cargo-checksum.json | 1 + third_party/rust/yoke-derive/Cargo.toml | 60 + third_party/rust/yoke-derive/LICENSE | 51 + third_party/rust/yoke-derive/README.md | 7 + .../rust/yoke-derive/examples/yoke_derive.rs | 86 + third_party/rust/yoke-derive/src/lib.rs | 273 + third_party/rust/yoke-derive/src/visitor.rs | 113 + third_party/rust/yoke/.cargo-checksum.json | 1 + third_party/rust/yoke/Cargo.toml | 86 + third_party/rust/yoke/LICENSE | 51 + third_party/rust/yoke/README.md | 27 + third_party/rust/yoke/src/either.rs | 87 + third_party/rust/yoke/src/erased.rs | 41 + third_party/rust/yoke/src/lib.rs | 65 + third_party/rust/yoke/src/macro_impls.rs | 108 + third_party/rust/yoke/src/trait_hack.rs | 318 + third_party/rust/yoke/src/yoke.rs | 1314 +++ third_party/rust/yoke/src/yokeable.rs | 325 + third_party/rust/yoke/src/zero_from.rs | 57 + .../rust/zerofrom-derive/.cargo-checksum.json | 1 + third_party/rust/zerofrom-derive/Cargo.toml | 60 + third_party/rust/zerofrom-derive/LICENSE | 51 + third_party/rust/zerofrom-derive/README.md | 7 + .../zerofrom-derive/examples/zf_derive.rs | 89 + third_party/rust/zerofrom-derive/src/lib.rs | 175 + .../rust/zerofrom-derive/src/visitor.rs | 114 + .../rust/zerofrom/.cargo-checksum.json | 1 + third_party/rust/zerofrom/Cargo.toml | 54 + third_party/rust/zerofrom/LICENSE | 51 + third_party/rust/zerofrom/README.md | 9 + third_party/rust/zerofrom/src/lib.rs | 36 + third_party/rust/zerofrom/src/macro_impls.rs | 145 + third_party/rust/zerofrom/src/zero_from.rs | 128 + .../rust/zerovec-derive/.cargo-checksum.json | 1 + third_party/rust/zerovec-derive/Cargo.toml | 71 + third_party/rust/zerovec-derive/LICENSE | 51 + third_party/rust/zerovec-derive/README.md | 7 + .../rust/zerovec-derive/examples/derives.rs | 157 + .../rust/zerovec-derive/examples/make.rs | 116 + .../rust/zerovec-derive/examples/make_var.rs | 189 + third_party/rust/zerovec-derive/src/lib.rs | 43 + .../rust/zerovec-derive/src/make_ule.rs | 348 + .../rust/zerovec-derive/src/make_varule.rs | 729 ++ third_party/rust/zerovec-derive/src/ule.rs | 107 + third_party/rust/zerovec-derive/src/utils.rs | 275 + third_party/rust/zerovec-derive/src/varule.rs | 130 + third_party/rust/zerovec/.cargo-checksum.json | 1 + third_party/rust/zerovec/Cargo.lock | 840 ++ third_party/rust/zerovec/Cargo.toml | 145 + third_party/rust/zerovec/LICENSE | 51 + third_party/rust/zerovec/README.md | 193 + .../benches/testdata/large_hashmap.postcard | 1 + .../testdata/large_zerohashmap.postcard | Bin 0 -> 3775153 bytes .../benches/testdata/large_zeromap.postcard | Bin 0 -> 2726574 bytes third_party/rust/zerovec/benches/vzv.rs | 212 + third_party/rust/zerovec/benches/zeromap.rs | 407 + third_party/rust/zerovec/benches/zerovec.rs | 165 + .../rust/zerovec/benches/zerovec_iai.rs | 65 + .../rust/zerovec/benches/zerovec_serde.rs | 145 + third_party/rust/zerovec/examples/zv_serde.rs | 51 + third_party/rust/zerovec/src/error.rs | 55 + .../rust/zerovec/src/flexzerovec/databake.rs | 66 + .../rust/zerovec/src/flexzerovec/mod.rs | 20 + .../rust/zerovec/src/flexzerovec/owned.rs | 335 + .../rust/zerovec/src/flexzerovec/serde.rs | 175 + .../rust/zerovec/src/flexzerovec/slice.rs | 723 ++ .../rust/zerovec/src/flexzerovec/vec.rs | 275 + .../rust/zerovec/src/hashmap/algorithms.rs | 162 + third_party/rust/zerovec/src/hashmap/mod.rs | 238 + third_party/rust/zerovec/src/hashmap/serde.rs | 147 + third_party/rust/zerovec/src/lib.rs | 519 ++ third_party/rust/zerovec/src/map/borrowed.rs | 322 + third_party/rust/zerovec/src/map/databake.rs | 82 + third_party/rust/zerovec/src/map/kv.rs | 131 + third_party/rust/zerovec/src/map/map.rs | 567 ++ third_party/rust/zerovec/src/map/mod.rs | 23 + third_party/rust/zerovec/src/map/serde.rs | 313 + .../rust/zerovec/src/map/serde_helpers.rs | 168 + third_party/rust/zerovec/src/map/vecs.rs | 724 ++ .../rust/zerovec/src/map2d/borrowed.rs | 344 + third_party/rust/zerovec/src/map2d/cursor.rs | 358 + .../rust/zerovec/src/map2d/databake.rs | 110 + third_party/rust/zerovec/src/map2d/map.rs | 827 ++ third_party/rust/zerovec/src/map2d/mod.rs | 18 + third_party/rust/zerovec/src/map2d/serde.rs | 430 + third_party/rust/zerovec/src/samples.rs | 52 + third_party/rust/zerovec/src/ule/chars.rs | 157 + third_party/rust/zerovec/src/ule/custom.rs | 145 + third_party/rust/zerovec/src/ule/encode.rs | 402 + third_party/rust/zerovec/src/ule/mod.rs | 394 + third_party/rust/zerovec/src/ule/multi.rs | 152 + third_party/rust/zerovec/src/ule/niche.rs | 180 + third_party/rust/zerovec/src/ule/option.rs | 265 + third_party/rust/zerovec/src/ule/plain.rs | 347 + third_party/rust/zerovec/src/ule/slices.rs | 103 + third_party/rust/zerovec/src/ule/tuple.rs | 182 + .../rust/zerovec/src/ule/unvalidated.rs | 211 + .../rust/zerovec/src/varzerovec/components.rs | 579 ++ .../rust/zerovec/src/varzerovec/databake.rs | 68 + .../rust/zerovec/src/varzerovec/mod.rs | 26 + .../rust/zerovec/src/varzerovec/owned.rs | 656 ++ .../rust/zerovec/src/varzerovec/serde.rs | 246 + .../rust/zerovec/src/varzerovec/slice.rs | 573 ++ .../rust/zerovec/src/varzerovec/vec.rs | 505 ++ third_party/rust/zerovec/src/yoke_impls.rs | 550 ++ .../rust/zerovec/src/zerofrom_impls.rs | 124 + .../rust/zerovec/src/zerovec/databake.rs | 69 + third_party/rust/zerovec/src/zerovec/mod.rs | 1004 +++ third_party/rust/zerovec/src/zerovec/serde.rs | 221 + third_party/rust/zerovec/src/zerovec/slice.rs | 599 ++ 1384 files changed, 151216 insertions(+), 269 deletions(-) create mode 100644 third_party/rust/diplomat-runtime/.cargo-checksum.json create mode 100644 third_party/rust/diplomat-runtime/Cargo.toml create mode 100644 third_party/rust/diplomat-runtime/LICENSE-APACHE create mode 100644 third_party/rust/diplomat-runtime/LICENSE-MIT create mode 100644 third_party/rust/diplomat-runtime/src/lib.rs create mode 100644 third_party/rust/diplomat-runtime/src/result.rs create mode 100644 third_party/rust/diplomat-runtime/src/wasm_glue.rs create mode 100644 third_party/rust/diplomat-runtime/src/writeable.rs create mode 100644 third_party/rust/diplomat/.cargo-checksum.json create mode 100644 third_party/rust/diplomat/Cargo.toml create mode 100644 third_party/rust/diplomat/LICENSE-APACHE create mode 100644 third_party/rust/diplomat/LICENSE-MIT create mode 100644 third_party/rust/diplomat/src/enum_convert.rs create mode 100644 third_party/rust/diplomat/src/lib.rs create mode 100644 third_party/rust/diplomat/src/snapshots/diplomat__tests__cfgd_struct.snap create mode 100644 third_party/rust/diplomat/src/snapshots/diplomat__tests__cfged_method-2.snap create mode 100644 third_party/rust/diplomat/src/snapshots/diplomat__tests__cfged_method.snap create mode 100644 third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_mutable_slice.snap create mode 100644 third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_mutable_str.snap create mode 100644 third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_slice.snap create mode 100644 third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_str.snap create mode 100644 third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_enum.snap create mode 100644 third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_rust_result.snap create mode 100644 third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_writeable_result.snap create mode 100644 third_party/rust/diplomat/src/snapshots/diplomat__tests__multilevel_borrows.snap create mode 100644 third_party/rust/diplomat/src/snapshots/diplomat__tests__self_params.snap create mode 100644 third_party/rust/diplomat/src/transparent_convert.rs create mode 100644 third_party/rust/diplomat_core/.cargo-checksum.json create mode 100644 third_party/rust/diplomat_core/Cargo.toml create mode 100644 third_party/rust/diplomat_core/LICENSE-APACHE create mode 100644 third_party/rust/diplomat_core/LICENSE-MIT create mode 100644 third_party/rust/diplomat_core/src/ast/attrs.rs create mode 100644 third_party/rust/diplomat_core/src/ast/docs.rs create mode 100644 third_party/rust/diplomat_core/src/ast/enums.rs create mode 100644 third_party/rust/diplomat_core/src/ast/idents.rs create mode 100644 third_party/rust/diplomat_core/src/ast/lifetimes.rs create mode 100644 third_party/rust/diplomat_core/src/ast/methods.rs create mode 100644 third_party/rust/diplomat_core/src/ast/mod.rs create mode 100644 third_party/rust/diplomat_core/src/ast/modules.rs create mode 100644 third_party/rust/diplomat_core/src/ast/paths.rs create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__enums__tests__enum_with_discr.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__enums__tests__simple_enum.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__cfged_method.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__nonstatic_methods-2.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__nonstatic_methods.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__static_methods-2.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__static_methods.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__modules__tests__import_in_non_diplomat_not_analyzed.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__modules__tests__method_visibility.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__modules__tests__simple_mod.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__structs__tests__simple_struct.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-2.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-3.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-4.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-5.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-6.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-7.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_boxes-2.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_boxes.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_named.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_option-2.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_option.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_primitives-2.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_primitives-3.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_primitives.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_references-2.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_references.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_result-2.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_result-3.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_result-4.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_result.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__non_opaque_move.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__opaque_checks_with_error.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__opaque_checks_with_safe_use.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__opaque_ffi.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__option_invalid.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__option_valid.snap create mode 100644 third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__zst_non_opaque.snap create mode 100644 third_party/rust/diplomat_core/src/ast/structs.rs create mode 100644 third_party/rust/diplomat_core/src/ast/types.rs create mode 100644 third_party/rust/diplomat_core/src/ast/validity.rs create mode 100644 third_party/rust/diplomat_core/src/environment.rs create mode 100644 third_party/rust/diplomat_core/src/hir/defs.rs create mode 100644 third_party/rust/diplomat_core/src/hir/elision.rs create mode 100644 third_party/rust/diplomat_core/src/hir/lifetimes.rs create mode 100644 third_party/rust/diplomat_core/src/hir/lowering.rs create mode 100644 third_party/rust/diplomat_core/src/hir/methods.rs create mode 100644 third_party/rust/diplomat_core/src/hir/mod.rs create mode 100644 third_party/rust/diplomat_core/src/hir/paths.rs create mode 100644 third_party/rust/diplomat_core/src/hir/primitives.rs create mode 100644 third_party/rust/diplomat_core/src/hir/snapshots/diplomat_core__hir__elision__tests__borrowing_fields.snap create mode 100644 third_party/rust/diplomat_core/src/hir/snapshots/diplomat_core__hir__elision__tests__simple_mod.snap create mode 100644 third_party/rust/diplomat_core/src/hir/ty_position.rs create mode 100644 third_party/rust/diplomat_core/src/hir/type_context.rs create mode 100644 third_party/rust/diplomat_core/src/hir/types.rs create mode 100644 third_party/rust/diplomat_core/src/lib.rs create mode 100644 third_party/rust/icu_capi/.cargo-checksum.json create mode 100644 third_party/rust/icu_capi/Cargo.toml create mode 100644 third_party/rust/icu_capi/LICENSE create mode 100644 third_party/rust/icu_capi/README.md create mode 100644 third_party/rust/icu_capi/c/README.md create mode 100644 third_party/rust/icu_capi/c/examples/fixeddecimal_tiny/README.md create mode 100644 third_party/rust/icu_capi/c/include/CodePointRangeIterator.h create mode 100644 third_party/rust/icu_capi/c/include/CodePointRangeIteratorResult.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XAnyCalendarKind.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XBidi.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XBidiDirection.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XBidiInfo.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XBidiParagraph.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XCalendar.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XCanonicalCombiningClassMap.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XCanonicalComposition.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XCanonicalDecomposition.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XCodePointMapData16.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XCodePointMapData8.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XCodePointSetData.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XCollator.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XCollatorAlternateHandling.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XCollatorBackwardSecondLevel.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XCollatorCaseFirst.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XCollatorCaseLevel.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XCollatorMaxVariable.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XCollatorNumeric.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XCollatorOptionsV1.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XCollatorStrength.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XComposingNormalizer.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XCustomTimeZone.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XDataProvider.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XDataStruct.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XDate.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XDateFormatter.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XDateLength.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XDateTime.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XDateTimeFormatter.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XDecomposed.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XDecomposingNormalizer.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XDisplayNamesFallback.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XDisplayNamesOptionsV1.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XDisplayNamesStyle.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XFixedDecimal.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XFixedDecimalFormatter.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XFixedDecimalGroupingStrategy.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XFixedDecimalSign.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XFixedDecimalSignDisplay.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XGeneralCategoryNameToMaskMapper.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XGraphemeClusterBreakIteratorLatin1.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XGraphemeClusterBreakIteratorUtf16.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XGraphemeClusterBreakIteratorUtf8.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XGraphemeClusterSegmenter.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XGregorianDateFormatter.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XGregorianDateTimeFormatter.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XGregorianZonedDateTimeFormatter.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XIsoDate.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XIsoDateTime.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XIsoTimeZoneFormat.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XIsoTimeZoneMinuteDisplay.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XIsoTimeZoneOptions.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XIsoTimeZoneSecondDisplay.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XIsoWeekday.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XLanguageDisplay.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XLineBreakIteratorLatin1.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XLineBreakIteratorUtf16.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XLineBreakIteratorUtf8.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XLineBreakOptionsV1.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XLineBreakStrictness.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XLineBreakWordOption.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XLineSegmenter.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XList.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XListFormatter.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XListLength.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XLocale.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XLocaleCanonicalizer.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XLocaleDisplayNamesFormatter.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XLocaleExpander.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XLocaleFallbackConfig.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XLocaleFallbackIterator.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XLocaleFallbackPriority.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XLocaleFallbacker.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XLocaleFallbackerWithConfig.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XLogger.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XMetazoneCalculator.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XOrdering.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XPluralCategories.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XPluralCategory.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XPluralOperands.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XPluralRules.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XPropertyValueNameToEnumMapper.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XRegionDisplayNames.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XReorderedIndexMap.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XScriptExtensionsSet.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XScriptWithExtensions.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XScriptWithExtensionsBorrowed.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XSegmenterWordType.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XSentenceBreakIteratorLatin1.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XSentenceBreakIteratorUtf16.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XSentenceBreakIteratorUtf8.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XSentenceSegmenter.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XTime.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XTimeFormatter.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XTimeLength.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XTimeZoneFormatter.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XTransformResult.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XUnicodeSetData.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XWeekCalculator.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XWeekOf.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XWeekRelativeUnit.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XWordBreakIteratorLatin1.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XWordBreakIteratorUtf16.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XWordBreakIteratorUtf8.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XWordSegmenter.h create mode 100644 third_party/rust/icu_capi/c/include/ICU4XZonedDateTimeFormatter.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_ICU4XAnyCalendarKind_void.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_ICU4XPluralCategory_void.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_ICU4XWeekOf_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_bool_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XBidi_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCalendar_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCanonicalComposition_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCodePointMapData16_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCodePointMapData8_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCodePointSetData_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCollator_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XComposingNormalizer_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCustomTimeZone_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDataProvider_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDataStruct_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDateFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDateTime_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDate_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XFixedDecimal_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XIsoDateTime_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XIsoDate_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLineSegmenter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XListFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleExpander_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocale_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XPluralOperands_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XPluralRules_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XTimeFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XTime_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XUnicodeSetData_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XWeekCalculator_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XWordSegmenter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_int32_t_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_uint16_t_void.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_void_ICU4XError.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_result_void_void.h create mode 100644 third_party/rust/icu_capi/c/include/diplomat_runtime.h create mode 100644 third_party/rust/icu_capi/cpp/README.md create mode 100644 third_party/rust/icu_capi/cpp/include/CodePointRangeIterator.h create mode 100644 third_party/rust/icu_capi/cpp/include/CodePointRangeIterator.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/CodePointRangeIteratorResult.h create mode 100644 third_party/rust/icu_capi/cpp/include/CodePointRangeIteratorResult.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XAnyCalendarKind.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XAnyCalendarKind.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XBidi.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XBidi.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XBidiDirection.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XBidiDirection.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XBidiInfo.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XBidiInfo.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XBidiParagraph.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XBidiParagraph.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCalendar.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCalendar.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCanonicalCombiningClassMap.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCanonicalCombiningClassMap.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCanonicalComposition.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCanonicalComposition.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCanonicalDecomposition.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCanonicalDecomposition.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCodePointMapData16.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCodePointMapData16.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCodePointMapData8.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCodePointMapData8.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCodePointSetData.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCodePointSetData.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCollator.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCollator.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCollatorAlternateHandling.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCollatorAlternateHandling.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCollatorBackwardSecondLevel.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCollatorBackwardSecondLevel.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCollatorCaseFirst.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCollatorCaseFirst.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCollatorCaseLevel.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCollatorCaseLevel.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCollatorMaxVariable.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCollatorMaxVariable.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCollatorNumeric.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCollatorNumeric.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCollatorOptionsV1.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCollatorOptionsV1.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCollatorStrength.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCollatorStrength.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XComposingNormalizer.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XComposingNormalizer.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCustomTimeZone.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XCustomTimeZone.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDataProvider.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDataProvider.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDataStruct.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDataStruct.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDate.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDate.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDateFormatter.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDateFormatter.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDateLength.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDateLength.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDateTime.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDateTime.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDateTimeFormatter.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDateTimeFormatter.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDecomposed.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDecomposed.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDecomposingNormalizer.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDecomposingNormalizer.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesFallback.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesFallback.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesOptionsV1.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesOptionsV1.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesStyle.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesStyle.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XError.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimal.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimal.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalFormatter.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalFormatter.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalGroupingStrategy.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalGroupingStrategy.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalSign.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalSign.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalSignDisplay.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalSignDisplay.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XGeneralCategoryNameToMaskMapper.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XGeneralCategoryNameToMaskMapper.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorLatin1.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorLatin1.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorUtf16.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorUtf16.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorUtf8.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorUtf8.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterSegmenter.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterSegmenter.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XGregorianDateFormatter.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XGregorianDateFormatter.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XGregorianDateTimeFormatter.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XGregorianDateTimeFormatter.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XGregorianZonedDateTimeFormatter.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XGregorianZonedDateTimeFormatter.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XIsoDate.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XIsoDate.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XIsoDateTime.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XIsoDateTime.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneFormat.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneFormat.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneMinuteDisplay.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneMinuteDisplay.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneOptions.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneOptions.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneSecondDisplay.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneSecondDisplay.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XIsoWeekday.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XIsoWeekday.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLanguageDisplay.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLanguageDisplay.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorLatin1.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorLatin1.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorUtf16.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorUtf16.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorUtf8.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorUtf8.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLineBreakOptionsV1.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLineBreakOptionsV1.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLineBreakStrictness.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLineBreakStrictness.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLineBreakWordOption.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLineBreakWordOption.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLineSegmenter.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLineSegmenter.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XList.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XList.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XListFormatter.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XListFormatter.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XListLength.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XListLength.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLocale.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLocale.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLocaleCanonicalizer.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLocaleCanonicalizer.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLocaleDisplayNamesFormatter.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLocaleDisplayNamesFormatter.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLocaleExpander.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLocaleExpander.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackConfig.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackConfig.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackIterator.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackIterator.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackPriority.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackPriority.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbacker.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbacker.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackerWithConfig.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackerWithConfig.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLogger.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XLogger.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XMetazoneCalculator.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XMetazoneCalculator.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XOrdering.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XOrdering.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XPluralCategories.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XPluralCategories.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XPluralCategory.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XPluralCategory.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XPluralOperands.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XPluralOperands.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XPluralRules.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XPluralRules.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XPropertyValueNameToEnumMapper.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XPropertyValueNameToEnumMapper.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XRegionDisplayNames.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XRegionDisplayNames.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XReorderedIndexMap.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XReorderedIndexMap.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XScriptExtensionsSet.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XScriptExtensionsSet.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XScriptWithExtensions.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XScriptWithExtensions.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XScriptWithExtensionsBorrowed.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XScriptWithExtensionsBorrowed.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XSegmenterWordType.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XSegmenterWordType.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorLatin1.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorLatin1.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorUtf16.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorUtf16.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorUtf8.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorUtf8.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XSentenceSegmenter.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XSentenceSegmenter.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XTime.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XTime.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XTimeFormatter.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XTimeFormatter.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XTimeLength.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XTimeLength.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XTimeZoneFormatter.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XTimeZoneFormatter.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XTransformResult.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XTransformResult.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XUnicodeSetData.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XUnicodeSetData.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XWeekCalculator.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XWeekCalculator.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XWeekOf.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XWeekOf.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XWeekRelativeUnit.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XWeekRelativeUnit.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorLatin1.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorLatin1.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorUtf16.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorUtf16.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorUtf8.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorUtf8.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XWordSegmenter.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XWordSegmenter.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XZonedDateTimeFormatter.h create mode 100644 third_party/rust/icu_capi/cpp/include/ICU4XZonedDateTimeFormatter.hpp create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_ICU4XAnyCalendarKind_void.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_ICU4XPluralCategory_void.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_ICU4XWeekOf_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_bool_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XBidi_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCalendar_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCanonicalComposition_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCodePointMapData16_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCodePointMapData8_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCodePointSetData_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCollator_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XComposingNormalizer_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCustomTimeZone_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDataProvider_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDataStruct_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDateFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDateTime_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDate_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XFixedDecimal_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XIsoDateTime_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XIsoDate_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLineSegmenter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XListFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleExpander_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocale_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XPluralOperands_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XPluralRules_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XTimeFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XTime_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XUnicodeSetData_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XWeekCalculator_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XWordSegmenter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_int32_t_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_uint16_t_void.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_void_ICU4XError.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_result_void_void.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_runtime.h create mode 100644 third_party/rust/icu_capi/cpp/include/diplomat_runtime.hpp create mode 100644 third_party/rust/icu_capi/js/README.md create mode 100644 third_party/rust/icu_capi/js/examples/tinywasm/README.md create mode 100644 third_party/rust/icu_capi/js/include/CodePointRangeIterator.d.ts create mode 100644 third_party/rust/icu_capi/js/include/CodePointRangeIterator.js create mode 100644 third_party/rust/icu_capi/js/include/CodePointRangeIteratorResult.d.ts create mode 100644 third_party/rust/icu_capi/js/include/CodePointRangeIteratorResult.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XAnyCalendarKind.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XAnyCalendarKind.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XBidi.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XBidi.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XBidiDirection.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XBidiDirection.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XBidiInfo.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XBidiInfo.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XBidiParagraph.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XBidiParagraph.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCalendar.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCalendar.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCanonicalCombiningClassMap.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCanonicalCombiningClassMap.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCanonicalComposition.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCanonicalComposition.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCanonicalDecomposition.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCanonicalDecomposition.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCodePointMapData16.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCodePointMapData16.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCodePointMapData8.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCodePointMapData8.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCodePointSetData.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCodePointSetData.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCollator.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCollator.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCollatorAlternateHandling.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCollatorAlternateHandling.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCollatorBackwardSecondLevel.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCollatorBackwardSecondLevel.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCollatorCaseFirst.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCollatorCaseFirst.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCollatorCaseLevel.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCollatorCaseLevel.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCollatorMaxVariable.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCollatorMaxVariable.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCollatorNumeric.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCollatorNumeric.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCollatorOptionsV1.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCollatorOptionsV1.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCollatorStrength.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCollatorStrength.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XComposingNormalizer.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XComposingNormalizer.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCustomTimeZone.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XCustomTimeZone.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDataProvider.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDataProvider.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDataStruct.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDataStruct.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDate.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDate.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDateFormatter.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDateFormatter.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDateLength.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDateLength.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDateTime.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDateTime.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDateTimeFormatter.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDateTimeFormatter.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDecomposed.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDecomposed.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDecomposingNormalizer.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDecomposingNormalizer.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDisplayNamesFallback.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDisplayNamesFallback.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDisplayNamesOptionsV1.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDisplayNamesOptionsV1.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDisplayNamesStyle.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XDisplayNamesStyle.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XError.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XError.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XFixedDecimal.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XFixedDecimal.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XFixedDecimalFormatter.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XFixedDecimalFormatter.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XFixedDecimalGroupingStrategy.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XFixedDecimalGroupingStrategy.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XFixedDecimalSign.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XFixedDecimalSign.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XFixedDecimalSignDisplay.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XFixedDecimalSignDisplay.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XGeneralCategoryNameToMaskMapper.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XGeneralCategoryNameToMaskMapper.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorLatin1.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorLatin1.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorUtf16.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorUtf16.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorUtf8.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorUtf8.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterSegmenter.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterSegmenter.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XGregorianDateFormatter.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XGregorianDateFormatter.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XGregorianDateTimeFormatter.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XGregorianDateTimeFormatter.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XGregorianZonedDateTimeFormatter.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XGregorianZonedDateTimeFormatter.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XIsoDate.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XIsoDate.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XIsoDateTime.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XIsoDateTime.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneFormat.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneFormat.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneMinuteDisplay.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneMinuteDisplay.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneOptions.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneOptions.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneSecondDisplay.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneSecondDisplay.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XIsoWeekday.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XIsoWeekday.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLanguageDisplay.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLanguageDisplay.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorLatin1.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorLatin1.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorUtf16.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorUtf16.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorUtf8.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorUtf8.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLineBreakOptionsV1.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLineBreakOptionsV1.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLineBreakStrictness.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLineBreakStrictness.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLineBreakWordOption.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLineBreakWordOption.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLineSegmenter.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLineSegmenter.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XList.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XList.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XListFormatter.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XListFormatter.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XListLength.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XListLength.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLocale.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLocale.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLocaleCanonicalizer.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLocaleCanonicalizer.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLocaleDisplayNamesFormatter.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLocaleDisplayNamesFormatter.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLocaleExpander.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLocaleExpander.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackConfig.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackConfig.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackIterator.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackIterator.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackPriority.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackPriority.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLocaleFallbacker.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLocaleFallbacker.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackerWithConfig.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackerWithConfig.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLogger.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XLogger.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XMetazoneCalculator.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XMetazoneCalculator.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XOrdering.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XOrdering.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XPluralCategories.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XPluralCategories.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XPluralCategory.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XPluralCategory.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XPluralOperands.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XPluralOperands.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XPluralRules.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XPluralRules.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XPropertyValueNameToEnumMapper.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XPropertyValueNameToEnumMapper.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XRegionDisplayNames.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XRegionDisplayNames.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XReorderedIndexMap.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XReorderedIndexMap.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XScriptExtensionsSet.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XScriptExtensionsSet.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XScriptWithExtensions.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XScriptWithExtensions.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XScriptWithExtensionsBorrowed.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XScriptWithExtensionsBorrowed.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XSegmenterWordType.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XSegmenterWordType.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorLatin1.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorLatin1.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorUtf16.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorUtf16.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorUtf8.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorUtf8.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XSentenceSegmenter.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XSentenceSegmenter.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XTime.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XTime.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XTimeFormatter.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XTimeFormatter.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XTimeLength.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XTimeLength.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XTimeZoneFormatter.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XTimeZoneFormatter.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XTransformResult.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XTransformResult.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XUnicodeSetData.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XUnicodeSetData.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XWeekCalculator.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XWeekCalculator.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XWeekOf.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XWeekOf.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XWeekRelativeUnit.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XWeekRelativeUnit.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorLatin1.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorLatin1.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorUtf16.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorUtf16.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorUtf8.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorUtf8.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XWordSegmenter.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XWordSegmenter.js create mode 100644 third_party/rust/icu_capi/js/include/ICU4XZonedDateTimeFormatter.d.ts create mode 100644 third_party/rust/icu_capi/js/include/ICU4XZonedDateTimeFormatter.js create mode 100644 third_party/rust/icu_capi/js/include/diplomat-runtime.d.ts create mode 100644 third_party/rust/icu_capi/js/include/diplomat-runtime.js create mode 100644 third_party/rust/icu_capi/js/include/diplomat-wasm.mjs create mode 100644 third_party/rust/icu_capi/js/include/index.d.ts create mode 100644 third_party/rust/icu_capi/js/include/index.js create mode 100644 third_party/rust/icu_capi/src/bidi.rs create mode 100644 third_party/rust/icu_capi/src/calendar.rs create mode 100644 third_party/rust/icu_capi/src/collator.rs create mode 100644 third_party/rust/icu_capi/src/common.rs create mode 100644 third_party/rust/icu_capi/src/data_struct.rs create mode 100644 third_party/rust/icu_capi/src/date.rs create mode 100644 third_party/rust/icu_capi/src/datetime.rs create mode 100644 third_party/rust/icu_capi/src/datetime_formatter.rs create mode 100644 third_party/rust/icu_capi/src/decimal.rs create mode 100644 third_party/rust/icu_capi/src/displaynames.rs create mode 100644 third_party/rust/icu_capi/src/errors.rs create mode 100644 third_party/rust/icu_capi/src/fallbacker.rs create mode 100644 third_party/rust/icu_capi/src/fixed_decimal.rs create mode 100644 third_party/rust/icu_capi/src/lib.rs create mode 100644 third_party/rust/icu_capi/src/list.rs create mode 100644 third_party/rust/icu_capi/src/locale.rs create mode 100644 third_party/rust/icu_capi/src/locid_transform.rs create mode 100644 third_party/rust/icu_capi/src/logging.rs create mode 100644 third_party/rust/icu_capi/src/metazone_calculator.rs create mode 100644 third_party/rust/icu_capi/src/normalizer.rs create mode 100644 third_party/rust/icu_capi/src/normalizer_properties.rs create mode 100644 third_party/rust/icu_capi/src/pluralrules.rs create mode 100644 third_party/rust/icu_capi/src/properties_iter.rs create mode 100644 third_party/rust/icu_capi/src/properties_maps.rs create mode 100644 third_party/rust/icu_capi/src/properties_names.rs create mode 100644 third_party/rust/icu_capi/src/properties_sets.rs create mode 100644 third_party/rust/icu_capi/src/properties_unisets.rs create mode 100644 third_party/rust/icu_capi/src/provider.rs create mode 100644 third_party/rust/icu_capi/src/script.rs create mode 100644 third_party/rust/icu_capi/src/segmenter_grapheme.rs create mode 100644 third_party/rust/icu_capi/src/segmenter_line.rs create mode 100644 third_party/rust/icu_capi/src/segmenter_sentence.rs create mode 100644 third_party/rust/icu_capi/src/segmenter_word.rs create mode 100644 third_party/rust/icu_capi/src/time.rs create mode 100644 third_party/rust/icu_capi/src/timezone.rs create mode 100644 third_party/rust/icu_capi/src/timezone_formatter.rs create mode 100644 third_party/rust/icu_capi/src/wasm_glue.rs create mode 100644 third_party/rust/icu_capi/src/week.rs create mode 100644 third_party/rust/icu_capi/src/zoned_formatter.rs create mode 100644 third_party/rust/icu_capi/tests/missing_apis.txt create mode 100644 third_party/rust/icu_collections/.cargo-checksum.json create mode 100644 third_party/rust/icu_collections/Cargo.lock create mode 100644 third_party/rust/icu_collections/Cargo.toml create mode 100644 third_party/rust/icu_collections/LICENSE create mode 100644 third_party/rust/icu_collections/README.md create mode 100644 third_party/rust/icu_collections/src/char16trie/LICENSE create mode 100644 third_party/rust/icu_collections/src/char16trie/README.md create mode 100644 third_party/rust/icu_collections/src/char16trie/mod.rs create mode 100644 third_party/rust/icu_collections/src/char16trie/tests/test_util.rs create mode 100644 third_party/rust/icu_collections/src/char16trie/tests/testdata/empty.toml create mode 100644 third_party/rust/icu_collections/src/char16trie/tests/testdata/months.toml create mode 100644 third_party/rust/icu_collections/src/char16trie/tests/testdata/test_a.toml create mode 100644 third_party/rust/icu_collections/src/char16trie/tests/testdata/test_a_ab.toml create mode 100644 third_party/rust/icu_collections/src/char16trie/tests/testdata/test_branches.toml create mode 100644 third_party/rust/icu_collections/src/char16trie/tests/testdata/test_compact.toml create mode 100644 third_party/rust/icu_collections/src/char16trie/tests/testdata/test_long_branch.toml create mode 100644 third_party/rust/icu_collections/src/char16trie/tests/testdata/test_long_sequence.toml create mode 100644 third_party/rust/icu_collections/src/char16trie/tests/testdata/test_shortest_branch.toml create mode 100644 third_party/rust/icu_collections/src/char16trie/tests/trie_tests.rs create mode 100644 third_party/rust/icu_collections/src/char16trie/trie.rs create mode 100644 third_party/rust/icu_collections/src/codepointinvlist/LICENSE create mode 100644 third_party/rust/icu_collections/src/codepointinvlist/README.md create mode 100644 third_party/rust/icu_collections/src/codepointinvlist/benches/inv_list.rs create mode 100644 third_party/rust/icu_collections/src/codepointinvlist/builder.rs create mode 100644 third_party/rust/icu_collections/src/codepointinvlist/conversions.rs create mode 100644 third_party/rust/icu_collections/src/codepointinvlist/cpinvlist.rs create mode 100644 third_party/rust/icu_collections/src/codepointinvlist/examples/unicode_bmp_blocks_selector.rs create mode 100644 third_party/rust/icu_collections/src/codepointinvlist/mod.rs create mode 100644 third_party/rust/icu_collections/src/codepointinvlist/utils.rs create mode 100644 third_party/rust/icu_collections/src/codepointinvliststringlist/mod.rs create mode 100644 third_party/rust/icu_collections/src/codepointtrie/LICENSE create mode 100644 third_party/rust/icu_collections/src/codepointtrie/README.md create mode 100644 third_party/rust/icu_collections/src/codepointtrie/benches/codepointtrie.rs create mode 100644 third_party/rust/icu_collections/src/codepointtrie/benches/iai_cpt.rs create mode 100644 third_party/rust/icu_collections/src/codepointtrie/benches/tries/gc_fast.rs create mode 100644 third_party/rust/icu_collections/src/codepointtrie/benches/tries/gc_small.rs create mode 100644 third_party/rust/icu_collections/src/codepointtrie/benches/tries/mod.rs create mode 100644 third_party/rust/icu_collections/src/codepointtrie/cptrie.rs create mode 100644 third_party/rust/icu_collections/src/codepointtrie/error.rs create mode 100644 third_party/rust/icu_collections/src/codepointtrie/impl_const.rs create mode 100644 third_party/rust/icu_collections/src/codepointtrie/mod.rs create mode 100644 third_party/rust/icu_collections/src/codepointtrie/planes.rs create mode 100644 third_party/rust/icu_collections/src/codepointtrie/serde.rs create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/planes_test.rs create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/test_util.rs create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/free-blocks.16.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/free-blocks.32.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/free-blocks.8.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/free-blocks.small16.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/grow-data.16.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/grow-data.32.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/grow-data.8.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/grow-data.small16.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/planes.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set-empty.16.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set-empty.32.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set-empty.8.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set-empty.small16.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set-single-value.16.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set-single-value.32.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set-single-value.8.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set-single-value.small16.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set1.16.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set1.32.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set1.8.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set1.small16.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set2-overlap.16.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set2-overlap.32.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set2-overlap.small16.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set3-initial-9.16.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set3-initial-9.32.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set3-initial-9.8.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/set3-initial-9.small16.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/short-all-same.16.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/short-all-same.8.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/short-all-same.small16.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/small0-in-fast.16.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/small0-in-fast.32.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/small0-in-fast.8.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/testdata/small0-in-fast.small16.toml create mode 100644 third_party/rust/icu_collections/src/codepointtrie/tests/trie_test_data_test.rs create mode 100644 third_party/rust/icu_collections/src/codepointtrie/toml.rs create mode 100644 third_party/rust/icu_collections/src/iterator_utils.rs create mode 100644 third_party/rust/icu_collections/src/lib.rs create mode 100644 third_party/rust/icu_locid/.cargo-checksum.json create mode 100644 third_party/rust/icu_locid/Cargo.lock create mode 100644 third_party/rust/icu_locid/Cargo.toml create mode 100644 third_party/rust/icu_locid/LICENSE create mode 100644 third_party/rust/icu_locid/README.md create mode 100644 third_party/rust/icu_locid/benches/fixtures/langid.json create mode 100644 third_party/rust/icu_locid/benches/fixtures/locale.json create mode 100644 third_party/rust/icu_locid/benches/fixtures/mod.rs create mode 100644 third_party/rust/icu_locid/benches/fixtures/subtags.json create mode 100644 third_party/rust/icu_locid/benches/helpers/macros.rs create mode 100644 third_party/rust/icu_locid/benches/helpers/mod.rs create mode 100644 third_party/rust/icu_locid/benches/iai_langid.rs create mode 100644 third_party/rust/icu_locid/benches/langid.rs create mode 100644 third_party/rust/icu_locid/benches/locale.rs create mode 100644 third_party/rust/icu_locid/benches/subtags.rs create mode 100644 third_party/rust/icu_locid/examples/filter_langids.rs create mode 100644 third_party/rust/icu_locid/examples/syntatically_canonicalize_locales.rs create mode 100644 third_party/rust/icu_locid/src/databake.rs create mode 100644 third_party/rust/icu_locid/src/extensions/mod.rs create mode 100644 third_party/rust/icu_locid/src/extensions/other/mod.rs create mode 100644 third_party/rust/icu_locid/src/extensions/other/subtag.rs create mode 100644 third_party/rust/icu_locid/src/extensions/private/mod.rs create mode 100644 third_party/rust/icu_locid/src/extensions/private/other.rs create mode 100644 third_party/rust/icu_locid/src/extensions/transform/fields.rs create mode 100644 third_party/rust/icu_locid/src/extensions/transform/key.rs create mode 100644 third_party/rust/icu_locid/src/extensions/transform/mod.rs create mode 100644 third_party/rust/icu_locid/src/extensions/transform/value.rs create mode 100644 third_party/rust/icu_locid/src/extensions/unicode/attribute.rs create mode 100644 third_party/rust/icu_locid/src/extensions/unicode/attributes.rs create mode 100644 third_party/rust/icu_locid/src/extensions/unicode/key.rs create mode 100644 third_party/rust/icu_locid/src/extensions/unicode/keywords.rs create mode 100644 third_party/rust/icu_locid/src/extensions/unicode/mod.rs create mode 100644 third_party/rust/icu_locid/src/extensions/unicode/value.rs create mode 100644 third_party/rust/icu_locid/src/helpers.rs create mode 100644 third_party/rust/icu_locid/src/langid.rs create mode 100644 third_party/rust/icu_locid/src/lib.rs create mode 100644 third_party/rust/icu_locid/src/locale.rs create mode 100644 third_party/rust/icu_locid/src/macros.rs create mode 100644 third_party/rust/icu_locid/src/ordering.rs create mode 100644 third_party/rust/icu_locid/src/parser/errors.rs create mode 100644 third_party/rust/icu_locid/src/parser/langid.rs create mode 100644 third_party/rust/icu_locid/src/parser/locale.rs create mode 100644 third_party/rust/icu_locid/src/parser/mod.rs create mode 100644 third_party/rust/icu_locid/src/serde.rs create mode 100644 third_party/rust/icu_locid/src/subtags/language.rs create mode 100644 third_party/rust/icu_locid/src/subtags/mod.rs create mode 100644 third_party/rust/icu_locid/src/subtags/region.rs create mode 100644 third_party/rust/icu_locid/src/subtags/script.rs create mode 100644 third_party/rust/icu_locid/src/subtags/variant.rs create mode 100644 third_party/rust/icu_locid/src/subtags/variants.rs create mode 100644 third_party/rust/icu_locid/src/zerovec.rs create mode 100644 third_party/rust/icu_locid/tests/fixtures/canonicalize.json create mode 100644 third_party/rust/icu_locid/tests/fixtures/invalid-extensions.json create mode 100644 third_party/rust/icu_locid/tests/fixtures/invalid.json create mode 100644 third_party/rust/icu_locid/tests/fixtures/langid.json create mode 100644 third_party/rust/icu_locid/tests/fixtures/locale.json create mode 100644 third_party/rust/icu_locid/tests/fixtures/mod.rs create mode 100644 third_party/rust/icu_locid/tests/helpers/mod.rs create mode 100644 third_party/rust/icu_locid/tests/langid.rs create mode 100644 third_party/rust/icu_locid/tests/locale.rs create mode 100644 third_party/rust/icu_provider/.cargo-checksum.json create mode 100644 third_party/rust/icu_provider/Cargo.toml create mode 100644 third_party/rust/icu_provider/LICENSE create mode 100644 third_party/rust/icu_provider/README.md create mode 100644 third_party/rust/icu_provider/src/any.rs create mode 100644 third_party/rust/icu_provider/src/buf.rs create mode 100644 third_party/rust/icu_provider/src/constructors.rs create mode 100644 third_party/rust/icu_provider/src/data_provider.rs create mode 100644 third_party/rust/icu_provider/src/datagen/data_conversion.rs create mode 100644 third_party/rust/icu_provider/src/datagen/iter.rs create mode 100644 third_party/rust/icu_provider/src/datagen/mod.rs create mode 100644 third_party/rust/icu_provider/src/datagen/payload.rs create mode 100644 third_party/rust/icu_provider/src/dynutil.rs create mode 100644 third_party/rust/icu_provider/src/error.rs create mode 100644 third_party/rust/icu_provider/src/hello_world.rs create mode 100644 third_party/rust/icu_provider/src/helpers.rs create mode 100644 third_party/rust/icu_provider/src/key.rs create mode 100644 third_party/rust/icu_provider/src/lib.rs create mode 100644 third_party/rust/icu_provider/src/marker.rs create mode 100644 third_party/rust/icu_provider/src/request.rs create mode 100644 third_party/rust/icu_provider/src/response.rs create mode 100644 third_party/rust/icu_provider/src/serde/borrow_de_utils.rs create mode 100644 third_party/rust/icu_provider/src/serde/mod.rs create mode 100644 third_party/rust/icu_provider_adapters/.cargo-checksum.json create mode 100644 third_party/rust/icu_provider_adapters/Cargo.toml create mode 100644 third_party/rust/icu_provider_adapters/LICENSE create mode 100644 third_party/rust/icu_provider_adapters/README.md create mode 100644 third_party/rust/icu_provider_adapters/src/any_payload.rs create mode 100644 third_party/rust/icu_provider_adapters/src/either.rs create mode 100644 third_party/rust/icu_provider_adapters/src/empty.rs create mode 100644 third_party/rust/icu_provider_adapters/src/fallback/adapter.rs create mode 100644 third_party/rust/icu_provider_adapters/src/fallback/algorithms.rs create mode 100644 third_party/rust/icu_provider_adapters/src/fallback/mod.rs create mode 100644 third_party/rust/icu_provider_adapters/src/fallback/provider.rs create mode 100644 third_party/rust/icu_provider_adapters/src/filter/impls.rs create mode 100644 third_party/rust/icu_provider_adapters/src/filter/mod.rs create mode 100644 third_party/rust/icu_provider_adapters/src/fork/by_error.rs create mode 100644 third_party/rust/icu_provider_adapters/src/fork/macros.rs create mode 100644 third_party/rust/icu_provider_adapters/src/fork/mod.rs create mode 100644 third_party/rust/icu_provider_adapters/src/fork/predicates.rs create mode 100644 third_party/rust/icu_provider_adapters/src/helpers.rs create mode 100644 third_party/rust/icu_provider_adapters/src/lib.rs create mode 100644 third_party/rust/icu_provider_adapters/tests/data/langtest/de/core/helloworld@1/de.json create mode 100644 third_party/rust/icu_provider_adapters/tests/data/langtest/de/manifest.json create mode 100644 third_party/rust/icu_provider_adapters/tests/data/langtest/ro/core/helloworld@1/ro.json create mode 100644 third_party/rust/icu_provider_adapters/tests/data/langtest/ro/manifest.json create mode 100644 third_party/rust/icu_provider_macros/.cargo-checksum.json create mode 100644 third_party/rust/icu_provider_macros/Cargo.toml create mode 100644 third_party/rust/icu_provider_macros/LICENSE create mode 100644 third_party/rust/icu_provider_macros/README.md create mode 100644 third_party/rust/icu_provider_macros/src/lib.rs create mode 100644 third_party/rust/icu_provider_macros/src/tests.rs create mode 100644 third_party/rust/icu_segmenter/.cargo-checksum.json create mode 100644 third_party/rust/icu_segmenter/Cargo.toml create mode 100644 third_party/rust/icu_segmenter/LICENSE create mode 100644 third_party/rust/icu_segmenter/README.md create mode 100644 third_party/rust/icu_segmenter/benches/bench.rs create mode 100644 third_party/rust/icu_segmenter/src/complex.rs create mode 100644 third_party/rust/icu_segmenter/src/dictionary.rs create mode 100644 third_party/rust/icu_segmenter/src/error.rs create mode 100644 third_party/rust/icu_segmenter/src/grapheme.rs create mode 100644 third_party/rust/icu_segmenter/src/indices.rs create mode 100644 third_party/rust/icu_segmenter/src/iterator_helpers.rs create mode 100644 third_party/rust/icu_segmenter/src/language.rs create mode 100644 third_party/rust/icu_segmenter/src/lib.rs create mode 100644 third_party/rust/icu_segmenter/src/line.rs create mode 100644 third_party/rust/icu_segmenter/src/lstm.rs create mode 100644 third_party/rust/icu_segmenter/src/math_helper.rs create mode 100644 third_party/rust/icu_segmenter/src/provider/lstm.rs create mode 100644 third_party/rust/icu_segmenter/src/provider/mod.rs create mode 100644 third_party/rust/icu_segmenter/src/rule_segmenter.rs create mode 100644 third_party/rust/icu_segmenter/src/sentence.rs create mode 100644 third_party/rust/icu_segmenter/src/symbols.rs create mode 100644 third_party/rust/icu_segmenter/src/word.rs create mode 100644 third_party/rust/icu_segmenter/tests/complex_word.rs create mode 100644 third_party/rust/icu_segmenter/tests/css_line_break.rs create mode 100644 third_party/rust/icu_segmenter/tests/css_word_break.rs create mode 100644 third_party/rust/icu_segmenter/tests/spec_test.rs create mode 100644 third_party/rust/icu_segmenter/tests/testdata/GraphemeBreakTest.txt create mode 100644 third_party/rust/icu_segmenter/tests/testdata/LineBreakTest.txt create mode 100644 third_party/rust/icu_segmenter/tests/testdata/SentenceBreakExtraTest.txt create mode 100644 third_party/rust/icu_segmenter/tests/testdata/SentenceBreakTest.txt create mode 100644 third_party/rust/icu_segmenter/tests/testdata/WordBreakTest.txt create mode 100644 third_party/rust/icu_segmenter/tests/testdata/provider/manifest.json create mode 100644 third_party/rust/icu_segmenter/tests/testdata/provider/segmenter/dictionary/w_auto@1/ja.postcard create mode 100644 third_party/rust/icu_segmenter/tests/testdata/provider/segmenter/dictionary/wl_ext@1/km.postcard create mode 100644 third_party/rust/icu_segmenter/tests/testdata/provider/segmenter/dictionary/wl_ext@1/lo.postcard create mode 100644 third_party/rust/icu_segmenter/tests/testdata/provider/segmenter/dictionary/wl_ext@1/my.postcard create mode 100644 third_party/rust/icu_segmenter/tests/testdata/provider/segmenter/dictionary/wl_ext@1/th.postcard create mode 100644 third_party/rust/icu_segmenter/tests/testdata/provider/segmenter/lstm/wl_auto@1/km.postcard create mode 100644 third_party/rust/icu_segmenter/tests/testdata/provider/segmenter/lstm/wl_auto@1/lo.postcard create mode 100644 third_party/rust/icu_segmenter/tests/testdata/provider/segmenter/lstm/wl_auto@1/my.postcard create mode 100644 third_party/rust/icu_segmenter/tests/testdata/provider/segmenter/lstm/wl_auto@1/th.postcard create mode 100644 third_party/rust/icu_segmenter/tests/testdata/test_text_codepoints.json create mode 100644 third_party/rust/icu_segmenter/tests/testdata/test_text_graphclust.json create mode 100644 third_party/rust/icu_segmenter/tests/word_rule_status.rs create mode 100644 third_party/rust/libm/.cargo-checksum.json create mode 100644 third_party/rust/libm/CHANGELOG.md create mode 100644 third_party/rust/libm/CONTRIBUTING.md create mode 100644 third_party/rust/libm/Cargo.toml create mode 100644 third_party/rust/libm/LICENSE-APACHE create mode 100644 third_party/rust/libm/LICENSE-MIT create mode 100644 third_party/rust/libm/README.md create mode 100644 third_party/rust/libm/build.rs create mode 100644 third_party/rust/libm/ci/docker/aarch64-unknown-linux-gnu/Dockerfile create mode 100644 third_party/rust/libm/ci/docker/arm-unknown-linux-gnueabi/Dockerfile create mode 100644 third_party/rust/libm/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile create mode 100644 third_party/rust/libm/ci/docker/armv7-unknown-linux-gnueabihf/Dockerfile create mode 100644 third_party/rust/libm/ci/docker/i686-unknown-linux-gnu/Dockerfile create mode 100644 third_party/rust/libm/ci/docker/mips-unknown-linux-gnu/Dockerfile create mode 100644 third_party/rust/libm/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile create mode 100644 third_party/rust/libm/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile create mode 100644 third_party/rust/libm/ci/docker/mipsel-unknown-linux-gnu/Dockerfile create mode 100644 third_party/rust/libm/ci/docker/powerpc-unknown-linux-gnu/Dockerfile create mode 100644 third_party/rust/libm/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile create mode 100644 third_party/rust/libm/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile create mode 100644 third_party/rust/libm/ci/docker/x86_64-unknown-linux-gnu/Dockerfile create mode 100755 third_party/rust/libm/ci/run-docker.sh create mode 100755 third_party/rust/libm/ci/run.sh create mode 100644 third_party/rust/libm/src/lib.rs create mode 100644 third_party/rust/libm/src/math/acos.rs create mode 100644 third_party/rust/libm/src/math/acosf.rs create mode 100644 third_party/rust/libm/src/math/acosh.rs create mode 100644 third_party/rust/libm/src/math/acoshf.rs create mode 100644 third_party/rust/libm/src/math/asin.rs create mode 100644 third_party/rust/libm/src/math/asinf.rs create mode 100644 third_party/rust/libm/src/math/asinh.rs create mode 100644 third_party/rust/libm/src/math/asinhf.rs create mode 100644 third_party/rust/libm/src/math/atan.rs create mode 100644 third_party/rust/libm/src/math/atan2.rs create mode 100644 third_party/rust/libm/src/math/atan2f.rs create mode 100644 third_party/rust/libm/src/math/atanf.rs create mode 100644 third_party/rust/libm/src/math/atanh.rs create mode 100644 third_party/rust/libm/src/math/atanhf.rs create mode 100644 third_party/rust/libm/src/math/cbrt.rs create mode 100644 third_party/rust/libm/src/math/cbrtf.rs create mode 100644 third_party/rust/libm/src/math/ceil.rs create mode 100644 third_party/rust/libm/src/math/ceilf.rs create mode 100644 third_party/rust/libm/src/math/copysign.rs create mode 100644 third_party/rust/libm/src/math/copysignf.rs create mode 100644 third_party/rust/libm/src/math/cos.rs create mode 100644 third_party/rust/libm/src/math/cosf.rs create mode 100644 third_party/rust/libm/src/math/cosh.rs create mode 100644 third_party/rust/libm/src/math/coshf.rs create mode 100644 third_party/rust/libm/src/math/erf.rs create mode 100644 third_party/rust/libm/src/math/erff.rs create mode 100644 third_party/rust/libm/src/math/exp.rs create mode 100644 third_party/rust/libm/src/math/exp10.rs create mode 100644 third_party/rust/libm/src/math/exp10f.rs create mode 100644 third_party/rust/libm/src/math/exp2.rs create mode 100644 third_party/rust/libm/src/math/exp2f.rs create mode 100644 third_party/rust/libm/src/math/expf.rs create mode 100644 third_party/rust/libm/src/math/expm1.rs create mode 100644 third_party/rust/libm/src/math/expm1f.rs create mode 100644 third_party/rust/libm/src/math/expo2.rs create mode 100644 third_party/rust/libm/src/math/fabs.rs create mode 100644 third_party/rust/libm/src/math/fabsf.rs create mode 100644 third_party/rust/libm/src/math/fdim.rs create mode 100644 third_party/rust/libm/src/math/fdimf.rs create mode 100644 third_party/rust/libm/src/math/fenv.rs create mode 100644 third_party/rust/libm/src/math/floor.rs create mode 100644 third_party/rust/libm/src/math/floorf.rs create mode 100644 third_party/rust/libm/src/math/fma.rs create mode 100644 third_party/rust/libm/src/math/fmaf.rs create mode 100644 third_party/rust/libm/src/math/fmax.rs create mode 100644 third_party/rust/libm/src/math/fmaxf.rs create mode 100644 third_party/rust/libm/src/math/fmin.rs create mode 100644 third_party/rust/libm/src/math/fminf.rs create mode 100644 third_party/rust/libm/src/math/fmod.rs create mode 100644 third_party/rust/libm/src/math/fmodf.rs create mode 100644 third_party/rust/libm/src/math/frexp.rs create mode 100644 third_party/rust/libm/src/math/frexpf.rs create mode 100644 third_party/rust/libm/src/math/hypot.rs create mode 100644 third_party/rust/libm/src/math/hypotf.rs create mode 100644 third_party/rust/libm/src/math/ilogb.rs create mode 100644 third_party/rust/libm/src/math/ilogbf.rs create mode 100644 third_party/rust/libm/src/math/j0.rs create mode 100644 third_party/rust/libm/src/math/j0f.rs create mode 100644 third_party/rust/libm/src/math/j1.rs create mode 100644 third_party/rust/libm/src/math/j1f.rs create mode 100644 third_party/rust/libm/src/math/jn.rs create mode 100644 third_party/rust/libm/src/math/jnf.rs create mode 100644 third_party/rust/libm/src/math/k_cos.rs create mode 100644 third_party/rust/libm/src/math/k_cosf.rs create mode 100644 third_party/rust/libm/src/math/k_expo2.rs create mode 100644 third_party/rust/libm/src/math/k_expo2f.rs create mode 100644 third_party/rust/libm/src/math/k_sin.rs create mode 100644 third_party/rust/libm/src/math/k_sinf.rs create mode 100644 third_party/rust/libm/src/math/k_tan.rs create mode 100644 third_party/rust/libm/src/math/k_tanf.rs create mode 100644 third_party/rust/libm/src/math/ldexp.rs create mode 100644 third_party/rust/libm/src/math/ldexpf.rs create mode 100644 third_party/rust/libm/src/math/lgamma.rs create mode 100644 third_party/rust/libm/src/math/lgamma_r.rs create mode 100644 third_party/rust/libm/src/math/lgammaf.rs create mode 100644 third_party/rust/libm/src/math/lgammaf_r.rs create mode 100644 third_party/rust/libm/src/math/log.rs create mode 100644 third_party/rust/libm/src/math/log10.rs create mode 100644 third_party/rust/libm/src/math/log10f.rs create mode 100644 third_party/rust/libm/src/math/log1p.rs create mode 100644 third_party/rust/libm/src/math/log1pf.rs create mode 100644 third_party/rust/libm/src/math/log2.rs create mode 100644 third_party/rust/libm/src/math/log2f.rs create mode 100644 third_party/rust/libm/src/math/logf.rs create mode 100644 third_party/rust/libm/src/math/mod.rs create mode 100644 third_party/rust/libm/src/math/modf.rs create mode 100644 third_party/rust/libm/src/math/modff.rs create mode 100644 third_party/rust/libm/src/math/nextafter.rs create mode 100644 third_party/rust/libm/src/math/nextafterf.rs create mode 100644 third_party/rust/libm/src/math/pow.rs create mode 100644 third_party/rust/libm/src/math/powf.rs create mode 100644 third_party/rust/libm/src/math/rem_pio2.rs create mode 100644 third_party/rust/libm/src/math/rem_pio2_large.rs create mode 100644 third_party/rust/libm/src/math/rem_pio2f.rs create mode 100644 third_party/rust/libm/src/math/remainder.rs create mode 100644 third_party/rust/libm/src/math/remainderf.rs create mode 100644 third_party/rust/libm/src/math/remquo.rs create mode 100644 third_party/rust/libm/src/math/remquof.rs create mode 100644 third_party/rust/libm/src/math/rint.rs create mode 100644 third_party/rust/libm/src/math/rintf.rs create mode 100644 third_party/rust/libm/src/math/round.rs create mode 100644 third_party/rust/libm/src/math/roundf.rs create mode 100644 third_party/rust/libm/src/math/scalbn.rs create mode 100644 third_party/rust/libm/src/math/scalbnf.rs create mode 100644 third_party/rust/libm/src/math/sin.rs create mode 100644 third_party/rust/libm/src/math/sincos.rs create mode 100644 third_party/rust/libm/src/math/sincosf.rs create mode 100644 third_party/rust/libm/src/math/sinf.rs create mode 100644 third_party/rust/libm/src/math/sinh.rs create mode 100644 third_party/rust/libm/src/math/sinhf.rs create mode 100644 third_party/rust/libm/src/math/sqrt.rs create mode 100644 third_party/rust/libm/src/math/sqrtf.rs create mode 100644 third_party/rust/libm/src/math/tan.rs create mode 100644 third_party/rust/libm/src/math/tanf.rs create mode 100644 third_party/rust/libm/src/math/tanh.rs create mode 100644 third_party/rust/libm/src/math/tanhf.rs create mode 100644 third_party/rust/libm/src/math/tgamma.rs create mode 100644 third_party/rust/libm/src/math/tgammaf.rs create mode 100644 third_party/rust/libm/src/math/trunc.rs create mode 100644 third_party/rust/libm/src/math/truncf.rs create mode 100644 third_party/rust/litemap/.cargo-checksum.json create mode 100644 third_party/rust/litemap/Cargo.lock create mode 100644 third_party/rust/litemap/Cargo.toml create mode 100644 third_party/rust/litemap/LICENSE create mode 100644 third_party/rust/litemap/README.md create mode 100644 third_party/rust/litemap/benches/bin/litemap_bincode.rs create mode 100644 third_party/rust/litemap/benches/bin/litemap_postcard.rs create mode 100644 third_party/rust/litemap/benches/litemap.rs create mode 100644 third_party/rust/litemap/benches/testdata/large_litemap.postcard create mode 100644 third_party/rust/litemap/examples/language_names_hash_map.rs create mode 100644 third_party/rust/litemap/examples/language_names_lite_map.rs create mode 100644 third_party/rust/litemap/src/lib.rs create mode 100644 third_party/rust/litemap/src/map.rs create mode 100644 third_party/rust/litemap/src/serde.rs create mode 100644 third_party/rust/litemap/src/serde_helpers.rs create mode 100644 third_party/rust/litemap/src/store/mod.rs create mode 100644 third_party/rust/litemap/src/store/slice_impl.rs create mode 100644 third_party/rust/litemap/src/store/vec_impl.rs create mode 100644 third_party/rust/litemap/src/testing.rs create mode 100644 third_party/rust/litemap/tests/rkyv.rs create mode 100644 third_party/rust/litemap/tests/serde.rs create mode 100644 third_party/rust/litemap/tests/store.rs create mode 100644 third_party/rust/strck/.cargo-checksum.json create mode 100644 third_party/rust/strck/Cargo.toml create mode 100644 third_party/rust/strck/LICENSE create mode 100644 third_party/rust/strck/README.md create mode 100644 third_party/rust/strck/src/lib.rs create mode 100644 third_party/rust/strck/src/partial_eq.rs create mode 100644 third_party/rust/strck/src/serde.rs create mode 100644 third_party/rust/strck_ident/.cargo-checksum.json create mode 100644 third_party/rust/strck_ident/Cargo.toml create mode 100644 third_party/rust/strck_ident/LICENSE create mode 100644 third_party/rust/strck_ident/README.md create mode 100644 third_party/rust/strck_ident/src/lib.rs create mode 100644 third_party/rust/strck_ident/src/rust.rs create mode 100644 third_party/rust/strck_ident/src/unicode.rs create mode 100644 third_party/rust/utf8_iter/.cargo-checksum.json create mode 100644 third_party/rust/utf8_iter/COPYRIGHT create mode 100644 third_party/rust/utf8_iter/Cargo.toml create mode 100644 third_party/rust/utf8_iter/LICENSE-APACHE create mode 100644 third_party/rust/utf8_iter/LICENSE-MIT create mode 100644 third_party/rust/utf8_iter/README.md create mode 100644 third_party/rust/utf8_iter/src/indices.rs create mode 100644 third_party/rust/utf8_iter/src/lib.rs create mode 100644 third_party/rust/writeable/.cargo-checksum.json create mode 100644 third_party/rust/writeable/Cargo.lock create mode 100644 third_party/rust/writeable/Cargo.toml create mode 100644 third_party/rust/writeable/LICENSE create mode 100644 third_party/rust/writeable/README.md create mode 100644 third_party/rust/writeable/benches/writeable.rs create mode 100644 third_party/rust/writeable/examples/writeable_message.rs create mode 100644 third_party/rust/writeable/src/impls.rs create mode 100644 third_party/rust/writeable/src/lib.rs create mode 100644 third_party/rust/writeable/src/ops.rs create mode 100644 third_party/rust/writeable/tests/writeable.rs create mode 100644 third_party/rust/yoke-derive/.cargo-checksum.json create mode 100644 third_party/rust/yoke-derive/Cargo.toml create mode 100644 third_party/rust/yoke-derive/LICENSE create mode 100644 third_party/rust/yoke-derive/README.md create mode 100644 third_party/rust/yoke-derive/examples/yoke_derive.rs create mode 100644 third_party/rust/yoke-derive/src/lib.rs create mode 100644 third_party/rust/yoke-derive/src/visitor.rs create mode 100644 third_party/rust/yoke/.cargo-checksum.json create mode 100644 third_party/rust/yoke/Cargo.toml create mode 100644 third_party/rust/yoke/LICENSE create mode 100644 third_party/rust/yoke/README.md create mode 100644 third_party/rust/yoke/src/either.rs create mode 100644 third_party/rust/yoke/src/erased.rs create mode 100644 third_party/rust/yoke/src/lib.rs create mode 100644 third_party/rust/yoke/src/macro_impls.rs create mode 100644 third_party/rust/yoke/src/trait_hack.rs create mode 100644 third_party/rust/yoke/src/yoke.rs create mode 100644 third_party/rust/yoke/src/yokeable.rs create mode 100644 third_party/rust/yoke/src/zero_from.rs create mode 100644 third_party/rust/zerofrom-derive/.cargo-checksum.json create mode 100644 third_party/rust/zerofrom-derive/Cargo.toml create mode 100644 third_party/rust/zerofrom-derive/LICENSE create mode 100644 third_party/rust/zerofrom-derive/README.md create mode 100644 third_party/rust/zerofrom-derive/examples/zf_derive.rs create mode 100644 third_party/rust/zerofrom-derive/src/lib.rs create mode 100644 third_party/rust/zerofrom-derive/src/visitor.rs create mode 100644 third_party/rust/zerofrom/.cargo-checksum.json create mode 100644 third_party/rust/zerofrom/Cargo.toml create mode 100644 third_party/rust/zerofrom/LICENSE create mode 100644 third_party/rust/zerofrom/README.md create mode 100644 third_party/rust/zerofrom/src/lib.rs create mode 100644 third_party/rust/zerofrom/src/macro_impls.rs create mode 100644 third_party/rust/zerofrom/src/zero_from.rs create mode 100644 third_party/rust/zerovec-derive/.cargo-checksum.json create mode 100644 third_party/rust/zerovec-derive/Cargo.toml create mode 100644 third_party/rust/zerovec-derive/LICENSE create mode 100644 third_party/rust/zerovec-derive/README.md create mode 100644 third_party/rust/zerovec-derive/examples/derives.rs create mode 100644 third_party/rust/zerovec-derive/examples/make.rs create mode 100644 third_party/rust/zerovec-derive/examples/make_var.rs create mode 100644 third_party/rust/zerovec-derive/src/lib.rs create mode 100644 third_party/rust/zerovec-derive/src/make_ule.rs create mode 100644 third_party/rust/zerovec-derive/src/make_varule.rs create mode 100644 third_party/rust/zerovec-derive/src/ule.rs create mode 100644 third_party/rust/zerovec-derive/src/utils.rs create mode 100644 third_party/rust/zerovec-derive/src/varule.rs create mode 100644 third_party/rust/zerovec/.cargo-checksum.json create mode 100644 third_party/rust/zerovec/Cargo.lock create mode 100644 third_party/rust/zerovec/Cargo.toml create mode 100644 third_party/rust/zerovec/LICENSE create mode 100644 third_party/rust/zerovec/README.md create mode 100644 third_party/rust/zerovec/benches/testdata/large_hashmap.postcard create mode 100644 third_party/rust/zerovec/benches/testdata/large_zerohashmap.postcard create mode 100644 third_party/rust/zerovec/benches/testdata/large_zeromap.postcard create mode 100644 third_party/rust/zerovec/benches/vzv.rs create mode 100644 third_party/rust/zerovec/benches/zeromap.rs create mode 100644 third_party/rust/zerovec/benches/zerovec.rs create mode 100644 third_party/rust/zerovec/benches/zerovec_iai.rs create mode 100644 third_party/rust/zerovec/benches/zerovec_serde.rs create mode 100644 third_party/rust/zerovec/examples/zv_serde.rs create mode 100644 third_party/rust/zerovec/src/error.rs create mode 100644 third_party/rust/zerovec/src/flexzerovec/databake.rs create mode 100644 third_party/rust/zerovec/src/flexzerovec/mod.rs create mode 100644 third_party/rust/zerovec/src/flexzerovec/owned.rs create mode 100644 third_party/rust/zerovec/src/flexzerovec/serde.rs create mode 100644 third_party/rust/zerovec/src/flexzerovec/slice.rs create mode 100644 third_party/rust/zerovec/src/flexzerovec/vec.rs create mode 100644 third_party/rust/zerovec/src/hashmap/algorithms.rs create mode 100644 third_party/rust/zerovec/src/hashmap/mod.rs create mode 100644 third_party/rust/zerovec/src/hashmap/serde.rs create mode 100644 third_party/rust/zerovec/src/lib.rs create mode 100644 third_party/rust/zerovec/src/map/borrowed.rs create mode 100644 third_party/rust/zerovec/src/map/databake.rs create mode 100644 third_party/rust/zerovec/src/map/kv.rs create mode 100644 third_party/rust/zerovec/src/map/map.rs create mode 100644 third_party/rust/zerovec/src/map/mod.rs create mode 100644 third_party/rust/zerovec/src/map/serde.rs create mode 100644 third_party/rust/zerovec/src/map/serde_helpers.rs create mode 100644 third_party/rust/zerovec/src/map/vecs.rs create mode 100644 third_party/rust/zerovec/src/map2d/borrowed.rs create mode 100644 third_party/rust/zerovec/src/map2d/cursor.rs create mode 100644 third_party/rust/zerovec/src/map2d/databake.rs create mode 100644 third_party/rust/zerovec/src/map2d/map.rs create mode 100644 third_party/rust/zerovec/src/map2d/mod.rs create mode 100644 third_party/rust/zerovec/src/map2d/serde.rs create mode 100644 third_party/rust/zerovec/src/samples.rs create mode 100644 third_party/rust/zerovec/src/ule/chars.rs create mode 100644 third_party/rust/zerovec/src/ule/custom.rs create mode 100644 third_party/rust/zerovec/src/ule/encode.rs create mode 100644 third_party/rust/zerovec/src/ule/mod.rs create mode 100644 third_party/rust/zerovec/src/ule/multi.rs create mode 100644 third_party/rust/zerovec/src/ule/niche.rs create mode 100644 third_party/rust/zerovec/src/ule/option.rs create mode 100644 third_party/rust/zerovec/src/ule/plain.rs create mode 100644 third_party/rust/zerovec/src/ule/slices.rs create mode 100644 third_party/rust/zerovec/src/ule/tuple.rs create mode 100644 third_party/rust/zerovec/src/ule/unvalidated.rs create mode 100644 third_party/rust/zerovec/src/varzerovec/components.rs create mode 100644 third_party/rust/zerovec/src/varzerovec/databake.rs create mode 100644 third_party/rust/zerovec/src/varzerovec/mod.rs create mode 100644 third_party/rust/zerovec/src/varzerovec/owned.rs create mode 100644 third_party/rust/zerovec/src/varzerovec/serde.rs create mode 100644 third_party/rust/zerovec/src/varzerovec/slice.rs create mode 100644 third_party/rust/zerovec/src/varzerovec/vec.rs create mode 100644 third_party/rust/zerovec/src/yoke_impls.rs create mode 100644 third_party/rust/zerovec/src/zerofrom_impls.rs create mode 100644 third_party/rust/zerovec/src/zerovec/databake.rs create mode 100644 third_party/rust/zerovec/src/zerovec/mod.rs create mode 100644 third_party/rust/zerovec/src/zerovec/serde.rs create mode 100644 third_party/rust/zerovec/src/zerovec/slice.rs diff --git a/.cargo/config.in b/.cargo/config.in index 902fab6bb4ac..395835e635aa 100644 --- a/.cargo/config.in +++ b/.cargo/config.in @@ -115,6 +115,11 @@ git = "https://github.com/mozilla/uniffi-rs.git" rev = "c0e64b839018728d8153ce1758d391b7782e2e21" replace-with = "vendored-sources" +[source."git+https://github.com/rust-diplomat/diplomat?rev=8d125999893fedfdf30595e97334c21ec4b18da9"] +git = "https://github.com/rust-diplomat/diplomat" +rev = "8d125999893fedfdf30595e97334c21ec4b18da9" +replace-with = "vendored-sources" + [source."git+https://github.com/rust-minidump/minidump-writer.git?rev=a15bd5cab6a3de251c0c23264be14b977c0af09c"] git = "https://github.com/rust-minidump/minidump-writer.git" rev = "a15bd5cab6a3de251c0c23264be14b977c0af09c" @@ -125,6 +130,11 @@ git = "https://github.com/rust-minidump/rust-minidump" rev = "87a29fba5e19cfae5ebf73a57ba31504a3872545" replace-with = "vendored-sources" +[source."git+https://github.com/unicode-org/icu4x?rev=14e9a3a9857be74582abe2dfa7ab799c5eaac873"] +git = "https://github.com/unicode-org/icu4x" +rev = "14e9a3a9857be74582abe2dfa7ab799c5eaac873" +replace-with = "vendored-sources" + # Take advantage of the fact that cargo will treat lines starting with # # as comments to add preprocessing directives. This file can thus by copied diff --git a/Cargo.lock b/Cargo.lock index 2fcb7a03871f..c2b38503df27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1323,6 +1323,36 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "diplomat" +version = "0.5.2" +source = "git+https://github.com/rust-diplomat/diplomat?rev=8d125999893fedfdf30595e97334c21ec4b18da9#8d125999893fedfdf30595e97334c21ec4b18da9" +dependencies = [ + "diplomat_core", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "diplomat-runtime" +version = "0.5.2" +source = "git+https://github.com/rust-diplomat/diplomat?rev=8d125999893fedfdf30595e97334c21ec4b18da9#8d125999893fedfdf30595e97334c21ec4b18da9" + +[[package]] +name = "diplomat_core" +version = "0.5.2" +source = "git+https://github.com/rust-diplomat/diplomat?rev=8d125999893fedfdf30595e97334c21ec4b18da9#8d125999893fedfdf30595e97334c21ec4b18da9" +dependencies = [ + "lazy_static", + "proc-macro2", + "quote", + "serde", + "smallvec", + "strck_ident", + "syn", +] + [[package]] name = "dirs" version = "4.0.0" @@ -2561,6 +2591,116 @@ dependencies = [ "want", ] +[[package]] +name = "icu_capi" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c29e1e7407081a5e425b295ef28526ca4c3cd7ce4475e1769c2863bb18b9305" +dependencies = [ + "diplomat", + "diplomat-runtime", + "icu_locid", + "icu_provider", + "icu_provider_adapters", + "icu_segmenter", + "icu_testdata", + "log", + "tinystr", + "writeable", +] + +[[package]] +name = "icu_collections" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef8302d8dfd6044d3ddb3f807a5ef3d7bbca9a574959c6d6e4dc39aa7012d0d5" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3003f85dccfc0e238ff567693248c59153a46f4e6125ba4020b973cef4d1d335" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_provider" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc312a7b6148f7dfe098047ae2494d12d4034f48ade58d4f353000db376e305" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_adapters" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4ae1e2bd0c41728b77e7c46e9afdec5e2127d1eedacc684724667d50c126bd3" +dependencies = [ + "icu_locid", + "icu_provider", + "tinystr", + "yoke", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b728b9421e93eff1d9f8681101b78fa745e0748c95c655c83f337044a7e10" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.107", +] + +[[package]] +name = "icu_segmenter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3300a7b6bf187be98a57264ad094f11f2e062c2e8263132af010ff522ee5495" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid", + "icu_provider", + "num-traits", + "utf8_iter", + "zerovec", +] + +[[package]] +name = "icu_testdata" +version = "1.2.0" +dependencies = [ + "icu_collections", + "icu_locid", + "icu_provider", + "icu_provider_adapters", + "icu_segmenter", + "zerovec", +] + [[package]] name = "id-arena" version = "2.2.1" @@ -2817,6 +2957,7 @@ dependencies = [ "encoding_c", "encoding_c_mem", "gluesmith", + "icu_capi", "mozglue-static", "smoosh", ] @@ -2954,6 +3095,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "libm" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" + [[package]] name = "libsqlite3-sys" version = "0.26.0" @@ -2998,6 +3145,12 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" +[[package]] +name = "litemap" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a04a5b2b6f54acba899926491d0a6c59d98012938ca2ab5befb281c034e8f94" + [[package]] name = "lmdb-rkv" version = "0.14.0" @@ -3827,6 +3980,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -4985,6 +5139,22 @@ dependencies = [ "xpcom", ] +[[package]] +name = "strck" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be91090ded9d8f979d9fe921777342d37e769e0b6b7296843a7a38247240e917" + +[[package]] +name = "strck_ident" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1c3802b169b3858a44667f221c9a0b3136e6019936ea926fc97fbad8af77202" +dependencies = [ + "strck", + "unicode-ident", +] + [[package]] name = "strsim" version = "0.10.0" @@ -5288,6 +5458,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ac3f5b6856e931e15e07b478e98c8045239829a65f9156d4fa7e7788197a5ef" dependencies = [ "displaydoc", + "zerovec", ] [[package]] @@ -5504,9 +5675,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.8" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" @@ -5775,6 +5946,12 @@ dependencies = [ "serde", ] +[[package]] +name = "utf8_iter" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64a8922555b9500e3d865caed19330172cd67cbf82203f1a3311d8c305cc9f33" + [[package]] name = "uuid" version = "1.3.0" @@ -6314,6 +6491,12 @@ dependencies = [ "euclid", ] +[[package]] +name = "writeable" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60e49e42bdb1d5dc76f4cd78102f8f0714d32edfa3efb82286eb0f0b1fc0da0f" + [[package]] name = "xml-rs" version = "0.8.4" @@ -6372,6 +6555,29 @@ dependencies = [ "linked-hash-map", ] +[[package]] +name = "yoke" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1848075a23a28f9773498ee9a0f2cf58fcbad4f8c0ccf84a210ab33c6ae495de" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.1" +source = "git+https://github.com/unicode-org/icu4x?rev=14e9a3a9857be74582abe2dfa7ab799c5eaac873#14e9a3a9857be74582abe2dfa7ab799c5eaac873" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + [[package]] name = "zeitstempel" version = "0.1.1" @@ -6383,6 +6589,48 @@ dependencies = [ "once_cell", ] +[[package]] +name = "zerofrom" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df54d76c3251de27615dfcce21e636c172dafb2549cd7fd93e21c66f6ca6bea2" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.2" +source = "git+https://github.com/unicode-org/icu4x?rev=14e9a3a9857be74582abe2dfa7ab799c5eaac873#14e9a3a9857be74582abe2dfa7ab799c5eaac873" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerovec" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "198f54134cd865f437820aa3b43d0ad518af4e68ee161b444cdd15d8e567c8ea" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.9.4" +source = "git+https://github.com/unicode-org/icu4x?rev=14e9a3a9857be74582abe2dfa7ab799c5eaac873#14e9a3a9857be74582abe2dfa7ab799c5eaac873" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + [[package]] name = "zip" version = "0.6.4" diff --git a/Cargo.toml b/Cargo.toml index d2e9f53e7b8a..2b2c11095313 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -207,6 +207,13 @@ tabs = { git = "https://github.com/mozilla/application-services", rev = "25972c3 viaduct = { git = "https://github.com/mozilla/application-services", rev = "25972c388a4cf3a6d8256504f3a09b711db2fc6a" } webext-storage = { git = "https://github.com/mozilla/application-services", rev = "25972c388a4cf3a6d8256504f3a09b711db2fc6a" } +# ICU4X 1.2 with synstructure 0.13.x / syn 2.x. When updating to next version, this should be removed. +diplomat = { git = "https://github.com/rust-diplomat/diplomat", rev = "8d125999893fedfdf30595e97334c21ec4b18da9" } +diplomat-runtime = { git = "https://github.com/rust-diplomat/diplomat", rev = "8d125999893fedfdf30595e97334c21ec4b18da9" } +yoke-derive = { git = "https://github.com/unicode-org/icu4x", rev = "14e9a3a9857be74582abe2dfa7ab799c5eaac873" } +zerofrom-derive = { git = "https://github.com/unicode-org/icu4x", rev = "14e9a3a9857be74582abe2dfa7ab799c5eaac873" } +zerovec-derive = { git = "https://github.com/unicode-org/icu4x", rev = "14e9a3a9857be74582abe2dfa7ab799c5eaac873" } + # Patch mio 0.6 to use winapi 0.3 and miow 0.3, getting rid of winapi 0.2. # There is not going to be new version of mio 0.6, mio now being >= 0.7.11. [patch.crates-io.mio] diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml index 3d0803e39eac..3d246d919ab3 100644 --- a/supply-chain/audits.toml +++ b/supply-chain/audits.toml @@ -397,6 +397,14 @@ start = "2022-12-16" end = "2024-06-21" notes = "Maintained by the Glean and Application Services teams" +[[wildcard-audits.utf8_iter]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +user-id = 4484 # Henri Sivonen (hsivonen) +start = "2022-04-19" +end = "2024-06-16" +notes = "Maintained by Henri Sivonen who works at Mozilla." + [[wildcard-audits.webdriver]] who = "Henrik Skupin " criteria = "safe-to-deploy" @@ -1185,6 +1193,39 @@ who = "Mike Hommey " criteria = "safe-to-deploy" delta = "0.10.3 -> 0.10.6" +[[audits.diplomat]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "0.5.2" +notes = "This crate is FFI wrapper generator using by ICU4X ffi libraries. This uses unsafe code to convert paramenters, I have reviewed this and generated headers." + +[[audits.diplomat]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +delta = "0.5.2 -> 0.5.2@git:8d125999893fedfdf30595e97334c21ec4b18da9" + +[[audits.diplomat-runtime]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "0.5.2" +notes = "This crate is FFI wrapper generator runtime using by ICU4X ffi libraries. This uses unsafe code for memory access of FFI. I have reviewed carefully." + +[[audits.diplomat-runtime]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +delta = "0.5.2 -> 0.5.2@git:8d125999893fedfdf30595e97334c21ec4b18da9" + +[[audits.diplomat_core]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "0.5.2" +notes = "This crate contains unsafe code, no network and no file access." + +[[audits.diplomat_core]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +delta = "0.5.2 -> 0.5.2@git:8d125999893fedfdf30595e97334c21ec4b18da9" + [[audits.displaydoc]] who = "Makoto Kato " criteria = "safe-to-deploy" @@ -1800,6 +1841,54 @@ who = "Mike Hommey " criteria = "safe-to-run" delta = "0.14.23 -> 0.14.24" +[[audits.icu_capi]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "1.2.2" +notes = "This crate is C/C++ FFI for ICU4X using diplomat crate. no unsafe and no file access etc on this crate." + +[[audits.icu_collections]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "1.2.0" +notes = "This crate is used by ICU4X for internal data structure. There is no fileaccess and network access. This uses unsafe block, but we confirm data is valid before." + +[[audits.icu_locid]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "1.2.0" +notes = "This has unsafe block to handle ascii string in utf-8 string. I've vetted the one instance of unsafe code." + +[[audits.icu_provider]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "1.2.0" +notes = "Although this has unsafe block, this has a commnet why this is safety and I audited code. Also, this doesn't have file access and network access." + +[[audits.icu_provider_adapters]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "1.2.0" +notes = "This is one of ICU4X data provider crates that depends on data type. This has no unsafe code and uses no ambient capabilities." + +[[audits.icu_provider_macros]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "1.2.0" +notes = "This crate is macros for ICU4X's data provider implementer. This has no unsafe code and uses no ambient capabilities." + +[[audits.icu_segmenter]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "1.2.1" +notes = "Original authors are Makoto Kato and Ting-Yu Lin who work at Mozilla. This crate uses unsafe to matrix calculation, but it is safety to check length. And there is no filesystem / network access." + +[[audits.icu_testdata]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "1.2.0" +notes = "This is just ICU4X data only that is generated by ICU4X datagen. Generated data is in unsafe block to use zero-copy implmentation, but it is safety." + [[audits.idna]] who = "Bobby Holley " criteria = "safe-to-deploy" @@ -1896,6 +1985,12 @@ who = "Mike Hommey " criteria = "safe-to-deploy" delta = "0.7.3 -> 0.7.4" +[[audits.libm]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "0.2.6" +notes = "This crate uses unsafe block, but this doesn't have network and file access. I audited code." + [[audits.libsqlite3-sys]] who = "Ben Dean-Kawamura " criteria = "safe-to-deploy" @@ -1912,6 +2007,12 @@ who = "Mike Hommey " criteria = "safe-to-run" delta = "0.5.4 -> 0.5.6" +[[audits.litemap]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "0.7.0" +notes = "This crete has no unsafe code, no file acceess and no network access." + [[audits.lmdb-rkv]] who = "Bobby Holley " criteria = "safe-to-deploy" @@ -3019,6 +3120,18 @@ who = "Mike Hommey " criteria = "safe-to-deploy" delta = "0.4.4 -> 0.4.7" +[[audits.strck]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "0.1.2" +notes = "This crate uses unsafe lock to keep invariant. I auditted code. Also, this doesn't have file access and network access." + +[[audits.strck_ident]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "0.1.2" +notes = "This crate doesn't use unsafe block, network access and filesystem access." + [[audits.subtle]] who = "Simon Friedberger " criteria = "safe-to-deploy" @@ -3318,6 +3431,11 @@ who = "Mike Hommey " criteria = "safe-to-deploy" delta = "0.9.0 -> 0.9.1" +[[audits.unicode-bidi]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +delta = "0.3.8 -> 0.3.13" + [[audits.unicode-ident]] who = "Mike Hommey " criteria = "safe-to-deploy" @@ -4013,12 +4131,54 @@ criteria = "safe-to-deploy" version = "0.1.0" notes = "Written and maintained by Gfx team at Mozilla." +[[audits.writeable]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "0.5.2" +notes = "writeable is a variation of fmt::Write with sink version. This uses `unsafe` block to handle potentially-invalid UTF-8 character. I've vetted the one instance of unsafe code." + [[audits.xmldecl]] who = "Henri Sivonen " criteria = "safe-to-deploy" version = "0.2.0" notes = "I, Henri Sivonen, wrote this crate myself for Gecko even though it's published on crates.io." +[[audits.yoke]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "0.7.1" +notes = "This crate is for zero-copy serialization for ICU4X data structure, and maintained by ICU4X team. Since this uses unsafe block for serialization, I audited code." + +[[audits.yoke-derive]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "0.7.1@git:14e9a3a9857be74582abe2dfa7ab799c5eaac873" +notes = "This crate is a helper for yoke crate that is ICU4X data structure, and maintained by ICU4X team. Since this uses unsafe block for serialization, all has the comment why this uses unsafe and I audited code." + +[[audits.zerofrom]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "0.1.2" +notes = "This crate is zero-copy version of \"From\". This has no unsafe code and uses no ambient capabilities." + +[[audits.zerofrom-derive]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "0.1.2@git:14e9a3a9857be74582abe2dfa7ab799c5eaac873" +notes = "This is custom derives for `ZeroFrom` that is from zerofrom crate. This has no unsafe code and uses no ambient capabilities." + +[[audits.zerovec]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "0.9.4" +notes = "This crate is zero-copy data structure implmentation. Although this uses unsafe block in several code, it requires for zero-copy. And this has a comment in code why this uses unsafe and I audited code." + +[[audits.zerovec-derive]] +who = "Makoto Kato " +criteria = "safe-to-deploy" +version = "0.9.4@git:14e9a3a9857be74582abe2dfa7ab799c5eaac873" +notes = "This is custom derives for `ZeroVec` that is from zerovec crate. Although this uses unsafe block for zero-copy, this has a comment in code why this uses unsafe and I audited code." + [[audits.zip]] who = "Mike Hommey " criteria = "safe-to-run" diff --git a/supply-chain/config.toml b/supply-chain/config.toml index 1729bf2e1549..f1fe526b2852 100644 --- a/supply-chain/config.toml +++ b/supply-chain/config.toml @@ -39,6 +39,18 @@ notes = "This is a pinned version of the upstream code, presumably to get a fix audit-as-crates-io = true notes = "This is upstream plus a warning fix from bug 1823866." +[policy.diplomat] +audit-as-crates-io = true +notes = "Upstream version not to use syn 1.x" + +[policy.diplomat-runtime] +audit-as-crates-io = true +notes = "Upstream version not to use syn 1.x" + +[policy.diplomat_core] +audit-as-crates-io = true +notes = "Upstream version not to use syn 1.x" + [policy.firefox-on-glean] audit-as-crates-io = false notes = "The crates.io version of this is just a placeholder to allow public crates to depend on firefox-on-glean." @@ -64,6 +76,10 @@ notes = "Used for fuzzing." criteria = "safe-to-run" notes = "Used for testing." +[policy.icu_testdata] +audit-as-crates-io = false +notes = "Customized ICU4X baked data only that Gecko wants" + [policy.l10nregistry] dependency-criteria = { fluent-testing = "safe-to-run", tokio = "safe-to-run" } notes = "This crate has two testing-only dependencies which are specified as regular-but-optional rather than a dev-dependencies, because they need to be available to both benchmarks and integration tests." @@ -221,6 +237,18 @@ notes = "Upstream project which we pin." [policy.wr_malloc_size_of] audit-as-crates-io = false +[policy.yoke-derive] +audit-as-crates-io = true +notes = "Upstream version not to use syn 1.x" + +[policy.zerofrom-derive] +audit-as-crates-io = true +notes = "Upstream version not to use syn 1.x" + +[policy.zerovec-derive] +audit-as-crates-io = true +notes = "Upstream version not to use syn 1.x" + [[exemptions.ahash]] version = "0.7.6" criteria = "safe-to-deploy" diff --git a/supply-chain/imports.lock b/supply-chain/imports.lock index 59b5f00de685..b14e7587581c 100644 --- a/supply-chain/imports.lock +++ b/supply-chain/imports.lock @@ -574,6 +574,13 @@ user-id = 48 user-login = "badboy" user-name = "Jan-Erik Rediger" +[[publisher.utf8_iter]] +version = "1.0.3" +when = "2022-09-09" +user-id = 4484 +user-login = "hsivonen" +user-name = "Henri Sivonen" + [[publisher.walkdir]] version = "2.3.2" when = "2021-03-22" diff --git a/third_party/rust/diplomat-runtime/.cargo-checksum.json b/third_party/rust/diplomat-runtime/.cargo-checksum.json new file mode 100644 index 000000000000..105d1c58938e --- /dev/null +++ b/third_party/rust/diplomat-runtime/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"7fc35f8643067872335fe85cf4a6a4289c1b82156cf1216d223b44513b8d0d98","LICENSE-APACHE":"639c20c7f14fb122750d5ad1a6cfb116d9bf8d103e709ee40949e5a12a731666","LICENSE-MIT":"3337fe6e4a3830ad87c23cb9d6d750f9a1e5c45efc08de9c76c1a207fc6966c4","src/lib.rs":"6c019d412bb5534abd3869a16574599dcff730b89a576c3cf4c5590a1d449d17","src/result.rs":"2b07ce3cbb02a141abc35742f307cc4ef2b097ce610e04d92a50c469f354401d","src/wasm_glue.rs":"f26aa119aa291a3cfafc16b73f713a391718294a51e2c656d0093cf1fd2befac","src/writeable.rs":"80d8a93feba545fcb3150b8daf546f3e060b0c8c11f13917409dd455abe0c3bd"},"package":null} \ No newline at end of file diff --git a/third_party/rust/diplomat-runtime/Cargo.toml b/third_party/rust/diplomat-runtime/Cargo.toml new file mode 100644 index 000000000000..4a692e8539c8 --- /dev/null +++ b/third_party/rust/diplomat-runtime/Cargo.toml @@ -0,0 +1,34 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2018" +name = "diplomat-runtime" +version = "0.5.2" +authors = [ + "Shadaj Laddad ", + "Manish Goregaokar ", + "Quinn Okabayashi ", +] +description = "Common runtime utilities used by diplomat codegen" +documentation = "https://docs.rs/diplomat_core/" +keywords = [ + "ffi", + "codegen", +] +categories = ["development-tools"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-diplomat/diplomat" + +[lib] +path = "src/lib.rs" + +[dependencies] diff --git a/third_party/rust/diplomat-runtime/LICENSE-APACHE b/third_party/rust/diplomat-runtime/LICENSE-APACHE new file mode 100644 index 000000000000..05fcffa855c4 --- /dev/null +++ b/third_party/rust/diplomat-runtime/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright 2022 The Diplomat Developers + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/rust/diplomat-runtime/LICENSE-MIT b/third_party/rust/diplomat-runtime/LICENSE-MIT new file mode 100644 index 000000000000..cf62c31bc753 --- /dev/null +++ b/third_party/rust/diplomat-runtime/LICENSE-MIT @@ -0,0 +1,27 @@ +MIT License + +Copyright (c) 2022 The Diplomat Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/rust/diplomat-runtime/src/lib.rs b/third_party/rust/diplomat-runtime/src/lib.rs new file mode 100644 index 000000000000..b6aa6dbb5c6e --- /dev/null +++ b/third_party/rust/diplomat-runtime/src/lib.rs @@ -0,0 +1,33 @@ +#![cfg_attr(not(any(target_arch = "wasm32")), no_std)] + +extern crate alloc; + +use alloc::alloc::Layout; + +#[cfg(target_arch = "wasm32")] +mod wasm_glue; +#[cfg(target_arch = "wasm32")] +pub use wasm_glue::{console_log, console_trace, console_warn}; + +mod writeable; +pub use writeable::DiplomatWriteable; + +mod result; +pub use result::DiplomatResult; + +/// Allocates a buffer of a given size in Rust's memory. +/// +/// # Safety +/// - The allocated buffer must be freed with [`diplomat_free()`]. +#[no_mangle] +pub unsafe extern "C" fn diplomat_alloc(size: usize, align: usize) -> *mut u8 { + alloc::alloc::alloc(Layout::from_size_align(size, align).unwrap()) +} + +/// Frees a buffer that was allocated in Rust's memory. +/// # Safety +/// - `ptr` must be a pointer to a valid buffer allocated by [`diplomat_alloc()`]. +#[no_mangle] +pub unsafe extern "C" fn diplomat_free(ptr: *mut u8, size: usize, align: usize) { + alloc::alloc::dealloc(ptr, Layout::from_size_align(size, align).unwrap()) +} diff --git a/third_party/rust/diplomat-runtime/src/result.rs b/third_party/rust/diplomat-runtime/src/result.rs new file mode 100644 index 000000000000..003281fd436e --- /dev/null +++ b/third_party/rust/diplomat-runtime/src/result.rs @@ -0,0 +1,60 @@ +use core::mem::ManuallyDrop; + +#[repr(C)] +union DiplomatResultValue { + ok: ManuallyDrop, + err: ManuallyDrop, +} + +/// A `Result`-like type that can be passed across the FFI boundary +/// as a value. Use this type when returning a result from an FFI +/// function instead of `Result`. +#[repr(C)] +pub struct DiplomatResult { + value: DiplomatResultValue, + pub is_ok: bool, +} + +impl Drop for DiplomatResult { + fn drop(&mut self) { + unsafe { + if self.is_ok { + let _ = ManuallyDrop::take(&mut self.value.ok); + } else { + let _ = ManuallyDrop::take(&mut self.value.err); + } + } + } +} + +impl From> for DiplomatResult { + fn from(result: Result) -> Self { + match result { + Result::Ok(ok) => DiplomatResult { + value: DiplomatResultValue { + ok: ManuallyDrop::new(ok), + }, + is_ok: true, + }, + + Result::Err(err) => DiplomatResult { + value: DiplomatResultValue { + err: ManuallyDrop::new(err), + }, + is_ok: false, + }, + } + } +} + +impl From> for Result { + fn from(mut result: DiplomatResult) -> Result { + unsafe { + if result.is_ok { + Ok(ManuallyDrop::take(&mut result.value.ok)) + } else { + Err(ManuallyDrop::take(&mut result.value.err)) + } + } + } +} diff --git a/third_party/rust/diplomat-runtime/src/wasm_glue.rs b/third_party/rust/diplomat-runtime/src/wasm_glue.rs new file mode 100644 index 000000000000..5fdc0452186f --- /dev/null +++ b/third_party/rust/diplomat-runtime/src/wasm_glue.rs @@ -0,0 +1,43 @@ +// minimal WASM logger based on https://github.com/DeMille/wasm-glue +extern "C" { + fn trace_js(ptr: *const u8, len: usize); + fn warn_js(ptr: *const u8, len: usize); + fn log_js(ptr: *const u8, len: usize); +} + +/// Throw an exception. +pub fn console_trace(msg: &str) { + unsafe { + trace_js(msg.as_ptr(), msg.len()); + } +} + +/// Write a message to `console.warn`. +pub fn console_warn(msg: &str) { + unsafe { warn_js(msg.as_ptr(), msg.len()) } +} + +/// Write a message to `console.log`. +pub fn console_log(msg: &str) { + unsafe { log_js(msg.as_ptr(), msg.len()) } +} + +#[no_mangle] +pub unsafe extern "C" fn diplomat_init() { + #[cfg(debug_assertions)] + // Sets a custom panic hook using `trace_js`, which by default crates a JS error + std::panic::set_hook(Box::new(|info| { + let file = info.location().unwrap().file(); + let line = info.location().unwrap().line(); + let col = info.location().unwrap().column(); + + let msg = match info.payload().downcast_ref::<&'static str>() { + Some(&s) => s, + None => match info.payload().downcast_ref::() { + Some(s) => s.as_str(), + None => "Box", + }, + }; + console_trace(&format!("Panicked at '{msg}', {file}:{line}:{col}")); + })); +} diff --git a/third_party/rust/diplomat-runtime/src/writeable.rs b/third_party/rust/diplomat-runtime/src/writeable.rs new file mode 100644 index 000000000000..d37f4197b5a5 --- /dev/null +++ b/third_party/rust/diplomat-runtime/src/writeable.rs @@ -0,0 +1,189 @@ +use alloc::boxed::Box; +use alloc::vec::Vec; +use core::ffi::c_void; +use core::{fmt, ptr}; + +/// An object that can one can write UTF-8 strings to +/// +/// This allows the C API to write to arbitrary kinds of objects, for example a +/// C++ std::string or a char buffer. +/// +/// The way to use this object is to fill out the `buf`, `len`, `cap` fields with +/// appropriate values for the buffer, its current length, and its current capacity, +/// and `flush` and `grow` with appropriate callbacks (using `context` to reference any +/// state they need). This object will be passed by mutable reference to the Rust side, +/// and Rust will write to it, calling `grow()` as necessary. Once done, it will call `flush()` +/// to update any state on `context` (e.g. adding a null terminator, updating the length). +/// The object on the foreign side will be directly usable after this, the foreign side +/// need not perform additional state updates after passing an [`DiplomatWriteable`] to +/// a function. +/// +/// [`diplomat_simple_writeable()`] can be used to write to a fixed-size char buffer. +/// +/// May be extended in the future to support further invariants +/// +/// DiplomatWriteable will not perform any cleanup on `context` or `buf`, these are logically +/// "borrows" from the FFI side. +/// +/// # Safety invariants: +/// - `flush()` and `grow()` will be passed `self` including `context` and it should always be safe to do so. +/// `context` may be null, however `flush()` and `grow()` must then be ready to receive it as such. +/// - `buf` must be `cap` bytes long +/// - `grow()` must either return false or update `buf` and `cap` for a valid buffer +/// of at least the requested buffer size +/// - `DiplomatWriteable::flush()` will be automatically called by Diplomat. `flush()` might also be called +/// (erroneously) on the Rust side (it's a public method), so it must be idempotent. +#[repr(C)] +pub struct DiplomatWriteable { + /// Context pointer for additional data needed by `grow()` and `flush()`. May be `null`. + /// + /// The pointer may reference structured data on the foreign side, + /// such as C++ std::string, used to reallocate buf. + context: *mut c_void, + /// The raw string buffer, which will be mutated on the Rust side. + buf: *mut u8, + /// The current filled size of the buffer + len: usize, + /// The current capacity of the buffer + cap: usize, + /// Called by Rust to indicate that there is no more data to write. + /// + /// May be called multiple times. + /// + /// Arguments: + /// - `self` (`*mut DiplomatWriteable`): This `DiplomatWriteable` + flush: extern "C" fn(*mut DiplomatWriteable), + /// Called by Rust to request more capacity in the buffer. The implementation should allocate a new + /// buffer and copy the contents of the old buffer into the new buffer, updating `self.buf` and `self.cap` + /// + /// Arguments: + /// - `self` (`*mut DiplomatWriteable`): This `DiplomatWriteable` + /// - `capacity` (`usize`): The requested capacity. + /// + /// Returns: `true` if the allocation succeeded. Should not update any state if it failed. + grow: extern "C" fn(*mut DiplomatWriteable, usize) -> bool, +} + +impl DiplomatWriteable { + /// Call this function before releasing the buffer to C + pub fn flush(&mut self) { + (self.flush)(self); + } +} +impl fmt::Write for DiplomatWriteable { + fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> { + let needed_len = self.len + s.len(); + if needed_len > self.cap { + let success = (self.grow)(self, needed_len); + if !success { + return Err(fmt::Error); + } + } + debug_assert!(needed_len <= self.cap); + unsafe { + ptr::copy_nonoverlapping(s.as_bytes().as_ptr(), self.buf.add(self.len), s.len()); + } + self.len = needed_len; + Ok(()) + } +} + +/// Create an `DiplomatWriteable` that can write to a fixed-length stack allocated `u8` buffer. +/// +/// Once done, this will append a null terminator to the written string. +/// +/// # Safety +/// +/// - `buf` must be a valid pointer to a region of memory that can hold at `buf_size` bytes +#[no_mangle] +pub unsafe extern "C" fn diplomat_simple_writeable( + buf: *mut u8, + buf_size: usize, +) -> DiplomatWriteable { + extern "C" fn grow(_this: *mut DiplomatWriteable, _cap: usize) -> bool { + false + } + extern "C" fn flush(this: *mut DiplomatWriteable) { + unsafe { + debug_assert!((*this).len <= (*this).cap); + let buf = (*this).buf; + ptr::write(buf.add((*this).len), 0) + } + } + DiplomatWriteable { + context: ptr::null_mut(), + buf, + len: 0, + // keep an extra byte in our pocket for the null terminator + cap: buf_size - 1, + flush, + grow, + } +} + +/// Create an [`DiplomatWriteable`] that can write to a dynamically allocated buffer managed by Rust. +/// +/// Use [`diplomat_buffer_writeable_destroy()`] to free the writable and its underlying buffer. +#[no_mangle] +pub extern "C" fn diplomat_buffer_writeable_create(cap: usize) -> *mut DiplomatWriteable { + extern "C" fn grow(this: *mut DiplomatWriteable, new_cap: usize) -> bool { + unsafe { + let this = this.as_mut().unwrap(); + let mut vec = Vec::from_raw_parts(this.buf, 0, this.cap); + vec.reserve(new_cap); + this.cap = vec.capacity(); + this.buf = vec.as_mut_ptr(); + core::mem::forget(vec); + } + true + } + + extern "C" fn flush(_: *mut DiplomatWriteable) {} + + let mut vec = Vec::::with_capacity(cap); + let ret = DiplomatWriteable { + context: ptr::null_mut(), + buf: vec.as_mut_ptr(), + len: 0, + cap, + flush, + grow, + }; + + core::mem::forget(vec); + Box::into_raw(Box::new(ret)) +} + +/// Grabs a pointer to the underlying buffer of a writable. +/// +/// # Safety +/// - The returned pointer is valid until the passed writable is destroyed. +/// - `this` must be a pointer to a valid [`DiplomatWriteable`] constructed by +/// [`diplomat_buffer_writeable_create()`]. +#[no_mangle] +pub extern "C" fn diplomat_buffer_writeable_get_bytes(this: &DiplomatWriteable) -> *mut u8 { + this.buf +} + +/// Gets the length in bytes of the content written to the writable. +/// +/// # Safety +/// - `this` must be a pointer to a valid [`DiplomatWriteable`] constructed by +/// [`diplomat_buffer_writeable_create()`]. +#[no_mangle] +pub extern "C" fn diplomat_buffer_writeable_len(this: &DiplomatWriteable) -> usize { + this.len +} + +/// Destructor for Rust-memory backed writables. +/// +/// # Safety +/// - `this` must be a pointer to a valid [`DiplomatWriteable`] constructed by +/// [`diplomat_buffer_writeable_create()`]. +#[no_mangle] +pub unsafe extern "C" fn diplomat_buffer_writeable_destroy(this: *mut DiplomatWriteable) { + let this = Box::from_raw(this); + let vec = Vec::from_raw_parts(this.buf, 0, this.cap); + drop(vec); + drop(this); +} diff --git a/third_party/rust/diplomat/.cargo-checksum.json b/third_party/rust/diplomat/.cargo-checksum.json new file mode 100644 index 000000000000..72395383f4f4 --- /dev/null +++ b/third_party/rust/diplomat/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"8ae49bf1abfabd0c4013a0629f806795773baeca9e99605e485c6d9060d5f18e","LICENSE-APACHE":"639c20c7f14fb122750d5ad1a6cfb116d9bf8d103e709ee40949e5a12a731666","LICENSE-MIT":"3337fe6e4a3830ad87c23cb9d6d750f9a1e5c45efc08de9c76c1a207fc6966c4","src/enum_convert.rs":"c0068cb8b563043030186cd9a0be6a4eac1a5f1761fe3646a99528e6d3dc5f54","src/lib.rs":"e606ade5f7cc5b43f56b07511b34fe5c0eb2e53640a347d17585062bf9cdea7c","src/snapshots/diplomat__tests__cfgd_struct.snap":"2874497e83ba3f43541d90869bfa428973c5b23df7fec2826e187d530f1a620b","src/snapshots/diplomat__tests__cfged_method-2.snap":"45f4c58a153cfc8a01d24fcd4474cd7ff84e34ed8b75e718143c16edd884c510","src/snapshots/diplomat__tests__cfged_method.snap":"b478d2d14e01209b45032b092bf91a2068f08f704b2395bc3ebd2ada21141077","src/snapshots/diplomat__tests__method_taking_mutable_slice.snap":"eafa335a999e416a044d32106e096ef57b7f41fb2f74b03d4adce13e7179b03d","src/snapshots/diplomat__tests__method_taking_mutable_str.snap":"e4c65337861a78b3c9762545fcdbccc1169bab9183ff750fc467a5367dba9c56","src/snapshots/diplomat__tests__method_taking_slice.snap":"eb2d7d00381ddef71411c170ce27d2490acfe9322bc3de397fe1cedcedeeee7b","src/snapshots/diplomat__tests__method_taking_str.snap":"92aa38d8618f0d52d5bc967a8d67a87f4b9cdc4f8651c624a9cc7b73033dbaa4","src/snapshots/diplomat__tests__mod_with_enum.snap":"fc225e910aa1afe496eb8d4da4342894f7786c53e12725b2f70018cf5230dddc","src/snapshots/diplomat__tests__mod_with_rust_result.snap":"48e30564d2cf0477db7062c58842b264d0cfec1d635e7dbaf12c12a2e9f1ab31","src/snapshots/diplomat__tests__mod_with_writeable_result.snap":"6ddbc34dbf7d362366cddda70c87a2f25d7ba0821ccbab90b5a79748f1064593","src/snapshots/diplomat__tests__multilevel_borrows.snap":"708fb54c2c3b8498aac83c20af891e12212874b94691fd734fd57f500ce54666","src/snapshots/diplomat__tests__self_params.snap":"1f6652799973e4afa751afebd6306e71ea439640cc1cae9848c5757d060bf699","src/transparent_convert.rs":"dde901986a6709a21f359596e85bc4fd009bb645c79b698d5af8e2a603996ac4"},"package":null} \ No newline at end of file diff --git a/third_party/rust/diplomat/Cargo.toml b/third_party/rust/diplomat/Cargo.toml new file mode 100644 index 000000000000..c0587af469e3 --- /dev/null +++ b/third_party/rust/diplomat/Cargo.toml @@ -0,0 +1,52 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2018" +name = "diplomat" +version = "0.5.2" +authors = [ + "Shadaj Laddad ", + "Manish Goregaokar ", + "Quinn Okabayashi ", +] +description = "The diplomat FFI generation macro" +documentation = "https://docs.rs/diplomat_core/" +keywords = [ + "ffi", + "codegen", +] +categories = ["development-tools"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-diplomat/diplomat" + +[lib] +path = "src/lib.rs" +proc-macro = true + +[dependencies] +proc-macro2 = "1.0.27" +quote = "1.0" + +[dependencies.diplomat_core] +version = "0.5.2" +path = "../core" + +[dependencies.syn] +version = "2.0" +features = [ + "full", + "extra-traits", +] + +[dev-dependencies] +insta = "1.7.1" +tempfile = "3.2.0" diff --git a/third_party/rust/diplomat/LICENSE-APACHE b/third_party/rust/diplomat/LICENSE-APACHE new file mode 100644 index 000000000000..05fcffa855c4 --- /dev/null +++ b/third_party/rust/diplomat/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright 2022 The Diplomat Developers + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/rust/diplomat/LICENSE-MIT b/third_party/rust/diplomat/LICENSE-MIT new file mode 100644 index 000000000000..cf62c31bc753 --- /dev/null +++ b/third_party/rust/diplomat/LICENSE-MIT @@ -0,0 +1,27 @@ +MIT License + +Copyright (c) 2022 The Diplomat Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/rust/diplomat/src/enum_convert.rs b/third_party/rust/diplomat/src/enum_convert.rs new file mode 100644 index 000000000000..0244f320e626 --- /dev/null +++ b/third_party/rust/diplomat/src/enum_convert.rs @@ -0,0 +1,85 @@ +use quote::{quote, ToTokens}; +use syn::parse::{Parse, ParseStream}; +use syn::*; + +// An attribute that is a list of idents +pub struct EnumConvertAttribute { + path: Path, + + needs_wildcard: bool, +} + +impl Parse for EnumConvertAttribute { + fn parse(input: ParseStream) -> Result { + let paths = input.parse_terminated(Path::parse, Token![,])?; + if paths.is_empty() { + return Err(input.error("#[diplomat::enum_convert] needs a path argument")); + } + let needs_wildcard = if paths.len() == 2 { + if let Some(ident) = paths[1].get_ident() { + if ident == "needs_wildcard" { + true + } else { + return Err(input.error( + "#[diplomat::enum_convert] only recognizes needs_wildcard keyword", + )); + } + } else { + return Err( + input.error("#[diplomat::enum_convert] only recognizes needs_wildcard keyword") + ); + } + } else if paths.len() > 1 { + return Err(input.error("#[diplomat::enum_convert] only supports up to two arguments")); + } else { + // no needs_wildcard marker + false + }; + Ok(EnumConvertAttribute { + path: paths[0].clone(), + needs_wildcard, + }) + } +} + +pub fn gen_enum_convert(attr: EnumConvertAttribute, input: ItemEnum) -> proc_macro2::TokenStream { + let mut from_arms = vec![]; + let mut into_arms = vec![]; + + let this_name = &input.ident; + let other_name = &attr.path; + for variant in &input.variants { + if variant.fields != Fields::Unit { + return Error::new(variant.ident.span(), "variant may not have fields") + .to_compile_error(); + } + + let variant_name = &variant.ident; + from_arms.push(quote!(#other_name::#variant_name => Self::#variant_name)); + into_arms.push(quote!(#this_name::#variant_name => Self::#variant_name)); + } + + if attr.needs_wildcard { + let error = format!( + "Encountered unknown field for {}", + other_name.to_token_stream() + ); + from_arms.push(quote!(_ => unreachable!(#error))) + } + quote! { + impl From<#other_name> for #this_name { + fn from(other: #other_name) -> Self { + match other { + #(#from_arms,)* + } + } + } + impl From<#this_name> for #other_name { + fn from(this: #this_name) -> Self { + match this { + #(#into_arms,)* + } + } + } + } +} diff --git a/third_party/rust/diplomat/src/lib.rs b/third_party/rust/diplomat/src/lib.rs new file mode 100644 index 000000000000..19e41d6028ac --- /dev/null +++ b/third_party/rust/diplomat/src/lib.rs @@ -0,0 +1,686 @@ +use proc_macro2::Span; +use quote::{quote, ToTokens}; +use syn::*; + +use diplomat_core::ast; + +mod enum_convert; +mod transparent_convert; + +fn cfgs_to_stream(attrs: &[String]) -> proc_macro2::TokenStream { + attrs.iter().fold(quote!(), |prev, attr| { + let attr = attr.parse::().unwrap(); + quote!(#prev #attr) + }) +} + +fn gen_params_at_boundary(param: &ast::Param, expanded_params: &mut Vec) { + match ¶m.ty { + ast::TypeName::StrReference(_) | ast::TypeName::PrimitiveSlice(..) => { + let data_type = if let ast::TypeName::PrimitiveSlice(.., prim) = ¶m.ty { + ast::TypeName::Primitive(*prim).to_syn().to_token_stream() + } else { + quote! { u8 } + }; + expanded_params.push(FnArg::Typed(PatType { + attrs: vec![], + pat: Box::new(Pat::Ident(PatIdent { + attrs: vec![], + by_ref: None, + mutability: None, + ident: Ident::new(&format!("{}_diplomat_data", param.name), Span::call_site()), + subpat: None, + })), + colon_token: syn::token::Colon(Span::call_site()), + ty: Box::new( + parse2({ + if let ast::TypeName::PrimitiveSlice(_, ast::Mutability::Mutable, _) = + ¶m.ty + { + quote! { *mut #data_type } + } else { + quote! { *const #data_type } + } + }) + .unwrap(), + ), + })); + + expanded_params.push(FnArg::Typed(PatType { + attrs: vec![], + pat: Box::new(Pat::Ident(PatIdent { + attrs: vec![], + by_ref: None, + mutability: None, + ident: Ident::new(&format!("{}_diplomat_len", param.name), Span::call_site()), + subpat: None, + })), + colon_token: syn::token::Colon(Span::call_site()), + ty: Box::new( + parse2(quote! { + usize + }) + .unwrap(), + ), + })); + } + o => { + expanded_params.push(FnArg::Typed(PatType { + attrs: vec![], + pat: Box::new(Pat::Ident(PatIdent { + attrs: vec![], + by_ref: None, + mutability: None, + ident: Ident::new(param.name.as_str(), Span::call_site()), + subpat: None, + })), + colon_token: syn::token::Colon(Span::call_site()), + ty: Box::new(o.to_syn()), + })); + } + } +} + +fn gen_params_invocation(param: &ast::Param, expanded_params: &mut Vec) { + match ¶m.ty { + ast::TypeName::StrReference(_) | ast::TypeName::PrimitiveSlice(..) => { + let data_ident = + Ident::new(&format!("{}_diplomat_data", param.name), Span::call_site()); + let len_ident = Ident::new(&format!("{}_diplomat_len", param.name), Span::call_site()); + + let tokens = if let ast::TypeName::PrimitiveSlice(_, mutability, _) = ¶m.ty { + match mutability { + ast::Mutability::Mutable => quote! { + unsafe { core::slice::from_raw_parts_mut(#data_ident, #len_ident) } + }, + ast::Mutability::Immutable => quote! { + unsafe { core::slice::from_raw_parts(#data_ident, #len_ident) } + }, + } + } else { + // TODO(#57): don't just unwrap? or should we assume that the other side gives us a good value? + quote! { + unsafe { + core::str::from_utf8(core::slice::from_raw_parts(#data_ident, #len_ident)).unwrap() + } + } + }; + expanded_params.push(parse2(tokens).unwrap()); + } + ast::TypeName::Result(_, _, _) => { + let param = ¶m.name; + expanded_params.push(parse2(quote!(#param.into())).unwrap()); + } + _ => { + expanded_params.push(Expr::Path(ExprPath { + attrs: vec![], + qself: None, + path: Ident::new(param.name.as_str(), Span::call_site()).into(), + })); + } + } +} + +fn gen_custom_type_method(strct: &ast::CustomType, m: &ast::Method) -> Item { + let self_ident = Ident::new(strct.name().as_str(), Span::call_site()); + let method_ident = Ident::new(m.name.as_str(), Span::call_site()); + let extern_ident = Ident::new(m.full_path_name.as_str(), Span::call_site()); + + let mut all_params = vec![]; + m.params.iter().for_each(|p| { + gen_params_at_boundary(p, &mut all_params); + }); + + let mut all_params_invocation = vec![]; + m.params.iter().for_each(|p| { + gen_params_invocation(p, &mut all_params_invocation); + }); + + let this_ident = Pat::Ident(PatIdent { + attrs: vec![], + by_ref: None, + mutability: None, + ident: Ident::new("this", Span::call_site()), + subpat: None, + }); + + if let Some(self_param) = &m.self_param { + all_params.insert( + 0, + FnArg::Typed(PatType { + attrs: vec![], + pat: Box::new(this_ident.clone()), + colon_token: syn::token::Colon(Span::call_site()), + ty: Box::new(self_param.to_typename().to_syn()), + }), + ); + } + + let lifetimes = { + let lifetime_env = &m.lifetime_env; + if lifetime_env.is_empty() { + quote! {} + } else { + quote! { <#lifetime_env> } + } + }; + + let method_invocation = if m.self_param.is_some() { + quote! { #this_ident.#method_ident } + } else { + quote! { #self_ident::#method_ident } + }; + + let (return_tokens, maybe_into) = if let Some(return_type) = &m.return_type { + if let ast::TypeName::Result(ok, err, true) = return_type { + let ok = ok.to_syn(); + let err = err.to_syn(); + ( + quote! { -> diplomat_runtime::DiplomatResult<#ok, #err> }, + quote! { .into() }, + ) + } else { + let return_type_syn = return_type.to_syn(); + (quote! { -> #return_type_syn }, quote! {}) + } + } else { + (quote! {}, quote! {}) + }; + + let writeable_flushes = m + .params + .iter() + .filter(|p| p.is_writeable()) + .map(|p| { + let p = &p.name; + quote! { #p.flush(); } + }) + .collect::>(); + + let cfg = cfgs_to_stream(&m.cfg_attrs); + + if writeable_flushes.is_empty() { + Item::Fn(syn::parse_quote! { + #[no_mangle] + #cfg + extern "C" fn #extern_ident#lifetimes(#(#all_params),*) #return_tokens { + #method_invocation(#(#all_params_invocation),*) #maybe_into + } + }) + } else { + Item::Fn(syn::parse_quote! { + #[no_mangle] + #cfg + extern "C" fn #extern_ident#lifetimes(#(#all_params),*) #return_tokens { + let ret = #method_invocation(#(#all_params_invocation),*); + #(#writeable_flushes)* + ret #maybe_into + } + }) + } +} + +struct AttributeInfo { + repr: bool, + opaque: bool, +} + +impl AttributeInfo { + fn extract(attrs: &mut Vec) -> Self { + let mut repr = false; + let mut opaque = false; + attrs.retain(|attr| { + let ident = &attr.path().segments.iter().next().unwrap().ident; + if ident == "repr" { + repr = true; + // don't actually extract repr attrs, just detect them + return true; + } else if ident == "diplomat" { + if attr.path().segments.len() == 2 { + let seg = &attr.path().segments.iter().nth(1).unwrap().ident; + if seg == "opaque" { + opaque = true; + return false; + } else if seg == "rust_link" || seg == "out" { + // diplomat-tool reads these, not diplomat::bridge. + // throw them away so rustc doesn't complain about unknown attributes + return false; + } else if seg == "enum_convert" || seg == "transparent_convert" { + // diplomat::bridge doesn't read this, but it's handled separately + // as an attribute + return true; + } else { + panic!("Only #[diplomat::opaque] and #[diplomat::rust_link] are supported") + } + } else { + panic!("#[diplomat::foo] attrs have a single-segment path name") + } + } + true + }); + + Self { repr, opaque } + } +} + +fn gen_bridge(input: ItemMod) -> ItemMod { + let module = ast::Module::from_syn(&input, true); + let (brace, mut new_contents) = input.content.unwrap(); + + new_contents.iter_mut().for_each(|c| match c { + Item::Struct(s) => { + let info = AttributeInfo::extract(&mut s.attrs); + if info.opaque || !info.repr { + let repr = if info.opaque { + // Normal opaque types don't need repr(transparent) because the inner type is + // never referenced. #[diplomat::transparent_convert] handles adding repr(transparent) + // on its own + quote!() + } else { + quote!(#[repr(C)]) + }; + *s = syn::parse_quote! { + #repr + #s + } + } + } + + Item::Enum(e) => { + let info = AttributeInfo::extract(&mut e.attrs); + if info.opaque { + panic!("#[diplomat::opaque] not allowed on enums") + } + *e = syn::parse_quote! { + #[repr(C)] + #e + }; + } + + Item::Impl(i) => { + for item in &mut i.items { + if let syn::ImplItem::Fn(ref mut m) = *item { + let info = AttributeInfo::extract(&mut m.attrs); + if info.opaque { + panic!("#[diplomat::opaque] not allowed on methods") + } + } + } + } + _ => (), + }); + + for custom_type in module.declared_types.values() { + custom_type.methods().iter().for_each(|m| { + new_contents.push(gen_custom_type_method(custom_type, m)); + }); + + let destroy_ident = Ident::new( + format!("{}_destroy", custom_type.name()).as_str(), + Span::call_site(), + ); + + let type_ident = custom_type.name().to_syn(); + + let (lifetime_defs, lifetimes) = if let Some(lifetime_env) = custom_type.lifetimes() { + ( + quote! { <#lifetime_env> }, + lifetime_env.lifetimes_to_tokens(), + ) + } else { + (quote! {}, quote! {}) + }; + + let cfg = cfgs_to_stream(custom_type.cfg_attrs()); + + // for now, body is empty since all we need to do is drop the box + // TODO(#13): change to take a `*mut` and handle DST boxes appropriately + new_contents.push(Item::Fn(syn::parse_quote! { + #[no_mangle] + #cfg + extern "C" fn #destroy_ident#lifetime_defs(this: Box<#type_ident#lifetimes>) {} + })); + } + + ItemMod { + attrs: input.attrs, + vis: input.vis, + mod_token: input.mod_token, + ident: input.ident, + content: Some((brace, new_contents)), + semi: input.semi, + unsafety: None, + } +} + +/// Mark a module to be exposed through Diplomat-generated FFI. +#[proc_macro_attribute] +pub fn bridge( + _attr: proc_macro::TokenStream, + input: proc_macro::TokenStream, +) -> proc_macro::TokenStream { + let expanded = gen_bridge(parse_macro_input!(input)); + proc_macro::TokenStream::from(expanded.to_token_stream()) +} + +/// Generate From and Into implementations for a Diplomat enum +/// +/// This is invoked as `#[diplomat::enum_convert(OtherEnumName)]` +/// on a Diplomat enum. It will assume the other enum has exactly the same variants +/// and generate From and Into implementations using those. In case that enum is `#[non_exhaustive]`, +/// you may use `#[diplomat::enum_convert(OtherEnumName, needs_wildcard)]` to generate a panicky wildcard +/// branch. It is up to the library author to ensure the enums are kept in sync. You may use the `#[non_exhaustive_omitted_patterns]` +/// lint to enforce this. +#[proc_macro_attribute] +pub fn enum_convert( + attr: proc_macro::TokenStream, + input: proc_macro::TokenStream, +) -> proc_macro::TokenStream { + // proc macros handle compile errors by using special error tokens. + // In case of an error, we don't want the original code to go away too + // (otherwise that will cause more errors) so we hold on to it and we tack it in + // with no modifications below + let input_cached: proc_macro2::TokenStream = input.clone().into(); + let expanded = + enum_convert::gen_enum_convert(parse_macro_input!(attr), parse_macro_input!(input)); + + let full = quote! { + #expanded + #input_cached + }; + proc_macro::TokenStream::from(full.to_token_stream()) +} + +/// Generate conversions from inner types for opaque Diplomat types with a single field +/// +/// This is invoked as `#[diplomat::transparent_convert]` +/// on an opaque Diplomat type. It will add `#[repr(transparent)]` and implement `pub(crate) fn transparent_convert()` +/// which allows constructing an `&Self` from a reference to the inner field. +#[proc_macro_attribute] +pub fn transparent_convert( + _attr: proc_macro::TokenStream, + input: proc_macro::TokenStream, +) -> proc_macro::TokenStream { + // proc macros handle compile errors by using special error tokens. + // In case of an error, we don't want the original code to go away too + // (otherwise that will cause more errors) so we hold on to it and we tack it in + // with no modifications below + let input_cached: proc_macro2::TokenStream = input.clone().into(); + let expanded = transparent_convert::gen_transparent_convert(parse_macro_input!(input)); + + let full = quote! { + #expanded + #input_cached + }; + proc_macro::TokenStream::from(full.to_token_stream()) +} + +#[cfg(test)] +mod tests { + use std::fs::File; + use std::io::{Read, Write}; + use std::process::Command; + + use quote::ToTokens; + use syn::parse_quote; + use tempfile::tempdir; + + use super::gen_bridge; + + fn rustfmt_code(code: &str) -> String { + let dir = tempdir().unwrap(); + let file_path = dir.path().join("temp.rs"); + let mut file = File::create(file_path.clone()).unwrap(); + + writeln!(file, "{code}").unwrap(); + drop(file); + + Command::new("rustfmt") + .arg(file_path.to_str().unwrap()) + .spawn() + .unwrap() + .wait() + .unwrap(); + + let mut file = File::open(file_path).unwrap(); + let mut data = String::new(); + file.read_to_string(&mut data).unwrap(); + drop(file); + dir.close().unwrap(); + data + } + + #[test] + fn method_taking_str() { + insta::assert_display_snapshot!(rustfmt_code( + &gen_bridge(parse_quote! { + mod ffi { + struct Foo {} + + impl Foo { + pub fn from_str(s: &str) { + unimplemented!() + } + } + } + }) + .to_token_stream() + .to_string() + )); + } + + #[test] + fn method_taking_slice() { + insta::assert_display_snapshot!(rustfmt_code( + &gen_bridge(parse_quote! { + mod ffi { + struct Foo {} + + impl Foo { + pub fn from_slice(s: &[f64]) { + unimplemented!() + } + } + } + }) + .to_token_stream() + .to_string() + )); + } + + #[test] + fn method_taking_mutable_slice() { + insta::assert_display_snapshot!(rustfmt_code( + &gen_bridge(parse_quote! { + mod ffi { + struct Foo {} + + impl Foo { + pub fn fill_slice(s: &mut [f64]) { + unimplemented!() + } + } + } + }) + .to_token_stream() + .to_string() + )); + } + + #[test] + fn mod_with_enum() { + insta::assert_display_snapshot!(rustfmt_code( + &gen_bridge(parse_quote! { + mod ffi { + enum Abc { + A, + B = 123, + } + + impl Abc { + pub fn do_something(&self) { + unimplemented!() + } + } + } + }) + .to_token_stream() + .to_string() + )); + } + + #[test] + fn mod_with_writeable_result() { + insta::assert_display_snapshot!(rustfmt_code( + &gen_bridge(parse_quote! { + mod ffi { + struct Foo {} + + impl Foo { + pub fn to_string(&self, to: &mut DiplomatWriteable) -> Result<(), ()> { + unimplemented!() + } + } + } + }) + .to_token_stream() + .to_string() + )); + } + + #[test] + fn mod_with_rust_result() { + insta::assert_display_snapshot!(rustfmt_code( + &gen_bridge(parse_quote! { + mod ffi { + struct Foo {} + + impl Foo { + pub fn bar(&self) -> Result<(), ()> { + unimplemented!() + } + } + } + }) + .to_token_stream() + .to_string() + )); + } + + #[test] + fn multilevel_borrows() { + insta::assert_display_snapshot!(rustfmt_code( + &gen_bridge(parse_quote! { + mod ffi { + #[diplomat::opaque] + struct Foo<'a>(&'a str); + + #[diplomat::opaque] + struct Bar<'b, 'a: 'b>(&'b Foo<'a>); + + struct Baz<'x, 'y> { + foo: &'y Foo<'x>, + } + + impl<'a> Foo<'a> { + pub fn new(x: &'a str) -> Box> { + unimplemented!() + } + + pub fn get_bar<'b>(&'b self) -> Box> { + unimplemented!() + } + + pub fn get_baz<'b>(&'b self) -> Baz<'b, 'a> { + Bax { foo: self } + } + } + } + }) + .to_token_stream() + .to_string() + )); + } + + #[test] + fn self_params() { + insta::assert_display_snapshot!(rustfmt_code( + &gen_bridge(parse_quote! { + mod ffi { + #[diplomat::opaque] + struct RefList<'a> { + data: &'a i32, + next: Option>, + } + + impl<'b> RefList<'b> { + pub fn extend(&mut self, other: &Self) -> Self { + unimplemented!() + } + } + } + }) + .to_token_stream() + .to_string() + )); + } + + #[test] + fn cfged_method() { + insta::assert_display_snapshot!(rustfmt_code( + &gen_bridge(parse_quote! { + mod ffi { + struct Foo {} + + impl Foo { + #[cfg(feature = "foo")] + pub fn bar(s: u8) { + unimplemented!() + } + } + } + }) + .to_token_stream() + .to_string() + )); + + insta::assert_display_snapshot!(rustfmt_code( + &gen_bridge(parse_quote! { + mod ffi { + struct Foo {} + + #[cfg(feature = "bar")] + impl Foo { + #[cfg(feature = "foo")] + pub fn bar(s: u8) { + unimplemented!() + } + } + } + }) + .to_token_stream() + .to_string() + )); + } + + #[test] + fn cfgd_struct() { + insta::assert_display_snapshot!(rustfmt_code( + &gen_bridge(parse_quote! { + mod ffi { + #[diplomat::opaque] + #[cfg(feature = "foo")] + struct Foo {} + #[cfg(feature = "foo")] + impl Foo { + pub fn bar(s: u8) { + unimplemented!() + } + } + } + }) + .to_token_stream() + .to_string() + )); + } +} diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__cfgd_struct.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__cfgd_struct.snap new file mode 100644 index 000000000000..432830917031 --- /dev/null +++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__cfgd_struct.snap @@ -0,0 +1,23 @@ +--- +source: macro/src/lib.rs +expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n #[diplomat :: opaque] #[cfg(feature = \"foo\")] struct Foo {}\n #[cfg(feature = \"foo\")] impl Foo\n { pub fn bar(s : u8) { unimplemented! () } }\n }\n }).to_token_stream().to_string())" +--- +mod ffi { + #[cfg(feature = "foo")] + struct Foo {} + #[cfg(feature = "foo")] + impl Foo { + pub fn bar(s: u8) { + unimplemented!() + } + } + #[no_mangle] + #[cfg(feature = "foo")] + extern "C" fn Foo_bar(s: u8) { + Foo::bar(s) + } + #[no_mangle] + #[cfg(feature = "foo")] + extern "C" fn Foo_destroy(this: Box) {} +} + diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__cfged_method-2.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__cfged_method-2.snap new file mode 100644 index 000000000000..c917e1947de9 --- /dev/null +++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__cfged_method-2.snap @@ -0,0 +1,24 @@ +--- +source: macro/src/lib.rs +expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n struct Foo {} #[cfg(feature = \"bar\")] impl Foo\n {\n #[cfg(feature = \"foo\")] pub fn bar(s : u8)\n { unimplemented! () }\n }\n }\n }).to_token_stream().to_string())" +--- +mod ffi { + #[repr(C)] + struct Foo {} + #[cfg(feature = "bar")] + impl Foo { + #[cfg(feature = "foo")] + pub fn bar(s: u8) { + unimplemented!() + } + } + #[no_mangle] + #[cfg(feature = "bar")] + #[cfg(feature = "foo")] + extern "C" fn Foo_bar(s: u8) { + Foo::bar(s) + } + #[no_mangle] + extern "C" fn Foo_destroy(this: Box) {} +} + diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__cfged_method.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__cfged_method.snap new file mode 100644 index 000000000000..bc4adbb73f89 --- /dev/null +++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__cfged_method.snap @@ -0,0 +1,22 @@ +--- +source: macro/src/lib.rs +expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n struct Foo {} impl Foo\n {\n #[cfg(feature = \"foo\")] pub fn bar(s : u8)\n { unimplemented! () }\n }\n }\n }).to_token_stream().to_string())" +--- +mod ffi { + #[repr(C)] + struct Foo {} + impl Foo { + #[cfg(feature = "foo")] + pub fn bar(s: u8) { + unimplemented!() + } + } + #[no_mangle] + #[cfg(feature = "foo")] + extern "C" fn Foo_bar(s: u8) { + Foo::bar(s) + } + #[no_mangle] + extern "C" fn Foo_destroy(this: Box) {} +} + diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_mutable_slice.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_mutable_slice.snap new file mode 100644 index 000000000000..01fea65c2e42 --- /dev/null +++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_mutable_slice.snap @@ -0,0 +1,20 @@ +--- +source: macro/src/lib.rs +expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n struct Foo {} impl Foo\n { pub fn fill_slice(s : & mut [f64]) { unimplemented! () } }\n }\n }).to_token_stream().to_string())" +--- +mod ffi { + #[repr(C)] + struct Foo {} + impl Foo { + pub fn fill_slice(s: &mut [f64]) { + unimplemented!() + } + } + #[no_mangle] + extern "C" fn Foo_fill_slice(s_diplomat_data: *mut f64, s_diplomat_len: usize) { + Foo::fill_slice(unsafe { core::slice::from_raw_parts_mut(s_diplomat_data, s_diplomat_len) }) + } + #[no_mangle] + extern "C" fn Foo_destroy(this: Box) {} +} + diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_mutable_str.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_mutable_str.snap new file mode 100644 index 000000000000..bebbcf845518 --- /dev/null +++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_mutable_str.snap @@ -0,0 +1,26 @@ +--- +source: macro/src/lib.rs +expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n struct Foo {} impl Foo\n {\n pub fn make_uppercase(s : & mut str) { unimplemented! () }\n }\n }\n }).to_token_stream().to_string())" +--- +mod ffi { + #[repr(C)] + struct Foo {} + impl Foo { + pub fn make_uppercase(s: &mut str) { + unimplemented!() + } + } + #[no_mangle] + extern "C" fn Foo_make_uppercase(s_diplomat_data: *mut u8, s_diplomat_len: usize) { + Foo::make_uppercase(unsafe { + core::str::from_utf8_mut(core::slice::from_raw_parts_mut( + s_diplomat_data, + s_diplomat_len, + )) + .unwrap() + }) + } + #[no_mangle] + extern "C" fn Foo_destroy(this: Box) {} +} + diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_slice.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_slice.snap new file mode 100644 index 000000000000..94daec2af587 --- /dev/null +++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_slice.snap @@ -0,0 +1,20 @@ +--- +source: macro/src/lib.rs +expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n struct Foo {} impl Foo\n { pub fn from_slice(s : & [f64]) { unimplemented! () } }\n }\n }).to_token_stream().to_string())" +--- +mod ffi { + #[repr(C)] + struct Foo {} + impl Foo { + pub fn from_slice(s: &[f64]) { + unimplemented!() + } + } + #[no_mangle] + extern "C" fn Foo_from_slice(s_diplomat_data: *const f64, s_diplomat_len: usize) { + Foo::from_slice(unsafe { core::slice::from_raw_parts(s_diplomat_data, s_diplomat_len) }) + } + #[no_mangle] + extern "C" fn Foo_destroy(this: Box) {} +} + diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_str.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_str.snap new file mode 100644 index 000000000000..7e736e5599ef --- /dev/null +++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__method_taking_str.snap @@ -0,0 +1,23 @@ +--- +source: macro/src/lib.rs +expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n struct Foo {} impl Foo\n { pub fn from_str(s : & str) { unimplemented! () } }\n }\n }).to_token_stream().to_string())" +--- +mod ffi { + #[repr(C)] + struct Foo {} + impl Foo { + pub fn from_str(s: &str) { + unimplemented!() + } + } + #[no_mangle] + extern "C" fn Foo_from_str(s_diplomat_data: *const u8, s_diplomat_len: usize) { + Foo::from_str(unsafe { + core::str::from_utf8(core::slice::from_raw_parts(s_diplomat_data, s_diplomat_len)) + .unwrap() + }) + } + #[no_mangle] + extern "C" fn Foo_destroy(this: Box) {} +} + diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_enum.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_enum.snap new file mode 100644 index 000000000000..723e17d7866b --- /dev/null +++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_enum.snap @@ -0,0 +1,23 @@ +--- +source: macro/src/lib.rs +expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n enum Abc { A, B = 123, } impl Abc\n { pub fn do_something(& self) { unimplemented! () } }\n }\n }).to_token_stream().to_string())" +--- +mod ffi { + #[repr(C)] + enum Abc { + A, + B = 123, + } + impl Abc { + pub fn do_something(&self) { + unimplemented!() + } + } + #[no_mangle] + extern "C" fn Abc_do_something(this: &Abc) { + this.do_something() + } + #[no_mangle] + extern "C" fn Abc_destroy(this: Box) {} +} + diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_rust_result.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_rust_result.snap new file mode 100644 index 000000000000..1eeb28808aae --- /dev/null +++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_rust_result.snap @@ -0,0 +1,20 @@ +--- +source: macro/src/lib.rs +expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n struct Foo {} impl Foo\n {\n pub fn bar(& self) -> Result < (), () >\n { unimplemented! () }\n }\n }\n }).to_token_stream().to_string())" +--- +mod ffi { + #[repr(C)] + struct Foo {} + impl Foo { + pub fn bar(&self) -> Result<(), ()> { + unimplemented!() + } + } + #[no_mangle] + extern "C" fn Foo_bar(this: &Foo) -> diplomat_runtime::DiplomatResult<(), ()> { + this.bar().into() + } + #[no_mangle] + extern "C" fn Foo_destroy(this: Box) {} +} + diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_writeable_result.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_writeable_result.snap new file mode 100644 index 000000000000..870193052f73 --- /dev/null +++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__mod_with_writeable_result.snap @@ -0,0 +1,25 @@ +--- +source: macro/src/lib.rs +expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n struct Foo {} impl Foo\n {\n pub fn to_string(& self, to : & mut DiplomatWriteable) ->\n Result < (), () > { unimplemented! () }\n }\n }\n }).to_token_stream().to_string())" +--- +mod ffi { + #[repr(C)] + struct Foo {} + impl Foo { + pub fn to_string(&self, to: &mut DiplomatWriteable) -> Result<(), ()> { + unimplemented!() + } + } + #[no_mangle] + extern "C" fn Foo_to_string( + this: &Foo, + to: &mut diplomat_runtime::DiplomatWriteable, + ) -> diplomat_runtime::DiplomatResult<(), ()> { + let ret = this.to_string(to); + to.flush(); + ret.into() + } + #[no_mangle] + extern "C" fn Foo_destroy(this: Box) {} +} + diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__multilevel_borrows.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__multilevel_borrows.snap new file mode 100644 index 000000000000..f662608096cc --- /dev/null +++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__multilevel_borrows.snap @@ -0,0 +1,45 @@ +--- +source: macro/src/lib.rs +expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n #[diplomat :: opaque] struct Foo < 'a > (& 'a str) ;\n #[diplomat :: opaque] struct Bar < 'b, 'a : 'b >\n (& 'b Foo < 'a >) ; struct Baz < 'x, 'y >\n { foo : & 'y Foo < 'x >, } impl < 'a > Foo < 'a >\n {\n pub fn new(x : & 'a str) -> Box < Foo < 'a >>\n { unimplemented! () } pub fn get_bar < 'b > (& 'b self) ->\n Box < Bar < 'b, 'a >> { unimplemented! () } pub fn get_baz <\n 'b > (& 'b self) -> Baz < 'b, 'a > { Bax { foo : self } }\n }\n }\n }).to_token_stream().to_string())" +--- +mod ffi { + struct Foo<'a>(&'a str); + struct Bar<'b, 'a: 'b>(&'b Foo<'a>); + #[repr(C)] + struct Baz<'x, 'y> { + foo: &'y Foo<'x>, + } + impl<'a> Foo<'a> { + pub fn new(x: &'a str) -> Box> { + unimplemented!() + } + pub fn get_bar<'b>(&'b self) -> Box> { + unimplemented!() + } + pub fn get_baz<'b>(&'b self) -> Baz<'b, 'a> { + Bax { foo: self } + } + } + #[no_mangle] + extern "C" fn Bar_destroy<'b, 'a: 'b>(this: Box>) {} + #[no_mangle] + extern "C" fn Baz_destroy<'x: 'y, 'y>(this: Box>) {} + #[no_mangle] + extern "C" fn Foo_new<'a>(x_diplomat_data: *const u8, x_diplomat_len: usize) -> Box> { + Foo::new(unsafe { + core::str::from_utf8(core::slice::from_raw_parts(x_diplomat_data, x_diplomat_len)) + .unwrap() + }) + } + #[no_mangle] + extern "C" fn Foo_get_bar<'a: 'b, 'b>(this: &'b Foo<'a>) -> Box> { + this.get_bar() + } + #[no_mangle] + extern "C" fn Foo_get_baz<'a: 'b, 'b>(this: &'b Foo<'a>) -> Baz<'b, 'a> { + this.get_baz() + } + #[no_mangle] + extern "C" fn Foo_destroy<'a>(this: Box>) {} +} + diff --git a/third_party/rust/diplomat/src/snapshots/diplomat__tests__self_params.snap b/third_party/rust/diplomat/src/snapshots/diplomat__tests__self_params.snap new file mode 100644 index 000000000000..6b931197ab41 --- /dev/null +++ b/third_party/rust/diplomat/src/snapshots/diplomat__tests__self_params.snap @@ -0,0 +1,22 @@ +--- +source: macro/src/lib.rs +expression: "rustfmt_code(&gen_bridge(parse_quote! {\n mod ffi\n {\n #[diplomat :: opaque] struct RefList < 'a >\n { data : & 'a i32, next : Option < Box < Self >>, } impl <\n 'b > RefList < 'b >\n {\n pub fn extend(& mut self, other : & Self) -> Self\n { unimplemented! () }\n }\n }\n }).to_token_stream().to_string())" +--- +mod ffi { + struct RefList<'a> { + data: &'a i32, + next: Option>, + } + impl<'b> RefList<'b> { + pub fn extend(&mut self, other: &Self) -> Self { + unimplemented!() + } + } + #[no_mangle] + extern "C" fn RefList_extend<'b>(this: &mut RefList<'b>, other: &RefList<'b>) -> RefList<'b> { + this.extend(other) + } + #[no_mangle] + extern "C" fn RefList_destroy<'a>(this: Box>) {} +} + diff --git a/third_party/rust/diplomat/src/transparent_convert.rs b/third_party/rust/diplomat/src/transparent_convert.rs new file mode 100644 index 000000000000..9ac8bf64e785 --- /dev/null +++ b/third_party/rust/diplomat/src/transparent_convert.rs @@ -0,0 +1,30 @@ +use quote::quote; +use syn::*; + +pub fn gen_transparent_convert(s: ItemStruct) -> proc_macro2::TokenStream { + let mut fields = s.fields.iter(); + let field1 = if let Some(field1) = fields.next() { + &field1.ty + } else { + panic!("#[diplomat::transparent_convert] only allowed on structs with a single field") + }; + + if fields.next().is_some() { + panic!("#[diplomat::transparent_convert] only allowed on structs with a single field") + } + let struct_name = &s.ident; + let (impl_generics, ty_generics, _) = s.generics.split_for_impl(); + let mut impl_generics: Generics = parse_quote!(#impl_generics); + let custom_lifetime: GenericParam = parse_quote!('transparent_convert_outer); + impl_generics.params.push(custom_lifetime); + quote! { + impl #impl_generics #struct_name #ty_generics { + // can potentially add transparent_convert_owned, _mut later + pub(crate) fn transparent_convert(from: &'transparent_convert_outer #field1) -> &'transparent_convert_outer Self { + unsafe { + &*(from as *const #field1 as *const Self) + } + } + } + } +} diff --git a/third_party/rust/diplomat_core/.cargo-checksum.json b/third_party/rust/diplomat_core/.cargo-checksum.json new file mode 100644 index 000000000000..d0548cab6552 --- /dev/null +++ b/third_party/rust/diplomat_core/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"ae4ad17c17bb15562639ac1f33e4870a245ef3e3be44090b7c77a001e27e7847","LICENSE-APACHE":"639c20c7f14fb122750d5ad1a6cfb116d9bf8d103e709ee40949e5a12a731666","LICENSE-MIT":"3337fe6e4a3830ad87c23cb9d6d750f9a1e5c45efc08de9c76c1a207fc6966c4","src/ast/attrs.rs":"df6cfb066fb921c72d1db6caa54e23034c0db98e6ab25269c941a402e910bd5c","src/ast/docs.rs":"254046792b18abbb07a9104d2fabc085e2ee63a69f63655cb1f349eb7d5fcd03","src/ast/enums.rs":"4d08ad2a6082d8c83b5470cf451d78da46a74fec1bd672ec5f6eb034933c1c12","src/ast/idents.rs":"05c7245ce6cb0d46b070f92a4996247545e1699da66d546bfd039a1e3a1a717d","src/ast/lifetimes.rs":"edf23c23de1527a9a628f9c0036998ffee173fd03d77176ec337dc9bc71d5095","src/ast/methods.rs":"193857701ed6fd7dc8b0fec550b3bbfa3c865233d81ece9f75f99e7c7a303b03","src/ast/mod.rs":"3cb72d09defd13487d110fa794390dc2fca5b06bd0918f74d683c6fc26614621","src/ast/modules.rs":"030b5d1a3e85334df0dce0334fbdc39b8a62f351a9b7a44b00cfd3d418297703","src/ast/paths.rs":"469e6184b24567b5c2b445aa69b8a6fcd9dc0682189ebce75050870d7197e523","src/ast/snapshots/diplomat_core__ast__enums__tests__enum_with_discr.snap":"40eeef62000de13291f7c7cb737cd68defc9613c70b6a1660d50a3503c1c67c1","src/ast/snapshots/diplomat_core__ast__enums__tests__simple_enum.snap":"ef3d53415593fc6045c90d53e9a21a8515e3a7fc43859d33d86a03e92413e514","src/ast/snapshots/diplomat_core__ast__methods__tests__cfged_method.snap":"57a28e10b9089324d72bd58c689cd13c6054cae5a501fe4051179df4de4d9fc6","src/ast/snapshots/diplomat_core__ast__methods__tests__nonstatic_methods-2.snap":"4a2b2c5fbef8b0d7a47903e19f82498d2c1cf470287892313bea97a3ddd88ad6","src/ast/snapshots/diplomat_core__ast__methods__tests__nonstatic_methods.snap":"e466d005550cfd12627717f74534cc59f5e6d4e435bf5f99764eb95669afd7d1","src/ast/snapshots/diplomat_core__ast__methods__tests__static_methods-2.snap":"9bb60225e6ca1d676cb88b6482bd23d531d799cbbe54d483dc80cd13b216bc08","src/ast/snapshots/diplomat_core__ast__methods__tests__static_methods.snap":"ddfae79cde8658ccd197c9b92d31f4d9be56e52086797cf4ec3df1026c36d9e5","src/ast/snapshots/diplomat_core__ast__modules__tests__import_in_non_diplomat_not_analyzed.snap":"3e0026f442c6162bb5497a76370f662aa8ca1f9c808edde69739dffc99819b75","src/ast/snapshots/diplomat_core__ast__modules__tests__method_visibility.snap":"8914e0eaecdf855a70966875e700742265feef8137dac74b8d2059ffd972e29b","src/ast/snapshots/diplomat_core__ast__modules__tests__simple_mod.snap":"dc0c4705db8b979e45cd42701282e3380048e0aebedde540528e1180cb872e1b","src/ast/snapshots/diplomat_core__ast__structs__tests__simple_struct.snap":"eb63f34275a6bf03bad5920c96484608061dc7361d8a5da03a9bb60cb53db789","src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-2.snap":"75c377161d51dc0c4d7d91b59b04c1de62b5dffaa1a2c9cac7841ce359f82d9d","src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-3.snap":"418ff306adad93373b277f1a2fa02d1c9e66c54534d2f675288e05dcdec9696f","src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-4.snap":"d247786f82ee693792c1309e89c5ade648c9e53c8c6c337a0eb297a91146d022","src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-5.snap":"9a7b7dde9399f300bfcd739506ded5113021880629d75291b962984ec1e8fe8c","src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-6.snap":"ff1e3b2867786c467ef1148d2837da441a23e4b32d7a284a438ff5c317bafc81","src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-7.snap":"b5a8f071bb237ac52dbc208d78a7b63c938ef23da5954c7d186d06521333d49f","src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes.snap":"6306fae6bc6fbaf5eb679bf3313877259f9ccc09232da568fd98fe8e20eab284","src/ast/snapshots/diplomat_core__ast__types__tests__typename_boxes-2.snap":"97946b1e3118aec7ac7490f0bf38ba45013bb63c5d6bac12e3dd20fc7103348f","src/ast/snapshots/diplomat_core__ast__types__tests__typename_boxes.snap":"e3a1a07e2bfa0869918c973983b658a8e4123203f86a54a743dc6aff6a984f65","src/ast/snapshots/diplomat_core__ast__types__tests__typename_named.snap":"30b58ef9e59641eea9dfba9b965256d7a5d8667e241b7a209eb7d09208d75f7e","src/ast/snapshots/diplomat_core__ast__types__tests__typename_option-2.snap":"c8b559341b0c0c376c4feb666d6cfb37ca8ee57eaae52831b963d8ace8b2e063","src/ast/snapshots/diplomat_core__ast__types__tests__typename_option.snap":"2b9409a8e150badfc2dac1602e8654bfbb88f8795fc71f356ac25be8f67fb4b2","src/ast/snapshots/diplomat_core__ast__types__tests__typename_primitives-2.snap":"506dcd6ea86644d4043229804bf615c8bc34cd20feef2204cd755674bf3cd00f","src/ast/snapshots/diplomat_core__ast__types__tests__typename_primitives-3.snap":"b92cd7f7cb2877c83ed8fac16d27b670e0e9d501cd6b3f70db84b322b686405f","src/ast/snapshots/diplomat_core__ast__types__tests__typename_primitives.snap":"c086765d65faac19f529a03f50ca0566cfe4e9a10b32f608ae4b9c3ad27ffdad","src/ast/snapshots/diplomat_core__ast__types__tests__typename_references-2.snap":"3ced7f6c3e2078d9534dff84e5e4a200efa84bf94435fde478c9e02b4a2b2053","src/ast/snapshots/diplomat_core__ast__types__tests__typename_references.snap":"77d5bcd560adff2216e349e0c87cff988501aef22848fbf1906b6b622ffe47cf","src/ast/snapshots/diplomat_core__ast__types__tests__typename_result-2.snap":"257ca08f5836a21dfd871d11939ba167c336ed3b870e92a64efffca0fd1be028","src/ast/snapshots/diplomat_core__ast__types__tests__typename_result-3.snap":"4210a8443eb02300e75e9eecb303dc2b0d10957901b7f1f82c0c66bc6c202798","src/ast/snapshots/diplomat_core__ast__types__tests__typename_result-4.snap":"2e552e3acfe7334184f6a96b92a2aaf8a3539ea690ba378066159e822ab28927","src/ast/snapshots/diplomat_core__ast__types__tests__typename_result.snap":"78b46313c00d7d2c830dbd482f8373a32ef5ae2104a1c83c74f9f12a62e0c99b","src/ast/snapshots/diplomat_core__ast__validity__tests__non_opaque_move.snap":"306bd6b571d09c4c9818d5b0bf60e2133e91247baa11fcfa38e2fc36d84358ac","src/ast/snapshots/diplomat_core__ast__validity__tests__opaque_checks_with_error.snap":"47febefdb2c7b41ab9ad197686b7729a68a706560dec6d429e0bb845ed67b0a1","src/ast/snapshots/diplomat_core__ast__validity__tests__opaque_checks_with_safe_use.snap":"4d5cd288ce61bd0ddd64bdf48bc9d87230087826597b3da80bb375ae11eaad22","src/ast/snapshots/diplomat_core__ast__validity__tests__opaque_ffi.snap":"229cadc16aa8748d4c53fb74702e240aa68bd4c82cc5912bd4118b99490fdc8d","src/ast/snapshots/diplomat_core__ast__validity__tests__option_invalid.snap":"8047a015af428da524a2f92e219358ebf33c78dff0b4c8b1055aea56db534b2a","src/ast/snapshots/diplomat_core__ast__validity__tests__option_valid.snap":"e4cdd3e7eab0a301a33cafd816fd4d0b52ae4e787dd2b5bd411f4b5c60830b7e","src/ast/snapshots/diplomat_core__ast__validity__tests__zst_non_opaque.snap":"c633eef30f39a376b86bca26338bf89d5ca3b6acc657ece8af144f1fd36cbc4d","src/ast/structs.rs":"84dfbf61253be28f6d5dd88906770f9af68e49950d2378e3581e2d4489cbfb18","src/ast/types.rs":"bc0e0e544387f3309c2fd32bbca176c8b3b38374d030e002ce1b4ea6b75c96e8","src/ast/validity.rs":"2bf93e65295f9ae5144bf04b642df8abe1f73b2db42eae41dcee040c8608b519","src/environment.rs":"2b767884b4e92119a9cfd0d88a47a64966f494f2cf8663729900dcb77bd16588","src/hir/defs.rs":"b035bf46e17ef5225fc430c485b03160f20164af0802689ea5e6ab1e8ebc1afe","src/hir/elision.rs":"f687c62e85fe634e6a086f5dd1871bd2fedfcffc73351fdfe1fea06883e31025","src/hir/lifetimes.rs":"b706f2c62b3217fdf8075fceeb5b0345c76acf1eb39941e182237407485bed5a","src/hir/lowering.rs":"c476cc8fa64d0aa3c67dbf2c51baa7d6b508adcb9db4f635264eebf0a4c10acd","src/hir/methods.rs":"4d5def24154ba6a917d4435555908f4ce6fbe95cd1a3ce4f14b0aa1e44cf38e7","src/hir/mod.rs":"fb5a446e2f94ee32efc5625120c7292d999502603cc5c5cb56fe469207982778","src/hir/paths.rs":"e120abdf0864b7e87c4c706fb4e4ad76db89049f3eeffdd3246bec4d091d8155","src/hir/primitives.rs":"c1cf8202aa95331590777a4f429ea5d68da4f64ddc8eddadce612246416953d3","src/hir/snapshots/diplomat_core__hir__elision__tests__borrowing_fields.snap":"eafdd16fb9ebfcebebd0517f361f8653b00275318aa27e44086a860b6f0bc39d","src/hir/snapshots/diplomat_core__hir__elision__tests__simple_mod.snap":"935af3ef7d70a9e9e659fcf2215e18f41bc32ab034430d7303d534cd0e294909","src/hir/ty_position.rs":"87fad133539d7c9bda7900791923d8c5198b33dbe368336e0ecf9e629781b4cf","src/hir/type_context.rs":"bc1c1e84639d724973a5d5acb108501e7414399ee6bcd2ceb4b11c700ab148b3","src/hir/types.rs":"01122d50f86dc5caaf31d844d2f8e37bfe1c7a88884b78128701d0f97d37247f","src/lib.rs":"23da7804b822960757426835da904118c7afafa59cf631fb1d4b946c7af28f64"},"package":null} \ No newline at end of file diff --git a/third_party/rust/diplomat_core/Cargo.toml b/third_party/rust/diplomat_core/Cargo.toml new file mode 100644 index 000000000000..cb9b45a1d0e4 --- /dev/null +++ b/third_party/rust/diplomat_core/Cargo.toml @@ -0,0 +1,66 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2021" +name = "diplomat_core" +version = "0.5.2" +authors = [ + "Shadaj Laddad ", + "Manish Goregaokar ", + "Quinn Okabayashi ", +] +description = "Shared utilities between Diplomat macros and code generation" +documentation = "https://docs.rs/diplomat_core/" +keywords = [ + "ffi", + "codegen", +] +categories = ["development-tools"] +license = "MIT/Apache-2.0" +repository = "https://github.com/rust-diplomat/diplomat" + +[package.metadata.docs.rs] +all-features = true + +[lib] +path = "src/lib.rs" + +[dependencies] +lazy_static = "1.4.0" +proc-macro2 = "1.0.27" +quote = "1.0" +smallvec = "1.9.0" + +[dependencies.displaydoc] +version = "0.2" +optional = true + +[dependencies.serde] +version = "1.0" +features = ["derive"] + +[dependencies.strck_ident] +version = "0.1" +features = ["rust"] + +[dependencies.syn] +version = "2" +features = [ + "full", + "extra-traits", +] + +[dev-dependencies] +insta = "1.7.1" + +[features] +hir = [] diff --git a/third_party/rust/diplomat_core/LICENSE-APACHE b/third_party/rust/diplomat_core/LICENSE-APACHE new file mode 100644 index 000000000000..05fcffa855c4 --- /dev/null +++ b/third_party/rust/diplomat_core/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright 2022 The Diplomat Developers + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/third_party/rust/diplomat_core/LICENSE-MIT b/third_party/rust/diplomat_core/LICENSE-MIT new file mode 100644 index 000000000000..cf62c31bc753 --- /dev/null +++ b/third_party/rust/diplomat_core/LICENSE-MIT @@ -0,0 +1,27 @@ +MIT License + +Copyright (c) 2022 The Diplomat Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/third_party/rust/diplomat_core/src/ast/attrs.rs b/third_party/rust/diplomat_core/src/ast/attrs.rs new file mode 100644 index 000000000000..43b5fed9e0ff --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/attrs.rs @@ -0,0 +1,10 @@ +//! This module contains utilities for dealing with Rust attributes + +use syn::Attribute; + +pub(crate) fn extract_cfg_attrs(attrs: &[Attribute]) -> impl Iterator + '_ { + attrs + .iter() + .filter(|&a| a.path().is_ident("cfg")) + .map(|a| quote::quote!(#a).to_string()) +} diff --git a/third_party/rust/diplomat_core/src/ast/docs.rs b/third_party/rust/diplomat_core/src/ast/docs.rs new file mode 100644 index 000000000000..058384857981 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/docs.rs @@ -0,0 +1,431 @@ +use super::Path; +use core::fmt; +use quote::ToTokens; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; +use syn::parse::{self, Parse, ParseStream}; +use syn::{Attribute, Ident, Meta, Token}; + +#[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Debug, Default)] +pub struct Docs(String, Vec); + +/// The type of markdown generated by [`Docs::to_markdown()`] +/// +/// Note that this only controls markdown generated by this code. Existing markdown +/// in the Rust documentation will not be sanitized in any way. +#[derive(PartialEq, Eq, Clone, Debug)] +pub enum MarkdownStyle { + /// Regular markdown with no specific extensions, compatible with most common flavors + Normal, + /// Markdown that can be losslessly converted to ReStructuredText + RstCompat, +} + +impl Docs { + pub fn from_attrs(attrs: &[Attribute]) -> Self { + Self(Self::get_doc_lines(attrs), Self::get_rust_link(attrs)) + } + + fn get_doc_lines(attrs: &[Attribute]) -> String { + let mut lines: String = String::new(); + + attrs.iter().for_each(|attr| { + if let Meta::NameValue(ref nv) = attr.meta { + if nv.path.is_ident("doc") { + let node: syn::LitStr = syn::parse2(nv.value.to_token_stream()).unwrap(); + let line = node.value().trim().to_string(); + + if !lines.is_empty() { + lines.push('\n'); + } + + lines.push_str(&line); + } + } + }); + + lines + } + + fn get_rust_link(attrs: &[Attribute]) -> Vec { + attrs + .iter() + .filter(|i| i.path().to_token_stream().to_string() == "diplomat :: rust_link") + .map(|i| i.parse_args().expect("Malformed attribute")) + .collect() + } + + pub fn is_empty(&self) -> bool { + self.0.is_empty() && self.1.is_empty() + } + + /// Convert to markdown + pub fn to_markdown(&self, docs_url_gen: &DocsUrlGenerator, style: MarkdownStyle) -> String { + use std::fmt::Write; + let mut lines = self.0.clone(); + let mut has_compact = false; + let backtick = if style == MarkdownStyle::RstCompat { + "" + } else { + "`" + }; + for rust_link in &self.1 { + if rust_link.display == RustLinkDisplay::Compact { + has_compact = true; + } else if rust_link.display == RustLinkDisplay::Normal { + write!( + lines, + "\n\nSee the [Rust documentation for {backtick}{name}{backtick}]({link}) for more information.", + name = rust_link.path.elements.last().unwrap(), + link = docs_url_gen.gen_for_rust_link(rust_link) + ) + .unwrap(); + } + } + if has_compact { + write!(lines, "\n\n Additional information: ").unwrap(); + for (i, rust_link) in self + .1 + .iter() + .filter(|r| r.display == RustLinkDisplay::Compact) + .enumerate() + { + if i != 0 { + write!(lines, ", ").unwrap(); + } + write!( + lines, + "[{}]({})", + i + 1, + docs_url_gen.gen_for_rust_link(rust_link) + ) + .unwrap(); + } + } + lines + } + + pub fn rust_links(&self) -> &[RustLink] { + &self.1 + } +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)] +pub enum RustLinkDisplay { + /// A nice expanded representation that includes the type name + /// + /// e.g. "See the \[link to Rust documentation\] for more details" + Normal, + /// A compact representation that will fit multiple rust_link entries in one line + /// + /// E.g. "For further information, see: 1, 2, 3, 4" (all links) + Compact, + /// Hidden. Useful for programmatically annotating an API as related without showing a link to the user + Hidden, +} + +#[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Debug, PartialOrd, Ord)] +pub struct RustLink { + pub path: Path, + pub typ: DocType, + pub display: RustLinkDisplay, +} + +impl Parse for RustLink { + fn parse(input: ParseStream<'_>) -> parse::Result { + let path = input.parse()?; + let path = Path::from_syn(&path); + let _comma: Token![,] = input.parse()?; + let ty_ident: Ident = input.parse()?; + let typ = match &*ty_ident.to_string() { + "Struct" => DocType::Struct, + "StructField" => DocType::StructField, + "Enum" => DocType::Enum, + "EnumVariant" => DocType::EnumVariant, + "EnumVariantField" => DocType::EnumVariantField, + "Trait" => DocType::Trait, + "FnInStruct" => DocType::FnInStruct, + "FnInEnum" => DocType::FnInEnum, + "FnInTrait" => DocType::FnInTrait, + "DefaultFnInTrait" => DocType::DefaultFnInTrait, + "Fn" => DocType::Fn, + "Mod" => DocType::Mod, + "Constant" => DocType::Constant, + "AssociatedConstantInEnum" => DocType::AssociatedConstantInEnum, + "AssociatedConstantInTrait" => DocType::AssociatedConstantInTrait, + "AssociatedConstantInStruct" => DocType::AssociatedConstantInStruct, + "Macro" => DocType::Macro, + "AssociatedTypeInEnum" => DocType::AssociatedTypeInEnum, + "AssociatedTypeInTrait" => DocType::AssociatedTypeInTrait, + "AssociatedTypeInStruct" => DocType::AssociatedTypeInStruct, + "Typedef" => DocType::Typedef, + _ => { + return Err(parse::Error::new( + ty_ident.span(), + "Unknown rust_link doc type", + )) + } + }; + let lookahead = input.lookahead1(); + let display = if lookahead.peek(Token![,]) { + let _comma: Token![,] = input.parse()?; + let display_ident: Ident = input.parse()?; + match &*display_ident.to_string() { + "normal" => RustLinkDisplay::Normal, + "compact" => RustLinkDisplay::Compact, + "hidden" => RustLinkDisplay::Hidden, + _ => return Err(parse::Error::new(display_ident.span(), "Unknown rust_link display style: Must be must be `normal`, `compact`, or `hidden`.")), + } + } else { + RustLinkDisplay::Normal + }; + Ok(RustLink { path, typ, display }) + } +} +impl fmt::Display for RustLink { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}#{:?}", self.path, self.typ) + } +} + +#[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Debug, PartialOrd, Ord)] +pub enum DocType { + Struct, + StructField, + Enum, + EnumVariant, + EnumVariantField, + Trait, + FnInStruct, + FnInEnum, + FnInTrait, + DefaultFnInTrait, + Fn, + Mod, + Constant, + AssociatedConstantInEnum, + AssociatedConstantInTrait, + AssociatedConstantInStruct, + Macro, + AssociatedTypeInEnum, + AssociatedTypeInTrait, + AssociatedTypeInStruct, + Typedef, +} + +#[derive(Default)] +pub struct DocsUrlGenerator { + default_url: Option, + base_urls: HashMap, +} + +impl DocsUrlGenerator { + pub fn with_base_urls(default_url: Option, base_urls: HashMap) -> Self { + Self { + default_url, + base_urls, + } + } + + fn gen_for_rust_link(&self, rust_link: &RustLink) -> String { + use DocType::*; + + let mut r = String::new(); + + let base = self + .base_urls + .get(rust_link.path.elements[0].as_str()) + .map(String::as_str) + .or(self.default_url.as_deref()) + .unwrap_or("https://docs.rs/"); + + r.push_str(base); + if !base.ends_with('/') { + r.push('/'); + } + if r == "https://docs.rs/" { + r.push_str(rust_link.path.elements[0].as_str()); + r.push_str("/latest/"); + } + + let mut elements = rust_link.path.elements.iter().peekable(); + + let module_depth = rust_link.path.elements.len() + - match rust_link.typ { + Mod => 0, + Struct | Enum | Trait | Fn | Macro | Constant | Typedef => 1, + FnInEnum + | FnInStruct + | FnInTrait + | DefaultFnInTrait + | EnumVariant + | StructField + | AssociatedTypeInEnum + | AssociatedTypeInStruct + | AssociatedTypeInTrait + | AssociatedConstantInEnum + | AssociatedConstantInStruct + | AssociatedConstantInTrait => 2, + EnumVariantField => 3, + }; + + for _ in 0..module_depth { + r.push_str(elements.next().unwrap().as_str()); + r.push('/'); + } + + if elements.peek().is_none() { + r.push_str("index.html"); + return r; + } + + r.push_str(match rust_link.typ { + Typedef => "type.", + Struct + | StructField + | FnInStruct + | AssociatedTypeInStruct + | AssociatedConstantInStruct => "struct.", + Enum + | EnumVariant + | EnumVariantField + | FnInEnum + | AssociatedTypeInEnum + | AssociatedConstantInEnum => "enum.", + Trait + | FnInTrait + | DefaultFnInTrait + | AssociatedTypeInTrait + | AssociatedConstantInTrait => "trait.", + Fn => "fn.", + Constant => "constant.", + Macro => "macro.", + Mod => unreachable!(), + }); + + r.push_str(elements.next().unwrap().as_str()); + + r.push_str(".html"); + + match rust_link.typ { + FnInStruct | FnInEnum | DefaultFnInTrait => { + r.push_str("#method."); + r.push_str(elements.next().unwrap().as_str()); + } + AssociatedTypeInStruct | AssociatedTypeInEnum | AssociatedTypeInTrait => { + r.push_str("#associatedtype."); + r.push_str(elements.next().unwrap().as_str()); + } + AssociatedConstantInStruct | AssociatedConstantInEnum | AssociatedConstantInTrait => { + r.push_str("#associatedconstant."); + r.push_str(elements.next().unwrap().as_str()); + } + FnInTrait => { + r.push_str("#tymethod."); + r.push_str(elements.next().unwrap().as_str()); + } + EnumVariant => { + r.push_str("#variant."); + r.push_str(elements.next().unwrap().as_str()); + } + StructField => { + r.push_str("#structfield."); + r.push_str(elements.next().unwrap().as_str()); + } + EnumVariantField => { + r.push_str("#variant."); + r.push_str(elements.next().unwrap().as_str()); + r.push_str(".field."); + r.push_str(elements.next().unwrap().as_str()); + } + _ => {} + } + r + } +} + +#[test] +fn test_docs_url_generator() { + let test_cases = [ + ( + syn::parse_quote! { #[diplomat::rust_link(std::foo::bar::batz, Struct)] }, + "https://docs.rs/std/latest/std/foo/bar/struct.batz.html", + ), + ( + syn::parse_quote! { #[diplomat::rust_link(std::foo::bar::batz, StructField)] }, + "https://docs.rs/std/latest/std/foo/struct.bar.html#structfield.batz", + ), + ( + syn::parse_quote! { #[diplomat::rust_link(std::foo::bar::batz, Enum)] }, + "https://docs.rs/std/latest/std/foo/bar/enum.batz.html", + ), + ( + syn::parse_quote! { #[diplomat::rust_link(std::foo::bar::batz, EnumVariant)] }, + "https://docs.rs/std/latest/std/foo/enum.bar.html#variant.batz", + ), + ( + syn::parse_quote! { #[diplomat::rust_link(std::foo::bar::batz, EnumVariantField)] }, + "https://docs.rs/std/latest/std/enum.foo.html#variant.bar.field.batz", + ), + ( + syn::parse_quote! { #[diplomat::rust_link(std::foo::bar::batz, Trait)] }, + "https://docs.rs/std/latest/std/foo/bar/trait.batz.html", + ), + ( + syn::parse_quote! { #[diplomat::rust_link(std::foo::bar::batz, FnInStruct)] }, + "https://docs.rs/std/latest/std/foo/struct.bar.html#method.batz", + ), + ( + syn::parse_quote! { #[diplomat::rust_link(std::foo::bar::batz, FnInEnum)] }, + "https://docs.rs/std/latest/std/foo/enum.bar.html#method.batz", + ), + ( + syn::parse_quote! { #[diplomat::rust_link(std::foo::bar::batz, FnInTrait)] }, + "https://docs.rs/std/latest/std/foo/trait.bar.html#tymethod.batz", + ), + ( + syn::parse_quote! { #[diplomat::rust_link(std::foo::bar::batz, DefaultFnInTrait)] }, + "https://docs.rs/std/latest/std/foo/trait.bar.html#method.batz", + ), + ( + syn::parse_quote! { #[diplomat::rust_link(std::foo::bar::batz, Fn)] }, + "https://docs.rs/std/latest/std/foo/bar/fn.batz.html", + ), + ( + syn::parse_quote! { #[diplomat::rust_link(std::foo::bar::batz, Mod)] }, + "https://docs.rs/std/latest/std/foo/bar/batz/index.html", + ), + ( + syn::parse_quote! { #[diplomat::rust_link(std::foo::bar::batz, Constant)] }, + "https://docs.rs/std/latest/std/foo/bar/constant.batz.html", + ), + ( + syn::parse_quote! { #[diplomat::rust_link(std::foo::bar::batz, Macro)] }, + "https://docs.rs/std/latest/std/foo/bar/macro.batz.html", + ), + ]; + + for (attr, expected) in test_cases.clone() { + assert_eq!( + DocsUrlGenerator::default().gen_for_rust_link(&Docs::from_attrs(&[attr]).1[0]), + expected + ); + } + + assert_eq!( + DocsUrlGenerator::with_base_urls( + None, + [("std".to_string(), "http://std-docs.biz/".to_string())] + .into_iter() + .collect() + ) + .gen_for_rust_link(&Docs::from_attrs(&[test_cases[0].0.clone()]).1[0]), + "http://std-docs.biz/std/foo/bar/struct.batz.html" + ); + + assert_eq!( + DocsUrlGenerator::with_base_urls(Some("http://std-docs.biz/".to_string()), HashMap::new()) + .gen_for_rust_link(&Docs::from_attrs(&[test_cases[0].0.clone()]).1[0]), + "http://std-docs.biz/std/foo/bar/struct.batz.html" + ); +} diff --git a/third_party/rust/diplomat_core/src/ast/enums.rs b/third_party/rust/diplomat_core/src/ast/enums.rs new file mode 100644 index 000000000000..ed60a205cebc --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/enums.rs @@ -0,0 +1,112 @@ +use serde::{Deserialize, Serialize}; + +use super::docs::Docs; +use super::{attrs, Ident, Method}; +use quote::ToTokens; + +/// A fieldless enum declaration in an FFI module. +#[derive(Clone, Serialize, Deserialize, Debug, Hash, PartialEq, Eq)] +pub struct Enum { + pub name: Ident, + pub docs: Docs, + /// A list of variants of the enum. (name, discriminant, docs) + pub variants: Vec<(Ident, isize, Docs)>, + pub methods: Vec, + pub cfg_attrs: Vec, +} + +impl From<&syn::ItemEnum> for Enum { + /// Extract an [`Enum`] metadata value from an AST node. + fn from(enm: &syn::ItemEnum) -> Enum { + let mut last_discriminant = -1; + if !enm.generics.params.is_empty() { + // Generic types are not allowed. + // Assuming all enums cannot have lifetimes? We don't even have a + // `lifetimes` field. If we change our minds we can adjust this later + // and update the `CustomType::lifetimes` API accordingly. + panic!("Enums cannot have generic parameters"); + } + + let cfg_attrs = attrs::extract_cfg_attrs(&enm.attrs).collect(); + Enum { + name: (&enm.ident).into(), + docs: Docs::from_attrs(&enm.attrs), + variants: enm + .variants + .iter() + .map(|v| { + let new_discriminant = v + .discriminant + .as_ref() + .map(|d| { + // Reparsing, signed literals are represented + // as a negation expression + let lit: Result = syn::parse2(d.1.to_token_stream()); + if let Ok(syn::Lit::Int(ref lit_int)) = lit { + lit_int.base10_parse::().unwrap() + } else { + panic!("Expected a discriminant to be a constant integer"); + } + }) + .unwrap_or_else(|| last_discriminant + 1); + + last_discriminant = new_discriminant; + + ( + (&v.ident).into(), + new_discriminant, + Docs::from_attrs(&v.attrs), + ) + }) + .collect(), + methods: vec![], + cfg_attrs, + } + } +} + +#[cfg(test)] +mod tests { + use insta::{self, Settings}; + + use syn; + + use super::Enum; + + #[test] + fn simple_enum() { + let mut settings = Settings::new(); + settings.set_sort_maps(true); + + settings.bind(|| { + insta::assert_yaml_snapshot!(Enum::from(&syn::parse_quote! { + /// Some docs. + #[diplomat::rust_link(foo::Bar, Enum)] + enum MyLocalEnum { + Abc, + /// Some more docs. + Def + } + })); + }); + } + + #[test] + fn enum_with_discr() { + let mut settings = Settings::new(); + settings.set_sort_maps(true); + + settings.bind(|| { + insta::assert_yaml_snapshot!(Enum::from(&syn::parse_quote! { + /// Some docs. + #[diplomat::rust_link(foo::Bar, Enum)] + enum DiscriminantedEnum { + Abc = -1, + Def = 0, + Ghi = 1, + Jkl = 2, + } + })); + }); + } +} diff --git a/third_party/rust/diplomat_core/src/ast/idents.rs b/third_party/rust/diplomat_core/src/ast/idents.rs new file mode 100644 index 000000000000..2177923b5d2d --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/idents.rs @@ -0,0 +1,86 @@ +use proc_macro2::Span; +use quote::{ToTokens, TokenStreamExt}; +use serde::{Deserialize, Serialize}; +use std::borrow::{Borrow, Cow}; +use std::fmt; + +/// An identifier, analogous to `syn::Ident` and `proc_macro2::Ident`. +#[derive(Hash, Eq, PartialEq, Serialize, Clone, Debug, Ord, PartialOrd)] +#[serde(transparent)] +pub struct Ident(Cow<'static, str>); + +impl Ident { + /// Validate a string + fn validate(string: &str) -> syn::Result<()> { + syn::parse_str::(string).map(|_| {}) + } + + /// Attempt to create a new `Ident`. + /// + /// This function fails if the input isn't valid according to + /// `proc_macro2::Ident`'s invariants. + pub fn try_new(string: String) -> syn::Result { + Self::validate(&string).map(|_| Self(Cow::from(string))) + } + + pub fn to_syn(&self) -> syn::Ident { + syn::Ident::new(self.as_str(), Span::call_site()) + } + + /// Get the `&str` representation. + pub fn as_str(&self) -> &str { + &self.0 + } + + /// An [`Ident`] containing "this". + pub const THIS: Self = Ident(Cow::Borrowed("this")); +} + +impl From<&'static str> for Ident { + fn from(string: &'static str) -> Self { + Self::validate(string).unwrap(); + Self(Cow::from(string)) + } +} + +impl From for Ident { + fn from(string: String) -> Self { + Self::validate(&string).unwrap(); + Self(Cow::from(string)) + } +} + +impl<'de> Deserialize<'de> for Ident { + /// The derived `Deserialize` allows for creating `Ident`s that do not uphold + /// the proper invariants. This custom impl ensures that this cannot happen. + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + Ok(Ident::from(String::deserialize(deserializer)?)) + } +} + +impl Borrow for Ident { + fn borrow(&self) -> &str { + self.as_str() + } +} + +impl fmt::Display for Ident { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.as_str().fmt(f) + } +} + +impl From<&syn::Ident> for Ident { + fn from(ident: &syn::Ident) -> Self { + Self(Cow::from(ident.to_string())) + } +} + +impl ToTokens for Ident { + fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) { + tokens.append(self.to_syn()); + } +} diff --git a/third_party/rust/diplomat_core/src/ast/lifetimes.rs b/third_party/rust/diplomat_core/src/ast/lifetimes.rs new file mode 100644 index 000000000000..5530d59db862 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/lifetimes.rs @@ -0,0 +1,573 @@ +use proc_macro2::Span; +use quote::{quote, ToTokens}; +use serde::{Deserialize, Serialize}; +use std::fmt; + +use super::{Docs, Ident, Param, SelfParam, TypeName}; + +/// A named lifetime, e.g. `'a`. +/// +/// # Invariants +/// +/// Cannot be `'static` or `'_`, use [`Lifetime`] to represent those instead. +#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, PartialOrd, Ord)] +#[serde(transparent)] +pub struct NamedLifetime(Ident); + +impl NamedLifetime { + pub fn name(&self) -> &Ident { + &self.0 + } +} + +impl<'de> Deserialize<'de> for NamedLifetime { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + // Special `Deserialize` impl to ensure invariants. + let named = Ident::deserialize(deserializer)?; + if named.as_str() == "static" { + panic!("cannot be static"); + } + Ok(NamedLifetime(named)) + } +} + +impl From<&syn::Lifetime> for NamedLifetime { + fn from(lt: &syn::Lifetime) -> Self { + Lifetime::from(lt).to_named().expect("cannot be static") + } +} + +impl From<&NamedLifetime> for NamedLifetime { + fn from(this: &NamedLifetime) -> Self { + this.clone() + } +} + +impl PartialEq for NamedLifetime { + fn eq(&self, other: &syn::Lifetime) -> bool { + other.ident == self.0.as_str() + } +} + +impl fmt::Display for NamedLifetime { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "'{}", self.0) + } +} + +impl ToTokens for NamedLifetime { + fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) { + use proc_macro2::{Punct, Spacing}; + Punct::new('\'', Spacing::Joint).to_tokens(tokens); + self.0.to_tokens(tokens); + } +} + +/// A lifetime dependency graph used for tracking which lifetimes outlive, +/// and are outlived by, other lifetimes. +/// +/// It is similar to [`syn::LifetimeDef`], except it can also track lifetime +/// bounds defined in the `where` clause. +#[derive(Clone, PartialEq, Eq, Hash, Debug)] +pub struct LifetimeEnv { + pub(crate) nodes: Vec, +} + +impl LifetimeEnv { + /// Construct an empty [`LifetimeEnv`]. + /// + /// To create one outside of this module, use `LifetimeEnv::from_method_item` + /// or `LifetimeEnv::from` on `&syn::Generics`. + fn new() -> Self { + Self { nodes: vec![] } + } + + /// Iterate through the names of the lifetimes in scope. + pub fn names(&self) -> impl Iterator + Clone { + self.nodes.iter().map(|node| &node.lifetime) + } + + /// Returns a [`LifetimeEnv`] for a method, accounting for lifetimes and bounds + /// defined in both the impl block and the method, as well as implicit lifetime + /// bounds in the optional `self` param, other param, and optional return type. + /// For example, the type `&'a Foo<'b>` implies `'b: 'a`. + pub fn from_method_item( + method: &syn::ImplItemFn, + impl_generics: Option<&syn::Generics>, + self_param: Option<&SelfParam>, + params: &[Param], + return_type: Option<&TypeName>, + ) -> Self { + let mut this = LifetimeEnv::new(); + // The impl generics _must_ be loaded into the env first, since the method + // generics might use lifetimes defined in the impl, and `extend_generics` + // panics if `'a: 'b` where `'b` isn't declared by the time it finishes. + if let Some(generics) = impl_generics { + this.extend_generics(generics); + } + this.extend_generics(&method.sig.generics); + + if let Some(self_param) = self_param { + this.extend_implicit_lifetime_bounds(&self_param.to_typename(), None); + } + for param in params { + this.extend_implicit_lifetime_bounds(¶m.ty, None); + } + if let Some(return_type) = return_type { + this.extend_implicit_lifetime_bounds(return_type, None); + } + + this + } + + /// Returns a [`LifetimeEnv`] for a struct, accounding for lifetimes and bounds + /// defined in the struct generics, as well as implicit lifetime bounds in + /// the struct's fields. For example, the field `&'a Foo<'b>` implies `'b: 'a`. + pub fn from_struct_item(strct: &syn::ItemStruct, fields: &[(Ident, TypeName, Docs)]) -> Self { + let mut this = LifetimeEnv::new(); + this.extend_generics(&strct.generics); + for (_, typ, _) in fields { + this.extend_implicit_lifetime_bounds(typ, None); + } + this + } + + /// Traverse a type, adding any implicit lifetime bounds that arise from + /// having a reference to an opaque containing a lifetime. + /// For example, the type `&'a Foo<'b>` implies `'b: 'a`. + fn extend_implicit_lifetime_bounds( + &mut self, + typ: &TypeName, + behind_ref: Option<&NamedLifetime>, + ) { + match typ { + TypeName::Named(path_type) => { + if let Some(borrow_lifetime) = behind_ref { + let explicit_longer_than_borrow = + LifetimeTransitivity::longer_than(self, borrow_lifetime); + let mut implicit_longer_than_borrow = vec![]; + + for path_lifetime in path_type.lifetimes.iter() { + if let Lifetime::Named(path_lifetime) = path_lifetime { + if !explicit_longer_than_borrow.contains(&path_lifetime) { + implicit_longer_than_borrow.push(path_lifetime); + } + } + } + + self.extend_bounds( + implicit_longer_than_borrow + .into_iter() + .map(|path_lifetime| (path_lifetime, Some(borrow_lifetime))), + ); + } + } + TypeName::Reference(lifetime, _, typ) => { + let behind_ref = if let Lifetime::Named(named) = lifetime { + Some(named) + } else { + None + }; + self.extend_implicit_lifetime_bounds(typ, behind_ref); + } + TypeName::Option(typ) => self.extend_implicit_lifetime_bounds(typ, None), + TypeName::Result(ok, err, _) => { + self.extend_implicit_lifetime_bounds(ok, None); + self.extend_implicit_lifetime_bounds(err, None); + } + _ => {} + } + } + + /// Add the lifetimes from generic parameters and where bounds. + fn extend_generics(&mut self, generics: &syn::Generics) { + let generic_bounds = generics.params.iter().map(|generic| match generic { + syn::GenericParam::Type(_) => panic!("generic types are unsupported"), + syn::GenericParam::Lifetime(def) => (&def.lifetime, &def.bounds), + syn::GenericParam::Const(_) => panic!("const generics are unsupported"), + }); + + let generic_defs = generic_bounds.clone().map(|(lifetime, _)| lifetime); + + self.extend_lifetimes(generic_defs); + self.extend_bounds(generic_bounds); + + if let Some(ref where_clause) = generics.where_clause { + self.extend_bounds(where_clause.predicates.iter().map(|pred| match pred { + syn::WherePredicate::Type(_) => panic!("trait bounds are unsupported"), + syn::WherePredicate::Lifetime(pred) => (&pred.lifetime, &pred.bounds), + _ => panic!("Found unknown kind of where predicate"), + })); + } + } + + /// Returns the number of lifetimes in the graph. + pub fn len(&self) -> usize { + self.nodes.len() + } + + /// Returns `true` if the graph contains no lifetimes. + pub fn is_empty(&self) -> bool { + self.nodes.is_empty() + } + + /// `<'a, 'b, 'c>` + /// + /// Write the existing lifetimes, excluding bounds, as generic parameters. + /// + /// To include lifetime bounds, use [`LifetimeEnv::lifetime_defs_to_tokens`]. + pub fn lifetimes_to_tokens(&self) -> proc_macro2::TokenStream { + if self.is_empty() { + return quote! {}; + } + + let lifetimes = self.nodes.iter().map(|node| &node.lifetime); + quote! { <#(#lifetimes),*> } + } + + /// Returns the index of a lifetime in the graph, or `None` if the lifetime + /// isn't in the graph. + pub(crate) fn id(&self, lifetime: &L) -> Option + where + NamedLifetime: PartialEq, + { + self.nodes + .iter() + .position(|node| &node.lifetime == lifetime) + } + + /// Add isolated lifetimes to the graph. + fn extend_lifetimes<'a, L, I>(&mut self, iter: I) + where + NamedLifetime: PartialEq + From<&'a L>, + L: 'a, + I: IntoIterator, + { + for lifetime in iter { + if self.id(lifetime).is_some() { + panic!( + "lifetime name `{}` declared twice in the same scope", + NamedLifetime::from(lifetime) + ); + } + + self.nodes.push(LifetimeNode { + lifetime: lifetime.into(), + shorter: vec![], + longer: vec![], + }); + } + } + + /// Add edges to the lifetime graph. + /// + /// This method is decoupled from [`LifetimeEnv::extend_lifetimes`] because + /// generics can define new lifetimes, while `where` clauses cannot. + /// + /// # Panics + /// + /// This method panics if any of the lifetime bounds aren't already defined + /// in the graph. This isn't allowed by rustc in the first place, so it should + /// only ever occur when deserializing an invalid [`LifetimeEnv`]. + fn extend_bounds<'a, L, B, I>(&mut self, iter: I) + where + NamedLifetime: PartialEq + From<&'a L>, + L: 'a, + B: IntoIterator, + I: IntoIterator, + { + for (lifetime, bounds) in iter { + let long = self.id(lifetime).expect("use of undeclared lifetime, this is a bug: try calling `LifetimeEnv::extend_lifetimes` first"); + for bound in bounds { + let short = self + .id(bound) + .expect("cannot use undeclared lifetime as a bound"); + self.nodes[short].longer.push(long); + self.nodes[long].shorter.push(short); + } + } + } +} + +impl fmt::Display for LifetimeEnv { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.to_token_stream().fmt(f) + } +} + +impl ToTokens for LifetimeEnv { + fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) { + for node in self.nodes.iter() { + let lifetime = &node.lifetime; + if node.shorter.is_empty() { + tokens.extend(quote! { #lifetime, }); + } else { + let bounds = node.shorter.iter().map(|&id| &self.nodes[id].lifetime); + tokens.extend(quote! { #lifetime: #(#bounds)+*, }); + } + } + } +} + +/// Serialize a [`LifetimeEnv`] as a map from lifetimes to their bounds. +impl Serialize for LifetimeEnv { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + use serde::ser::SerializeMap; + let mut seq = serializer.serialize_map(Some(self.len()))?; + + for node in self.nodes.iter() { + /// Helper type for serializing bounds. + struct Bounds<'a> { + ids: &'a [usize], + nodes: &'a [LifetimeNode], + } + + impl<'a> Serialize for Bounds<'a> { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + use serde::ser::SerializeSeq; + let mut seq = serializer.serialize_seq(Some(self.ids.len()))?; + for &id in self.ids { + seq.serialize_element(&self.nodes[id].lifetime)?; + } + seq.end() + } + } + + seq.serialize_entry( + &node.lifetime, + &Bounds { + ids: &node.shorter[..], + nodes: &self.nodes, + }, + )?; + } + seq.end() + } +} + +impl<'de> Deserialize<'de> for LifetimeEnv { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + use std::collections::BTreeMap; + + let m: BTreeMap> = + Deserialize::deserialize(deserializer)?; + + let mut this = LifetimeEnv::new(); + this.extend_lifetimes(m.keys()); + this.extend_bounds(m.iter()); + Ok(this) + } +} + +/// A lifetime, along with ptrs to all lifetimes that are explicitly +/// shorter/longer than it. +/// +/// This type is internal to [`LifetimeGraph`]- the ptrs are stored as `usize`s, +/// meaning that they may be invalid if a `LifetimeEdges` is created in one +/// `LifetimeGraph` and then used in another. +#[derive(Clone, PartialEq, Eq, Hash, Debug)] +pub(crate) struct LifetimeNode { + /// The name of the lifetime. + pub(crate) lifetime: NamedLifetime, + + /// Pointers to all lifetimes that this lives _at least_ as long as. + /// + /// Note: This doesn't account for transitivity. + pub(crate) shorter: Vec, + + /// Pointers to all lifetimes that live _at least_ as long as this. + /// + /// Note: This doesn't account for transitivity. + pub(crate) longer: Vec, +} + +/// A lifetime, analogous to [`syn::Lifetime`]. +#[derive(Clone, Debug, Hash, Eq, PartialEq, Serialize, Deserialize)] +pub enum Lifetime { + /// The `'static` lifetime. + Static, + + /// A named lifetime, like `'a`. + Named(NamedLifetime), + + /// An elided lifetime. + Anonymous, +} + +impl Lifetime { + /// Returns the inner `NamedLifetime` if the lifetime is the `Named` variant, + /// otherwise `None`. + pub fn to_named(self) -> Option { + if let Lifetime::Named(named) = self { + return Some(named); + } + None + } + + /// Returns a reference to the inner `NamedLifetime` if the lifetime is the + /// `Named` variant, otherwise `None`. + pub fn as_named(&self) -> Option<&NamedLifetime> { + if let Lifetime::Named(named) = self { + return Some(named); + } + None + } +} + +impl fmt::Display for Lifetime { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Lifetime::Static => "'static".fmt(f), + Lifetime::Named(ref named) => named.fmt(f), + Lifetime::Anonymous => "'_".fmt(f), + } + } +} + +impl ToTokens for Lifetime { + fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) { + match self { + Lifetime::Static => syn::Lifetime::new("'static", Span::call_site()).to_tokens(tokens), + Lifetime::Named(ref s) => s.to_tokens(tokens), + Lifetime::Anonymous => syn::Lifetime::new("'_", Span::call_site()).to_tokens(tokens), + }; + } +} + +impl From<&syn::Lifetime> for Lifetime { + fn from(lt: &syn::Lifetime) -> Self { + if lt.ident == "static" { + Self::Static + } else { + Self::Named(NamedLifetime((<.ident).into())) + } + } +} + +impl From<&Option> for Lifetime { + fn from(lt: &Option) -> Self { + lt.as_ref().map(Into::into).unwrap_or(Self::Anonymous) + } +} + +impl Lifetime { + /// Converts the [`Lifetime`] back into an AST node that can be spliced into a program. + pub fn to_syn(&self) -> Option { + match *self { + Self::Static => Some(syn::Lifetime::new("'static", Span::call_site())), + Self::Anonymous => None, + Self::Named(ref s) => Some(syn::Lifetime::new(&s.to_string(), Span::call_site())), + } + } +} + +/// Collect all lifetimes that are either longer_or_shorter +pub struct LifetimeTransitivity<'env> { + env: &'env LifetimeEnv, + visited: Vec, + out: Vec<&'env NamedLifetime>, + longer_or_shorter: LongerOrShorter, +} + +impl<'env> LifetimeTransitivity<'env> { + /// Returns a new [`LifetimeTransitivity`] that finds all longer lifetimes. + pub fn longer(env: &'env LifetimeEnv) -> Self { + Self::new(env, LongerOrShorter::Longer) + } + + /// Returns a new [`LifetimeTransitivity`] that finds all shorter lifetimes. + pub fn shorter(env: &'env LifetimeEnv) -> Self { + Self::new(env, LongerOrShorter::Shorter) + } + + /// Returns all the lifetimes longer than a provided `NamedLifetime`. + pub fn longer_than(env: &'env LifetimeEnv, named: &NamedLifetime) -> Vec<&'env NamedLifetime> { + let mut this = Self::new(env, LongerOrShorter::Longer); + this.visit(named); + this.finish() + } + + /// Returns all the lifetimes shorter than the provided `NamedLifetime`. + pub fn shorter_than(env: &'env LifetimeEnv, named: &NamedLifetime) -> Vec<&'env NamedLifetime> { + let mut this = Self::new(env, LongerOrShorter::Shorter); + this.visit(named); + this.finish() + } + + /// Returns a new [`LifetimeTransitivity`]. + fn new(env: &'env LifetimeEnv, longer_or_shorter: LongerOrShorter) -> Self { + LifetimeTransitivity { + env, + visited: vec![false; env.len()], + out: vec![], + longer_or_shorter, + } + } + + /// Visits a lifetime, as well as all the nodes it's transitively longer or + /// shorter than, depending on how the `LifetimeTransitivity` was constructed. + pub fn visit(&mut self, named: &NamedLifetime) { + if let Some(id) = self + .env + .nodes + .iter() + .position(|node| node.lifetime == *named) + { + self.dfs(id); + } + } + + /// Performs depth-first search through the `LifetimeEnv` created at construction + /// for all nodes longer or shorter than the node at the provided index, + /// depending on how the `LifetimeTransitivity` was constructed. + fn dfs(&mut self, index: usize) { + // Note: all of these indexings SHOULD be valid because + // `visited.len() == nodes.len()`, and the ids come from + // calling `Iterator::position` on `nodes`, which never shrinks. + // So we should be able to change these to `get_unchecked`... + if !self.visited[index] { + self.visited[index] = true; + + let node = &self.env.nodes[index]; + self.out.push(&node.lifetime); + for &edge_index in self.longer_or_shorter.edges(node).iter() { + self.dfs(edge_index); + } + } + } + + /// Returns the transitively reachable lifetimes. + pub fn finish(self) -> Vec<&'env NamedLifetime> { + self.out + } +} + +/// A helper type for [`LifetimeTransitivity`] determining whether to find the +/// transitively longer or transitively shorter lifetimes. +enum LongerOrShorter { + Longer, + Shorter, +} + +impl LongerOrShorter { + /// Returns either the indices of the longer or shorter lifetimes, depending + /// on `self`. + fn edges<'node>(&self, node: &'node LifetimeNode) -> &'node [usize] { + match self { + LongerOrShorter::Longer => &node.longer[..], + LongerOrShorter::Shorter => &node.shorter[..], + } + } +} diff --git a/third_party/rust/diplomat_core/src/ast/methods.rs b/third_party/rust/diplomat_core/src/ast/methods.rs new file mode 100644 index 000000000000..8498c97463a4 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/methods.rs @@ -0,0 +1,592 @@ +use serde::{Deserialize, Serialize}; +use std::ops::ControlFlow; + +use super::attrs; +use super::docs::Docs; +use super::{Ident, Lifetime, LifetimeEnv, Mutability, Path, PathType, TypeName, ValidityError}; +use crate::Env; + +/// A method declared in the `impl` associated with an FFI struct. +/// Includes both static and non-static methods, which can be distinguished +/// by inspecting [`Method::self_param`]. +#[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Debug)] +pub struct Method { + /// The name of the method as initially declared. + pub name: Ident, + + /// Lines of documentation for the method. + pub docs: Docs, + + /// The name of the FFI function wrapping around the method. + pub full_path_name: Ident, + + /// The `self` param of the method, if any. + pub self_param: Option, + + /// All non-`self` params taken by the method. + pub params: Vec, + + /// The return type of the method, if any. + pub return_type: Option, + + /// The lifetimes introduced in this method and surrounding impl block. + pub lifetime_env: LifetimeEnv, + + /// The list of `cfg` attributes (if any). + /// + /// These are strings instead of `syn::Attribute` or `proc_macro2::TokenStream` + /// because those types are not `PartialEq`, `Hash`, `Serialize`, etc. + pub cfg_attrs: Vec, +} + +impl Method { + /// Extracts a [`Method`] from an AST node inside an `impl`. + pub fn from_syn( + m: &syn::ImplItemFn, + self_path_type: PathType, + impl_generics: Option<&syn::Generics>, + cfg_attrs: &[String], + ) -> Method { + let self_ident = self_path_type.path.elements.last().unwrap(); + let method_ident = &m.sig.ident; + let extern_ident = syn::Ident::new( + format!("{self_ident}_{method_ident}").as_str(), + m.sig.ident.span(), + ); + + let all_params = m + .sig + .inputs + .iter() + .filter_map(|a| match a { + syn::FnArg::Receiver(_) => None, + syn::FnArg::Typed(ref t) => Some(Param::from_syn(t, self_path_type.clone())), + }) + .collect::>(); + + let self_param = m + .sig + .receiver() + .map(|rec| SelfParam::from_syn(rec, self_path_type.clone())); + + let return_ty = match &m.sig.output { + syn::ReturnType::Type(_, return_typ) => { + // When we allow lifetime elision, this is where we would want to + // support it so we can insert the expanded explicit lifetimes. + Some(TypeName::from_syn( + return_typ.as_ref(), + Some(self_path_type), + )) + } + syn::ReturnType::Default => None, + }; + + let lifetime_env = LifetimeEnv::from_method_item( + m, + impl_generics, + self_param.as_ref(), + &all_params[..], + return_ty.as_ref(), + ); + + let mut cfg_attrs = cfg_attrs.to_owned(); + cfg_attrs.extend(attrs::extract_cfg_attrs(&m.attrs)); + + Method { + name: Ident::from(method_ident), + docs: Docs::from_attrs(&m.attrs), + full_path_name: Ident::from(&extern_ident), + self_param, + params: all_params, + return_type: return_ty, + lifetime_env, + cfg_attrs, + } + } + + /// Returns the parameters that the output is lifetime-bound to. + /// + /// # Examples + /// + /// Given the following method: + /// ```ignore + /// fn foo<'a, 'b: 'a, 'c>(&'a self, bar: Bar<'b>, baz: Baz<'c>) -> FooBar<'a> { ... } + /// ``` + /// Then this method would return the `&'a self` and `bar: Bar<'b>` params + /// because `'a` is in the return type, and `'b` must live at least as long + /// as `'a`. It wouldn't include `baz: Baz<'c>` though, because the return + /// type isn't bound by `'c` in any way. + /// + /// # Panics + /// + /// This method may panic if `TypeName::check_result_type_validity` (called by + /// `Method::check_validity`) doesn't pass first, since the result type may + /// contain elided lifetimes that we depend on for this method. The validity + /// checks ensure that the return type doesn't elide any lifetimes, ensuring + /// that this method will produce correct results. + pub fn borrowed_params(&self) -> BorrowedParams { + // To determine which params the return type is bound to, we just have to + // find the params that contain a lifetime that's also in the return type. + if let Some(ref return_type) = self.return_type { + // The lifetimes that must outlive the return type + let lifetimes = return_type.longer_lifetimes(&self.lifetime_env); + + let held_self_param = self.self_param.as_ref().filter(|self_param| { + // Check if `self` is a reference with a lifetime in the return type. + if let Some((Lifetime::Named(ref name), _)) = self_param.reference { + if lifetimes.contains(&name) { + return true; + } + } + self_param.path_type.lifetimes.iter().any(|lt| { + if let Lifetime::Named(name) = lt { + lifetimes.contains(&name) + } else { + false + } + }) + }); + + // Collect all the params that contain a named lifetime that's also + // in the return type. + let held_params = self + .params + .iter() + .filter_map(|param| { + let mut lt_kind = LifetimeKind::ReturnValue; + param + .ty + .visit_lifetimes(&mut |lt, _| { + // Thanks to `TypeName::visit_lifetimes`, we can + // traverse the lifetimes without allocations and + // short-circuit if we find a match. + match lt { + Lifetime::Named(name) if lifetimes.contains(&name) => { + return ControlFlow::Break(()); + } + Lifetime::Static => { + lt_kind = LifetimeKind::Static; + return ControlFlow::Break(()); + } + _ => {} + }; + ControlFlow::Continue(()) + }) + .is_break() + .then(|| (param, lt_kind)) + }) + .collect(); + + BorrowedParams(held_self_param, held_params) + } else { + BorrowedParams(None, vec![]) + } + } + + /// Performs type-specific validity checks (see [TypeName::check_validity()]) + pub fn check_validity<'a>( + &'a self, + in_path: &Path, + env: &Env, + errors: &mut Vec, + ) { + // validity check that if the self type is nonopaque, that it is + // behind a reference + if let Some(ref self_param) = self.self_param { + self_param + .to_typename() + .check_validity(in_path, env, errors); + } + for m in self.params.iter() { + // Do we need to check the validity of the input types? + m.ty.check_validity(in_path, env, errors); + } + if let Some(ref t) = self.return_type { + t.check_return_type_validity(in_path, env, errors); + } + } + + /// Checks whether the method qualifies for special writeable handling. + /// To qualify, a method must: + /// - not return any value + /// - have the last argument be an `&mut diplomat_runtime::DiplomatWriteable` + /// + /// Typically, methods of this form will be transformed in the bindings to a + /// method that doesn't take the writeable as an argument but instead creates + /// one locally and just returns the final string. + pub fn is_writeable_out(&self) -> bool { + let return_compatible = self + .return_type + .as_ref() + .map(|return_type| match return_type { + TypeName::Unit => true, + TypeName::Result(ok, _, _) => { + matches!(ok.as_ref(), TypeName::Unit) + } + _ => false, + }) + .unwrap_or(true); + + return_compatible && self.params.last().map(Param::is_writeable).unwrap_or(false) + } + + /// Checks if any parameters are writeable (regardless of other compatibilities for writeable output) + pub fn has_writeable_param(&self) -> bool { + self.params.iter().any(|p| p.is_writeable()) + } + + /// Returns the documentation block + pub fn docs(&self) -> &Docs { + &self.docs + } +} + +/// The `self` parameter taken by a [`Method`]. +#[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Debug)] +pub struct SelfParam { + /// The lifetime and mutability of the `self` param, if it's a reference. + pub reference: Option<(Lifetime, Mutability)>, + + /// The type of the parameter, which will be a named reference to + /// the associated struct, + pub path_type: PathType, +} + +impl SelfParam { + pub fn to_typename(&self) -> TypeName { + let typ = TypeName::Named(self.path_type.clone()); + if let Some((ref lifetime, ref mutability)) = self.reference { + return TypeName::Reference(lifetime.clone(), *mutability, Box::new(typ)); + } + typ + } + + pub fn from_syn(rec: &syn::Receiver, path_type: PathType) -> Self { + SelfParam { + reference: rec + .reference + .as_ref() + .map(|(_, lt)| (lt.into(), Mutability::from_syn(&rec.mutability))), + path_type, + } + } +} + +/// A parameter taken by a [`Method`], not including `self`. +#[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Debug)] +pub struct Param { + /// The name of the parameter in the original method declaration. + pub name: Ident, + + /// The type of the parameter. + pub ty: TypeName, +} + +impl Param { + /// Check if this parameter is a Writeable + pub fn is_writeable(&self) -> bool { + match self.ty { + TypeName::Reference(_, Mutability::Mutable, ref w) => **w == TypeName::Writeable, + _ => false, + } + } + + pub fn from_syn(t: &syn::PatType, self_path_type: PathType) -> Self { + let ident = match t.pat.as_ref() { + syn::Pat::Ident(ident) => ident, + _ => panic!("Unexpected param type"), + }; + + Param { + name: (&ident.ident).into(), + ty: TypeName::from_syn(&t.ty, Some(self_path_type)), + } + } +} + +/// The type of lifetime. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum LifetimeKind { + /// Param must live at least as long as the returned object. + ReturnValue, + /// Param must live for the duration of the program. + Static, +} + +#[derive(Default, Debug)] +/// Parameters in a method that might be borrowed in the return type. +pub struct BorrowedParams<'a>( + pub Option<&'a SelfParam>, + pub Vec<(&'a Param, LifetimeKind)>, +); + +impl BorrowedParams<'_> { + /// Returns an [`Iterator`] through the names of the parameters that are borrowed + /// for the lifetime of the return value, accepting an `Ident` that the `self` + /// param will be called if present. + pub fn return_names<'a>(&'a self, self_name: &'a Ident) -> impl Iterator { + self.0.iter().map(move |_| self_name).chain( + self.1.iter().filter_map(|&(param, ltk)| { + (ltk == LifetimeKind::ReturnValue).then(|| ¶m.name) + }), + ) + } + + /// Returns an [`Iterator`] through the names of the parameters that are borrowed for a + /// static lifetime. + pub fn static_names(&self) -> impl Iterator { + self.1 + .iter() + .filter_map(|&(param, ltk)| (ltk == LifetimeKind::Static).then(|| ¶m.name)) + } + + /// Returns `true` if a provided param name is included in the borrowed params, + /// otherwise `false`. + /// + /// This method doesn't check the `self` parameter. Use + /// [`BorrowedParams::borrows_self`] instead. + pub fn contains(&self, param_name: &Ident) -> bool { + self.1.iter().any(|(param, _)| ¶m.name == param_name) + } + + /// Returns `true` if there are no borrowed parameters, otherwise `false`. + pub fn is_empty(&self) -> bool { + self.0.is_none() && self.1.is_empty() + } + + /// Returns `true` if the `self` param is borrowed, otherwise `false`. + pub fn borrows_self(&self) -> bool { + self.0.is_some() + } + + /// Returns `true` if there are any borrowed params, otherwise `false`. + pub fn borrows_params(&self) -> bool { + !self.1.is_empty() + } + + /// Returns the number of borrowed params. + pub fn len(&self) -> usize { + self.1.len() + usize::from(self.0.is_some()) + } +} + +#[cfg(test)] +mod tests { + use insta; + + use syn; + + use crate::ast::Ident; + + use super::{Method, Path, PathType}; + + #[test] + fn static_methods() { + insta::assert_yaml_snapshot!(Method::from_syn( + &syn::parse_quote! { + /// Some docs. + #[diplomat::rust_link(foo::Bar::batz, FnInStruct)] + fn foo(x: u64, y: MyCustomStruct) { + + } + }, + PathType::new(Path::empty().sub_path(Ident::from("MyStructContainingMethod"))), + None, + &[] + )); + + insta::assert_yaml_snapshot!(Method::from_syn( + &syn::parse_quote! { + /// Some docs. + /// Some more docs. + /// + /// Even more docs. + #[diplomat::rust_link(foo::Bar::batz, FnInEnum)] + fn foo(x: u64, y: MyCustomStruct) -> u64 { + x + } + }, + PathType::new(Path::empty().sub_path(Ident::from("MyStructContainingMethod"))), + None, + &[] + )); + } + + #[test] + fn cfged_method() { + insta::assert_yaml_snapshot!(Method::from_syn( + &syn::parse_quote! { + /// Some docs. + #[diplomat::rust_link(foo::Bar::batz, FnInStruct)] + #[cfg(any(feature = "foo", not(feature = "bar")))] + fn foo(x: u64, y: MyCustomStruct) { + + } + }, + PathType::new(Path::empty().sub_path(Ident::from("MyStructContainingMethod"))), + None, + &[] + )); + } + + #[test] + fn nonstatic_methods() { + insta::assert_yaml_snapshot!(Method::from_syn( + &syn::parse_quote! { + fn foo(&self, x: u64, y: MyCustomStruct) { + + } + }, + PathType::new(Path::empty().sub_path(Ident::from("MyStructContainingMethod"))), + None, + &[] + )); + + insta::assert_yaml_snapshot!(Method::from_syn( + &syn::parse_quote! { + #[diplomat::rust_link(foo::Bar::batz, FnInStruct)] + fn foo(&mut self, x: u64, y: MyCustomStruct) -> u64 { + x + } + }, + PathType::new(Path::empty().sub_path(Ident::from("MyStructContainingMethod"))), + None, + &[] + )); + } + + macro_rules! assert_borrowed_params { + ([$($return_param:ident),*] $(, [$($static_param:ident),*])? => $($tokens:tt)* ) => {{ + let method = Method::from_syn( + &syn::parse_quote! { $($tokens)* }, + PathType::new(Path::empty().sub_path(Ident::from("MyStructContainingMethod"))), + None, + &[] + ); + + let borrowed_params = method.borrowed_params(); + // The ident parser in syn doesn't allow `self`, so we use "this" as a placeholder + // and then change it. + let mut actual_return: Vec<&str> = borrowed_params.return_names(&Ident::THIS).map(|ident| ident.as_str()).collect(); + if borrowed_params.0.is_some() { + actual_return[0] = "self"; + } + let expected_return: &[&str] = &[$(stringify!($return_param)),*]; + assert_eq!(actual_return, expected_return); + let actual_static: Vec<&str> = borrowed_params.static_names().map(|ident| ident.as_str()).collect(); + let expected_static: &[&str] = &[$($(stringify!($static_param)),*)?]; + assert_eq!(actual_static, expected_static); + }}; + } + + #[test] + fn static_params_held_by_return_type() { + assert_borrowed_params! { [first, second] => + #[diplomat::rust_link(foo::Bar::batz, FnInStruct)] + fn foo<'a, 'b>(first: &'a First, second: &'b Second, third: &Third) -> Foo<'a, 'b> { + unimplemented!() + } + } + + assert_borrowed_params! { [hold] => + #[diplomat::rust_link(Foo, FnInStruct)] + fn transitivity<'a, 'b: 'a, 'c: 'b, 'd: 'c, 'e: 'd, 'x>(hold: &'x One<'e>, nohold: &One<'x>) -> Box> { + unimplemented!() + } + } + + assert_borrowed_params! { [hold] => + #[diplomat::rust_link(Foo, FnInStruct)] + fn a_le_b_and_b_le_a<'a: 'b, 'b: 'a>(hold: &'b Bar, nohold: &'c Bar) -> Box> { + unimplemented!() + } + } + + assert_borrowed_params! { [a, b, c, d] => + #[diplomat::rust_link(Foo, FnInStruct)] + fn many_dependents<'a, 'b: 'a, 'c: 'a, 'd: 'b, 'x, 'y>(a: &'x One<'a>, b: &'b One<'a>, c: &Two<'x, 'c>, d: &'x Two<'d, 'y>, nohold: &'x Two<'x, 'y>) -> Box> { + unimplemented!() + } + } + + assert_borrowed_params! { [hold] => + #[diplomat::rust_link(Foo, FnInStruct)] + fn return_outlives_param<'short, 'long: 'short>(hold: &Two<'long, 'short>, nohold: &'short One<'short>) -> Box> { + unimplemented!() + } + } + + assert_borrowed_params! { [hold] => + #[diplomat::rust_link(Foo, FnInStruct)] + fn transitivity_deep_types<'a, 'b: 'a, 'c: 'b, 'd: 'c>(hold: Option>>, nohold: &'a Box>>) -> Result>, Error> { + unimplemented!() + } + } + + assert_borrowed_params! { [top, left, right, bottom] => + #[diplomat::rust_link(Foo, FnInStruct)] + fn diamond_top<'top, 'left: 'top, 'right: 'top, 'bottom: 'left + 'right>(top: One<'top>, left: One<'left>, right: One<'right>, bottom: One<'bottom>) -> Box> { + unimplemented!() + } + } + + assert_borrowed_params! { [left, bottom] => + #[diplomat::rust_link(Foo, FnInStruct)] + fn diamond_left<'top, 'left: 'top, 'right: 'top, 'bottom: 'left + 'right>(top: One<'top>, left: One<'left>, right: One<'right>, bottom: One<'bottom>) -> Box> { + unimplemented!() + } + } + + assert_borrowed_params! { [right, bottom] => + #[diplomat::rust_link(Foo, FnInStruct)] + fn diamond_right<'top, 'left: 'top, 'right: 'top, 'bottom: 'left + 'right>(top: One<'top>, left: One<'left>, right: One<'right>, bottom: One<'bottom>) -> Box> { + unimplemented!() + } + } + + assert_borrowed_params! { [bottom] => + #[diplomat::rust_link(Foo, FnInStruct)] + fn diamond_bottom<'top, 'left: 'top, 'right: 'top, 'bottom: 'left + 'right>(top: One<'top>, left: One<'left>, right: One<'right>, bottom: One<'bottom>) -> Box> { + unimplemented!() + } + } + + assert_borrowed_params! { [a, b, c, d] => + #[diplomat::rust_link(Foo, FnInStruct)] + fn diamond_and_nested_types<'a, 'b: 'a, 'c: 'b, 'd: 'b + 'c, 'x, 'y>(a: &'x One<'a>, b: &'y One<'b>, c: &One<'c>, d: &One<'d>, nohold: &One<'x>) -> Box> { + unimplemented!() + } + } + } + + #[test] + fn nonstatic_params_held_by_return_type() { + assert_borrowed_params! { [self] => + #[diplomat::rust_link(foo::Bar::batz, FnInStruct)] + fn foo<'a>(&'a self) -> Foo<'a> { + unimplemented!() + } + } + + assert_borrowed_params! { [self, foo, bar] => + #[diplomat::rust_link(foo::Bar::batz, FnInStruct)] + fn foo<'x, 'y>(&'x self, foo: &'x Foo, bar: &Bar<'y>, baz: &Baz) -> Foo<'x, 'y> { + unimplemented!() + } + } + + assert_borrowed_params! { [self, bar] => + #[diplomat::rust_link(foo::Bar::batz, FnInStruct)] + fn foo<'a, 'b>(&'a self, bar: Bar<'b>) -> Foo<'a, 'b> { + unimplemented!() + } + } + + assert_borrowed_params! { [self, bar], [baz] => + #[diplomat::rust_link(foo::Bar::batz, FnInStruct)] + fn foo<'a, 'b>(&'a self, bar: Bar<'b>, baz: &'static str) -> Foo<'a, 'b, 'static> { + unimplemented!() + } + } + } +} diff --git a/third_party/rust/diplomat_core/src/ast/mod.rs b/third_party/rust/diplomat_core/src/ast/mod.rs new file mode 100644 index 000000000000..c034c1f89370 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/mod.rs @@ -0,0 +1,37 @@ +/// As part of the macro expansion and code generation process, Diplomat +/// generates a simplified version of the Rust AST that captures special +/// types such as opaque structs, [`Box`], and [`Result`] with utilities +/// for handling such types. +pub(crate) mod attrs; + +mod methods; +pub use methods::{BorrowedParams, Method, Param, SelfParam}; + +mod modules; +pub use modules::{File, Module}; + +mod structs; +pub use structs::{OpaqueStruct, Struct}; + +mod enums; +pub use enums::Enum; + +mod types; +pub use types::{ + CustomType, LifetimeOrigin, ModSymbol, Mutability, PathType, PrimitiveType, TypeName, +}; + +mod lifetimes; +pub use lifetimes::{Lifetime, LifetimeEnv, LifetimeTransitivity, NamedLifetime}; + +mod paths; +pub use paths::Path; + +mod idents; +pub use idents::Ident; + +mod docs; +pub use docs::{DocType, Docs, DocsUrlGenerator, MarkdownStyle, RustLink, RustLinkDisplay}; + +mod validity; +pub use validity::ValidityError; diff --git a/third_party/rust/diplomat_core/src/ast/modules.rs b/third_party/rust/diplomat_core/src/ast/modules.rs new file mode 100644 index 000000000000..5c1a266aefce --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/modules.rs @@ -0,0 +1,406 @@ +use std::collections::{BTreeMap, HashSet}; +use std::fmt::Write as _; + +use quote::ToTokens; +use serde::{Deserialize, Serialize}; +use syn::{ImplItem, Item, ItemMod, UseTree, Visibility}; + +use super::{ + attrs, CustomType, Enum, Ident, Method, ModSymbol, Mutability, OpaqueStruct, Path, PathType, + RustLink, Struct, ValidityError, +}; +use crate::environment::*; + +/// Custom Diplomat attribute that can be placed on a struct definition. +#[derive(Debug)] +enum DiplomatStructAttribute { + /// The `#[diplomat::out]` attribute, used for non-opaque structs that + /// contain an owned opaque in the form of a `Box`. + Out, + /// The `#[diplomat::opaque]` attribute, used for marking a struct as opaque. + /// Note that opaque structs can be borrowed in return types, but cannot + /// be passed into a function behind a mutable reference. + Opaque, + /// The `#[diplomat::opaque_mut]` attribute, used for marking a struct as + /// opaque and mutable. + /// Note that mutable opaque structs can never be borrowed in return types + /// (even immutably!), but can be passed into a function behind a mutable + /// reference. + OpaqueMut, +} + +impl DiplomatStructAttribute { + /// Parses a [`DiplomatStructAttribute`] from an array of [`syn::Attribute`]s. + /// If more than one kind is found, an error is returned containing all the + /// ones encountered, since all the current attributes are disjoint. + fn parse(attrs: &[syn::Attribute]) -> Result, Vec> { + let mut buf = String::with_capacity(32); + let mut res = Ok(None); + for attr in attrs { + buf.clear(); + write!(&mut buf, "{}", attr.path().to_token_stream()).unwrap(); + let parsed = match buf.as_str() { + "diplomat :: out" => Some(Self::Out), + "diplomat :: opaque" => Some(Self::Opaque), + "diplomat :: opaque_mut" => Some(Self::OpaqueMut), + _ => None, + }; + + if let Some(parsed) = parsed { + match res { + Ok(None) => res = Ok(Some(parsed)), + Ok(Some(first)) => res = Err(vec![first, parsed]), + Err(ref mut errors) => errors.push(parsed), + } + } + } + + res + } +} + +#[derive(Clone, Serialize, Deserialize, Debug)] +pub struct Module { + pub name: Ident, + pub imports: Vec<(Path, Ident)>, + pub declared_types: BTreeMap, + pub sub_modules: Vec, +} + +impl Module { + pub fn check_validity(&self, in_path: &Path, env: &Env, errors: &mut Vec) { + self.declared_types.values().for_each(|t| { + t.check_validity(&in_path.sub_path(self.name.clone()), env, errors); + }); + + self.sub_modules.iter().for_each(|t| { + t.check_validity(&in_path.sub_path(self.name.clone()), env, errors); + }); + } + + pub fn all_rust_links(&self) -> HashSet<&RustLink> { + let mut rust_links = self + .declared_types + .values() + .flat_map(|t| t.all_rust_links()) + .collect::>(); + + self.sub_modules.iter().for_each(|m| { + rust_links.extend(m.all_rust_links().iter()); + }); + rust_links + } + + pub fn insert_all_types(&self, in_path: Path, out: &mut Env) { + let mut mod_symbols = ModuleEnv::default(); + + self.imports.iter().for_each(|(path, name)| { + mod_symbols.insert(name.clone(), ModSymbol::Alias(path.clone())); + }); + + self.declared_types.iter().for_each(|(k, v)| { + if mod_symbols + .insert(k.clone(), ModSymbol::CustomType(v.clone())) + .is_some() + { + panic!("Two types were declared with the same name, this needs to be implemented"); + } + }); + + let path_to_self = in_path.sub_path(self.name.clone()); + self.sub_modules.iter().for_each(|m| { + m.insert_all_types(path_to_self.clone(), out); + mod_symbols.insert(m.name.clone(), ModSymbol::SubModule(m.name.clone())); + }); + + out.insert(path_to_self, mod_symbols); + } + + pub fn from_syn(input: &ItemMod, force_analyze: bool) -> Module { + let mut custom_types_by_name = BTreeMap::new(); + let mut sub_modules = Vec::new(); + let mut imports = Vec::new(); + + let analyze_types = force_analyze + || input + .attrs + .iter() + .any(|a| a.path().to_token_stream().to_string() == "diplomat :: bridge"); + + input + .content + .as_ref() + .map(|t| &t.1[..]) + .unwrap_or_default() + .iter() + .for_each(|a| match a { + Item::Use(u) => { + if analyze_types { + extract_imports(&Path::empty(), &u.tree, &mut imports); + } + } + Item::Struct(strct) => { + if analyze_types { + let custom_type = match DiplomatStructAttribute::parse(&strct.attrs[..]) { + Ok(None) => CustomType::Struct(Struct::new(strct, false)), + Ok(Some(DiplomatStructAttribute::Out)) => { + CustomType::Struct(Struct::new(strct, true)) + } + Ok(Some(DiplomatStructAttribute::Opaque)) => { + CustomType::Opaque(OpaqueStruct::new(strct, Mutability::Immutable)) + } + Ok(Some(DiplomatStructAttribute::OpaqueMut)) => { + CustomType::Opaque(OpaqueStruct::new(strct, Mutability::Mutable)) + } + Err(errors) => { + panic!("Multiple conflicting Diplomat struct attributes, there can be at most one: {errors:?}"); + } + }; + + custom_types_by_name.insert(Ident::from(&strct.ident), custom_type); + } + } + + Item::Enum(enm) => { + if analyze_types { + custom_types_by_name + .insert((&enm.ident).into(), CustomType::Enum(Enum::from(enm))); + } + } + + Item::Impl(imp) => { + if analyze_types { + assert!(imp.trait_.is_none()); + + let self_path = match imp.self_ty.as_ref() { + syn::Type::Path(s) => PathType::from(s), + _ => panic!("Self type not found"), + }; + let cfg_attrs: Vec<_> = attrs::extract_cfg_attrs(&imp.attrs).collect(); + + let mut new_methods = imp + .items + .iter() + .filter_map(|i| match i { + ImplItem::Fn(m) => Some(m), + _ => None, + }) + .filter(|m| matches!(m.vis, Visibility::Public(_))) + .map(|m| Method::from_syn(m, self_path.clone(), Some(&imp.generics), &cfg_attrs)) + .collect(); + + let self_ident = self_path.path.elements.last().unwrap(); + + match custom_types_by_name.get_mut(self_ident).unwrap() { + CustomType::Struct(strct) => { + strct.methods.append(&mut new_methods); + } + CustomType::Opaque(strct) => { + strct.methods.append(&mut new_methods); + } + CustomType::Enum(enm) => { + enm.methods.append(&mut new_methods); + } + } + } + } + Item::Mod(item_mod) => { + sub_modules.push(Module::from_syn(item_mod, false)); + } + _ => {} + }); + + Module { + name: (&input.ident).into(), + imports, + declared_types: custom_types_by_name, + sub_modules, + } + } +} + +fn extract_imports(base_path: &Path, use_tree: &UseTree, out: &mut Vec<(Path, Ident)>) { + match use_tree { + UseTree::Name(name) => out.push(( + base_path.sub_path((&name.ident).into()), + (&name.ident).into(), + )), + UseTree::Path(path) => { + extract_imports(&base_path.sub_path((&path.ident).into()), &path.tree, out) + } + UseTree::Glob(_) => todo!("Glob imports are not yet supported"), + UseTree::Group(group) => { + group + .items + .iter() + .for_each(|i| extract_imports(base_path, i, out)); + } + UseTree::Rename(rename) => out.push(( + base_path.sub_path((&rename.ident).into()), + (&rename.rename).into(), + )), + } +} + +#[derive(Serialize, Deserialize, Clone, Debug)] +pub struct File { + pub modules: BTreeMap, +} + +impl File { + /// Performs all necessary validity checks and returns any errors + /// + /// Environment should be passed in from `.all_types()` + pub fn check_validity(&self, env: &Env) -> Vec { + let mut errors = vec![]; + self.modules + .values() + .for_each(|t| t.check_validity(&Path::empty(), env, &mut errors)); + errors + } + + /// Fuses all declared types into a single environment `HashMap`. + pub fn all_types(&self) -> Env { + let mut out = Env::default(); + let mut top_symbols = ModuleEnv::default(); + + self.modules.values().for_each(|m| { + m.insert_all_types(Path::empty(), &mut out); + top_symbols.insert(m.name.clone(), ModSymbol::SubModule(m.name.clone())); + }); + + out.insert(Path::empty(), top_symbols); + + out + } + + pub fn all_rust_links(&self) -> HashSet<&RustLink> { + self.modules + .values() + .flat_map(|m| m.all_rust_links().into_iter()) + .collect() + } +} + +impl From<&syn::File> for File { + /// Get all custom types across all modules defined in a given file. + fn from(file: &syn::File) -> File { + let mut out = BTreeMap::new(); + file.items.iter().for_each(|i| { + if let Item::Mod(item_mod) = i { + out.insert( + item_mod.ident.to_string(), + Module::from_syn(item_mod, false), + ); + } + }); + + File { modules: out } + } +} + +#[cfg(test)] +mod tests { + use insta::{self, Settings}; + + use syn; + + use crate::ast::{File, Module}; + + #[test] + fn simple_mod() { + let mut settings = Settings::new(); + settings.set_sort_maps(true); + + settings.bind(|| { + insta::assert_yaml_snapshot!(Module::from_syn( + &syn::parse_quote! { + mod ffi { + struct NonOpaqueStruct { + a: i32, + b: Box + } + + impl NonOpaqueStruct { + pub fn new(x: i32) -> NonOpaqueStruct { + unimplemented!(); + } + + pub fn set_a(&mut self, new_a: i32) { + self.a = new_a; + } + } + + #[diplomat::opaque] + struct OpaqueStruct { + a: SomeExternalType + } + + impl OpaqueStruct { + pub fn new() -> Box { + unimplemented!(); + } + + pub fn get_string(&self) -> String { + unimplemented!() + } + } + } + }, + true + )); + }); + } + + #[test] + fn method_visibility() { + let mut settings = Settings::new(); + settings.set_sort_maps(true); + + settings.bind(|| { + insta::assert_yaml_snapshot!(Module::from_syn( + &syn::parse_quote! { + #[diplomat::bridge] + mod ffi { + struct Foo {} + + impl Foo { + pub fn pub_fn() { + unimplemented!() + } + pub(crate) fn pub_crate_fn() { + unimplemented!() + } + pub(super) fn pub_super_fn() { + unimplemented!() + } + fn priv_fn() { + unimplemented!() + } + } + } + }, + true + )); + }); + } + + #[test] + fn import_in_non_diplomat_not_analyzed() { + let mut settings = Settings::new(); + settings.set_sort_maps(true); + + settings.bind(|| { + insta::assert_yaml_snapshot!(File::from(&syn::parse_quote! { + #[diplomat::bridge] + mod ffi { + struct Foo {} + } + + mod other { + use something::*; + } + })); + }); + } +} diff --git a/third_party/rust/diplomat_core/src/ast/paths.rs b/third_party/rust/diplomat_core/src/ast/paths.rs new file mode 100644 index 000000000000..fd2e07fce228 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/paths.rs @@ -0,0 +1,76 @@ +use serde::{Deserialize, Serialize}; +use std::fmt; + +use super::Ident; + +#[derive(Hash, Eq, PartialEq, Deserialize, Serialize, Clone, Debug, Ord, PartialOrd)] +pub struct Path { + pub elements: Vec, +} + +impl Path { + pub fn get_super(&self) -> Path { + let mut new_elements = self.elements.clone(); + new_elements.remove(new_elements.len() - 1); + Path { + elements: new_elements, + } + } + + pub fn sub_path(&self, ident: Ident) -> Path { + let mut new_elements = self.elements.clone(); + new_elements.push(ident); + Path { + elements: new_elements, + } + } + + pub fn to_syn(&self) -> syn::Path { + syn::Path { + leading_colon: None, + segments: self + .elements + .iter() + .map(|s| syn::PathSegment { + ident: s.to_syn(), + arguments: syn::PathArguments::None, + }) + .collect(), + } + } + + pub fn from_syn(path: &syn::Path) -> Path { + Path { + elements: path + .segments + .iter() + .map(|seg| (&seg.ident).into()) + .collect(), + } + } + + pub fn empty() -> Path { + Path { elements: vec![] } + } +} + +impl fmt::Display for Path { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + if let Some((head, tail)) = self.elements.split_first() { + head.fmt(f)?; + for seg in tail { + "::".fmt(f)?; + seg.fmt(f)?; + } + } + Ok(()) + } +} + +impl FromIterator for Path { + fn from_iter>(iter: T) -> Self { + Path { + elements: iter.into_iter().collect(), + } + } +} diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__enums__tests__enum_with_discr.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__enums__tests__enum_with_discr.snap new file mode 100644 index 000000000000..278f28303955 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__enums__tests__enum_with_discr.snap @@ -0,0 +1,33 @@ +--- +source: core/src/ast/enums.rs +expression: "Enum::from(&syn::parse_quote! {\n /// Some docs.\n #[diplomat :: rust_link(foo :: Bar, Enum)] enum\n DiscriminantedEnum { Abc = - 1, Def = 0, Ghi = 1, Jkl = 2, }\n })" +--- +name: DiscriminantedEnum +docs: + - Some docs. + - - path: + elements: + - foo + - Bar + typ: Enum + display: Normal +variants: + - - Abc + - -1 + - - "" + - [] + - - Def + - 0 + - - "" + - [] + - - Ghi + - 1 + - - "" + - [] + - - Jkl + - 2 + - - "" + - [] +methods: [] +cfg_attrs: [] + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__enums__tests__simple_enum.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__enums__tests__simple_enum.snap new file mode 100644 index 000000000000..76a0fa674df3 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__enums__tests__simple_enum.snap @@ -0,0 +1,25 @@ +--- +source: core/src/ast/enums.rs +expression: "Enum::from(&syn::parse_quote! {\n /// Some docs.\n #[diplomat :: rust_link(foo :: Bar, Enum)] enum MyLocalEnum\n {\n Abc, /// Some more docs.\n Def\n }\n })" +--- +name: MyLocalEnum +docs: + - Some docs. + - - path: + elements: + - foo + - Bar + typ: Enum + display: Normal +variants: + - - Abc + - 0 + - - "" + - [] + - - Def + - 1 + - - Some more docs. + - [] +methods: [] +cfg_attrs: [] + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__cfged_method.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__cfged_method.snap new file mode 100644 index 000000000000..a4c80c413203 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__cfged_method.snap @@ -0,0 +1,32 @@ +--- +source: core/src/ast/methods.rs +expression: "Method::from_syn(&syn::parse_quote! {\n /// Some docs.\n #[diplomat :: rust_link(foo :: Bar :: batz, FnInStruct)]\n #[cfg(any(feature = \"foo\", not(feature = \"bar\")))] fn\n foo(x : u64, y : MyCustomStruct) {}\n },\n PathType::new(Path::empty().sub_path(Ident::from(\"MyStructContainingMethod\"))),\n None, &[])" +--- +name: foo +docs: + - Some docs. + - - path: + elements: + - foo + - Bar + - batz + typ: FnInStruct + display: Normal +full_path_name: MyStructContainingMethod_foo +self_param: ~ +params: + - name: x + ty: + Primitive: u64 + - name: y + ty: + Named: + path: + elements: + - MyCustomStruct + lifetimes: [] +return_type: ~ +lifetime_env: {} +cfg_attrs: + - "# [cfg (any (feature = \"foo\" , not (feature = \"bar\")))]" + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__nonstatic_methods-2.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__nonstatic_methods-2.snap new file mode 100644 index 000000000000..d807dbe22828 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__nonstatic_methods-2.snap @@ -0,0 +1,40 @@ +--- +source: core/src/ast/methods.rs +expression: "Method::from_syn(&syn::parse_quote! {\n #[diplomat :: rust_link(foo :: Bar :: batz, FnInStruct)] fn\n foo(& mut self, x : u64, y : MyCustomStruct) -> u64 { x }\n },\n PathType::new(Path::empty().sub_path(Ident::from(\"MyStructContainingMethod\"))),\n None, &[])" +--- +name: foo +docs: + - "" + - - path: + elements: + - foo + - Bar + - batz + typ: FnInStruct + display: Normal +full_path_name: MyStructContainingMethod_foo +self_param: + reference: + - Anonymous + - Mutable + path_type: + path: + elements: + - MyStructContainingMethod + lifetimes: [] +params: + - name: x + ty: + Primitive: u64 + - name: y + ty: + Named: + path: + elements: + - MyCustomStruct + lifetimes: [] +return_type: + Primitive: u64 +lifetime_env: {} +cfg_attrs: [] + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__nonstatic_methods.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__nonstatic_methods.snap new file mode 100644 index 000000000000..e0fd9a1711da --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__nonstatic_methods.snap @@ -0,0 +1,33 @@ +--- +source: core/src/ast/methods.rs +expression: "Method::from_syn(&syn::parse_quote! {\n fn foo(& self, x : u64, y : MyCustomStruct) {}\n },\n PathType::new(Path::empty().sub_path(Ident::from(\"MyStructContainingMethod\"))),\n None, &[])" +--- +name: foo +docs: + - "" + - [] +full_path_name: MyStructContainingMethod_foo +self_param: + reference: + - Anonymous + - Immutable + path_type: + path: + elements: + - MyStructContainingMethod + lifetimes: [] +params: + - name: x + ty: + Primitive: u64 + - name: y + ty: + Named: + path: + elements: + - MyCustomStruct + lifetimes: [] +return_type: ~ +lifetime_env: {} +cfg_attrs: [] + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__static_methods-2.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__static_methods-2.snap new file mode 100644 index 000000000000..8a76fe97db28 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__static_methods-2.snap @@ -0,0 +1,32 @@ +--- +source: core/src/ast/methods.rs +expression: "Method::from_syn(&syn::parse_quote! {\n /// Some docs.\n /// Some more docs.\n ///\n /// Even more docs.\n #[diplomat :: rust_link(foo :: Bar :: batz, FnInEnum)] fn\n foo(x : u64, y : MyCustomStruct) -> u64 { x }\n },\n PathType::new(Path::empty().sub_path(Ident::from(\"MyStructContainingMethod\"))),\n None, &[])" +--- +name: foo +docs: + - "Some docs.\nSome more docs.\n\nEven more docs." + - - path: + elements: + - foo + - Bar + - batz + typ: FnInEnum + display: Normal +full_path_name: MyStructContainingMethod_foo +self_param: ~ +params: + - name: x + ty: + Primitive: u64 + - name: y + ty: + Named: + path: + elements: + - MyCustomStruct + lifetimes: [] +return_type: + Primitive: u64 +lifetime_env: {} +cfg_attrs: [] + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__static_methods.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__static_methods.snap new file mode 100644 index 000000000000..08086b20b27f --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__methods__tests__static_methods.snap @@ -0,0 +1,31 @@ +--- +source: core/src/ast/methods.rs +expression: "Method::from_syn(&syn::parse_quote! {\n /// Some docs.\n #[diplomat :: rust_link(foo :: Bar :: batz, FnInStruct)] fn\n foo(x : u64, y : MyCustomStruct) {}\n },\n PathType::new(Path::empty().sub_path(Ident::from(\"MyStructContainingMethod\"))),\n None, &[])" +--- +name: foo +docs: + - Some docs. + - - path: + elements: + - foo + - Bar + - batz + typ: FnInStruct + display: Normal +full_path_name: MyStructContainingMethod_foo +self_param: ~ +params: + - name: x + ty: + Primitive: u64 + - name: y + ty: + Named: + path: + elements: + - MyCustomStruct + lifetimes: [] +return_type: ~ +lifetime_env: {} +cfg_attrs: [] + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__modules__tests__import_in_non_diplomat_not_analyzed.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__modules__tests__import_in_non_diplomat_not_analyzed.snap new file mode 100644 index 000000000000..67c1d665ccb0 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__modules__tests__import_in_non_diplomat_not_analyzed.snap @@ -0,0 +1,27 @@ +--- +source: core/src/ast/modules.rs +expression: "File::from(&syn::parse_quote! {\n #[diplomat :: bridge] mod ffi { struct Foo {} } mod other\n { use something :: * ; }\n })" +--- +modules: + ffi: + name: ffi + imports: [] + declared_types: + Foo: + Struct: + name: Foo + docs: + - "" + - [] + lifetimes: {} + fields: [] + methods: [] + output_only: false + cfg_attrs: [] + sub_modules: [] + other: + name: other + imports: [] + declared_types: {} + sub_modules: [] + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__modules__tests__method_visibility.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__modules__tests__method_visibility.snap new file mode 100644 index 000000000000..ee09aa6b788c --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__modules__tests__method_visibility.snap @@ -0,0 +1,30 @@ +--- +source: core/src/ast/modules.rs +expression: "Module::from_syn(&syn::parse_quote! {\n #[diplomat :: bridge] mod ffi\n {\n struct Foo {} impl Foo\n {\n pub fn pub_fn() { unimplemented! () } pub(crate) fn\n pub_crate_fn() { unimplemented! () } pub(super) fn\n pub_super_fn() { unimplemented! () } fn priv_fn()\n { unimplemented! () }\n }\n }\n }, true)" +--- +name: ffi +imports: [] +declared_types: + Foo: + Struct: + name: Foo + docs: + - "" + - [] + lifetimes: {} + fields: [] + methods: + - name: pub_fn + docs: + - "" + - [] + full_path_name: Foo_pub_fn + self_param: ~ + params: [] + return_type: ~ + lifetime_env: {} + cfg_attrs: [] + output_only: false + cfg_attrs: [] +sub_modules: [] + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__modules__tests__simple_mod.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__modules__tests__simple_mod.snap new file mode 100644 index 000000000000..611d3efbccea --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__modules__tests__simple_mod.snap @@ -0,0 +1,121 @@ +--- +source: core/src/ast/modules.rs +expression: "Module::from_syn(&syn::parse_quote! {\n mod ffi\n {\n struct NonOpaqueStruct\n { a : i32, b : Box < NonOpaqueStruct > } impl\n NonOpaqueStruct\n {\n pub fn new(x : i32) -> NonOpaqueStruct\n { unimplemented! () ; } pub fn\n set_a(& mut self, new_a : i32) { self.a = new_a ; }\n } #[diplomat :: opaque] struct OpaqueStruct\n { a : SomeExternalType } impl OpaqueStruct\n {\n pub fn new() -> Box < OpaqueStruct > { unimplemented! () ; }\n pub fn get_string(& self) -> String { unimplemented! () }\n }\n }\n }, true)" +--- +name: ffi +imports: [] +declared_types: + NonOpaqueStruct: + Struct: + name: NonOpaqueStruct + docs: + - "" + - [] + lifetimes: {} + fields: + - - a + - Primitive: i32 + - - "" + - [] + - - b + - Box: + Named: + path: + elements: + - NonOpaqueStruct + lifetimes: [] + - - "" + - [] + methods: + - name: new + docs: + - "" + - [] + full_path_name: NonOpaqueStruct_new + self_param: ~ + params: + - name: x + ty: + Primitive: i32 + return_type: + Named: + path: + elements: + - NonOpaqueStruct + lifetimes: [] + lifetime_env: {} + cfg_attrs: [] + - name: set_a + docs: + - "" + - [] + full_path_name: NonOpaqueStruct_set_a + self_param: + reference: + - Anonymous + - Mutable + path_type: + path: + elements: + - NonOpaqueStruct + lifetimes: [] + params: + - name: new_a + ty: + Primitive: i32 + return_type: ~ + lifetime_env: {} + cfg_attrs: [] + output_only: false + cfg_attrs: [] + OpaqueStruct: + Opaque: + name: OpaqueStruct + docs: + - "" + - [] + lifetimes: {} + methods: + - name: new + docs: + - "" + - [] + full_path_name: OpaqueStruct_new + self_param: ~ + params: [] + return_type: + Box: + Named: + path: + elements: + - OpaqueStruct + lifetimes: [] + lifetime_env: {} + cfg_attrs: [] + - name: get_string + docs: + - "" + - [] + full_path_name: OpaqueStruct_get_string + self_param: + reference: + - Anonymous + - Immutable + path_type: + path: + elements: + - OpaqueStruct + lifetimes: [] + params: [] + return_type: + Named: + path: + elements: + - String + lifetimes: [] + lifetime_env: {} + cfg_attrs: [] + mutability: Immutable + cfg_attrs: [] +sub_modules: [] + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__structs__tests__simple_struct.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__structs__tests__simple_struct.snap new file mode 100644 index 000000000000..0de9adef93d0 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__structs__tests__simple_struct.snap @@ -0,0 +1,32 @@ +--- +source: core/src/ast/structs.rs +expression: "Struct::new(&syn::parse_quote! {\n /// Some docs.\n #[diplomat :: rust_link(foo :: Bar, Struct)] struct\n MyLocalStruct { a : i32, b : Box < MyLocalStruct > }\n }, true)" +--- +name: MyLocalStruct +docs: + - Some docs. + - - path: + elements: + - foo + - Bar + typ: Struct + display: Normal +lifetimes: {} +fields: + - - a + - Primitive: i32 + - - "" + - [] + - - b + - Box: + Named: + path: + elements: + - MyLocalStruct + lifetimes: [] + - - "" + - [] +methods: [] +output_only: true +cfg_attrs: [] + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-2.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-2.snap new file mode 100644 index 000000000000..8a60d74bbd3d --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-2.snap @@ -0,0 +1,12 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! { :: core :: my_type :: Foo }, None)" +--- +Named: + path: + elements: + - core + - my_type + - Foo + lifetimes: [] + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-3.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-3.snap new file mode 100644 index 000000000000..8aabe3da062d --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-3.snap @@ -0,0 +1,13 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! { :: core :: my_type :: Foo < 'test > },\n None)" +--- +Named: + path: + elements: + - core + - my_type + - Foo + lifetimes: + - Named: test + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-4.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-4.snap new file mode 100644 index 000000000000..8be4ee653706 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-4.snap @@ -0,0 +1,12 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! { Option < Ref < 'object >> }, None)" +--- +Option: + Named: + path: + elements: + - Ref + lifetimes: + - Named: object + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-5.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-5.snap new file mode 100644 index 000000000000..8c8ed1c1d9b7 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-5.snap @@ -0,0 +1,14 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! { Foo < 'a, 'b, 'c, 'd > }, None)" +--- +Named: + path: + elements: + - Foo + lifetimes: + - Named: a + - Named: b + - Named: c + - Named: d + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-6.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-6.snap new file mode 100644 index 000000000000..fbbae2758dff --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-6.snap @@ -0,0 +1,18 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! {\n very :: long :: path :: to :: my :: Type < 'x, 'y, 'z >\n }, None)" +--- +Named: + path: + elements: + - very + - long + - path + - to + - my + - Type + lifetimes: + - Named: x + - Named: y + - Named: z + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-7.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-7.snap new file mode 100644 index 000000000000..f5284cdb086c --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes-7.snap @@ -0,0 +1,20 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! {\n Result < OkRef < 'a, 'b >, ErrRef < 'c >>\n }, None)" +--- +Result: + - Named: + path: + elements: + - OkRef + lifetimes: + - Named: a + - Named: b + - Named: + path: + elements: + - ErrRef + lifetimes: + - Named: c + - true + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes.snap new file mode 100644 index 000000000000..41047acab8ec --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__lifetimes.snap @@ -0,0 +1,12 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! { Foo < 'a, 'b > }, None)" +--- +Named: + path: + elements: + - Foo + lifetimes: + - Named: a + - Named: b + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_boxes-2.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_boxes-2.snap new file mode 100644 index 000000000000..18a72a2ffe95 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_boxes-2.snap @@ -0,0 +1,11 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! { Box < MyLocalStruct > }, None)" +--- +Box: + Named: + path: + elements: + - MyLocalStruct + lifetimes: [] + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_boxes.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_boxes.snap new file mode 100644 index 000000000000..30d9ae3e16b4 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_boxes.snap @@ -0,0 +1,7 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! { Box < i32 > }, None)" +--- +Box: + Primitive: i32 + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_named.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_named.snap new file mode 100644 index 000000000000..f7763c5f4dd4 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_named.snap @@ -0,0 +1,10 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! { MyLocalStruct }, None)" +--- +Named: + path: + elements: + - MyLocalStruct + lifetimes: [] + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_option-2.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_option-2.snap new file mode 100644 index 000000000000..6ec59dd4bced --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_option-2.snap @@ -0,0 +1,11 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! { Option < MyLocalStruct > }, None)" +--- +Option: + Named: + path: + elements: + - MyLocalStruct + lifetimes: [] + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_option.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_option.snap new file mode 100644 index 000000000000..178ed4f069b2 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_option.snap @@ -0,0 +1,7 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! { Option < i32 > }, None)" +--- +Option: + Primitive: i32 + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_primitives-2.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_primitives-2.snap new file mode 100644 index 000000000000..38877277908c --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_primitives-2.snap @@ -0,0 +1,6 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! { usize }, None)" +--- +Primitive: usize + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_primitives-3.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_primitives-3.snap new file mode 100644 index 000000000000..2fac7f44aed9 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_primitives-3.snap @@ -0,0 +1,6 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! { bool }, None)" +--- +Primitive: bool + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_primitives.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_primitives.snap new file mode 100644 index 000000000000..5ef0eaf5e550 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_primitives.snap @@ -0,0 +1,6 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! { i32 }, None)" +--- +Primitive: i32 + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_references-2.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_references-2.snap new file mode 100644 index 000000000000..396affe3e3b4 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_references-2.snap @@ -0,0 +1,13 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! { & mut MyLocalStruct }, None)" +--- +Reference: + - Anonymous + - Mutable + - Named: + path: + elements: + - MyLocalStruct + lifetimes: [] + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_references.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_references.snap new file mode 100644 index 000000000000..38c72a4bd228 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_references.snap @@ -0,0 +1,9 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! { & i32 }, None)" +--- +Reference: + - Anonymous + - Immutable + - Primitive: i32 + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_result-2.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_result-2.snap new file mode 100644 index 000000000000..fdf85da6f49d --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_result-2.snap @@ -0,0 +1,13 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! {\n DiplomatResult < (), MyLocalStruct >\n }, None)" +--- +Result: + - Unit + - Named: + path: + elements: + - MyLocalStruct + lifetimes: [] + - false + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_result-3.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_result-3.snap new file mode 100644 index 000000000000..7b77d3d32545 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_result-3.snap @@ -0,0 +1,13 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! { Result < MyLocalStruct, i32 > }, None)" +--- +Result: + - Named: + path: + elements: + - MyLocalStruct + lifetimes: [] + - Primitive: i32 + - true + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_result-4.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_result-4.snap new file mode 100644 index 000000000000..b0a0feeb910b --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_result-4.snap @@ -0,0 +1,13 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! { Result < (), MyLocalStruct > }, None)" +--- +Result: + - Unit + - Named: + path: + elements: + - MyLocalStruct + lifetimes: [] + - true + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_result.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_result.snap new file mode 100644 index 000000000000..a6c6687d3758 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__types__tests__typename_result.snap @@ -0,0 +1,13 @@ +--- +source: core/src/ast/types.rs +expression: "TypeName::from_syn(&syn::parse_quote! {\n DiplomatResult < MyLocalStruct, i32 >\n }, None)" +--- +Result: + - Named: + path: + elements: + - MyLocalStruct + lifetimes: [] + - Primitive: i32 + - false + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__non_opaque_move.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__non_opaque_move.snap new file mode 100644 index 000000000000..4d95880db522 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__non_opaque_move.snap @@ -0,0 +1,9 @@ +--- +source: core/src/ast/validity.rs +expression: output +--- +A non-opaque type was found behind a Box or reference, these can only be handled by-move as they get converted at the FFI boundary: NonOpaque +A non-opaque type was found behind a Box or reference, these can only be handled by-move as they get converted at the FFI boundary: NonOpaque +A non-opaque type was found behind a Box or reference, these can only be handled by-move as they get converted at the FFI boundary: NonOpaque +A non-opaque type was found behind a Box or reference, these can only be handled by-move as they get converted at the FFI boundary: NonOpaque + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__opaque_checks_with_error.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__opaque_checks_with_error.snap new file mode 100644 index 000000000000..71c938260863 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__opaque_checks_with_error.snap @@ -0,0 +1,7 @@ +--- +source: core/src/ast/validity.rs +expression: output +--- +An opaque type crossed the FFI boundary as a value: OpaqueStruct +An opaque type crossed the FFI boundary as a value: OpaqueStruct + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__opaque_checks_with_safe_use.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__opaque_checks_with_safe_use.snap new file mode 100644 index 000000000000..d6caef53180b --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__opaque_checks_with_safe_use.snap @@ -0,0 +1,6 @@ +--- +source: core/src/ast/validity.rs +expression: output +--- +A non-opaque zero-sized struct or enum has been defined: ffi::NonOpaqueStruct + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__opaque_ffi.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__opaque_ffi.snap new file mode 100644 index 000000000000..c0ec108b4c25 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__opaque_ffi.snap @@ -0,0 +1,7 @@ +--- +source: core/src/ast/validity.rs +expression: output +--- +An opaque type crossed the FFI boundary as a value: MyOpaqueStruct +An opaque type crossed the FFI boundary as a value: MyOpaqueStruct + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__option_invalid.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__option_invalid.snap new file mode 100644 index 000000000000..8efd837e9c0d --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__option_invalid.snap @@ -0,0 +1,9 @@ +--- +source: core/src/ast/validity.rs +expression: output +--- +A non-reference type was found inside an Option: Option +A non-reference type was found inside an Option: Option> +A non-reference type was found inside an Option: Option +A non-reference type was found inside an Option: Option + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__option_valid.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__option_valid.snap new file mode 100644 index 000000000000..1dd797bbfbba --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__option_valid.snap @@ -0,0 +1,5 @@ +--- +source: core/src/ast/validity.rs +expression: output +--- + diff --git a/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__zst_non_opaque.snap b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__zst_non_opaque.snap new file mode 100644 index 000000000000..6bea4ec7da21 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/snapshots/diplomat_core__ast__validity__tests__zst_non_opaque.snap @@ -0,0 +1,7 @@ +--- +source: core/src/ast/validity.rs +expression: output +--- +A non-opaque zero-sized struct or enum has been defined: ffi::OpaqueEnum +A non-opaque zero-sized struct or enum has been defined: ffi::OpaqueStruct + diff --git a/third_party/rust/diplomat_core/src/ast/structs.rs b/third_party/rust/diplomat_core/src/ast/structs.rs new file mode 100644 index 000000000000..e79613820019 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/structs.rs @@ -0,0 +1,109 @@ +use serde::{Deserialize, Serialize}; + +use super::docs::Docs; +use super::{attrs, Ident, LifetimeEnv, Method, Mutability, PathType, TypeName}; + +/// A struct declaration in an FFI module that is not opaque. +#[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Debug)] +pub struct Struct { + pub name: Ident, + pub docs: Docs, + pub lifetimes: LifetimeEnv, + pub fields: Vec<(Ident, TypeName, Docs)>, + pub methods: Vec, + pub output_only: bool, + pub cfg_attrs: Vec, +} + +impl Struct { + /// Extract a [`Struct`] metadata value from an AST node. + pub fn new(strct: &syn::ItemStruct, output_only: bool) -> Self { + let self_path_type = PathType::extract_self_type(strct); + let fields: Vec<_> = strct + .fields + .iter() + .map(|field| { + // Non-opaque tuple structs will never be allowed + let name = field + .ident + .as_ref() + .map(Into::into) + .expect("non-opaque tuples structs are disallowed"); + let type_name = TypeName::from_syn(&field.ty, Some(self_path_type.clone())); + let docs = Docs::from_attrs(&field.attrs); + + (name, type_name, docs) + }) + .collect(); + + let lifetimes = LifetimeEnv::from_struct_item(strct, &fields[..]); + let cfg_attrs = attrs::extract_cfg_attrs(&strct.attrs).collect(); + + Struct { + name: (&strct.ident).into(), + docs: Docs::from_attrs(&strct.attrs), + lifetimes, + fields, + methods: vec![], + output_only, + cfg_attrs, + } + } +} + +/// A struct annotated with [`diplomat::opaque`] whose fields are not visible. +/// Opaque structs cannot be passed by-value across the FFI boundary, so they +/// must be boxed or passed as references. +#[derive(Clone, Serialize, Deserialize, Debug, Hash, PartialEq, Eq)] +pub struct OpaqueStruct { + pub name: Ident, + pub docs: Docs, + pub lifetimes: LifetimeEnv, + pub methods: Vec, + pub mutability: Mutability, + pub cfg_attrs: Vec, +} + +impl OpaqueStruct { + /// Extract a [`OpaqueStruct`] metadata value from an AST node. + pub fn new(strct: &syn::ItemStruct, mutability: Mutability) -> Self { + let cfg_attrs = attrs::extract_cfg_attrs(&strct.attrs).collect(); + OpaqueStruct { + name: Ident::from(&strct.ident), + docs: Docs::from_attrs(&strct.attrs), + lifetimes: LifetimeEnv::from_struct_item(strct, &[]), + methods: vec![], + mutability, + cfg_attrs, + } + } +} + +#[cfg(test)] +mod tests { + use insta::{self, Settings}; + + use syn; + + use super::Struct; + + #[test] + fn simple_struct() { + let mut settings = Settings::new(); + settings.set_sort_maps(true); + + settings.bind(|| { + insta::assert_yaml_snapshot!(Struct::new( + &syn::parse_quote! { + /// Some docs. + #[diplomat::rust_link(foo::Bar, Struct)] + struct MyLocalStruct { + a: i32, + b: Box + } + }, + true + )); + }); + } +} diff --git a/third_party/rust/diplomat_core/src/ast/types.rs b/third_party/rust/diplomat_core/src/ast/types.rs new file mode 100644 index 000000000000..178fa2699921 --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/types.rs @@ -0,0 +1,1219 @@ +use proc_macro2::Span; +use quote::ToTokens; +use serde::{Deserialize, Serialize}; +use syn::{punctuated::Punctuated, *}; + +use lazy_static::lazy_static; +use std::collections::HashMap; +use std::fmt; +use std::ops::ControlFlow; + +use super::{ + Docs, Enum, Ident, Lifetime, LifetimeEnv, LifetimeTransitivity, Method, NamedLifetime, + OpaqueStruct, Path, RustLink, Struct, ValidityError, +}; +use crate::Env; + +/// A type declared inside a Diplomat-annotated module. +#[derive(Clone, Serialize, Deserialize, Debug, Hash, PartialEq, Eq)] +pub enum CustomType { + /// A non-opaque struct whose fields will be visible across the FFI boundary. + Struct(Struct), + /// A struct annotated with [`diplomat::opaque`] whose fields are not visible. + Opaque(OpaqueStruct), + /// A fieldless enum. + Enum(Enum), +} + +impl CustomType { + /// Get the name of the custom type, which is unique within a module. + pub fn name(&self) -> &Ident { + match self { + CustomType::Struct(strct) => &strct.name, + CustomType::Opaque(strct) => &strct.name, + CustomType::Enum(enm) => &enm.name, + } + } + + /// Get the methods declared in impls of the custom type. + pub fn methods(&self) -> &Vec { + match self { + CustomType::Struct(strct) => &strct.methods, + CustomType::Opaque(strct) => &strct.methods, + CustomType::Enum(enm) => &enm.methods, + } + } + + pub fn cfg_attrs(&self) -> &[String] { + match self { + CustomType::Struct(strct) => &strct.cfg_attrs, + CustomType::Opaque(strct) => &strct.cfg_attrs, + CustomType::Enum(enm) => &enm.cfg_attrs, + } + } + + /// Get the doc lines of the custom type. + pub fn docs(&self) -> &Docs { + match self { + CustomType::Struct(strct) => &strct.docs, + CustomType::Opaque(strct) => &strct.docs, + CustomType::Enum(enm) => &enm.docs, + } + } + + /// Get all rust links on this type and its methods + pub fn all_rust_links(&self) -> impl Iterator + '_ { + [self.docs()] + .into_iter() + .chain(self.methods().iter().map(|m| m.docs())) + .flat_map(|d| d.rust_links().iter()) + } + + pub fn self_path(&self, in_path: &Path) -> Path { + in_path.sub_path(self.name().clone()) + } + + /// Get the lifetimes of the custom type. + pub fn lifetimes(&self) -> Option<&LifetimeEnv> { + match self { + CustomType::Struct(strct) => Some(&strct.lifetimes), + CustomType::Opaque(strct) => Some(&strct.lifetimes), + CustomType::Enum(_) => None, + } + } + + /// Performs various validity checks: + /// + /// - Checks that any references to opaque structs in parameters or return values + /// are always behind a box or reference, and that non-opaque custom types are *never* behind + /// references or boxes. The latter check is needed because non-opaque custom types typically get + /// *converted* at the FFI boundary. + /// - Ensures that we are not exporting any non-opaque zero-sized types + /// - Ensures that Options only contain boxes and references + /// + /// Errors are pushed into the `errors` vector. + pub fn check_validity<'a>( + &'a self, + in_path: &Path, + env: &Env, + errors: &mut Vec, + ) { + match self { + CustomType::Struct(strct) => { + for (_, field, _) in strct.fields.iter() { + field.check_validity(in_path, env, errors); + } + + // check for ZSTs + if !strct.fields.iter().any(|f| !f.1.is_zst()) { + errors.push(ValidityError::NonOpaqueZST(self.self_path(in_path))) + } + } + CustomType::Opaque(_) => {} + CustomType::Enum(e) => { + // check for ZSTs + if e.variants.is_empty() { + errors.push(ValidityError::NonOpaqueZST(self.self_path(in_path))) + } + } + } + + for method in self.methods().iter() { + method.check_validity(in_path, env, errors); + } + } +} + +/// A symbol declared in a module, which can either be a pointer to another path, +/// or a custom type defined directly inside that module +#[derive(Clone, Serialize, Deserialize, Debug)] +pub enum ModSymbol { + /// A symbol that is a pointer to another path. + Alias(Path), + /// A symbol that is a submodule. + SubModule(Ident), + /// A symbol that is a custom type. + CustomType(CustomType), +} + +/// A named type that is just a path, e.g. `std::borrow::Cow<'a, T>`. +#[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Debug)] +pub struct PathType { + pub path: Path, + pub lifetimes: Vec, +} + +impl PathType { + pub fn to_syn(&self) -> syn::TypePath { + let mut path = self.path.to_syn(); + + if !self.lifetimes.is_empty() { + if let Some(seg) = path.segments.last_mut() { + let lifetimes = &self.lifetimes; + seg.arguments = + syn::PathArguments::AngleBracketed(syn::parse_quote! { <#(#lifetimes),*> }); + } + } + + syn::TypePath { qself: None, path } + } + + pub fn new(path: Path) -> Self { + Self { + path, + lifetimes: vec![], + } + } + + /// Get the `Self` type from a struct declaration. + /// + /// Consider the following struct declaration: + /// ``` + /// struct RefList<'a> { + /// data: &'a i32, + /// next: Option>, + /// } + /// ``` + /// When determining what type `Self` is in the `next` field, we would have to call + /// this method on the `syn::ItemStruct` that represents this struct declaration. + /// This method would then return a `PathType` representing `RefList<'a>`, so we + /// know that's what `Self` should refer to. + /// + /// The reason this function exists though is so when we convert the fields' types + /// to `PathType`s, we don't panic. We don't actually need to write the struct's + /// field types expanded in the macro, so this function is more for correctness, + pub fn extract_self_type(strct: &syn::ItemStruct) -> Self { + let self_name = (&strct.ident).into(); + + PathType { + path: Path { + elements: vec![self_name], + }, + lifetimes: strct + .generics + .lifetimes() + .map(|lt_def| (<_def.lifetime).into()) + .collect(), + } + } + + /// If this is a [`TypeName::Named`], grab the [`CustomType`] it points to from + /// the `env`, which contains all [`CustomType`]s across all FFI modules. + /// + /// Also returns the path the CustomType is in (useful for resolving fields) + pub fn resolve_with_path<'a>(&self, in_path: &Path, env: &'a Env) -> (Path, &'a CustomType) { + let local_path = &self.path; + let mut cur_path = in_path.clone(); + for (i, elem) in local_path.elements.iter().enumerate() { + match elem.as_str() { + "crate" => { + // TODO(#34): get the name of enclosing crate from env when we support multiple crates + cur_path = Path::empty() + } + + "super" => cur_path = cur_path.get_super(), + + o => match env.get(&cur_path, o) { + Some(ModSymbol::Alias(p)) => { + let mut remaining_elements: Vec = + local_path.elements.iter().skip(i + 1).cloned().collect(); + let mut new_path = p.elements.clone(); + new_path.append(&mut remaining_elements); + return PathType::new(Path { elements: new_path }) + .resolve_with_path(&cur_path.clone(), env); + } + Some(ModSymbol::SubModule(name)) => { + cur_path.elements.push(name.clone()); + } + Some(ModSymbol::CustomType(t)) => { + if i == local_path.elements.len() - 1 { + return (cur_path, t); + } else { + panic!( + "Unexpected custom type when resolving symbol {} in {}", + o, + cur_path.elements.join("::") + ) + } + } + None => panic!( + "Could not resolve symbol {} in {}", + o, + cur_path.elements.join("::") + ), + }, + } + } + + panic!( + "Path {} does not point to a custom type", + in_path.elements.join("::") + ) + } + + /// If this is a [`TypeName::Named`], grab the [`CustomType`] it points to from + /// the `env`, which contains all [`CustomType`]s across all FFI modules. + /// + /// If you need to resolve struct fields later, call [`Self::resolve_with_path()`] instead + /// to get the path to resolve the fields in. + pub fn resolve<'a>(&self, in_path: &Path, env: &'a Env) -> &'a CustomType { + self.resolve_with_path(in_path, env).1 + } +} + +impl From<&syn::TypePath> for PathType { + fn from(other: &syn::TypePath) -> Self { + let lifetimes = other + .path + .segments + .last() + .and_then(|last| { + if let PathArguments::AngleBracketed(angle_generics) = &last.arguments { + Some( + angle_generics + .args + .iter() + .map(|generic_arg| match generic_arg { + GenericArgument::Lifetime(lifetime) => lifetime.into(), + _ => panic!("generic type arguments are unsupported"), + }) + .collect(), + ) + } else { + None + } + }) + .unwrap_or_default(); + + Self { + path: Path::from_syn(&other.path), + lifetimes, + } + } +} + +impl From for PathType { + fn from(other: Path) -> Self { + PathType::new(other) + } +} + +#[derive(Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Debug)] +pub enum Mutability { + Mutable, + Immutable, +} + +impl Mutability { + pub fn to_syn(&self) -> Option { + match self { + Mutability::Mutable => Some(syn::token::Mut(Span::call_site())), + Mutability::Immutable => None, + } + } + + pub fn from_syn(t: &Option) -> Self { + match t { + Some(_) => Mutability::Mutable, + None => Mutability::Immutable, + } + } + + /// Returns `true` if `&self` is the mutable variant, otherwise `false`. + pub fn is_mutable(&self) -> bool { + matches!(self, Mutability::Mutable) + } + + /// Returns `true` if `&self` is the immutable variant, otherwise `false`. + pub fn is_immutable(&self) -> bool { + matches!(self, Mutability::Immutable) + } + + /// Shorthand ternary operator for choosing a value based on whether + /// a `Mutability` is mutable or immutable. + /// + /// The following pattern (with very slight variations) shows up often in code gen: + /// ```ignore + /// if mutability.is_mutable() { + /// "" + /// } else { + /// "const " + /// } + /// ``` + /// This is particularly annoying in `write!(...)` statements, where `cargo fmt` + /// expands it to take up 5 lines. + /// + /// This method offers a 1-line alternative: + /// ```ignore + /// mutability.if_mut_else("", "const ") + /// ``` + /// For cases where lazy evaluation is desired, consider using a conditional + /// or a `match` statement. + pub fn if_mut_else(&self, if_mut: T, if_immut: T) -> T { + match self { + Mutability::Mutable => if_mut, + Mutability::Immutable => if_immut, + } + } +} + +/// A local type reference, such as the type of a field, parameter, or return value. +/// Unlike [`CustomType`], which represents a type declaration, [`TypeName`]s can compose +/// types through references and boxing, and can also capture unresolved paths. +#[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize, Debug)] +pub enum TypeName { + /// A built-in Rust scalar primitive. + Primitive(PrimitiveType), + /// An unresolved path to a custom type, which can be resolved after all types + /// are collected with [`TypeName::resolve()`]. + Named(PathType), + /// An optionally mutable reference to another type. + Reference(Lifetime, Mutability, Box), + /// A `Box` type. + Box(Box), + /// A `Option` type. + Option(Box), + /// A `Result` or `diplomat_runtime::DiplomatWriteable` type. If the bool is true, it's `Result` + Result(Box, Box, bool), + Writeable, + /// A `&str` type. + StrReference(Lifetime), + /// A `&[T]` type, where `T` is a primitive. + PrimitiveSlice(Lifetime, Mutability, PrimitiveType), + /// The `()` type. + Unit, + /// The `Self` type. + SelfType(PathType), +} + +impl TypeName { + /// Converts the [`TypeName`] back into an AST node that can be spliced into a program. + pub fn to_syn(&self) -> syn::Type { + match self { + TypeName::Primitive(name) => { + syn::Type::Path(syn::parse_str(PRIMITIVE_TO_STRING.get(name).unwrap()).unwrap()) + } + TypeName::Named(name) | TypeName::SelfType(name) => { + // Self also gets expanded instead of turning into `Self` because + // this code is used to generate the `extern "C"` functions, which + // aren't in an impl block. + syn::Type::Path(name.to_syn()) + } + TypeName::Reference(lifetime, mutability, underlying) => { + syn::Type::Reference(TypeReference { + and_token: syn::token::And(Span::call_site()), + lifetime: lifetime.to_syn(), + mutability: mutability.to_syn(), + elem: Box::new(underlying.to_syn()), + }) + } + TypeName::Box(underlying) => syn::Type::Path(TypePath { + qself: None, + path: syn::Path { + leading_colon: None, + segments: Punctuated::from_iter(vec![PathSegment { + ident: syn::Ident::new("Box", Span::call_site()), + arguments: PathArguments::AngleBracketed(AngleBracketedGenericArguments { + colon2_token: None, + lt_token: syn::token::Lt(Span::call_site()), + args: Punctuated::from_iter(vec![GenericArgument::Type( + underlying.to_syn(), + )]), + gt_token: syn::token::Gt(Span::call_site()), + }), + }]), + }, + }), + TypeName::Option(underlying) => syn::Type::Path(TypePath { + qself: None, + path: syn::Path { + leading_colon: None, + segments: Punctuated::from_iter(vec![PathSegment { + ident: syn::Ident::new("Option", Span::call_site()), + arguments: PathArguments::AngleBracketed(AngleBracketedGenericArguments { + colon2_token: None, + lt_token: syn::token::Lt(Span::call_site()), + args: Punctuated::from_iter(vec![GenericArgument::Type( + underlying.to_syn(), + )]), + gt_token: syn::token::Gt(Span::call_site()), + }), + }]), + }, + }), + TypeName::Result(ok, err, true) => syn::Type::Path(TypePath { + qself: None, + path: syn::Path { + leading_colon: None, + segments: Punctuated::from_iter(vec![PathSegment { + ident: syn::Ident::new("Result", Span::call_site()), + arguments: PathArguments::AngleBracketed(AngleBracketedGenericArguments { + colon2_token: None, + lt_token: syn::token::Lt(Span::call_site()), + args: Punctuated::from_iter(vec![ + GenericArgument::Type(ok.to_syn()), + GenericArgument::Type(err.to_syn()), + ]), + gt_token: syn::token::Gt(Span::call_site()), + }), + }]), + }, + }), + TypeName::Result(ok, err, false) => syn::Type::Path(TypePath { + qself: None, + path: syn::Path { + leading_colon: None, + segments: Punctuated::from_iter(vec![ + PathSegment { + ident: syn::Ident::new("diplomat_runtime", Span::call_site()), + arguments: PathArguments::None, + }, + PathSegment { + ident: syn::Ident::new("DiplomatResult", Span::call_site()), + arguments: PathArguments::AngleBracketed( + AngleBracketedGenericArguments { + colon2_token: None, + lt_token: syn::token::Lt(Span::call_site()), + args: Punctuated::from_iter(vec![ + GenericArgument::Type(ok.to_syn()), + GenericArgument::Type(err.to_syn()), + ]), + gt_token: syn::token::Gt(Span::call_site()), + }, + ), + }, + ]), + }, + }), + TypeName::Writeable => syn::parse_quote! { + diplomat_runtime::DiplomatWriteable + }, + TypeName::StrReference(lifetime) => syn::parse_str(&format!( + "{}str", + ReferenceDisplay(lifetime, &Mutability::Immutable) + )) + .unwrap(), + TypeName::PrimitiveSlice(lifetime, mutability, name) => { + let primitive_name = PRIMITIVE_TO_STRING.get(name).unwrap(); + let formatted_str = format!( + "{}[{}]", + ReferenceDisplay(lifetime, mutability), + primitive_name + ); + syn::parse_str(&formatted_str).unwrap() + } + TypeName::Unit => syn::parse_quote! { + () + }, + } + } + + /// Extract a [`TypeName`] from a [`syn::Type`] AST node. + /// The following rules are used to infer [`TypeName`] variants: + /// - If the type is a path with a single element that is the name of a Rust primitive, returns a [`TypeName::Primitive`] + /// - If the type is a path with a single element [`Box`], returns a [`TypeName::Box`] with the type parameter recursively converted + /// - If the type is a path with a single element [`Option`], returns a [`TypeName::Option`] with the type parameter recursively converted + /// - If the type is a path with a single element `Self` and `self_path_type` is provided, returns a [`TypeName::Named`] + /// - If the type is a path with a single element [`Result`], returns a [`TypeName::Result`] with the type parameters recursively converted + /// - If the type is a path equal to [`diplomat_runtime::DiplomatResult`], returns a [`TypeName::DiplomatResult`] with the type parameters recursively converted + /// - If the type is a path equal to [`diplomat_runtime::DiplomatWriteable`], returns a [`TypeName::Writeable`] + /// - If the type is a reference to `str`, returns a [`TypeName::StrReference`] + /// - If the type is a reference to a slice of a Rust primitive, returns a [`TypeName::PrimitiveSlice`] + /// - If the type is a reference (`&` or `&mut`), returns a [`TypeName::Reference`] with the referenced type recursively converted + /// - Otherwise, assume that the reference is to a [`CustomType`] in either the current module or another one, returns a [`TypeName::Named`] + pub fn from_syn(ty: &syn::Type, self_path_type: Option) -> TypeName { + match ty { + syn::Type::Reference(r) => { + let lifetime = Lifetime::from(&r.lifetime); + let mutability = Mutability::from_syn(&r.mutability); + + if r.elem.to_token_stream().to_string() == "str" { + if mutability.is_mutable() { + panic!("mutable `str` references are disallowed"); + } + return TypeName::StrReference(lifetime); + } + if let syn::Type::Slice(slice) = &*r.elem { + if let syn::Type::Path(p) = &*slice.elem { + if let Some(primitive) = p + .path + .get_ident() + .and_then(|i| STRING_TO_PRIMITIVE.get(i.to_string().as_str())) + { + return TypeName::PrimitiveSlice(lifetime, mutability, *primitive); + } + } + } + TypeName::Reference( + lifetime, + mutability, + Box::new(TypeName::from_syn(r.elem.as_ref(), self_path_type)), + ) + } + syn::Type::Path(p) => { + if let Some(primitive) = p + .path + .get_ident() + .and_then(|i| STRING_TO_PRIMITIVE.get(i.to_string().as_str())) + { + TypeName::Primitive(*primitive) + } else if p.path.segments.len() == 1 && p.path.segments[0].ident == "Box" { + if let PathArguments::AngleBracketed(type_args) = &p.path.segments[0].arguments + { + if let GenericArgument::Type(tpe) = &type_args.args[0] { + TypeName::Box(Box::new(TypeName::from_syn(tpe, self_path_type))) + } else { + panic!("Expected first type argument for Box to be a type") + } + } else { + panic!("Expected angle brackets for Box type") + } + } else if p.path.segments.len() == 1 && p.path.segments[0].ident == "Option" { + if let PathArguments::AngleBracketed(type_args) = &p.path.segments[0].arguments + { + if let GenericArgument::Type(tpe) = &type_args.args[0] { + TypeName::Option(Box::new(TypeName::from_syn(tpe, self_path_type))) + } else { + panic!("Expected first type argument for Option to be a type") + } + } else { + panic!("Expected angle brackets for Option type") + } + } else if p.path.segments.len() == 1 && p.path.segments[0].ident == "Self" { + if let Some(self_path_type) = self_path_type { + TypeName::SelfType(self_path_type) + } else { + panic!("Cannot have `Self` type outside of a method"); + } + } else if p.path.segments.len() == 1 && p.path.segments[0].ident == "Result" + || is_runtime_type(p, "DiplomatResult") + { + if let PathArguments::AngleBracketed(type_args) = + &p.path.segments.last().unwrap().arguments + { + if let (GenericArgument::Type(ok), GenericArgument::Type(err)) = + (&type_args.args[0], &type_args.args[1]) + { + let ok = TypeName::from_syn(ok, self_path_type.clone()); + let err = TypeName::from_syn(err, self_path_type); + TypeName::Result( + Box::new(ok), + Box::new(err), + !is_runtime_type(p, "DiplomatResult"), + ) + } else { + panic!("Expected both type arguments for Result to be a type") + } + } else { + panic!("Expected angle brackets for Result type") + } + } else if is_runtime_type(p, "DiplomatWriteable") { + TypeName::Writeable + } else { + TypeName::Named(PathType::from(p)) + } + } + syn::Type::Tuple(tup) => { + if tup.elems.is_empty() { + TypeName::Unit + } else { + todo!("Tuples are not currently supported") + } + } + other => panic!("Unsupported type: {}", other.to_token_stream()), + } + } + + /// Returns `true` if `self` is the `TypeName::SelfType` variant, otherwise + /// `false`. + pub fn is_self(&self) -> bool { + matches!(self, TypeName::SelfType(_)) + } + + /// Recurse down the type tree, visiting all lifetimes. + /// + /// Using this function, you can collect all the lifetimes into a collection, + /// or examine each one without having to make any additional allocations. + pub fn visit_lifetimes<'a, F, B>(&'a self, visit: &mut F) -> ControlFlow + where + F: FnMut(&'a Lifetime, LifetimeOrigin) -> ControlFlow, + { + match self { + TypeName::Named(path_type) | TypeName::SelfType(path_type) => path_type + .lifetimes + .iter() + .try_for_each(|lt| visit(lt, LifetimeOrigin::Named)), + TypeName::Reference(lt, _, ty) => { + ty.visit_lifetimes(visit)?; + visit(lt, LifetimeOrigin::Reference) + } + TypeName::Box(ty) | TypeName::Option(ty) => ty.visit_lifetimes(visit), + TypeName::Result(ok, err, _) => { + ok.visit_lifetimes(visit)?; + err.visit_lifetimes(visit) + } + TypeName::StrReference(lt) => visit(lt, LifetimeOrigin::StrReference), + TypeName::PrimitiveSlice(lt, ..) => visit(lt, LifetimeOrigin::PrimitiveSlice), + _ => ControlFlow::Continue(()), + } + } + + /// Returns `true` if any lifetime satisfies a predicate, otherwise `false`. + /// + /// This method is short-circuiting, meaning that if the predicate ever succeeds, + /// it will return immediately. + pub fn any_lifetime<'a, F>(&'a self, mut f: F) -> bool + where + F: FnMut(&'a Lifetime, LifetimeOrigin) -> bool, + { + self.visit_lifetimes(&mut |lifetime, origin| { + if f(lifetime, origin) { + ControlFlow::Break(()) + } else { + ControlFlow::Continue(()) + } + }) + .is_break() + } + + /// Returns `true` if all lifetimes satisfy a predicate, otherwise `false`. + /// + /// This method is short-circuiting, meaning that if the predicate ever fails, + /// it will return immediately. + pub fn all_lifetimes<'a, F>(&'a self, mut f: F) -> bool + where + F: FnMut(&'a Lifetime, LifetimeOrigin) -> bool, + { + self.visit_lifetimes(&mut |lifetime, origin| { + if f(lifetime, origin) { + ControlFlow::Continue(()) + } else { + ControlFlow::Break(()) + } + }) + .is_continue() + } + + /// Returns all lifetimes in a [`LifetimeEnv`] that must live at least as + /// long as the type. + pub fn longer_lifetimes<'env>( + &self, + lifetime_env: &'env LifetimeEnv, + ) -> Vec<&'env NamedLifetime> { + self.transitive_lifetime_bounds(LifetimeTransitivity::longer(lifetime_env)) + } + + /// Returns all lifetimes in a [`LifetimeEnv`] that are outlived by the type. + pub fn shorter_lifetimes<'env>( + &self, + lifetime_env: &'env LifetimeEnv, + ) -> Vec<&'env NamedLifetime> { + self.transitive_lifetime_bounds(LifetimeTransitivity::shorter(lifetime_env)) + } + + /// Visits the provided [`LifetimeTransitivity`] value with all `NamedLifetime`s + /// in the type tree, and returns the transitively reachable lifetimes. + fn transitive_lifetime_bounds<'env>( + &self, + mut transitivity: LifetimeTransitivity<'env>, + ) -> Vec<&'env NamedLifetime> { + self.visit_lifetimes(&mut |lifetime, _| -> ControlFlow<()> { + if let Lifetime::Named(named) = lifetime { + transitivity.visit(named); + } + ControlFlow::Continue(()) + }); + transitivity.finish() + } + + fn check_opaque<'a>( + &'a self, + in_path: &Path, + env: &Env, + behind_reference: bool, + errors: &mut Vec, + ) { + match self { + TypeName::Reference(.., underlying) => { + underlying.check_opaque(in_path, env, true, errors) + } + TypeName::Box(underlying) => underlying.check_opaque(in_path, env, true, errors), + TypeName::Option(underlying) => underlying.check_opaque(in_path, env, false, errors), + TypeName::Result(ok, err, _) => { + ok.check_opaque(in_path, env, false, errors); + err.check_opaque(in_path, env, false, errors); + } + TypeName::Named(path_type) => { + if let CustomType::Opaque(_) = path_type.resolve(in_path, env) { + if !behind_reference { + errors.push(ValidityError::OpaqueAsValue(self.clone())) + } + } else if behind_reference { + errors.push(ValidityError::NonOpaqueBehindRef(self.clone())) + } + } + _ => {} + } + } + + // Disallow non-pointer containing Option inside struct fields and Result + fn check_option(&self, errors: &mut Vec) { + match self { + TypeName::Reference(.., underlying) => underlying.check_option(errors), + TypeName::Box(underlying) => underlying.check_option(errors), + TypeName::Option(underlying) => { + if !underlying.is_pointer() { + errors.push(ValidityError::OptionNotContainingPointer(self.clone())) + } + } + TypeName::Result(ok, err, _) => { + ok.check_option(errors); + err.check_option(errors); + } + _ => {} + } + } + + /// Checks that any references to opaque structs in parameters or return values + /// are always behind a box or reference, and that non-opaque custom types are *never* behind + /// references or boxes. + /// + /// Also checks that there are no elided lifetimes in the return type. + /// + /// Errors are pushed into the `errors` vector. + pub fn check_validity<'a>( + &'a self, + in_path: &Path, + env: &Env, + errors: &mut Vec, + ) { + self.check_opaque(in_path, env, false, errors); + self.check_option(errors); + } + + /// Checks the validity of return types. + /// + /// This is equivalent to `TypeName::check_validity`, but it also ensures + /// that the type doesn't elide any lifetimes. + /// + /// Once we decide to support lifetime elision in return types, this function + /// will probably be removed. + pub fn check_return_type_validity( + &self, + in_path: &Path, + env: &Env, + errors: &mut Vec, + ) { + self.check_validity(in_path, env, errors); + self.check_lifetime_elision(self, in_path, env, errors); + } + + /// Checks that there aren't any elided lifetimes. + fn check_lifetime_elision( + &self, + full_type: &Self, + in_path: &Path, + env: &Env, + errors: &mut Vec, + ) { + match self { + TypeName::Named(path_type) | TypeName::SelfType(path_type) => { + let (_path, custom) = path_type.resolve_with_path(in_path, env); + if let Some(lifetimes) = custom.lifetimes() { + let lifetimes_provided = path_type + .lifetimes + .iter() + .filter(|lt| !matches!(lt, Lifetime::Anonymous)) + .count(); + + if lifetimes_provided != lifetimes.len() { + // There's a discrepency between the number of declared + // lifetimes and the number of lifetimes provided in + // the return type, so there must have been elision. + errors.push(ValidityError::LifetimeElisionInReturn { + full_type: full_type.clone(), + sub_type: self.clone(), + }); + } else { + // The struct was written with the number of lifetimes + // that it was declared with, so we're good. + } + } else { + // `CustomType::Enum`, which doesn't have any lifetimes. + // We already checked that enums don't have generics in + // core. + } + } + TypeName::Reference(lifetime, _, ty) => { + if let Lifetime::Anonymous = lifetime { + errors.push(ValidityError::LifetimeElisionInReturn { + full_type: full_type.clone(), + sub_type: self.clone(), + }); + } + + ty.check_lifetime_elision(full_type, in_path, env, errors); + } + TypeName::Box(ty) | TypeName::Option(ty) => { + ty.check_lifetime_elision(full_type, in_path, env, errors) + } + TypeName::Result(ok, err, _) => { + ok.check_lifetime_elision(full_type, in_path, env, errors); + err.check_lifetime_elision(full_type, in_path, env, errors); + } + TypeName::StrReference(Lifetime::Anonymous) + | TypeName::PrimitiveSlice(Lifetime::Anonymous, ..) => { + errors.push(ValidityError::LifetimeElisionInReturn { + full_type: full_type.clone(), + sub_type: self.clone(), + }); + } + _ => {} + } + } + + pub fn is_zst(&self) -> bool { + // check_zst() prevents non-unit types from being ZSTs + matches!(*self, TypeName::Unit) + } + + pub fn is_pointer(&self) -> bool { + matches!(*self, TypeName::Reference(..) | TypeName::Box(_)) + } +} + +pub enum LifetimeOrigin { + Named, + Reference, + StrReference, + PrimitiveSlice, +} + +fn is_runtime_type(p: &TypePath, name: &str) -> bool { + (p.path.segments.len() == 1 && p.path.segments[0].ident == name) + || (p.path.segments.len() == 2 + && p.path.segments[0].ident == "diplomat_runtime" + && p.path.segments[1].ident == name) +} + +impl fmt::Display for TypeName { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + TypeName::Primitive(p) => p.fmt(f), + TypeName::Named(p) | TypeName::SelfType(p) => p.fmt(f), + TypeName::Reference(lifetime, mutability, typ) => { + write!(f, "{}{typ}", ReferenceDisplay(lifetime, mutability)) + } + TypeName::Box(typ) => write!(f, "Box<{typ}>"), + TypeName::Option(typ) => write!(f, "Option<{typ}>"), + TypeName::Result(ok, err, _) => { + write!(f, "Result<{ok}, {err}>") + } + TypeName::Writeable => "DiplomatWriteable".fmt(f), + TypeName::StrReference(lifetime) => { + write!( + f, + "{}str", + ReferenceDisplay(lifetime, &Mutability::Immutable) + ) + } + TypeName::PrimitiveSlice(lifetime, mutability, typ) => { + write!(f, "{}[{typ}]", ReferenceDisplay(lifetime, mutability)) + } + TypeName::Unit => "()".fmt(f), + } + } +} + +/// An [`fmt::Display`] type for formatting Rust references. +/// +/// # Examples +/// +/// ```ignore +/// let lifetime = Lifetime::from(&syn::parse_str::("'a")); +/// let mutability = Mutability::Mutable; +/// // ... +/// let fmt = format!("{}[u8]", ReferenceDisplay(&lifetime, &mutability)); +/// +/// assert_eq!(fmt, "&'a mut [u8]"); +/// ``` +struct ReferenceDisplay<'a>(&'a Lifetime, &'a Mutability); + +impl<'a> fmt::Display for ReferenceDisplay<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.0 { + Lifetime::Static => "&'static ".fmt(f)?, + Lifetime::Named(lifetime) => write!(f, "&{lifetime} ")?, + Lifetime::Anonymous => '&'.fmt(f)?, + } + + if self.1.is_mutable() { + "mut ".fmt(f)?; + } + + Ok(()) + } +} + +impl fmt::Display for PathType { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.path.fmt(f)?; + + if let Some((first, rest)) = self.lifetimes.split_first() { + write!(f, "<{first}")?; + for lifetime in rest { + write!(f, ", {lifetime}")?; + } + '>'.fmt(f)?; + } + Ok(()) + } +} + +/// A built-in Rust primitive scalar type. +#[derive(Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Debug)] +#[allow(non_camel_case_types)] +pub enum PrimitiveType { + i8, + u8, + i16, + u16, + i32, + u32, + i64, + u64, + i128, + u128, + isize, + usize, + f32, + f64, + bool, + char, +} + +impl fmt::Display for PrimitiveType { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + PrimitiveType::i8 => "i8", + PrimitiveType::u8 => "u8", + PrimitiveType::i16 => "i16", + PrimitiveType::u16 => "u16", + PrimitiveType::i32 => "i32", + PrimitiveType::u32 => "u32", + PrimitiveType::i64 => "i64", + PrimitiveType::u64 => "u64", + PrimitiveType::i128 => "i128", + PrimitiveType::u128 => "u128", + PrimitiveType::isize => "isize", + PrimitiveType::usize => "usize", + PrimitiveType::f32 => "f32", + PrimitiveType::f64 => "f64", + PrimitiveType::bool => "bool", + PrimitiveType::char => "char", + } + .fmt(f) + } +} + +lazy_static! { + static ref PRIMITIVES_MAPPING: [(&'static str, PrimitiveType); 16] = [ + ("i8", PrimitiveType::i8), + ("u8", PrimitiveType::u8), + ("i16", PrimitiveType::i16), + ("u16", PrimitiveType::u16), + ("i32", PrimitiveType::i32), + ("u32", PrimitiveType::u32), + ("i64", PrimitiveType::i64), + ("u64", PrimitiveType::u64), + ("i128", PrimitiveType::i128), + ("u128", PrimitiveType::u128), + ("isize", PrimitiveType::isize), + ("usize", PrimitiveType::usize), + ("f32", PrimitiveType::f32), + ("f64", PrimitiveType::f64), + ("bool", PrimitiveType::bool), + ("char", PrimitiveType::char), + ]; + static ref STRING_TO_PRIMITIVE: HashMap<&'static str, PrimitiveType> = + PRIMITIVES_MAPPING.iter().cloned().collect(); + static ref PRIMITIVE_TO_STRING: HashMap = + PRIMITIVES_MAPPING.iter().map(|t| (t.1, t.0)).collect(); +} + +#[cfg(test)] +mod tests { + use insta; + + use syn; + + use super::TypeName; + + #[test] + fn typename_primitives() { + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + i32 + }, + None + )); + + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + usize + }, + None + )); + + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + bool + }, + None + )); + } + + #[test] + fn typename_named() { + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + MyLocalStruct + }, + None + )); + } + + #[test] + fn typename_references() { + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + &i32 + }, + None + )); + + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + &mut MyLocalStruct + }, + None + )); + } + + #[test] + fn typename_boxes() { + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + Box + }, + None + )); + + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + Box + }, + None + )); + } + + #[test] + fn typename_option() { + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + Option + }, + None + )); + + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + Option + }, + None + )); + } + + #[test] + fn typename_result() { + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + DiplomatResult + }, + None + )); + + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + DiplomatResult<(), MyLocalStruct> + }, + None + )); + + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + Result + }, + None + )); + + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + Result<(), MyLocalStruct> + }, + None + )); + } + + #[test] + fn lifetimes() { + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + Foo<'a, 'b> + }, + None + )); + + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + ::core::my_type::Foo + }, + None + )); + + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + ::core::my_type::Foo<'test> + }, + None + )); + + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + Option> + }, + None + )); + + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + Foo<'a, 'b, 'c, 'd> + }, + None + )); + + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + very::long::path::to::my::Type<'x, 'y, 'z> + }, + None + )); + + insta::assert_yaml_snapshot!(TypeName::from_syn( + &syn::parse_quote! { + Result, ErrRef<'c>> + }, + None + )); + } +} diff --git a/third_party/rust/diplomat_core/src/ast/validity.rs b/third_party/rust/diplomat_core/src/ast/validity.rs new file mode 100644 index 000000000000..c1f37bfa677a --- /dev/null +++ b/third_party/rust/diplomat_core/src/ast/validity.rs @@ -0,0 +1,224 @@ +use super::{Ident, Path, TypeName}; + +#[cfg_attr(feature = "displaydoc", derive(displaydoc::Display))] +#[derive(Debug, Clone)] +pub enum ValidityError { + /// An oqaue type crosses the FFI boundary as a value. + #[cfg_attr( + feature = "displaydoc", + displaydoc("An opaque type crossed the FFI boundary as a value: {0}") + )] + OpaqueAsValue(TypeName), + /// A non-oquare zero-sized struct or enum has been defined. + #[cfg_attr( + feature = "displaydoc", + displaydoc("A non-opaque zero-sized struct or enum has been defined: {0}") + )] + NonOpaqueZST(Path), + /// A non-opaque type was found behind a `Box` or reference. + #[cfg_attr( + feature = "displaydoc", + displaydoc( + "A non-opaque type was found behind a Box or reference, these can \ + only be handled by-move as they get converted at the FFI boundary: {0}" + ) + )] + NonOpaqueBehindRef(TypeName), + /// A non-reference type was found inside an `Option`. + #[cfg_attr( + feature = "displaydoc", + displaydoc("A non-reference type was found inside an Option: {0}") + )] + OptionNotContainingPointer(TypeName), + /// A return type contains elided lifetimes. + #[cfg_attr( + feature = "displaydoc", + displaydoc("A return type contains elided lifetimes, which aren't yet supported: {sub_type} in {full_type}") + )] + LifetimeElisionInReturn { + full_type: TypeName, + sub_type: TypeName, + }, + /// An alias or submodule was found instead of a custom type. + #[cfg_attr( + feature = "displaydoc", + displaydoc("An alias or submodule was found instead of a custom type with the name {0}.") + )] + PathTypeNameConflict(Ident), +} + +#[cfg(test)] +mod tests { + use std::fmt::Write; + + macro_rules! uitest_validity { + ($($file:tt)*) => { + let parsed: syn::File = syn::parse_quote! { $($file)* }; + let custom_types = crate::ast::File::from(&parsed); + let env = custom_types.all_types(); + + let errors = custom_types.check_validity(&env); + + let mut output = String::new(); + for error in errors { + write!(&mut output, "{}\n", error).unwrap(); + } + insta::with_settings!({}, { + insta::assert_display_snapshot!(output) + }); + } + } + + #[test] + fn test_opaque_ffi() { + uitest_validity! { + #[diplomat::bridge] + mod ffi { + #[diplomat::opaque] + struct MyOpaqueStruct(UnknownType); + + impl MyOpaqueStruct { + pub fn new() -> Box {} + pub fn new_broken() -> MyOpaqueStruct {} + pub fn do_thing(&self) {} + pub fn do_thing_broken(self) {} + pub fn broken_differently(&self, x: &MyOpaqueStruct) {} + } + } + } + } + + #[test] + fn opaque_checks_with_safe_use() { + uitest_validity! { + #[diplomat::bridge] + mod ffi { + struct NonOpaqueStruct {} + + impl NonOpaqueStruct { + fn new(x: i32) -> NonOpaqueStruct { + unimplemented!(); + } + } + + #[diplomat::opaque] + struct OpaqueStruct {} + + impl OpaqueStruct { + pub fn new() -> Box { + unimplemented!(); + } + + pub fn get_i32(&self) -> i32 { + unimplemented!() + } + } + } + }; + } + + #[test] + fn opaque_checks_with_error() { + uitest_validity! { + #[diplomat::bridge] + mod ffi { + #[diplomat::opaque] + struct OpaqueStruct {} + + impl OpaqueStruct { + pub fn new() -> OpaqueStruct { + unimplemented!(); + } + + pub fn get_i32(self) -> i32 { + unimplemented!() + } + } + } + }; + } + + #[test] + fn zst_non_opaque() { + uitest_validity! { + #[diplomat::bridge] + mod ffi { + struct OpaqueStruct; + + enum OpaqueEnum {} + } + }; + } + + #[test] + fn option_invalid() { + uitest_validity! { + #[diplomat::bridge] + mod ffi { + use diplomat_runtime::DiplomatResult; + struct Foo { + field: Option, + } + + impl Foo { + pub fn do_thing(opt: Option>) { + + } + + pub fn do_thing2(opt: DiplomatResult, u8>) { + + } + pub fn do_thing2(opt: Option) { + + } + } + } + }; + } + + #[test] + fn option_valid() { + uitest_validity! { + #[diplomat::bridge] + mod ffi { + struct Foo { + field: Option>, + } + + impl Foo { + pub fn do_thing(opt: Option>) { + + } + pub fn do_thing2(opt: Option<&u32>) { + + } + } + } + }; + } + + #[test] + fn non_opaque_move() { + uitest_validity! { + #[diplomat::bridge] + mod ffi { + struct NonOpaque { + num: u8, + } + + impl NonOpaque { + pub fn foo(&self) {} + } + + #[diplomat::opaque] + struct Opaque; + + impl Opaque { + pub fn bar<'a>(&'a self) -> &'a NonOpaque {} + pub fn baz<'a>(&'a self, x: &'a NonOpaque) {} + pub fn quux(&self) -> Box {} + } + } + }; + } +} diff --git a/third_party/rust/diplomat_core/src/environment.rs b/third_party/rust/diplomat_core/src/environment.rs new file mode 100644 index 000000000000..a028378ef6db --- /dev/null +++ b/third_party/rust/diplomat_core/src/environment.rs @@ -0,0 +1,88 @@ +use crate::ast::*; +use std::collections::BTreeMap; +use std::ops::Index; + +/// The type resolution environment +/// +/// Also contains the entire module structure +#[derive(Default, Clone)] +pub struct Env { + pub(crate) env: BTreeMap, +} + +/// The type resolution environment within a specific module +#[derive(Default, Clone)] +pub struct ModuleEnv { + pub(crate) module: BTreeMap, +} + +impl Env { + pub(crate) fn insert(&mut self, path: Path, module: ModuleEnv) { + self.env.insert(path, module); + } + + /// Given a path to a module and a name, get the item, if any + pub fn get(&self, path: &Path, name: &str) -> Option<&ModSymbol> { + self.env.get(path).and_then(|m| m.module.get(name)) + } + + /// Iterate over all items in the environment + /// + /// This will occur in a stable lexically sorted order by path and then name + pub fn iter_items(&self) -> impl Iterator + '_ { + self.env + .iter() + .flat_map(|(k, v)| v.module.iter().map(move |v2| (k, v2.0, v2.1))) + } + + /// Iterate over all modules + /// + /// This will occur in a stable lexically sorted order by path + pub fn iter_modules(&self) -> impl Iterator + '_ { + self.env.iter() + } +} + +impl ModuleEnv { + pub(crate) fn insert(&mut self, name: Ident, symbol: ModSymbol) -> Option { + self.module.insert(name, symbol) + } + + /// Given an item name, fetch it + pub fn get(&self, name: &str) -> Option<&ModSymbol> { + self.module.get(name) + } + + /// Iterate over all name-item pairs in this module + pub fn iter(&self) -> impl Iterator + '_ { + self.module.iter() + } + + /// Iterate over all names in this module + /// + /// This will occur in a stable lexically sorted order by name + pub fn names(&self) -> impl Iterator + '_ { + self.module.keys() + } + + /// Iterate over all items in this module + /// + /// This will occur in a stable lexically sorted order by name + pub fn items(&self) -> impl Iterator + '_ { + self.module.values() + } +} + +impl Index<&Path> for Env { + type Output = ModuleEnv; + fn index(&self, i: &Path) -> &ModuleEnv { + &self.env[i] + } +} + +impl Index<&str> for ModuleEnv { + type Output = ModSymbol; + fn index(&self, i: &str) -> &ModSymbol { + &self.module[i] + } +} diff --git a/third_party/rust/diplomat_core/src/hir/defs.rs b/third_party/rust/diplomat_core/src/hir/defs.rs new file mode 100644 index 000000000000..175640bb4b48 --- /dev/null +++ b/third_party/rust/diplomat_core/src/hir/defs.rs @@ -0,0 +1,166 @@ +//! Type definitions for structs, output structs, opaque structs, and enums. + +use super::{Everywhere, IdentBuf, Method, OutputOnly, TyPosition, Type}; +use crate::ast::Docs; + +pub enum ReturnableStructDef<'tcx> { + Struct(&'tcx StructDef), + OutStruct(&'tcx OutStructDef), +} + +#[derive(Copy, Clone, Debug)] +pub enum TypeDef<'tcx> { + Struct(&'tcx StructDef), + OutStruct(&'tcx OutStructDef), + Opaque(&'tcx OpaqueDef), + Enum(&'tcx EnumDef), +} + +/// Structs that can only be returned from methods. +pub type OutStructDef = StructDef; + +/// Structs that can be either inputs or outputs in methods. +#[derive(Debug)] +pub struct StructDef { + pub docs: Docs, + pub name: IdentBuf, + pub fields: Vec>, + pub methods: Vec, +} + +/// A struct whose contents are opaque across the FFI boundary, and can only +/// cross when behind a pointer. +/// +/// All opaques can be inputs or outputs when behind a reference, but owned +/// opaques can only be returned since there isn't a general way for most languages +/// to give up ownership. +/// +/// A struct marked with `#[diplomat::opaque]`. +#[derive(Debug)] +pub struct OpaqueDef { + pub docs: Docs, + pub name: IdentBuf, + pub methods: Vec, +} + +/// The enum type. +#[derive(Debug)] +pub struct EnumDef { + pub docs: Docs, + pub name: IdentBuf, + pub variants: Vec, + pub methods: Vec, +} + +/// A field on a [`OutStruct`]s. +pub type OutStructField = StructField; + +/// A field on a [`Struct`]s. +#[derive(Debug)] +pub struct StructField { + pub docs: Docs, + pub name: IdentBuf, + pub ty: Type

, +} + +/// A variant of an [`Enum`]. +#[derive(Debug)] +pub struct EnumVariant { + pub docs: Docs, + pub name: IdentBuf, + pub discriminant: isize, +} + +impl StructDef

{ + pub(super) fn new( + docs: Docs, + name: IdentBuf, + fields: Vec>, + methods: Vec, + ) -> Self { + Self { + docs, + name, + fields, + methods, + } + } +} + +impl OpaqueDef { + pub(super) fn new(docs: Docs, name: IdentBuf, methods: Vec) -> Self { + Self { + docs, + name, + methods, + } + } +} + +impl EnumDef { + pub(super) fn new( + docs: Docs, + name: IdentBuf, + variants: Vec, + methods: Vec, + ) -> Self { + Self { + docs, + name, + variants, + methods, + } + } +} + +impl<'a> From<&'a StructDef> for TypeDef<'a> { + fn from(x: &'a StructDef) -> Self { + TypeDef::Struct(x) + } +} + +impl<'a> From<&'a OutStructDef> for TypeDef<'a> { + fn from(x: &'a OutStructDef) -> Self { + TypeDef::OutStruct(x) + } +} + +impl<'a> From<&'a OpaqueDef> for TypeDef<'a> { + fn from(x: &'a OpaqueDef) -> Self { + TypeDef::Opaque(x) + } +} + +impl<'a> From<&'a EnumDef> for TypeDef<'a> { + fn from(x: &'a EnumDef) -> Self { + TypeDef::Enum(x) + } +} + +impl<'tcx> TypeDef<'tcx> { + pub fn name(&self) -> &'tcx IdentBuf { + match *self { + Self::Struct(ty) => &ty.name, + Self::OutStruct(ty) => &ty.name, + Self::Opaque(ty) => &ty.name, + Self::Enum(ty) => &ty.name, + } + } + + pub fn docs(&self) -> &'tcx Docs { + match *self { + Self::Struct(ty) => &ty.docs, + Self::OutStruct(ty) => &ty.docs, + Self::Opaque(ty) => &ty.docs, + Self::Enum(ty) => &ty.docs, + } + } + pub fn methods(&self) -> &'tcx [Method] { + match *self { + Self::Struct(ty) => &ty.methods, + Self::OutStruct(ty) => &ty.methods, + Self::Opaque(ty) => &ty.methods, + Self::Enum(ty) => &ty.methods, + } + } +} diff --git a/third_party/rust/diplomat_core/src/hir/elision.rs b/third_party/rust/diplomat_core/src/hir/elision.rs new file mode 100644 index 000000000000..18debd557bd5 --- /dev/null +++ b/third_party/rust/diplomat_core/src/hir/elision.rs @@ -0,0 +1,549 @@ +//! This module provides the functionality for lowering lifetimes from the AST +//! to the HIR, while simultaneously inferencing elided lifetimes. +//! +//! Full elision rules can be found in the [Nomicon]. +//! +//! The key factor about lifetime elision is that all elision in the output of +//! the method (if there is any) corresponds to exactly one lifetime in the method +//! arguments, which may or may not be elided. Therefore, our task is to find this +//! potential lifetime first, so that if we encounter an elided lifetime while +//! lowering the output, we know which lifetime it corresponds to. +//! +//! # Unspoken Rules of Elision. +//! +//! Broadly speaking, the Nomicon defines the elision rules are such: +//! 1. If there's a `&self` or `&mut self`, the lifetime of that borrow +//! corresponds to elision in the output. +//! 2. Otherwise, if there's exactly one lifetime in the input, then that lifetime +//! corresponds to elision in the output. +//! 3. If neither of these cases hold, then the output cannot contain elision. +//! +//! What the Nomicon doesn't tell you is that there are weird corner cases around +//! using the `Self` type. Specifically, lifetimes in the `Self` type and in the +//! type of the `self` argument (optional) aren't considered when figuring out +//! which lifetime should correspond to elision in the output. +//! +//! Check out the following code: +//! ```compile_fail +//! struct Foo<'a>(&'a str); +//! +//! impl<'a> Foo<'a> { +//! fn get(self) -> &str { self.0 } +//! } +//! ``` +//! This code will fail to compile because it doesn't look at the `'a` in the +//! `Foo<'a>`, which is what the type of `self` expands to. Therefore, it will +//! conclude that there's nothing for the output to borrow from. +//! This can be fixed by returning `&'a str` though. Many of the design +//! decisions in this module were made to be able to replicate this behavior. +//! +//! You may be asking "why would we care about rejecting code that rustc rejects +//! before it reaches us?" And the answer is this: +//! ```rust +//! # struct Foo<'a>(&'a str); +//! impl<'a> Foo<'a> { +//! fn get(self, s: &str) -> &str { s } +//! } +//! ``` +//! This code is accepted by rustc, since it only considers the lifetime of `s` +//! when searching for a lifetime that corresponds to output elision. If we were +//! to naively look at all the lifetimes, we would see the lifetime in the `self` +//! argument and the lifetime of `s`, making us reject this method. Therefore, we +//! have to be extremely careful when traversing lifetimes, and make sure that +//! lifetimes of `Self` are lowered but _not_ considered for elision, while other +//! lifetimes are lowered while also being considered for elision. +//! +//! # Lowering and Inference +//! +//! Lowering and elision inference is broken into three distinct stages: +//! 1. Lowering the borrow in `&self` or `&mut self`, if there is one. +//! 2. Lowering lifetimes of other params. +//! 3. Lowering lifetimes of the output. +//! +//! Although each stage fundementally lowers lifetimes, they behave differently +//! when lowering elided lifetimes. Naturally, this module represents each stage +//! as a state in a state machine. +//! +//! The first state is represented by the [`SelfParamLifetimeLowerer`] type. +//! Since there is either zero or one occurrences of `&self` or `&mut self`, it +//! exposes the `.no_self_ref()` and `.lower_self_ref(lt)` methods respectively, +//! which consume the `SelfParamLifetimeLowerer` and return the next state, +//! [`ParamLifetimeLowerer`], as well as the lowered lifetime. The reason these +//! are two distinct types is that the lifetime in `&self` and `&mut self` takes +//! precedence over any other lifetimes in the input, so `.lower_self_ref(lt)` +//! tells the next state that the candidate lifetime is already found, and to +//! generate fresh anonymous lifetimes for any elided lifetimes. +//! +//! The second state is represented by the [`ParamLifetimeLowerer`] type. +//! It implements a helper trait, [`LifetimeLowerer`], which abstracts the lowering +//! of references and generic lifetimes. Internally, it wraps an [`ElisionSource`], +//! which acts as a state machine for tracking candidate lifetimes to correspond +//! to elision in the output. When a lifetime that's not in the type of the `self` +//! argument or in the expanded generics of the `Self` type is visited, this +//! state machine is potentially updated to another state. If the lifetime is +//! anonymous, it's added to the internal list of nodes that go into the final +//! [`LifetimeEnv`] after lowering. Once all the lifetimes in the input are +//! lowered, the `into_return_ltl()` method is called to transition into the +//! final state. +//! +//! The third and final state is represented by the [`ReturnLifetimeLowerer`] type. +//! Similar to `ParamLifetimeLowerer`, it also implements the [`LifetimeLowerer`] +//! helper trait. However, it differs from `ParamLifetimeLowerer` since instead +//! of potentially updating the internal `ElisionSource` when visiting a lifetime, +//! it instead reads from it when an elided lifetime occurs. Once all the output +//! lifetimes are lowered, `.finish()` is called to return the finalized +//! [`LifetimeEnv`]. +//! +//! [Nomicon]: https://doc.rust-lang.org/nomicon/lifetime-elision.html + +use super::{ + lower_ident, Lifetime, LifetimeEnv, LoweringError, MaybeStatic, MethodLifetime, TypeLifetime, + TypeLifetimes, +}; +use crate::ast; +use smallvec::SmallVec; + +/// Lower [`ast::Lifetime`]s to [`TypeLifetime`]s. +/// +/// This helper traits allows the [`lower_type`] and [`lower_out_type`] methods +/// to abstractly lower lifetimes without concern for what sort of tracking +/// goes on. In particular, elision inference requires updating internal state +/// when visiting lifetimes in the input. +pub trait LifetimeLowerer { + /// Lowers an [`ast::Lifetime`]. + fn lower_lifetime(&mut self, lifetime: &ast::Lifetime) -> MaybeStatic; + + /// Lowers a slice of [`ast::Lifetime`]s by calling + /// [`LifetimeLowerer::lower_lifetime`] repeatedly. + fn lower_lifetimes(&mut self, lifetimes: &[ast::Lifetime]) -> TypeLifetimes { + TypeLifetimes::from_fn(lifetimes, |lifetime| self.lower_lifetime(lifetime)) + } + + /// Lowers a slice of [`ast::Lifetime`], where the strategy may vary depending + /// on whether or not the lifetimes are expanded from the `Self` type. + /// + /// The distinction between this and [`LifetimeLowerer::lower_lifetimes`] is + /// that if `Self` expands to a type with anonymous lifetimes like `Foo<'_>`, + /// then multiple instances of `Self` should expand to have the same anonymous + /// lifetime, and this lifetime can be cached inside of the `self` argument. + /// Additionally, elision inferences knows to not search inside the generics + /// of `Self` types for candidate lifetimes to correspond to elided lifetimes + /// in the output. + fn lower_generics(&mut self, lifetimes: &[ast::Lifetime], is_self: bool) -> TypeLifetimes; +} + +/// A state machine for tracking which lifetime in a function's parameters +/// may correspond to elided lifetimes in the output. +#[derive(Copy, Clone)] +enum ElisionSource { + /// No borrows in the input, no elision. + NoBorrows, + /// `&self` or `&mut self`, elision allowed. + SelfParam(MaybeStatic), + /// One param contains a borrow, elision allowed. + OneParam(MaybeStatic), + /// Multiple borrows and no self borrow, no elision. + MultipleBorrows, +} + +impl ElisionSource { + /// Potentially transition to a new state. + fn visit_lifetime(&mut self, lifetime: MaybeStatic) { + match self { + ElisionSource::NoBorrows => *self = ElisionSource::OneParam(lifetime), + ElisionSource::SelfParam(_) => { + // References to self have the highest precedence, do nothing. + } + ElisionSource::OneParam(_) => *self = ElisionSource::MultipleBorrows, + ElisionSource::MultipleBorrows => { + // There's ambiguity. This is valid when there's no elision in + // the output. + } + }; + } +} + +/// A type for storing shared information between the different states of elision +/// inference. +/// +/// This contains data for generating fresh elided lifetimes, looking up named +/// lifetimes, and caching lifetimes of `Self`. +pub(super) struct BaseLifetimeLowerer<'ast> { + lifetime_env: &'ast ast::LifetimeEnv, + self_lifetimes: Option, + nodes: SmallVec<[Lifetime; 4]>, + num_lifetimes: usize, +} + +/// The first phase of output elision inference. +/// +/// In the first phase, the type signature of the `&self` or `&mut self` type +/// is lowered into its HIR representation, if present. According to elision +/// rules, this reference has the highest precedence as the lifetime that +/// goes into elision in the output, and so it's checked first. +pub struct SelfParamLifetimeLowerer<'ast> { + base: BaseLifetimeLowerer<'ast>, +} + +/// The second phase of output elision inference. +/// +/// In the second phase, all lifetimes in the parameter type signatures +/// (besides the lifetime of self, if present) are lowered. If a self param +/// didn't claim the potential output elided lifetime, then if there's a +/// single lifetime (elided or not) in the inputs, it will claim the +/// potential output elided lifetime. +pub struct ParamLifetimeLowerer<'ast> { + elision_source: ElisionSource, + base: BaseLifetimeLowerer<'ast>, +} + +/// The third and final phase of output elision inference. +/// +/// In the third phase, the type signature of the output type is lowered into +/// its HIR representation. If one of the input lifetimes were marked as +/// responsible for any elision in the output, then anonymous lifetimes get +/// that lifetime. If none did and there is elision in the output, then +/// rustc should have errored and said the elision was ambiguous, meaning +/// that state should be impossible so it panics. +pub struct ReturnLifetimeLowerer<'ast> { + elision_source: ElisionSource, + base: BaseLifetimeLowerer<'ast>, +} + +impl<'ast> BaseLifetimeLowerer<'ast> { + /// Returns a [`TypeLifetime`] representing a new anonymous lifetime, and + /// pushes it to the nodes vector. + fn new_elided(&mut self) -> TypeLifetime { + let index = self.num_lifetimes; + self.num_lifetimes += 1; + TypeLifetime::new(index) + } + + /// Lowers a single [`ast::Lifetime`]. If the lifetime is elided, then a fresh + /// [`ImplicitLifetime`] is generated. + fn lower_lifetime(&mut self, lifetime: &ast::Lifetime) -> MaybeStatic { + match lifetime { + ast::Lifetime::Static => MaybeStatic::Static, + ast::Lifetime::Named(named) => { + MaybeStatic::NonStatic(TypeLifetime::from_ast(named, self.lifetime_env)) + } + ast::Lifetime::Anonymous => MaybeStatic::NonStatic(self.new_elided()), + } + } + + /// Retrieves the cached `Self` lifetimes, or caches newly generated + /// lifetimes and returns those. + fn self_lifetimes_or_new(&mut self, ast_lifetimes: &[ast::Lifetime]) -> TypeLifetimes { + if let Some(lifetimes) = &self.self_lifetimes { + lifetimes.clone() + } else { + let lifetimes = TypeLifetimes::from_fn(ast_lifetimes, |lt| self.lower_lifetime(lt)); + self.self_lifetimes = Some(lifetimes.clone()); + lifetimes + } + } +} + +impl<'ast> SelfParamLifetimeLowerer<'ast> { + /// Returns a new [`SelfParamLifetimeLowerer`]. + pub fn new( + lifetime_env: &'ast ast::LifetimeEnv, + errors: &mut Vec, + ) -> Option { + let mut hir_nodes = Some(SmallVec::new()); + + for ast_node in lifetime_env.nodes.iter() { + let lifetime = lower_ident(ast_node.lifetime.name(), "named lifetime", errors); + match (lifetime, &mut hir_nodes) { + (Some(lifetime), Some(hir_nodes)) => { + hir_nodes.push(Lifetime::new( + lifetime, + ast_node + .longer + .iter() + .map(|i| MethodLifetime::new(*i)) + .collect(), + ast_node + .shorter + .iter() + .map(|i| MethodLifetime::new(*i)) + .collect(), + )); + } + _ => hir_nodes = None, + } + } + + hir_nodes.map(|nodes| Self { + base: BaseLifetimeLowerer { + lifetime_env, + self_lifetimes: None, + num_lifetimes: nodes.len(), + nodes, + }, + }) + } + + /// Lowers the lifetime of `&self` or `&mut self`. + /// + /// The lifetimes of `&self` and `&mut self` are special, because they + /// automatically take priority over any other lifetime in the input for + /// being tied to any elided lifetimes in the output. + /// + /// Along with returning the lowered lifetime, this method also returns the + /// next state in elision inference, the [`ParamLifetimeLowerer`]. + pub fn lower_self_ref( + mut self, + lifetime: &ast::Lifetime, + ) -> (MaybeStatic, ParamLifetimeLowerer<'ast>) { + let self_lifetime = self.base.lower_lifetime(lifetime); + + ( + self_lifetime, + self.into_param_ltl(ElisionSource::SelfParam(self_lifetime)), + ) + } + + /// Acknowledges that there's no `&self` or `&mut self`, and transitions + /// to the next state, [`ParamLifetimeLowerer`]. + pub fn no_self_ref(self) -> ParamLifetimeLowerer<'ast> { + self.into_param_ltl(ElisionSource::NoBorrows) + } + + /// Transition into the next state, [`ParamLifetimeLowerer`]. + fn into_param_ltl(self, elision_source: ElisionSource) -> ParamLifetimeLowerer<'ast> { + ParamLifetimeLowerer { + elision_source, + base: self.base, + } + } +} + +impl<'ast> ParamLifetimeLowerer<'ast> { + /// Once all lifetimes in the parameters are lowered, this function is + /// called to transition to the next state, [`ReturnLifetimeLowerer`]. + pub fn into_return_ltl(self) -> ReturnLifetimeLowerer<'ast> { + ReturnLifetimeLowerer { + elision_source: self.elision_source, + base: self.base, + } + } +} + +impl<'ast> LifetimeLowerer for ParamLifetimeLowerer<'ast> { + fn lower_lifetime(&mut self, borrow: &ast::Lifetime) -> MaybeStatic { + let lifetime = self.base.lower_lifetime(borrow); + self.elision_source.visit_lifetime(lifetime); + lifetime + } + + fn lower_generics(&mut self, lifetimes: &[ast::Lifetime], is_self: bool) -> TypeLifetimes { + if is_self { + self.base.self_lifetimes_or_new(lifetimes) + } else { + self.lower_lifetimes(lifetimes) + } + } +} + +impl<'ast> ReturnLifetimeLowerer<'ast> { + /// Finalize the lifetimes in the method, returning the resulting [`LifetimeEnv`]. + pub fn finish(self) -> LifetimeEnv { + LifetimeEnv::new(self.base.nodes, self.base.num_lifetimes) + } +} + +impl<'ast> LifetimeLowerer for ReturnLifetimeLowerer<'ast> { + fn lower_lifetime(&mut self, borrow: &ast::Lifetime) -> MaybeStatic { + match borrow { + ast::Lifetime::Static => MaybeStatic::Static, + ast::Lifetime::Named(named) => { + MaybeStatic::NonStatic(TypeLifetime::from_ast(named, self.base.lifetime_env)) + } + ast::Lifetime::Anonymous => match self.elision_source { + ElisionSource::SelfParam(lifetime) | ElisionSource::OneParam(lifetime) => lifetime, + ElisionSource::NoBorrows => { + panic!("nothing to borrow from, this shouldn't pass rustc's checks") + } + ElisionSource::MultipleBorrows => { + panic!("source of elision is ambiguous, this shouldn't pass rustc's checks") + } + }, + } + } + + fn lower_generics(&mut self, lifetimes: &[ast::Lifetime], is_self: bool) -> TypeLifetimes { + if is_self { + self.base.self_lifetimes_or_new(lifetimes) + } else { + self.lower_lifetimes(lifetimes) + } + } +} + +impl LifetimeLowerer for &ast::LifetimeEnv { + fn lower_lifetime(&mut self, lifetime: &ast::Lifetime) -> MaybeStatic { + match lifetime { + ast::Lifetime::Static => MaybeStatic::Static, + ast::Lifetime::Named(named) => { + MaybeStatic::NonStatic(TypeLifetime::from_ast(named, self)) + } + ast::Lifetime::Anonymous => { + panic!("anonymous lifetime inside struct, this shouldn't pass rustc's checks") + } + } + } + + fn lower_generics(&mut self, lifetimes: &[ast::Lifetime], _: bool) -> TypeLifetimes { + self.lower_lifetimes(lifetimes) + } +} + +// Things to test: +// 1. ensure that if there are multiple inputs that are `Self`, where `Self` has +// an elided lifetime, all expansions of `Self` have the same anonymous lifetimes. + +#[cfg(test)] +mod tests { + use strck_ident::IntoCk; + + /// Convert a syntax tree into a [`TypeContext`]. + macro_rules! tcx { + ($($tokens:tt)*) => {{ + let m = crate::ast::Module::from_syn(&syn::parse_quote! { $($tokens)* }, true); + + let mut env = crate::Env::default(); + let mut top_symbols = crate::ModuleEnv::default(); + + m.insert_all_types(crate::ast::Path::empty(), &mut env); + top_symbols.insert(m.name.clone(), crate::ast::ModSymbol::SubModule(m.name.clone())); + + env.insert(crate::ast::Path::empty(), top_symbols); + + let tcx = crate::hir::TypeContext::from_ast(&env).unwrap(); + + tcx + }} + } + + macro_rules! do_test { + ($($tokens:tt)*) => {{ + let mut settings = insta::Settings::new(); + settings.set_sort_maps(true); + + settings.bind(|| { + let tcx = tcx! { $($tokens)* }; + + insta::assert_debug_snapshot!(tcx); + }) + }} + } + + #[test] + fn simple_mod() { + do_test! { + mod ffi { + #[diplomat::opaque] + struct Opaque<'a> { + s: &'a str, + } + + struct Struct<'a> { + s: &'a str, + } + + #[diplomat::out] + struct OutStruct<'a> { + inner: Box>, + } + + impl<'a> OutStruct<'a> { + pub fn new(s: &'a str) -> Self { + Self { inner: Box::new(Opaque { s }) } + } + + } + + impl<'a> Struct<'a> { + pub fn rustc_elision(self, s: &str) -> &str { + s + } + } + } + } + } + + #[test] + fn test_borrowing_fields() { + use std::collections::BTreeMap; + use std::fmt; + + let tcx = tcx! { + mod ffi { + #[diplomat::opaque] + pub struct Opaque; + + struct Input<'p, 'q> { + p_data: &'p Opaque, + q_data: &'q Opaque, + name: &'static str, + inner: Inner<'q>, + } + + struct Inner<'a> { + more_data: &'a str, + } + + struct Output<'p,'q> { + p_data: &'p Opaque, + q_data: &'q Opaque, + } + + impl<'a, 'b> Input<'a, 'b> { + pub fn as_output(self, _s: &'static str) -> Output<'b, 'a> { + Output { data: self.data } + } + + } + } + }; + + let method = &tcx + .structs() + .iter() + .find(|def| def.name == "Input") + .unwrap() + .methods[0]; + + let visitor = method.borrowing_field_visitor(&tcx, "this".ck().unwrap()); + let mut lt_to_borrowing_fields: BTreeMap<_, Vec<_>> = BTreeMap::new(); + visitor.visit_borrowing_fields(|lt, bf| { + lt_to_borrowing_fields + .entry(lt) + .or_default() + .push(DebugBorrowingField(bf)); + }); + + struct DebugBorrowingField<'m>(crate::hir::BorrowingField<'m>); + + impl<'m> fmt::Debug for DebugBorrowingField<'m> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("\"")?; + self.0.try_backtrace(|i, ident| { + if i != 0 { + f.write_str(".")?; + } + f.write_str(ident.as_str()) + })?; + f.write_str("\"") + } + } + + let mut settings = insta::Settings::new(); + settings.set_sort_maps(true); + + settings.bind(|| { + insta::assert_debug_snapshot!(lt_to_borrowing_fields); + }) + } +} diff --git a/third_party/rust/diplomat_core/src/hir/lifetimes.rs b/third_party/rust/diplomat_core/src/hir/lifetimes.rs new file mode 100644 index 000000000000..914b414ef444 --- /dev/null +++ b/third_party/rust/diplomat_core/src/hir/lifetimes.rs @@ -0,0 +1,284 @@ +//! Lifetime information for types. +#![allow(dead_code)] + +use super::IdentBuf; +use crate::ast; +use smallvec::{smallvec, SmallVec}; + +/// Convenience const representing the number of lifetimes a [`LifetimeEnv`] +/// can hold inline before needing to dynamically allocate. +const INLINE_NUM_LIFETIMES: usize = 4; + +// TODO(Quinn): This type is going to mainly be recycled from `ast::LifetimeEnv`. +// Not fully sure how that will look like yet, but the ideas of what this will do +// is basically the same. +#[derive(Debug)] +pub struct LifetimeEnv { + /// List of named lifetimes in scope of the method, in the form of an + /// adjacency matrix. + nodes: SmallVec<[Lifetime; INLINE_NUM_LIFETIMES]>, + + /// The number of named _and_ anonymous lifetimes in the method. + /// We store the sum since it represents the upper bound on what indices + /// are in range of the graph. If we make a [`MethodLfetimes`] with + /// `num_lifetimes` entries, then `TypeLifetime`s that convert into + /// `MethodLifetime`s will fall into this range, and we'll know that it's + /// a named lifetime if it's < `nodes.len()`, or that it's an anonymous + /// lifetime if it's < `num_lifetimes`. Otherwise, we'd have to make a + /// distinction in `TypeLifetime` about which kind it refers to. + num_lifetimes: usize, +} + +/// A lifetime in a [`LifetimeEnv`], which keeps track of which lifetimes it's +/// longer and shorter than. +#[derive(Debug)] +pub(super) struct Lifetime { + ident: IdentBuf, + longer: SmallVec<[MethodLifetime; 2]>, + shorter: SmallVec<[MethodLifetime; 2]>, +} + +impl Lifetime { + /// Returns a new [`Lifetime`]. + pub(super) fn new( + ident: IdentBuf, + longer: SmallVec<[MethodLifetime; 2]>, + shorter: SmallVec<[MethodLifetime; 2]>, + ) -> Self { + Self { + ident, + longer, + shorter, + } + } +} + +/// Visit subtype lifetimes recursively, keeping track of which have already +/// been visited. +pub struct SubtypeLifetimeVisitor<'lt, F> { + lifetime_env: &'lt LifetimeEnv, + visited: SmallVec<[bool; INLINE_NUM_LIFETIMES]>, + visit_fn: F, +} + +impl<'lt, F> SubtypeLifetimeVisitor<'lt, F> +where + F: FnMut(MethodLifetime), +{ + fn new(lifetime_env: &'lt LifetimeEnv, visit_fn: F) -> Self { + Self { + lifetime_env, + visited: smallvec![false; lifetime_env.nodes.len()], + visit_fn, + } + } + + /// Visit more sublifetimes. This method tracks which lifetimes have already + /// been visited, and uses this to not visit the same lifetime twice. + pub fn visit_subtypes(&mut self, method_lifetime: MethodLifetime) { + if let Some(visited @ false) = self.visited.get_mut(method_lifetime.0) { + *visited = true; + + (self.visit_fn)(method_lifetime); + + for longer in self.lifetime_env.nodes[method_lifetime.0].longer.iter() { + self.visit_subtypes(*longer) + } + } else { + debug_assert!( + method_lifetime.0 > self.lifetime_env.num_lifetimes, + "method lifetime has an internal index that's not in range of the lifetime env" + ); + } + } +} + +/// Wrapper type for `TypeLifetime` and `MethodLifetime`, indicating that it may +/// be the `'static` lifetime. +#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +pub enum MaybeStatic { + Static, + NonStatic(T), +} + +impl MaybeStatic { + /// Maps the lifetime, if it's not the `'static` lifetime, to another + /// non-static lifetime. + pub(super) fn map_nonstatic(self, f: F) -> MaybeStatic + where + F: FnOnce(T) -> R, + { + match self { + MaybeStatic::Static => MaybeStatic::Static, + MaybeStatic::NonStatic(lifetime) => MaybeStatic::NonStatic(f(lifetime)), + } + } + + /// Maps the lifetime, if it's not the `'static` lifetime, to a potentially + /// static lifetime. + pub(super) fn flat_map_nonstatic(self, f: F) -> MaybeStatic + where + F: FnOnce(T) -> MaybeStatic, + { + match self { + MaybeStatic::Static => MaybeStatic::Static, + MaybeStatic::NonStatic(lifetime) => f(lifetime), + } + } +} + +/// A lifetime that exists as part of a type signature. +/// +/// This type can be mapped to a [`MethodLifetime`] by using the +/// [`TypeLifetime::as_method_lifetime`] method. +#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +pub struct TypeLifetime(usize); + +/// A set of lifetimes that exist as generic arguments on [`StructPath`]s, +/// [`OutStructPath`]s, and [`OpaquePath`]s. +/// +/// By itself, `TypeLifetimes` isn't very useful. However, it can be combined with +/// a [`MethodLifetimes`] using [`TypeLifetimes::as_method_lifetimes`] to get the lifetimes +/// in the scope of a method it appears in. +/// +/// [`StructPath`]: super::StructPath +/// [`OutStructPath`]: super::OutStructPath +/// [`OpaquePath`]: super::OpaquePath +#[derive(Clone, Debug)] +pub struct TypeLifetimes { + indices: SmallVec<[MaybeStatic; 2]>, +} + +/// A lifetime that exists as part of a method signature, e.g. `'a` or an +/// anonymous lifetime. +/// +/// This type is intended to be used as a key into a map to keep track of which +/// borrowed fields depend on which method lifetimes. +#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +pub struct MethodLifetime(usize); + +/// Map a lifetime in a nested struct to the original lifetime defined +/// in the method that it refers to. +pub struct MethodLifetimes { + indices: SmallVec<[MaybeStatic; 2]>, +} + +impl LifetimeEnv { + /// Returns a new [`LifetimeEnv`]. + pub(super) fn new( + nodes: SmallVec<[Lifetime; INLINE_NUM_LIFETIMES]>, + num_lifetimes: usize, + ) -> Self { + Self { + nodes, + num_lifetimes, + } + } + + /// Returns a fresh [`MethodLifetimes`] corresponding to `self`. + pub fn method_lifetimes(&self) -> MethodLifetimes { + let indices = (0..self.num_lifetimes) + .map(|index| MaybeStatic::NonStatic(MethodLifetime(index))) + .collect(); + + MethodLifetimes { indices } + } + + /// Returns a new [`SubtypeLifetimeVisitor`], which can visit all reachable + /// lifetimes + pub fn subtype_lifetimes_visitor(&self, visit_fn: F) -> SubtypeLifetimeVisitor<'_, F> + where + F: FnMut(MethodLifetime), + { + SubtypeLifetimeVisitor::new(self, visit_fn) + } +} + +impl TypeLifetime { + /// Returns a [`TypeLifetime`] from its AST counterparts. + pub(super) fn from_ast(named: &ast::NamedLifetime, lifetime_env: &ast::LifetimeEnv) -> Self { + let index = lifetime_env + .id(named) + .unwrap_or_else(|| panic!("lifetime `{named}` not found in lifetime env")); + Self(index) + } + + pub(super) fn new(index: usize) -> Self { + Self(index) + } + + /// Returns a new [`MaybeStatic`] representing `self` in the + /// scope of the method that it appears in. + /// + /// For example, if we have some `Foo<'a>` type with a field `&'a Bar`, then + /// we can call this on the `'a` on the field. If `Foo` was `Foo<'static>` + /// in the method, then this will return `MaybeStatic::Static`. But if it + /// was `Foo<'b>`, then this will return `MaybeStatic::NonStatic` containing + /// the `MethodLifetime` corresponding to `'b`. + pub fn as_method_lifetime( + self, + method_lifetimes: &MethodLifetimes, + ) -> MaybeStatic { + method_lifetimes.indices[self.0] + } +} + +impl TypeLifetimes { + pub(super) fn from_fn(lifetimes: &[ast::Lifetime], lower_fn: F) -> Self + where + F: FnMut(&ast::Lifetime) -> MaybeStatic, + { + Self { + indices: lifetimes.iter().map(lower_fn).collect(), + } + } + + /// Returns a new [`MethodLifetimes`] representing the lifetimes in the scope + /// of the method this type appears in. + /// + /// # Examples + /// + /// ```rust + /// # struct Alice<'a>(&'a ()); + /// # struct Bob<'b>(&'b ()); + /// struct Foo<'a, 'b> { + /// alice: Alice<'a>, + /// bob: Bob<'b>, + /// } + /// + /// fn bar<'x, 'y>(arg: Foo<'x, 'y>) {} + /// ``` + /// Here, `Foo` will have a [`TypeLifetimes`] containing `['a, 'b]`, + /// and `bar` will have a [`MethodLifetimes`] containing `{'x: 'x, 'y: 'y}`. + /// When we enter the scope of `Foo` as a type, we use this method to combine + /// the two to get a new [`MethodLifetimes`] representing the mapping from + /// lifetimes in `Foo`'s scope to lifetimes in `bar`s scope: `{'a: 'x, 'b: 'y}`. + /// + /// This tells us that `arg.alice` has lifetime `'x` in the method, and + /// that `arg.bob` has lifetime `'y`. + pub fn as_method_lifetimes(&self, method_lifetimes: &MethodLifetimes) -> MethodLifetimes { + let indices = self + .indices + .iter() + .map(|maybe_static_lt| { + maybe_static_lt.flat_map_nonstatic(|lt| lt.as_method_lifetime(method_lifetimes)) + }) + .collect(); + + MethodLifetimes { indices } + } +} + +impl MethodLifetime { + /// Returns a new `MethodLifetime` from an index into a `LifetimeEnv`. + pub(super) fn new(index: usize) -> Self { + Self(index) + } +} + +impl MethodLifetimes { + /// Returns an iterator over the contained [`MethodLifetime`]s. + pub(super) fn lifetimes(&self) -> impl Iterator> + '_ { + self.indices.iter().copied() + } +} diff --git a/third_party/rust/diplomat_core/src/hir/lowering.rs b/third_party/rust/diplomat_core/src/hir/lowering.rs new file mode 100644 index 000000000000..882cf78a5418 --- /dev/null +++ b/third_party/rust/diplomat_core/src/hir/lowering.rs @@ -0,0 +1,856 @@ +use super::{ + Borrow, EnumDef, EnumPath, EnumVariant, IdentBuf, LifetimeEnv, LifetimeLowerer, LookupId, + MaybeOwn, Method, NonOptional, OpaqueDef, OpaquePath, Optional, OutStructDef, OutStructField, + OutStructPath, OutType, Param, ParamLifetimeLowerer, ParamSelf, PrimitiveType, + ReturnLifetimeLowerer, ReturnType, ReturnableStructPath, SelfParamLifetimeLowerer, SelfType, + Slice, StructDef, StructField, StructPath, SuccessType, Type, +}; +use crate::{ast, Env}; +use core::fmt; +use strck_ident::IntoCk; + +/// An error from lowering the AST to the HIR. +#[derive(Debug)] +pub enum LoweringError { + /// The purpose of having this is that translating to the HIR has enormous + /// potential for really detailed error handling and giving suggestions. + /// + /// Unfortunately, working out what the error enum should look like to enable + /// this is really hard. The plan is that once the lowering code is completely + /// written, we ctrl+F for `"LoweringError::Other"` in the lowering code, and turn every + /// instance into an specialized enum variant, generalizing where possible + /// without losing any information. + Other(String), +} + +impl fmt::Display for LoweringError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Self::Other(ref s) => s.fmt(f), + } + } +} + +/// Lowers an [`ast::Ident`]s into an [`hir::IdentBuf`]. +/// +/// If there are any errors, they're pushed to `errors` and `None` is returned. +pub fn lower_ident( + ident: &ast::Ident, + context: &'static str, + errors: &mut Vec, +) -> Option { + match ident.as_str().ck() { + Ok(name) => Some(name.to_owned()), + Err(e) => { + errors.push(LoweringError::Other(format!( + "Ident `{ident}` from {context} could not be turned into a Rust ident: {e}" + ))); + None + } + } +} + +/// Lowers an AST definition. +pub(super) trait TypeLowerer: Sized { + /// Type of the AST definition that gets lowered. + type AstDef; + + /// Lowers the AST definition into `Self`. + /// + /// If there are any errors, they're pushed to `errors` and `None` is returned. + fn lower( + ast_def: &Self::AstDef, + lookup_id: &LookupId, + in_path: &ast::Path, + env: &Env, + errors: &mut Vec, + ) -> Option; + + /// Lowers multiple items at once + fn lower_all( + ast_defs: &[(&ast::Path, &Self::AstDef)], + lookup_id: &LookupId, + env: &Env, + errors: &mut Vec, + ) -> Option> { + let mut hir_types = Some(Vec::with_capacity(ast_defs.len())); + + for (in_path, ast_def) in ast_defs { + let hir_type = Self::lower(ast_def, lookup_id, in_path, env, errors); + + match (hir_type, &mut hir_types) { + (Some(hir_type), Some(hir_types)) => hir_types.push(hir_type), + _ => hir_types = None, + } + } + + hir_types + } +} + +impl TypeLowerer for EnumDef { + type AstDef = ast::Enum; + + fn lower( + ast_enum: &Self::AstDef, + lookup_id: &LookupId, + in_path: &ast::Path, + env: &Env, + errors: &mut Vec, + ) -> Option { + let name = lower_ident(&ast_enum.name, "enum name", errors); + + let mut variants = Some(Vec::with_capacity(ast_enum.variants.len())); + + for (ident, discriminant, docs) in ast_enum.variants.iter() { + let name = lower_ident(ident, "enum variant", errors); + + match (name, &mut variants) { + (Some(name), Some(variants)) => { + variants.push(EnumVariant { + docs: docs.clone(), + name, + discriminant: *discriminant, + }); + } + _ => variants = None, + } + } + + let methods = lower_all_methods(&ast_enum.methods[..], lookup_id, in_path, env, errors); + + Some(EnumDef::new( + ast_enum.docs.clone(), + name?, + variants?, + methods?, + )) + } +} + +impl TypeLowerer for OpaqueDef { + type AstDef = ast::OpaqueStruct; + + fn lower( + ast_opaque: &Self::AstDef, + lookup_id: &LookupId, + in_path: &ast::Path, + env: &Env, + errors: &mut Vec, + ) -> Option { + let name = lower_ident(&ast_opaque.name, "opaque name", errors); + + let methods = lower_all_methods(&ast_opaque.methods[..], lookup_id, in_path, env, errors); + + Some(OpaqueDef::new(ast_opaque.docs.clone(), name?, methods?)) + } +} + +impl TypeLowerer for StructDef { + type AstDef = ast::Struct; + + fn lower( + ast_struct: &Self::AstDef, + lookup_id: &LookupId, + in_path: &ast::Path, + env: &Env, + errors: &mut Vec, + ) -> Option { + let name = lower_ident(&ast_struct.name, "struct name", errors); + + let fields = if ast_struct.fields.is_empty() { + errors.push(LoweringError::Other(format!( + "struct `{}` is a ZST because it has no fields", + ast_struct.name + ))); + None + } else { + let mut fields = Some(Vec::with_capacity(ast_struct.fields.len())); + + for (name, ty, docs) in ast_struct.fields.iter() { + let name = lower_ident(name, "struct field name", errors); + let ty = lower_type( + ty, + Some(&mut &ast_struct.lifetimes), + lookup_id, + in_path, + env, + errors, + ); + + match (name, ty, &mut fields) { + (Some(name), Some(ty), Some(fields)) => fields.push(StructField { + docs: docs.clone(), + name, + ty, + }), + _ => fields = None, + } + } + + fields + }; + + let methods = lower_all_methods(&ast_struct.methods[..], lookup_id, in_path, env, errors); + + Some(StructDef::new( + ast_struct.docs.clone(), + name?, + fields?, + methods?, + )) + } +} + +impl TypeLowerer for OutStructDef { + type AstDef = ast::Struct; + + fn lower( + ast_out_struct: &Self::AstDef, + lookup_id: &LookupId, + in_path: &ast::Path, + env: &Env, + errors: &mut Vec, + ) -> Option { + let name = lower_ident(&ast_out_struct.name, "out-struct name", errors); + + let fields = if ast_out_struct.fields.is_empty() { + errors.push(LoweringError::Other(format!( + "struct `{}` is a ZST because it has no fields", + ast_out_struct.name + ))); + None + } else { + let mut fields = Some(Vec::with_capacity(ast_out_struct.fields.len())); + + for (name, ty, docs) in ast_out_struct.fields.iter() { + let name = lower_ident(name, "out-struct field name", errors); + let ty = lower_out_type( + ty, + Some(&mut &ast_out_struct.lifetimes), + lookup_id, + in_path, + env, + errors, + ); + + match (name, ty, &mut fields) { + (Some(name), Some(ty), Some(fields)) => fields.push(OutStructField { + docs: docs.clone(), + name, + ty, + }), + _ => fields = None, + } + } + + fields + }; + + let methods = + lower_all_methods(&ast_out_struct.methods[..], lookup_id, in_path, env, errors); + + Some(OutStructDef::new( + ast_out_struct.docs.clone(), + name?, + fields?, + methods?, + )) + } +} + +/// Lowers an [`ast::Method`]s an [`hir::Method`]. +/// +/// If there are any errors, they're pushed to `errors` and `None` is returned. +fn lower_method( + method: &ast::Method, + lookup_id: &LookupId, + in_path: &ast::Path, + env: &Env, + errors: &mut Vec, +) -> Option { + let name = lower_ident(&method.name, "method name", errors); + + let (ast_params, takes_writeable) = match method.params.split_last() { + Some((last, remaining)) if last.is_writeable() => (remaining, true), + _ => (&method.params[..], false), + }; + + let self_param_ltl = SelfParamLifetimeLowerer::new(&method.lifetime_env, errors); + + let (param_self, param_ltl) = if let Some(self_param) = method.self_param.as_ref() { + lower_self_param( + self_param, + self_param_ltl, + lookup_id, + &method.full_path_name, + in_path, + env, + errors, + ) + .map(|(param_self, param_ltl)| (Some(Some(param_self)), Some(param_ltl))) + .unwrap_or((None, None)) + } else { + ( + Some(None), + self_param_ltl.map(SelfParamLifetimeLowerer::no_self_ref), + ) + }; + + let (params, return_ltl) = + lower_many_params(ast_params, param_ltl, lookup_id, in_path, env, errors) + .map(|(params, return_ltl)| (Some(params), Some(return_ltl))) + .unwrap_or((None, None)); + + let (output, lifetime_env) = lower_return_type( + method.return_type.as_ref(), + takes_writeable, + return_ltl, + lookup_id, + in_path, + env, + errors, + )?; + + Some(Method { + docs: method.docs.clone(), + name: name?, + lifetime_env, + param_self: param_self?, + params: params?, + output, + }) +} + +/// Lowers many [`ast::Method`]s into a vector of [`hir::Method`]s. +/// +/// If there are any errors, they're pushed to `errors` and `None` is returned. +fn lower_all_methods( + ast_methods: &[ast::Method], + lookup_id: &LookupId, + in_path: &ast::Path, + env: &Env, + errors: &mut Vec, +) -> Option> { + let mut methods = Some(Vec::with_capacity(ast_methods.len())); + + for method in ast_methods { + let method = lower_method(method, lookup_id, in_path, env, errors); + match (method, &mut methods) { + (Some(method), Some(methods)) => { + methods.push(method); + } + _ => methods = None, + } + } + + methods +} + +/// Lowers an [`ast::TypeName`]s into a [`hir::Type`]. +/// +/// If there are any errors, they're pushed to `errors` and `None` is returned. +fn lower_type( + ty: &ast::TypeName, + ltl: Option<&mut L>, + lookup_id: &LookupId, + in_path: &ast::Path, + env: &Env, + errors: &mut Vec, +) -> Option { + match ty { + ast::TypeName::Primitive(prim) => Some(Type::Primitive(PrimitiveType::from_ast(*prim))), + ast::TypeName::Named(path) | ast::TypeName::SelfType(path) => { + match path.resolve(in_path, env) { + ast::CustomType::Struct(strct) => { + if let Some(tcx_id) = lookup_id.resolve_struct(strct) { + let lifetimes = ltl?.lower_generics(&path.lifetimes[..], ty.is_self()); + + Some(Type::Struct(StructPath::new(lifetimes, tcx_id))) + } else if lookup_id.resolve_out_struct(strct).is_some() { + errors.push(LoweringError::Other(format!("found struct in input that is marked with #[diplomat::out]: {ty} in {path}"))); + None + } else { + unreachable!("struct `{}` wasn't found in the set of structs or out-structs, this is a bug.", strct.name); + } + } + ast::CustomType::Opaque(_) => { + errors.push(LoweringError::Other(format!( + "Opaque passed by value in input: {path}" + ))); + None + } + ast::CustomType::Enum(enm) => { + let tcx_id = lookup_id + .resolve_enum(enm) + .expect("can't find enum in lookup map, which contains all enums from env"); + + Some(Type::Enum(EnumPath::new(tcx_id))) + } + } + } + ast::TypeName::Reference(lifetime, mutability, ref_ty) => match ref_ty.as_ref() { + ast::TypeName::Named(path) | ast::TypeName::SelfType(path) => { + match path.resolve(in_path, env) { + ast::CustomType::Opaque(opaque) => ltl.map(|ltl| { + let borrow = Borrow::new(ltl.lower_lifetime(lifetime), *mutability); + let lifetimes = ltl.lower_generics(&path.lifetimes[..], ref_ty.is_self()); + let tcx_id = lookup_id.resolve_opaque(opaque).expect( + "can't find opaque in lookup map, which contains all opaques from env", + ); + + Type::Opaque(OpaquePath::new(lifetimes, Optional(false), borrow, tcx_id)) + }), + _ => { + errors.push(LoweringError::Other(format!("found &T in input where T is a custom type, but not opaque. T = {ref_ty}"))); + None + } + } + } + _ => { + errors.push(LoweringError::Other(format!("found &T in input where T isn't a custom type and therefore not opaque. T = {ref_ty}"))); + None + } + }, + ast::TypeName::Box(box_ty) => { + errors.push(match box_ty.as_ref() { + ast::TypeName::Named(path) | ast::TypeName::SelfType(path) => { + match path.resolve(in_path, env) { + ast::CustomType::Opaque(_) => LoweringError::Other(format!("found Box in input where T is an opaque, but owned opaques aren't allowed in inputs. try &T instead? T = {path}")), + _ => LoweringError::Other(format!("found Box in input where T is a custom type but not opaque. non-opaques can't be behind pointers, and opaques in inputs can't be owned. T = {path}")), + } + } + _ => LoweringError::Other(format!("found Box in input where T isn't a custom type. T = {box_ty}")), + }); + None + } + ast::TypeName::Option(opt_ty) => { + match opt_ty.as_ref() { + ast::TypeName::Reference(lifetime, mutability, ref_ty) => match ref_ty.as_ref() { + ast::TypeName::Named(path) | ast::TypeName::SelfType(path) => match path.resolve(in_path, env) { + ast::CustomType::Opaque(opaque) => ltl.map(|ltl| { + let borrow = Borrow::new(ltl.lower_lifetime(lifetime), *mutability); + let lifetimes = ltl.lower_generics(&path.lifetimes, ref_ty.is_self()); + let tcx_id = lookup_id.resolve_opaque(opaque).expect( + "can't find opaque in lookup map, which contains all opaques from env", + ); + + Type::Opaque(OpaquePath::new( + lifetimes, + Optional(true), + borrow, + tcx_id, + )) + }), + _ => { + errors.push(LoweringError::Other(format!("found Option<&T> in input where T is a custom type, but it's not opaque. T = {ref_ty}"))); + None + } + }, + _ => { + errors.push(LoweringError::Other(format!("found Option<&T> in input, but T isn't a custom type and therefore not opaque. T = {ref_ty}"))); + None + } + }, + ast::TypeName::Box(box_ty) => { + // we could see whats in the box here too + errors.push(LoweringError::Other(format!("found Option> in input, but box isn't allowed in inputs. T = {box_ty}"))); + None + } + _ => { + errors.push(LoweringError::Other(format!("found Option in input, where T isn't a reference but Option in inputs requires that T is a reference to an opaque. T = {opt_ty}"))); + None + } + } + } + ast::TypeName::Result(_, _, _) => { + errors.push(LoweringError::Other( + "Results can only appear as the top-level return type of methods".into(), + )); + None + } + ast::TypeName::Writeable => { + errors.push(LoweringError::Other( + "Writeables can only appear as the last parameter of a method".into(), + )); + None + } + ast::TypeName::StrReference(lifetime) => { + Some(Type::Slice(Slice::Str(ltl?.lower_lifetime(lifetime)))) + } + ast::TypeName::PrimitiveSlice(lifetime, mutability, prim) => { + let borrow = Borrow::new(ltl?.lower_lifetime(lifetime), *mutability); + let prim = PrimitiveType::from_ast(*prim); + + Some(Type::Slice(Slice::Primitive(borrow, prim))) + } + ast::TypeName::Unit => { + errors.push(LoweringError::Other("Unit types can only appear as the return value of a method, or as the Ok/Err variants of a returned result".into())); + None + } + } +} + +/// Lowers an [`ast::TypeName`]s into an [`hir::OutType`]. +/// +/// If there are any errors, they're pushed to `errors` and `None` is returned. +fn lower_out_type( + ty: &ast::TypeName, + ltl: Option<&mut L>, + lookup_id: &LookupId, + in_path: &ast::Path, + env: &Env, + errors: &mut Vec, +) -> Option { + match ty { + ast::TypeName::Primitive(prim) => Some(OutType::Primitive(PrimitiveType::from_ast(*prim))), + ast::TypeName::Named(path) | ast::TypeName::SelfType(path) => { + match path.resolve(in_path, env) { + ast::CustomType::Struct(strct) => { + let lifetimes = ltl?.lower_generics(&path.lifetimes, ty.is_self()); + + if let Some(tcx_id) = lookup_id.resolve_struct(strct) { + Some(OutType::Struct(ReturnableStructPath::Struct( + StructPath::new(lifetimes, tcx_id), + ))) + } else if let Some(tcx_id) = lookup_id.resolve_out_struct(strct) { + Some(OutType::Struct(ReturnableStructPath::OutStruct( + OutStructPath::new(lifetimes, tcx_id), + ))) + } else { + unreachable!("struct `{}` wasn't found in the set of structs or out-structs, this is a bug.", strct.name); + } + } + ast::CustomType::Opaque(_) => { + errors.push(LoweringError::Other(format!( + "Opaque passed by value in input: {path}" + ))); + None + } + ast::CustomType::Enum(enm) => { + let tcx_id = lookup_id + .resolve_enum(enm) + .expect("can't find enum in lookup map, which contains all enums from env"); + + Some(OutType::Enum(EnumPath::new(tcx_id))) + } + } + } + ast::TypeName::Reference(lifetime, mutability, ref_ty) => match ref_ty.as_ref() { + ast::TypeName::Named(path) | ast::TypeName::SelfType(path) => { + match path.resolve(in_path, env) { + ast::CustomType::Opaque(opaque) => ltl.map(|ltl| { + let borrow = Borrow::new(ltl.lower_lifetime(lifetime), *mutability); + let lifetimes = ltl.lower_generics(&path.lifetimes, ref_ty.is_self()); + let tcx_id = lookup_id.resolve_opaque(opaque).expect( + "can't find opaque in lookup map, which contains all opaques from env", + ); + + OutType::Opaque(OpaquePath::new( + lifetimes, + Optional(false), + MaybeOwn::Borrow(borrow), + tcx_id, + )) + }), + _ => { + errors.push(LoweringError::Other(format!("found &T in output where T is a custom type, but not opaque. T = {ref_ty}"))); + None + } + } + } + _ => { + errors.push(LoweringError::Other(format!("found &T in output where T isn't a custom type and therefore not opaque. T = {ref_ty}"))); + None + } + }, + ast::TypeName::Box(box_ty) => match box_ty.as_ref() { + ast::TypeName::Named(path) | ast::TypeName::SelfType(path) => { + match path.resolve(in_path, env) { + ast::CustomType::Opaque(opaque) => ltl.map(|ltl| { + let lifetimes = ltl.lower_generics(&path.lifetimes, box_ty.is_self()); + let tcx_id = lookup_id.resolve_opaque(opaque).expect( + "can't find opaque in lookup map, which contains all opaques from env", + ); + + OutType::Opaque(OpaquePath::new( + lifetimes, + Optional(true), + MaybeOwn::Own, + tcx_id, + )) + }), + _ => { + errors.push(LoweringError::Other(format!("found Box in output where T is a custom type but not opaque. non-opaques can't be behind pointers. T = {path}"))); + None + } + } + } + _ => { + errors.push(LoweringError::Other(format!( + "found Box in output where T isn't a custom type. T = {box_ty}" + ))); + None + } + }, + ast::TypeName::Option(opt_ty) => match opt_ty.as_ref() { + ast::TypeName::Reference(lifetime, mutability, ref_ty) => match ref_ty.as_ref() { + ast::TypeName::Named(path) | ast::TypeName::SelfType(path) => { + match path.resolve(in_path, env) { + ast::CustomType::Opaque(opaque) => ltl.map(|ltl| { + let borrow = Borrow::new(ltl.lower_lifetime(lifetime), *mutability); + let lifetimes = ltl.lower_generics(&path.lifetimes, ref_ty.is_self()); + let tcx_id = lookup_id.resolve_opaque(opaque).expect( + "can't find opaque in lookup map, which contains all opaques from env", + ); + + OutType::Opaque(OpaquePath::new( + lifetimes, + Optional(true), + MaybeOwn::Borrow(borrow), + tcx_id, + )) + }), + _ => { + errors.push(LoweringError::Other(format!("found Option<&T> where T is a custom type, but it's not opaque. T = {ref_ty}"))); + None + } + } + } + _ => { + errors.push(LoweringError::Other(format!("found Option<&T>, but T isn't a custom type and therefore not opaque. T = {ref_ty}"))); + None + } + }, + ast::TypeName::Box(box_ty) => match box_ty.as_ref() { + ast::TypeName::Named(path) | ast::TypeName::SelfType(path) => { + match path.resolve(in_path, env) { + ast::CustomType::Opaque(opaque) => { + let lifetimes = ltl?.lower_generics(&path.lifetimes, box_ty.is_self()); + let tcx_id = lookup_id.resolve_opaque(opaque).expect( + "can't find opaque in lookup map, which contains all opaques from env", + ); + + Some(OutType::Opaque(OpaquePath::new( + lifetimes, + Optional(true), + MaybeOwn::Own, + tcx_id, + ))) + } + _ => { + errors.push(LoweringError::Other(format!("found Option> where T is a custom type, but it's not opaque. T = {box_ty}"))); + None + } + } + } + _ => { + errors.push(LoweringError::Other(format!("found Option>, but T isn't a custom type and therefore not opaque. T = {box_ty}"))); + None + } + }, + _ => { + errors.push(LoweringError::Other(format!("found Option, where T isn't a reference but Option in inputs requires that T is a reference to an opaque. T = {opt_ty}"))); + None + } + }, + ast::TypeName::Result(_, _, _) => { + errors.push(LoweringError::Other( + "Results can only appear as the top-level return type of methods".into(), + )); + None + } + ast::TypeName::Writeable => { + errors.push(LoweringError::Other( + "Writeables can only appear as the last parameter of a method".into(), + )); + None + } + ast::TypeName::StrReference(lifetime) => { + Some(OutType::Slice(Slice::Str(ltl?.lower_lifetime(lifetime)))) + } + ast::TypeName::PrimitiveSlice(lifetime, mutability, prim) => { + let borrow = Borrow::new(ltl?.lower_lifetime(lifetime), *mutability); + let prim = PrimitiveType::from_ast(*prim); + + Some(OutType::Slice(Slice::Primitive(borrow, prim))) + } + ast::TypeName::Unit => { + errors.push(LoweringError::Other("Unit types can only appear as the return value of a method, or as the Ok/Err variants of a returned result".into())); + None + } + } +} + +/// Lowers an [`ast::SelfParam`] into an [`hir::ParamSelf`]. +/// +/// If there are any errors, they're pushed to `errors` and `None` is returned. +fn lower_self_param<'ast>( + self_param: &ast::SelfParam, + self_param_ltl: Option>, + lookup_id: &LookupId, + method_full_path: &ast::Ident, // for better error msg + in_path: &ast::Path, + env: &Env, + errors: &mut Vec, +) -> Option<(ParamSelf, ParamLifetimeLowerer<'ast>)> { + match self_param.path_type.resolve(in_path, env) { + ast::CustomType::Struct(strct) => { + if let Some(tcx_id) = lookup_id.resolve_struct(strct) { + if self_param.reference.is_some() { + errors.push(LoweringError::Other(format!("Method `{method_full_path}` takes a reference to a struct as a self parameter, which isn't allowed"))); + None + } else { + let mut param_ltl = self_param_ltl?.no_self_ref(); + + // Even if we explicitly write out the type of `self` like + // `self: Foo<'a>`, the `'a` is still not considered for + // elision according to rustc, so is_self=true. + let type_lifetimes = + param_ltl.lower_generics(&self_param.path_type.lifetimes[..], true); + + Some(( + ParamSelf::new(SelfType::Struct(StructPath::new(type_lifetimes, tcx_id))), + param_ltl, + )) + } + } else if lookup_id.resolve_out_struct(strct).is_some() { + if let Some((lifetime, _)) = &self_param.reference { + errors.push(LoweringError::Other(format!("Method `{method_full_path}` takes an out-struct as the self parameter, which isn't allowed. Also, it's behind a reference, `{lifetime}`, but only opaques can be behind references"))); + None + } else { + errors.push(LoweringError::Other(format!("Method `{method_full_path}` takes an out-struct as the self parameter, which isn't allowed"))); + None + } + } else { + unreachable!( + "struct `{}` wasn't found in the set of structs or out-structs, this is a bug.", + strct.name + ); + } + } + ast::CustomType::Opaque(opaque) => { + let tcx_id = lookup_id.resolve_opaque(opaque).expect("opaque is in env"); + + if let Some((lifetime, mutability)) = &self_param.reference { + let (borrow_lifetime, mut param_ltl) = self_param_ltl?.lower_self_ref(lifetime); + let borrow = Borrow::new(borrow_lifetime, *mutability); + let lifetimes = param_ltl.lower_generics(&self_param.path_type.lifetimes, true); + + Some(( + ParamSelf::new(SelfType::Opaque(OpaquePath::new( + lifetimes, + NonOptional, + borrow, + tcx_id, + ))), + param_ltl, + )) + } else { + errors.push(LoweringError::Other(format!("Method `{method_full_path}` takes an opaque by value as the self parameter, but opaques as inputs must be behind refs"))); + None + } + } + ast::CustomType::Enum(enm) => { + let tcx_id = lookup_id.resolve_enum(enm).expect("enum is in env"); + + Some(( + ParamSelf::new(SelfType::Enum(EnumPath::new(tcx_id))), + self_param_ltl?.no_self_ref(), + )) + } + } +} + +/// Lowers an [`ast::Param`] into an [`hir::Param`]. +/// +/// If there are any errors, they're pushed to `errors` and `None` is returned. +/// +/// Note that this expects that if there was a writeable param at the end in +/// the method, it's not passed into here. +fn lower_param( + param: &ast::Param, + ltl: Option<&mut L>, + lookup_id: &LookupId, + in_path: &ast::Path, + env: &Env, + errors: &mut Vec, +) -> Option { + let name = lower_ident(¶m.name, "param name", errors); + let ty = lower_type(¶m.ty, ltl, lookup_id, in_path, env, errors); + + Some(Param::new(name?, ty?)) +} + +/// Lowers many [`ast::Param`]s into a vector of [`hir::Param`]s. +/// +/// If there are any errors, they're pushed to `errors` and `None` is returned. +/// +/// Note that this expects that if there was a writeable param at the end in +/// the method, `ast_params` was sliced to not include it. This happens in +/// `lower_method`, the caller of this function. +fn lower_many_params<'ast>( + ast_params: &[ast::Param], + mut param_ltl: Option>, + lookup_id: &LookupId, + in_path: &ast::Path, + env: &Env, + errors: &mut Vec, +) -> Option<(Vec, ReturnLifetimeLowerer<'ast>)> { + let mut params = Some(Vec::with_capacity(ast_params.len())); + + for param in ast_params { + let param = lower_param(param, param_ltl.as_mut(), lookup_id, in_path, env, errors); + + match (param, &mut params) { + (Some(param), Some(params)) => { + params.push(param); + } + _ => params = None, + } + } + + Some((params?, param_ltl?.into_return_ltl())) +} + +/// Lowers the return type of an [`ast::Method`] into a [`hir::ReturnFallability`]. +/// +/// If there are any errors, they're pushed to `errors` and `None` is returned. +fn lower_return_type( + return_type: Option<&ast::TypeName>, + takes_writeable: bool, + mut return_ltl: Option>, + lookup_id: &LookupId, + in_path: &ast::Path, + env: &Env, + errors: &mut Vec, +) -> Option<(ReturnType, LifetimeEnv)> { + let writeable_option = if takes_writeable { + Some(SuccessType::Writeable) + } else { + None + }; + match return_type.unwrap_or(&ast::TypeName::Unit) { + ast::TypeName::Result(ok_ty, err_ty, _) => { + let ok_ty = match ok_ty.as_ref() { + ast::TypeName::Unit => Some(writeable_option), + ty => lower_out_type(ty, return_ltl.as_mut(), lookup_id, in_path, env, errors) + .map(|ty| Some(SuccessType::OutType(ty))), + }; + let err_ty = match err_ty.as_ref() { + ast::TypeName::Unit => Some(None), + ty => lower_out_type(ty, return_ltl.as_mut(), lookup_id, in_path, env, errors) + .map(Some), + }; + + match (ok_ty, err_ty) { + (Some(ok_ty), Some(err_ty)) => Some(ReturnType::Fallible(ok_ty, err_ty)), + _ => None, + } + } + ast::TypeName::Unit => Some(ReturnType::Infallible(writeable_option)), + ty => lower_out_type(ty, return_ltl.as_mut(), lookup_id, in_path, env, errors) + .map(|ty| ReturnType::Infallible(Some(SuccessType::OutType(ty)))), + } + .and_then(|return_fallability| Some((return_fallability, return_ltl?.finish()))) +} diff --git a/third_party/rust/diplomat_core/src/hir/methods.rs b/third_party/rust/diplomat_core/src/hir/methods.rs new file mode 100644 index 000000000000..b6050553fe51 --- /dev/null +++ b/third_party/rust/diplomat_core/src/hir/methods.rs @@ -0,0 +1,489 @@ +//! Methods for types and navigating lifetimes within methods. + +use std::fmt::{self, Write}; + +use smallvec::SmallVec; + +use super::{ + paths, Docs, Ident, IdentBuf, LifetimeEnv, MaybeStatic, MethodLifetime, MethodLifetimes, + OutType, SelfType, Slice, Type, TypeContext, TypeLifetime, TypeLifetimes, +}; + +/// A method exposed to Diplomat. +#[derive(Debug)] +pub struct Method { + pub docs: Docs, + pub name: IdentBuf, + pub lifetime_env: LifetimeEnv, + + pub param_self: Option, + pub params: Vec, + pub output: ReturnType, +} + +/// Type that the method returns. +#[derive(Debug)] +pub enum SuccessType { + Writeable, + OutType(OutType), +} + +/// Whether or not the method returns a value or a result. +#[derive(Debug)] +pub enum ReturnType { + Infallible(Option), + Fallible(Option, Option), +} + +/// The `self` parameter of a method. +#[derive(Debug)] +pub struct ParamSelf { + pub ty: SelfType, +} + +/// A parameter in a method. +#[derive(Debug)] +pub struct Param { + pub name: IdentBuf, + pub ty: Type, +} + +/// An id for indexing into a [`BorrowingFieldsVisitor`]. +#[derive(Copy, Clone, Debug)] +struct ParentId(usize); + +/// Convenience const representing the number of nested structs a [`BorrowingFieldVisitor`] +/// can hold inline before needing to dynamically allocate. +const INLINE_NUM_PARENTS: usize = 4; + +/// Convenience const representing the number of borrowed fields a [`BorrowingFieldVisitor`] +/// can hold inline before needing to dynamically allocate. +const INLINE_NUM_LEAVES: usize = 8; + +/// A tree of lifetimes mapping onto a specific instantiation of a type tree. +/// +/// Each `BorrowingFieldsVisitor` corresponds to the type of an input of a method. +pub struct BorrowingFieldVisitor<'m> { + parents: SmallVec<[(Option, &'m Ident); INLINE_NUM_PARENTS]>, + leaves: SmallVec<[BorrowingFieldVisitorLeaf; INLINE_NUM_LEAVES]>, +} + +/// Non-recursive input-output types that contain lifetimes +enum BorrowingFieldVisitorLeaf { + Opaque(ParentId, MaybeStatic, MethodLifetimes), + Slice(ParentId, MaybeStatic), +} + +/// A leaf of a lifetime tree capable of tracking its parents. +#[derive(Copy, Clone)] +pub struct BorrowingField<'m> { + /// All inner nodes in the tree. When tracing from the root, we jump around + /// this slice based on indices, but don't necessarily use all of them. + parents: &'m [(Option, &'m Ident)], + + /// The unpacked field that is a leaf on the tree. + leaf: &'m BorrowingFieldVisitorLeaf, +} + +impl SuccessType { + /// Returns `true` if it's writeable, otherwise `false`. + pub fn is_writeable(&self) -> bool { + matches!(self, SuccessType::Writeable) + } + + /// Returns a return type, if it's not a writeable. + pub fn as_type(&self) -> Option<&OutType> { + match self { + SuccessType::Writeable => None, + SuccessType::OutType(ty) => Some(ty), + } + } +} + +impl ReturnType { + /// Returns `true` if it's writeable, otherwise `false`. + pub fn is_writeable(&self) -> bool { + self.return_type() + .map(SuccessType::is_writeable) + .unwrap_or(false) + } + + /// Returns the [`ReturnOk`] value, whether it's the single return type or + /// the `Ok` variant of a result. + pub fn return_type(&self) -> Option<&SuccessType> { + match self { + ReturnType::Infallible(ret) | ReturnType::Fallible(ret, _) => ret.as_ref(), + } + } + + /// Returns `true` if the FFI function returns a value (such that it may be assigned to a variable). + pub fn returns_value(&self) -> bool { + match self { + ReturnType::Fallible(_, _) => true, + ReturnType::Infallible(Some(SuccessType::OutType(_))) => true, + ReturnType::Infallible(Some(SuccessType::Writeable)) => false, + ReturnType::Infallible(None) => false, + } + } +} + +impl ParamSelf { + pub(super) fn new(ty: SelfType) -> Self { + Self { ty } + } + + /// Return the number of fields and leaves that will show up in the [`BorrowingFieldVisitor`]. + /// + /// This method is used to calculate how much space to allocate upfront. + fn field_leaf_lifetime_counts(&self, tcx: &TypeContext) -> (usize, usize) { + match self.ty { + SelfType::Opaque(_) => (1, 1), + SelfType::Struct(ref ty) => ty.resolve(tcx).fields.iter().fold((1, 0), |acc, field| { + let inner = field.ty.field_leaf_lifetime_counts(tcx); + (acc.0 + inner.0, acc.1 + inner.1) + }), + SelfType::Enum(_) => (0, 0), + } + } +} + +impl Param { + pub(super) fn new(name: IdentBuf, ty: Type) -> Self { + Self { name, ty } + } +} + +impl Method { + /// Returns `true` if the method takes a writeable as an out parameter, + /// otherwise `false`. + pub fn is_writeable(&self) -> bool { + self.output.is_writeable() + } + + /// Returns a fresh [`MethodLifetimes`] corresponding to `self`. + pub fn method_lifetimes(&self) -> MethodLifetimes { + self.lifetime_env.method_lifetimes() + } + + /// Returns a new [`BorrowingFieldVisitor`], which allocates memory to + /// efficiently represent all fields (and their paths!) of the inputs that + /// have a lifetime. + /// ```ignore + /// # use std::collections::BTreeMap; + /// let visitor = method.borrowing_field_visitor(&tcx, "this".ck().unwrap()); + /// let mut map = BTreeMap::new(); + /// visitor.visit_borrowing_fields(|lifetime, field| { + /// map.entry(lifetime).or_default().push(field); + /// }) + /// ``` + pub fn borrowing_field_visitor<'m>( + &'m self, + tcx: &'m TypeContext, + self_name: &'m Ident, + ) -> BorrowingFieldVisitor<'m> { + BorrowingFieldVisitor::new(self, tcx, self_name) + } +} + +impl ParentId { + /// Pushes a new parent to the vec, returning the corresponding [`ParentId`]. + fn new<'m>( + parent: Option, + name: &'m Ident, + parents: &mut SmallVec<[(Option, &'m Ident); 4]>, + ) -> Self { + let this = ParentId(parents.len()); + parents.push((parent, name)); + this + } +} + +impl<'m> BorrowingFieldVisitor<'m> { + /// Visits every borrowing field and method lifetime that it uses. + /// + /// The idea is that you could use this to construct a mapping from + /// `MethodLifetime`s to `BorrowingField`s. We choose to use a visitor + /// pattern to avoid having to + /// + /// This would be convenient in the JavaScript backend where if you're + /// returning an `NonOpaque<'a, 'b>` from Rust, you need to pass a + /// `[[all input borrowing fields with 'a], [all input borrowing fields with 'b]]` + /// array into `NonOpaque`'s constructor. + /// + /// Alternatively, you could use such a map in the C++ backend by recursing + /// down the return type and keeping track of which fields you've recursed + /// into so far, and when you hit some lifetime 'a, generate docs saying + /// "path.to.current.field must be outlived by {borrowing fields of input that + /// contain 'a}". + pub fn visit_borrowing_fields<'a, F>(&'a self, mut visit: F) + where + F: FnMut(MaybeStatic, BorrowingField<'a>), + { + for leaf in self.leaves.iter() { + let borrowing_field = BorrowingField { + parents: self.parents.as_slice(), + leaf, + }; + + match leaf { + BorrowingFieldVisitorLeaf::Opaque(_, lt, method_lifetimes) => { + visit(*lt, borrowing_field); + for lt in method_lifetimes.lifetimes() { + visit(lt, borrowing_field); + } + } + BorrowingFieldVisitorLeaf::Slice(_, lt) => { + visit(*lt, borrowing_field); + } + } + } + } + + /// Returns a new `BorrowingFieldsVisitor` containing all the lifetime trees of the arguments + /// in only two allocations. + fn new(method: &'m Method, tcx: &'m TypeContext, self_name: &'m Ident) -> Self { + let (parents, leaves) = method + .param_self + .as_ref() + .map(|param_self| param_self.field_leaf_lifetime_counts(tcx)) + .into_iter() + .chain( + method + .params + .iter() + .map(|param| param.ty.field_leaf_lifetime_counts(tcx)), + ) + .reduce(|acc, x| (acc.0 + x.0, acc.1 + x.1)) + .map(|(num_fields, num_leaves)| { + let num_params = method.params.len() + usize::from(method.param_self.is_some()); + let mut parents = SmallVec::with_capacity(num_fields + num_params); + let mut leaves = SmallVec::with_capacity(num_leaves); + let method_lifetimes = method.method_lifetimes(); + + if let Some(param_self) = method.param_self.as_ref() { + let parent = ParentId::new(None, self_name, &mut parents); + match ¶m_self.ty { + SelfType::Opaque(ty) => { + Self::visit_opaque( + &ty.lifetimes, + &ty.borrowed().lifetime, + parent, + &method_lifetimes, + &mut leaves, + ); + } + SelfType::Struct(ty) => { + Self::visit_struct( + ty, + tcx, + parent, + &method_lifetimes, + &mut parents, + &mut leaves, + ); + } + SelfType::Enum(_) => {} + } + } + + for param in method.params.iter() { + let parent = ParentId::new(None, param.name.as_ref(), &mut parents); + Self::from_type( + ¶m.ty, + tcx, + parent, + &method_lifetimes, + &mut parents, + &mut leaves, + ); + } + + // sanity check that the preallocations were correct + debug_assert_eq!( + parents.capacity(), + std::cmp::max(INLINE_NUM_PARENTS, num_fields + num_params) + ); + debug_assert_eq!( + leaves.capacity(), + std::cmp::max(INLINE_NUM_LEAVES, num_leaves) + ); + (parents, leaves) + }) + .unwrap_or_default(); + + Self { parents, leaves } + } + + /// Returns a new [`BorrowingFieldsVisitor`] corresponding to a type. + fn from_type( + ty: &'m Type, + tcx: &'m TypeContext, + parent: ParentId, + method_lifetimes: &MethodLifetimes, + parents: &mut SmallVec<[(Option, &'m Ident); 4]>, + leaves: &mut SmallVec<[BorrowingFieldVisitorLeaf; 8]>, + ) { + match ty { + Type::Opaque(path) => { + Self::visit_opaque( + &path.lifetimes, + &path.borrowed().lifetime, + parent, + method_lifetimes, + leaves, + ); + } + Type::Slice(slice) => { + Self::visit_slice(slice, parent, method_lifetimes, leaves); + } + Type::Struct(path) => { + Self::visit_struct(path, tcx, parent, method_lifetimes, parents, leaves); + } + _ => {} + } + } + + /// Add an opaque as a leaf during construction of a [`BorrowingFieldsVisitor`]. + fn visit_opaque( + lifetimes: &'m TypeLifetimes, + borrow: &'m MaybeStatic, + parent: ParentId, + method_lifetimes: &MethodLifetimes, + leaves: &mut SmallVec<[BorrowingFieldVisitorLeaf; 8]>, + ) { + let method_borrow_lifetime = + borrow.flat_map_nonstatic(|lt| lt.as_method_lifetime(method_lifetimes)); + let method_type_lifetimes = lifetimes.as_method_lifetimes(method_lifetimes); + leaves.push(BorrowingFieldVisitorLeaf::Opaque( + parent, + method_borrow_lifetime, + method_type_lifetimes, + )); + } + + /// Add a slice as a leaf during construction of a [`BorrowingFieldsVisitor`]. + fn visit_slice( + slice: &Slice, + parent: ParentId, + method_lifetimes: &MethodLifetimes, + leaves: &mut SmallVec<[BorrowingFieldVisitorLeaf; 8]>, + ) { + let method_lifetime = slice + .lifetime() + .flat_map_nonstatic(|lt| lt.as_method_lifetime(method_lifetimes)); + leaves.push(BorrowingFieldVisitorLeaf::Slice(parent, method_lifetime)); + } + + /// Add a struct as a parent and recurse down leaves during construction of a + /// [`BorrowingFieldsVisitor`]. + fn visit_struct( + ty: &paths::StructPath, + tcx: &'m TypeContext, + parent: ParentId, + method_lifetimes: &MethodLifetimes, + parents: &mut SmallVec<[(Option, &'m Ident); 4]>, + leaves: &mut SmallVec<[BorrowingFieldVisitorLeaf; 8]>, + ) { + let method_type_lifetimes = ty.lifetimes.as_method_lifetimes(method_lifetimes); + for field in ty.resolve(tcx).fields.iter() { + Self::from_type( + &field.ty, + tcx, + ParentId::new(Some(parent), field.name.as_ref(), parents), + &method_type_lifetimes, + parents, + leaves, + ); + } + } +} + +impl<'m> BorrowingField<'m> { + /// Visit fields in order. + /// + /// If `self` represents the field `param.first.second`, then calling [`BorrowingField::trace`] + /// will visit the following in order: `"param"`, `"first"`, `"second"`. + pub fn backtrace(&self, mut visit: F) + where + F: FnMut(usize, &'m Ident), + { + let (parent, ident) = match self.leaf { + BorrowingFieldVisitorLeaf::Opaque(id, ..) | BorrowingFieldVisitorLeaf::Slice(id, _) => { + self.parents[id.0] + } + }; + + self.backtrace_rec(parent, ident, &mut visit); + } + + /// Recursively visits fields in order from root to leaf by building up the + /// stack, and then visiting fields as it unwinds. + fn backtrace_rec(&self, parent: Option, ident: &'m Ident, visit: &mut F) -> usize + where + F: FnMut(usize, &'m Ident), + { + let from_end = if let Some(id) = parent { + let (parent, ident) = self.parents[id.0]; + self.backtrace_rec(parent, ident, visit) + } else { + 0 + }; + + visit(from_end, ident); + + from_end + 1 + } + + /// Fallibly visits fields in order. + /// + /// This method is similar to [`BorrowinfField::backtrace`], but short-circuits + /// when an `Err` is returned. + pub fn try_backtrace(&self, mut visit: F) -> Result<(), E> + where + F: FnMut(usize, &'m Ident) -> Result<(), E>, + { + let (parent, ident) = match self.leaf { + BorrowingFieldVisitorLeaf::Opaque(id, ..) | BorrowingFieldVisitorLeaf::Slice(id, _) => { + self.parents[id.0] + } + }; + + self.try_backtrace_rec(parent, ident, &mut visit)?; + + Ok(()) + } + + /// Recursively visits fields in order from root to leaf by building up the + /// stack, and then visiting fields as it unwinds. + fn try_backtrace_rec( + &self, + parent: Option, + ident: &'m Ident, + visit: &mut F, + ) -> Result + where + F: FnMut(usize, &'m Ident) -> Result<(), E>, + { + let from_end = if let Some(id) = parent { + let (parent, ident) = self.parents[id.0]; + self.try_backtrace_rec(parent, ident, visit)? + } else { + 0 + }; + + visit(from_end, ident)?; + + Ok(from_end + 1) + } +} + +impl<'m> fmt::Display for BorrowingField<'m> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.try_backtrace(|i, ident| { + if i != 0 { + f.write_char('.')?; + } + f.write_str(ident.as_str()) + }) + } +} diff --git a/third_party/rust/diplomat_core/src/hir/mod.rs b/third_party/rust/diplomat_core/src/hir/mod.rs new file mode 100644 index 000000000000..3ee4963aff50 --- /dev/null +++ b/third_party/rust/diplomat_core/src/hir/mod.rs @@ -0,0 +1,29 @@ +//! Experimental high-level representation (HIR) for Diplomat. +//! +//! Enabled with the `"hir"` Cargo feature + +mod defs; +mod elision; +mod lifetimes; +mod lowering; +mod methods; +mod paths; +mod primitives; +mod ty_position; +mod type_context; +mod types; +pub use defs::*; +pub(super) use elision::*; +pub use lifetimes::*; +pub(super) use lowering::*; +pub use methods::*; +pub use paths::*; +pub use primitives::*; +pub use ty_position::*; +pub use type_context::*; +pub use types::*; + +pub use lowering::LoweringError; + +pub use crate::ast::Docs; +pub use strck_ident::rust::{Ident, IdentBuf}; diff --git a/third_party/rust/diplomat_core/src/hir/paths.rs b/third_party/rust/diplomat_core/src/hir/paths.rs new file mode 100644 index 000000000000..446490c7d2f4 --- /dev/null +++ b/third_party/rust/diplomat_core/src/hir/paths.rs @@ -0,0 +1,167 @@ +use super::{ + Borrow, EnumDef, EnumId, Everywhere, OpaqueDef, OpaqueId, OpaqueOwner, OutStructDef, + OutputOnly, ReturnableStructDef, StructDef, TyPosition, TypeContext, TypeLifetimes, +}; + +/// Path to a struct that may appear as an output. +#[derive(Debug, Clone)] +pub enum ReturnableStructPath { + Struct(StructPath), + OutStruct(OutStructPath), +} + +/// Path to a struct that can only be used as an output. +pub type OutStructPath = StructPath; + +/// Path to a struct that can be used in inputs and outputs. +#[derive(Debug, Clone)] +pub struct StructPath { + pub lifetimes: TypeLifetimes, + pub tcx_id: P::StructId, +} + +/// Path to an opaque. +/// +/// There are three kinds of opaques that Diplomat uses, so this type has two +/// generic arguments to differentiate between the three, while still showing +/// that the three are all paths to opaques. The monomorphized versions that +/// Diplomat uses are: +/// +/// 1. `OpaquePath`: Opaques in return types, +/// which can be optional and either owned or borrowed. +/// 2. `OpaquePath`: Opaques in method parameters, which can +/// be optional but must be borrowed, since most languages don't have a way to +/// entirely give up ownership of a value. +/// 3. `OpaquePath`: Opaques in the `&self` position, which +/// cannot be optional and must be borrowed for the same reason as above. +#[derive(Debug, Clone)] +pub struct OpaquePath { + pub lifetimes: TypeLifetimes, + pub optional: Opt, + pub owner: Owner, + pub tcx_id: OpaqueId, +} + +#[derive(Debug, Copy, Clone)] +pub struct Optional(pub(super) bool); + +#[derive(Debug, Copy, Clone)] +pub struct NonOptional; + +impl OpaquePath { + pub fn is_optional(&self) -> bool { + self.optional.0 + } +} + +impl OpaquePath { + pub fn wrap_optional(self) -> OpaquePath { + OpaquePath { + lifetimes: self.lifetimes, + optional: Optional(false), + owner: self.owner, + tcx_id: self.tcx_id, + } + } +} + +impl OpaquePath { + pub fn as_borrowed(&self) -> Option<&Borrow> { + self.owner.as_borrowed() + } +} + +impl OpaquePath { + pub fn borrowed(&self) -> &Borrow { + &self.owner + } +} + +/// Path to an enum. +#[derive(Debug, Clone)] +pub struct EnumPath { + pub tcx_id: EnumId, +} + +/// Determine whether a pointer to an opaque type is owned or borrowed. +/// +/// Since owned opaques cannot be used as inputs, this only appears in output types. +#[derive(Copy, Clone, Debug)] +pub enum MaybeOwn { + Own, + Borrow(Borrow), +} + +impl MaybeOwn { + pub fn as_borrowed(&self) -> Option<&Borrow> { + match self { + MaybeOwn::Own => None, + MaybeOwn::Borrow(borrow) => Some(borrow), + } + } +} + +impl ReturnableStructPath { + pub fn resolve<'tcx>(&self, tcx: &'tcx TypeContext) -> ReturnableStructDef<'tcx> { + match self { + ReturnableStructPath::Struct(path) => ReturnableStructDef::Struct(path.resolve(tcx)), + ReturnableStructPath::OutStruct(path) => { + ReturnableStructDef::OutStruct(path.resolve(tcx)) + } + } + } +} + +impl StructPath

{ + /// Returns a new [`EnumPath`]. + pub(super) fn new(lifetimes: TypeLifetimes, tcx_id: P::StructId) -> Self { + Self { lifetimes, tcx_id } + } +} +impl StructPath { + /// Returns the [`StructDef`] that this path references. + pub fn resolve<'tcx>(&self, tcx: &'tcx TypeContext) -> &'tcx StructDef { + tcx.resolve_struct(self.tcx_id) + } +} + +impl OutStructPath { + /// Returns the [`OutStructDef`] that this path references. + pub fn resolve<'tcx>(&self, tcx: &'tcx TypeContext) -> &'tcx OutStructDef { + tcx.resolve_out_struct(self.tcx_id) + } +} + +impl OpaquePath { + /// Returns a new [`EnumPath`]. + pub(super) fn new( + lifetimes: TypeLifetimes, + optional: Opt, + owner: Owner, + tcx_id: OpaqueId, + ) -> Self { + Self { + lifetimes, + optional, + owner, + tcx_id, + } + } + + /// Returns the [`OpaqueDef`] that this path references. + pub fn resolve<'tcx>(&self, tcx: &'tcx TypeContext) -> &'tcx OpaqueDef { + tcx.resolve_opaque(self.tcx_id) + } +} + +impl EnumPath { + /// Returns a new [`EnumPath`]. + pub(super) fn new(tcx_id: EnumId) -> Self { + Self { tcx_id } + } + + /// Returns the [`EnumDef`] that this path references. + pub fn resolve<'tcx>(&self, tcx: &'tcx TypeContext) -> &'tcx EnumDef { + tcx.resolve_enum(self.tcx_id) + } +} diff --git a/third_party/rust/diplomat_core/src/hir/primitives.rs b/third_party/rust/diplomat_core/src/hir/primitives.rs new file mode 100644 index 000000000000..4f68b41f115e --- /dev/null +++ b/third_party/rust/diplomat_core/src/hir/primitives.rs @@ -0,0 +1,128 @@ +//! Primitives types that can cross the FFI boundary. +use crate::ast; + +/// 8, 16, 32, and 64-bit signed and unsigned integers. +#[derive(Copy, Clone, Debug)] +pub enum IntType { + I8, + I16, + I32, + I64, + U8, + U16, + U32, + U64, +} + +/// Platform-dependent signed and unsigned size types. +#[derive(Copy, Clone, Debug)] +pub enum IntSizeType { + Isize, + Usize, +} + +/// 128-bit signed and unsigned integers. +#[derive(Copy, Clone, Debug)] +pub enum Int128Type { + I128, + U128, +} + +/// 32 and 64-bit floating point numbers. +#[derive(Copy, Clone, Debug)] +pub enum FloatType { + F32, + F64, +} + +/// All primitive types. +#[derive(Copy, Clone, Debug)] +pub enum PrimitiveType { + Bool, + Char, + Int(IntType), + IntSize(IntSizeType), + Int128(Int128Type), + Float(FloatType), +} + +impl IntType { + /// Returns the string representation of `self`. + pub fn as_str(&self) -> &'static str { + match self { + IntType::I8 => "i8", + IntType::I16 => "i16", + IntType::I32 => "i32", + IntType::I64 => "i64", + IntType::U8 => "u8", + IntType::U16 => "u16", + IntType::U32 => "u32", + IntType::U64 => "u64", + } + } +} + +impl IntSizeType { + /// Returns the string representation of `self`. + pub fn as_str(&self) -> &'static str { + match self { + IntSizeType::Isize => "isize", + IntSizeType::Usize => "usize", + } + } +} + +impl Int128Type { + /// Returns the string representation of `self`. + pub fn as_str(&self) -> &'static str { + match self { + Int128Type::I128 => "i128", + Int128Type::U128 => "u128", + } + } +} + +impl FloatType { + /// Returns the string representation of `self`. + pub fn as_str(&self) -> &'static str { + match self { + FloatType::F32 => "f32", + FloatType::F64 => "f64", + } + } +} + +impl PrimitiveType { + pub(super) fn from_ast(prim: ast::PrimitiveType) -> Self { + match prim { + ast::PrimitiveType::i8 => PrimitiveType::Int(IntType::I8), + ast::PrimitiveType::u8 => PrimitiveType::Int(IntType::U8), + ast::PrimitiveType::i16 => PrimitiveType::Int(IntType::I16), + ast::PrimitiveType::u16 => PrimitiveType::Int(IntType::U16), + ast::PrimitiveType::i32 => PrimitiveType::Int(IntType::I32), + ast::PrimitiveType::u32 => PrimitiveType::Int(IntType::U32), + ast::PrimitiveType::i64 => PrimitiveType::Int(IntType::I64), + ast::PrimitiveType::u64 => PrimitiveType::Int(IntType::U64), + ast::PrimitiveType::isize => PrimitiveType::IntSize(IntSizeType::Isize), + ast::PrimitiveType::usize => PrimitiveType::IntSize(IntSizeType::Usize), + ast::PrimitiveType::i128 => PrimitiveType::Int128(Int128Type::I128), + ast::PrimitiveType::u128 => PrimitiveType::Int128(Int128Type::U128), + ast::PrimitiveType::f32 => PrimitiveType::Float(FloatType::F32), + ast::PrimitiveType::f64 => PrimitiveType::Float(FloatType::F64), + ast::PrimitiveType::bool => PrimitiveType::Bool, + ast::PrimitiveType::char => PrimitiveType::Char, + } + } + + /// Returns the string representation of `self`. + pub fn as_str(&self) -> &'static str { + match self { + PrimitiveType::Bool => "bool", + PrimitiveType::Char => "char", + PrimitiveType::Int(ty) => ty.as_str(), + PrimitiveType::IntSize(ty) => ty.as_str(), + PrimitiveType::Int128(ty) => ty.as_str(), + PrimitiveType::Float(ty) => ty.as_str(), + } + } +} diff --git a/third_party/rust/diplomat_core/src/hir/snapshots/diplomat_core__hir__elision__tests__borrowing_fields.snap b/third_party/rust/diplomat_core/src/hir/snapshots/diplomat_core__hir__elision__tests__borrowing_fields.snap new file mode 100644 index 000000000000..70dfebc24ea1 --- /dev/null +++ b/third_party/rust/diplomat_core/src/hir/snapshots/diplomat_core__hir__elision__tests__borrowing_fields.snap @@ -0,0 +1,25 @@ +--- +source: core/src/hir/elision.rs +expression: map +--- +{ + Static: [ + "this.name", + "_s", + ], + NonStatic( + MethodLifetime( + 0, + ), + ): [ + "this.p_data", + ], + NonStatic( + MethodLifetime( + 1, + ), + ): [ + "this.q_data", + "this.inner.more_data", + ], +} diff --git a/third_party/rust/diplomat_core/src/hir/snapshots/diplomat_core__hir__elision__tests__simple_mod.snap b/third_party/rust/diplomat_core/src/hir/snapshots/diplomat_core__hir__elision__tests__simple_mod.snap new file mode 100644 index 000000000000..47bb56bf33da --- /dev/null +++ b/third_party/rust/diplomat_core/src/hir/snapshots/diplomat_core__hir__elision__tests__simple_mod.snap @@ -0,0 +1,208 @@ +--- +source: core/src/hir/elision.rs +expression: tcx +--- +TypeContext { + out_structs: [ + StructDef { + docs: Docs( + "", + [], + ), + name: "OutStruct", + fields: [ + StructField { + docs: Docs( + "", + [], + ), + name: "inner", + ty: Opaque( + OpaquePath { + lifetimes: TypeLifetimes { + indices: [ + NonStatic( + TypeLifetime( + 0, + ), + ), + ], + }, + optional: Optional( + true, + ), + owner: Own, + tcx_id: OpaqueId( + 0, + ), + }, + ), + }, + ], + methods: [ + Method { + docs: Docs( + "", + [], + ), + name: "new", + lifetime_env: LifetimeEnv { + nodes: [ + Lifetime { + ident: "a", + longer: [], + shorter: [], + }, + ], + num_lifetimes: 1, + }, + param_self: None, + params: [ + Param { + name: "s", + ty: Slice( + Str( + NonStatic( + TypeLifetime( + 0, + ), + ), + ), + ), + }, + ], + output: Infallible( + Some( + OutType( + Struct( + OutStruct( + StructPath { + lifetimes: TypeLifetimes { + indices: [ + NonStatic( + TypeLifetime( + 0, + ), + ), + ], + }, + tcx_id: OutStructId( + 0, + ), + }, + ), + ), + ), + ), + ), + }, + ], + }, + ], + structs: [ + StructDef { + docs: Docs( + "", + [], + ), + name: "Struct", + fields: [ + StructField { + docs: Docs( + "", + [], + ), + name: "s", + ty: Slice( + Str( + NonStatic( + TypeLifetime( + 0, + ), + ), + ), + ), + }, + ], + methods: [ + Method { + docs: Docs( + "", + [], + ), + name: "rustc_elision", + lifetime_env: LifetimeEnv { + nodes: [ + Lifetime { + ident: "a", + longer: [], + shorter: [], + }, + ], + num_lifetimes: 2, + }, + param_self: Some( + ParamSelf { + ty: Struct( + StructPath { + lifetimes: TypeLifetimes { + indices: [ + NonStatic( + TypeLifetime( + 0, + ), + ), + ], + }, + tcx_id: StructId( + 0, + ), + }, + ), + }, + ), + params: [ + Param { + name: "s", + ty: Slice( + Str( + NonStatic( + TypeLifetime( + 1, + ), + ), + ), + ), + }, + ], + output: Infallible( + Some( + OutType( + Slice( + Str( + NonStatic( + TypeLifetime( + 1, + ), + ), + ), + ), + ), + ), + ), + }, + ], + }, + ], + opaques: [ + OpaqueDef { + docs: Docs( + "", + [], + ), + name: "Opaque", + methods: [], + }, + ], + enums: [], +} diff --git a/third_party/rust/diplomat_core/src/hir/ty_position.rs b/third_party/rust/diplomat_core/src/hir/ty_position.rs new file mode 100644 index 000000000000..ed6d75258684 --- /dev/null +++ b/third_party/rust/diplomat_core/src/hir/ty_position.rs @@ -0,0 +1,182 @@ +use super::{ + Borrow, MaybeOwn, Mutability, OutStructId, ReturnableStructPath, StructId, StructPath, TypeId, +}; +use core::fmt::Debug; + +/// Abstraction over where a type can appear in a function signature. +/// +/// # "Output only" and "everywhere" types +/// +/// While Rust is able to give up ownership of values, languages that Diplomat +/// supports (C++, Javascript, etc.) generally cannot. For example, we can +/// construct a `Box` in a Rust function and _return_ it to the other +/// language as a pointer. However, we cannot _accept_ `Box` as an input +/// because there's nothing stopping other languages from using that value again. +/// Therefore, we classify boxed opaques as "output only" types, since they can +/// only be returned from Rust but not taken as inputs. +/// +/// Furthermore, Diplomat also supports "bag o' stuff" structs where all fields get +/// translated at the boundary. If one contains an "output only" type as a field, +/// then the whole struct must also be "output only". In particular, this means +/// that if a boxed opaque is nested in a bunch of "bag o' stuff" structs, than +/// all of those structs must also be "output only". +/// +/// Currently, there are only two classes of structs: those that are "output only", +/// and those that are not. These are represented by the types [`OutputOnly`] +/// and [`Everywhere`] marker types respectively, which are the _only_ two types +/// that implement [`TyPosition`]. +/// +/// # How does abstraction help? +/// +/// The HIR was designed around the idea of making invalid states unrepresentable. +/// Since "output only" types can contain values that "everywhere" types cannot, +/// it doesn't make sense for them to be represented in the same type, even if +/// they're mostly the same. One of these differences is that opaques (which are +/// always behind a pointer) can only be represented as a borrow in "everywhere" +/// types, but can additionally be represented as owned in "output only" types. +/// If we were to use the same type for both, then backends working with "everywhere" +/// types would constantly have unreachable statements for owned opaque cases. +/// +/// That being said, "output only" and "everywhere" types are still mostly the +/// same, so this trait allows us to describe the differences. For example, the +/// HIR uses a singular [`Type`](super::Type) type for representing both +/// "output only" types and "everywhere" types, since it takes advantage of this +/// traits associated types to "fill in" the different parts: +/// ```ignore +/// pub enum Type { +/// Primitive(PrimitiveType), +/// Opaque(OpaquePath), +/// Struct(P::StructPath), +/// Enum(EnumPath), +/// Slice(Slice), +/// } +/// ``` +/// +/// When `P` takes on [`Everywhere`], this signature becomes: +/// ```ignore +/// pub enum Type { +/// Primitive(PrimitiveType), +/// Opaque(OpaquePath), +/// Struct(StructPath), +/// Enum(EnumPath), +/// Slice(Slice), +/// } +/// ``` +/// +/// This allows us to represent any kind of type that can appear "everywhere" +/// i.e. in inputs or outputs. Notice how the second generic in the `Opaque` +/// variant becomes [`Borrow`]. This describes the semantics of the pointer that +/// the opaque lives behind, and shows that for "everywhere" types, opaques +/// can _only_ be represented as living behind a borrow. +/// +/// Contrast this to when `P` takes on [`OutputOnly`]: +/// ```ignore +/// pub enum Type { +/// Primitive(PrimitiveType), +/// Opaque(OpaquePath), +/// Struct(OutStructPath), +/// Enum(EnumPath), +/// Slice(Slice), +/// } +/// ``` +/// Here, the second generic of the `Opaque` variant becomes [`MaybeOwn`], meaning +/// that "output only" types can contain opaques that are either borrowed _or_ owned. +/// +/// Therefore, this trait allows be extremely precise about making invalid states +/// unrepresentable, while also reducing duplicated code. +/// +pub trait TyPosition: Debug + Copy { + const IS_OUT_ONLY: bool; + + /// Type representing how we can point to opaques, which must always be behind a pointer. + /// + /// The types represented by [`OutputOnly`] are capable of either owning or + /// borrowing opaques, and so the associated type for that impl is [`MaybeOwn`]. + /// + /// On the other hand, types represented by [`Everywhere`] can only contain + /// borrowes, so the associated type for that impl is [`Borrow`]. + type OpaqueOwnership: Debug + OpaqueOwner; + + type StructId: Debug; + + type StructPath: Debug; + + fn id_for_path(p: &Self::StructPath) -> TypeId; +} + +/// One of two types implementing [`TyPosition`], representing types that can be +/// used as both input and output to functions. +/// +/// The complement of this type is [`OutputOnly`]. +#[derive(Debug, Copy, Clone)] +pub struct Everywhere; + +/// One of two types implementing [`TyPosition`], representing types that can +/// only be used as return types in functions. +/// +/// The complement of this type is [`Everywhere`]. +#[derive(Debug, Copy, Clone)] +pub struct OutputOnly; + +impl TyPosition for Everywhere { + const IS_OUT_ONLY: bool = false; + type OpaqueOwnership = Borrow; + type StructId = StructId; + type StructPath = StructPath; + + fn id_for_path(p: &Self::StructPath) -> TypeId { + p.tcx_id.into() + } +} + +impl TyPosition for OutputOnly { + const IS_OUT_ONLY: bool = true; + type OpaqueOwnership = MaybeOwn; + type StructId = OutStructId; + type StructPath = ReturnableStructPath; + fn id_for_path(p: &Self::StructPath) -> TypeId { + match p { + ReturnableStructPath::Struct(p) => p.tcx_id.into(), + ReturnableStructPath::OutStruct(p) => p.tcx_id.into(), + } + } +} + +/// Abstraction over how a type can hold a pointer to an opaque. +/// +/// This trait is designed as a helper abstraction for the `OpaqueOwnership` +/// associated type in the [`TyPosition`] trait. As such, only has two implementing +/// types: [`MaybeOwn`] and [`Borrow`] for the [`OutputOnly`] and [`Everywhere`] +/// implementations of [`TyPosition`] respectively. +pub trait OpaqueOwner { + /// Return the mutability of this owner + fn mutability(&self) -> Option; + + fn is_owned(&self) -> bool; +} + +impl OpaqueOwner for MaybeOwn { + fn mutability(&self) -> Option { + match self { + MaybeOwn::Own => None, + MaybeOwn::Borrow(b) => b.mutability(), + } + } + + fn is_owned(&self) -> bool { + match self { + MaybeOwn::Own => true, + MaybeOwn::Borrow(_) => false, + } + } +} + +impl OpaqueOwner for Borrow { + fn mutability(&self) -> Option { + Some(self.mutability) + } + + fn is_owned(&self) -> bool { + false + } +} diff --git a/third_party/rust/diplomat_core/src/hir/type_context.rs b/third_party/rust/diplomat_core/src/hir/type_context.rs new file mode 100644 index 000000000000..58ffd62738a2 --- /dev/null +++ b/third_party/rust/diplomat_core/src/hir/type_context.rs @@ -0,0 +1,254 @@ +//! Store all the types contained in the HIR. + +use super::{EnumDef, LoweringError, OpaqueDef, OutStructDef, StructDef, TypeDef, TypeLowerer}; +#[allow(unused_imports)] // use in docs links +use crate::hir; +use crate::{ast, Env}; +use smallvec::SmallVec; +use std::collections::HashMap; +use std::ops::Index; + +/// A context type owning all types exposed to Diplomat. +#[derive(Debug)] +pub struct TypeContext { + out_structs: Vec, + structs: Vec, + opaques: Vec, + enums: Vec, +} + +/// Key used to index into a [`TypeContext`] representing a struct. +#[derive(Copy, Clone, Debug)] +pub struct StructId(usize); + +/// Key used to index into a [`TypeContext`] representing an out struct. +#[derive(Copy, Clone, Debug)] +pub struct OutStructId(usize); + +/// Key used to index into a [`TypeContext`] representing a opaque. +#[derive(Copy, Clone, Debug)] +pub struct OpaqueId(usize); + +/// Key used to index into a [`TypeContext`] representing an enum. +#[derive(Copy, Clone, Debug)] +pub struct EnumId(usize); + +#[derive(Copy, Clone, Debug)] +pub enum TypeId { + Struct(StructId), + OutStruct(OutStructId), + Opaque(OpaqueId), + Enum(EnumId), +} + +impl TypeContext { + pub fn all_types<'tcx>(&'tcx self) -> impl Iterator)> { + self.structs + .iter() + .enumerate() + .map(|(i, ty)| (TypeId::Struct(StructId(i)), TypeDef::Struct(ty))) + .chain( + self.out_structs + .iter() + .enumerate() + .map(|(i, ty)| (TypeId::OutStruct(OutStructId(i)), TypeDef::OutStruct(ty))), + ) + .chain( + self.opaques + .iter() + .enumerate() + .map(|(i, ty)| (TypeId::Opaque(OpaqueId(i)), TypeDef::Opaque(ty))), + ) + .chain( + self.enums + .iter() + .enumerate() + .map(|(i, ty)| (TypeId::Enum(EnumId(i)), TypeDef::Enum(ty))), + ) + } + + pub fn out_structs(&self) -> &[OutStructDef] { + &self.out_structs + } + + pub fn structs(&self) -> &[StructDef] { + &self.structs + } + + pub fn opaques(&self) -> &[OpaqueDef] { + &self.opaques + } + + pub fn enums(&self) -> &[EnumDef] { + &self.enums + } + + pub fn resolve_type<'tcx>(&'tcx self, id: TypeId) -> TypeDef<'tcx> { + match id { + TypeId::Struct(i) => TypeDef::Struct(self.resolve_struct(i)), + TypeId::OutStruct(i) => TypeDef::OutStruct(self.resolve_out_struct(i)), + TypeId::Opaque(i) => TypeDef::Opaque(self.resolve_opaque(i)), + TypeId::Enum(i) => TypeDef::Enum(self.resolve_enum(i)), + } + } + + pub(crate) fn resolve_out_struct(&self, id: OutStructId) -> &OutStructDef { + self.out_structs.index(id.0) + } + + pub(crate) fn resolve_struct(&self, id: StructId) -> &StructDef { + self.structs.index(id.0) + } + + pub(crate) fn resolve_opaque(&self, id: OpaqueId) -> &OpaqueDef { + self.opaques.index(id.0) + } + + pub(crate) fn resolve_enum(&self, id: EnumId) -> &EnumDef { + self.enums.index(id.0) + } + + /// Lower the AST to the HIR while simultaneously performing validation. + pub fn from_ast(env: &Env) -> Result> { + let mut ast_out_structs = SmallVec::<[_; 16]>::new(); + let mut ast_structs = SmallVec::<[_; 16]>::new(); + let mut ast_opaques = SmallVec::<[_; 16]>::new(); + let mut ast_enums = SmallVec::<[_; 16]>::new(); + + let mut errors = Vec::with_capacity(0); + + for (path, _, sym) in env.iter_items() { + if let ast::ModSymbol::CustomType(custom_type) = sym { + match custom_type { + ast::CustomType::Struct(strct) => { + if strct.output_only { + ast_out_structs.push((path, strct)); + } else { + ast_structs.push((path, strct)); + } + } + ast::CustomType::Opaque(opaque) => ast_opaques.push((path, opaque)), + ast::CustomType::Enum(enm) => ast_enums.push((path, enm)), + } + } + } + + let lookup_id = LookupId::new( + &ast_out_structs[..], + &ast_structs[..], + &ast_opaques[..], + &ast_enums[..], + ); + + let out_structs = + OutStructDef::lower_all(&ast_out_structs[..], &lookup_id, env, &mut errors); + let structs = StructDef::lower_all(&ast_structs[..], &lookup_id, env, &mut errors); + let opaques = OpaqueDef::lower_all(&ast_opaques[..], &lookup_id, env, &mut errors); + let enums = EnumDef::lower_all(&ast_enums[..], &lookup_id, env, &mut errors); + + match (out_structs, structs, opaques, enums) { + (Some(out_structs), Some(structs), Some(opaques), Some(enums)) => { + assert!( + errors.is_empty(), + "All lowering succeeded but still found error messages: {errors:?}" + ); + Ok(Self { + out_structs, + structs, + opaques, + enums, + }) + } + _ => { + assert!(!errors.is_empty(), "Lowering failed without error messages"); + Err(errors) + } + } + } +} + +/// Struct that just wraps the mapping from AST custom types to their IDs that +/// will show up in the final [`TypeContext`]. +/// +/// The entire point of this type is to reduce the number of arguments in helper +/// functions which need to look up IDs for structs. It does nothing fancy and +/// is only ever used when constructing a [`TypeContext`]. +pub(super) struct LookupId<'ast> { + out_struct_map: HashMap<&'ast ast::Struct, OutStructId>, + struct_map: HashMap<&'ast ast::Struct, StructId>, + opaque_map: HashMap<&'ast ast::OpaqueStruct, OpaqueId>, + enum_map: HashMap<&'ast ast::Enum, EnumId>, +} + +impl<'ast> LookupId<'ast> { + /// Returns a new [`LookupId`]. + fn new( + out_structs: &[(&ast::Path, &'ast ast::Struct)], + structs: &[(&ast::Path, &'ast ast::Struct)], + opaques: &[(&ast::Path, &'ast ast::OpaqueStruct)], + enums: &[(&ast::Path, &'ast ast::Enum)], + ) -> Self { + Self { + out_struct_map: out_structs + .iter() + .enumerate() + .map(|(index, (_, strct))| (*strct, OutStructId(index))) + .collect(), + struct_map: structs + .iter() + .enumerate() + .map(|(index, (_, strct))| (*strct, StructId(index))) + .collect(), + opaque_map: opaques + .iter() + .enumerate() + .map(|(index, (_, opaque))| (*opaque, OpaqueId(index))) + .collect(), + enum_map: enums + .iter() + .enumerate() + .map(|(index, (_, enm))| (*enm, EnumId(index))) + .collect(), + } + } + + pub(super) fn resolve_out_struct(&self, strct: &ast::Struct) -> Option { + self.out_struct_map.get(strct).copied() + } + + pub(super) fn resolve_struct(&self, strct: &ast::Struct) -> Option { + self.struct_map.get(strct).copied() + } + + pub(super) fn resolve_opaque(&self, opaque: &ast::OpaqueStruct) -> Option { + self.opaque_map.get(opaque).copied() + } + + pub(super) fn resolve_enum(&self, enm: &ast::Enum) -> Option { + self.enum_map.get(enm).copied() + } +} + +impl From for TypeId { + fn from(x: StructId) -> Self { + TypeId::Struct(x) + } +} + +impl From for TypeId { + fn from(x: OutStructId) -> Self { + TypeId::OutStruct(x) + } +} + +impl From for TypeId { + fn from(x: OpaqueId) -> Self { + TypeId::Opaque(x) + } +} + +impl From for TypeId { + fn from(x: EnumId) -> Self { + TypeId::Enum(x) + } +} diff --git a/third_party/rust/diplomat_core/src/hir/types.rs b/third_party/rust/diplomat_core/src/hir/types.rs new file mode 100644 index 000000000000..dd296b744488 --- /dev/null +++ b/third_party/rust/diplomat_core/src/hir/types.rs @@ -0,0 +1,99 @@ +//! Types that can be exposed in Diplomat APIs. + +use super::{ + EnumPath, Everywhere, MaybeStatic, NonOptional, OpaquePath, Optional, OutputOnly, + PrimitiveType, StructPath, TyPosition, TypeContext, TypeLifetime, +}; +use crate::ast; +pub use ast::Mutability; + +/// Type that can only be used as an output. +pub type OutType = Type; + +/// Type that may be used as input or output. +#[derive(Debug)] +pub enum Type { + Primitive(PrimitiveType), + Opaque(OpaquePath), + Struct(P::StructPath), + Enum(EnumPath), + Slice(Slice), +} + +/// Type that can appear in the `self` position. +#[derive(Debug, Clone)] +pub enum SelfType { + Opaque(OpaquePath), + Struct(StructPath), + Enum(EnumPath), +} + +#[derive(Copy, Clone, Debug)] +pub enum Slice { + /// A string slice, e.g. `&str`. + Str(MaybeStatic), + + /// A primitive slice, e.g. `&mut [u8]`. + Primitive(Borrow, PrimitiveType), +} + +// For now, the lifetime in not optional. This is because when you have references +// as fields of structs, the lifetime must always be present, and we want to uphold +// this invariant at the type level within the HIR. +// +// The only time when a lifetime is optional in Rust code is in function signatures, +// where implicit lifetimes are allowed. Getting this to all fit together will +// involve getting the implicit lifetime thing to be understood by Diplomat, but +// should be doable. +#[derive(Copy, Clone, Debug)] +pub struct Borrow { + pub lifetime: MaybeStatic, + pub mutability: Mutability, +} + +impl Type { + /// Return the number of fields and leaves that will show up in the [`LifetimeTree`] + /// returned by [`Param::lifetime_tree`] and [`ParamSelf::lifetime_tree`]. + /// + /// This method is used to calculate how much space to allocate upfront. + pub(super) fn field_leaf_lifetime_counts(&self, tcx: &TypeContext) -> (usize, usize) { + match self { + Type::Struct(ty) => ty.resolve(tcx).fields.iter().fold((1, 0), |acc, field| { + let inner = field.ty.field_leaf_lifetime_counts(tcx); + (acc.0 + inner.0, acc.1 + inner.1) + }), + Type::Opaque(_) | Type::Slice(_) => (1, 1), + Type::Primitive(_) | Type::Enum(_) => (0, 0), + } + } +} + +impl Slice { + /// Returns the [`TypeLifetime`] contained in either the `Str` or `Primitive` + /// variant. + pub fn lifetime(&self) -> &MaybeStatic { + match self { + Slice::Str(lifetime) => lifetime, + Slice::Primitive(reference, _) => &reference.lifetime, + } + } +} + +impl Borrow { + pub(super) fn new(lifetime: MaybeStatic, mutability: Mutability) -> Self { + Self { + lifetime, + mutability, + } + } +} + +impl From for Type { + fn from(s: SelfType) -> Type { + match s { + SelfType::Opaque(o) => Type::Opaque(o.wrap_optional()), + SelfType::Struct(s) => Type::Struct(s), + SelfType::Enum(e) => Type::Enum(e), + } + } +} diff --git a/third_party/rust/diplomat_core/src/lib.rs b/third_party/rust/diplomat_core/src/lib.rs new file mode 100644 index 000000000000..a5b2b17ad85b --- /dev/null +++ b/third_party/rust/diplomat_core/src/lib.rs @@ -0,0 +1,14 @@ +//! The Diplomat core module contains common logic between +//! the macro expansion and code generation. Right now, this +//! is primarily the AST types that Diplomat generates while +//! extracting APIs. + +#![allow(clippy::needless_lifetimes)] // we use named lifetimes for clarity + +pub mod ast; +#[cfg(feature = "hir")] +pub mod hir; + +mod environment; + +pub use environment::{Env, ModuleEnv}; diff --git a/third_party/rust/icu_capi/.cargo-checksum.json b/third_party/rust/icu_capi/.cargo-checksum.json new file mode 100644 index 000000000000..3b79cc1f6179 --- /dev/null +++ b/third_party/rust/icu_capi/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"a9f8c93e6f5fef683bed4df60ef8bb9b98997ac6af0a454ad6c2a207290a3587","LICENSE":"4ad7541d66a407234e2c84902124cef325c29f3e966353efdb800bedb8b8da21","README.md":"ff88c9913a6c75cc82bdfad4e6de23fbcac4be6cdbf5f9d4b326f20f85c927eb","c/README.md":"96cec260fc38a16a614e7ddf01258c0a60b1efe6f074cfbcd2c71c9d21cb9c4d","c/examples/fixeddecimal_tiny/README.md":"83d48bb81d46bc43dc7aa54b0d93b75c95df2555ea716e2f78de260492a06066","c/include/CodePointRangeIterator.h":"855f692f24f7a35c21d3f7f02bd7025c9e26836abf19f9eedb4c7acbebde7b0e","c/include/CodePointRangeIteratorResult.h":"24c9939e1dbb5475aaa463548eb9370dc8dda1d441b1fc7183aca4cb38e9c974","c/include/ICU4XAnyCalendarKind.h":"98fbcf1e114c8075bab271443108a0ff2eee01f4bba4bbcfe8222bdb5f616489","c/include/ICU4XBidi.h":"8a4579f8215964b3172f48844ea09b12e849dda996b071d1819641f00b4906e3","c/include/ICU4XBidiDirection.h":"89a59db1407f4dd10898bd7e51a145a7cfe0633b83eeec45f0032d973d6264b2","c/include/ICU4XBidiInfo.h":"0cc33c56c2d5404b83a09cd4a4707f9ed25945b49f6cfeb9c3aadfd2ee65cfd4","c/include/ICU4XBidiParagraph.h":"bd149a4f5554e9200bcfc66f048c9cc4027575417bd9d5669d3c630b9a8284e4","c/include/ICU4XCalendar.h":"5a9106afbda3c239f63514979d885ae452cdcae6cc6026d3f8490d69aacd521b","c/include/ICU4XCanonicalCombiningClassMap.h":"92c5129ef2a7e9994f66cb94b43abf94f335d2e2a37ad5fac2cd999b85ac5456","c/include/ICU4XCanonicalComposition.h":"635cfc855017d7dfab446a39e5d8d835fc46b79a629508790c3037476bd8d9ba","c/include/ICU4XCanonicalDecomposition.h":"1076939f1fe5b67d9798524b0d757b5b8bd291b112ff6f3f6365ad219a8e2f2b","c/include/ICU4XCodePointMapData16.h":"57bd7f80f4cf901d2b7048b0e91d6fb95c0c0d30845f53026794f5b0adbc198e","c/include/ICU4XCodePointMapData8.h":"6e9b20e9028cb628f93ed9a9b8e8890f32e4c6bb91c2d0dfe2b32f63a83b974a","c/include/ICU4XCodePointSetData.h":"7337436920bb0777892687a1f72249f6b1cd669a1a80d20a8096e5bdc590eb7e","c/include/ICU4XCollator.h":"8d4aa7b68d6266fd1b063381087d1a46571e4cb69316d931de13984a4be925d3","c/include/ICU4XCollatorAlternateHandling.h":"ebd0f6409caaf133b8168447a3697c957c820c2fdb3df20511f2f2204b00b4c9","c/include/ICU4XCollatorBackwardSecondLevel.h":"0e5e2eb6dc28eeb00474dc8fae31986760fbcbeb89a161137798b16a7fbd1321","c/include/ICU4XCollatorCaseFirst.h":"554673ede038c701bb1901dd445ca7053166ff4acb287d0e176f2eaee11ea1f6","c/include/ICU4XCollatorCaseLevel.h":"136d4e3bfd658b4eaff32265b44a1655f12d279389ac2b6751dcb2796cb9fd4e","c/include/ICU4XCollatorMaxVariable.h":"a92d7ace800d74f69ea143768aef1c077e82100d7793c5c4f0e269127ac8d06e","c/include/ICU4XCollatorNumeric.h":"47bf4863d1b84232c8eec2acc7fa8c15416a4ec5d0e271ae6937ca21662cbbf7","c/include/ICU4XCollatorOptionsV1.h":"e5a839b8690b7a2a5fddbfb897928c3c533c9bee8a172d64f99b9bfbfac54991","c/include/ICU4XCollatorStrength.h":"9c01f423c788b5b68391487d8e773eff3b409d0f4c91c08b750ec46a90a9fef9","c/include/ICU4XComposingNormalizer.h":"05f377de32c1a12a6460fba63033e23fbd418d737943f7452ff7b177ac433ad7","c/include/ICU4XCustomTimeZone.h":"6ac971546dc119416caab463a57688126649f599c6a95a54bf8ff7d6c87dd3bc","c/include/ICU4XDataProvider.h":"ce5c502cb1b0beeaac051c460fe212ca6f7ca10093f71cdce167d3b99e2f5d81","c/include/ICU4XDataStruct.h":"d9214515d58f8b3aadfbb1fb4f5ba030b2f00b9b250cf953e50e9ef4e4158437","c/include/ICU4XDate.h":"3a2974b05110af1eed01249a7a6c0c8b5f891adb16f05ff8253d6fd70be4c17f","c/include/ICU4XDateFormatter.h":"9b68b9c96457bb3a58fc41a992a815a216d9dc690ebc7e1123f283580cb3f569","c/include/ICU4XDateLength.h":"99a2dc6ff1a34a84800cda21dc69a81ccec348cda6082970eef8feeb9ea8c051","c/include/ICU4XDateTime.h":"3f04cc39abc5477b145a546488513fe2235f7dbab482f0aa09dc9c1904b7fbca","c/include/ICU4XDateTimeFormatter.h":"27b315cdd9213ddddef012c001d5d2956f9441ff3c078ab5bd438b02a6ffc4e7","c/include/ICU4XDecomposed.h":"005a75fcf7fbcca73b674740e6319509c62b70b1337423fd024e28735f6a5c78","c/include/ICU4XDecomposingNormalizer.h":"3ba38d2ab181d2d319a7efe7b03e78651d679621cd4cfd0e44e276617999fe24","c/include/ICU4XDisplayNamesFallback.h":"7d7f8b545fcad7c5dcb1ace2a30aac8014dbf4b4b2f256956e724cf94e6c2677","c/include/ICU4XDisplayNamesOptionsV1.h":"182689a09a7d7ee60704ab5ac7b62f774948c3fdd9b25e67c6e8ce3b46dec971","c/include/ICU4XDisplayNamesStyle.h":"1bc8b6c69691c237e802fb4379904fb5fcdd5abfb2bdc3e68b3ca0a205d1080a","c/include/ICU4XError.h":"03ebddcc05bbc59289120acad0229802d8f5d6afd6b1889c1415e625a193b9a9","c/include/ICU4XFixedDecimal.h":"e8faf4b7ced8c8d277c0dae8bfd3706d53d1231f329913731b969696fdafb5e9","c/include/ICU4XFixedDecimalFormatter.h":"1271f7f8bf20feec7e5861d6a985339c5bf6da4e81f1099c799546c54e09a94f","c/include/ICU4XFixedDecimalGroupingStrategy.h":"6a3bfa97e9d53d02730909a0a23d468663e0466fb13312b02da3625eb4ac6980","c/include/ICU4XFixedDecimalSign.h":"5bdc531f7961d47cc8130427a80c3e40b6bd11678fecf71f779ec217a70ad3be","c/include/ICU4XFixedDecimalSignDisplay.h":"412d93364396b0d1e987d6f997871084163103360bb0a474d2ea8889b9a51db3","c/include/ICU4XGeneralCategoryNameToMaskMapper.h":"53ce5570633c42454da873f08e7de33ccee0e7e120adcc682b2d9ffeac65046d","c/include/ICU4XGraphemeClusterBreakIteratorLatin1.h":"e516f5f3e7916a2a2f101b4790e0fad5c2d0d3f534b512016e260e7bc1a96828","c/include/ICU4XGraphemeClusterBreakIteratorUtf16.h":"8318a9183ebe63cb91f63535b658a035e08724464efc5523643f54f9eb3c33cf","c/include/ICU4XGraphemeClusterBreakIteratorUtf8.h":"62bde7543b4505cb7ca78fb3586770945a368a17ddb6f759679537864590d4a3","c/include/ICU4XGraphemeClusterSegmenter.h":"623fe0deb02155a66363a301eabdd71d0e8565c991e43c0a0b269345dfc4edd5","c/include/ICU4XGregorianDateFormatter.h":"b16d94873ab46783e3ca040ae1f3335c008caa7eb83267ddd2decfb11de8173b","c/include/ICU4XGregorianDateTimeFormatter.h":"895afb0c42900402535b73d7a92c348000e24ade6b333e6a8d0c99f46a3c306f","c/include/ICU4XGregorianZonedDateTimeFormatter.h":"a8d6fac5c2514ca88334bd273ad96160c74582aa416f9c7e13a7969425cd0d95","c/include/ICU4XIsoDate.h":"199c271f59c6d0f6cd199466ba96b8a954b1a8a83a696fa180ab2f3ad085b405","c/include/ICU4XIsoDateTime.h":"cf93f6ec4ba94142c471e453ac78f63620d71a6eb971a674c015572765208e7b","c/include/ICU4XIsoTimeZoneFormat.h":"7f99a45d84ab1292fe3ef50b0030b27442cec24172afb04674f6dd861cfa410b","c/include/ICU4XIsoTimeZoneMinuteDisplay.h":"e8acbc9cc0d191e38e271b5d4da97688047937aadc98dc241a4e66839d7c1315","c/include/ICU4XIsoTimeZoneOptions.h":"a23d3a3aea566b9e0bb28945a7da11862e59462c37aae925a8b06f6b3c53e181","c/include/ICU4XIsoTimeZoneSecondDisplay.h":"f1e23eac627f2bd85a59db7b700a374714119b855e5adcdfa27ca3ef19c02d0d","c/include/ICU4XIsoWeekday.h":"a145439e1c3918a4e7ff0b03b39c2c8b1a2c7e035b4a9eb44b15f62c2b5b084d","c/include/ICU4XLanguageDisplay.h":"53090fe4bd1ec74367afbc9fb7580203690ce53ca99f58905da365693c446951","c/include/ICU4XLineBreakIteratorLatin1.h":"bb1851ad2560aaa88c819b06542693186ba991dc8a5fc26936781e00ed215fa6","c/include/ICU4XLineBreakIteratorUtf16.h":"61d5f40b5ddfed50a4414dafeb75aab49384309375a5bb8c1db21987eb95ffa6","c/include/ICU4XLineBreakIteratorUtf8.h":"453e6711f0345128bb982838ed40bd67a141265a21b0cd2218310d8bc93dd014","c/include/ICU4XLineBreakOptionsV1.h":"230517bf5ccee15032ec091dc18074ca4714242a7ffd81983ab3d872d0e46245","c/include/ICU4XLineBreakStrictness.h":"0906420e594bc72ff88957b4b9f85966cd5d72a99bea8b9f29c593d0d421ebb6","c/include/ICU4XLineBreakWordOption.h":"812e0beb839fc77869f0e82144d5f28323f74e54217aa2a684e026d54cb3bcf6","c/include/ICU4XLineSegmenter.h":"1b8b32fbca641d11d7c29180fd37882ae84e6019574d88d5726f27d8d732ca46","c/include/ICU4XList.h":"61aa297726f8320e2db5dc82fbcaf9655606e69c1b576c4609ed7cc00a4761fe","c/include/ICU4XListFormatter.h":"e7a4c0960e21dd7c927f2446e68f899f6fa1ffbd3fb62f16275e3549b3b7df95","c/include/ICU4XListLength.h":"d5614e3beeb177aa994be08e2d2aedb60eb70029d85bf3a6c6e146fcd81585da","c/include/ICU4XLocale.h":"4c8a4eee422925ea9a5b358ea2d2e0ceafb3bc7506a3e08bfc0abe6c583d28b1","c/include/ICU4XLocaleCanonicalizer.h":"729fc0b406f32508ca271f342e8e0a04d5a9ad236b9cf29afe8ef3dc0e55956d","c/include/ICU4XLocaleDisplayNamesFormatter.h":"6b2627ea0c51382fa9c17986d419fced926af9765ccc4a50cbee186a18bb4e8c","c/include/ICU4XLocaleExpander.h":"acc58a303fc99ff1aee637985887b2694bf3744963f19fad790af7cd3d1d4b5b","c/include/ICU4XLocaleFallbackConfig.h":"fb5037e7dcff96d6fddbcfe82ed86792865623e3ee83a27a7f57b282b317a49b","c/include/ICU4XLocaleFallbackIterator.h":"6509d75408b7a6d430f4caa3468148d0a06c4ff4490728205692db5d9c2e556e","c/include/ICU4XLocaleFallbackPriority.h":"aa69b2108b5fefcd0325b7263f1db8473b17ab8d5fad74e641eb8ee2bfd4b54c","c/include/ICU4XLocaleFallbacker.h":"965da30fd0e5280c086a104fccd117a63450f30efa49b9198037cd95d6b22bcd","c/include/ICU4XLocaleFallbackerWithConfig.h":"8144d2a7fbd88ce8e0dfca4522d4a00e0850332f53b3b47751687a2ed772749f","c/include/ICU4XLogger.h":"9a5442ab6151781529d6168d452ff12b2a82f1ce60905d7cf1b165a22c1b8b87","c/include/ICU4XMetazoneCalculator.h":"f67642f2699df48e660034834c60620efddf28b5313daf6a4caeb49231e72600","c/include/ICU4XOrdering.h":"2623e442030eeaad06e60a85813fd38690f934a615cf7d1d34dc7ce3f687c737","c/include/ICU4XPluralCategories.h":"4b976338eb417be4d785654d9edcd7f6557e5ce8426e03b37d8a59349eba2aa5","c/include/ICU4XPluralCategory.h":"7f5e82bd8a601c3fd69c9a8ef462e01fedd26a3713a227b9daddc4360e49b0e8","c/include/ICU4XPluralOperands.h":"c67fb8047061802a466f0655d9613e88c24c5773865f905e9784b66ef61b5e28","c/include/ICU4XPluralRules.h":"bb6d62895a2824ae2c566a1bb9c3d866b2f4e4fa2186be4043d209f5944743b6","c/include/ICU4XPropertyValueNameToEnumMapper.h":"fe2ecc1e6816bd71738a82744957fd27fd6d8b91229a5c641c544172cc822996","c/include/ICU4XRegionDisplayNames.h":"fece0a7fe6227f47132200bfcd37ebb90fb5cfde2af4e2385f01aba2713c4cca","c/include/ICU4XReorderedIndexMap.h":"ba81910d14a97545a2d2514a6fa7c003585a52a51fb08edc54d8d2b2df08c741","c/include/ICU4XScriptExtensionsSet.h":"8d170c1ac68202b6714f8a181d9a2026a34d1ba2947d3c75c0d0fb3d4b531fb2","c/include/ICU4XScriptWithExtensions.h":"58f24862866b02a818ccb8869802364d89799cf65359ad92ba9a8796ba5c82fc","c/include/ICU4XScriptWithExtensionsBorrowed.h":"56995aeb93fbda6b12a7222effb465a31a9d2e0d64a9d45207fc7b43156f9b87","c/include/ICU4XSegmenterWordType.h":"c56bb9194ad922268b5ce5acb9793f18d61afc0d80cc20ed10ef255117091eba","c/include/ICU4XSentenceBreakIteratorLatin1.h":"76e4c306ea7e28d5df48e9a0e66a0fa21b62e43d1716cd515aaf190dbd01fc70","c/include/ICU4XSentenceBreakIteratorUtf16.h":"90286cc87e2ce166dda09ec8ecaf69403432a2fb0d31c86f425fffbfe15f5814","c/include/ICU4XSentenceBreakIteratorUtf8.h":"4d28f1f34829adbdf398cc08628966086de864d3147a0476693860d682398bd1","c/include/ICU4XSentenceSegmenter.h":"087908c9867c63e7ad934a7db4c0ae260dcc87f3f6ab950ff5a608c733a368a8","c/include/ICU4XTime.h":"0195a178069eb12e4b86853ca41fba24b115a24358f5320631f2bee0410f349e","c/include/ICU4XTimeFormatter.h":"a0f7ab82243fcd1d930e1af7673a982c8403fdfea4cef8fa219b693908b58c44","c/include/ICU4XTimeLength.h":"e1e9d2cde0a36b43d8caef5291e3fc3d41d72ed798eeeb599ab734768df68105","c/include/ICU4XTimeZoneFormatter.h":"f3ffe8f4b44d144c150318b93f020437b7fb83ec7ef9bcac33b03e2e71e2daf1","c/include/ICU4XTransformResult.h":"dbf8cde4f204381c530e60c387ea01eb6a73b3d67a963dea32a9875f027c5f2a","c/include/ICU4XUnicodeSetData.h":"3aedbed12b9ce6a746d1f9b85cbb663db9587bb71238653a616521d2b1fda2ba","c/include/ICU4XWeekCalculator.h":"7560f941ad512bf045f67f3674c8a3756eed62616dbda956570f2eb8ed70baa7","c/include/ICU4XWeekOf.h":"ef291c354d39c66adf434f31fcf1d9b0d7a03c37fc8a8097f398c39372f05aea","c/include/ICU4XWeekRelativeUnit.h":"a1e54b138571b2aa6e20ba938e69c39555719154b9fa74ebb7f03c09a4b3828e","c/include/ICU4XWordBreakIteratorLatin1.h":"3c3e35b91880e86849ece754d4d4fea2b17e90b8ebad4168ba6e570129caf52d","c/include/ICU4XWordBreakIteratorUtf16.h":"76c18f9020d59df7618ec62dcd0ed949773c4bb174054edd7221e3ae4af55d0d","c/include/ICU4XWordBreakIteratorUtf8.h":"bbc05ad9673c69f806be7f161ab0624242b5d0ba01e8e647eb722090b7e0e889","c/include/ICU4XWordSegmenter.h":"48969a7681b120bd12deb3810c0bec4e278cf73241c6c622a1ba62360e4c78c7","c/include/ICU4XZonedDateTimeFormatter.h":"8729fb75529af74d089f4ba464d2db17cb01dd8e4905aef018340d2d6e5b5cf4","c/include/diplomat_result_ICU4XAnyCalendarKind_void.h":"b7554e62e43d2829413955894fc2cf46f6fdd2f08cc22602267fd8720e28acf4","c/include/diplomat_result_ICU4XPluralCategory_void.h":"be4f24d6a8448c7358cb7929c1fe95d0c81bdab4d6c2f9597fb31318c6ac178a","c/include/diplomat_result_ICU4XWeekOf_ICU4XError.h":"6da99185bd3b0007580e8ca95475ac6a03ab108c1e4859abb9c6fa4f4268f189","c/include/diplomat_result_bool_ICU4XError.h":"d89d4b9ff8dbda4b70ea59b1735eb6fed987446d854c4ec5825ca3a96139c769","c/include/diplomat_result_box_ICU4XBidi_ICU4XError.h":"3d5e49b5efdb3fe613a90b25f242faffe361c2406c6bdfe9aa7f7374303e389f","c/include/diplomat_result_box_ICU4XCalendar_ICU4XError.h":"b1093f46d43172b0367a5c0e2888c51d75cf09e9b74a6d4ac9f8494659cc23f0","c/include/diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError.h":"044822a551a4621aaecf0973ec8c247ee08e6b1558985baea7b593554661461b","c/include/diplomat_result_box_ICU4XCanonicalComposition_ICU4XError.h":"2fe231fed603754eb654ccd0cf1514755bf4575762b7ea55a9fa1cdaa8a0ef97","c/include/diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError.h":"6fff2f082e8d041fe9b8d222bad577ab340793de1f532d1ca94deaf67a1a7f79","c/include/diplomat_result_box_ICU4XCodePointMapData16_ICU4XError.h":"f4128b4152ff66339f054902c1e053898d412dccce46e4f2b8bd391da13ea8a5","c/include/diplomat_result_box_ICU4XCodePointMapData8_ICU4XError.h":"8ba3f332ab68f208844590b58983c11e198bf31b3e40a96db3cad00ef2fccfc4","c/include/diplomat_result_box_ICU4XCodePointSetData_ICU4XError.h":"f3022441f2cc26e69cfcdb1e479207def3d3995e12a93671adc4d5b2c4c00bd7","c/include/diplomat_result_box_ICU4XCollator_ICU4XError.h":"f98f23497388805eef199cd493921353c8198032a7f1602ba21a8e5b9aeb50ca","c/include/diplomat_result_box_ICU4XComposingNormalizer_ICU4XError.h":"207bf6e3194f0c26209f1d399c94dfc7002d09498fa3b683a63221e54376b2af","c/include/diplomat_result_box_ICU4XCustomTimeZone_ICU4XError.h":"e3bd5c643d87a96cc2e22c54763743fc034831166cfe4e0996e19987679ec97d","c/include/diplomat_result_box_ICU4XDataProvider_ICU4XError.h":"e55c3014a4f7e3c65b4749a881dc613e8931a96ba8e9772afd64b29fbcd222ef","c/include/diplomat_result_box_ICU4XDataStruct_ICU4XError.h":"122a632de08b8ed4a13c678b97adb0ca2d93682a4ae23d6ee530e2d1c0cd6a40","c/include/diplomat_result_box_ICU4XDateFormatter_ICU4XError.h":"c99bc3e292e71a5afa819fbfbb657c61776235a2372557a4f3c2f2611ef0bfdc","c/include/diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError.h":"72831cc9f547c1da597eb8e26844627102754a767f17d48da05b67b3aed6da4d","c/include/diplomat_result_box_ICU4XDateTime_ICU4XError.h":"64c9f51cc38897871f44ff3bbfccdc09cb2219aa73129624df907c64bfc0b246","c/include/diplomat_result_box_ICU4XDate_ICU4XError.h":"e63883c8bdca729b9b54540afe8c520363230eb85d51922a289427f8d2989e6e","c/include/diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError.h":"cdc24b34a7b3220f74fe7ba159404945be2ace03f5204ae4e5359da4e22eba42","c/include/diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError.h":"c24bbe0cf8763492dc660bd7e439c2e40f0b3fa5311e73237174c43462023580","c/include/diplomat_result_box_ICU4XFixedDecimal_ICU4XError.h":"0706eeb65200fd9475b3da7f46d57f43bc115851670a17658f277d8cca39519d","c/include/diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError.h":"314a668723cd9b6d9939b1b1a5008e764ee8f31c2f755b4383888581339f7705","c/include/diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError.h":"e31c88dcaf07b2dec8b9a1ac90de644cb3c88d26bcd5342fa9e5e3d4b66fe909","c/include/diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError.h":"9e20178cfe4a63a5e5af84c468c6cec4b3d88cc8ec8f8aa8a7aae5b0cc6a3cc3","c/include/diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError.h":"4a30e2b94172ae78bb10626f6edee04cdfbb18fefcb584831a5f2afc21061c2c","c/include/diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError.h":"f5cf70a90def9156d8e2a711a1d766c1b74aa30574adf321bfa98e52a3a508f8","c/include/diplomat_result_box_ICU4XIsoDateTime_ICU4XError.h":"b536e34f20ce877f7b7cc096742d4ced3a111da455be857f762332f4bb88b8a6","c/include/diplomat_result_box_ICU4XIsoDate_ICU4XError.h":"d82cb4aa37b6aa3bca008aef27e4cc5a443a6393d4557fc8e4d3cf1f7d27374f","c/include/diplomat_result_box_ICU4XLineSegmenter_ICU4XError.h":"1c268f748fb0fabc4bee3bf2dff6be1397455d701aec641cca49147223ae0d1f","c/include/diplomat_result_box_ICU4XListFormatter_ICU4XError.h":"43cbd479e2b6dec150cc040f27e8322509e6dd33f87dbd0be970b478520fc3dd","c/include/diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError.h":"37da5709ea21bcdebba934627a24f696a716509d1fa743336385cda259ae165b","c/include/diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError.h":"0dc0a8de105ed8b047d875a88e21d53a23fda879893e85b523e77fe3b91b576c","c/include/diplomat_result_box_ICU4XLocaleExpander_ICU4XError.h":"818396c7da0fa28981abc5486906eefe8fca44f45d1455e32525a1c4870c9850","c/include/diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError.h":"03c9c7a6182bbbd5abf697e2900fb5f1bf35479359e2b9a6318e883e9c3a9f2f","c/include/diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError.h":"76bc810c1f5cdce04bbced497a83ed18597864784cfcd1918470bcf16d7ee72f","c/include/diplomat_result_box_ICU4XLocale_ICU4XError.h":"325af7add47038ba4997fccec85f8c17ab746d75452873b57b9e49fe3fb926aa","c/include/diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError.h":"11366824711543693cfc29e85ef6506dcf1b126d6479f7cf4516e1b08309cfcf","c/include/diplomat_result_box_ICU4XPluralOperands_ICU4XError.h":"37b5b35f3ee46ca40ef6081e78cfcc827c40ece420c56fa9f1ef3caace0ddfd1","c/include/diplomat_result_box_ICU4XPluralRules_ICU4XError.h":"00ffa08f94e61e0df7ed1471f5a5f539eb167492b19e2d9bd6bd3fb7bf7c6090","c/include/diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError.h":"27375665f96cb573a703464e5213ebc1c9dee48dcac2ca362409445d28314b3e","c/include/diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError.h":"a79303283606d3d9f0bfe8b8957ddc7e251f1ea8d71a0c2e023622543d0cc98f","c/include/diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError.h":"9d2032bcad19a83584795296de438ea680c7b9452315034b9f3dc83406926d58","c/include/diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError.h":"64f17863f06568a2a2493ec5c43eff09a6800898cdc1b0ee7927fc17e29055ce","c/include/diplomat_result_box_ICU4XTimeFormatter_ICU4XError.h":"c3428ab6414190e537638497972f666fcde75a09882d6233e94f2348213c59a8","c/include/diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError.h":"8d93dbf810a3a6d8bde00608df728387a7fc92e3d59b66de8fc44f7383dc172e","c/include/diplomat_result_box_ICU4XTime_ICU4XError.h":"fd59b48cbeeea9f6c00ba4efd8003cef962603398371e4489ed3bf0696727757","c/include/diplomat_result_box_ICU4XUnicodeSetData_ICU4XError.h":"7a75ff83facb7287597af360b9ff4c1fe7a71b750d40c9146a94c780481ae84a","c/include/diplomat_result_box_ICU4XWeekCalculator_ICU4XError.h":"92d217965ad6296835a9d69458d9f5fa6e9ca55114d64dcaf8dc4a7512df2c09","c/include/diplomat_result_box_ICU4XWordSegmenter_ICU4XError.h":"6662198d1464c95468270aec56563f0bcc17e75babd4316ff60b8587ce9766be","c/include/diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError.h":"cb5a1ba7eeb206886266c2aa172486073084f8d9d271a52136205185f6376ac7","c/include/diplomat_result_int32_t_ICU4XError.h":"c9f9241d50cdffaebb1135ee78efe6bfa212743f71d59b0715ed0a79b05332ea","c/include/diplomat_result_uint16_t_void.h":"ad0d09f20115172cea2f459beb97a7df28a89708bb5a3a5372523d6eec42e37e","c/include/diplomat_result_void_ICU4XError.h":"bd03f10ee6b79c9498c2586ee94eef1f89d499cddb25d77b774ef066250bc632","c/include/diplomat_result_void_void.h":"f5f36a86bbf084e3eb2bf2a616efff7f612a208c2e747d5452b32d609eb450e0","c/include/diplomat_runtime.h":"1cea1a3675774fcb4253a58affeb7fad8e771af0b1077051b87bcc4b13ae309d","cpp/README.md":"f8becb1c485a7cdd870adc583f56e0511f642d884a330792eb15eb5939b60ef6","cpp/include/CodePointRangeIterator.h":"855f692f24f7a35c21d3f7f02bd7025c9e26836abf19f9eedb4c7acbebde7b0e","cpp/include/CodePointRangeIterator.hpp":"aeefc02597eca61d27e2848b78358b30c5ffcf462b1794976f255c0905282ca2","cpp/include/CodePointRangeIteratorResult.h":"24c9939e1dbb5475aaa463548eb9370dc8dda1d441b1fc7183aca4cb38e9c974","cpp/include/CodePointRangeIteratorResult.hpp":"948860d7de655ee92e5a15620437b2cb404b78a269308342d66badf83dd789ed","cpp/include/ICU4XAnyCalendarKind.h":"98fbcf1e114c8075bab271443108a0ff2eee01f4bba4bbcfe8222bdb5f616489","cpp/include/ICU4XAnyCalendarKind.hpp":"0345cab3b8c52e11773628104c4ed4ec581ca28e696f6de4a24ee27eb6030ace","cpp/include/ICU4XBidi.h":"8a4579f8215964b3172f48844ea09b12e849dda996b071d1819641f00b4906e3","cpp/include/ICU4XBidi.hpp":"990b63ef759c67ef7707e59ab14a9112cf0f8b41da5225388edebbe24dfe0255","cpp/include/ICU4XBidiDirection.h":"89a59db1407f4dd10898bd7e51a145a7cfe0633b83eeec45f0032d973d6264b2","cpp/include/ICU4XBidiDirection.hpp":"a2798336baad4eeefeb6d2178a5ed7bd83a0dba7e56d7bddab2b4ea373ceee9f","cpp/include/ICU4XBidiInfo.h":"0cc33c56c2d5404b83a09cd4a4707f9ed25945b49f6cfeb9c3aadfd2ee65cfd4","cpp/include/ICU4XBidiInfo.hpp":"d78a1aaaa4c8464672fb23eac1e6877117fed69ebfd45de57296f44178ed282c","cpp/include/ICU4XBidiParagraph.h":"bd149a4f5554e9200bcfc66f048c9cc4027575417bd9d5669d3c630b9a8284e4","cpp/include/ICU4XBidiParagraph.hpp":"d1b752526306b423c2f3a72ffb04a0c91a9a752c3f7c859ddb87ca3adcf247f8","cpp/include/ICU4XCalendar.h":"5a9106afbda3c239f63514979d885ae452cdcae6cc6026d3f8490d69aacd521b","cpp/include/ICU4XCalendar.hpp":"f58723713febe0ced0b8fb03e5242d03f5f92198a9bb49fed3390e4ddd94e9e0","cpp/include/ICU4XCanonicalCombiningClassMap.h":"92c5129ef2a7e9994f66cb94b43abf94f335d2e2a37ad5fac2cd999b85ac5456","cpp/include/ICU4XCanonicalCombiningClassMap.hpp":"498135391687de192cef4dc2f1315b7b0341d7e411e6f66acd9513ca559a7adf","cpp/include/ICU4XCanonicalComposition.h":"635cfc855017d7dfab446a39e5d8d835fc46b79a629508790c3037476bd8d9ba","cpp/include/ICU4XCanonicalComposition.hpp":"68a488f80a379f31c268a3c126f9a58412c1a8a8e0817d62cdb925d0e8610454","cpp/include/ICU4XCanonicalDecomposition.h":"1076939f1fe5b67d9798524b0d757b5b8bd291b112ff6f3f6365ad219a8e2f2b","cpp/include/ICU4XCanonicalDecomposition.hpp":"e6136c027a4c4c81e2a878a85f5f764dd75dc4a3778f9268207eced128c2ebd5","cpp/include/ICU4XCodePointMapData16.h":"57bd7f80f4cf901d2b7048b0e91d6fb95c0c0d30845f53026794f5b0adbc198e","cpp/include/ICU4XCodePointMapData16.hpp":"854e3278a354955feb4017906923c0b0d7ba19af05a77b63261b6de0398eb6de","cpp/include/ICU4XCodePointMapData8.h":"6e9b20e9028cb628f93ed9a9b8e8890f32e4c6bb91c2d0dfe2b32f63a83b974a","cpp/include/ICU4XCodePointMapData8.hpp":"42c0e3520591a0ecd16b34d3bd9cc585086112b3f31e2251ebd6590f0d508f52","cpp/include/ICU4XCodePointSetData.h":"7337436920bb0777892687a1f72249f6b1cd669a1a80d20a8096e5bdc590eb7e","cpp/include/ICU4XCodePointSetData.hpp":"3008e1d1522e7038ca00ab5e352bd48c466d8152294260df02d6eaf194f98aa7","cpp/include/ICU4XCollator.h":"8d4aa7b68d6266fd1b063381087d1a46571e4cb69316d931de13984a4be925d3","cpp/include/ICU4XCollator.hpp":"9373eab5286a3fe523bce8033f5a66dffaf5831fa118011d8253a8aa3d2fc8ed","cpp/include/ICU4XCollatorAlternateHandling.h":"ebd0f6409caaf133b8168447a3697c957c820c2fdb3df20511f2f2204b00b4c9","cpp/include/ICU4XCollatorAlternateHandling.hpp":"f324793e4acf74b5f18ce33bd8a736b1f2edd2cc0296ce9745df70fe4d640870","cpp/include/ICU4XCollatorBackwardSecondLevel.h":"0e5e2eb6dc28eeb00474dc8fae31986760fbcbeb89a161137798b16a7fbd1321","cpp/include/ICU4XCollatorBackwardSecondLevel.hpp":"7e4601fa0c633cbcefa66619d28f0a7b11300e095fe8c3d77f83a80a906fc70b","cpp/include/ICU4XCollatorCaseFirst.h":"554673ede038c701bb1901dd445ca7053166ff4acb287d0e176f2eaee11ea1f6","cpp/include/ICU4XCollatorCaseFirst.hpp":"ba808e98d766b2c5540759930362bd5a9439e1816183f20589c9d067d836191e","cpp/include/ICU4XCollatorCaseLevel.h":"136d4e3bfd658b4eaff32265b44a1655f12d279389ac2b6751dcb2796cb9fd4e","cpp/include/ICU4XCollatorCaseLevel.hpp":"3aa95154f2474b8727466041821861639583068808ff0d6a8f9fd29f21b42414","cpp/include/ICU4XCollatorMaxVariable.h":"a92d7ace800d74f69ea143768aef1c077e82100d7793c5c4f0e269127ac8d06e","cpp/include/ICU4XCollatorMaxVariable.hpp":"23ac90567b9781ad7c3cc241484ffe3f59107d213a390f1a3808e1449b583035","cpp/include/ICU4XCollatorNumeric.h":"47bf4863d1b84232c8eec2acc7fa8c15416a4ec5d0e271ae6937ca21662cbbf7","cpp/include/ICU4XCollatorNumeric.hpp":"2d81a2a423ccfc431fea2bf8d9c9f313f29609c3bb154a77d6a1433e3e6e05c3","cpp/include/ICU4XCollatorOptionsV1.h":"e5a839b8690b7a2a5fddbfb897928c3c533c9bee8a172d64f99b9bfbfac54991","cpp/include/ICU4XCollatorOptionsV1.hpp":"5e10e9d2d460e83028d53506ac5bab2febc1744df911e92537ceda0cba7600fe","cpp/include/ICU4XCollatorStrength.h":"9c01f423c788b5b68391487d8e773eff3b409d0f4c91c08b750ec46a90a9fef9","cpp/include/ICU4XCollatorStrength.hpp":"aaf8eca64c73a4096be030c35807bf4d4c8788ba97ac3b4edcc6e85bc1cc3bc4","cpp/include/ICU4XComposingNormalizer.h":"05f377de32c1a12a6460fba63033e23fbd418d737943f7452ff7b177ac433ad7","cpp/include/ICU4XComposingNormalizer.hpp":"db57d5257c91b1c2fd3cc2d95af8ece87abae793db55f238c45e1c71eeed1647","cpp/include/ICU4XCustomTimeZone.h":"6ac971546dc119416caab463a57688126649f599c6a95a54bf8ff7d6c87dd3bc","cpp/include/ICU4XCustomTimeZone.hpp":"e8557cd0ebdd153cbfbcaa2fab9fef29766ad0684d537250f8f2e163ae1224e4","cpp/include/ICU4XDataProvider.h":"ce5c502cb1b0beeaac051c460fe212ca6f7ca10093f71cdce167d3b99e2f5d81","cpp/include/ICU4XDataProvider.hpp":"f15437414f2d41da572093acdace04f2cb9a4f8315ad0beb75c536b880439fa4","cpp/include/ICU4XDataStruct.h":"d9214515d58f8b3aadfbb1fb4f5ba030b2f00b9b250cf953e50e9ef4e4158437","cpp/include/ICU4XDataStruct.hpp":"590c53801274d961125d278954894e2ab78a95d87fac960d5516f6218f5c0c18","cpp/include/ICU4XDate.h":"3a2974b05110af1eed01249a7a6c0c8b5f891adb16f05ff8253d6fd70be4c17f","cpp/include/ICU4XDate.hpp":"b065fb015d2614e8eacc5335a7f2d6c93fa37440d7c8eafb18d95539a2f10e8c","cpp/include/ICU4XDateFormatter.h":"9b68b9c96457bb3a58fc41a992a815a216d9dc690ebc7e1123f283580cb3f569","cpp/include/ICU4XDateFormatter.hpp":"1b380267c6d71a96414b4bbd02f022ce3a8dd457a92b39f67611c24f98cec919","cpp/include/ICU4XDateLength.h":"99a2dc6ff1a34a84800cda21dc69a81ccec348cda6082970eef8feeb9ea8c051","cpp/include/ICU4XDateLength.hpp":"618b6d1c185d5ddb6b73d6201478ee5286ed33726f858b2528749f061e9a9769","cpp/include/ICU4XDateTime.h":"3f04cc39abc5477b145a546488513fe2235f7dbab482f0aa09dc9c1904b7fbca","cpp/include/ICU4XDateTime.hpp":"d39a2c8830bd1c91bdae10cf4b9ef60e5cce270396e6a949b228ab8b79a148b5","cpp/include/ICU4XDateTimeFormatter.h":"27b315cdd9213ddddef012c001d5d2956f9441ff3c078ab5bd438b02a6ffc4e7","cpp/include/ICU4XDateTimeFormatter.hpp":"23260d8476029a82d98d07bf0b0c19066f2d335a5147a30988e713209e516860","cpp/include/ICU4XDecomposed.h":"005a75fcf7fbcca73b674740e6319509c62b70b1337423fd024e28735f6a5c78","cpp/include/ICU4XDecomposed.hpp":"4ec09d0a6fc60412a3f2ea5d11c1f5e46914625db332d0221ef8a7d9488460d2","cpp/include/ICU4XDecomposingNormalizer.h":"3ba38d2ab181d2d319a7efe7b03e78651d679621cd4cfd0e44e276617999fe24","cpp/include/ICU4XDecomposingNormalizer.hpp":"c6bcfda10c5e9f22c3cb4900bd1d5d19a266178bfcf14ec1a04ad18a883fef54","cpp/include/ICU4XDisplayNamesFallback.h":"7d7f8b545fcad7c5dcb1ace2a30aac8014dbf4b4b2f256956e724cf94e6c2677","cpp/include/ICU4XDisplayNamesFallback.hpp":"8eb30a0572cd9c6ec2cdbf882ca63db31e78939bb74f06d240adc2a1463caa29","cpp/include/ICU4XDisplayNamesOptionsV1.h":"182689a09a7d7ee60704ab5ac7b62f774948c3fdd9b25e67c6e8ce3b46dec971","cpp/include/ICU4XDisplayNamesOptionsV1.hpp":"a2ab21d2b5d47fe1f29a5404bdf4ebacfecd66df113c1dd65558986ccae1a54a","cpp/include/ICU4XDisplayNamesStyle.h":"1bc8b6c69691c237e802fb4379904fb5fcdd5abfb2bdc3e68b3ca0a205d1080a","cpp/include/ICU4XDisplayNamesStyle.hpp":"465d0c920fbca53761685191215f8bc42059dd80771fc186c70a2f5cb3a737c4","cpp/include/ICU4XError.h":"03ebddcc05bbc59289120acad0229802d8f5d6afd6b1889c1415e625a193b9a9","cpp/include/ICU4XError.hpp":"55adbf441f229d098141e10fa63c23d0fdb9fdb767b2d343ea527ccf6e499194","cpp/include/ICU4XFixedDecimal.h":"e8faf4b7ced8c8d277c0dae8bfd3706d53d1231f329913731b969696fdafb5e9","cpp/include/ICU4XFixedDecimal.hpp":"cae1765dd2ae3e7d1f680410ad39e13c3fb13716a349b958b25db06eb5104313","cpp/include/ICU4XFixedDecimalFormatter.h":"1271f7f8bf20feec7e5861d6a985339c5bf6da4e81f1099c799546c54e09a94f","cpp/include/ICU4XFixedDecimalFormatter.hpp":"af3e74f7e320ead985327b314ca47518dfcba303b5c20ecdb839d0b7885f8bf7","cpp/include/ICU4XFixedDecimalGroupingStrategy.h":"6a3bfa97e9d53d02730909a0a23d468663e0466fb13312b02da3625eb4ac6980","cpp/include/ICU4XFixedDecimalGroupingStrategy.hpp":"b8fbb86fc7c18f45043907b527d1e996e8cee5d342bf250193f7127c942c5168","cpp/include/ICU4XFixedDecimalSign.h":"5bdc531f7961d47cc8130427a80c3e40b6bd11678fecf71f779ec217a70ad3be","cpp/include/ICU4XFixedDecimalSign.hpp":"fcc18aaa54f457ca9e724e56ada12f7e4ed85391016aaa8bae5e73f5217b06b4","cpp/include/ICU4XFixedDecimalSignDisplay.h":"412d93364396b0d1e987d6f997871084163103360bb0a474d2ea8889b9a51db3","cpp/include/ICU4XFixedDecimalSignDisplay.hpp":"873f72122de0c261096272963a2f985773a2431a4dd887a80a777c4e1f9c148f","cpp/include/ICU4XGeneralCategoryNameToMaskMapper.h":"53ce5570633c42454da873f08e7de33ccee0e7e120adcc682b2d9ffeac65046d","cpp/include/ICU4XGeneralCategoryNameToMaskMapper.hpp":"48da40a7e007d0f272fb83bfedaa3f9a6cff0446e94690aed1af43b78b719137","cpp/include/ICU4XGraphemeClusterBreakIteratorLatin1.h":"e516f5f3e7916a2a2f101b4790e0fad5c2d0d3f534b512016e260e7bc1a96828","cpp/include/ICU4XGraphemeClusterBreakIteratorLatin1.hpp":"7bb4b698563e4b6bf591609ae2ea03c49ce13cfe79f9550ff70717bdf24a6be9","cpp/include/ICU4XGraphemeClusterBreakIteratorUtf16.h":"8318a9183ebe63cb91f63535b658a035e08724464efc5523643f54f9eb3c33cf","cpp/include/ICU4XGraphemeClusterBreakIteratorUtf16.hpp":"04ea34383760a33a46c3bada8832bca788f056b0ec3fa80e3b14500fb80444b6","cpp/include/ICU4XGraphemeClusterBreakIteratorUtf8.h":"62bde7543b4505cb7ca78fb3586770945a368a17ddb6f759679537864590d4a3","cpp/include/ICU4XGraphemeClusterBreakIteratorUtf8.hpp":"227f18ddbca6eea16773b1501565a708aa389cc7cedead7d29a54796d5bcf696","cpp/include/ICU4XGraphemeClusterSegmenter.h":"623fe0deb02155a66363a301eabdd71d0e8565c991e43c0a0b269345dfc4edd5","cpp/include/ICU4XGraphemeClusterSegmenter.hpp":"b577ab314bb56123351c61f09229e7cbd515a380cc1841ce8fcd9648054472f5","cpp/include/ICU4XGregorianDateFormatter.h":"b16d94873ab46783e3ca040ae1f3335c008caa7eb83267ddd2decfb11de8173b","cpp/include/ICU4XGregorianDateFormatter.hpp":"3766501ab72d5d8a15f6fc3b7e71771a70fa45b68332513745c240256ae02fef","cpp/include/ICU4XGregorianDateTimeFormatter.h":"895afb0c42900402535b73d7a92c348000e24ade6b333e6a8d0c99f46a3c306f","cpp/include/ICU4XGregorianDateTimeFormatter.hpp":"e11865d553f84b6434609498cd3efb2a834a629066d9485ee6c3be266956603d","cpp/include/ICU4XGregorianZonedDateTimeFormatter.h":"a8d6fac5c2514ca88334bd273ad96160c74582aa416f9c7e13a7969425cd0d95","cpp/include/ICU4XGregorianZonedDateTimeFormatter.hpp":"fff493a0810169834c40a666d7d33acc5f8c8a31f7e401947fbf1b3196881cf9","cpp/include/ICU4XIsoDate.h":"199c271f59c6d0f6cd199466ba96b8a954b1a8a83a696fa180ab2f3ad085b405","cpp/include/ICU4XIsoDate.hpp":"1d51c0e5e8bbc477557e4fe6a971f6d97e79a141e7d2b76bcf5d0a468941db1e","cpp/include/ICU4XIsoDateTime.h":"cf93f6ec4ba94142c471e453ac78f63620d71a6eb971a674c015572765208e7b","cpp/include/ICU4XIsoDateTime.hpp":"8595c210a3b8afdfd0b383a7bbf0aff8a99e8320a67819751d496ed0808920ff","cpp/include/ICU4XIsoTimeZoneFormat.h":"7f99a45d84ab1292fe3ef50b0030b27442cec24172afb04674f6dd861cfa410b","cpp/include/ICU4XIsoTimeZoneFormat.hpp":"c7d3cff3cb93f1c6865ad18973f01722616f27b338ffc8ca55d7ead35c5fc587","cpp/include/ICU4XIsoTimeZoneMinuteDisplay.h":"e8acbc9cc0d191e38e271b5d4da97688047937aadc98dc241a4e66839d7c1315","cpp/include/ICU4XIsoTimeZoneMinuteDisplay.hpp":"bf8ae21b6853039315520b67b81ec70896512851d77a5f4a30436fb3b0cb1ff8","cpp/include/ICU4XIsoTimeZoneOptions.h":"a23d3a3aea566b9e0bb28945a7da11862e59462c37aae925a8b06f6b3c53e181","cpp/include/ICU4XIsoTimeZoneOptions.hpp":"6ec0dcfef0f2f6bc66a2eab5d696b4b0133f2b316fce4d231d4a987f3b6c7e1d","cpp/include/ICU4XIsoTimeZoneSecondDisplay.h":"f1e23eac627f2bd85a59db7b700a374714119b855e5adcdfa27ca3ef19c02d0d","cpp/include/ICU4XIsoTimeZoneSecondDisplay.hpp":"42af9f01ba7caa56e8e381d57c3f7789d44e596f6df1a346508eaede5bd204a9","cpp/include/ICU4XIsoWeekday.h":"a145439e1c3918a4e7ff0b03b39c2c8b1a2c7e035b4a9eb44b15f62c2b5b084d","cpp/include/ICU4XIsoWeekday.hpp":"3bd1f9001004c3609349046b07347ed178b534d6f87f45f2e69c25d7e8b843d6","cpp/include/ICU4XLanguageDisplay.h":"53090fe4bd1ec74367afbc9fb7580203690ce53ca99f58905da365693c446951","cpp/include/ICU4XLanguageDisplay.hpp":"b7878b46171828cde4fc75eb7a6fce911ecc5b7aecfa36fb813a73bb8b24fc00","cpp/include/ICU4XLineBreakIteratorLatin1.h":"bb1851ad2560aaa88c819b06542693186ba991dc8a5fc26936781e00ed215fa6","cpp/include/ICU4XLineBreakIteratorLatin1.hpp":"fa563128300d5aea168d1c8187367e9c17dc878b4d7dbe9b27591d50fe83f07f","cpp/include/ICU4XLineBreakIteratorUtf16.h":"61d5f40b5ddfed50a4414dafeb75aab49384309375a5bb8c1db21987eb95ffa6","cpp/include/ICU4XLineBreakIteratorUtf16.hpp":"73c347094bea6a1680945b6683544a13f2504da288f2b783857814d3a9066cd6","cpp/include/ICU4XLineBreakIteratorUtf8.h":"453e6711f0345128bb982838ed40bd67a141265a21b0cd2218310d8bc93dd014","cpp/include/ICU4XLineBreakIteratorUtf8.hpp":"077bf5b2696467e5b718430364d416b331a50d8275321d67cfd7fe5c4e759ca2","cpp/include/ICU4XLineBreakOptionsV1.h":"230517bf5ccee15032ec091dc18074ca4714242a7ffd81983ab3d872d0e46245","cpp/include/ICU4XLineBreakOptionsV1.hpp":"4d9c26453bb1cf9f5c4b01c825061f6d49012f22aa0fe2a659fd85ee6aff4a36","cpp/include/ICU4XLineBreakStrictness.h":"0906420e594bc72ff88957b4b9f85966cd5d72a99bea8b9f29c593d0d421ebb6","cpp/include/ICU4XLineBreakStrictness.hpp":"161d6ce8be738710272a8c09be8a347ffc0fa822c77f3299b12e99d4a500527d","cpp/include/ICU4XLineBreakWordOption.h":"812e0beb839fc77869f0e82144d5f28323f74e54217aa2a684e026d54cb3bcf6","cpp/include/ICU4XLineBreakWordOption.hpp":"b042c9a409b241014c29c6528b1b27c993a22d5ab6475efd32cf2b467e707259","cpp/include/ICU4XLineSegmenter.h":"1b8b32fbca641d11d7c29180fd37882ae84e6019574d88d5726f27d8d732ca46","cpp/include/ICU4XLineSegmenter.hpp":"7098dd82c3777c574514c126c9552916227e2a5c69628640aeba0abf516a42ec","cpp/include/ICU4XList.h":"61aa297726f8320e2db5dc82fbcaf9655606e69c1b576c4609ed7cc00a4761fe","cpp/include/ICU4XList.hpp":"45b79c77f5597b8edffbb813eaac6ea4ca240abed997973d7d4b952018eb4671","cpp/include/ICU4XListFormatter.h":"e7a4c0960e21dd7c927f2446e68f899f6fa1ffbd3fb62f16275e3549b3b7df95","cpp/include/ICU4XListFormatter.hpp":"bceea10dc8c1fc35fd75fe92272a68fe2f8f1dd997dcf859a83d65d692a4a817","cpp/include/ICU4XListLength.h":"d5614e3beeb177aa994be08e2d2aedb60eb70029d85bf3a6c6e146fcd81585da","cpp/include/ICU4XListLength.hpp":"8e062284ab2efff53a34aacedad5845fcccb569ce5aa37f8617f45bcbf8d3bbf","cpp/include/ICU4XLocale.h":"4c8a4eee422925ea9a5b358ea2d2e0ceafb3bc7506a3e08bfc0abe6c583d28b1","cpp/include/ICU4XLocale.hpp":"e4b7e2d0a5c3638d4793eed39aae52e9ca63e5b727d2baa31fd269c5425504de","cpp/include/ICU4XLocaleCanonicalizer.h":"729fc0b406f32508ca271f342e8e0a04d5a9ad236b9cf29afe8ef3dc0e55956d","cpp/include/ICU4XLocaleCanonicalizer.hpp":"b994be60de6a074574bebe7a38f741109a5a6d2ba21aca7a60c3966eb7a892c9","cpp/include/ICU4XLocaleDisplayNamesFormatter.h":"6b2627ea0c51382fa9c17986d419fced926af9765ccc4a50cbee186a18bb4e8c","cpp/include/ICU4XLocaleDisplayNamesFormatter.hpp":"c8965c77b3137d111df4cca07afb7ab4441ff63461ad533eae1e5de3ecd9c27e","cpp/include/ICU4XLocaleExpander.h":"acc58a303fc99ff1aee637985887b2694bf3744963f19fad790af7cd3d1d4b5b","cpp/include/ICU4XLocaleExpander.hpp":"3369e762d696696a3628db46bc3c2f12632792b22b8a4485888fafbe76953296","cpp/include/ICU4XLocaleFallbackConfig.h":"fb5037e7dcff96d6fddbcfe82ed86792865623e3ee83a27a7f57b282b317a49b","cpp/include/ICU4XLocaleFallbackConfig.hpp":"80496635ffa9415f931cd3871ab1a4094c5b01e258965a37822f65952e59faf7","cpp/include/ICU4XLocaleFallbackIterator.h":"6509d75408b7a6d430f4caa3468148d0a06c4ff4490728205692db5d9c2e556e","cpp/include/ICU4XLocaleFallbackIterator.hpp":"52daf604389451ebce0499552e180f1d6b30f762858e550c3a508b7c1bfbc091","cpp/include/ICU4XLocaleFallbackPriority.h":"aa69b2108b5fefcd0325b7263f1db8473b17ab8d5fad74e641eb8ee2bfd4b54c","cpp/include/ICU4XLocaleFallbackPriority.hpp":"3de5a7fb6a8a3ef3265e269c27c1b38c75b1a0b3515b7b459c0193f20def5af4","cpp/include/ICU4XLocaleFallbacker.h":"965da30fd0e5280c086a104fccd117a63450f30efa49b9198037cd95d6b22bcd","cpp/include/ICU4XLocaleFallbacker.hpp":"e31fb699b3c0352ce8235a566b69c89834f53cb257c17a89fccca36e2e651ce3","cpp/include/ICU4XLocaleFallbackerWithConfig.h":"8144d2a7fbd88ce8e0dfca4522d4a00e0850332f53b3b47751687a2ed772749f","cpp/include/ICU4XLocaleFallbackerWithConfig.hpp":"486a23b16de67b587b86b49f772e57e009acc268e6af16c987a0a5dda415916c","cpp/include/ICU4XLogger.h":"9a5442ab6151781529d6168d452ff12b2a82f1ce60905d7cf1b165a22c1b8b87","cpp/include/ICU4XLogger.hpp":"5afeeb0c30304e3b3d9b31b3b774832129f3414e466aadee043dca560dc628ab","cpp/include/ICU4XMetazoneCalculator.h":"f67642f2699df48e660034834c60620efddf28b5313daf6a4caeb49231e72600","cpp/include/ICU4XMetazoneCalculator.hpp":"1c2325c5d9c0b9d39063c7ef91e023299065be9c506b7cf0b3b5905a7ffc4738","cpp/include/ICU4XOrdering.h":"2623e442030eeaad06e60a85813fd38690f934a615cf7d1d34dc7ce3f687c737","cpp/include/ICU4XOrdering.hpp":"86811686ddaf5da7d0329a40c22fb7bd3b24b5a7f69806c105f20ed19b8c00c3","cpp/include/ICU4XPluralCategories.h":"4b976338eb417be4d785654d9edcd7f6557e5ce8426e03b37d8a59349eba2aa5","cpp/include/ICU4XPluralCategories.hpp":"007f36b82e22f1e7de269ed193f7b75b270621e45a2b35846154e6e4ac957d13","cpp/include/ICU4XPluralCategory.h":"7f5e82bd8a601c3fd69c9a8ef462e01fedd26a3713a227b9daddc4360e49b0e8","cpp/include/ICU4XPluralCategory.hpp":"5d0e1861814fa4ca2c09727ec84e6e84803242758b7daf6b90835ff45619f352","cpp/include/ICU4XPluralOperands.h":"c67fb8047061802a466f0655d9613e88c24c5773865f905e9784b66ef61b5e28","cpp/include/ICU4XPluralOperands.hpp":"1de31d5b684d95a3b0602cefcb1d097887f055dd8f5761b14ab99b2b15c5df58","cpp/include/ICU4XPluralRules.h":"bb6d62895a2824ae2c566a1bb9c3d866b2f4e4fa2186be4043d209f5944743b6","cpp/include/ICU4XPluralRules.hpp":"6f8ee9f09a0af7dd6b396703f4f73a678bee04bda01efce45cb095ca248fe699","cpp/include/ICU4XPropertyValueNameToEnumMapper.h":"fe2ecc1e6816bd71738a82744957fd27fd6d8b91229a5c641c544172cc822996","cpp/include/ICU4XPropertyValueNameToEnumMapper.hpp":"80d40acfc044b2a7fcf100b9ab1898a09bb29c4b4e4d64b49daa0d7e0a3ddd57","cpp/include/ICU4XRegionDisplayNames.h":"fece0a7fe6227f47132200bfcd37ebb90fb5cfde2af4e2385f01aba2713c4cca","cpp/include/ICU4XRegionDisplayNames.hpp":"7cc4b8ec4a1157cd36b2fe0a03ed5fd2dcb95856a47441e11915071ced14969e","cpp/include/ICU4XReorderedIndexMap.h":"ba81910d14a97545a2d2514a6fa7c003585a52a51fb08edc54d8d2b2df08c741","cpp/include/ICU4XReorderedIndexMap.hpp":"0161d74cde2c0119ae6f602253ca713e2e990a895ed85f7e31bd9ba15bf5359e","cpp/include/ICU4XScriptExtensionsSet.h":"8d170c1ac68202b6714f8a181d9a2026a34d1ba2947d3c75c0d0fb3d4b531fb2","cpp/include/ICU4XScriptExtensionsSet.hpp":"ff058b84470a116d16325ae15805173e0ef20854116101725cd61d5768145da6","cpp/include/ICU4XScriptWithExtensions.h":"58f24862866b02a818ccb8869802364d89799cf65359ad92ba9a8796ba5c82fc","cpp/include/ICU4XScriptWithExtensions.hpp":"6baa886aa88123e52a6fbdb3c857a15e66727af526d88c2f8f192d3c352b3b6a","cpp/include/ICU4XScriptWithExtensionsBorrowed.h":"56995aeb93fbda6b12a7222effb465a31a9d2e0d64a9d45207fc7b43156f9b87","cpp/include/ICU4XScriptWithExtensionsBorrowed.hpp":"1fe52a0f0960c2bdcf726cc08f70372c6f8bbc0cc6900bff8583a697a3841349","cpp/include/ICU4XSegmenterWordType.h":"c56bb9194ad922268b5ce5acb9793f18d61afc0d80cc20ed10ef255117091eba","cpp/include/ICU4XSegmenterWordType.hpp":"e59484de3a51a97634dfb80388bb4cb926e4cc6098ba9765341fbf4f2af6258f","cpp/include/ICU4XSentenceBreakIteratorLatin1.h":"76e4c306ea7e28d5df48e9a0e66a0fa21b62e43d1716cd515aaf190dbd01fc70","cpp/include/ICU4XSentenceBreakIteratorLatin1.hpp":"a7b281ec1a67e6285db900a108ea7757a24a50ecd17849ea476b35b369ff8db4","cpp/include/ICU4XSentenceBreakIteratorUtf16.h":"90286cc87e2ce166dda09ec8ecaf69403432a2fb0d31c86f425fffbfe15f5814","cpp/include/ICU4XSentenceBreakIteratorUtf16.hpp":"a3bd82ba16263006290e1d7eb51871213fc7d235bd52fd2dd1b7675dfb652434","cpp/include/ICU4XSentenceBreakIteratorUtf8.h":"4d28f1f34829adbdf398cc08628966086de864d3147a0476693860d682398bd1","cpp/include/ICU4XSentenceBreakIteratorUtf8.hpp":"4ffe846e616e67f87841b7e9e84a074995cc01c71f83bb0c3a9594a7f60cf111","cpp/include/ICU4XSentenceSegmenter.h":"087908c9867c63e7ad934a7db4c0ae260dcc87f3f6ab950ff5a608c733a368a8","cpp/include/ICU4XSentenceSegmenter.hpp":"3707a46f5699e8300be991f5b1cf4e276b533b4ebf563b5ef1703a14e47bb193","cpp/include/ICU4XTime.h":"0195a178069eb12e4b86853ca41fba24b115a24358f5320631f2bee0410f349e","cpp/include/ICU4XTime.hpp":"759f203ceefadde8969820bad3f70392b9a035d3eea3d74cbf1f661e53035e19","cpp/include/ICU4XTimeFormatter.h":"a0f7ab82243fcd1d930e1af7673a982c8403fdfea4cef8fa219b693908b58c44","cpp/include/ICU4XTimeFormatter.hpp":"f4d94c9e8017a67e54c2980c64fa99a2d29791421d052da35c33bb4caae71d68","cpp/include/ICU4XTimeLength.h":"e1e9d2cde0a36b43d8caef5291e3fc3d41d72ed798eeeb599ab734768df68105","cpp/include/ICU4XTimeLength.hpp":"b8522f485ba1fab96f4d8796731fde44714628efe7182a7d25f503fffce05a54","cpp/include/ICU4XTimeZoneFormatter.h":"f3ffe8f4b44d144c150318b93f020437b7fb83ec7ef9bcac33b03e2e71e2daf1","cpp/include/ICU4XTimeZoneFormatter.hpp":"aa8443019ae7baabcbd3f7f18b222ec1223d1d90aa483cebc8ce23d34597e8e9","cpp/include/ICU4XTransformResult.h":"dbf8cde4f204381c530e60c387ea01eb6a73b3d67a963dea32a9875f027c5f2a","cpp/include/ICU4XTransformResult.hpp":"f566567e771bad16396c0f573a5b7837c12c3d496578cc359bc6cd11a808a394","cpp/include/ICU4XUnicodeSetData.h":"3aedbed12b9ce6a746d1f9b85cbb663db9587bb71238653a616521d2b1fda2ba","cpp/include/ICU4XUnicodeSetData.hpp":"a1456b8a976b9ea30184181160fb18db65e4ae726aff0beffbf2ab8492492a45","cpp/include/ICU4XWeekCalculator.h":"7560f941ad512bf045f67f3674c8a3756eed62616dbda956570f2eb8ed70baa7","cpp/include/ICU4XWeekCalculator.hpp":"98f9534296279dbb079cf7a2640e4610f067d6411f6fe55ff5dc002c94394c6e","cpp/include/ICU4XWeekOf.h":"ef291c354d39c66adf434f31fcf1d9b0d7a03c37fc8a8097f398c39372f05aea","cpp/include/ICU4XWeekOf.hpp":"a9b3a178649aa8ad0433dacaa24c532c022425387d9220a830d62ce0e6635c9b","cpp/include/ICU4XWeekRelativeUnit.h":"a1e54b138571b2aa6e20ba938e69c39555719154b9fa74ebb7f03c09a4b3828e","cpp/include/ICU4XWeekRelativeUnit.hpp":"81f4c0749743a386d56470925c1d1f8cb6b76a0277ec18a9f678fca9fc1738bb","cpp/include/ICU4XWordBreakIteratorLatin1.h":"3c3e35b91880e86849ece754d4d4fea2b17e90b8ebad4168ba6e570129caf52d","cpp/include/ICU4XWordBreakIteratorLatin1.hpp":"1f433e085849e4d77c24c01b58e97c7ba48cddca97fcced95060d2548607f653","cpp/include/ICU4XWordBreakIteratorUtf16.h":"76c18f9020d59df7618ec62dcd0ed949773c4bb174054edd7221e3ae4af55d0d","cpp/include/ICU4XWordBreakIteratorUtf16.hpp":"e8dba884122fdcda08e8320df1b20a2b4504bc91fd8704721d973d903f1bdfcd","cpp/include/ICU4XWordBreakIteratorUtf8.h":"bbc05ad9673c69f806be7f161ab0624242b5d0ba01e8e647eb722090b7e0e889","cpp/include/ICU4XWordBreakIteratorUtf8.hpp":"1defe077c3ca1f9a1c99c36f69b8f5052a7e10fac3eabad9d51c2a29d595539c","cpp/include/ICU4XWordSegmenter.h":"48969a7681b120bd12deb3810c0bec4e278cf73241c6c622a1ba62360e4c78c7","cpp/include/ICU4XWordSegmenter.hpp":"f856f3143f7fca0edcd50f2fd315b74f2ccb80f18acb4e522496b173b7769ad1","cpp/include/ICU4XZonedDateTimeFormatter.h":"8729fb75529af74d089f4ba464d2db17cb01dd8e4905aef018340d2d6e5b5cf4","cpp/include/ICU4XZonedDateTimeFormatter.hpp":"ddf61c54fe3566c9262420e14efd131d3c78fc8fd752631a5ff66fa65abd3d91","cpp/include/diplomat_result_ICU4XAnyCalendarKind_void.h":"b7554e62e43d2829413955894fc2cf46f6fdd2f08cc22602267fd8720e28acf4","cpp/include/diplomat_result_ICU4XPluralCategory_void.h":"be4f24d6a8448c7358cb7929c1fe95d0c81bdab4d6c2f9597fb31318c6ac178a","cpp/include/diplomat_result_ICU4XWeekOf_ICU4XError.h":"6da99185bd3b0007580e8ca95475ac6a03ab108c1e4859abb9c6fa4f4268f189","cpp/include/diplomat_result_bool_ICU4XError.h":"d89d4b9ff8dbda4b70ea59b1735eb6fed987446d854c4ec5825ca3a96139c769","cpp/include/diplomat_result_box_ICU4XBidi_ICU4XError.h":"3d5e49b5efdb3fe613a90b25f242faffe361c2406c6bdfe9aa7f7374303e389f","cpp/include/diplomat_result_box_ICU4XCalendar_ICU4XError.h":"b1093f46d43172b0367a5c0e2888c51d75cf09e9b74a6d4ac9f8494659cc23f0","cpp/include/diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError.h":"044822a551a4621aaecf0973ec8c247ee08e6b1558985baea7b593554661461b","cpp/include/diplomat_result_box_ICU4XCanonicalComposition_ICU4XError.h":"2fe231fed603754eb654ccd0cf1514755bf4575762b7ea55a9fa1cdaa8a0ef97","cpp/include/diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError.h":"6fff2f082e8d041fe9b8d222bad577ab340793de1f532d1ca94deaf67a1a7f79","cpp/include/diplomat_result_box_ICU4XCodePointMapData16_ICU4XError.h":"f4128b4152ff66339f054902c1e053898d412dccce46e4f2b8bd391da13ea8a5","cpp/include/diplomat_result_box_ICU4XCodePointMapData8_ICU4XError.h":"8ba3f332ab68f208844590b58983c11e198bf31b3e40a96db3cad00ef2fccfc4","cpp/include/diplomat_result_box_ICU4XCodePointSetData_ICU4XError.h":"f3022441f2cc26e69cfcdb1e479207def3d3995e12a93671adc4d5b2c4c00bd7","cpp/include/diplomat_result_box_ICU4XCollator_ICU4XError.h":"f98f23497388805eef199cd493921353c8198032a7f1602ba21a8e5b9aeb50ca","cpp/include/diplomat_result_box_ICU4XComposingNormalizer_ICU4XError.h":"207bf6e3194f0c26209f1d399c94dfc7002d09498fa3b683a63221e54376b2af","cpp/include/diplomat_result_box_ICU4XCustomTimeZone_ICU4XError.h":"e3bd5c643d87a96cc2e22c54763743fc034831166cfe4e0996e19987679ec97d","cpp/include/diplomat_result_box_ICU4XDataProvider_ICU4XError.h":"e55c3014a4f7e3c65b4749a881dc613e8931a96ba8e9772afd64b29fbcd222ef","cpp/include/diplomat_result_box_ICU4XDataStruct_ICU4XError.h":"122a632de08b8ed4a13c678b97adb0ca2d93682a4ae23d6ee530e2d1c0cd6a40","cpp/include/diplomat_result_box_ICU4XDateFormatter_ICU4XError.h":"c99bc3e292e71a5afa819fbfbb657c61776235a2372557a4f3c2f2611ef0bfdc","cpp/include/diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError.h":"72831cc9f547c1da597eb8e26844627102754a767f17d48da05b67b3aed6da4d","cpp/include/diplomat_result_box_ICU4XDateTime_ICU4XError.h":"64c9f51cc38897871f44ff3bbfccdc09cb2219aa73129624df907c64bfc0b246","cpp/include/diplomat_result_box_ICU4XDate_ICU4XError.h":"e63883c8bdca729b9b54540afe8c520363230eb85d51922a289427f8d2989e6e","cpp/include/diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError.h":"cdc24b34a7b3220f74fe7ba159404945be2ace03f5204ae4e5359da4e22eba42","cpp/include/diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError.h":"c24bbe0cf8763492dc660bd7e439c2e40f0b3fa5311e73237174c43462023580","cpp/include/diplomat_result_box_ICU4XFixedDecimal_ICU4XError.h":"0706eeb65200fd9475b3da7f46d57f43bc115851670a17658f277d8cca39519d","cpp/include/diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError.h":"314a668723cd9b6d9939b1b1a5008e764ee8f31c2f755b4383888581339f7705","cpp/include/diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError.h":"e31c88dcaf07b2dec8b9a1ac90de644cb3c88d26bcd5342fa9e5e3d4b66fe909","cpp/include/diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError.h":"9e20178cfe4a63a5e5af84c468c6cec4b3d88cc8ec8f8aa8a7aae5b0cc6a3cc3","cpp/include/diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError.h":"4a30e2b94172ae78bb10626f6edee04cdfbb18fefcb584831a5f2afc21061c2c","cpp/include/diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError.h":"f5cf70a90def9156d8e2a711a1d766c1b74aa30574adf321bfa98e52a3a508f8","cpp/include/diplomat_result_box_ICU4XIsoDateTime_ICU4XError.h":"b536e34f20ce877f7b7cc096742d4ced3a111da455be857f762332f4bb88b8a6","cpp/include/diplomat_result_box_ICU4XIsoDate_ICU4XError.h":"d82cb4aa37b6aa3bca008aef27e4cc5a443a6393d4557fc8e4d3cf1f7d27374f","cpp/include/diplomat_result_box_ICU4XLineSegmenter_ICU4XError.h":"1c268f748fb0fabc4bee3bf2dff6be1397455d701aec641cca49147223ae0d1f","cpp/include/diplomat_result_box_ICU4XListFormatter_ICU4XError.h":"43cbd479e2b6dec150cc040f27e8322509e6dd33f87dbd0be970b478520fc3dd","cpp/include/diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError.h":"37da5709ea21bcdebba934627a24f696a716509d1fa743336385cda259ae165b","cpp/include/diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError.h":"0dc0a8de105ed8b047d875a88e21d53a23fda879893e85b523e77fe3b91b576c","cpp/include/diplomat_result_box_ICU4XLocaleExpander_ICU4XError.h":"818396c7da0fa28981abc5486906eefe8fca44f45d1455e32525a1c4870c9850","cpp/include/diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError.h":"03c9c7a6182bbbd5abf697e2900fb5f1bf35479359e2b9a6318e883e9c3a9f2f","cpp/include/diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError.h":"76bc810c1f5cdce04bbced497a83ed18597864784cfcd1918470bcf16d7ee72f","cpp/include/diplomat_result_box_ICU4XLocale_ICU4XError.h":"325af7add47038ba4997fccec85f8c17ab746d75452873b57b9e49fe3fb926aa","cpp/include/diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError.h":"11366824711543693cfc29e85ef6506dcf1b126d6479f7cf4516e1b08309cfcf","cpp/include/diplomat_result_box_ICU4XPluralOperands_ICU4XError.h":"37b5b35f3ee46ca40ef6081e78cfcc827c40ece420c56fa9f1ef3caace0ddfd1","cpp/include/diplomat_result_box_ICU4XPluralRules_ICU4XError.h":"00ffa08f94e61e0df7ed1471f5a5f539eb167492b19e2d9bd6bd3fb7bf7c6090","cpp/include/diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError.h":"27375665f96cb573a703464e5213ebc1c9dee48dcac2ca362409445d28314b3e","cpp/include/diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError.h":"a79303283606d3d9f0bfe8b8957ddc7e251f1ea8d71a0c2e023622543d0cc98f","cpp/include/diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError.h":"9d2032bcad19a83584795296de438ea680c7b9452315034b9f3dc83406926d58","cpp/include/diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError.h":"64f17863f06568a2a2493ec5c43eff09a6800898cdc1b0ee7927fc17e29055ce","cpp/include/diplomat_result_box_ICU4XTimeFormatter_ICU4XError.h":"c3428ab6414190e537638497972f666fcde75a09882d6233e94f2348213c59a8","cpp/include/diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError.h":"8d93dbf810a3a6d8bde00608df728387a7fc92e3d59b66de8fc44f7383dc172e","cpp/include/diplomat_result_box_ICU4XTime_ICU4XError.h":"fd59b48cbeeea9f6c00ba4efd8003cef962603398371e4489ed3bf0696727757","cpp/include/diplomat_result_box_ICU4XUnicodeSetData_ICU4XError.h":"7a75ff83facb7287597af360b9ff4c1fe7a71b750d40c9146a94c780481ae84a","cpp/include/diplomat_result_box_ICU4XWeekCalculator_ICU4XError.h":"92d217965ad6296835a9d69458d9f5fa6e9ca55114d64dcaf8dc4a7512df2c09","cpp/include/diplomat_result_box_ICU4XWordSegmenter_ICU4XError.h":"6662198d1464c95468270aec56563f0bcc17e75babd4316ff60b8587ce9766be","cpp/include/diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError.h":"cb5a1ba7eeb206886266c2aa172486073084f8d9d271a52136205185f6376ac7","cpp/include/diplomat_result_int32_t_ICU4XError.h":"c9f9241d50cdffaebb1135ee78efe6bfa212743f71d59b0715ed0a79b05332ea","cpp/include/diplomat_result_uint16_t_void.h":"ad0d09f20115172cea2f459beb97a7df28a89708bb5a3a5372523d6eec42e37e","cpp/include/diplomat_result_void_ICU4XError.h":"bd03f10ee6b79c9498c2586ee94eef1f89d499cddb25d77b774ef066250bc632","cpp/include/diplomat_result_void_void.h":"f5f36a86bbf084e3eb2bf2a616efff7f612a208c2e747d5452b32d609eb450e0","cpp/include/diplomat_runtime.h":"1cea1a3675774fcb4253a58affeb7fad8e771af0b1077051b87bcc4b13ae309d","cpp/include/diplomat_runtime.hpp":"c4c0a6c954d337ecbc5b9253e4afd3cff0b11f120744e156c5dd038b9dc16a65","js/README.md":"3857edd1d256ab90f6d21421a61e275f6564d61f9e8531563ba3f6d6a717a698","js/examples/tinywasm/README.md":"c56bd81847b028f4d8f3cac2301fed9baa59bf89d58d8ea49454a3709bd9ef3e","js/include/CodePointRangeIterator.d.ts":"d57f6f61fd8a8b2601bd06734e15a8f5dc878577d7e7969874d23baaa3e1b4f0","js/include/CodePointRangeIterator.js":"fa0ccbc9c661e28691328e9646032330f217d5279def15fdb3a1154d2a4a6e15","js/include/CodePointRangeIteratorResult.d.ts":"85bbbb07a69531fef0af2162007fb9c44b09fd9e11f7107f79c76fe50c43f368","js/include/CodePointRangeIteratorResult.js":"27975bc4adb5e51ff11bd3112fb777e68c3e38f90b640c485cac4b087478cb5e","js/include/ICU4XAnyCalendarKind.d.ts":"c56d8881d52812fab1f87d5d2d07d3e58ec1d0f61e7fe781ed4bff0ddc399e17","js/include/ICU4XAnyCalendarKind.js":"ece4ff9c97c2c88204887156ac75fb9e88de7901a64ba4c802575d874c522c86","js/include/ICU4XBidi.d.ts":"c87156bca0ac92beb8a4782076f1fa9d3e6084ad6cd8cb24f0caf5f607e56577","js/include/ICU4XBidi.js":"7f1e1fb0682bd5752930fba82023076f9af899c264c0584740db796ad0cdd70c","js/include/ICU4XBidiDirection.d.ts":"317c63f1d8356db98aadf0a94646314ac85049dc997cf219952a759cefad9b9b","js/include/ICU4XBidiDirection.js":"e286a80f116ee30f238e3892841c4406b4ac70da1aa3a2cf410e306bd513a4c1","js/include/ICU4XBidiInfo.d.ts":"12d8bc98bc2d0ea9d4bdc670a1102aa7f6b6487d1f5b3bc72bf00a98d34a4cf5","js/include/ICU4XBidiInfo.js":"b928e6f667d85da40fa282c4c3dc997eeb72e5a2f0dd4463915f1856a7905582","js/include/ICU4XBidiParagraph.d.ts":"2f59520c170fe5ef5805f3766ff1750aac100d8d76df83d84a1d8408cc694002","js/include/ICU4XBidiParagraph.js":"e7d3f24158e88ce4b8f2865d3ae2df97507fd44e3211779b718d0612afa017e7","js/include/ICU4XCalendar.d.ts":"81d11eb4f57c0923810220f13f6f2abd201b3a6f7fc1c0b0ac31ef8b7924955f","js/include/ICU4XCalendar.js":"a08fd6d289bc9773b513fb1996e5906260ff5a927583170a474b9223478020e5","js/include/ICU4XCanonicalCombiningClassMap.d.ts":"6e3bc37833baf885a0fda89ec6de4719ff42561352ca216d13eab5f97ada3d7e","js/include/ICU4XCanonicalCombiningClassMap.js":"c4bf21112a1e0ad426172fd1b0d8c29596a35b6890d2ba96ddd465cf97ac9532","js/include/ICU4XCanonicalComposition.d.ts":"db0b2569c69e42095346cef853b80886b6192d2d8712abd18d9035152306eeee","js/include/ICU4XCanonicalComposition.js":"0497787831c7882e9adfd51aa088b860efc56408da1211027a6fcbf170ac08f1","js/include/ICU4XCanonicalDecomposition.d.ts":"0eaad17e4af4a14e846ad215d88a6834903302b4313bb243d93cd2202dfab475","js/include/ICU4XCanonicalDecomposition.js":"3d4d41bd086f00d08cd0a47b82354d16473571c1a8b2b657def87e071e089eaf","js/include/ICU4XCodePointMapData16.d.ts":"61acf8bd7e14edc18851b30b58d078882f4c3c31546c95a32fb002115539b9dd","js/include/ICU4XCodePointMapData16.js":"a0d2b97fc9315e52ad2c605d38206e92c78f2d2eb12bf63d3c59a68a35ce9382","js/include/ICU4XCodePointMapData8.d.ts":"f1997b8c4cdb1f68f223bb83fa898cd2b54d37495e843e2373e98e5921c7a06b","js/include/ICU4XCodePointMapData8.js":"4a6e2c4b58269c5931c6f21e2ef99b4ee6c98ecebff52ae9c1f27aa02a34a0fd","js/include/ICU4XCodePointSetData.d.ts":"b1e34ed4afb30317f873d6f18139f4a6ca37abf8f1bade431493c411480bea93","js/include/ICU4XCodePointSetData.js":"ff8d7ce7ef92b5414c6bcb0824b6408f4faa3d5a0e417ffe219249c6f65446f5","js/include/ICU4XCollator.d.ts":"e2fecdedacbe21a460989ff98f640d9f2b9b303e4d5fda31e66108810709677d","js/include/ICU4XCollator.js":"43e56831427319f3fecc0e33df0cf63ac3243e1f43ef8c7d9683a75f0ee7fca0","js/include/ICU4XCollatorAlternateHandling.d.ts":"03aab27aacacad47d5e1c3ef74682cfe16dd292d2710521cf873c0834f9f26bc","js/include/ICU4XCollatorAlternateHandling.js":"049e1ba2097da5039767f7a6ff94f69137f246ec566cfc42664bd716132298da","js/include/ICU4XCollatorBackwardSecondLevel.d.ts":"05e290e9c34bacc9068798655e0c317fd0e4903254546ea20ef7c3c049921bd8","js/include/ICU4XCollatorBackwardSecondLevel.js":"ccdcc0e6a437a9602ff2edc9c726639fd53e061c9b1452575d53bfd8026b1739","js/include/ICU4XCollatorCaseFirst.d.ts":"b6e797dcf5fc91e8b13561a713d95cb67a774c2e574cae1aead1889091c0744a","js/include/ICU4XCollatorCaseFirst.js":"a54790c13db56ba55b6ead3490993f0fbf32aabaa4bf32822f61fa242063da61","js/include/ICU4XCollatorCaseLevel.d.ts":"dc8f297926ec3d13b288ce58d2deb5190eb48970037424b8ac4d33cb0842ecde","js/include/ICU4XCollatorCaseLevel.js":"c655244e5535140c6f6d7b85969d15a43e0b7b61e98c197aa00a511c2ac41b11","js/include/ICU4XCollatorMaxVariable.d.ts":"7bdafde54caa08d22c0cb235aedf46051fa49302dd6b62df2be9e552efb532da","js/include/ICU4XCollatorMaxVariable.js":"0a591a149ec5151b4fd846b499fb3bf20aca1a2cca5791118f9458bf1a37bdcb","js/include/ICU4XCollatorNumeric.d.ts":"94a0605103bcfee58b251dba1a2742c2917c0ce06ceda9be7dcd29c77bb9c397","js/include/ICU4XCollatorNumeric.js":"632155467bec07aeeef78f5721caa8d61ec24a305e2a4b4eafaeca7fcd97c344","js/include/ICU4XCollatorOptionsV1.d.ts":"2ae0e76b41200ae5377fa9dabc8f4f84dd2b84d9a57db4837536e0edaee3e1fd","js/include/ICU4XCollatorOptionsV1.js":"e34f6dd3fd520984602662ee13ebc523518f695909940a89e6053b57db2cc464","js/include/ICU4XCollatorStrength.d.ts":"fe6d2d0d9c72d2a4600b9e4b781498786c638c76f240d22c543e9d2f2c3cea64","js/include/ICU4XCollatorStrength.js":"92ed009fcdbd94f016a73c76d73d7372ccf18c72ce0ac50fc8241cd6c5a805a7","js/include/ICU4XComposingNormalizer.d.ts":"ba148619684cb5ed09de2be92bc4a25e0dadbada25a674781c372375314e03c5","js/include/ICU4XComposingNormalizer.js":"d4fab3af67264b8753509aa658c19de06480706e789ea1e776273dd09eb40d5e","js/include/ICU4XCustomTimeZone.d.ts":"470c177322de8af524f49472998c7be535811d4f7e96b93312ab06bac78d80b6","js/include/ICU4XCustomTimeZone.js":"5afd9b9f0ab052dd019b144c23d5f5d050cc715ca355e68b727ae59ee2b0398e","js/include/ICU4XDataProvider.d.ts":"6916428da09278adacde68bef6a5fad198068782c741adaad1b5f119f28d22ee","js/include/ICU4XDataProvider.js":"1328f3899a9926fabfc8e07497c198b0e26fa75fea764f4352d0025c04bd3b4e","js/include/ICU4XDataStruct.d.ts":"52bb18b8031806687697a0ed59fdb1dc2d0a0f4cf37f3dc26048428d3ed115a3","js/include/ICU4XDataStruct.js":"b8bf46ac2da07ab94a4b82b8bb0ee346dca9f03b432b14294af3493df6ab5c0b","js/include/ICU4XDate.d.ts":"ba89c442a5c4792843c271d2aa6ca381288b1a8efe3e274f3599754b33c3f24b","js/include/ICU4XDate.js":"4a30babebc4c2049d6329cb59421d5862dc04e21d40dc72a48cf2829e48ee5b4","js/include/ICU4XDateFormatter.d.ts":"0f41e2cbbbffc9111679bac561e59657e1d339404dab241f4761396bc705066c","js/include/ICU4XDateFormatter.js":"7b942a7b422231c87cdb18df23e5846a3fa13532ed322a845e83e2b3116a1ebe","js/include/ICU4XDateLength.d.ts":"eef23cd41ffa44b0c036f77586de3e8a29ee5739df353610cfbf5684475b54b6","js/include/ICU4XDateLength.js":"205b80b04f23b372e77d0078995725080abb8014f771ed845d9729e8469ea060","js/include/ICU4XDateTime.d.ts":"a4f373d5de310b55bf3a9966174d5f2d5f3237f8158ee509b934e1b020054ccd","js/include/ICU4XDateTime.js":"145bdc19af2caac028b2a20e643c35762ec20620da534ecd4bbbd31be9ae0103","js/include/ICU4XDateTimeFormatter.d.ts":"e5afbcb8e2b8696b0201ef095859a0072531c5c82682e2dd42a7d64b2514a900","js/include/ICU4XDateTimeFormatter.js":"4716df1aeefd2ca22c8d7f1c0d72976df64b87e037fd79002968c148ccb54050","js/include/ICU4XDecomposed.d.ts":"e0e463649ad4d688f693bfca82a5b813f689d41ece7af24cd4d4931d079f987c","js/include/ICU4XDecomposed.js":"045c80ac3139cbfd7027b502982c6bad54da3ced336889325287d00efb7b8153","js/include/ICU4XDecomposingNormalizer.d.ts":"394646951aad4a24432feebfbc18c97cadf4465a3fc23443f2358ff2cdb64158","js/include/ICU4XDecomposingNormalizer.js":"13caadba19bfc1a8f467d836a0ba501526af53e52b454eb02fe1bde01f662294","js/include/ICU4XDisplayNamesFallback.d.ts":"90a75af7ac32052addee947488fb037058d92a55306302751eec00cfbe39c60a","js/include/ICU4XDisplayNamesFallback.js":"4128a1f5ef5d51516602477d384b7292c622f21b96d3db9e0efa9d383783a0e6","js/include/ICU4XDisplayNamesOptionsV1.d.ts":"fd077385772e9b481a278b28dbd62f483d4a1f4792fa990ed9cc0ef669b3bbb7","js/include/ICU4XDisplayNamesOptionsV1.js":"30968df2eae8d61c3b214e36d4bf9602a18500e0d85e06a5c409ae62be831297","js/include/ICU4XDisplayNamesStyle.d.ts":"57d11b1d80dc944496d031e6d99c811f326d891c239674ccdac1531b7e12fb5e","js/include/ICU4XDisplayNamesStyle.js":"3b4621b09a32d06266826f8c44b892231820a442445fedb4fd331ee066085353","js/include/ICU4XError.d.ts":"4438493f49c015b59befa5bf8d43499e665a414376d8e3291b476c681e34bdab","js/include/ICU4XError.js":"9edd393befd656137bf23f0afd988c7f4e1761400baeb97cdf1a4d7a8dee3d62","js/include/ICU4XFixedDecimal.d.ts":"9a1efe2c4a206ad5d03c70500d23a784ad60eec2f7f85fc8aff0558208be6708","js/include/ICU4XFixedDecimal.js":"c2358ed01693d1285603706dd2e320d4dc7a871af5b244528d7d9d33939de6b6","js/include/ICU4XFixedDecimalFormatter.d.ts":"b81afd4d6c1db506bc4d5f9f4c8d9a23b2097ccfa495719947b53fbf780e86d2","js/include/ICU4XFixedDecimalFormatter.js":"860d0fb6991a1902f609a3d6ee69881fc643fcdaaf859631756aac6237ba2b70","js/include/ICU4XFixedDecimalGroupingStrategy.d.ts":"c7f86b0e8b3888d98b74651a92ca7a2da96fc1ba1a794de2d35d4935c43bc943","js/include/ICU4XFixedDecimalGroupingStrategy.js":"a5c22febf577b3ea1a7b7b4cd649ebac03b06ce0e977f775252b6237c7a8b0c5","js/include/ICU4XFixedDecimalSign.d.ts":"f1efdccafa4c5a444708b2590142a294a3968ba991d65b0af52efd6e61c44287","js/include/ICU4XFixedDecimalSign.js":"33b839074193bef69c84559aefb0c3dfe92b0fd19f367c976fd0adf0afdc0a69","js/include/ICU4XFixedDecimalSignDisplay.d.ts":"80a07e2ec90650f151c6590b613a169736e4cf62dfd7de96ec8643ac29fdcac2","js/include/ICU4XFixedDecimalSignDisplay.js":"82c5b3c34b653717eb5e8d1c4a3af5fc10a89ebddaa62bca475f8f7bb6febd9a","js/include/ICU4XGeneralCategoryNameToMaskMapper.d.ts":"8b0bd158fa8092d75a804fb818ed19c310ae039c3538133e61b45c95e9333ff6","js/include/ICU4XGeneralCategoryNameToMaskMapper.js":"4f1699cd06f0a3967ecbdd92c740648286e414920f41869f7bdf8cd441b48c7d","js/include/ICU4XGraphemeClusterBreakIteratorLatin1.d.ts":"e24f6aa6e90fbb8dadb29b638203dd5ab8406a715c6610922e950f202ab32fd7","js/include/ICU4XGraphemeClusterBreakIteratorLatin1.js":"a9c00068e8edbb16247daef76a0e98817ce5ef38d987ef39ae16a80dabe0cf3a","js/include/ICU4XGraphemeClusterBreakIteratorUtf16.d.ts":"a9a6d4deb0cb21766460ef1c484be2e89c4334bb2dcdb514e837cb8e08fbd8ff","js/include/ICU4XGraphemeClusterBreakIteratorUtf16.js":"c807849a8d644a1c62d44da11deb312dcbc60d41e0a56736b023ee15d26431c1","js/include/ICU4XGraphemeClusterBreakIteratorUtf8.d.ts":"50076ec53626df84f0cdc52f1584c86167d9f893c89ceb7d3705ace72738772d","js/include/ICU4XGraphemeClusterBreakIteratorUtf8.js":"581c4936c238d01397239b0fc6ef60b56450df1f549cda22c7828c4dc17dfcf7","js/include/ICU4XGraphemeClusterSegmenter.d.ts":"08a10bc561f7518052c98f43197a59508f9fd03b782dabbb1b4d1787e662921d","js/include/ICU4XGraphemeClusterSegmenter.js":"bacd5016c6854f640c37e43c00af98c8cdb53bb6e62f5fe5f69e67dc94dec0cc","js/include/ICU4XGregorianDateFormatter.d.ts":"738229dd0fc7af800492bab135f744d4c5450497d3f0c7c46b0d85dc371bf81f","js/include/ICU4XGregorianDateFormatter.js":"2bb205c43996ae94e0bb8e5e2d5f5e77a0b2e87d77921344f850fee98b52f285","js/include/ICU4XGregorianDateTimeFormatter.d.ts":"557c25b05863a2f6e698164e8d25513d80b57d0a06366fe06d9865097481150d","js/include/ICU4XGregorianDateTimeFormatter.js":"b140ad91ab5c79e4eabde0f88e1ab5b2a75677344bbf223b2056f876e5daac20","js/include/ICU4XGregorianZonedDateTimeFormatter.d.ts":"da8a81b205ac83facc262401b089e174444808962093615ceb90082ffbd23d4d","js/include/ICU4XGregorianZonedDateTimeFormatter.js":"654e5be83071231eaac7a6809fab7160712a536225bcfadd50d5e0599cb90215","js/include/ICU4XIsoDate.d.ts":"10c3a273e8fe0ed78d3de3d6a88ea3d44bfa8c5d8f9ddcdc064787448247c9f7","js/include/ICU4XIsoDate.js":"556da857e3b6ff2193b9d2dfa95e4ffc34888fc938ef6aca553d3462cd1dfb15","js/include/ICU4XIsoDateTime.d.ts":"8899cdcb803cec01710909b492c9516af35e884b5761ef738f8fd531a805cf14","js/include/ICU4XIsoDateTime.js":"22bf911c96f3582e3c3b519e13188b614f55cb3b0b18a6d94342daaa3da1784f","js/include/ICU4XIsoTimeZoneFormat.d.ts":"d20d6be2e315c2591366ef46ba20aad41347560d36b5b08779cc20b92897208a","js/include/ICU4XIsoTimeZoneFormat.js":"4f3073326cdb8d381e4e5bfbbb5d9b2adf57f6b45816a5781ef5fd1e380c6764","js/include/ICU4XIsoTimeZoneMinuteDisplay.d.ts":"c5943895fb243a43aee6f03a7cecb9062d7113688ace55ec10bb7e661153994a","js/include/ICU4XIsoTimeZoneMinuteDisplay.js":"cfece4237e82485a41df404463db20e6b0c58a3d170b6f59dea9c93cc7c3c09b","js/include/ICU4XIsoTimeZoneOptions.d.ts":"51350e0d7baebb25e0793fc80d6a58a5332603bb6cf45024e94af100e887d41f","js/include/ICU4XIsoTimeZoneOptions.js":"e90518cbabd0d37f94904a0e83f53e82192e0e49de5bcd386fdd7bc390bd37ec","js/include/ICU4XIsoTimeZoneSecondDisplay.d.ts":"84f8320d39f28fd527c32b6e6565ee793473f801687fcc0e489c7f0c8deb7317","js/include/ICU4XIsoTimeZoneSecondDisplay.js":"b1cd283e031dd9b3869eec96842350e39a1fd1d474de4c1674fef6a1833c2521","js/include/ICU4XIsoWeekday.d.ts":"1a226e9475a87c7f94fedba962b52256b6dcf460bdd5797623e2e0881378d29c","js/include/ICU4XIsoWeekday.js":"36c67fb01cffa129c5b9d2f83f332a8f4edd04158fc57f71d278a4f14cf6088f","js/include/ICU4XLanguageDisplay.d.ts":"505fa367e6869919cef5bbc334cf5c30e3b29892e9d0bfb7e9075b30a9e7dfcd","js/include/ICU4XLanguageDisplay.js":"b7ac8b55119879fd7ff69e040add565f06ee55a738493d38414b80d655e61348","js/include/ICU4XLineBreakIteratorLatin1.d.ts":"77d023ada016b5167ba3a56e50402027e1a5e8406603074d0029029b28161e9f","js/include/ICU4XLineBreakIteratorLatin1.js":"411a5db01c4e0a83ddc6f0122d4b4b8e9d370a6afb78bbe94bbfefd8b4e6f9da","js/include/ICU4XLineBreakIteratorUtf16.d.ts":"c651fb3946304770d89e66ee906d95dd925341c2c670158e4eafcc7d96359fd1","js/include/ICU4XLineBreakIteratorUtf16.js":"0e5daebc83d589fb44da5702ec520ca204f9a7c1ab25d5b4c31fdc3cf25ff477","js/include/ICU4XLineBreakIteratorUtf8.d.ts":"3ff898adf41bbfe5a70026dd4f5150da256dcc33ddd41db47efd2d421db2f2ed","js/include/ICU4XLineBreakIteratorUtf8.js":"a2b368943d931b587439c633d25a6741058c5c2d77daf55dc30e5c4206ac29cb","js/include/ICU4XLineBreakOptionsV1.d.ts":"c88d710b9dccd65b33cf4b4c8dcd8eb60ba1ab1fa54816f4f7ff39c5e3435d27","js/include/ICU4XLineBreakOptionsV1.js":"e51c63c7fdbddad161fa0e5d39ab0ac35b68df97a780bc157340f5b09d1ea6c5","js/include/ICU4XLineBreakStrictness.d.ts":"30b061be158e691458869210b6cf51fff3fe83428297f55f94c42c943d0c3140","js/include/ICU4XLineBreakStrictness.js":"fd036dc7c622567122e957d9d6e4422ce0a68cee499e878eea7410d4fc0278e6","js/include/ICU4XLineBreakWordOption.d.ts":"2b5a8e1529d19c0c9c695db512aeb0e9cb625065dbe72529f5d27aa20ffa087e","js/include/ICU4XLineBreakWordOption.js":"9fd6b0a78cd0b3240ee948e8d909aa27bed7321677898bd5637a55b771876d88","js/include/ICU4XLineSegmenter.d.ts":"828008a63c661a74142b7ed318b77878c41371102eb384f13bedf095e2e353b8","js/include/ICU4XLineSegmenter.js":"adb478c1e4f6fed8f99c8af9f020131b4e9a4bd529f3250c64beafa1dbabeab9","js/include/ICU4XList.d.ts":"e1ed8081468f45f683d54b5711bace87e936b7186c3dc21ed4d5ff5b7c1e970f","js/include/ICU4XList.js":"c4fa159d0179a3b313b1d62681d612bd6acd7158adeb2bae8795d7682c123da2","js/include/ICU4XListFormatter.d.ts":"3a0e51659810f28fc8790674fc692cad98bfce095cd40ff4a210041ae4375f55","js/include/ICU4XListFormatter.js":"393314b48835bc5bbdf4803f78eba87f34b02ff653fe84bf6d74e470037a30e1","js/include/ICU4XListLength.d.ts":"c1ed5664d9bdd0e369cfd2a0804fe4defa1cb2a6e6199b5640385e5c17084538","js/include/ICU4XListLength.js":"70f38d18c4e5651cbfa6e55ad06117a604a60f644d5fb419aea279446ff5552b","js/include/ICU4XLocale.d.ts":"52e8360d77bed333cd798ea28cc19bdc30d54030a66213cc7809936313644b8d","js/include/ICU4XLocale.js":"56900f40b0c138e77b2629c129c4b323210a6b7d095fc941e25e594f87a22d77","js/include/ICU4XLocaleCanonicalizer.d.ts":"9a30e0c786d049b21b95e38ebcd297398b0f426ccdf3e72a9c561090acdd50d3","js/include/ICU4XLocaleCanonicalizer.js":"4aa757b4f90132a6f25b1b1f37ebff5d17c221e29eca729c6a65b1d25ae28094","js/include/ICU4XLocaleDisplayNamesFormatter.d.ts":"bfb1a5e0cfa97a9087d8d47f34e0e9ecaa3f2697658747ebf6fb3555e5437e3e","js/include/ICU4XLocaleDisplayNamesFormatter.js":"de6c4675ec4acdc7f8d38c03348878528fcfe2699c420dfcc178bec67db98160","js/include/ICU4XLocaleExpander.d.ts":"83b8c3d3dd32a755ee174821a10dca52b826021b4be2c99f04ff498ffb4b1d6b","js/include/ICU4XLocaleExpander.js":"21a64dc1cb6d594c125cce4173016cf7776d2ac58296efe8d2fdb574152459ff","js/include/ICU4XLocaleFallbackConfig.d.ts":"f091de16055144f77d42be76560b004435ae8b38a7c8ca421c11e60905c70c42","js/include/ICU4XLocaleFallbackConfig.js":"100a5c71663c069c139ad4120cb56a86e53ec1ec518fcd66def129f69afdb421","js/include/ICU4XLocaleFallbackIterator.d.ts":"dbfdf1d7c7facef8fbb28a05cecd3dcbd743dbe34a0ae4232c3577075b98c17d","js/include/ICU4XLocaleFallbackIterator.js":"eb5c29c67cad751ac47ab79aaba0f2bbf0fe15f1aa53f76a14051b35b09b9fc7","js/include/ICU4XLocaleFallbackPriority.d.ts":"05b568b006f9ecc762e7f78292bb3e2a4932818b2905c98449823af6df9bec22","js/include/ICU4XLocaleFallbackPriority.js":"bcca1eff8492141ebfec82fb94f4cd0f936e352fa573a649ddd6cd5d03032b27","js/include/ICU4XLocaleFallbacker.d.ts":"8d9917044615b767a01b569733a39fd0c96ae7b45c5c939886aa2a2398ea4604","js/include/ICU4XLocaleFallbacker.js":"46010266181d4a771218acea7901d86584231c3f4ce7589c74c7982bb9487dda","js/include/ICU4XLocaleFallbackerWithConfig.d.ts":"d417bb9fe35c7ddb3d0015fc9a7c6a4687ccfe321485a149b96d0c8ce43b9437","js/include/ICU4XLocaleFallbackerWithConfig.js":"afb34eda2648372870850f6dc3299130a98f56d29d48a4d543663456450c526e","js/include/ICU4XLogger.d.ts":"9910521bbf3e85e9a1e4fac7723e282916d4db782508713d2a04fac0f5b3235d","js/include/ICU4XLogger.js":"5ab42fa3277aa58009229b7ba691bbf465ec016f53bbd9fcec0da711368682fd","js/include/ICU4XMetazoneCalculator.d.ts":"37341f959fcd097ff641b313d624a5f24c5dd6fc948da76a3e663ee0aa1db825","js/include/ICU4XMetazoneCalculator.js":"f777f20baa8e09a1fb369d50eda09dee2d5eecf2430e9189550f2b7905fc5183","js/include/ICU4XOrdering.d.ts":"9e474203a8efd5539cf60ae8378109156fea4eee6226eb8915997f2104d22aee","js/include/ICU4XOrdering.js":"2e21cf078e0161d29a509aa542126324ae37eaf7d8c44398ec8e1f7012233df9","js/include/ICU4XPluralCategories.d.ts":"9f45d0edf2b304a76b94cd3fb9b496eb3ff11fa215e47ca8350015f423992514","js/include/ICU4XPluralCategories.js":"31fffaeff9c831a2e5d2cc252c6a5e1be060268230591b585e079664e8d327e0","js/include/ICU4XPluralCategory.d.ts":"a22e2c7b9d6377a1151855748649aa167e67a763fe605394a118e0c52236057d","js/include/ICU4XPluralCategory.js":"22f169e440a7a5000890327dbbdb0d4c434ac184ee0716a58d27583cb220b334","js/include/ICU4XPluralOperands.d.ts":"021fcda7962967b82344b89ae32e5fbf28b0da83b651d2ac94f92fa3dfeeafa4","js/include/ICU4XPluralOperands.js":"3cd306fec2320a3c6236b61b1817ec30fab4e576f67ef550f6aad77565454203","js/include/ICU4XPluralRules.d.ts":"948952cddcbb80b996a07ed295635e193c744febfbb7ec3f14451b513480f655","js/include/ICU4XPluralRules.js":"17562775d3023b0b2256f9fd628e179066904dff40959ecf7d82b835e9f6dbd7","js/include/ICU4XPropertyValueNameToEnumMapper.d.ts":"d01735437ecd14dc600240b9b9c44f85cb7f4afeaff0049b5d85c52610fc7d61","js/include/ICU4XPropertyValueNameToEnumMapper.js":"0188ddc8d26cfd4b8c4f62576d1d93aaecc4c40174f13ccdc68379980b84793e","js/include/ICU4XRegionDisplayNames.d.ts":"0680ab49d9e6c100e746e256c9a84a272c8083a273d2a5c91b5c548a61d47aa0","js/include/ICU4XRegionDisplayNames.js":"37f27838d2d76c21b999d65f25409f73862f6f508dacf0f274111ad9558d881f","js/include/ICU4XReorderedIndexMap.d.ts":"4a90052cb5496475e6b67ec25742865311ddfd51523058c50034a528170946c5","js/include/ICU4XReorderedIndexMap.js":"06b1d3c12710611d1becaf78590aba71e1a20fbdcbd506bbda0948a869914869","js/include/ICU4XScriptExtensionsSet.d.ts":"d3cde86b6fef3a78669eb035678afced44fd7f5769c62b6d70c017f87df23758","js/include/ICU4XScriptExtensionsSet.js":"f4327c39b98a699306515c5e7ca0e13802066fc66514fccdfe05fc9b62584bd6","js/include/ICU4XScriptWithExtensions.d.ts":"8b1753d86d1f753dfcefeb67c17855b16442b514b4854a8cf90220411ddd795a","js/include/ICU4XScriptWithExtensions.js":"d5bd963ec59adc25856513a38f6e98b6f2795a05e76a515287d389dd11679a89","js/include/ICU4XScriptWithExtensionsBorrowed.d.ts":"c9bb16d8784e838766f7067c562754b25eb8e9acade28594623256ea417f5e29","js/include/ICU4XScriptWithExtensionsBorrowed.js":"bbabd18b1a4ad1abd410e2e80d0a7baa525b8dbf533876a0fad6f8ba57ec4fdb","js/include/ICU4XSegmenterWordType.d.ts":"89617b9a7652474cefd4aa55eb2d50c380f389351f3119e4b158bab22bc0cba8","js/include/ICU4XSegmenterWordType.js":"17216e3d9c88b8274b552bf7783162b60f5b0011c700119377c356a26607f8d9","js/include/ICU4XSentenceBreakIteratorLatin1.d.ts":"8bc66e377ab330f4c82de876733058b87dabc56439cdc313f45c12fa2d46a925","js/include/ICU4XSentenceBreakIteratorLatin1.js":"1706b50089f28ed7fbcedd4833c08718c6842f72f8d5a340e22944dea98d2193","js/include/ICU4XSentenceBreakIteratorUtf16.d.ts":"551f7719b6d478225ca7a673b85e7dbca330e3b0216a6bcfbf4025313f09f704","js/include/ICU4XSentenceBreakIteratorUtf16.js":"668f357e016c248b030d023899269e4ef988be800effeb96b1f885119c9fd249","js/include/ICU4XSentenceBreakIteratorUtf8.d.ts":"f84d88d2f5ff28433ec7684c3bb58b3d0754ca9b9b5eb11c946d06953498be11","js/include/ICU4XSentenceBreakIteratorUtf8.js":"b8f2d32cf3d26d4b7ef3239ba24b2ab7ac6952e9927d2e4a4a6abd55e0af4ccd","js/include/ICU4XSentenceSegmenter.d.ts":"20b3e3f0770109c50dbd9a61574544e39c2941b6dfb00ea4c37491a2b08a4f20","js/include/ICU4XSentenceSegmenter.js":"a383a4d6596cceda9c67cf0b4443fbe8177ef3dc4afbc9c9d98fde2fcb0c212e","js/include/ICU4XTime.d.ts":"179cc8aadcf1ce8c57ecad196bf1fbba1958827230bb44f9c204050c5e74cde2","js/include/ICU4XTime.js":"f8d71a8d31a1558aaa06229b66def15d4ab26a414898a8bab017176d46efb7df","js/include/ICU4XTimeFormatter.d.ts":"5f8dba343a5822d27b173c2327b81bcea003c012f4536b92b7113259e9c01c84","js/include/ICU4XTimeFormatter.js":"988762e4117fbce07535a0918709e9758f66667173dbe168ed50514f1d1941e0","js/include/ICU4XTimeLength.d.ts":"b0c182c13844ae3f5f2eea7ff83d94185889782332097b80ebf3ebdae38023f1","js/include/ICU4XTimeLength.js":"0cbbbba9443099f57d8bd2ebf35a187298796d641c416958658007e9f2a30080","js/include/ICU4XTimeZoneFormatter.d.ts":"6df528d588b2f6732a95de7bbf451c74ae6951873d8af38c69db31df9f013662","js/include/ICU4XTimeZoneFormatter.js":"597c21cdd50a5804d43e6626d907996afa09a3fd2a41b5da5bb929d79bb28be7","js/include/ICU4XTransformResult.d.ts":"3cc2c7b95b19d3893ee20bbd8c826f82af0bf3cf49a2f664345d91dfdd144d59","js/include/ICU4XTransformResult.js":"008db4e4c749e29116ae7d47e8f86ba383f8edacaeb507cee624281cf35dc724","js/include/ICU4XUnicodeSetData.d.ts":"8bbc14c8461010a8327197c5222db924ae6766a75cfeb0596e9812ed7cdc502f","js/include/ICU4XUnicodeSetData.js":"bde864cc0089af51169cbde08bbafc5805f726cf85edf5f7b08e627a47c5fe15","js/include/ICU4XWeekCalculator.d.ts":"b78e0f45bb0dffdd445f9868e2f82a0e883bd9d98487e5fd3f83f539fe086ca6","js/include/ICU4XWeekCalculator.js":"1ebe2adbf71aae5d758a239e992d8c8980a0e96390441de6b3f9eeb97d08f926","js/include/ICU4XWeekOf.d.ts":"a668ca6a8cad17fdda6f91e86b78fb839d3a77280bf6b82102f96c52acb2105f","js/include/ICU4XWeekOf.js":"baa59cc4dc4cd81eb8fe10cc30a88c36bc3d733e28a0379ae50abd987a326038","js/include/ICU4XWeekRelativeUnit.d.ts":"62f25b2de9eb8ae942b48213f7e7eb85eae23ea0d4c32e542985d83f26b3bbeb","js/include/ICU4XWeekRelativeUnit.js":"2aabbb5d149bbfcf0a1b9b53c3a53b3fad76af1c310dbea661db76a6252cd632","js/include/ICU4XWordBreakIteratorLatin1.d.ts":"61a078fe55d9f4841b4e0cbf015bd6c0d49f4cb88fe6a20fcd1fd521eac268fb","js/include/ICU4XWordBreakIteratorLatin1.js":"78ce9ac8660b08e28e520ec9c8af4b77732ea150caa167bd9c809a3ab6af1807","js/include/ICU4XWordBreakIteratorUtf16.d.ts":"2f4d9cc55c1a651b4d71685d2c6875c8325716dfe5c34ed92be976787ecabf1d","js/include/ICU4XWordBreakIteratorUtf16.js":"db426aee8c0490220efeea8f11fab669a1d09dd4f1d81dea8332d5b70da40a47","js/include/ICU4XWordBreakIteratorUtf8.d.ts":"d595d92f6e458a31d487dfa10d057d5386a7c871d7bfee28dd678c7fee386bfe","js/include/ICU4XWordBreakIteratorUtf8.js":"3f2e86fe6ae74f2d3f9db4ce22c884cfce154556e38648ac5500876a5422bd7e","js/include/ICU4XWordSegmenter.d.ts":"dae3b62c026586df4ec332893a0aa397e85ab08a3b53ce7932b5c8366585593e","js/include/ICU4XWordSegmenter.js":"5e58900690ab8c858e23a9bcd66de4afb1cbe98c9669356b4678d9f7098ce843","js/include/ICU4XZonedDateTimeFormatter.d.ts":"ecf019baa608b3202375bc7ede5e975f4a3d8bc01da808d2fd1ae613bc302648","js/include/ICU4XZonedDateTimeFormatter.js":"530ffb402a51ca286ae83d95e7f2f0dd1a4840957f77c40dcf79937cbbe644b8","js/include/diplomat-runtime.d.ts":"78d7de59ac7564fd1dd4c13361b7e674d6c11dd8b0a3fb980cfdc250723cddd9","js/include/diplomat-runtime.js":"381cb7c57836cdbc102f12434e03cb07377c5a7a7e2d2744463f056df23a6574","js/include/diplomat-wasm.mjs":"49cb8c515b5279e2905a6222d6353e504a06cf1399c1a8e985bc0d27ad0eba46","js/include/index.d.ts":"ab9f6831c8e192c0d290c48975cdba95e11f37547105b755dd6ce6bdc4b4dfb0","js/include/index.js":"a56b713246f376474fa14700fbf37abc151b123c3a5c82f5e111855446193257","src/bidi.rs":"d6d677d5f8a4e6f04179d7e5977af35c22e3b00d5b9f81495b7972a2d4d7ee40","src/calendar.rs":"60c4fcce0a7af922a1e3f426fa99439823c6de258a2f19ee57118b2ea26b8355","src/collator.rs":"43dba2b8ebbaddc06255ff0dd0cff5253c571926be917580c9a2972ea9a011d0","src/common.rs":"4a90f75f9199f03d7b672a05fe1c8dde7c4502f5e879a34070cae1ed884da1a4","src/data_struct.rs":"9b0f2c1e1c5b1c819779d6864c0dfec8d93a60e9c00268c65d70ea21ed4420a4","src/date.rs":"a24ff5eaa600be4a6788d62aac17e4440e80b371ff17e0bdd9d07af5cd037989","src/datetime.rs":"a554450cc1bb232cddbb0c1d7d468fff92202c3fda2064f5f1f36ae5db5d3134","src/datetime_formatter.rs":"ecd6956df262d17e52e19b99fec87ba92f2c50202be5ce88c60bbdbcfc0e89a0","src/decimal.rs":"b576231965373ddb08939b8cd41ac8692663275189414a6436a96141b16080aa","src/displaynames.rs":"201d838259f28b40304406324a198264b4d074908bc90dc21dd772a66a7abfb5","src/errors.rs":"2c5656726a0b220678fa39fec0b624e34f774ffda4ce9f7f24b05bbdfe46a6f5","src/fallbacker.rs":"b8dff1ac8d004f7ee2e667a38f877ad217e65d9ddaff240e50f5892a2826b072","src/fixed_decimal.rs":"68244e584dc14986557f461772d602c9161a4fa7a6b79df9070f0259da32a78d","src/lib.rs":"6dd0669aad14239bb09bf3efd63ea89f6c47a8750be84d5177a9ebfcdf3da305","src/list.rs":"869119afa48ea814f552b393ade0b169b27f81708de8777a5a7316ce52588d5e","src/locale.rs":"bdc70fead361e0441284790bec67c4785b4397b8c4b39c33e1a93f95e249f9a4","src/locid_transform.rs":"befe78fe020a2718b6cccf13ac666afff9e49d7103aa6752d5ac9b7e89670adb","src/logging.rs":"e979d7168991327b868d907cf0d3d8ef8658c1eaed0dc8eff9bb8945e8754057","src/metazone_calculator.rs":"0268b6ac079f39ff0d955e74c796933d37aa9f73cd9f7cc878456b303a4293e3","src/normalizer.rs":"0341b399a1b5c8849aa2ba109a5e84b4cd432def06bd8580106c21ed5f35741d","src/normalizer_properties.rs":"da1c254ec30d2b318fbb462ebe6434f8c5dce5fb47c180af191f776fd7cee0aa","src/pluralrules.rs":"15223e62b94a8db04b05a05c14a3d026a02fae77e1e58c82aca5b29431a40577","src/properties_iter.rs":"95689d704c04240a5bf9a8698b0712cebbce48aba09d1530f46477294a055343","src/properties_maps.rs":"89cce0c34f7faf0674b201a39b6e60741dc3338983f72756ee559bc00c2df800","src/properties_names.rs":"1af529c6232d8a06f92c1dafd2806d7e53b91fe6e7411e5d02ebad08a27a8edf","src/properties_sets.rs":"d0ca329a771a4a386761a33d21fd021d37be6ac0cb5e22a9a12b82bd63e2791d","src/properties_unisets.rs":"9914e1fd10116a89896759d7f098cf2dc99fcd494c8b3c8e97c20714e56a8db1","src/provider.rs":"863bf34b0a30d2ed017593ce4f3ee87c258fa7900097351630a910b4ec0bc5a8","src/script.rs":"4ccbab3d2aafb908e84bd0777623ace94f7d860da3237583208523eb6b0d5b41","src/segmenter_grapheme.rs":"d80c15da492426947ace987af9cd6acdcb20996d39642b770cf800b9f1eef207","src/segmenter_line.rs":"64a5255076b414af984211cc62b93ca9b432f289e2951d52d39d78b5545d240f","src/segmenter_sentence.rs":"1b47a5818d54d1bd9aa61eaccb06b45e1362b636d5eaa097bea9e1044e1408a0","src/segmenter_word.rs":"eaebc6be36e2524d457a577bda5c13c60a651c9e3822b016aaf9986c222b35ef","src/time.rs":"ca62f4a84863e8812f1567acf2c05599b367464f26bf5a324d4004ba61c7da70","src/timezone.rs":"e032c27df73e398b71c358d7d00d6dcd87ca1b8ba100201793dca1a6675e0d03","src/timezone_formatter.rs":"936377a57eca9c3191d58103f17b816fdfa6e3011c420cb13373116cbf11bd65","src/wasm_glue.rs":"ac2d6d807b0b67bbe058b328c270364ac153c9a2de6471650c2a38ef10271f97","src/week.rs":"e0ff4f35e9dfc51eb6676eb34e450e476b5c44291ffe0422dc239c5741833907","src/zoned_formatter.rs":"bc7b808417086880e0cdb21585327bbd3e16500e2f27965a43a01a9d8eb3fb80","tests/missing_apis.txt":"59c9e555fc3aa93046c85313bd533982c1f93282c834a6594b90d57d49d7f871"},"package":"3c29e1e7407081a5e425b295ef28526ca4c3cd7ce4475e1769c2863bb18b9305"} \ No newline at end of file diff --git a/third_party/rust/icu_capi/Cargo.toml b/third_party/rust/icu_capi/Cargo.toml new file mode 100644 index 000000000000..a36756da3bc3 --- /dev/null +++ b/third_party/rust/icu_capi/Cargo.toml @@ -0,0 +1,248 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2021" +name = "icu_capi" +version = "1.2.2" +authors = ["The ICU4X Project Developers"] +include = [ + "src/**/*", + "examples/**/*", + "benches/**/*", + "tests/**/*", + "**/include/**/*", + "Cargo.toml", + "LICENSE", + "README.md", +] +description = "C interface to ICU4X" +readme = "README.md" +categories = ["internationalization"] +license = "Unicode-DFS-2016" +repository = "https://github.com/unicode-org/icu4x" +resolver = "2" + +[package.metadata.cargo-all-features] +denylist = [ + "bench", + "logging", + "cpp_default", + "wasm_default", +] +max_combination_size = 2 + +[package.metadata.docs.rs] +all-features = true + +[dependencies.diplomat] +version = "0.5.2" + +[dependencies.diplomat-runtime] +version = "0.5.2" + +[dependencies.fixed_decimal] +version = "0.5.2" +features = ["ryu"] +optional = true + +[dependencies.icu_calendar] +version = "1.2.0" +optional = true + +[dependencies.icu_collator] +version = "1.2.0" +optional = true + +[dependencies.icu_collections] +version = "1.2.0" +optional = true + +[dependencies.icu_datetime] +version = "1.2.0" +optional = true + +[dependencies.icu_decimal] +version = "1.2.0" +optional = true + +[dependencies.icu_displaynames] +version = "0.10.0" +optional = true + +[dependencies.icu_list] +version = "1.2.0" +optional = true + +[dependencies.icu_locid] +version = "1.2.0" + +[dependencies.icu_locid_transform] +version = "1.2.0" +optional = true + +[dependencies.icu_normalizer] +version = "1.2.0" +optional = true + +[dependencies.icu_plurals] +version = "1.2.0" +optional = true + +[dependencies.icu_properties] +version = "1.2.0" +features = ["bidi"] +optional = true + +[dependencies.icu_provider] +version = "1.2.0" + +[dependencies.icu_provider_adapters] +version = "1.2.0" + +[dependencies.icu_provider_blob] +version = "1.2.0" +optional = true + +[dependencies.icu_segmenter] +version = "1.2.0" +optional = true + +[dependencies.icu_testdata] +version = "1.2.0" +features = ["icu_segmenter"] +optional = true + +[dependencies.icu_timezone] +version = "1.2.0" +optional = true + +[dependencies.serde] +version = "1.0" +optional = true +default-features = false + +[dependencies.tinystr] +version = "0.7.1" +default-features = false + +[dependencies.unicode-bidi] +version = "0.3.13" +optional = true +default-features = false + +[dependencies.writeable] +version = "0.5.1" + +[features] +any_provider = [] +buffer_provider = [ + "dep:icu_provider_blob", + "dep:serde", + "icu_calendar?/serde", + "icu_collator?/serde", + "icu_datetime?/serde", + "icu_decimal?/serde", + "icu_displaynames?/serde", + "icu_list?/serde", + "icu_locid_transform?/serde", + "icu_locid/serde", + "icu_normalizer?/serde", + "icu_plurals?/serde", + "icu_properties?/serde", + "icu_provider/serde", + "icu_provider_adapters/serde", + "icu_segmenter?/serde", + "icu_testdata?/buffer", + "icu_timezone?/serde", +] +cpp_default = [ + "provider_test", + "logging", + "simple_logger", +] +default = [ + "any_provider", + "default_components", +] +default_components = [ + "icu_calendar", + "icu_collator", + "icu_datetime", + "icu_decimal", + "icu_list", + "icu_locid_transform", + "icu_normalizer", + "icu_plurals", + "icu_properties", + "icu_segmenter", + "icu_timezone", +] +icu_calendar = ["dep:icu_calendar"] +icu_collator = ["dep:icu_collator"] +icu_datetime = [ + "dep:icu_datetime", + "dep:icu_calendar", + "dep:icu_timezone", + "dep:icu_decimal", + "dep:icu_plurals", +] +icu_decimal = [ + "dep:icu_decimal", + "dep:fixed_decimal", +] +icu_displaynames = ["dep:icu_displaynames"] +icu_list = ["dep:icu_list"] +icu_locid_transform = ["dep:icu_locid_transform"] +icu_normalizer = ["dep:icu_normalizer"] +icu_plurals = [ + "dep:icu_plurals", + "dep:fixed_decimal", +] +icu_properties = [ + "dep:icu_properties", + "dep:icu_collections", + "dep:unicode-bidi", +] +icu_segmenter = ["dep:icu_segmenter"] +icu_timezone = [ + "dep:icu_timezone", + "dep:icu_calendar", +] +logging = [ + "icu_provider/log_error_context", + "dep:log", +] +provider_fs = [ + "dep:icu_provider_fs", + "buffer_provider", +] +provider_test = ["dep:icu_testdata"] +simple_logger = ["dep:simple_logger"] +wasm_default = [ + "buffer_provider", + "logging", +] + +[target."cfg(not(any(target_arch = \"wasm32\", target_os = \"none\")))".dependencies.icu_provider_fs] +version = "1.2.0" +optional = true + +[target."cfg(not(target_arch = \"wasm32\"))".dependencies.log] +version = "0.4" +optional = true + +[target."cfg(not(target_arch = \"wasm32\"))".dependencies.simple_logger] +version = "4.1.0" +optional = true + +[target."cfg(target_arch = \"wasm32\")".dependencies.log] +version = "0.4" diff --git a/third_party/rust/icu_capi/LICENSE b/third_party/rust/icu_capi/LICENSE new file mode 100644 index 000000000000..9858d01abf58 --- /dev/null +++ b/third_party/rust/icu_capi/LICENSE @@ -0,0 +1,51 @@ +UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE + +See Terms of Use +for definitions of Unicode Inc.’s Data Files and Software. + +NOTICE TO USER: Carefully read the following legal agreement. +BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S +DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"), +YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE +TERMS AND CONDITIONS OF THIS AGREEMENT. +IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE +THE DATA FILES OR SOFTWARE. + +COPYRIGHT AND PERMISSION NOTICE + +Copyright © 1991-2022 Unicode, Inc. All rights reserved. +Distributed under the Terms of Use in https://www.unicode.org/copyright.html. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Unicode data files and any associated documentation +(the "Data Files") or Unicode software and any associated documentation +(the "Software") to deal in the Data Files or Software +without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, and/or sell copies of +the Data Files or Software, and to permit persons to whom the Data Files +or Software are furnished to do so, provided that either +(a) this copyright and permission notice appear with all copies +of the Data Files or Software, or +(b) this copyright and permission notice appear in associated +Documentation. + +THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT OF THIRD PARTY RIGHTS. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS +NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL +DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THE DATA FILES OR SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, +use or other dealings in these Data Files or Software without prior +written authorization of the copyright holder. + +— + +Portions of ICU4X may have been adapted from ICU4C and/or ICU4J. +ICU 1.8.1 to ICU 57.1 © 1995-2016 International Business Machines Corporation and others. diff --git a/third_party/rust/icu_capi/README.md b/third_party/rust/icu_capi/README.md new file mode 100644 index 000000000000..d6adb5f919b3 --- /dev/null +++ b/third_party/rust/icu_capi/README.md @@ -0,0 +1,26 @@ +# icu_capi [![crates.io](https://img.shields.io/crates/v/icu_capi)](https://crates.io/crates/icu_capi) + +This crate contains the source of truth for the [Diplomat](https://github.com/rust-diplomat/diplomat)-generated +FFI bindings. This generates the C, C++, JavaScript, and TypeScript bindings. This crate also contains the `extern "C"` +FFI for ICU4X. + +While the types in this crate are public, APIs from this crate are *not intended to be used from Rust* +and as such this crate may unpredictably change its Rust API across compatible semver versions. The `extern "C"` APIs exposed +by this crate, while not directly documented, are stable within the same major semver version, as are the bindings exposed under +the `cpp/` and `js/` folders. + +This crate may still be explored for documentation on docs.rs, and there are generated language-specific docs available as well. +C++ has sphinx docs in `cpp/docs/`, and the header files also contain documentation comments. The JS version has sphinx docs under +`js/docs`, and the TypeScript sources in `js/include` are compatible with `tsdoc`. + +This crate is `no_std` and will not typically build as a staticlib on its own. If you wish to link to it you should prefer +using `icu_capi_staticlib`, or for more esoteric platforms you may write a shim crate depending on this crate that hooks in +an allocator and panic hook. + +More information on using ICU4X from C++ can be found in [our tutorial]. + +[our tutorial]: https://github.com/unicode-org/icu4x/blob/main/docs/tutorials/cpp.md + +## More Information + +For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x). diff --git a/third_party/rust/icu_capi/c/README.md b/third_party/rust/icu_capi/c/README.md new file mode 100644 index 000000000000..c0bfbeca1958 --- /dev/null +++ b/third_party/rust/icu_capi/c/README.md @@ -0,0 +1,18 @@ +# C FFI for ICU4X + +This folder contains the C FFI for ICU4X. To re-generate the bindings run: + +```sh +cargo make diplomat-install +cargo make diplomat-gen-c +``` + +Or re-generate all of the bindings: + +```sh +cargo make diplomat-gen +``` + +## More Information + +For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x). diff --git a/third_party/rust/icu_capi/c/examples/fixeddecimal_tiny/README.md b/third_party/rust/icu_capi/c/examples/fixeddecimal_tiny/README.md new file mode 100644 index 000000000000..0aba7c34190f --- /dev/null +++ b/third_party/rust/icu_capi/c/examples/fixeddecimal_tiny/README.md @@ -0,0 +1,8 @@ +# Tiny FixedDecimal FFI Demo + +This example contains tooling to build a size-optimized binary using FixedDecimal and FixedDecimalFormatter in C over FFI. + +Prerequisites: `clang` and `lld` 14. `apt-get install clang lld` *might* work, but if you run into errors, refer to the following thread for tips: + +https://github.com/rust-lang/rust/issues/60059 + diff --git a/third_party/rust/icu_capi/c/include/CodePointRangeIterator.h b/third_party/rust/icu_capi/c/include/CodePointRangeIterator.h new file mode 100644 index 000000000000..36d6d23175a0 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/CodePointRangeIterator.h @@ -0,0 +1,30 @@ +#ifndef CodePointRangeIterator_H +#define CodePointRangeIterator_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct CodePointRangeIterator CodePointRangeIterator; +#ifdef __cplusplus +} // namespace capi +#endif +#include "CodePointRangeIteratorResult.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +CodePointRangeIteratorResult CodePointRangeIterator_next(CodePointRangeIterator* self); +void CodePointRangeIterator_destroy(CodePointRangeIterator* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/CodePointRangeIteratorResult.h b/third_party/rust/icu_capi/c/include/CodePointRangeIteratorResult.h new file mode 100644 index 000000000000..846873be11f3 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/CodePointRangeIteratorResult.h @@ -0,0 +1,32 @@ +#ifndef CodePointRangeIteratorResult_H +#define CodePointRangeIteratorResult_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct CodePointRangeIteratorResult { + uint32_t start; + uint32_t end; + bool done; +} CodePointRangeIteratorResult; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void CodePointRangeIteratorResult_destroy(CodePointRangeIteratorResult* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XAnyCalendarKind.h b/third_party/rust/icu_capi/c/include/ICU4XAnyCalendarKind.h new file mode 100644 index 000000000000..035ec9ef17ba --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XAnyCalendarKind.h @@ -0,0 +1,46 @@ +#ifndef ICU4XAnyCalendarKind_H +#define ICU4XAnyCalendarKind_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XAnyCalendarKind { + ICU4XAnyCalendarKind_Iso = 0, + ICU4XAnyCalendarKind_Gregorian = 1, + ICU4XAnyCalendarKind_Buddhist = 2, + ICU4XAnyCalendarKind_Japanese = 3, + ICU4XAnyCalendarKind_JapaneseExtended = 4, + ICU4XAnyCalendarKind_Ethiopian = 5, + ICU4XAnyCalendarKind_EthiopianAmeteAlem = 6, + ICU4XAnyCalendarKind_Indian = 7, + ICU4XAnyCalendarKind_Coptic = 8, +} ICU4XAnyCalendarKind; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XLocale.h" +#include "diplomat_result_ICU4XAnyCalendarKind_void.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_ICU4XAnyCalendarKind_void ICU4XAnyCalendarKind_get_for_locale(const ICU4XLocale* locale); + +diplomat_result_ICU4XAnyCalendarKind_void ICU4XAnyCalendarKind_get_for_bcp47(const char* s_data, size_t s_len); + +diplomat_result_void_ICU4XError ICU4XAnyCalendarKind_bcp47(ICU4XAnyCalendarKind self, DiplomatWriteable* write); +void ICU4XAnyCalendarKind_destroy(ICU4XAnyCalendarKind* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XBidi.h b/third_party/rust/icu_capi/c/include/ICU4XBidi.h new file mode 100644 index 000000000000..1ed7cfc8c245 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XBidi.h @@ -0,0 +1,45 @@ +#ifndef ICU4XBidi_H +#define ICU4XBidi_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XBidi ICU4XBidi; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XBidi_ICU4XError.h" +#include "ICU4XBidiInfo.h" +#include "ICU4XReorderedIndexMap.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XBidi_ICU4XError ICU4XBidi_create(const ICU4XDataProvider* provider); + +ICU4XBidiInfo* ICU4XBidi_for_text(const ICU4XBidi* self, const char* text_data, size_t text_len, uint8_t default_level); + +ICU4XReorderedIndexMap* ICU4XBidi_reorder_visual(const ICU4XBidi* self, const uint8_t* levels_data, size_t levels_len); + +bool ICU4XBidi_level_is_rtl(uint8_t level); + +bool ICU4XBidi_level_is_ltr(uint8_t level); + +uint8_t ICU4XBidi_level_rtl(); + +uint8_t ICU4XBidi_level_ltr(); +void ICU4XBidi_destroy(ICU4XBidi* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XBidiDirection.h b/third_party/rust/icu_capi/c/include/ICU4XBidiDirection.h new file mode 100644 index 000000000000..33de81d6e9da --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XBidiDirection.h @@ -0,0 +1,32 @@ +#ifndef ICU4XBidiDirection_H +#define ICU4XBidiDirection_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XBidiDirection { + ICU4XBidiDirection_Ltr = 0, + ICU4XBidiDirection_Rtl = 1, + ICU4XBidiDirection_Mixed = 2, +} ICU4XBidiDirection; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XBidiDirection_destroy(ICU4XBidiDirection* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XBidiInfo.h b/third_party/rust/icu_capi/c/include/ICU4XBidiInfo.h new file mode 100644 index 000000000000..02e8c21659a6 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XBidiInfo.h @@ -0,0 +1,36 @@ +#ifndef ICU4XBidiInfo_H +#define ICU4XBidiInfo_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XBidiInfo ICU4XBidiInfo; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XBidiParagraph.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +size_t ICU4XBidiInfo_paragraph_count(const ICU4XBidiInfo* self); + +ICU4XBidiParagraph* ICU4XBidiInfo_paragraph_at(const ICU4XBidiInfo* self, size_t n); + +size_t ICU4XBidiInfo_size(const ICU4XBidiInfo* self); + +uint8_t ICU4XBidiInfo_level_at(const ICU4XBidiInfo* self, size_t pos); +void ICU4XBidiInfo_destroy(ICU4XBidiInfo* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XBidiParagraph.h b/third_party/rust/icu_capi/c/include/ICU4XBidiParagraph.h new file mode 100644 index 000000000000..269f940cc7d7 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XBidiParagraph.h @@ -0,0 +1,43 @@ +#ifndef ICU4XBidiParagraph_H +#define ICU4XBidiParagraph_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XBidiParagraph ICU4XBidiParagraph; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_void_ICU4XError.h" +#include "ICU4XBidiDirection.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_void_ICU4XError ICU4XBidiParagraph_set_paragraph_in_text(ICU4XBidiParagraph* self, size_t n); + +ICU4XBidiDirection ICU4XBidiParagraph_direction(const ICU4XBidiParagraph* self); + +size_t ICU4XBidiParagraph_size(const ICU4XBidiParagraph* self); + +size_t ICU4XBidiParagraph_range_start(const ICU4XBidiParagraph* self); + +size_t ICU4XBidiParagraph_range_end(const ICU4XBidiParagraph* self); + +diplomat_result_void_ICU4XError ICU4XBidiParagraph_reorder_line(const ICU4XBidiParagraph* self, size_t range_start, size_t range_end, DiplomatWriteable* out); + +uint8_t ICU4XBidiParagraph_level_at(const ICU4XBidiParagraph* self, size_t pos); +void ICU4XBidiParagraph_destroy(ICU4XBidiParagraph* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XCalendar.h b/third_party/rust/icu_capi/c/include/ICU4XCalendar.h new file mode 100644 index 000000000000..9ea6484b5f89 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XCalendar.h @@ -0,0 +1,37 @@ +#ifndef ICU4XCalendar_H +#define ICU4XCalendar_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCalendar ICU4XCalendar; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "diplomat_result_box_ICU4XCalendar_ICU4XError.h" +#include "ICU4XAnyCalendarKind.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XCalendar_ICU4XError ICU4XCalendar_create_for_locale(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +diplomat_result_box_ICU4XCalendar_ICU4XError ICU4XCalendar_create_for_kind(const ICU4XDataProvider* provider, ICU4XAnyCalendarKind kind); + +ICU4XAnyCalendarKind ICU4XCalendar_kind(const ICU4XCalendar* self); +void ICU4XCalendar_destroy(ICU4XCalendar* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XCanonicalCombiningClassMap.h b/third_party/rust/icu_capi/c/include/ICU4XCanonicalCombiningClassMap.h new file mode 100644 index 000000000000..f0fc447ba0d4 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XCanonicalCombiningClassMap.h @@ -0,0 +1,35 @@ +#ifndef ICU4XCanonicalCombiningClassMap_H +#define ICU4XCanonicalCombiningClassMap_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCanonicalCombiningClassMap ICU4XCanonicalCombiningClassMap; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError ICU4XCanonicalCombiningClassMap_create(const ICU4XDataProvider* provider); + +uint8_t ICU4XCanonicalCombiningClassMap_get(const ICU4XCanonicalCombiningClassMap* self, char32_t ch); + +uint8_t ICU4XCanonicalCombiningClassMap_get32(const ICU4XCanonicalCombiningClassMap* self, uint32_t ch); +void ICU4XCanonicalCombiningClassMap_destroy(ICU4XCanonicalCombiningClassMap* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XCanonicalComposition.h b/third_party/rust/icu_capi/c/include/ICU4XCanonicalComposition.h new file mode 100644 index 000000000000..e9ae621739fb --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XCanonicalComposition.h @@ -0,0 +1,33 @@ +#ifndef ICU4XCanonicalComposition_H +#define ICU4XCanonicalComposition_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCanonicalComposition ICU4XCanonicalComposition; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XCanonicalComposition_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XCanonicalComposition_ICU4XError ICU4XCanonicalComposition_create(const ICU4XDataProvider* provider); + +char32_t ICU4XCanonicalComposition_compose(const ICU4XCanonicalComposition* self, char32_t starter, char32_t second); +void ICU4XCanonicalComposition_destroy(ICU4XCanonicalComposition* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XCanonicalDecomposition.h b/third_party/rust/icu_capi/c/include/ICU4XCanonicalDecomposition.h new file mode 100644 index 000000000000..d18d108b905e --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XCanonicalDecomposition.h @@ -0,0 +1,34 @@ +#ifndef ICU4XCanonicalDecomposition_H +#define ICU4XCanonicalDecomposition_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCanonicalDecomposition ICU4XCanonicalDecomposition; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError.h" +#include "ICU4XDecomposed.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError ICU4XCanonicalDecomposition_create(const ICU4XDataProvider* provider); + +ICU4XDecomposed ICU4XCanonicalDecomposition_decompose(const ICU4XCanonicalDecomposition* self, char32_t c); +void ICU4XCanonicalDecomposition_destroy(ICU4XCanonicalDecomposition* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XCodePointMapData16.h b/third_party/rust/icu_capi/c/include/ICU4XCodePointMapData16.h new file mode 100644 index 000000000000..19effe2d921f --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XCodePointMapData16.h @@ -0,0 +1,43 @@ +#ifndef ICU4XCodePointMapData16_H +#define ICU4XCodePointMapData16_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCodePointMapData16 ICU4XCodePointMapData16; +#ifdef __cplusplus +} // namespace capi +#endif +#include "CodePointRangeIterator.h" +#include "ICU4XCodePointSetData.h" +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XCodePointMapData16_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +uint16_t ICU4XCodePointMapData16_get(const ICU4XCodePointMapData16* self, char32_t cp); + +uint16_t ICU4XCodePointMapData16_get32(const ICU4XCodePointMapData16* self, uint32_t cp); + +CodePointRangeIterator* ICU4XCodePointMapData16_iter_ranges_for_value(const ICU4XCodePointMapData16* self, uint16_t value); + +CodePointRangeIterator* ICU4XCodePointMapData16_iter_ranges_for_value_complemented(const ICU4XCodePointMapData16* self, uint16_t value); + +ICU4XCodePointSetData* ICU4XCodePointMapData16_get_set_for_value(const ICU4XCodePointMapData16* self, uint16_t value); + +diplomat_result_box_ICU4XCodePointMapData16_ICU4XError ICU4XCodePointMapData16_load_script(const ICU4XDataProvider* provider); +void ICU4XCodePointMapData16_destroy(ICU4XCodePointMapData16* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XCodePointMapData8.h b/third_party/rust/icu_capi/c/include/ICU4XCodePointMapData8.h new file mode 100644 index 000000000000..69a6a46b900a --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XCodePointMapData8.h @@ -0,0 +1,59 @@ +#ifndef ICU4XCodePointMapData8_H +#define ICU4XCodePointMapData8_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCodePointMapData8 ICU4XCodePointMapData8; +#ifdef __cplusplus +} // namespace capi +#endif +#include "CodePointRangeIterator.h" +#include "ICU4XCodePointSetData.h" +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XCodePointMapData8_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +uint8_t ICU4XCodePointMapData8_get(const ICU4XCodePointMapData8* self, char32_t cp); + +uint8_t ICU4XCodePointMapData8_get32(const ICU4XCodePointMapData8* self, uint32_t cp); + +uint32_t ICU4XCodePointMapData8_general_category_to_mask(uint8_t gc); + +CodePointRangeIterator* ICU4XCodePointMapData8_iter_ranges_for_value(const ICU4XCodePointMapData8* self, uint8_t value); + +CodePointRangeIterator* ICU4XCodePointMapData8_iter_ranges_for_value_complemented(const ICU4XCodePointMapData8* self, uint8_t value); + +CodePointRangeIterator* ICU4XCodePointMapData8_iter_ranges_for_mask(const ICU4XCodePointMapData8* self, uint32_t mask); + +ICU4XCodePointSetData* ICU4XCodePointMapData8_get_set_for_value(const ICU4XCodePointMapData8* self, uint8_t value); + +diplomat_result_box_ICU4XCodePointMapData8_ICU4XError ICU4XCodePointMapData8_load_general_category(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointMapData8_ICU4XError ICU4XCodePointMapData8_load_bidi_class(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointMapData8_ICU4XError ICU4XCodePointMapData8_load_east_asian_width(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointMapData8_ICU4XError ICU4XCodePointMapData8_load_line_break(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointMapData8_ICU4XError ICU4XCodePointMapData8_try_grapheme_cluster_break(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointMapData8_ICU4XError ICU4XCodePointMapData8_load_word_break(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointMapData8_ICU4XError ICU4XCodePointMapData8_load_sentence_break(const ICU4XDataProvider* provider); +void ICU4XCodePointMapData8_destroy(ICU4XCodePointMapData8* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XCodePointSetData.h b/third_party/rust/icu_capi/c/include/ICU4XCodePointSetData.h new file mode 100644 index 000000000000..10356e90b7b5 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XCodePointSetData.h @@ -0,0 +1,172 @@ +#ifndef ICU4XCodePointSetData_H +#define ICU4XCodePointSetData_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCodePointSetData ICU4XCodePointSetData; +#ifdef __cplusplus +} // namespace capi +#endif +#include "CodePointRangeIterator.h" +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XCodePointSetData_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +bool ICU4XCodePointSetData_contains(const ICU4XCodePointSetData* self, char32_t cp); + +bool ICU4XCodePointSetData_contains32(const ICU4XCodePointSetData* self, uint32_t cp); + +CodePointRangeIterator* ICU4XCodePointSetData_iter_ranges(const ICU4XCodePointSetData* self); + +CodePointRangeIterator* ICU4XCodePointSetData_iter_ranges_complemented(const ICU4XCodePointSetData* self); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_for_general_category_group(const ICU4XDataProvider* provider, uint32_t group); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_ascii_hex_digit(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_alnum(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_alphabetic(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_bidi_control(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_bidi_mirrored(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_blank(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_cased(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_case_ignorable(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_full_composition_exclusion(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_changes_when_casefolded(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_changes_when_casemapped(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_changes_when_nfkc_casefolded(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_changes_when_lowercased(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_changes_when_titlecased(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_changes_when_uppercased(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_dash(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_deprecated(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_default_ignorable_code_point(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_diacritic(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_emoji_modifier_base(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_emoji_component(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_emoji_modifier(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_emoji(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_emoji_presentation(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_extender(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_extended_pictographic(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_graph(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_grapheme_base(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_grapheme_extend(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_grapheme_link(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_hex_digit(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_hyphen(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_id_continue(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_ideographic(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_id_start(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_ids_binary_operator(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_ids_trinary_operator(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_join_control(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_logical_order_exception(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_lowercase(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_math(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_noncharacter_code_point(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_nfc_inert(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_nfd_inert(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_nfkc_inert(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_nfkd_inert(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_pattern_syntax(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_pattern_white_space(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_prepended_concatenation_mark(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_print(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_quotation_mark(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_radical(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_regional_indicator(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_soft_dotted(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_segment_starter(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_case_sensitive(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_sentence_terminal(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_terminal_punctuation(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_unified_ideograph(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_uppercase(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_variation_selector(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_white_space(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_xdigit(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_xid_continue(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_xid_start(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_for_ecma262(const ICU4XDataProvider* provider, const char* property_name_data, size_t property_name_len); +void ICU4XCodePointSetData_destroy(ICU4XCodePointSetData* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XCollator.h b/third_party/rust/icu_capi/c/include/ICU4XCollator.h new file mode 100644 index 000000000000..973c2cedd96a --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XCollator.h @@ -0,0 +1,40 @@ +#ifndef ICU4XCollator_H +#define ICU4XCollator_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCollator ICU4XCollator; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XCollatorOptionsV1.h" +#include "diplomat_result_box_ICU4XCollator_ICU4XError.h" +#include "ICU4XOrdering.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XCollator_ICU4XError ICU4XCollator_create_v1(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XCollatorOptionsV1 options); + +ICU4XOrdering ICU4XCollator_compare(const ICU4XCollator* self, const char* left_data, size_t left_len, const char* right_data, size_t right_len); + +ICU4XOrdering ICU4XCollator_compare_valid_utf8(const ICU4XCollator* self, const char* left_data, size_t left_len, const char* right_data, size_t right_len); + +ICU4XOrdering ICU4XCollator_compare_utf16(const ICU4XCollator* self, const uint16_t* left_data, size_t left_len, const uint16_t* right_data, size_t right_len); +void ICU4XCollator_destroy(ICU4XCollator* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XCollatorAlternateHandling.h b/third_party/rust/icu_capi/c/include/ICU4XCollatorAlternateHandling.h new file mode 100644 index 000000000000..dfc3d595eb2a --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XCollatorAlternateHandling.h @@ -0,0 +1,32 @@ +#ifndef ICU4XCollatorAlternateHandling_H +#define ICU4XCollatorAlternateHandling_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XCollatorAlternateHandling { + ICU4XCollatorAlternateHandling_Auto = 0, + ICU4XCollatorAlternateHandling_NonIgnorable = 1, + ICU4XCollatorAlternateHandling_Shifted = 2, +} ICU4XCollatorAlternateHandling; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XCollatorAlternateHandling_destroy(ICU4XCollatorAlternateHandling* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XCollatorBackwardSecondLevel.h b/third_party/rust/icu_capi/c/include/ICU4XCollatorBackwardSecondLevel.h new file mode 100644 index 000000000000..659f9b2f1093 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XCollatorBackwardSecondLevel.h @@ -0,0 +1,32 @@ +#ifndef ICU4XCollatorBackwardSecondLevel_H +#define ICU4XCollatorBackwardSecondLevel_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XCollatorBackwardSecondLevel { + ICU4XCollatorBackwardSecondLevel_Auto = 0, + ICU4XCollatorBackwardSecondLevel_Off = 1, + ICU4XCollatorBackwardSecondLevel_On = 2, +} ICU4XCollatorBackwardSecondLevel; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XCollatorBackwardSecondLevel_destroy(ICU4XCollatorBackwardSecondLevel* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XCollatorCaseFirst.h b/third_party/rust/icu_capi/c/include/ICU4XCollatorCaseFirst.h new file mode 100644 index 000000000000..c01eb216d09d --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XCollatorCaseFirst.h @@ -0,0 +1,33 @@ +#ifndef ICU4XCollatorCaseFirst_H +#define ICU4XCollatorCaseFirst_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XCollatorCaseFirst { + ICU4XCollatorCaseFirst_Auto = 0, + ICU4XCollatorCaseFirst_Off = 1, + ICU4XCollatorCaseFirst_LowerFirst = 2, + ICU4XCollatorCaseFirst_UpperFirst = 3, +} ICU4XCollatorCaseFirst; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XCollatorCaseFirst_destroy(ICU4XCollatorCaseFirst* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XCollatorCaseLevel.h b/third_party/rust/icu_capi/c/include/ICU4XCollatorCaseLevel.h new file mode 100644 index 000000000000..cbf686596775 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XCollatorCaseLevel.h @@ -0,0 +1,32 @@ +#ifndef ICU4XCollatorCaseLevel_H +#define ICU4XCollatorCaseLevel_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XCollatorCaseLevel { + ICU4XCollatorCaseLevel_Auto = 0, + ICU4XCollatorCaseLevel_Off = 1, + ICU4XCollatorCaseLevel_On = 2, +} ICU4XCollatorCaseLevel; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XCollatorCaseLevel_destroy(ICU4XCollatorCaseLevel* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XCollatorMaxVariable.h b/third_party/rust/icu_capi/c/include/ICU4XCollatorMaxVariable.h new file mode 100644 index 000000000000..0e5a3a516fec --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XCollatorMaxVariable.h @@ -0,0 +1,34 @@ +#ifndef ICU4XCollatorMaxVariable_H +#define ICU4XCollatorMaxVariable_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XCollatorMaxVariable { + ICU4XCollatorMaxVariable_Auto = 0, + ICU4XCollatorMaxVariable_Space = 1, + ICU4XCollatorMaxVariable_Punctuation = 2, + ICU4XCollatorMaxVariable_Symbol = 3, + ICU4XCollatorMaxVariable_Currency = 4, +} ICU4XCollatorMaxVariable; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XCollatorMaxVariable_destroy(ICU4XCollatorMaxVariable* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XCollatorNumeric.h b/third_party/rust/icu_capi/c/include/ICU4XCollatorNumeric.h new file mode 100644 index 000000000000..4dd2ec0408f2 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XCollatorNumeric.h @@ -0,0 +1,32 @@ +#ifndef ICU4XCollatorNumeric_H +#define ICU4XCollatorNumeric_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XCollatorNumeric { + ICU4XCollatorNumeric_Auto = 0, + ICU4XCollatorNumeric_Off = 1, + ICU4XCollatorNumeric_On = 2, +} ICU4XCollatorNumeric; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XCollatorNumeric_destroy(ICU4XCollatorNumeric* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XCollatorOptionsV1.h b/third_party/rust/icu_capi/c/include/ICU4XCollatorOptionsV1.h new file mode 100644 index 000000000000..dc73557efe67 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XCollatorOptionsV1.h @@ -0,0 +1,50 @@ +#ifndef ICU4XCollatorOptionsV1_H +#define ICU4XCollatorOptionsV1_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XCollatorStrength.h" +#include "ICU4XCollatorAlternateHandling.h" +#include "ICU4XCollatorCaseFirst.h" +#include "ICU4XCollatorMaxVariable.h" +#include "ICU4XCollatorCaseLevel.h" +#include "ICU4XCollatorNumeric.h" +#include "ICU4XCollatorBackwardSecondLevel.h" +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCollatorOptionsV1 { + ICU4XCollatorStrength strength; + ICU4XCollatorAlternateHandling alternate_handling; + ICU4XCollatorCaseFirst case_first; + ICU4XCollatorMaxVariable max_variable; + ICU4XCollatorCaseLevel case_level; + ICU4XCollatorNumeric numeric; + ICU4XCollatorBackwardSecondLevel backward_second_level; +} ICU4XCollatorOptionsV1; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XCollatorStrength.h" +#include "ICU4XCollatorAlternateHandling.h" +#include "ICU4XCollatorCaseFirst.h" +#include "ICU4XCollatorMaxVariable.h" +#include "ICU4XCollatorCaseLevel.h" +#include "ICU4XCollatorNumeric.h" +#include "ICU4XCollatorBackwardSecondLevel.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XCollatorOptionsV1_destroy(ICU4XCollatorOptionsV1* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XCollatorStrength.h b/third_party/rust/icu_capi/c/include/ICU4XCollatorStrength.h new file mode 100644 index 000000000000..f230214febad --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XCollatorStrength.h @@ -0,0 +1,35 @@ +#ifndef ICU4XCollatorStrength_H +#define ICU4XCollatorStrength_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XCollatorStrength { + ICU4XCollatorStrength_Auto = 0, + ICU4XCollatorStrength_Primary = 1, + ICU4XCollatorStrength_Secondary = 2, + ICU4XCollatorStrength_Tertiary = 3, + ICU4XCollatorStrength_Quaternary = 4, + ICU4XCollatorStrength_Identical = 5, +} ICU4XCollatorStrength; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XCollatorStrength_destroy(ICU4XCollatorStrength* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XComposingNormalizer.h b/third_party/rust/icu_capi/c/include/ICU4XComposingNormalizer.h new file mode 100644 index 000000000000..1798af0d8e3e --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XComposingNormalizer.h @@ -0,0 +1,38 @@ +#ifndef ICU4XComposingNormalizer_H +#define ICU4XComposingNormalizer_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XComposingNormalizer ICU4XComposingNormalizer; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XComposingNormalizer_ICU4XError.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XComposingNormalizer_ICU4XError ICU4XComposingNormalizer_create_nfc(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XComposingNormalizer_ICU4XError ICU4XComposingNormalizer_create_nfkc(const ICU4XDataProvider* provider); + +diplomat_result_void_ICU4XError ICU4XComposingNormalizer_normalize(const ICU4XComposingNormalizer* self, const char* s_data, size_t s_len, DiplomatWriteable* write); + +bool ICU4XComposingNormalizer_is_normalized(const ICU4XComposingNormalizer* self, const char* s_data, size_t s_len); +void ICU4XComposingNormalizer_destroy(ICU4XComposingNormalizer* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XCustomTimeZone.h b/third_party/rust/icu_capi/c/include/ICU4XCustomTimeZone.h new file mode 100644 index 000000000000..fe6181a1049b --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XCustomTimeZone.h @@ -0,0 +1,81 @@ +#ifndef ICU4XCustomTimeZone_H +#define ICU4XCustomTimeZone_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCustomTimeZone ICU4XCustomTimeZone; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_box_ICU4XCustomTimeZone_ICU4XError.h" +#include "diplomat_result_void_ICU4XError.h" +#include "diplomat_result_int32_t_ICU4XError.h" +#include "diplomat_result_bool_ICU4XError.h" +#include "ICU4XMetazoneCalculator.h" +#include "ICU4XIsoDateTime.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XCustomTimeZone_ICU4XError ICU4XCustomTimeZone_create_from_string(const char* s_data, size_t s_len); + +ICU4XCustomTimeZone* ICU4XCustomTimeZone_create_empty(); + +ICU4XCustomTimeZone* ICU4XCustomTimeZone_create_utc(); + +diplomat_result_void_ICU4XError ICU4XCustomTimeZone_try_set_gmt_offset_seconds(ICU4XCustomTimeZone* self, int32_t offset_seconds); + +void ICU4XCustomTimeZone_clear_gmt_offset(ICU4XCustomTimeZone* self); + +diplomat_result_int32_t_ICU4XError ICU4XCustomTimeZone_gmt_offset_seconds(const ICU4XCustomTimeZone* self); + +diplomat_result_bool_ICU4XError ICU4XCustomTimeZone_is_gmt_offset_positive(const ICU4XCustomTimeZone* self); + +diplomat_result_bool_ICU4XError ICU4XCustomTimeZone_is_gmt_offset_zero(const ICU4XCustomTimeZone* self); + +diplomat_result_bool_ICU4XError ICU4XCustomTimeZone_gmt_offset_has_minutes(const ICU4XCustomTimeZone* self); + +diplomat_result_bool_ICU4XError ICU4XCustomTimeZone_gmt_offset_has_seconds(const ICU4XCustomTimeZone* self); + +diplomat_result_void_ICU4XError ICU4XCustomTimeZone_try_set_time_zone_id(ICU4XCustomTimeZone* self, const char* id_data, size_t id_len); + +void ICU4XCustomTimeZone_clear_time_zone_id(ICU4XCustomTimeZone* self); + +diplomat_result_void_ICU4XError ICU4XCustomTimeZone_time_zone_id(const ICU4XCustomTimeZone* self, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XCustomTimeZone_try_set_metazone_id(ICU4XCustomTimeZone* self, const char* id_data, size_t id_len); + +void ICU4XCustomTimeZone_clear_metazone_id(ICU4XCustomTimeZone* self); + +diplomat_result_void_ICU4XError ICU4XCustomTimeZone_metazone_id(const ICU4XCustomTimeZone* self, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XCustomTimeZone_try_set_zone_variant(ICU4XCustomTimeZone* self, const char* id_data, size_t id_len); + +void ICU4XCustomTimeZone_clear_zone_variant(ICU4XCustomTimeZone* self); + +diplomat_result_void_ICU4XError ICU4XCustomTimeZone_zone_variant(const ICU4XCustomTimeZone* self, DiplomatWriteable* write); + +void ICU4XCustomTimeZone_set_standard_time(ICU4XCustomTimeZone* self); + +void ICU4XCustomTimeZone_set_daylight_time(ICU4XCustomTimeZone* self); + +diplomat_result_bool_ICU4XError ICU4XCustomTimeZone_is_standard_time(const ICU4XCustomTimeZone* self); + +diplomat_result_bool_ICU4XError ICU4XCustomTimeZone_is_daylight_time(const ICU4XCustomTimeZone* self); + +void ICU4XCustomTimeZone_maybe_calculate_metazone(ICU4XCustomTimeZone* self, const ICU4XMetazoneCalculator* metazone_calculator, const ICU4XIsoDateTime* local_datetime); +void ICU4XCustomTimeZone_destroy(ICU4XCustomTimeZone* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XDataProvider.h b/third_party/rust/icu_capi/c/include/ICU4XDataProvider.h new file mode 100644 index 000000000000..fd8b35b78778 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XDataProvider.h @@ -0,0 +1,46 @@ +#ifndef ICU4XDataProvider_H +#define ICU4XDataProvider_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XDataProvider ICU4XDataProvider; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_box_ICU4XDataProvider_ICU4XError.h" +#include "diplomat_result_void_ICU4XError.h" +#include "ICU4XLocaleFallbacker.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XDataProvider_ICU4XError ICU4XDataProvider_create_fs(const char* path_data, size_t path_len); + +ICU4XDataProvider* ICU4XDataProvider_create_test(); + +diplomat_result_box_ICU4XDataProvider_ICU4XError ICU4XDataProvider_create_from_byte_slice(const uint8_t* blob_data, size_t blob_len); + +ICU4XDataProvider* ICU4XDataProvider_create_empty(); + +diplomat_result_void_ICU4XError ICU4XDataProvider_fork_by_key(ICU4XDataProvider* self, ICU4XDataProvider* other); + +diplomat_result_void_ICU4XError ICU4XDataProvider_fork_by_locale(ICU4XDataProvider* self, ICU4XDataProvider* other); + +diplomat_result_void_ICU4XError ICU4XDataProvider_enable_locale_fallback(ICU4XDataProvider* self); + +diplomat_result_void_ICU4XError ICU4XDataProvider_enable_locale_fallback_with(ICU4XDataProvider* self, const ICU4XLocaleFallbacker* fallbacker); +void ICU4XDataProvider_destroy(ICU4XDataProvider* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XDataStruct.h b/third_party/rust/icu_capi/c/include/ICU4XDataStruct.h new file mode 100644 index 000000000000..a07ff02fb8e4 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XDataStruct.h @@ -0,0 +1,30 @@ +#ifndef ICU4XDataStruct_H +#define ICU4XDataStruct_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XDataStruct ICU4XDataStruct; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_box_ICU4XDataStruct_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XDataStruct_ICU4XError ICU4XDataStruct_create_decimal_symbols_v1(const char* plus_sign_prefix_data, size_t plus_sign_prefix_len, const char* plus_sign_suffix_data, size_t plus_sign_suffix_len, const char* minus_sign_prefix_data, size_t minus_sign_prefix_len, const char* minus_sign_suffix_data, size_t minus_sign_suffix_len, const char* decimal_separator_data, size_t decimal_separator_len, const char* grouping_separator_data, size_t grouping_separator_len, uint8_t primary_group_size, uint8_t secondary_group_size, uint8_t min_group_size, const char32_t* digits_data, size_t digits_len); +void ICU4XDataStruct_destroy(ICU4XDataStruct* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XDate.h b/third_party/rust/icu_capi/c/include/ICU4XDate.h new file mode 100644 index 000000000000..e88128678899 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XDate.h @@ -0,0 +1,66 @@ +#ifndef ICU4XDate_H +#define ICU4XDate_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XDate ICU4XDate; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XCalendar.h" +#include "diplomat_result_box_ICU4XDate_ICU4XError.h" +#include "ICU4XIsoDate.h" +#include "ICU4XIsoWeekday.h" +#include "ICU4XWeekCalculator.h" +#include "diplomat_result_ICU4XWeekOf_ICU4XError.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XDate_ICU4XError ICU4XDate_create_from_iso_in_calendar(int32_t year, uint8_t month, uint8_t day, const ICU4XCalendar* calendar); + +diplomat_result_box_ICU4XDate_ICU4XError ICU4XDate_create_from_codes_in_calendar(const char* era_code_data, size_t era_code_len, int32_t year, const char* month_code_data, size_t month_code_len, uint8_t day, const ICU4XCalendar* calendar); + +ICU4XDate* ICU4XDate_to_calendar(const ICU4XDate* self, const ICU4XCalendar* calendar); + +ICU4XIsoDate* ICU4XDate_to_iso(const ICU4XDate* self); + +uint32_t ICU4XDate_day_of_month(const ICU4XDate* self); + +ICU4XIsoWeekday ICU4XDate_day_of_week(const ICU4XDate* self); + +uint32_t ICU4XDate_week_of_month(const ICU4XDate* self, ICU4XIsoWeekday first_weekday); + +diplomat_result_ICU4XWeekOf_ICU4XError ICU4XDate_week_of_year(const ICU4XDate* self, const ICU4XWeekCalculator* calculator); + +uint32_t ICU4XDate_ordinal_month(const ICU4XDate* self); + +diplomat_result_void_ICU4XError ICU4XDate_month_code(const ICU4XDate* self, DiplomatWriteable* write); + +int32_t ICU4XDate_year_in_era(const ICU4XDate* self); + +diplomat_result_void_ICU4XError ICU4XDate_era(const ICU4XDate* self, DiplomatWriteable* write); + +uint8_t ICU4XDate_months_in_year(const ICU4XDate* self); + +uint8_t ICU4XDate_days_in_month(const ICU4XDate* self); + +uint32_t ICU4XDate_days_in_year(const ICU4XDate* self); + +ICU4XCalendar* ICU4XDate_calendar(const ICU4XDate* self); +void ICU4XDate_destroy(ICU4XDate* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XDateFormatter.h b/third_party/rust/icu_capi/c/include/ICU4XDateFormatter.h new file mode 100644 index 000000000000..8dc5316e4789 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XDateFormatter.h @@ -0,0 +1,46 @@ +#ifndef ICU4XDateFormatter_H +#define ICU4XDateFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XDateFormatter ICU4XDateFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XDateLength.h" +#include "diplomat_result_box_ICU4XDateFormatter_ICU4XError.h" +#include "ICU4XDate.h" +#include "diplomat_result_void_ICU4XError.h" +#include "ICU4XIsoDate.h" +#include "ICU4XDateTime.h" +#include "ICU4XIsoDateTime.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XDateFormatter_ICU4XError ICU4XDateFormatter_create_with_length(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XDateLength date_length); + +diplomat_result_void_ICU4XError ICU4XDateFormatter_format_date(const ICU4XDateFormatter* self, const ICU4XDate* value, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XDateFormatter_format_iso_date(const ICU4XDateFormatter* self, const ICU4XIsoDate* value, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XDateFormatter_format_datetime(const ICU4XDateFormatter* self, const ICU4XDateTime* value, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XDateFormatter_format_iso_datetime(const ICU4XDateFormatter* self, const ICU4XIsoDateTime* value, DiplomatWriteable* write); +void ICU4XDateFormatter_destroy(ICU4XDateFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XDateLength.h b/third_party/rust/icu_capi/c/include/ICU4XDateLength.h new file mode 100644 index 000000000000..b2ca91823365 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XDateLength.h @@ -0,0 +1,33 @@ +#ifndef ICU4XDateLength_H +#define ICU4XDateLength_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XDateLength { + ICU4XDateLength_Full = 0, + ICU4XDateLength_Long = 1, + ICU4XDateLength_Medium = 2, + ICU4XDateLength_Short = 3, +} ICU4XDateLength; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XDateLength_destroy(ICU4XDateLength* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XDateTime.h b/third_party/rust/icu_capi/c/include/ICU4XDateTime.h new file mode 100644 index 000000000000..a9dc1cee7160 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XDateTime.h @@ -0,0 +1,82 @@ +#ifndef ICU4XDateTime_H +#define ICU4XDateTime_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XDateTime ICU4XDateTime; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XCalendar.h" +#include "diplomat_result_box_ICU4XDateTime_ICU4XError.h" +#include "ICU4XDate.h" +#include "ICU4XTime.h" +#include "ICU4XIsoDateTime.h" +#include "ICU4XIsoWeekday.h" +#include "ICU4XWeekCalculator.h" +#include "diplomat_result_ICU4XWeekOf_ICU4XError.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XDateTime_ICU4XError ICU4XDateTime_create_from_iso_in_calendar(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const ICU4XCalendar* calendar); + +diplomat_result_box_ICU4XDateTime_ICU4XError ICU4XDateTime_create_from_codes_in_calendar(const char* era_code_data, size_t era_code_len, int32_t year, const char* month_code_data, size_t month_code_len, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const ICU4XCalendar* calendar); + +ICU4XDateTime* ICU4XDateTime_create_from_date_and_time(const ICU4XDate* date, const ICU4XTime* time); + +ICU4XDate* ICU4XDateTime_date(const ICU4XDateTime* self); + +ICU4XTime* ICU4XDateTime_time(const ICU4XDateTime* self); + +ICU4XIsoDateTime* ICU4XDateTime_to_iso(const ICU4XDateTime* self); + +ICU4XDateTime* ICU4XDateTime_to_calendar(const ICU4XDateTime* self, const ICU4XCalendar* calendar); + +uint8_t ICU4XDateTime_hour(const ICU4XDateTime* self); + +uint8_t ICU4XDateTime_minute(const ICU4XDateTime* self); + +uint8_t ICU4XDateTime_second(const ICU4XDateTime* self); + +uint32_t ICU4XDateTime_nanosecond(const ICU4XDateTime* self); + +uint32_t ICU4XDateTime_day_of_month(const ICU4XDateTime* self); + +ICU4XIsoWeekday ICU4XDateTime_day_of_week(const ICU4XDateTime* self); + +uint32_t ICU4XDateTime_week_of_month(const ICU4XDateTime* self, ICU4XIsoWeekday first_weekday); + +diplomat_result_ICU4XWeekOf_ICU4XError ICU4XDateTime_week_of_year(const ICU4XDateTime* self, const ICU4XWeekCalculator* calculator); + +uint32_t ICU4XDateTime_ordinal_month(const ICU4XDateTime* self); + +diplomat_result_void_ICU4XError ICU4XDateTime_month_code(const ICU4XDateTime* self, DiplomatWriteable* write); + +int32_t ICU4XDateTime_year_in_era(const ICU4XDateTime* self); + +diplomat_result_void_ICU4XError ICU4XDateTime_era(const ICU4XDateTime* self, DiplomatWriteable* write); + +uint8_t ICU4XDateTime_months_in_year(const ICU4XDateTime* self); + +uint8_t ICU4XDateTime_days_in_month(const ICU4XDateTime* self); + +uint32_t ICU4XDateTime_days_in_year(const ICU4XDateTime* self); + +ICU4XCalendar* ICU4XDateTime_calendar(const ICU4XDateTime* self); +void ICU4XDateTime_destroy(ICU4XDateTime* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XDateTimeFormatter.h b/third_party/rust/icu_capi/c/include/ICU4XDateTimeFormatter.h new file mode 100644 index 000000000000..5f0af4ddba1e --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XDateTimeFormatter.h @@ -0,0 +1,41 @@ +#ifndef ICU4XDateTimeFormatter_H +#define ICU4XDateTimeFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XDateTimeFormatter ICU4XDateTimeFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XDateLength.h" +#include "ICU4XTimeLength.h" +#include "diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError.h" +#include "ICU4XDateTime.h" +#include "diplomat_result_void_ICU4XError.h" +#include "ICU4XIsoDateTime.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError ICU4XDateTimeFormatter_create_with_lengths(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XDateLength date_length, ICU4XTimeLength time_length); + +diplomat_result_void_ICU4XError ICU4XDateTimeFormatter_format_datetime(const ICU4XDateTimeFormatter* self, const ICU4XDateTime* value, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XDateTimeFormatter_format_iso_datetime(const ICU4XDateTimeFormatter* self, const ICU4XIsoDateTime* value, DiplomatWriteable* write); +void ICU4XDateTimeFormatter_destroy(ICU4XDateTimeFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XDecomposed.h b/third_party/rust/icu_capi/c/include/ICU4XDecomposed.h new file mode 100644 index 000000000000..3f287e8192a9 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XDecomposed.h @@ -0,0 +1,31 @@ +#ifndef ICU4XDecomposed_H +#define ICU4XDecomposed_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XDecomposed { + char32_t first; + char32_t second; +} ICU4XDecomposed; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XDecomposed_destroy(ICU4XDecomposed* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XDecomposingNormalizer.h b/third_party/rust/icu_capi/c/include/ICU4XDecomposingNormalizer.h new file mode 100644 index 000000000000..f542f7a7302e --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XDecomposingNormalizer.h @@ -0,0 +1,38 @@ +#ifndef ICU4XDecomposingNormalizer_H +#define ICU4XDecomposingNormalizer_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XDecomposingNormalizer ICU4XDecomposingNormalizer; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError ICU4XDecomposingNormalizer_create_nfd(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError ICU4XDecomposingNormalizer_create_nfkd(const ICU4XDataProvider* provider); + +diplomat_result_void_ICU4XError ICU4XDecomposingNormalizer_normalize(const ICU4XDecomposingNormalizer* self, const char* s_data, size_t s_len, DiplomatWriteable* write); + +bool ICU4XDecomposingNormalizer_is_normalized(const ICU4XDecomposingNormalizer* self, const char* s_data, size_t s_len); +void ICU4XDecomposingNormalizer_destroy(ICU4XDecomposingNormalizer* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XDisplayNamesFallback.h b/third_party/rust/icu_capi/c/include/ICU4XDisplayNamesFallback.h new file mode 100644 index 000000000000..085fc8de5dde --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XDisplayNamesFallback.h @@ -0,0 +1,31 @@ +#ifndef ICU4XDisplayNamesFallback_H +#define ICU4XDisplayNamesFallback_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XDisplayNamesFallback { + ICU4XDisplayNamesFallback_Code = 0, + ICU4XDisplayNamesFallback_None = 1, +} ICU4XDisplayNamesFallback; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XDisplayNamesFallback_destroy(ICU4XDisplayNamesFallback* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XDisplayNamesOptionsV1.h b/third_party/rust/icu_capi/c/include/ICU4XDisplayNamesOptionsV1.h new file mode 100644 index 000000000000..e998cde0e779 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XDisplayNamesOptionsV1.h @@ -0,0 +1,38 @@ +#ifndef ICU4XDisplayNamesOptionsV1_H +#define ICU4XDisplayNamesOptionsV1_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XDisplayNamesStyle.h" +#include "ICU4XDisplayNamesFallback.h" +#include "ICU4XLanguageDisplay.h" +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XDisplayNamesOptionsV1 { + ICU4XDisplayNamesStyle style; + ICU4XDisplayNamesFallback fallback; + ICU4XLanguageDisplay language_display; +} ICU4XDisplayNamesOptionsV1; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDisplayNamesStyle.h" +#include "ICU4XDisplayNamesFallback.h" +#include "ICU4XLanguageDisplay.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XDisplayNamesOptionsV1_destroy(ICU4XDisplayNamesOptionsV1* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XDisplayNamesStyle.h b/third_party/rust/icu_capi/c/include/ICU4XDisplayNamesStyle.h new file mode 100644 index 000000000000..048da455daf4 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XDisplayNamesStyle.h @@ -0,0 +1,34 @@ +#ifndef ICU4XDisplayNamesStyle_H +#define ICU4XDisplayNamesStyle_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XDisplayNamesStyle { + ICU4XDisplayNamesStyle_Auto = 0, + ICU4XDisplayNamesStyle_Narrow = 1, + ICU4XDisplayNamesStyle_Short = 2, + ICU4XDisplayNamesStyle_Long = 3, + ICU4XDisplayNamesStyle_Menu = 4, +} ICU4XDisplayNamesStyle; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XDisplayNamesStyle_destroy(ICU4XDisplayNamesStyle* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XError.h b/third_party/rust/icu_capi/c/include/ICU4XError.h new file mode 100644 index 000000000000..65e1c04a25c2 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XError.h @@ -0,0 +1,83 @@ +#ifndef ICU4XError_H +#define ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XError { + ICU4XError_UnknownError = 0, + ICU4XError_WriteableError = 1, + ICU4XError_OutOfBoundsError = 2, + ICU4XError_DataMissingDataKeyError = 256, + ICU4XError_DataMissingVariantError = 257, + ICU4XError_DataMissingLocaleError = 258, + ICU4XError_DataNeedsVariantError = 259, + ICU4XError_DataNeedsLocaleError = 260, + ICU4XError_DataExtraneousLocaleError = 261, + ICU4XError_DataFilteredResourceError = 262, + ICU4XError_DataMismatchedTypeError = 263, + ICU4XError_DataMissingPayloadError = 264, + ICU4XError_DataInvalidStateError = 265, + ICU4XError_DataCustomError = 266, + ICU4XError_DataIoError = 267, + ICU4XError_DataUnavailableBufferFormatError = 268, + ICU4XError_DataMismatchedAnyBufferError = 269, + ICU4XError_LocaleUndefinedSubtagError = 512, + ICU4XError_LocaleParserLanguageError = 513, + ICU4XError_LocaleParserSubtagError = 514, + ICU4XError_LocaleParserExtensionError = 515, + ICU4XError_DataStructValidityError = 768, + ICU4XError_PropertyUnknownScriptIdError = 1024, + ICU4XError_PropertyUnknownGeneralCategoryGroupError = 1025, + ICU4XError_PropertyUnexpectedPropertyNameError = 1026, + ICU4XError_FixedDecimalLimitError = 1280, + ICU4XError_FixedDecimalSyntaxError = 1281, + ICU4XError_PluralsParserError = 1536, + ICU4XError_CalendarParseError = 1792, + ICU4XError_CalendarOverflowError = 1793, + ICU4XError_CalendarUnderflowError = 1794, + ICU4XError_CalendarOutOfRangeError = 1795, + ICU4XError_CalendarUnknownEraError = 1796, + ICU4XError_CalendarUnknownMonthCodeError = 1797, + ICU4XError_CalendarMissingInputError = 1798, + ICU4XError_CalendarUnknownKindError = 1799, + ICU4XError_CalendarMissingError = 1800, + ICU4XError_DateTimePatternError = 2048, + ICU4XError_DateTimeMissingInputFieldError = 2049, + ICU4XError_DateTimeSkeletonError = 2050, + ICU4XError_DateTimeUnsupportedFieldError = 2051, + ICU4XError_DateTimeUnsupportedOptionsError = 2052, + ICU4XError_DateTimeMissingWeekdaySymbolError = 2053, + ICU4XError_DateTimeMissingMonthSymbolError = 2054, + ICU4XError_DateTimeFixedDecimalError = 2055, + ICU4XError_DateTimeMismatchedCalendarError = 2056, + ICU4XError_TinyStrTooLargeError = 2304, + ICU4XError_TinyStrContainsNullError = 2305, + ICU4XError_TinyStrNonAsciiError = 2306, + ICU4XError_TimeZoneOffsetOutOfBoundsError = 2560, + ICU4XError_TimeZoneInvalidOffsetError = 2561, + ICU4XError_TimeZoneMissingInputError = 2562, + ICU4XError_NormalizerFutureExtensionError = 2816, + ICU4XError_NormalizerValidationError = 2817, +} ICU4XError; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XError_destroy(ICU4XError* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XFixedDecimal.h b/third_party/rust/icu_capi/c/include/ICU4XFixedDecimal.h new file mode 100644 index 000000000000..361294b68748 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XFixedDecimal.h @@ -0,0 +1,101 @@ +#ifndef ICU4XFixedDecimal_H +#define ICU4XFixedDecimal_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XFixedDecimal ICU4XFixedDecimal; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_box_ICU4XFixedDecimal_ICU4XError.h" +#include "ICU4XFixedDecimalSign.h" +#include "ICU4XFixedDecimalSignDisplay.h" +#include "diplomat_result_void_void.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +ICU4XFixedDecimal* ICU4XFixedDecimal_create_from_i32(int32_t v); + +ICU4XFixedDecimal* ICU4XFixedDecimal_create_from_u32(uint32_t v); + +ICU4XFixedDecimal* ICU4XFixedDecimal_create_from_i64(int64_t v); + +ICU4XFixedDecimal* ICU4XFixedDecimal_create_from_u64(uint64_t v); + +diplomat_result_box_ICU4XFixedDecimal_ICU4XError ICU4XFixedDecimal_create_from_f64_with_integer_precision(double f); + +diplomat_result_box_ICU4XFixedDecimal_ICU4XError ICU4XFixedDecimal_create_from_f64_with_lower_magnitude(double f, int16_t magnitude); + +diplomat_result_box_ICU4XFixedDecimal_ICU4XError ICU4XFixedDecimal_create_from_f64_with_significant_digits(double f, uint8_t digits); + +diplomat_result_box_ICU4XFixedDecimal_ICU4XError ICU4XFixedDecimal_create_from_f64_with_floating_precision(double f); + +diplomat_result_box_ICU4XFixedDecimal_ICU4XError ICU4XFixedDecimal_create_from_string(const char* v_data, size_t v_len); + +uint8_t ICU4XFixedDecimal_digit_at(const ICU4XFixedDecimal* self, int16_t magnitude); + +int16_t ICU4XFixedDecimal_magnitude_start(const ICU4XFixedDecimal* self); + +int16_t ICU4XFixedDecimal_magnitude_end(const ICU4XFixedDecimal* self); + +int16_t ICU4XFixedDecimal_nonzero_magnitude_start(const ICU4XFixedDecimal* self); + +int16_t ICU4XFixedDecimal_nonzero_magnitude_end(const ICU4XFixedDecimal* self); + +bool ICU4XFixedDecimal_is_zero(const ICU4XFixedDecimal* self); + +void ICU4XFixedDecimal_multiply_pow10(ICU4XFixedDecimal* self, int16_t power); + +ICU4XFixedDecimalSign ICU4XFixedDecimal_sign(const ICU4XFixedDecimal* self); + +void ICU4XFixedDecimal_set_sign(ICU4XFixedDecimal* self, ICU4XFixedDecimalSign sign); + +void ICU4XFixedDecimal_apply_sign_display(ICU4XFixedDecimal* self, ICU4XFixedDecimalSignDisplay sign_display); + +void ICU4XFixedDecimal_trim_start(ICU4XFixedDecimal* self); + +void ICU4XFixedDecimal_trim_end(ICU4XFixedDecimal* self); + +void ICU4XFixedDecimal_pad_start(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_pad_end(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_set_max_position(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_trunc(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_half_trunc(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_expand(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_half_expand(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_ceil(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_half_ceil(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_floor(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_half_floor(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_half_even(ICU4XFixedDecimal* self, int16_t position); + +diplomat_result_void_void ICU4XFixedDecimal_concatenate_end(ICU4XFixedDecimal* self, ICU4XFixedDecimal* other); + +void ICU4XFixedDecimal_to_string(const ICU4XFixedDecimal* self, DiplomatWriteable* to); +void ICU4XFixedDecimal_destroy(ICU4XFixedDecimal* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XFixedDecimalFormatter.h b/third_party/rust/icu_capi/c/include/ICU4XFixedDecimalFormatter.h new file mode 100644 index 000000000000..aa1cfd6a48c5 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XFixedDecimalFormatter.h @@ -0,0 +1,40 @@ +#ifndef ICU4XFixedDecimalFormatter_H +#define ICU4XFixedDecimalFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XFixedDecimalFormatter ICU4XFixedDecimalFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XFixedDecimalGroupingStrategy.h" +#include "diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError.h" +#include "ICU4XDataStruct.h" +#include "ICU4XFixedDecimal.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError ICU4XFixedDecimalFormatter_create_with_grouping_strategy(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XFixedDecimalGroupingStrategy grouping_strategy); + +diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError ICU4XFixedDecimalFormatter_create_with_decimal_symbols_v1(const ICU4XDataStruct* data_struct, ICU4XFixedDecimalGroupingStrategy grouping_strategy); + +diplomat_result_void_ICU4XError ICU4XFixedDecimalFormatter_format(const ICU4XFixedDecimalFormatter* self, const ICU4XFixedDecimal* value, DiplomatWriteable* write); +void ICU4XFixedDecimalFormatter_destroy(ICU4XFixedDecimalFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XFixedDecimalGroupingStrategy.h b/third_party/rust/icu_capi/c/include/ICU4XFixedDecimalGroupingStrategy.h new file mode 100644 index 000000000000..7648892cc5bb --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XFixedDecimalGroupingStrategy.h @@ -0,0 +1,33 @@ +#ifndef ICU4XFixedDecimalGroupingStrategy_H +#define ICU4XFixedDecimalGroupingStrategy_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XFixedDecimalGroupingStrategy { + ICU4XFixedDecimalGroupingStrategy_Auto = 0, + ICU4XFixedDecimalGroupingStrategy_Never = 1, + ICU4XFixedDecimalGroupingStrategy_Always = 2, + ICU4XFixedDecimalGroupingStrategy_Min2 = 3, +} ICU4XFixedDecimalGroupingStrategy; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XFixedDecimalGroupingStrategy_destroy(ICU4XFixedDecimalGroupingStrategy* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XFixedDecimalSign.h b/third_party/rust/icu_capi/c/include/ICU4XFixedDecimalSign.h new file mode 100644 index 000000000000..12fff3cf1cee --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XFixedDecimalSign.h @@ -0,0 +1,32 @@ +#ifndef ICU4XFixedDecimalSign_H +#define ICU4XFixedDecimalSign_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XFixedDecimalSign { + ICU4XFixedDecimalSign_None = 0, + ICU4XFixedDecimalSign_Negative = 1, + ICU4XFixedDecimalSign_Positive = 2, +} ICU4XFixedDecimalSign; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XFixedDecimalSign_destroy(ICU4XFixedDecimalSign* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XFixedDecimalSignDisplay.h b/third_party/rust/icu_capi/c/include/ICU4XFixedDecimalSignDisplay.h new file mode 100644 index 000000000000..8c2612e51628 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XFixedDecimalSignDisplay.h @@ -0,0 +1,34 @@ +#ifndef ICU4XFixedDecimalSignDisplay_H +#define ICU4XFixedDecimalSignDisplay_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XFixedDecimalSignDisplay { + ICU4XFixedDecimalSignDisplay_Auto = 0, + ICU4XFixedDecimalSignDisplay_Never = 1, + ICU4XFixedDecimalSignDisplay_Always = 2, + ICU4XFixedDecimalSignDisplay_ExceptZero = 3, + ICU4XFixedDecimalSignDisplay_Negative = 4, +} ICU4XFixedDecimalSignDisplay; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XFixedDecimalSignDisplay_destroy(ICU4XFixedDecimalSignDisplay* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XGeneralCategoryNameToMaskMapper.h b/third_party/rust/icu_capi/c/include/ICU4XGeneralCategoryNameToMaskMapper.h new file mode 100644 index 000000000000..3a4e2d4d13aa --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XGeneralCategoryNameToMaskMapper.h @@ -0,0 +1,35 @@ +#ifndef ICU4XGeneralCategoryNameToMaskMapper_H +#define ICU4XGeneralCategoryNameToMaskMapper_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XGeneralCategoryNameToMaskMapper ICU4XGeneralCategoryNameToMaskMapper; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +uint32_t ICU4XGeneralCategoryNameToMaskMapper_get_strict(const ICU4XGeneralCategoryNameToMaskMapper* self, const char* name_data, size_t name_len); + +uint32_t ICU4XGeneralCategoryNameToMaskMapper_get_loose(const ICU4XGeneralCategoryNameToMaskMapper* self, const char* name_data, size_t name_len); + +diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError ICU4XGeneralCategoryNameToMaskMapper_load(const ICU4XDataProvider* provider); +void ICU4XGeneralCategoryNameToMaskMapper_destroy(ICU4XGeneralCategoryNameToMaskMapper* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XGraphemeClusterBreakIteratorLatin1.h b/third_party/rust/icu_capi/c/include/ICU4XGraphemeClusterBreakIteratorLatin1.h new file mode 100644 index 000000000000..9e23489fd3dd --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XGraphemeClusterBreakIteratorLatin1.h @@ -0,0 +1,29 @@ +#ifndef ICU4XGraphemeClusterBreakIteratorLatin1_H +#define ICU4XGraphemeClusterBreakIteratorLatin1_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XGraphemeClusterBreakIteratorLatin1 ICU4XGraphemeClusterBreakIteratorLatin1; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XGraphemeClusterBreakIteratorLatin1_next(ICU4XGraphemeClusterBreakIteratorLatin1* self); +void ICU4XGraphemeClusterBreakIteratorLatin1_destroy(ICU4XGraphemeClusterBreakIteratorLatin1* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XGraphemeClusterBreakIteratorUtf16.h b/third_party/rust/icu_capi/c/include/ICU4XGraphemeClusterBreakIteratorUtf16.h new file mode 100644 index 000000000000..f0de4c0214d6 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XGraphemeClusterBreakIteratorUtf16.h @@ -0,0 +1,29 @@ +#ifndef ICU4XGraphemeClusterBreakIteratorUtf16_H +#define ICU4XGraphemeClusterBreakIteratorUtf16_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XGraphemeClusterBreakIteratorUtf16 ICU4XGraphemeClusterBreakIteratorUtf16; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XGraphemeClusterBreakIteratorUtf16_next(ICU4XGraphemeClusterBreakIteratorUtf16* self); +void ICU4XGraphemeClusterBreakIteratorUtf16_destroy(ICU4XGraphemeClusterBreakIteratorUtf16* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XGraphemeClusterBreakIteratorUtf8.h b/third_party/rust/icu_capi/c/include/ICU4XGraphemeClusterBreakIteratorUtf8.h new file mode 100644 index 000000000000..331b17eac783 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XGraphemeClusterBreakIteratorUtf8.h @@ -0,0 +1,29 @@ +#ifndef ICU4XGraphemeClusterBreakIteratorUtf8_H +#define ICU4XGraphemeClusterBreakIteratorUtf8_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XGraphemeClusterBreakIteratorUtf8 ICU4XGraphemeClusterBreakIteratorUtf8; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XGraphemeClusterBreakIteratorUtf8_next(ICU4XGraphemeClusterBreakIteratorUtf8* self); +void ICU4XGraphemeClusterBreakIteratorUtf8_destroy(ICU4XGraphemeClusterBreakIteratorUtf8* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XGraphemeClusterSegmenter.h b/third_party/rust/icu_capi/c/include/ICU4XGraphemeClusterSegmenter.h new file mode 100644 index 000000000000..1805090bfbdc --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XGraphemeClusterSegmenter.h @@ -0,0 +1,40 @@ +#ifndef ICU4XGraphemeClusterSegmenter_H +#define ICU4XGraphemeClusterSegmenter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XGraphemeClusterSegmenter ICU4XGraphemeClusterSegmenter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError.h" +#include "ICU4XGraphemeClusterBreakIteratorUtf8.h" +#include "ICU4XGraphemeClusterBreakIteratorUtf16.h" +#include "ICU4XGraphemeClusterBreakIteratorLatin1.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError ICU4XGraphemeClusterSegmenter_create(const ICU4XDataProvider* provider); + +ICU4XGraphemeClusterBreakIteratorUtf8* ICU4XGraphemeClusterSegmenter_segment_utf8(const ICU4XGraphemeClusterSegmenter* self, const char* input_data, size_t input_len); + +ICU4XGraphemeClusterBreakIteratorUtf16* ICU4XGraphemeClusterSegmenter_segment_utf16(const ICU4XGraphemeClusterSegmenter* self, const uint16_t* input_data, size_t input_len); + +ICU4XGraphemeClusterBreakIteratorLatin1* ICU4XGraphemeClusterSegmenter_segment_latin1(const ICU4XGraphemeClusterSegmenter* self, const uint8_t* input_data, size_t input_len); +void ICU4XGraphemeClusterSegmenter_destroy(ICU4XGraphemeClusterSegmenter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XGregorianDateFormatter.h b/third_party/rust/icu_capi/c/include/ICU4XGregorianDateFormatter.h new file mode 100644 index 000000000000..cf3ad9e9f4ae --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XGregorianDateFormatter.h @@ -0,0 +1,40 @@ +#ifndef ICU4XGregorianDateFormatter_H +#define ICU4XGregorianDateFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XGregorianDateFormatter ICU4XGregorianDateFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XDateLength.h" +#include "diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError.h" +#include "ICU4XIsoDate.h" +#include "diplomat_result_void_ICU4XError.h" +#include "ICU4XIsoDateTime.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError ICU4XGregorianDateFormatter_create_with_length(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XDateLength length); + +diplomat_result_void_ICU4XError ICU4XGregorianDateFormatter_format_iso_date(const ICU4XGregorianDateFormatter* self, const ICU4XIsoDate* value, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XGregorianDateFormatter_format_iso_datetime(const ICU4XGregorianDateFormatter* self, const ICU4XIsoDateTime* value, DiplomatWriteable* write); +void ICU4XGregorianDateFormatter_destroy(ICU4XGregorianDateFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XGregorianDateTimeFormatter.h b/third_party/rust/icu_capi/c/include/ICU4XGregorianDateTimeFormatter.h new file mode 100644 index 000000000000..0b56ddc3934b --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XGregorianDateTimeFormatter.h @@ -0,0 +1,38 @@ +#ifndef ICU4XGregorianDateTimeFormatter_H +#define ICU4XGregorianDateTimeFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XGregorianDateTimeFormatter ICU4XGregorianDateTimeFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XDateLength.h" +#include "ICU4XTimeLength.h" +#include "diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError.h" +#include "ICU4XIsoDateTime.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError ICU4XGregorianDateTimeFormatter_create_with_lengths(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XDateLength date_length, ICU4XTimeLength time_length); + +diplomat_result_void_ICU4XError ICU4XGregorianDateTimeFormatter_format_iso_datetime(const ICU4XGregorianDateTimeFormatter* self, const ICU4XIsoDateTime* value, DiplomatWriteable* write); +void ICU4XGregorianDateTimeFormatter_destroy(ICU4XGregorianDateTimeFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XGregorianZonedDateTimeFormatter.h b/third_party/rust/icu_capi/c/include/ICU4XGregorianZonedDateTimeFormatter.h new file mode 100644 index 000000000000..4be60c2b0b27 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XGregorianZonedDateTimeFormatter.h @@ -0,0 +1,42 @@ +#ifndef ICU4XGregorianZonedDateTimeFormatter_H +#define ICU4XGregorianZonedDateTimeFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XGregorianZonedDateTimeFormatter ICU4XGregorianZonedDateTimeFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XDateLength.h" +#include "ICU4XTimeLength.h" +#include "diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError.h" +#include "ICU4XIsoTimeZoneOptions.h" +#include "ICU4XIsoDateTime.h" +#include "ICU4XCustomTimeZone.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError ICU4XGregorianZonedDateTimeFormatter_create_with_lengths(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XDateLength date_length, ICU4XTimeLength time_length); + +diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError ICU4XGregorianZonedDateTimeFormatter_create_with_lengths_and_iso_8601_time_zone_fallback(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XDateLength date_length, ICU4XTimeLength time_length, ICU4XIsoTimeZoneOptions zone_options); + +diplomat_result_void_ICU4XError ICU4XGregorianZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone(const ICU4XGregorianZonedDateTimeFormatter* self, const ICU4XIsoDateTime* datetime, const ICU4XCustomTimeZone* time_zone, DiplomatWriteable* write); +void ICU4XGregorianZonedDateTimeFormatter_destroy(ICU4XGregorianZonedDateTimeFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XIsoDate.h b/third_party/rust/icu_capi/c/include/ICU4XIsoDate.h new file mode 100644 index 000000000000..aadc7590bad9 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XIsoDate.h @@ -0,0 +1,57 @@ +#ifndef ICU4XIsoDate_H +#define ICU4XIsoDate_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XIsoDate ICU4XIsoDate; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_box_ICU4XIsoDate_ICU4XError.h" +#include "ICU4XCalendar.h" +#include "ICU4XDate.h" +#include "ICU4XIsoWeekday.h" +#include "ICU4XWeekCalculator.h" +#include "diplomat_result_ICU4XWeekOf_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XIsoDate_ICU4XError ICU4XIsoDate_create(int32_t year, uint8_t month, uint8_t day); + +ICU4XDate* ICU4XIsoDate_to_calendar(const ICU4XIsoDate* self, const ICU4XCalendar* calendar); + +ICU4XDate* ICU4XIsoDate_to_any(const ICU4XIsoDate* self); + +uint32_t ICU4XIsoDate_day_of_month(const ICU4XIsoDate* self); + +ICU4XIsoWeekday ICU4XIsoDate_day_of_week(const ICU4XIsoDate* self); + +uint32_t ICU4XIsoDate_week_of_month(const ICU4XIsoDate* self, ICU4XIsoWeekday first_weekday); + +diplomat_result_ICU4XWeekOf_ICU4XError ICU4XIsoDate_week_of_year(const ICU4XIsoDate* self, const ICU4XWeekCalculator* calculator); + +uint32_t ICU4XIsoDate_month(const ICU4XIsoDate* self); + +int32_t ICU4XIsoDate_year(const ICU4XIsoDate* self); + +uint8_t ICU4XIsoDate_months_in_year(const ICU4XIsoDate* self); + +uint8_t ICU4XIsoDate_days_in_month(const ICU4XIsoDate* self); + +uint32_t ICU4XIsoDate_days_in_year(const ICU4XIsoDate* self); +void ICU4XIsoDate_destroy(ICU4XIsoDate* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XIsoDateTime.h b/third_party/rust/icu_capi/c/include/ICU4XIsoDateTime.h new file mode 100644 index 000000000000..6f1a2acbe2d6 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XIsoDateTime.h @@ -0,0 +1,77 @@ +#ifndef ICU4XIsoDateTime_H +#define ICU4XIsoDateTime_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XIsoDateTime ICU4XIsoDateTime; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_box_ICU4XIsoDateTime_ICU4XError.h" +#include "ICU4XIsoDate.h" +#include "ICU4XTime.h" +#include "ICU4XDateTime.h" +#include "ICU4XCalendar.h" +#include "ICU4XIsoWeekday.h" +#include "ICU4XWeekCalculator.h" +#include "diplomat_result_ICU4XWeekOf_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XIsoDateTime_ICU4XError ICU4XIsoDateTime_create(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond); + +ICU4XIsoDateTime* ICU4XIsoDateTime_crate_from_date_and_time(const ICU4XIsoDate* date, const ICU4XTime* time); + +ICU4XIsoDateTime* ICU4XIsoDateTime_create_from_minutes_since_local_unix_epoch(int32_t minutes); + +ICU4XIsoDate* ICU4XIsoDateTime_date(const ICU4XIsoDateTime* self); + +ICU4XTime* ICU4XIsoDateTime_time(const ICU4XIsoDateTime* self); + +ICU4XDateTime* ICU4XIsoDateTime_to_any(const ICU4XIsoDateTime* self); + +int32_t ICU4XIsoDateTime_minutes_since_local_unix_epoch(const ICU4XIsoDateTime* self); + +ICU4XDateTime* ICU4XIsoDateTime_to_calendar(const ICU4XIsoDateTime* self, const ICU4XCalendar* calendar); + +uint8_t ICU4XIsoDateTime_hour(const ICU4XIsoDateTime* self); + +uint8_t ICU4XIsoDateTime_minute(const ICU4XIsoDateTime* self); + +uint8_t ICU4XIsoDateTime_second(const ICU4XIsoDateTime* self); + +uint32_t ICU4XIsoDateTime_nanosecond(const ICU4XIsoDateTime* self); + +uint32_t ICU4XIsoDateTime_day_of_month(const ICU4XIsoDateTime* self); + +ICU4XIsoWeekday ICU4XIsoDateTime_day_of_week(const ICU4XIsoDateTime* self); + +uint32_t ICU4XIsoDateTime_week_of_month(const ICU4XIsoDateTime* self, ICU4XIsoWeekday first_weekday); + +diplomat_result_ICU4XWeekOf_ICU4XError ICU4XIsoDateTime_week_of_year(const ICU4XIsoDateTime* self, const ICU4XWeekCalculator* calculator); + +uint32_t ICU4XIsoDateTime_month(const ICU4XIsoDateTime* self); + +int32_t ICU4XIsoDateTime_year(const ICU4XIsoDateTime* self); + +uint8_t ICU4XIsoDateTime_months_in_year(const ICU4XIsoDateTime* self); + +uint8_t ICU4XIsoDateTime_days_in_month(const ICU4XIsoDateTime* self); + +uint32_t ICU4XIsoDateTime_days_in_year(const ICU4XIsoDateTime* self); +void ICU4XIsoDateTime_destroy(ICU4XIsoDateTime* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XIsoTimeZoneFormat.h b/third_party/rust/icu_capi/c/include/ICU4XIsoTimeZoneFormat.h new file mode 100644 index 000000000000..e48a1142f213 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XIsoTimeZoneFormat.h @@ -0,0 +1,33 @@ +#ifndef ICU4XIsoTimeZoneFormat_H +#define ICU4XIsoTimeZoneFormat_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XIsoTimeZoneFormat { + ICU4XIsoTimeZoneFormat_Basic = 0, + ICU4XIsoTimeZoneFormat_Extended = 1, + ICU4XIsoTimeZoneFormat_UtcBasic = 2, + ICU4XIsoTimeZoneFormat_UtcExtended = 3, +} ICU4XIsoTimeZoneFormat; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XIsoTimeZoneFormat_destroy(ICU4XIsoTimeZoneFormat* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XIsoTimeZoneMinuteDisplay.h b/third_party/rust/icu_capi/c/include/ICU4XIsoTimeZoneMinuteDisplay.h new file mode 100644 index 000000000000..edeee9701913 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XIsoTimeZoneMinuteDisplay.h @@ -0,0 +1,31 @@ +#ifndef ICU4XIsoTimeZoneMinuteDisplay_H +#define ICU4XIsoTimeZoneMinuteDisplay_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XIsoTimeZoneMinuteDisplay { + ICU4XIsoTimeZoneMinuteDisplay_Required = 0, + ICU4XIsoTimeZoneMinuteDisplay_Optional = 1, +} ICU4XIsoTimeZoneMinuteDisplay; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XIsoTimeZoneMinuteDisplay_destroy(ICU4XIsoTimeZoneMinuteDisplay* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XIsoTimeZoneOptions.h b/third_party/rust/icu_capi/c/include/ICU4XIsoTimeZoneOptions.h new file mode 100644 index 000000000000..7ba051c3e617 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XIsoTimeZoneOptions.h @@ -0,0 +1,38 @@ +#ifndef ICU4XIsoTimeZoneOptions_H +#define ICU4XIsoTimeZoneOptions_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XIsoTimeZoneFormat.h" +#include "ICU4XIsoTimeZoneMinuteDisplay.h" +#include "ICU4XIsoTimeZoneSecondDisplay.h" +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XIsoTimeZoneOptions { + ICU4XIsoTimeZoneFormat format; + ICU4XIsoTimeZoneMinuteDisplay minutes; + ICU4XIsoTimeZoneSecondDisplay seconds; +} ICU4XIsoTimeZoneOptions; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XIsoTimeZoneFormat.h" +#include "ICU4XIsoTimeZoneMinuteDisplay.h" +#include "ICU4XIsoTimeZoneSecondDisplay.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XIsoTimeZoneOptions_destroy(ICU4XIsoTimeZoneOptions* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XIsoTimeZoneSecondDisplay.h b/third_party/rust/icu_capi/c/include/ICU4XIsoTimeZoneSecondDisplay.h new file mode 100644 index 000000000000..487a248f958a --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XIsoTimeZoneSecondDisplay.h @@ -0,0 +1,31 @@ +#ifndef ICU4XIsoTimeZoneSecondDisplay_H +#define ICU4XIsoTimeZoneSecondDisplay_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XIsoTimeZoneSecondDisplay { + ICU4XIsoTimeZoneSecondDisplay_Optional = 0, + ICU4XIsoTimeZoneSecondDisplay_Never = 1, +} ICU4XIsoTimeZoneSecondDisplay; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XIsoTimeZoneSecondDisplay_destroy(ICU4XIsoTimeZoneSecondDisplay* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XIsoWeekday.h b/third_party/rust/icu_capi/c/include/ICU4XIsoWeekday.h new file mode 100644 index 000000000000..a23d0a3b9e92 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XIsoWeekday.h @@ -0,0 +1,36 @@ +#ifndef ICU4XIsoWeekday_H +#define ICU4XIsoWeekday_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XIsoWeekday { + ICU4XIsoWeekday_Monday = 1, + ICU4XIsoWeekday_Tuesday = 2, + ICU4XIsoWeekday_Wednesday = 3, + ICU4XIsoWeekday_Thursday = 4, + ICU4XIsoWeekday_Friday = 5, + ICU4XIsoWeekday_Saturday = 6, + ICU4XIsoWeekday_Sunday = 7, +} ICU4XIsoWeekday; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XIsoWeekday_destroy(ICU4XIsoWeekday* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XLanguageDisplay.h b/third_party/rust/icu_capi/c/include/ICU4XLanguageDisplay.h new file mode 100644 index 000000000000..0b921351fefa --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XLanguageDisplay.h @@ -0,0 +1,31 @@ +#ifndef ICU4XLanguageDisplay_H +#define ICU4XLanguageDisplay_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XLanguageDisplay { + ICU4XLanguageDisplay_Dialect = 0, + ICU4XLanguageDisplay_Standard = 1, +} ICU4XLanguageDisplay; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XLanguageDisplay_destroy(ICU4XLanguageDisplay* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XLineBreakIteratorLatin1.h b/third_party/rust/icu_capi/c/include/ICU4XLineBreakIteratorLatin1.h new file mode 100644 index 000000000000..c1a4c391318f --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XLineBreakIteratorLatin1.h @@ -0,0 +1,29 @@ +#ifndef ICU4XLineBreakIteratorLatin1_H +#define ICU4XLineBreakIteratorLatin1_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLineBreakIteratorLatin1 ICU4XLineBreakIteratorLatin1; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XLineBreakIteratorLatin1_next(ICU4XLineBreakIteratorLatin1* self); +void ICU4XLineBreakIteratorLatin1_destroy(ICU4XLineBreakIteratorLatin1* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XLineBreakIteratorUtf16.h b/third_party/rust/icu_capi/c/include/ICU4XLineBreakIteratorUtf16.h new file mode 100644 index 000000000000..78ae12c7e4b4 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XLineBreakIteratorUtf16.h @@ -0,0 +1,29 @@ +#ifndef ICU4XLineBreakIteratorUtf16_H +#define ICU4XLineBreakIteratorUtf16_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLineBreakIteratorUtf16 ICU4XLineBreakIteratorUtf16; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XLineBreakIteratorUtf16_next(ICU4XLineBreakIteratorUtf16* self); +void ICU4XLineBreakIteratorUtf16_destroy(ICU4XLineBreakIteratorUtf16* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XLineBreakIteratorUtf8.h b/third_party/rust/icu_capi/c/include/ICU4XLineBreakIteratorUtf8.h new file mode 100644 index 000000000000..3a08c5ad232b --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XLineBreakIteratorUtf8.h @@ -0,0 +1,29 @@ +#ifndef ICU4XLineBreakIteratorUtf8_H +#define ICU4XLineBreakIteratorUtf8_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLineBreakIteratorUtf8 ICU4XLineBreakIteratorUtf8; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XLineBreakIteratorUtf8_next(ICU4XLineBreakIteratorUtf8* self); +void ICU4XLineBreakIteratorUtf8_destroy(ICU4XLineBreakIteratorUtf8* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XLineBreakOptionsV1.h b/third_party/rust/icu_capi/c/include/ICU4XLineBreakOptionsV1.h new file mode 100644 index 000000000000..5fbf4b581426 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XLineBreakOptionsV1.h @@ -0,0 +1,36 @@ +#ifndef ICU4XLineBreakOptionsV1_H +#define ICU4XLineBreakOptionsV1_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XLineBreakStrictness.h" +#include "ICU4XLineBreakWordOption.h" +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLineBreakOptionsV1 { + ICU4XLineBreakStrictness strictness; + ICU4XLineBreakWordOption word_option; + bool ja_zh; +} ICU4XLineBreakOptionsV1; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XLineBreakStrictness.h" +#include "ICU4XLineBreakWordOption.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XLineBreakOptionsV1_destroy(ICU4XLineBreakOptionsV1* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XLineBreakStrictness.h b/third_party/rust/icu_capi/c/include/ICU4XLineBreakStrictness.h new file mode 100644 index 000000000000..e3534b7ec733 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XLineBreakStrictness.h @@ -0,0 +1,33 @@ +#ifndef ICU4XLineBreakStrictness_H +#define ICU4XLineBreakStrictness_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XLineBreakStrictness { + ICU4XLineBreakStrictness_Loose = 0, + ICU4XLineBreakStrictness_Normal = 1, + ICU4XLineBreakStrictness_Strict = 2, + ICU4XLineBreakStrictness_Anywhere = 3, +} ICU4XLineBreakStrictness; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XLineBreakStrictness_destroy(ICU4XLineBreakStrictness* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XLineBreakWordOption.h b/third_party/rust/icu_capi/c/include/ICU4XLineBreakWordOption.h new file mode 100644 index 000000000000..02a6ca6f2d41 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XLineBreakWordOption.h @@ -0,0 +1,32 @@ +#ifndef ICU4XLineBreakWordOption_H +#define ICU4XLineBreakWordOption_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XLineBreakWordOption { + ICU4XLineBreakWordOption_Normal = 0, + ICU4XLineBreakWordOption_BreakAll = 1, + ICU4XLineBreakWordOption_KeepAll = 2, +} ICU4XLineBreakWordOption; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XLineBreakWordOption_destroy(ICU4XLineBreakWordOption* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XLineSegmenter.h b/third_party/rust/icu_capi/c/include/ICU4XLineSegmenter.h new file mode 100644 index 000000000000..f734ec78f827 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XLineSegmenter.h @@ -0,0 +1,51 @@ +#ifndef ICU4XLineSegmenter_H +#define ICU4XLineSegmenter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLineSegmenter ICU4XLineSegmenter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XLineSegmenter_ICU4XError.h" +#include "ICU4XLineBreakOptionsV1.h" +#include "ICU4XLineBreakIteratorUtf8.h" +#include "ICU4XLineBreakIteratorUtf16.h" +#include "ICU4XLineBreakIteratorLatin1.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XLineSegmenter_ICU4XError ICU4XLineSegmenter_create_auto(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XLineSegmenter_ICU4XError ICU4XLineSegmenter_create_lstm(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XLineSegmenter_ICU4XError ICU4XLineSegmenter_create_dictionary(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XLineSegmenter_ICU4XError ICU4XLineSegmenter_create_auto_with_options_v1(const ICU4XDataProvider* provider, ICU4XLineBreakOptionsV1 options); + +diplomat_result_box_ICU4XLineSegmenter_ICU4XError ICU4XLineSegmenter_create_lstm_with_options_v1(const ICU4XDataProvider* provider, ICU4XLineBreakOptionsV1 options); + +diplomat_result_box_ICU4XLineSegmenter_ICU4XError ICU4XLineSegmenter_create_dictionary_with_options_v1(const ICU4XDataProvider* provider, ICU4XLineBreakOptionsV1 options); + +ICU4XLineBreakIteratorUtf8* ICU4XLineSegmenter_segment_utf8(const ICU4XLineSegmenter* self, const char* input_data, size_t input_len); + +ICU4XLineBreakIteratorUtf16* ICU4XLineSegmenter_segment_utf16(const ICU4XLineSegmenter* self, const uint16_t* input_data, size_t input_len); + +ICU4XLineBreakIteratorLatin1* ICU4XLineSegmenter_segment_latin1(const ICU4XLineSegmenter* self, const uint8_t* input_data, size_t input_len); +void ICU4XLineSegmenter_destroy(ICU4XLineSegmenter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XList.h b/third_party/rust/icu_capi/c/include/ICU4XList.h new file mode 100644 index 000000000000..6549561c37ba --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XList.h @@ -0,0 +1,35 @@ +#ifndef ICU4XList_H +#define ICU4XList_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XList ICU4XList; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +ICU4XList* ICU4XList_create(); + +ICU4XList* ICU4XList_create_with_capacity(size_t capacity); + +void ICU4XList_push(ICU4XList* self, const char* val_data, size_t val_len); + +size_t ICU4XList_len(const ICU4XList* self); +void ICU4XList_destroy(ICU4XList* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XListFormatter.h b/third_party/rust/icu_capi/c/include/ICU4XListFormatter.h new file mode 100644 index 000000000000..ee358dc254cc --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XListFormatter.h @@ -0,0 +1,41 @@ +#ifndef ICU4XListFormatter_H +#define ICU4XListFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XListFormatter ICU4XListFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XListLength.h" +#include "diplomat_result_box_ICU4XListFormatter_ICU4XError.h" +#include "ICU4XList.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XListFormatter_ICU4XError ICU4XListFormatter_create_and_with_length(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XListLength length); + +diplomat_result_box_ICU4XListFormatter_ICU4XError ICU4XListFormatter_create_or_with_length(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XListLength length); + +diplomat_result_box_ICU4XListFormatter_ICU4XError ICU4XListFormatter_create_unit_with_length(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XListLength length); + +diplomat_result_void_ICU4XError ICU4XListFormatter_format(const ICU4XListFormatter* self, const ICU4XList* list, DiplomatWriteable* write); +void ICU4XListFormatter_destroy(ICU4XListFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XListLength.h b/third_party/rust/icu_capi/c/include/ICU4XListLength.h new file mode 100644 index 000000000000..7092f6d9dfd7 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XListLength.h @@ -0,0 +1,32 @@ +#ifndef ICU4XListLength_H +#define ICU4XListLength_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XListLength { + ICU4XListLength_Wide = 0, + ICU4XListLength_Short = 1, + ICU4XListLength_Narrow = 2, +} ICU4XListLength; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XListLength_destroy(ICU4XListLength* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XLocale.h b/third_party/rust/icu_capi/c/include/ICU4XLocale.h new file mode 100644 index 000000000000..dea8d196b5cd --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XLocale.h @@ -0,0 +1,64 @@ +#ifndef ICU4XLocale_H +#define ICU4XLocale_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLocale ICU4XLocale; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_box_ICU4XLocale_ICU4XError.h" +#include "diplomat_result_void_ICU4XError.h" +#include "ICU4XOrdering.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XLocale_ICU4XError ICU4XLocale_create_from_string(const char* name_data, size_t name_len); + +ICU4XLocale* ICU4XLocale_create_und(); + +ICU4XLocale* ICU4XLocale_clone(const ICU4XLocale* self); + +diplomat_result_void_ICU4XError ICU4XLocale_basename(const ICU4XLocale* self, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XLocale_get_unicode_extension(const ICU4XLocale* self, const char* bytes_data, size_t bytes_len, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XLocale_language(const ICU4XLocale* self, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XLocale_set_language(ICU4XLocale* self, const char* bytes_data, size_t bytes_len); + +diplomat_result_void_ICU4XError ICU4XLocale_region(const ICU4XLocale* self, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XLocale_set_region(ICU4XLocale* self, const char* bytes_data, size_t bytes_len); + +diplomat_result_void_ICU4XError ICU4XLocale_script(const ICU4XLocale* self, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XLocale_set_script(ICU4XLocale* self, const char* bytes_data, size_t bytes_len); + +diplomat_result_void_ICU4XError ICU4XLocale_canonicalize(const char* bytes_data, size_t bytes_len, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XLocale_to_string(const ICU4XLocale* self, DiplomatWriteable* write); + +bool ICU4XLocale_normalizing_eq(const ICU4XLocale* self, const char* other_data, size_t other_len); + +ICU4XOrdering ICU4XLocale_strict_cmp(const ICU4XLocale* self, const char* other_data, size_t other_len); + +ICU4XLocale* ICU4XLocale_create_en(); + +ICU4XLocale* ICU4XLocale_create_bn(); +void ICU4XLocale_destroy(ICU4XLocale* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XLocaleCanonicalizer.h b/third_party/rust/icu_capi/c/include/ICU4XLocaleCanonicalizer.h new file mode 100644 index 000000000000..8b48ad8bb602 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XLocaleCanonicalizer.h @@ -0,0 +1,37 @@ +#ifndef ICU4XLocaleCanonicalizer_H +#define ICU4XLocaleCanonicalizer_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLocaleCanonicalizer ICU4XLocaleCanonicalizer; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError.h" +#include "ICU4XLocale.h" +#include "ICU4XTransformResult.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError ICU4XLocaleCanonicalizer_create(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError ICU4XLocaleCanonicalizer_create_extended(const ICU4XDataProvider* provider); + +ICU4XTransformResult ICU4XLocaleCanonicalizer_canonicalize(const ICU4XLocaleCanonicalizer* self, ICU4XLocale* locale); +void ICU4XLocaleCanonicalizer_destroy(ICU4XLocaleCanonicalizer* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XLocaleDisplayNamesFormatter.h b/third_party/rust/icu_capi/c/include/ICU4XLocaleDisplayNamesFormatter.h new file mode 100644 index 000000000000..0e164017f485 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XLocaleDisplayNamesFormatter.h @@ -0,0 +1,36 @@ +#ifndef ICU4XLocaleDisplayNamesFormatter_H +#define ICU4XLocaleDisplayNamesFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLocaleDisplayNamesFormatter ICU4XLocaleDisplayNamesFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XDisplayNamesOptionsV1.h" +#include "diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError ICU4XLocaleDisplayNamesFormatter_try_new_unstable(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XDisplayNamesOptionsV1 options); + +diplomat_result_void_ICU4XError ICU4XLocaleDisplayNamesFormatter_of(const ICU4XLocaleDisplayNamesFormatter* self, const ICU4XLocale* locale, DiplomatWriteable* write); +void ICU4XLocaleDisplayNamesFormatter_destroy(ICU4XLocaleDisplayNamesFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XLocaleExpander.h b/third_party/rust/icu_capi/c/include/ICU4XLocaleExpander.h new file mode 100644 index 000000000000..a7de7be16b91 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XLocaleExpander.h @@ -0,0 +1,39 @@ +#ifndef ICU4XLocaleExpander_H +#define ICU4XLocaleExpander_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLocaleExpander ICU4XLocaleExpander; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XLocaleExpander_ICU4XError.h" +#include "ICU4XLocale.h" +#include "ICU4XTransformResult.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XLocaleExpander_ICU4XError ICU4XLocaleExpander_create(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XLocaleExpander_ICU4XError ICU4XLocaleExpander_create_extended(const ICU4XDataProvider* provider); + +ICU4XTransformResult ICU4XLocaleExpander_maximize(const ICU4XLocaleExpander* self, ICU4XLocale* locale); + +ICU4XTransformResult ICU4XLocaleExpander_minimize(const ICU4XLocaleExpander* self, ICU4XLocale* locale); +void ICU4XLocaleExpander_destroy(ICU4XLocaleExpander* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XLocaleFallbackConfig.h b/third_party/rust/icu_capi/c/include/ICU4XLocaleFallbackConfig.h new file mode 100644 index 000000000000..b3741e6bf0f5 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XLocaleFallbackConfig.h @@ -0,0 +1,33 @@ +#ifndef ICU4XLocaleFallbackConfig_H +#define ICU4XLocaleFallbackConfig_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XLocaleFallbackPriority.h" +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLocaleFallbackConfig { + ICU4XLocaleFallbackPriority priority; + DiplomatStringView extension_key; +} ICU4XLocaleFallbackConfig; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XLocaleFallbackPriority.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XLocaleFallbackConfig_destroy(ICU4XLocaleFallbackConfig* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XLocaleFallbackIterator.h b/third_party/rust/icu_capi/c/include/ICU4XLocaleFallbackIterator.h new file mode 100644 index 000000000000..e2dd7a1a3bab --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XLocaleFallbackIterator.h @@ -0,0 +1,32 @@ +#ifndef ICU4XLocaleFallbackIterator_H +#define ICU4XLocaleFallbackIterator_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLocaleFallbackIterator ICU4XLocaleFallbackIterator; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XLocale.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +ICU4XLocale* ICU4XLocaleFallbackIterator_get(const ICU4XLocaleFallbackIterator* self); + +void ICU4XLocaleFallbackIterator_step(ICU4XLocaleFallbackIterator* self); +void ICU4XLocaleFallbackIterator_destroy(ICU4XLocaleFallbackIterator* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XLocaleFallbackPriority.h b/third_party/rust/icu_capi/c/include/ICU4XLocaleFallbackPriority.h new file mode 100644 index 000000000000..e4ab748065c8 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XLocaleFallbackPriority.h @@ -0,0 +1,32 @@ +#ifndef ICU4XLocaleFallbackPriority_H +#define ICU4XLocaleFallbackPriority_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XLocaleFallbackPriority { + ICU4XLocaleFallbackPriority_Language = 0, + ICU4XLocaleFallbackPriority_Region = 1, + ICU4XLocaleFallbackPriority_Collation = 2, +} ICU4XLocaleFallbackPriority; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XLocaleFallbackPriority_destroy(ICU4XLocaleFallbackPriority* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XLocaleFallbacker.h b/third_party/rust/icu_capi/c/include/ICU4XLocaleFallbacker.h new file mode 100644 index 000000000000..24efb0602f66 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XLocaleFallbacker.h @@ -0,0 +1,37 @@ +#ifndef ICU4XLocaleFallbacker_H +#define ICU4XLocaleFallbacker_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLocaleFallbacker ICU4XLocaleFallbacker; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError.h" +#include "ICU4XLocaleFallbackConfig.h" +#include "diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError ICU4XLocaleFallbacker_create(const ICU4XDataProvider* provider); + +ICU4XLocaleFallbacker* ICU4XLocaleFallbacker_create_without_data(); + +diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError ICU4XLocaleFallbacker_for_config(const ICU4XLocaleFallbacker* self, ICU4XLocaleFallbackConfig config); +void ICU4XLocaleFallbacker_destroy(ICU4XLocaleFallbacker* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XLocaleFallbackerWithConfig.h b/third_party/rust/icu_capi/c/include/ICU4XLocaleFallbackerWithConfig.h new file mode 100644 index 000000000000..e8baa9563e86 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XLocaleFallbackerWithConfig.h @@ -0,0 +1,31 @@ +#ifndef ICU4XLocaleFallbackerWithConfig_H +#define ICU4XLocaleFallbackerWithConfig_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLocaleFallbackerWithConfig ICU4XLocaleFallbackerWithConfig; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XLocale.h" +#include "ICU4XLocaleFallbackIterator.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +ICU4XLocaleFallbackIterator* ICU4XLocaleFallbackerWithConfig_fallback_for_locale(const ICU4XLocaleFallbackerWithConfig* self, const ICU4XLocale* locale); +void ICU4XLocaleFallbackerWithConfig_destroy(ICU4XLocaleFallbackerWithConfig* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XLogger.h b/third_party/rust/icu_capi/c/include/ICU4XLogger.h new file mode 100644 index 000000000000..3c3a1b8fa321 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XLogger.h @@ -0,0 +1,29 @@ +#ifndef ICU4XLogger_H +#define ICU4XLogger_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLogger ICU4XLogger; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +bool ICU4XLogger_init_simple_logger(); +void ICU4XLogger_destroy(ICU4XLogger* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XMetazoneCalculator.h b/third_party/rust/icu_capi/c/include/ICU4XMetazoneCalculator.h new file mode 100644 index 000000000000..9c66754e90eb --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XMetazoneCalculator.h @@ -0,0 +1,31 @@ +#ifndef ICU4XMetazoneCalculator_H +#define ICU4XMetazoneCalculator_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XMetazoneCalculator ICU4XMetazoneCalculator; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError ICU4XMetazoneCalculator_create(const ICU4XDataProvider* provider); +void ICU4XMetazoneCalculator_destroy(ICU4XMetazoneCalculator* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XOrdering.h b/third_party/rust/icu_capi/c/include/ICU4XOrdering.h new file mode 100644 index 000000000000..2c1885f43e2b --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XOrdering.h @@ -0,0 +1,32 @@ +#ifndef ICU4XOrdering_H +#define ICU4XOrdering_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XOrdering { + ICU4XOrdering_Less = -1, + ICU4XOrdering_Equal = 0, + ICU4XOrdering_Greater = 1, +} ICU4XOrdering; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XOrdering_destroy(ICU4XOrdering* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XPluralCategories.h b/third_party/rust/icu_capi/c/include/ICU4XPluralCategories.h new file mode 100644 index 000000000000..931ea2daa794 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XPluralCategories.h @@ -0,0 +1,35 @@ +#ifndef ICU4XPluralCategories_H +#define ICU4XPluralCategories_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XPluralCategories { + bool zero; + bool one; + bool two; + bool few; + bool many; + bool other; +} ICU4XPluralCategories; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XPluralCategories_destroy(ICU4XPluralCategories* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XPluralCategory.h b/third_party/rust/icu_capi/c/include/ICU4XPluralCategory.h new file mode 100644 index 000000000000..543681c74646 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XPluralCategory.h @@ -0,0 +1,37 @@ +#ifndef ICU4XPluralCategory_H +#define ICU4XPluralCategory_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XPluralCategory { + ICU4XPluralCategory_Zero = 0, + ICU4XPluralCategory_One = 1, + ICU4XPluralCategory_Two = 2, + ICU4XPluralCategory_Few = 3, + ICU4XPluralCategory_Many = 4, + ICU4XPluralCategory_Other = 5, +} ICU4XPluralCategory; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_ICU4XPluralCategory_void.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_ICU4XPluralCategory_void ICU4XPluralCategory_get_for_cldr_string(const char* s_data, size_t s_len); +void ICU4XPluralCategory_destroy(ICU4XPluralCategory* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XPluralOperands.h b/third_party/rust/icu_capi/c/include/ICU4XPluralOperands.h new file mode 100644 index 000000000000..14d997555f78 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XPluralOperands.h @@ -0,0 +1,30 @@ +#ifndef ICU4XPluralOperands_H +#define ICU4XPluralOperands_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XPluralOperands ICU4XPluralOperands; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_box_ICU4XPluralOperands_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XPluralOperands_ICU4XError ICU4XPluralOperands_create_from_string(const char* s_data, size_t s_len); +void ICU4XPluralOperands_destroy(ICU4XPluralOperands* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XPluralRules.h b/third_party/rust/icu_capi/c/include/ICU4XPluralRules.h new file mode 100644 index 000000000000..0794a7ac8ef3 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XPluralRules.h @@ -0,0 +1,41 @@ +#ifndef ICU4XPluralRules_H +#define ICU4XPluralRules_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XPluralRules ICU4XPluralRules; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "diplomat_result_box_ICU4XPluralRules_ICU4XError.h" +#include "ICU4XPluralOperands.h" +#include "ICU4XPluralCategory.h" +#include "ICU4XPluralCategories.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XPluralRules_ICU4XError ICU4XPluralRules_create_cardinal(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +diplomat_result_box_ICU4XPluralRules_ICU4XError ICU4XPluralRules_create_ordinal(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +ICU4XPluralCategory ICU4XPluralRules_category_for(const ICU4XPluralRules* self, const ICU4XPluralOperands* op); + +ICU4XPluralCategories ICU4XPluralRules_categories(const ICU4XPluralRules* self); +void ICU4XPluralRules_destroy(ICU4XPluralRules* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XPropertyValueNameToEnumMapper.h b/third_party/rust/icu_capi/c/include/ICU4XPropertyValueNameToEnumMapper.h new file mode 100644 index 000000000000..7598c1837204 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XPropertyValueNameToEnumMapper.h @@ -0,0 +1,49 @@ +#ifndef ICU4XPropertyValueNameToEnumMapper_H +#define ICU4XPropertyValueNameToEnumMapper_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XPropertyValueNameToEnumMapper ICU4XPropertyValueNameToEnumMapper; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int16_t ICU4XPropertyValueNameToEnumMapper_get_strict(const ICU4XPropertyValueNameToEnumMapper* self, const char* name_data, size_t name_len); + +int16_t ICU4XPropertyValueNameToEnumMapper_get_loose(const ICU4XPropertyValueNameToEnumMapper* self, const char* name_data, size_t name_len); + +diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError ICU4XPropertyValueNameToEnumMapper_load_general_category(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError ICU4XPropertyValueNameToEnumMapper_load_bidi_class(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError ICU4XPropertyValueNameToEnumMapper_load_east_asian_width(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError ICU4XPropertyValueNameToEnumMapper_load_line_break(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError ICU4XPropertyValueNameToEnumMapper_load_grapheme_cluster_break(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError ICU4XPropertyValueNameToEnumMapper_load_word_break(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError ICU4XPropertyValueNameToEnumMapper_load_sentence_break(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError ICU4XPropertyValueNameToEnumMapper_load_script(const ICU4XDataProvider* provider); +void ICU4XPropertyValueNameToEnumMapper_destroy(ICU4XPropertyValueNameToEnumMapper* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XRegionDisplayNames.h b/third_party/rust/icu_capi/c/include/ICU4XRegionDisplayNames.h new file mode 100644 index 000000000000..aa8a65020395 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XRegionDisplayNames.h @@ -0,0 +1,35 @@ +#ifndef ICU4XRegionDisplayNames_H +#define ICU4XRegionDisplayNames_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XRegionDisplayNames ICU4XRegionDisplayNames; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError ICU4XRegionDisplayNames_try_new_unstable(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +diplomat_result_void_ICU4XError ICU4XRegionDisplayNames_of(const ICU4XRegionDisplayNames* self, const char* region_data, size_t region_len, DiplomatWriteable* write); +void ICU4XRegionDisplayNames_destroy(ICU4XRegionDisplayNames* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XReorderedIndexMap.h b/third_party/rust/icu_capi/c/include/ICU4XReorderedIndexMap.h new file mode 100644 index 000000000000..f5507a72178f --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XReorderedIndexMap.h @@ -0,0 +1,33 @@ +#ifndef ICU4XReorderedIndexMap_H +#define ICU4XReorderedIndexMap_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XReorderedIndexMap ICU4XReorderedIndexMap; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +DiplomatUsizeView ICU4XReorderedIndexMap_as_slice(const ICU4XReorderedIndexMap* self); + +size_t ICU4XReorderedIndexMap_len(const ICU4XReorderedIndexMap* self); + +size_t ICU4XReorderedIndexMap_get(const ICU4XReorderedIndexMap* self, size_t index); +void ICU4XReorderedIndexMap_destroy(ICU4XReorderedIndexMap* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XScriptExtensionsSet.h b/third_party/rust/icu_capi/c/include/ICU4XScriptExtensionsSet.h new file mode 100644 index 000000000000..b4982dc22c34 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XScriptExtensionsSet.h @@ -0,0 +1,34 @@ +#ifndef ICU4XScriptExtensionsSet_H +#define ICU4XScriptExtensionsSet_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XScriptExtensionsSet ICU4XScriptExtensionsSet; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_uint16_t_void.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +bool ICU4XScriptExtensionsSet_contains(const ICU4XScriptExtensionsSet* self, uint16_t script); + +size_t ICU4XScriptExtensionsSet_count(const ICU4XScriptExtensionsSet* self); + +diplomat_result_uint16_t_void ICU4XScriptExtensionsSet_script_at(const ICU4XScriptExtensionsSet* self, size_t index); +void ICU4XScriptExtensionsSet_destroy(ICU4XScriptExtensionsSet* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XScriptWithExtensions.h b/third_party/rust/icu_capi/c/include/ICU4XScriptWithExtensions.h new file mode 100644 index 000000000000..df2dd5394649 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XScriptWithExtensions.h @@ -0,0 +1,41 @@ +#ifndef ICU4XScriptWithExtensions_H +#define ICU4XScriptWithExtensions_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XScriptWithExtensions ICU4XScriptWithExtensions; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError.h" +#include "ICU4XScriptWithExtensionsBorrowed.h" +#include "CodePointRangeIterator.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError ICU4XScriptWithExtensions_create(const ICU4XDataProvider* provider); + +uint16_t ICU4XScriptWithExtensions_get_script_val(const ICU4XScriptWithExtensions* self, uint32_t code_point); + +bool ICU4XScriptWithExtensions_has_script(const ICU4XScriptWithExtensions* self, uint32_t code_point, uint16_t script); + +ICU4XScriptWithExtensionsBorrowed* ICU4XScriptWithExtensions_as_borrowed(const ICU4XScriptWithExtensions* self); + +CodePointRangeIterator* ICU4XScriptWithExtensions_iter_ranges_for_script(const ICU4XScriptWithExtensions* self, uint16_t script); +void ICU4XScriptWithExtensions_destroy(ICU4XScriptWithExtensions* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XScriptWithExtensionsBorrowed.h b/third_party/rust/icu_capi/c/include/ICU4XScriptWithExtensionsBorrowed.h new file mode 100644 index 000000000000..905b5ecc6bb0 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XScriptWithExtensionsBorrowed.h @@ -0,0 +1,34 @@ +#ifndef ICU4XScriptWithExtensionsBorrowed_H +#define ICU4XScriptWithExtensionsBorrowed_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XScriptWithExtensionsBorrowed ICU4XScriptWithExtensionsBorrowed; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XScriptExtensionsSet.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +uint16_t ICU4XScriptWithExtensionsBorrowed_get_script_val(const ICU4XScriptWithExtensionsBorrowed* self, uint32_t code_point); + +ICU4XScriptExtensionsSet* ICU4XScriptWithExtensionsBorrowed_get_script_extensions_val(const ICU4XScriptWithExtensionsBorrowed* self, uint32_t code_point); + +bool ICU4XScriptWithExtensionsBorrowed_has_script(const ICU4XScriptWithExtensionsBorrowed* self, uint32_t code_point, uint16_t script); +void ICU4XScriptWithExtensionsBorrowed_destroy(ICU4XScriptWithExtensionsBorrowed* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XSegmenterWordType.h b/third_party/rust/icu_capi/c/include/ICU4XSegmenterWordType.h new file mode 100644 index 000000000000..9f4f81cf10ce --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XSegmenterWordType.h @@ -0,0 +1,32 @@ +#ifndef ICU4XSegmenterWordType_H +#define ICU4XSegmenterWordType_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XSegmenterWordType { + ICU4XSegmenterWordType_None = 0, + ICU4XSegmenterWordType_Number = 1, + ICU4XSegmenterWordType_Letter = 2, +} ICU4XSegmenterWordType; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XSegmenterWordType_destroy(ICU4XSegmenterWordType* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XSentenceBreakIteratorLatin1.h b/third_party/rust/icu_capi/c/include/ICU4XSentenceBreakIteratorLatin1.h new file mode 100644 index 000000000000..6dd7b132dc37 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XSentenceBreakIteratorLatin1.h @@ -0,0 +1,29 @@ +#ifndef ICU4XSentenceBreakIteratorLatin1_H +#define ICU4XSentenceBreakIteratorLatin1_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XSentenceBreakIteratorLatin1 ICU4XSentenceBreakIteratorLatin1; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XSentenceBreakIteratorLatin1_next(ICU4XSentenceBreakIteratorLatin1* self); +void ICU4XSentenceBreakIteratorLatin1_destroy(ICU4XSentenceBreakIteratorLatin1* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XSentenceBreakIteratorUtf16.h b/third_party/rust/icu_capi/c/include/ICU4XSentenceBreakIteratorUtf16.h new file mode 100644 index 000000000000..3ed0dc18c34c --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XSentenceBreakIteratorUtf16.h @@ -0,0 +1,29 @@ +#ifndef ICU4XSentenceBreakIteratorUtf16_H +#define ICU4XSentenceBreakIteratorUtf16_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XSentenceBreakIteratorUtf16 ICU4XSentenceBreakIteratorUtf16; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XSentenceBreakIteratorUtf16_next(ICU4XSentenceBreakIteratorUtf16* self); +void ICU4XSentenceBreakIteratorUtf16_destroy(ICU4XSentenceBreakIteratorUtf16* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XSentenceBreakIteratorUtf8.h b/third_party/rust/icu_capi/c/include/ICU4XSentenceBreakIteratorUtf8.h new file mode 100644 index 000000000000..655cb67b6cd1 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XSentenceBreakIteratorUtf8.h @@ -0,0 +1,29 @@ +#ifndef ICU4XSentenceBreakIteratorUtf8_H +#define ICU4XSentenceBreakIteratorUtf8_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XSentenceBreakIteratorUtf8 ICU4XSentenceBreakIteratorUtf8; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XSentenceBreakIteratorUtf8_next(ICU4XSentenceBreakIteratorUtf8* self); +void ICU4XSentenceBreakIteratorUtf8_destroy(ICU4XSentenceBreakIteratorUtf8* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XSentenceSegmenter.h b/third_party/rust/icu_capi/c/include/ICU4XSentenceSegmenter.h new file mode 100644 index 000000000000..7701c9f04289 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XSentenceSegmenter.h @@ -0,0 +1,40 @@ +#ifndef ICU4XSentenceSegmenter_H +#define ICU4XSentenceSegmenter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XSentenceSegmenter ICU4XSentenceSegmenter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError.h" +#include "ICU4XSentenceBreakIteratorUtf8.h" +#include "ICU4XSentenceBreakIteratorUtf16.h" +#include "ICU4XSentenceBreakIteratorLatin1.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError ICU4XSentenceSegmenter_create(const ICU4XDataProvider* provider); + +ICU4XSentenceBreakIteratorUtf8* ICU4XSentenceSegmenter_segment_utf8(const ICU4XSentenceSegmenter* self, const char* input_data, size_t input_len); + +ICU4XSentenceBreakIteratorUtf16* ICU4XSentenceSegmenter_segment_utf16(const ICU4XSentenceSegmenter* self, const uint16_t* input_data, size_t input_len); + +ICU4XSentenceBreakIteratorLatin1* ICU4XSentenceSegmenter_segment_latin1(const ICU4XSentenceSegmenter* self, const uint8_t* input_data, size_t input_len); +void ICU4XSentenceSegmenter_destroy(ICU4XSentenceSegmenter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XTime.h b/third_party/rust/icu_capi/c/include/ICU4XTime.h new file mode 100644 index 000000000000..d92fef92e4b8 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XTime.h @@ -0,0 +1,38 @@ +#ifndef ICU4XTime_H +#define ICU4XTime_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XTime ICU4XTime; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_box_ICU4XTime_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XTime_ICU4XError ICU4XTime_create(uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond); + +uint8_t ICU4XTime_hour(const ICU4XTime* self); + +uint8_t ICU4XTime_minute(const ICU4XTime* self); + +uint8_t ICU4XTime_second(const ICU4XTime* self); + +uint32_t ICU4XTime_nanosecond(const ICU4XTime* self); +void ICU4XTime_destroy(ICU4XTime* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XTimeFormatter.h b/third_party/rust/icu_capi/c/include/ICU4XTimeFormatter.h new file mode 100644 index 000000000000..d200881399fa --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XTimeFormatter.h @@ -0,0 +1,43 @@ +#ifndef ICU4XTimeFormatter_H +#define ICU4XTimeFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XTimeFormatter ICU4XTimeFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XTimeLength.h" +#include "diplomat_result_box_ICU4XTimeFormatter_ICU4XError.h" +#include "ICU4XTime.h" +#include "diplomat_result_void_ICU4XError.h" +#include "ICU4XDateTime.h" +#include "ICU4XIsoDateTime.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XTimeFormatter_ICU4XError ICU4XTimeFormatter_create_with_length(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XTimeLength length); + +diplomat_result_void_ICU4XError ICU4XTimeFormatter_format_time(const ICU4XTimeFormatter* self, const ICU4XTime* value, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XTimeFormatter_format_datetime(const ICU4XTimeFormatter* self, const ICU4XDateTime* value, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XTimeFormatter_format_iso_datetime(const ICU4XTimeFormatter* self, const ICU4XIsoDateTime* value, DiplomatWriteable* write); +void ICU4XTimeFormatter_destroy(ICU4XTimeFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XTimeLength.h b/third_party/rust/icu_capi/c/include/ICU4XTimeLength.h new file mode 100644 index 000000000000..6d98bc8ccb59 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XTimeLength.h @@ -0,0 +1,33 @@ +#ifndef ICU4XTimeLength_H +#define ICU4XTimeLength_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XTimeLength { + ICU4XTimeLength_Full = 0, + ICU4XTimeLength_Long = 1, + ICU4XTimeLength_Medium = 2, + ICU4XTimeLength_Short = 3, +} ICU4XTimeLength; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XTimeLength_destroy(ICU4XTimeLength* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XTimeZoneFormatter.h b/third_party/rust/icu_capi/c/include/ICU4XTimeZoneFormatter.h new file mode 100644 index 000000000000..c11abf4362cb --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XTimeZoneFormatter.h @@ -0,0 +1,53 @@ +#ifndef ICU4XTimeZoneFormatter_H +#define ICU4XTimeZoneFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XTimeZoneFormatter ICU4XTimeZoneFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError.h" +#include "ICU4XIsoTimeZoneOptions.h" +#include "diplomat_result_void_ICU4XError.h" +#include "ICU4XCustomTimeZone.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError ICU4XTimeZoneFormatter_create_with_localized_gmt_fallback(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError ICU4XTimeZoneFormatter_create_with_iso_8601_fallback(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XIsoTimeZoneOptions options); + +diplomat_result_void_ICU4XError ICU4XTimeZoneFormatter_load_generic_non_location_long(ICU4XTimeZoneFormatter* self, const ICU4XDataProvider* provider); + +diplomat_result_void_ICU4XError ICU4XTimeZoneFormatter_load_generic_non_location_short(ICU4XTimeZoneFormatter* self, const ICU4XDataProvider* provider); + +diplomat_result_void_ICU4XError ICU4XTimeZoneFormatter_load_specific_non_location_long(ICU4XTimeZoneFormatter* self, const ICU4XDataProvider* provider); + +diplomat_result_void_ICU4XError ICU4XTimeZoneFormatter_load_specific_non_location_short(ICU4XTimeZoneFormatter* self, const ICU4XDataProvider* provider); + +diplomat_result_void_ICU4XError ICU4XTimeZoneFormatter_load_generic_location_format(ICU4XTimeZoneFormatter* self, const ICU4XDataProvider* provider); + +diplomat_result_void_ICU4XError ICU4XTimeZoneFormatter_load_localized_gmt_format(ICU4XTimeZoneFormatter* self); + +diplomat_result_void_ICU4XError ICU4XTimeZoneFormatter_load_iso_8601_format(ICU4XTimeZoneFormatter* self, ICU4XIsoTimeZoneOptions options); + +diplomat_result_void_ICU4XError ICU4XTimeZoneFormatter_format_custom_time_zone(const ICU4XTimeZoneFormatter* self, const ICU4XCustomTimeZone* value, DiplomatWriteable* write); +void ICU4XTimeZoneFormatter_destroy(ICU4XTimeZoneFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XTransformResult.h b/third_party/rust/icu_capi/c/include/ICU4XTransformResult.h new file mode 100644 index 000000000000..66b268e266a7 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XTransformResult.h @@ -0,0 +1,31 @@ +#ifndef ICU4XTransformResult_H +#define ICU4XTransformResult_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XTransformResult { + ICU4XTransformResult_Modified = 0, + ICU4XTransformResult_Unmodified = 1, +} ICU4XTransformResult; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XTransformResult_destroy(ICU4XTransformResult* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XUnicodeSetData.h b/third_party/rust/icu_capi/c/include/ICU4XUnicodeSetData.h new file mode 100644 index 000000000000..3e10e53097e5 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XUnicodeSetData.h @@ -0,0 +1,48 @@ +#ifndef ICU4XUnicodeSetData_H +#define ICU4XUnicodeSetData_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XUnicodeSetData ICU4XUnicodeSetData; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XUnicodeSetData_ICU4XError.h" +#include "ICU4XLocale.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +bool ICU4XUnicodeSetData_contains(const ICU4XUnicodeSetData* self, const char* s_data, size_t s_len); + +bool ICU4XUnicodeSetData_contains_char(const ICU4XUnicodeSetData* self, char32_t cp); + +bool ICU4XUnicodeSetData_contains32(const ICU4XUnicodeSetData* self, uint32_t cp); + +diplomat_result_box_ICU4XUnicodeSetData_ICU4XError ICU4XUnicodeSetData_load_basic_emoji(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XUnicodeSetData_ICU4XError ICU4XUnicodeSetData_load_exemplars_main(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +diplomat_result_box_ICU4XUnicodeSetData_ICU4XError ICU4XUnicodeSetData_load_exemplars_auxiliary(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +diplomat_result_box_ICU4XUnicodeSetData_ICU4XError ICU4XUnicodeSetData_load_exemplars_punctuation(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +diplomat_result_box_ICU4XUnicodeSetData_ICU4XError ICU4XUnicodeSetData_load_exemplars_numbers(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +diplomat_result_box_ICU4XUnicodeSetData_ICU4XError ICU4XUnicodeSetData_load_exemplars_index(const ICU4XDataProvider* provider, const ICU4XLocale* locale); +void ICU4XUnicodeSetData_destroy(ICU4XUnicodeSetData* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XWeekCalculator.h b/third_party/rust/icu_capi/c/include/ICU4XWeekCalculator.h new file mode 100644 index 000000000000..02a52c6e87be --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XWeekCalculator.h @@ -0,0 +1,39 @@ +#ifndef ICU4XWeekCalculator_H +#define ICU4XWeekCalculator_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XWeekCalculator ICU4XWeekCalculator; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "diplomat_result_box_ICU4XWeekCalculator_ICU4XError.h" +#include "ICU4XIsoWeekday.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XWeekCalculator_ICU4XError ICU4XWeekCalculator_create(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +ICU4XWeekCalculator* ICU4XWeekCalculator_create_from_first_day_of_week_and_min_week_days(ICU4XIsoWeekday first_weekday, uint8_t min_week_days); + +ICU4XIsoWeekday ICU4XWeekCalculator_first_weekday(const ICU4XWeekCalculator* self); + +uint8_t ICU4XWeekCalculator_min_week_days(const ICU4XWeekCalculator* self); +void ICU4XWeekCalculator_destroy(ICU4XWeekCalculator* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XWeekOf.h b/third_party/rust/icu_capi/c/include/ICU4XWeekOf.h new file mode 100644 index 000000000000..5441b943d41f --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XWeekOf.h @@ -0,0 +1,33 @@ +#ifndef ICU4XWeekOf_H +#define ICU4XWeekOf_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XWeekRelativeUnit.h" +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XWeekOf { + uint16_t week; + ICU4XWeekRelativeUnit unit; +} ICU4XWeekOf; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XWeekRelativeUnit.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XWeekOf_destroy(ICU4XWeekOf* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XWeekRelativeUnit.h b/third_party/rust/icu_capi/c/include/ICU4XWeekRelativeUnit.h new file mode 100644 index 000000000000..ee6802dc3b37 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XWeekRelativeUnit.h @@ -0,0 +1,32 @@ +#ifndef ICU4XWeekRelativeUnit_H +#define ICU4XWeekRelativeUnit_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XWeekRelativeUnit { + ICU4XWeekRelativeUnit_Previous = 0, + ICU4XWeekRelativeUnit_Current = 1, + ICU4XWeekRelativeUnit_Next = 2, +} ICU4XWeekRelativeUnit; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XWeekRelativeUnit_destroy(ICU4XWeekRelativeUnit* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XWordBreakIteratorLatin1.h b/third_party/rust/icu_capi/c/include/ICU4XWordBreakIteratorLatin1.h new file mode 100644 index 000000000000..112025bdf510 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XWordBreakIteratorLatin1.h @@ -0,0 +1,34 @@ +#ifndef ICU4XWordBreakIteratorLatin1_H +#define ICU4XWordBreakIteratorLatin1_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XWordBreakIteratorLatin1 ICU4XWordBreakIteratorLatin1; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XSegmenterWordType.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XWordBreakIteratorLatin1_next(ICU4XWordBreakIteratorLatin1* self); + +ICU4XSegmenterWordType ICU4XWordBreakIteratorLatin1_word_type(const ICU4XWordBreakIteratorLatin1* self); + +bool ICU4XWordBreakIteratorLatin1_is_word_like(const ICU4XWordBreakIteratorLatin1* self); +void ICU4XWordBreakIteratorLatin1_destroy(ICU4XWordBreakIteratorLatin1* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XWordBreakIteratorUtf16.h b/third_party/rust/icu_capi/c/include/ICU4XWordBreakIteratorUtf16.h new file mode 100644 index 000000000000..676aea3cff49 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XWordBreakIteratorUtf16.h @@ -0,0 +1,34 @@ +#ifndef ICU4XWordBreakIteratorUtf16_H +#define ICU4XWordBreakIteratorUtf16_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XWordBreakIteratorUtf16 ICU4XWordBreakIteratorUtf16; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XSegmenterWordType.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XWordBreakIteratorUtf16_next(ICU4XWordBreakIteratorUtf16* self); + +ICU4XSegmenterWordType ICU4XWordBreakIteratorUtf16_word_type(const ICU4XWordBreakIteratorUtf16* self); + +bool ICU4XWordBreakIteratorUtf16_is_word_like(const ICU4XWordBreakIteratorUtf16* self); +void ICU4XWordBreakIteratorUtf16_destroy(ICU4XWordBreakIteratorUtf16* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XWordBreakIteratorUtf8.h b/third_party/rust/icu_capi/c/include/ICU4XWordBreakIteratorUtf8.h new file mode 100644 index 000000000000..d8e98fb9b19d --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XWordBreakIteratorUtf8.h @@ -0,0 +1,34 @@ +#ifndef ICU4XWordBreakIteratorUtf8_H +#define ICU4XWordBreakIteratorUtf8_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XWordBreakIteratorUtf8 ICU4XWordBreakIteratorUtf8; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XSegmenterWordType.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XWordBreakIteratorUtf8_next(ICU4XWordBreakIteratorUtf8* self); + +ICU4XSegmenterWordType ICU4XWordBreakIteratorUtf8_word_type(const ICU4XWordBreakIteratorUtf8* self); + +bool ICU4XWordBreakIteratorUtf8_is_word_like(const ICU4XWordBreakIteratorUtf8* self); +void ICU4XWordBreakIteratorUtf8_destroy(ICU4XWordBreakIteratorUtf8* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XWordSegmenter.h b/third_party/rust/icu_capi/c/include/ICU4XWordSegmenter.h new file mode 100644 index 000000000000..5bef9437e092 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XWordSegmenter.h @@ -0,0 +1,44 @@ +#ifndef ICU4XWordSegmenter_H +#define ICU4XWordSegmenter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XWordSegmenter ICU4XWordSegmenter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XWordSegmenter_ICU4XError.h" +#include "ICU4XWordBreakIteratorUtf8.h" +#include "ICU4XWordBreakIteratorUtf16.h" +#include "ICU4XWordBreakIteratorLatin1.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XWordSegmenter_ICU4XError ICU4XWordSegmenter_create_auto(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XWordSegmenter_ICU4XError ICU4XWordSegmenter_create_lstm(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XWordSegmenter_ICU4XError ICU4XWordSegmenter_create_dictionary(const ICU4XDataProvider* provider); + +ICU4XWordBreakIteratorUtf8* ICU4XWordSegmenter_segment_utf8(const ICU4XWordSegmenter* self, const char* input_data, size_t input_len); + +ICU4XWordBreakIteratorUtf16* ICU4XWordSegmenter_segment_utf16(const ICU4XWordSegmenter* self, const uint16_t* input_data, size_t input_len); + +ICU4XWordBreakIteratorLatin1* ICU4XWordSegmenter_segment_latin1(const ICU4XWordSegmenter* self, const uint8_t* input_data, size_t input_len); +void ICU4XWordSegmenter_destroy(ICU4XWordSegmenter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/ICU4XZonedDateTimeFormatter.h b/third_party/rust/icu_capi/c/include/ICU4XZonedDateTimeFormatter.h new file mode 100644 index 000000000000..77b228a5a2cf --- /dev/null +++ b/third_party/rust/icu_capi/c/include/ICU4XZonedDateTimeFormatter.h @@ -0,0 +1,45 @@ +#ifndef ICU4XZonedDateTimeFormatter_H +#define ICU4XZonedDateTimeFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XZonedDateTimeFormatter ICU4XZonedDateTimeFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XDateLength.h" +#include "ICU4XTimeLength.h" +#include "diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError.h" +#include "ICU4XIsoTimeZoneOptions.h" +#include "ICU4XDateTime.h" +#include "ICU4XCustomTimeZone.h" +#include "diplomat_result_void_ICU4XError.h" +#include "ICU4XIsoDateTime.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError ICU4XZonedDateTimeFormatter_create_with_lengths(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XDateLength date_length, ICU4XTimeLength time_length); + +diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError ICU4XZonedDateTimeFormatter_create_with_lengths_and_iso_8601_time_zone_fallback(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XDateLength date_length, ICU4XTimeLength time_length, ICU4XIsoTimeZoneOptions zone_options); + +diplomat_result_void_ICU4XError ICU4XZonedDateTimeFormatter_format_datetime_with_custom_time_zone(const ICU4XZonedDateTimeFormatter* self, const ICU4XDateTime* datetime, const ICU4XCustomTimeZone* time_zone, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone(const ICU4XZonedDateTimeFormatter* self, const ICU4XIsoDateTime* datetime, const ICU4XCustomTimeZone* time_zone, DiplomatWriteable* write); +void ICU4XZonedDateTimeFormatter_destroy(ICU4XZonedDateTimeFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_ICU4XAnyCalendarKind_void.h b/third_party/rust/icu_capi/c/include/diplomat_result_ICU4XAnyCalendarKind_void.h new file mode 100644 index 000000000000..f67f66ed4db4 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_ICU4XAnyCalendarKind_void.h @@ -0,0 +1,24 @@ +#ifndef diplomat_result_ICU4XAnyCalendarKind_void_H +#define diplomat_result_ICU4XAnyCalendarKind_void_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XAnyCalendarKind.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_ICU4XAnyCalendarKind_void { + union { + ICU4XAnyCalendarKind ok; + }; + bool is_ok; +} diplomat_result_ICU4XAnyCalendarKind_void; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_ICU4XPluralCategory_void.h b/third_party/rust/icu_capi/c/include/diplomat_result_ICU4XPluralCategory_void.h new file mode 100644 index 000000000000..b56ef60acb7f --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_ICU4XPluralCategory_void.h @@ -0,0 +1,24 @@ +#ifndef diplomat_result_ICU4XPluralCategory_void_H +#define diplomat_result_ICU4XPluralCategory_void_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XPluralCategory.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_ICU4XPluralCategory_void { + union { + ICU4XPluralCategory ok; + }; + bool is_ok; +} diplomat_result_ICU4XPluralCategory_void; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_ICU4XWeekOf_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_ICU4XWeekOf_ICU4XError.h new file mode 100644 index 000000000000..4dee8f941f70 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_ICU4XWeekOf_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_ICU4XWeekOf_ICU4XError_H +#define diplomat_result_ICU4XWeekOf_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XWeekOf.h" +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_ICU4XWeekOf_ICU4XError { + union { + ICU4XWeekOf ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_ICU4XWeekOf_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_bool_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_bool_ICU4XError.h new file mode 100644 index 000000000000..015930214da6 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_bool_ICU4XError.h @@ -0,0 +1,25 @@ +#ifndef diplomat_result_bool_ICU4XError_H +#define diplomat_result_bool_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_bool_ICU4XError { + union { + bool ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_bool_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XBidi_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XBidi_ICU4XError.h new file mode 100644 index 000000000000..f1cd7ca6a30d --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XBidi_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XBidi_ICU4XError_H +#define diplomat_result_box_ICU4XBidi_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XBidi ICU4XBidi; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XBidi_ICU4XError { + union { + ICU4XBidi* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XBidi_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCalendar_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCalendar_ICU4XError.h new file mode 100644 index 000000000000..bffa22c6b027 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCalendar_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XCalendar_ICU4XError_H +#define diplomat_result_box_ICU4XCalendar_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XCalendar ICU4XCalendar; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XCalendar_ICU4XError { + union { + ICU4XCalendar* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XCalendar_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError.h new file mode 100644 index 000000000000..2c05f7967151 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError_H +#define diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XCanonicalCombiningClassMap ICU4XCanonicalCombiningClassMap; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError { + union { + ICU4XCanonicalCombiningClassMap* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCanonicalComposition_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCanonicalComposition_ICU4XError.h new file mode 100644 index 000000000000..66d0386ff8b0 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCanonicalComposition_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XCanonicalComposition_ICU4XError_H +#define diplomat_result_box_ICU4XCanonicalComposition_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XCanonicalComposition ICU4XCanonicalComposition; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XCanonicalComposition_ICU4XError { + union { + ICU4XCanonicalComposition* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XCanonicalComposition_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError.h new file mode 100644 index 000000000000..cf02637fef0f --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError_H +#define diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XCanonicalDecomposition ICU4XCanonicalDecomposition; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError { + union { + ICU4XCanonicalDecomposition* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCodePointMapData16_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCodePointMapData16_ICU4XError.h new file mode 100644 index 000000000000..fbe11daad2e1 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCodePointMapData16_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XCodePointMapData16_ICU4XError_H +#define diplomat_result_box_ICU4XCodePointMapData16_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XCodePointMapData16 ICU4XCodePointMapData16; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XCodePointMapData16_ICU4XError { + union { + ICU4XCodePointMapData16* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XCodePointMapData16_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCodePointMapData8_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCodePointMapData8_ICU4XError.h new file mode 100644 index 000000000000..2e203279e3b8 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCodePointMapData8_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XCodePointMapData8_ICU4XError_H +#define diplomat_result_box_ICU4XCodePointMapData8_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XCodePointMapData8 ICU4XCodePointMapData8; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XCodePointMapData8_ICU4XError { + union { + ICU4XCodePointMapData8* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XCodePointMapData8_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCodePointSetData_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCodePointSetData_ICU4XError.h new file mode 100644 index 000000000000..e70e39ba61dc --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCodePointSetData_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XCodePointSetData_ICU4XError_H +#define diplomat_result_box_ICU4XCodePointSetData_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XCodePointSetData ICU4XCodePointSetData; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XCodePointSetData_ICU4XError { + union { + ICU4XCodePointSetData* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XCodePointSetData_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCollator_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCollator_ICU4XError.h new file mode 100644 index 000000000000..abb5c8a59839 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCollator_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XCollator_ICU4XError_H +#define diplomat_result_box_ICU4XCollator_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XCollator ICU4XCollator; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XCollator_ICU4XError { + union { + ICU4XCollator* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XCollator_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XComposingNormalizer_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XComposingNormalizer_ICU4XError.h new file mode 100644 index 000000000000..d0c381ef039c --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XComposingNormalizer_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XComposingNormalizer_ICU4XError_H +#define diplomat_result_box_ICU4XComposingNormalizer_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XComposingNormalizer ICU4XComposingNormalizer; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XComposingNormalizer_ICU4XError { + union { + ICU4XComposingNormalizer* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XComposingNormalizer_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCustomTimeZone_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCustomTimeZone_ICU4XError.h new file mode 100644 index 000000000000..4709a89871e5 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XCustomTimeZone_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XCustomTimeZone_ICU4XError_H +#define diplomat_result_box_ICU4XCustomTimeZone_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XCustomTimeZone ICU4XCustomTimeZone; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XCustomTimeZone_ICU4XError { + union { + ICU4XCustomTimeZone* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XCustomTimeZone_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDataProvider_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDataProvider_ICU4XError.h new file mode 100644 index 000000000000..a5be84418382 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDataProvider_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XDataProvider_ICU4XError_H +#define diplomat_result_box_ICU4XDataProvider_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XDataProvider ICU4XDataProvider; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XDataProvider_ICU4XError { + union { + ICU4XDataProvider* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XDataProvider_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDataStruct_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDataStruct_ICU4XError.h new file mode 100644 index 000000000000..d8c1d33e2107 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDataStruct_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XDataStruct_ICU4XError_H +#define diplomat_result_box_ICU4XDataStruct_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XDataStruct ICU4XDataStruct; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XDataStruct_ICU4XError { + union { + ICU4XDataStruct* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XDataStruct_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDateFormatter_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDateFormatter_ICU4XError.h new file mode 100644 index 000000000000..b6d9671434c5 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDateFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XDateFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XDateFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XDateFormatter ICU4XDateFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XDateFormatter_ICU4XError { + union { + ICU4XDateFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XDateFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError.h new file mode 100644 index 000000000000..855e74fe6c06 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XDateTimeFormatter ICU4XDateTimeFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError { + union { + ICU4XDateTimeFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDateTime_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDateTime_ICU4XError.h new file mode 100644 index 000000000000..2d4cb2fe4840 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDateTime_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XDateTime_ICU4XError_H +#define diplomat_result_box_ICU4XDateTime_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XDateTime ICU4XDateTime; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XDateTime_ICU4XError { + union { + ICU4XDateTime* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XDateTime_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDate_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDate_ICU4XError.h new file mode 100644 index 000000000000..30461b264a65 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDate_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XDate_ICU4XError_H +#define diplomat_result_box_ICU4XDate_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XDate ICU4XDate; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XDate_ICU4XError { + union { + ICU4XDate* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XDate_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError.h new file mode 100644 index 000000000000..c51d9907bc9f --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError_H +#define diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XDecomposingNormalizer ICU4XDecomposingNormalizer; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError { + union { + ICU4XDecomposingNormalizer* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError.h new file mode 100644 index 000000000000..8ee245a09336 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XFixedDecimalFormatter ICU4XFixedDecimalFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError { + union { + ICU4XFixedDecimalFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XFixedDecimal_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XFixedDecimal_ICU4XError.h new file mode 100644 index 000000000000..f45cd78fb93b --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XFixedDecimal_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XFixedDecimal_ICU4XError_H +#define diplomat_result_box_ICU4XFixedDecimal_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XFixedDecimal ICU4XFixedDecimal; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XFixedDecimal_ICU4XError { + union { + ICU4XFixedDecimal* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XFixedDecimal_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError.h new file mode 100644 index 000000000000..98ff137a9a3c --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError_H +#define diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XGeneralCategoryNameToMaskMapper ICU4XGeneralCategoryNameToMaskMapper; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError { + union { + ICU4XGeneralCategoryNameToMaskMapper* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError.h new file mode 100644 index 000000000000..d560b381a59d --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError_H +#define diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XGraphemeClusterSegmenter ICU4XGraphemeClusterSegmenter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError { + union { + ICU4XGraphemeClusterSegmenter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError.h new file mode 100644 index 000000000000..86b13be9121b --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XGregorianDateFormatter ICU4XGregorianDateFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError { + union { + ICU4XGregorianDateFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError.h new file mode 100644 index 000000000000..4393d9ffb0fb --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XGregorianDateTimeFormatter ICU4XGregorianDateTimeFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError { + union { + ICU4XGregorianDateTimeFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError.h new file mode 100644 index 000000000000..270b38ba94ce --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XGregorianZonedDateTimeFormatter ICU4XGregorianZonedDateTimeFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError { + union { + ICU4XGregorianZonedDateTimeFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XIsoDateTime_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XIsoDateTime_ICU4XError.h new file mode 100644 index 000000000000..8a55b47a68b0 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XIsoDateTime_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XIsoDateTime_ICU4XError_H +#define diplomat_result_box_ICU4XIsoDateTime_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XIsoDateTime ICU4XIsoDateTime; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XIsoDateTime_ICU4XError { + union { + ICU4XIsoDateTime* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XIsoDateTime_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XIsoDate_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XIsoDate_ICU4XError.h new file mode 100644 index 000000000000..8528d73b0721 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XIsoDate_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XIsoDate_ICU4XError_H +#define diplomat_result_box_ICU4XIsoDate_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XIsoDate ICU4XIsoDate; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XIsoDate_ICU4XError { + union { + ICU4XIsoDate* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XIsoDate_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLineSegmenter_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLineSegmenter_ICU4XError.h new file mode 100644 index 000000000000..004d3494ae04 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLineSegmenter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XLineSegmenter_ICU4XError_H +#define diplomat_result_box_ICU4XLineSegmenter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XLineSegmenter ICU4XLineSegmenter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XLineSegmenter_ICU4XError { + union { + ICU4XLineSegmenter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XLineSegmenter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XListFormatter_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XListFormatter_ICU4XError.h new file mode 100644 index 000000000000..df40aa2daed1 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XListFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XListFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XListFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XListFormatter ICU4XListFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XListFormatter_ICU4XError { + union { + ICU4XListFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XListFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError.h new file mode 100644 index 000000000000..a49bb700ca67 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError_H +#define diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XLocaleCanonicalizer ICU4XLocaleCanonicalizer; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError { + union { + ICU4XLocaleCanonicalizer* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError.h new file mode 100644 index 000000000000..6b0f09b2a2ff --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XLocaleDisplayNamesFormatter ICU4XLocaleDisplayNamesFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError { + union { + ICU4XLocaleDisplayNamesFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleExpander_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleExpander_ICU4XError.h new file mode 100644 index 000000000000..c7275e699c2d --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleExpander_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XLocaleExpander_ICU4XError_H +#define diplomat_result_box_ICU4XLocaleExpander_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XLocaleExpander ICU4XLocaleExpander; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XLocaleExpander_ICU4XError { + union { + ICU4XLocaleExpander* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XLocaleExpander_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError.h new file mode 100644 index 000000000000..0dc002718e8c --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError_H +#define diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XLocaleFallbackerWithConfig ICU4XLocaleFallbackerWithConfig; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError { + union { + ICU4XLocaleFallbackerWithConfig* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError.h new file mode 100644 index 000000000000..3427bf3e3a35 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError_H +#define diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XLocaleFallbacker ICU4XLocaleFallbacker; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError { + union { + ICU4XLocaleFallbacker* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocale_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocale_ICU4XError.h new file mode 100644 index 000000000000..f5720b612f3d --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XLocale_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XLocale_ICU4XError_H +#define diplomat_result_box_ICU4XLocale_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XLocale ICU4XLocale; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XLocale_ICU4XError { + union { + ICU4XLocale* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XLocale_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError.h new file mode 100644 index 000000000000..ebd519e0b5b4 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError_H +#define diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XMetazoneCalculator ICU4XMetazoneCalculator; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError { + union { + ICU4XMetazoneCalculator* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XPluralOperands_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XPluralOperands_ICU4XError.h new file mode 100644 index 000000000000..7c068ba4b801 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XPluralOperands_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XPluralOperands_ICU4XError_H +#define diplomat_result_box_ICU4XPluralOperands_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XPluralOperands ICU4XPluralOperands; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XPluralOperands_ICU4XError { + union { + ICU4XPluralOperands* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XPluralOperands_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XPluralRules_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XPluralRules_ICU4XError.h new file mode 100644 index 000000000000..4fa522b8508f --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XPluralRules_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XPluralRules_ICU4XError_H +#define diplomat_result_box_ICU4XPluralRules_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XPluralRules ICU4XPluralRules; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XPluralRules_ICU4XError { + union { + ICU4XPluralRules* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XPluralRules_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError.h new file mode 100644 index 000000000000..047ef959b040 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError_H +#define diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XPropertyValueNameToEnumMapper ICU4XPropertyValueNameToEnumMapper; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError { + union { + ICU4XPropertyValueNameToEnumMapper* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError.h new file mode 100644 index 000000000000..fcf7e88a232a --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError_H +#define diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XRegionDisplayNames ICU4XRegionDisplayNames; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError { + union { + ICU4XRegionDisplayNames* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError.h new file mode 100644 index 000000000000..bffd6161aa8d --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError_H +#define diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XScriptWithExtensions ICU4XScriptWithExtensions; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError { + union { + ICU4XScriptWithExtensions* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError.h new file mode 100644 index 000000000000..a8ab968fa946 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError_H +#define diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XSentenceSegmenter ICU4XSentenceSegmenter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError { + union { + ICU4XSentenceSegmenter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XTimeFormatter_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XTimeFormatter_ICU4XError.h new file mode 100644 index 000000000000..0e63cbbc2a80 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XTimeFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XTimeFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XTimeFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XTimeFormatter ICU4XTimeFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XTimeFormatter_ICU4XError { + union { + ICU4XTimeFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XTimeFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError.h new file mode 100644 index 000000000000..5f4851051e9a --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XTimeZoneFormatter ICU4XTimeZoneFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError { + union { + ICU4XTimeZoneFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XTime_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XTime_ICU4XError.h new file mode 100644 index 000000000000..3e58b1e4daa6 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XTime_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XTime_ICU4XError_H +#define diplomat_result_box_ICU4XTime_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XTime ICU4XTime; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XTime_ICU4XError { + union { + ICU4XTime* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XTime_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XUnicodeSetData_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XUnicodeSetData_ICU4XError.h new file mode 100644 index 000000000000..6dd14e82b64d --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XUnicodeSetData_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XUnicodeSetData_ICU4XError_H +#define diplomat_result_box_ICU4XUnicodeSetData_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XUnicodeSetData ICU4XUnicodeSetData; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XUnicodeSetData_ICU4XError { + union { + ICU4XUnicodeSetData* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XUnicodeSetData_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XWeekCalculator_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XWeekCalculator_ICU4XError.h new file mode 100644 index 000000000000..1f547fd383c3 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XWeekCalculator_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XWeekCalculator_ICU4XError_H +#define diplomat_result_box_ICU4XWeekCalculator_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XWeekCalculator ICU4XWeekCalculator; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XWeekCalculator_ICU4XError { + union { + ICU4XWeekCalculator* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XWeekCalculator_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XWordSegmenter_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XWordSegmenter_ICU4XError.h new file mode 100644 index 000000000000..e41c59b661e1 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XWordSegmenter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XWordSegmenter_ICU4XError_H +#define diplomat_result_box_ICU4XWordSegmenter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XWordSegmenter ICU4XWordSegmenter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XWordSegmenter_ICU4XError { + union { + ICU4XWordSegmenter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XWordSegmenter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError.h new file mode 100644 index 000000000000..52a0ab446213 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XZonedDateTimeFormatter ICU4XZonedDateTimeFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError { + union { + ICU4XZonedDateTimeFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_int32_t_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_int32_t_ICU4XError.h new file mode 100644 index 000000000000..adbe148dd153 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_int32_t_ICU4XError.h @@ -0,0 +1,25 @@ +#ifndef diplomat_result_int32_t_ICU4XError_H +#define diplomat_result_int32_t_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_int32_t_ICU4XError { + union { + int32_t ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_int32_t_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_uint16_t_void.h b/third_party/rust/icu_capi/c/include/diplomat_result_uint16_t_void.h new file mode 100644 index 000000000000..3adeb5f36de3 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_uint16_t_void.h @@ -0,0 +1,23 @@ +#ifndef diplomat_result_uint16_t_void_H +#define diplomat_result_uint16_t_void_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_uint16_t_void { + union { + uint16_t ok; + }; + bool is_ok; +} diplomat_result_uint16_t_void; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_void_ICU4XError.h b/third_party/rust/icu_capi/c/include/diplomat_result_void_ICU4XError.h new file mode 100644 index 000000000000..f092491e3404 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_void_ICU4XError.h @@ -0,0 +1,24 @@ +#ifndef diplomat_result_void_ICU4XError_H +#define diplomat_result_void_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_void_ICU4XError { + union { + ICU4XError err; + }; + bool is_ok; +} diplomat_result_void_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_result_void_void.h b/third_party/rust/icu_capi/c/include/diplomat_result_void_void.h new file mode 100644 index 000000000000..2d5cc704e526 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_result_void_void.h @@ -0,0 +1,20 @@ +#ifndef diplomat_result_void_void_H +#define diplomat_result_void_void_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_void_void { + bool is_ok; +} diplomat_result_void_void; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/c/include/diplomat_runtime.h b/third_party/rust/icu_capi/c/include/diplomat_runtime.h new file mode 100644 index 000000000000..de0f9c76fee3 --- /dev/null +++ b/third_party/rust/icu_capi/c/include/diplomat_runtime.h @@ -0,0 +1,70 @@ +#ifndef DIPLOMAT_RUNTIME_C_H +#define DIPLOMAT_RUNTIME_C_H + +#include +#include +#include +#include + +// uchar.h doesn't always exist, but char32_t is always available +// in C++ anyway +#ifndef __cplusplus +#ifdef __APPLE__ +#include +typedef uint16_t char16_t; +typedef uint32_t char32_t; +#else +#include +#endif +#endif + + +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +typedef struct DiplomatWriteable { + void* context; + char* buf; + size_t len; + size_t cap; + void (*flush)(struct DiplomatWriteable*); + bool (*grow)(struct DiplomatWriteable*, size_t); +} DiplomatWriteable; + +DiplomatWriteable diplomat_simple_writeable(char* buf, size_t buf_size); + +typedef struct DiplomatStringView { + const char* data; + size_t len; +} DiplomatStringView; + +#define MAKE_SLICE_VIEW(name, c_ty) \ + typedef struct Diplomat##name##View { \ + const c_ty* data; \ + size_t len; \ + } Diplomat##name##View; + +MAKE_SLICE_VIEW(I8, int8_t) +MAKE_SLICE_VIEW(U8, uint8_t) +MAKE_SLICE_VIEW(I16, int16_t) +MAKE_SLICE_VIEW(U16, uint16_t) +MAKE_SLICE_VIEW(I32, int32_t) +MAKE_SLICE_VIEW(U32, uint32_t) +MAKE_SLICE_VIEW(I64, int64_t) +MAKE_SLICE_VIEW(U64, uint64_t) +MAKE_SLICE_VIEW(Isize, intptr_t) +MAKE_SLICE_VIEW(Usize, size_t) +MAKE_SLICE_VIEW(F32, float) +MAKE_SLICE_VIEW(F64, double) +MAKE_SLICE_VIEW(Bool, bool) +MAKE_SLICE_VIEW(Char, char32_t) + + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif + +#endif diff --git a/third_party/rust/icu_capi/cpp/README.md b/third_party/rust/icu_capi/cpp/README.md new file mode 100644 index 000000000000..0fd964e92ede --- /dev/null +++ b/third_party/rust/icu_capi/cpp/README.md @@ -0,0 +1,18 @@ +# C++ FFI for ICU4X + +This folder contains the C++ FFI for ICU4X. To re-generate the bindings run: + +```sh +cargo make diplomat-install +cargo make diplomat-gen-cpp +``` + +Or re-generate all of the bindings: + +```sh +cargo make diplomat-gen +``` + +## More Information + +For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x). diff --git a/third_party/rust/icu_capi/cpp/include/CodePointRangeIterator.h b/third_party/rust/icu_capi/cpp/include/CodePointRangeIterator.h new file mode 100644 index 000000000000..36d6d23175a0 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/CodePointRangeIterator.h @@ -0,0 +1,30 @@ +#ifndef CodePointRangeIterator_H +#define CodePointRangeIterator_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct CodePointRangeIterator CodePointRangeIterator; +#ifdef __cplusplus +} // namespace capi +#endif +#include "CodePointRangeIteratorResult.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +CodePointRangeIteratorResult CodePointRangeIterator_next(CodePointRangeIterator* self); +void CodePointRangeIterator_destroy(CodePointRangeIterator* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/CodePointRangeIterator.hpp b/third_party/rust/icu_capi/cpp/include/CodePointRangeIterator.hpp new file mode 100644 index 000000000000..3c2d5caef028 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/CodePointRangeIterator.hpp @@ -0,0 +1,54 @@ +#ifndef CodePointRangeIterator_HPP +#define CodePointRangeIterator_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "CodePointRangeIterator.h" + +struct CodePointRangeIteratorResult; + +/** + * A destruction policy for using CodePointRangeIterator with std::unique_ptr. + */ +struct CodePointRangeIteratorDeleter { + void operator()(capi::CodePointRangeIterator* l) const noexcept { + capi::CodePointRangeIterator_destroy(l); + } +}; + +/** + * An iterator over code point ranges, produced by `ICU4XCodePointSetData` or + * one of the `ICU4XCodePointMapData` types + */ +class CodePointRangeIterator { + public: + + /** + * Advance the iterator by one and return the next range. + * + * If the iterator is out of items, `done` will be true + */ + CodePointRangeIteratorResult next(); + inline const capi::CodePointRangeIterator* AsFFI() const { return this->inner.get(); } + inline capi::CodePointRangeIterator* AsFFIMut() { return this->inner.get(); } + inline CodePointRangeIterator(capi::CodePointRangeIterator* i) : inner(i) {} + CodePointRangeIterator() = default; + CodePointRangeIterator(CodePointRangeIterator&&) noexcept = default; + CodePointRangeIterator& operator=(CodePointRangeIterator&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "CodePointRangeIteratorResult.hpp" + +inline CodePointRangeIteratorResult CodePointRangeIterator::next() { + capi::CodePointRangeIteratorResult diplomat_raw_struct_out_value = capi::CodePointRangeIterator_next(this->inner.get()); + return CodePointRangeIteratorResult{ .start = std::move(diplomat_raw_struct_out_value.start), .end = std::move(diplomat_raw_struct_out_value.end), .done = std::move(diplomat_raw_struct_out_value.done) }; +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/CodePointRangeIteratorResult.h b/third_party/rust/icu_capi/cpp/include/CodePointRangeIteratorResult.h new file mode 100644 index 000000000000..846873be11f3 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/CodePointRangeIteratorResult.h @@ -0,0 +1,32 @@ +#ifndef CodePointRangeIteratorResult_H +#define CodePointRangeIteratorResult_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct CodePointRangeIteratorResult { + uint32_t start; + uint32_t end; + bool done; +} CodePointRangeIteratorResult; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void CodePointRangeIteratorResult_destroy(CodePointRangeIteratorResult* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/CodePointRangeIteratorResult.hpp b/third_party/rust/icu_capi/cpp/include/CodePointRangeIteratorResult.hpp new file mode 100644 index 000000000000..086ddfce0802 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/CodePointRangeIteratorResult.hpp @@ -0,0 +1,33 @@ +#ifndef CodePointRangeIteratorResult_HPP +#define CodePointRangeIteratorResult_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "CodePointRangeIteratorResult.h" + + + +/** + * Result of a single iteration of [`CodePointRangeIterator`]. + * Logically can be considered to be an `Option>`, + * + * `start` and `end` represent an inclusive range of code points [start, end], + * and `done` will be true if the iterator has already finished. The last contentful + * iteration will NOT produce a range done=true, in other words `start` and `end` are useful + * values if and only if `done=false`. + */ +struct CodePointRangeIteratorResult { + public: + uint32_t start; + uint32_t end; + bool done; +}; + + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XAnyCalendarKind.h b/third_party/rust/icu_capi/cpp/include/ICU4XAnyCalendarKind.h new file mode 100644 index 000000000000..035ec9ef17ba --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XAnyCalendarKind.h @@ -0,0 +1,46 @@ +#ifndef ICU4XAnyCalendarKind_H +#define ICU4XAnyCalendarKind_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XAnyCalendarKind { + ICU4XAnyCalendarKind_Iso = 0, + ICU4XAnyCalendarKind_Gregorian = 1, + ICU4XAnyCalendarKind_Buddhist = 2, + ICU4XAnyCalendarKind_Japanese = 3, + ICU4XAnyCalendarKind_JapaneseExtended = 4, + ICU4XAnyCalendarKind_Ethiopian = 5, + ICU4XAnyCalendarKind_EthiopianAmeteAlem = 6, + ICU4XAnyCalendarKind_Indian = 7, + ICU4XAnyCalendarKind_Coptic = 8, +} ICU4XAnyCalendarKind; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XLocale.h" +#include "diplomat_result_ICU4XAnyCalendarKind_void.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_ICU4XAnyCalendarKind_void ICU4XAnyCalendarKind_get_for_locale(const ICU4XLocale* locale); + +diplomat_result_ICU4XAnyCalendarKind_void ICU4XAnyCalendarKind_get_for_bcp47(const char* s_data, size_t s_len); + +diplomat_result_void_ICU4XError ICU4XAnyCalendarKind_bcp47(ICU4XAnyCalendarKind self, DiplomatWriteable* write); +void ICU4XAnyCalendarKind_destroy(ICU4XAnyCalendarKind* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XAnyCalendarKind.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XAnyCalendarKind.hpp new file mode 100644 index 000000000000..8fc9fa8a9230 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XAnyCalendarKind.hpp @@ -0,0 +1,72 @@ +#ifndef ICU4XAnyCalendarKind_HPP +#define ICU4XAnyCalendarKind_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XAnyCalendarKind.h" + + + +/** + * The various calendar types currently supported by [`ICU4XCalendar`] + * + * See the [Rust documentation for `AnyCalendarKind`](https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendarKind.html) for more information. + */ +enum struct ICU4XAnyCalendarKind { + + /** + * The kind of an Iso calendar + */ + Iso = 0, + + /** + * The kind of a Gregorian calendar + */ + Gregorian = 1, + + /** + * The kind of a Buddhist calendar + */ + Buddhist = 2, + + /** + * The kind of a Japanese calendar with modern eras + */ + Japanese = 3, + + /** + * The kind of a Japanese calendar with modern and historic eras + */ + JapaneseExtended = 4, + + /** + * The kind of an Ethiopian calendar, with Amete Mihret era + */ + Ethiopian = 5, + + /** + * The kind of an Ethiopian calendar, with Amete Alem era + */ + EthiopianAmeteAlem = 6, + + /** + * The kind of a Indian calendar + */ + Indian = 7, + + /** + * The kind of a Coptic calendar + */ + Coptic = 8, +}; +class ICU4XLocale; +#include "ICU4XError.hpp" + +#include "ICU4XLocale.hpp" +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XBidi.h b/third_party/rust/icu_capi/cpp/include/ICU4XBidi.h new file mode 100644 index 000000000000..1ed7cfc8c245 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XBidi.h @@ -0,0 +1,45 @@ +#ifndef ICU4XBidi_H +#define ICU4XBidi_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XBidi ICU4XBidi; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XBidi_ICU4XError.h" +#include "ICU4XBidiInfo.h" +#include "ICU4XReorderedIndexMap.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XBidi_ICU4XError ICU4XBidi_create(const ICU4XDataProvider* provider); + +ICU4XBidiInfo* ICU4XBidi_for_text(const ICU4XBidi* self, const char* text_data, size_t text_len, uint8_t default_level); + +ICU4XReorderedIndexMap* ICU4XBidi_reorder_visual(const ICU4XBidi* self, const uint8_t* levels_data, size_t levels_len); + +bool ICU4XBidi_level_is_rtl(uint8_t level); + +bool ICU4XBidi_level_is_ltr(uint8_t level); + +uint8_t ICU4XBidi_level_rtl(); + +uint8_t ICU4XBidi_level_ltr(); +void ICU4XBidi_destroy(ICU4XBidi* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XBidi.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XBidi.hpp new file mode 100644 index 000000000000..d3fa1827d01d --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XBidi.hpp @@ -0,0 +1,142 @@ +#ifndef ICU4XBidi_HPP +#define ICU4XBidi_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XBidi.h" + +class ICU4XDataProvider; +class ICU4XBidi; +#include "ICU4XError.hpp" +class ICU4XBidiInfo; +class ICU4XReorderedIndexMap; + +/** + * A destruction policy for using ICU4XBidi with std::unique_ptr. + */ +struct ICU4XBidiDeleter { + void operator()(capi::ICU4XBidi* l) const noexcept { + capi::ICU4XBidi_destroy(l); + } +}; + +/** + * 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. + */ +class ICU4XBidi { + public: + + /** + * Creates a new [`ICU4XBidi`] from locale data. + * + * See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/properties/bidi/struct.BidiClassAdapter.html#method.new) for more information. + */ + static diplomat::result create(const ICU4XDataProvider& provider); + + /** + * Use the data loaded in this object to process a string and calculate bidi information + * + * Takes in a Level for the default level, if it is an invalid value it will default to LTR + * + * See the [Rust documentation for `new_with_data_source`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.BidiInfo.html#method.new_with_data_source) for more information. + * + * Lifetimes: `text` must live at least as long as the output. + */ + ICU4XBidiInfo for_text(const std::string_view text, uint8_t default_level) const; + + /** + * Utility function for producing reorderings given a list of levels + * + * Produces a map saying which visual index maps to which source index. + * + * The levels array must not have values greater than 126 (this is the + * Bidi maximum explicit depth plus one). + * Failure to follow this invariant may lead to incorrect results, + * but is still safe. + * + * See the [Rust documentation for `reorder_visual`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.BidiInfo.html#method.reorder_visual) for more information. + */ + ICU4XReorderedIndexMap reorder_visual(const diplomat::span levels) const; + + /** + * Check if a Level returned by level_at is an RTL level. + * + * Invalid levels (numbers greater than 125) will be assumed LTR + * + * See the [Rust documentation for `is_rtl`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Level.html#method.is_rtl) for more information. + */ + static bool level_is_rtl(uint8_t level); + + /** + * Check if a Level returned by level_at is an LTR level. + * + * Invalid levels (numbers greater than 125) will be assumed LTR + * + * See the [Rust documentation for `is_ltr`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Level.html#method.is_ltr) for more information. + */ + static bool level_is_ltr(uint8_t level); + + /** + * Get a basic RTL Level value + * + * See the [Rust documentation for `rtl`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Level.html#method.rtl) for more information. + */ + static uint8_t level_rtl(); + + /** + * Get a simple LTR Level value + * + * See the [Rust documentation for `ltr`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Level.html#method.ltr) for more information. + */ + static uint8_t level_ltr(); + inline const capi::ICU4XBidi* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XBidi* AsFFIMut() { return this->inner.get(); } + inline ICU4XBidi(capi::ICU4XBidi* i) : inner(i) {} + ICU4XBidi() = default; + ICU4XBidi(ICU4XBidi&&) noexcept = default; + ICU4XBidi& operator=(ICU4XBidi&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XBidiInfo.hpp" +#include "ICU4XReorderedIndexMap.hpp" + +inline diplomat::result ICU4XBidi::create(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XBidi_create(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XBidi(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XBidiInfo ICU4XBidi::for_text(const std::string_view text, uint8_t default_level) const { + return ICU4XBidiInfo(capi::ICU4XBidi_for_text(this->inner.get(), text.data(), text.size(), default_level)); +} +inline ICU4XReorderedIndexMap ICU4XBidi::reorder_visual(const diplomat::span levels) const { + return ICU4XReorderedIndexMap(capi::ICU4XBidi_reorder_visual(this->inner.get(), levels.data(), levels.size())); +} +inline bool ICU4XBidi::level_is_rtl(uint8_t level) { + return capi::ICU4XBidi_level_is_rtl(level); +} +inline bool ICU4XBidi::level_is_ltr(uint8_t level) { + return capi::ICU4XBidi_level_is_ltr(level); +} +inline uint8_t ICU4XBidi::level_rtl() { + return capi::ICU4XBidi_level_rtl(); +} +inline uint8_t ICU4XBidi::level_ltr() { + return capi::ICU4XBidi_level_ltr(); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XBidiDirection.h b/third_party/rust/icu_capi/cpp/include/ICU4XBidiDirection.h new file mode 100644 index 000000000000..33de81d6e9da --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XBidiDirection.h @@ -0,0 +1,32 @@ +#ifndef ICU4XBidiDirection_H +#define ICU4XBidiDirection_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XBidiDirection { + ICU4XBidiDirection_Ltr = 0, + ICU4XBidiDirection_Rtl = 1, + ICU4XBidiDirection_Mixed = 2, +} ICU4XBidiDirection; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XBidiDirection_destroy(ICU4XBidiDirection* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XBidiDirection.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XBidiDirection.hpp new file mode 100644 index 000000000000..ad21e51910ea --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XBidiDirection.hpp @@ -0,0 +1,21 @@ +#ifndef ICU4XBidiDirection_HPP +#define ICU4XBidiDirection_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XBidiDirection.h" + + +enum struct ICU4XBidiDirection { + Ltr = 0, + Rtl = 1, + Mixed = 2, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XBidiInfo.h b/third_party/rust/icu_capi/cpp/include/ICU4XBidiInfo.h new file mode 100644 index 000000000000..02e8c21659a6 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XBidiInfo.h @@ -0,0 +1,36 @@ +#ifndef ICU4XBidiInfo_H +#define ICU4XBidiInfo_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XBidiInfo ICU4XBidiInfo; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XBidiParagraph.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +size_t ICU4XBidiInfo_paragraph_count(const ICU4XBidiInfo* self); + +ICU4XBidiParagraph* ICU4XBidiInfo_paragraph_at(const ICU4XBidiInfo* self, size_t n); + +size_t ICU4XBidiInfo_size(const ICU4XBidiInfo* self); + +uint8_t ICU4XBidiInfo_level_at(const ICU4XBidiInfo* self, size_t pos); +void ICU4XBidiInfo_destroy(ICU4XBidiInfo* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XBidiInfo.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XBidiInfo.hpp new file mode 100644 index 000000000000..11cf6162d2f7 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XBidiInfo.hpp @@ -0,0 +1,89 @@ +#ifndef ICU4XBidiInfo_HPP +#define ICU4XBidiInfo_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XBidiInfo.h" + +class ICU4XBidiParagraph; + +/** + * A destruction policy for using ICU4XBidiInfo with std::unique_ptr. + */ +struct ICU4XBidiInfoDeleter { + void operator()(capi::ICU4XBidiInfo* l) const noexcept { + capi::ICU4XBidiInfo_destroy(l); + } +}; + +/** + * An object containing bidi information for a given string, produced by `for_text()` on `ICU4XBidi` + * + * See the [Rust documentation for `BidiInfo`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.BidiInfo.html) for more information. + */ +class ICU4XBidiInfo { + public: + + /** + * The number of paragraphs contained here + */ + size_t paragraph_count() const; + + /** + * Get the nth paragraph, returning None if out of bounds + * + * Lifetimes: `this` must live at least as long as the output. + */ + std::optional paragraph_at(size_t n) const; + + /** + * The number of bytes in this full text + */ + size_t size() const; + + /** + * Get the BIDI level at a particular byte index in the full text. + * This integer is conceptually a `unicode_bidi::Level`, + * and can be further inspected using the static methods on ICU4XBidi. + * + * Returns 0 (equivalent to `Level::ltr()`) on error + */ + uint8_t level_at(size_t pos) const; + inline const capi::ICU4XBidiInfo* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XBidiInfo* AsFFIMut() { return this->inner.get(); } + inline ICU4XBidiInfo(capi::ICU4XBidiInfo* i) : inner(i) {} + ICU4XBidiInfo() = default; + ICU4XBidiInfo(ICU4XBidiInfo&&) noexcept = default; + ICU4XBidiInfo& operator=(ICU4XBidiInfo&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XBidiParagraph.hpp" + +inline size_t ICU4XBidiInfo::paragraph_count() const { + return capi::ICU4XBidiInfo_paragraph_count(this->inner.get()); +} +inline std::optional ICU4XBidiInfo::paragraph_at(size_t n) const { + auto diplomat_optional_raw_out_value = capi::ICU4XBidiInfo_paragraph_at(this->inner.get(), n); + std::optional diplomat_optional_out_value; + if (diplomat_optional_raw_out_value != nullptr) { + diplomat_optional_out_value = ICU4XBidiParagraph(diplomat_optional_raw_out_value); + } else { + diplomat_optional_out_value = std::nullopt; + } + return diplomat_optional_out_value; +} +inline size_t ICU4XBidiInfo::size() const { + return capi::ICU4XBidiInfo_size(this->inner.get()); +} +inline uint8_t ICU4XBidiInfo::level_at(size_t pos) const { + return capi::ICU4XBidiInfo_level_at(this->inner.get(), pos); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XBidiParagraph.h b/third_party/rust/icu_capi/cpp/include/ICU4XBidiParagraph.h new file mode 100644 index 000000000000..269f940cc7d7 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XBidiParagraph.h @@ -0,0 +1,43 @@ +#ifndef ICU4XBidiParagraph_H +#define ICU4XBidiParagraph_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XBidiParagraph ICU4XBidiParagraph; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_void_ICU4XError.h" +#include "ICU4XBidiDirection.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_void_ICU4XError ICU4XBidiParagraph_set_paragraph_in_text(ICU4XBidiParagraph* self, size_t n); + +ICU4XBidiDirection ICU4XBidiParagraph_direction(const ICU4XBidiParagraph* self); + +size_t ICU4XBidiParagraph_size(const ICU4XBidiParagraph* self); + +size_t ICU4XBidiParagraph_range_start(const ICU4XBidiParagraph* self); + +size_t ICU4XBidiParagraph_range_end(const ICU4XBidiParagraph* self); + +diplomat_result_void_ICU4XError ICU4XBidiParagraph_reorder_line(const ICU4XBidiParagraph* self, size_t range_start, size_t range_end, DiplomatWriteable* out); + +uint8_t ICU4XBidiParagraph_level_at(const ICU4XBidiParagraph* self, size_t pos); +void ICU4XBidiParagraph_destroy(ICU4XBidiParagraph* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XBidiParagraph.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XBidiParagraph.hpp new file mode 100644 index 000000000000..a7c9ad5d4ef3 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XBidiParagraph.hpp @@ -0,0 +1,150 @@ +#ifndef ICU4XBidiParagraph_HPP +#define ICU4XBidiParagraph_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XBidiParagraph.h" + +#include "ICU4XError.hpp" +#include "ICU4XBidiDirection.hpp" + +/** + * A destruction policy for using ICU4XBidiParagraph with std::unique_ptr. + */ +struct ICU4XBidiParagraphDeleter { + void operator()(capi::ICU4XBidiParagraph* l) const noexcept { + capi::ICU4XBidiParagraph_destroy(l); + } +}; + +/** + * Bidi information for a single processed paragraph + */ +class ICU4XBidiParagraph { + public: + + /** + * Given a paragraph index `n` within the surrounding text, this sets this + * object to the paragraph at that index. Returns `ICU4XError::OutOfBoundsError` when out of bounds. + * + * This is equivalent to calling `paragraph_at()` on `ICU4XBidiInfo` but doesn't + * create a new object + */ + diplomat::result set_paragraph_in_text(size_t n); + + /** + * The primary direction of this paragraph + * + * See the [Rust documentation for `level_at`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Paragraph.html#method.level_at) for more information. + */ + ICU4XBidiDirection direction() const; + + /** + * The number of bytes in this paragraph + * + * See the [Rust documentation for `len`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.ParagraphInfo.html#method.len) for more information. + */ + size_t size() const; + + /** + * The start index of this paragraph within the source text + */ + size_t range_start() const; + + /** + * The end index of this paragraph within the source text + */ + size_t range_end() const; + + /** + * Reorder a line based on display order. The ranges are specified relative to the source text and must be contained + * within this paragraph's range. + * + * See the [Rust documentation for `level_at`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Paragraph.html#method.level_at) for more information. + */ + template diplomat::result reorder_line_to_writeable(size_t range_start, size_t range_end, W& out) const; + + /** + * Reorder a line based on display order. The ranges are specified relative to the source text and must be contained + * within this paragraph's range. + * + * See the [Rust documentation for `level_at`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Paragraph.html#method.level_at) for more information. + */ + diplomat::result reorder_line(size_t range_start, size_t range_end) const; + + /** + * Get the BIDI level at a particular byte index in this paragraph. + * This integer is conceptually a `unicode_bidi::Level`, + * and can be further inspected using the static methods on ICU4XBidi. + * + * Returns 0 (equivalent to `Level::ltr()`) on error + * + * See the [Rust documentation for `level_at`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Paragraph.html#method.level_at) for more information. + */ + uint8_t level_at(size_t pos) const; + inline const capi::ICU4XBidiParagraph* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XBidiParagraph* AsFFIMut() { return this->inner.get(); } + inline ICU4XBidiParagraph(capi::ICU4XBidiParagraph* i) : inner(i) {} + ICU4XBidiParagraph() = default; + ICU4XBidiParagraph(ICU4XBidiParagraph&&) noexcept = default; + ICU4XBidiParagraph& operator=(ICU4XBidiParagraph&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline diplomat::result ICU4XBidiParagraph::set_paragraph_in_text(size_t n) { + auto diplomat_result_raw_out_value = capi::ICU4XBidiParagraph_set_paragraph_in_text(this->inner.get(), n); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XBidiDirection ICU4XBidiParagraph::direction() const { + return static_cast(capi::ICU4XBidiParagraph_direction(this->inner.get())); +} +inline size_t ICU4XBidiParagraph::size() const { + return capi::ICU4XBidiParagraph_size(this->inner.get()); +} +inline size_t ICU4XBidiParagraph::range_start() const { + return capi::ICU4XBidiParagraph_range_start(this->inner.get()); +} +inline size_t ICU4XBidiParagraph::range_end() const { + return capi::ICU4XBidiParagraph_range_end(this->inner.get()); +} +template inline diplomat::result ICU4XBidiParagraph::reorder_line_to_writeable(size_t range_start, size_t range_end, W& out) const { + capi::DiplomatWriteable out_writer = diplomat::WriteableTrait::Construct(out); + auto diplomat_result_raw_out_value = capi::ICU4XBidiParagraph_reorder_line(this->inner.get(), range_start, range_end, &out_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XBidiParagraph::reorder_line(size_t range_start, size_t range_end) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XBidiParagraph_reorder_line(this->inner.get(), range_start, range_end, &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +inline uint8_t ICU4XBidiParagraph::level_at(size_t pos) const { + return capi::ICU4XBidiParagraph_level_at(this->inner.get(), pos); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCalendar.h b/third_party/rust/icu_capi/cpp/include/ICU4XCalendar.h new file mode 100644 index 000000000000..9ea6484b5f89 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCalendar.h @@ -0,0 +1,37 @@ +#ifndef ICU4XCalendar_H +#define ICU4XCalendar_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCalendar ICU4XCalendar; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "diplomat_result_box_ICU4XCalendar_ICU4XError.h" +#include "ICU4XAnyCalendarKind.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XCalendar_ICU4XError ICU4XCalendar_create_for_locale(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +diplomat_result_box_ICU4XCalendar_ICU4XError ICU4XCalendar_create_for_kind(const ICU4XDataProvider* provider, ICU4XAnyCalendarKind kind); + +ICU4XAnyCalendarKind ICU4XCalendar_kind(const ICU4XCalendar* self); +void ICU4XCalendar_destroy(ICU4XCalendar* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCalendar.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XCalendar.hpp new file mode 100644 index 000000000000..5748eae9b875 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCalendar.hpp @@ -0,0 +1,93 @@ +#ifndef ICU4XCalendar_HPP +#define ICU4XCalendar_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XCalendar.h" + +class ICU4XDataProvider; +class ICU4XLocale; +class ICU4XCalendar; +#include "ICU4XError.hpp" +#include "ICU4XAnyCalendarKind.hpp" + +/** + * A destruction policy for using ICU4XCalendar with std::unique_ptr. + */ +struct ICU4XCalendarDeleter { + void operator()(capi::ICU4XCalendar* l) const noexcept { + capi::ICU4XCalendar_destroy(l); + } +}; + +/** + * + * + * See the [Rust documentation for `AnyCalendar`](https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendar.html) for more information. + */ +class ICU4XCalendar { + public: + + /** + * Creates a new [`ICU4XCalendar`] from the specified date and time. + * + * See the [Rust documentation for `try_new_for_locale_unstable`](https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendar.html#method.try_new_for_locale_unstable) for more information. + */ + static diplomat::result create_for_locale(const ICU4XDataProvider& provider, const ICU4XLocale& locale); + + /** + * Creates a new [`ICU4XCalendar`] from the specified date and time. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendar.html#method.try_new_unstable) for more information. + */ + static diplomat::result create_for_kind(const ICU4XDataProvider& provider, ICU4XAnyCalendarKind kind); + + /** + * 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. + */ + ICU4XAnyCalendarKind kind() const; + inline const capi::ICU4XCalendar* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XCalendar* AsFFIMut() { return this->inner.get(); } + inline ICU4XCalendar(capi::ICU4XCalendar* i) : inner(i) {} + ICU4XCalendar() = default; + ICU4XCalendar(ICU4XCalendar&&) noexcept = default; + ICU4XCalendar& operator=(ICU4XCalendar&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" + +inline diplomat::result ICU4XCalendar::create_for_locale(const ICU4XDataProvider& provider, const ICU4XLocale& locale) { + auto diplomat_result_raw_out_value = capi::ICU4XCalendar_create_for_locale(provider.AsFFI(), locale.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCalendar(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCalendar::create_for_kind(const ICU4XDataProvider& provider, ICU4XAnyCalendarKind kind) { + auto diplomat_result_raw_out_value = capi::ICU4XCalendar_create_for_kind(provider.AsFFI(), static_cast(kind)); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCalendar(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XAnyCalendarKind ICU4XCalendar::kind() const { + return static_cast(capi::ICU4XCalendar_kind(this->inner.get())); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCanonicalCombiningClassMap.h b/third_party/rust/icu_capi/cpp/include/ICU4XCanonicalCombiningClassMap.h new file mode 100644 index 000000000000..f0fc447ba0d4 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCanonicalCombiningClassMap.h @@ -0,0 +1,35 @@ +#ifndef ICU4XCanonicalCombiningClassMap_H +#define ICU4XCanonicalCombiningClassMap_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCanonicalCombiningClassMap ICU4XCanonicalCombiningClassMap; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError ICU4XCanonicalCombiningClassMap_create(const ICU4XDataProvider* provider); + +uint8_t ICU4XCanonicalCombiningClassMap_get(const ICU4XCanonicalCombiningClassMap* self, char32_t ch); + +uint8_t ICU4XCanonicalCombiningClassMap_get32(const ICU4XCanonicalCombiningClassMap* self, uint32_t ch); +void ICU4XCanonicalCombiningClassMap_destroy(ICU4XCanonicalCombiningClassMap* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCanonicalCombiningClassMap.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XCanonicalCombiningClassMap.hpp new file mode 100644 index 000000000000..f2d092b9db5d --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCanonicalCombiningClassMap.hpp @@ -0,0 +1,87 @@ +#ifndef ICU4XCanonicalCombiningClassMap_HPP +#define ICU4XCanonicalCombiningClassMap_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XCanonicalCombiningClassMap.h" + +class ICU4XDataProvider; +class ICU4XCanonicalCombiningClassMap; +#include "ICU4XError.hpp" + +/** + * A destruction policy for using ICU4XCanonicalCombiningClassMap with std::unique_ptr. + */ +struct ICU4XCanonicalCombiningClassMapDeleter { + void operator()(capi::ICU4XCanonicalCombiningClassMap* l) const noexcept { + capi::ICU4XCanonicalCombiningClassMap_destroy(l); + } +}; + +/** + * 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. + */ +class ICU4XCanonicalCombiningClassMap { + public: + + /** + * Construct a new ICU4XCanonicalCombiningClassMap instance for NFC + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalCombiningClassMap.html#method.try_new_unstable) for more information. + */ + static diplomat::result create(const ICU4XDataProvider& provider); + + /** + * + * + * 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) + */ + uint8_t get(char32_t ch) const; + + /** + * + * + * See the [Rust documentation for `get32`](https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalCombiningClassMap.html#method.get32) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/properties/properties/struct.CanonicalCombiningClass.html) + */ + uint8_t get32(uint32_t ch) const; + inline const capi::ICU4XCanonicalCombiningClassMap* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XCanonicalCombiningClassMap* AsFFIMut() { return this->inner.get(); } + inline ICU4XCanonicalCombiningClassMap(capi::ICU4XCanonicalCombiningClassMap* i) : inner(i) {} + ICU4XCanonicalCombiningClassMap() = default; + ICU4XCanonicalCombiningClassMap(ICU4XCanonicalCombiningClassMap&&) noexcept = default; + ICU4XCanonicalCombiningClassMap& operator=(ICU4XCanonicalCombiningClassMap&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" + +inline diplomat::result ICU4XCanonicalCombiningClassMap::create(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCanonicalCombiningClassMap_create(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCanonicalCombiningClassMap(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline uint8_t ICU4XCanonicalCombiningClassMap::get(char32_t ch) const { + return capi::ICU4XCanonicalCombiningClassMap_get(this->inner.get(), ch); +} +inline uint8_t ICU4XCanonicalCombiningClassMap::get32(uint32_t ch) const { + return capi::ICU4XCanonicalCombiningClassMap_get32(this->inner.get(), ch); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCanonicalComposition.h b/third_party/rust/icu_capi/cpp/include/ICU4XCanonicalComposition.h new file mode 100644 index 000000000000..e9ae621739fb --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCanonicalComposition.h @@ -0,0 +1,33 @@ +#ifndef ICU4XCanonicalComposition_H +#define ICU4XCanonicalComposition_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCanonicalComposition ICU4XCanonicalComposition; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XCanonicalComposition_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XCanonicalComposition_ICU4XError ICU4XCanonicalComposition_create(const ICU4XDataProvider* provider); + +char32_t ICU4XCanonicalComposition_compose(const ICU4XCanonicalComposition* self, char32_t starter, char32_t second); +void ICU4XCanonicalComposition_destroy(ICU4XCanonicalComposition* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCanonicalComposition.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XCanonicalComposition.hpp new file mode 100644 index 000000000000..19f128bc5fe5 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCanonicalComposition.hpp @@ -0,0 +1,76 @@ +#ifndef ICU4XCanonicalComposition_HPP +#define ICU4XCanonicalComposition_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XCanonicalComposition.h" + +class ICU4XDataProvider; +class ICU4XCanonicalComposition; +#include "ICU4XError.hpp" + +/** + * A destruction policy for using ICU4XCanonicalComposition with std::unique_ptr. + */ +struct ICU4XCanonicalCompositionDeleter { + void operator()(capi::ICU4XCanonicalComposition* l) const noexcept { + capi::ICU4XCanonicalComposition_destroy(l); + } +}; + +/** + * The raw canonical composition operation. + * + * Callers should generally use ICU4XComposingNormalizer unless they specifically need raw composition operations + * + * See the [Rust documentation for `CanonicalComposition`](https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalComposition.html) for more information. + */ +class ICU4XCanonicalComposition { + public: + + /** + * Construct a new ICU4XCanonicalComposition instance for NFC + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalComposition.html#method.try_new_unstable) for more information. + */ + static diplomat::result create(const ICU4XDataProvider& provider); + + /** + * Performs canonical composition (including Hangul) on a pair of characters + * or returns NUL if these characters don’t compose. Composition exclusions are taken into account. + * + * See the [Rust documentation for `compose`](https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalComposition.html#method.compose) for more information. + */ + char32_t compose(char32_t starter, char32_t second) const; + inline const capi::ICU4XCanonicalComposition* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XCanonicalComposition* AsFFIMut() { return this->inner.get(); } + inline ICU4XCanonicalComposition(capi::ICU4XCanonicalComposition* i) : inner(i) {} + ICU4XCanonicalComposition() = default; + ICU4XCanonicalComposition(ICU4XCanonicalComposition&&) noexcept = default; + ICU4XCanonicalComposition& operator=(ICU4XCanonicalComposition&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" + +inline diplomat::result ICU4XCanonicalComposition::create(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCanonicalComposition_create(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCanonicalComposition(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline char32_t ICU4XCanonicalComposition::compose(char32_t starter, char32_t second) const { + return capi::ICU4XCanonicalComposition_compose(this->inner.get(), starter, second); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCanonicalDecomposition.h b/third_party/rust/icu_capi/cpp/include/ICU4XCanonicalDecomposition.h new file mode 100644 index 000000000000..d18d108b905e --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCanonicalDecomposition.h @@ -0,0 +1,34 @@ +#ifndef ICU4XCanonicalDecomposition_H +#define ICU4XCanonicalDecomposition_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCanonicalDecomposition ICU4XCanonicalDecomposition; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError.h" +#include "ICU4XDecomposed.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError ICU4XCanonicalDecomposition_create(const ICU4XDataProvider* provider); + +ICU4XDecomposed ICU4XCanonicalDecomposition_decompose(const ICU4XCanonicalDecomposition* self, char32_t c); +void ICU4XCanonicalDecomposition_destroy(ICU4XCanonicalDecomposition* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCanonicalDecomposition.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XCanonicalDecomposition.hpp new file mode 100644 index 000000000000..ebc5b89a3bc9 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCanonicalDecomposition.hpp @@ -0,0 +1,78 @@ +#ifndef ICU4XCanonicalDecomposition_HPP +#define ICU4XCanonicalDecomposition_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XCanonicalDecomposition.h" + +class ICU4XDataProvider; +class ICU4XCanonicalDecomposition; +#include "ICU4XError.hpp" +struct ICU4XDecomposed; + +/** + * A destruction policy for using ICU4XCanonicalDecomposition with std::unique_ptr. + */ +struct ICU4XCanonicalDecompositionDeleter { + void operator()(capi::ICU4XCanonicalDecomposition* l) const noexcept { + capi::ICU4XCanonicalDecomposition_destroy(l); + } +}; + +/** + * The raw (non-recursive) canonical decomposition operation. + * + * Callers should generally use ICU4XDecomposingNormalizer unless they specifically need raw composition operations + * + * See the [Rust documentation for `CanonicalDecomposition`](https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalDecomposition.html) for more information. + */ +class ICU4XCanonicalDecomposition { + public: + + /** + * Construct a new ICU4XCanonicalDecomposition instance for NFC + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalDecomposition.html#method.try_new_unstable) for more information. + */ + static diplomat::result create(const ICU4XDataProvider& provider); + + /** + * 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. + */ + ICU4XDecomposed decompose(char32_t c) const; + inline const capi::ICU4XCanonicalDecomposition* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XCanonicalDecomposition* AsFFIMut() { return this->inner.get(); } + inline ICU4XCanonicalDecomposition(capi::ICU4XCanonicalDecomposition* i) : inner(i) {} + ICU4XCanonicalDecomposition() = default; + ICU4XCanonicalDecomposition(ICU4XCanonicalDecomposition&&) noexcept = default; + ICU4XCanonicalDecomposition& operator=(ICU4XCanonicalDecomposition&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XDecomposed.hpp" + +inline diplomat::result ICU4XCanonicalDecomposition::create(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCanonicalDecomposition_create(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCanonicalDecomposition(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XDecomposed ICU4XCanonicalDecomposition::decompose(char32_t c) const { + capi::ICU4XDecomposed diplomat_raw_struct_out_value = capi::ICU4XCanonicalDecomposition_decompose(this->inner.get(), c); + return ICU4XDecomposed{ .first = std::move(diplomat_raw_struct_out_value.first), .second = std::move(diplomat_raw_struct_out_value.second) }; +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCodePointMapData16.h b/third_party/rust/icu_capi/cpp/include/ICU4XCodePointMapData16.h new file mode 100644 index 000000000000..19effe2d921f --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCodePointMapData16.h @@ -0,0 +1,43 @@ +#ifndef ICU4XCodePointMapData16_H +#define ICU4XCodePointMapData16_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCodePointMapData16 ICU4XCodePointMapData16; +#ifdef __cplusplus +} // namespace capi +#endif +#include "CodePointRangeIterator.h" +#include "ICU4XCodePointSetData.h" +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XCodePointMapData16_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +uint16_t ICU4XCodePointMapData16_get(const ICU4XCodePointMapData16* self, char32_t cp); + +uint16_t ICU4XCodePointMapData16_get32(const ICU4XCodePointMapData16* self, uint32_t cp); + +CodePointRangeIterator* ICU4XCodePointMapData16_iter_ranges_for_value(const ICU4XCodePointMapData16* self, uint16_t value); + +CodePointRangeIterator* ICU4XCodePointMapData16_iter_ranges_for_value_complemented(const ICU4XCodePointMapData16* self, uint16_t value); + +ICU4XCodePointSetData* ICU4XCodePointMapData16_get_set_for_value(const ICU4XCodePointMapData16* self, uint16_t value); + +diplomat_result_box_ICU4XCodePointMapData16_ICU4XError ICU4XCodePointMapData16_load_script(const ICU4XDataProvider* provider); +void ICU4XCodePointMapData16_destroy(ICU4XCodePointMapData16* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCodePointMapData16.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XCodePointMapData16.hpp new file mode 100644 index 000000000000..b2ef8318aaca --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCodePointMapData16.hpp @@ -0,0 +1,125 @@ +#ifndef ICU4XCodePointMapData16_HPP +#define ICU4XCodePointMapData16_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XCodePointMapData16.h" + +class CodePointRangeIterator; +class ICU4XCodePointSetData; +class ICU4XDataProvider; +class ICU4XCodePointMapData16; +#include "ICU4XError.hpp" + +/** + * A destruction policy for using ICU4XCodePointMapData16 with std::unique_ptr. + */ +struct ICU4XCodePointMapData16Deleter { + void operator()(capi::ICU4XCodePointMapData16* l) const noexcept { + capi::ICU4XCodePointMapData16_destroy(l); + } +}; + +/** + * An ICU4X Unicode Map Property object, capable of querying whether a code point (key) to obtain the Unicode property value, for a specific Unicode property. + * + * For properties whose values fit into 16 bits. + * + * See the [Rust documentation for `properties`](https://docs.rs/icu/latest/icu/properties/index.html) for more information. + * + * See the [Rust documentation for `CodePointMapData`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapData.html) for more information. + * + * See the [Rust documentation for `CodePointMapDataBorrowed`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html) for more information. + */ +class ICU4XCodePointMapData16 { + public: + + /** + * Gets the value for a code point. + * + * See the [Rust documentation for `get`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.get) for more information. + */ + uint16_t get(char32_t cp) const; + + /** + * Gets the value for a code point (specified as a 32 bit integer, in UTF-32) + */ + uint16_t get32(uint32_t cp) const; + + /** + * Produces an iterator over ranges of code points that map to `value` + * + * See the [Rust documentation for `iter_ranges_for_value`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.iter_ranges_for_value) for more information. + * + * Lifetimes: `this` must live at least as long as the output. + */ + CodePointRangeIterator iter_ranges_for_value(uint16_t value) const; + + /** + * Produces an iterator over ranges of code points that do not map to `value` + * + * See the [Rust documentation for `iter_ranges_for_value_complemented`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.iter_ranges_for_value_complemented) for more information. + * + * Lifetimes: `this` must live at least as long as the output. + */ + CodePointRangeIterator iter_ranges_for_value_complemented(uint16_t value) const; + + /** + * Gets a [`ICU4XCodePointSetData`] 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. + */ + ICU4XCodePointSetData get_set_for_value(uint16_t value) const; + + /** + * + * + * See the [Rust documentation for `load_script`](https://docs.rs/icu/latest/icu/properties/maps/fn.load_script.html) for more information. + */ + static diplomat::result load_script(const ICU4XDataProvider& provider); + inline const capi::ICU4XCodePointMapData16* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XCodePointMapData16* AsFFIMut() { return this->inner.get(); } + inline ICU4XCodePointMapData16(capi::ICU4XCodePointMapData16* i) : inner(i) {} + ICU4XCodePointMapData16() = default; + ICU4XCodePointMapData16(ICU4XCodePointMapData16&&) noexcept = default; + ICU4XCodePointMapData16& operator=(ICU4XCodePointMapData16&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "CodePointRangeIterator.hpp" +#include "ICU4XCodePointSetData.hpp" +#include "ICU4XDataProvider.hpp" + +inline uint16_t ICU4XCodePointMapData16::get(char32_t cp) const { + return capi::ICU4XCodePointMapData16_get(this->inner.get(), cp); +} +inline uint16_t ICU4XCodePointMapData16::get32(uint32_t cp) const { + return capi::ICU4XCodePointMapData16_get32(this->inner.get(), cp); +} +inline CodePointRangeIterator ICU4XCodePointMapData16::iter_ranges_for_value(uint16_t value) const { + return CodePointRangeIterator(capi::ICU4XCodePointMapData16_iter_ranges_for_value(this->inner.get(), value)); +} +inline CodePointRangeIterator ICU4XCodePointMapData16::iter_ranges_for_value_complemented(uint16_t value) const { + return CodePointRangeIterator(capi::ICU4XCodePointMapData16_iter_ranges_for_value_complemented(this->inner.get(), value)); +} +inline ICU4XCodePointSetData ICU4XCodePointMapData16::get_set_for_value(uint16_t value) const { + return ICU4XCodePointSetData(capi::ICU4XCodePointMapData16_get_set_for_value(this->inner.get(), value)); +} +inline diplomat::result ICU4XCodePointMapData16::load_script(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData16_load_script(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointMapData16(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCodePointMapData8.h b/third_party/rust/icu_capi/cpp/include/ICU4XCodePointMapData8.h new file mode 100644 index 000000000000..69a6a46b900a --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCodePointMapData8.h @@ -0,0 +1,59 @@ +#ifndef ICU4XCodePointMapData8_H +#define ICU4XCodePointMapData8_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCodePointMapData8 ICU4XCodePointMapData8; +#ifdef __cplusplus +} // namespace capi +#endif +#include "CodePointRangeIterator.h" +#include "ICU4XCodePointSetData.h" +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XCodePointMapData8_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +uint8_t ICU4XCodePointMapData8_get(const ICU4XCodePointMapData8* self, char32_t cp); + +uint8_t ICU4XCodePointMapData8_get32(const ICU4XCodePointMapData8* self, uint32_t cp); + +uint32_t ICU4XCodePointMapData8_general_category_to_mask(uint8_t gc); + +CodePointRangeIterator* ICU4XCodePointMapData8_iter_ranges_for_value(const ICU4XCodePointMapData8* self, uint8_t value); + +CodePointRangeIterator* ICU4XCodePointMapData8_iter_ranges_for_value_complemented(const ICU4XCodePointMapData8* self, uint8_t value); + +CodePointRangeIterator* ICU4XCodePointMapData8_iter_ranges_for_mask(const ICU4XCodePointMapData8* self, uint32_t mask); + +ICU4XCodePointSetData* ICU4XCodePointMapData8_get_set_for_value(const ICU4XCodePointMapData8* self, uint8_t value); + +diplomat_result_box_ICU4XCodePointMapData8_ICU4XError ICU4XCodePointMapData8_load_general_category(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointMapData8_ICU4XError ICU4XCodePointMapData8_load_bidi_class(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointMapData8_ICU4XError ICU4XCodePointMapData8_load_east_asian_width(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointMapData8_ICU4XError ICU4XCodePointMapData8_load_line_break(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointMapData8_ICU4XError ICU4XCodePointMapData8_try_grapheme_cluster_break(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointMapData8_ICU4XError ICU4XCodePointMapData8_load_word_break(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointMapData8_ICU4XError ICU4XCodePointMapData8_load_sentence_break(const ICU4XDataProvider* provider); +void ICU4XCodePointMapData8_destroy(ICU4XCodePointMapData8* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCodePointMapData8.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XCodePointMapData8.hpp new file mode 100644 index 000000000000..b74ea2061b48 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCodePointMapData8.hpp @@ -0,0 +1,258 @@ +#ifndef ICU4XCodePointMapData8_HPP +#define ICU4XCodePointMapData8_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XCodePointMapData8.h" + +class CodePointRangeIterator; +class ICU4XCodePointSetData; +class ICU4XDataProvider; +class ICU4XCodePointMapData8; +#include "ICU4XError.hpp" + +/** + * A destruction policy for using ICU4XCodePointMapData8 with std::unique_ptr. + */ +struct ICU4XCodePointMapData8Deleter { + void operator()(capi::ICU4XCodePointMapData8* l) const noexcept { + capi::ICU4XCodePointMapData8_destroy(l); + } +}; + +/** + * An ICU4X Unicode Map Property object, capable of querying whether a code point (key) to obtain the Unicode property value, for a specific Unicode property. + * + * For properties whose values fit into 8 bits. + * + * See the [Rust documentation for `properties`](https://docs.rs/icu/latest/icu/properties/index.html) for more information. + * + * See the [Rust documentation for `CodePointMapData`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapData.html) for more information. + * + * See the [Rust documentation for `CodePointMapDataBorrowed`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html) for more information. + */ +class ICU4XCodePointMapData8 { + public: + + /** + * Gets the value for a code point. + * + * See the [Rust documentation for `get`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.get) for more information. + */ + uint8_t get(char32_t cp) const; + + /** + * Gets the value for a code point (specified as a 32 bit integer, in UTF-32) + */ + uint8_t get32(uint32_t cp) const; + + /** + * Converts a general category to its corresponding mask value + * + * Nonexistant general categories will map to the empty mask + * + * See the [Rust documentation for `GeneralCategoryGroup`](https://docs.rs/icu/latest/icu/properties/struct.GeneralCategoryGroup.html) for more information. + */ + static uint32_t general_category_to_mask(uint8_t gc); + + /** + * Produces an iterator over ranges of code points that map to `value` + * + * See the [Rust documentation for `iter_ranges_for_value`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.iter_ranges_for_value) for more information. + * + * Lifetimes: `this` must live at least as long as the output. + */ + CodePointRangeIterator iter_ranges_for_value(uint8_t value) const; + + /** + * Produces an iterator over ranges of code points that do not map to `value` + * + * See the [Rust documentation for `iter_ranges_for_value_complemented`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.iter_ranges_for_value_complemented) for more information. + * + * Lifetimes: `this` must live at least as long as the output. + */ + CodePointRangeIterator iter_ranges_for_value_complemented(uint8_t value) const; + + /** + * Given a mask value (the nth bit marks property value = n), produce an iterator over ranges of code points + * whose property values are contained in the mask. + * + * The main mask property supported is that for General_Category, which can be obtained via `general_category_to_mask()` or + * by using `ICU4XGeneralCategoryNameToMaskMapper` + * + * Should only be used on maps for properties with values less than 32 (like Generak_Category), + * other maps will have unpredictable results + * + * See the [Rust documentation for `iter_ranges_for_group`](https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.iter_ranges_for_group) for more information. + * + * Lifetimes: `this` must live at least as long as the output. + */ + CodePointRangeIterator iter_ranges_for_mask(uint32_t mask) const; + + /** + * Gets a [`ICU4XCodePointSetData`] 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. + */ + ICU4XCodePointSetData get_set_for_value(uint8_t value) const; + + /** + * + * + * See the [Rust documentation for `load_general_category`](https://docs.rs/icu/latest/icu/properties/maps/fn.load_general_category.html) for more information. + */ + static diplomat::result load_general_category(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_bidi_class`](https://docs.rs/icu/latest/icu/properties/maps/fn.load_bidi_class.html) for more information. + */ + static diplomat::result load_bidi_class(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_east_asian_width`](https://docs.rs/icu/latest/icu/properties/maps/fn.load_east_asian_width.html) for more information. + */ + static diplomat::result load_east_asian_width(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_line_break`](https://docs.rs/icu/latest/icu/properties/maps/fn.load_line_break.html) for more information. + */ + static diplomat::result load_line_break(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_grapheme_cluster_break`](https://docs.rs/icu/latest/icu/properties/maps/fn.load_grapheme_cluster_break.html) for more information. + */ + static diplomat::result try_grapheme_cluster_break(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_word_break`](https://docs.rs/icu/latest/icu/properties/maps/fn.load_word_break.html) for more information. + */ + static diplomat::result load_word_break(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_sentence_break`](https://docs.rs/icu/latest/icu/properties/maps/fn.load_sentence_break.html) for more information. + */ + static diplomat::result load_sentence_break(const ICU4XDataProvider& provider); + inline const capi::ICU4XCodePointMapData8* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XCodePointMapData8* AsFFIMut() { return this->inner.get(); } + inline ICU4XCodePointMapData8(capi::ICU4XCodePointMapData8* i) : inner(i) {} + ICU4XCodePointMapData8() = default; + ICU4XCodePointMapData8(ICU4XCodePointMapData8&&) noexcept = default; + ICU4XCodePointMapData8& operator=(ICU4XCodePointMapData8&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "CodePointRangeIterator.hpp" +#include "ICU4XCodePointSetData.hpp" +#include "ICU4XDataProvider.hpp" + +inline uint8_t ICU4XCodePointMapData8::get(char32_t cp) const { + return capi::ICU4XCodePointMapData8_get(this->inner.get(), cp); +} +inline uint8_t ICU4XCodePointMapData8::get32(uint32_t cp) const { + return capi::ICU4XCodePointMapData8_get32(this->inner.get(), cp); +} +inline uint32_t ICU4XCodePointMapData8::general_category_to_mask(uint8_t gc) { + return capi::ICU4XCodePointMapData8_general_category_to_mask(gc); +} +inline CodePointRangeIterator ICU4XCodePointMapData8::iter_ranges_for_value(uint8_t value) const { + return CodePointRangeIterator(capi::ICU4XCodePointMapData8_iter_ranges_for_value(this->inner.get(), value)); +} +inline CodePointRangeIterator ICU4XCodePointMapData8::iter_ranges_for_value_complemented(uint8_t value) const { + return CodePointRangeIterator(capi::ICU4XCodePointMapData8_iter_ranges_for_value_complemented(this->inner.get(), value)); +} +inline CodePointRangeIterator ICU4XCodePointMapData8::iter_ranges_for_mask(uint32_t mask) const { + return CodePointRangeIterator(capi::ICU4XCodePointMapData8_iter_ranges_for_mask(this->inner.get(), mask)); +} +inline ICU4XCodePointSetData ICU4XCodePointMapData8::get_set_for_value(uint8_t value) const { + return ICU4XCodePointSetData(capi::ICU4XCodePointMapData8_get_set_for_value(this->inner.get(), value)); +} +inline diplomat::result ICU4XCodePointMapData8::load_general_category(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData8_load_general_category(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointMapData8(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointMapData8::load_bidi_class(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData8_load_bidi_class(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointMapData8(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointMapData8::load_east_asian_width(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData8_load_east_asian_width(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointMapData8(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointMapData8::load_line_break(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData8_load_line_break(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointMapData8(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointMapData8::try_grapheme_cluster_break(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData8_try_grapheme_cluster_break(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointMapData8(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointMapData8::load_word_break(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData8_load_word_break(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointMapData8(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointMapData8::load_sentence_break(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointMapData8_load_sentence_break(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointMapData8(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCodePointSetData.h b/third_party/rust/icu_capi/cpp/include/ICU4XCodePointSetData.h new file mode 100644 index 000000000000..10356e90b7b5 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCodePointSetData.h @@ -0,0 +1,172 @@ +#ifndef ICU4XCodePointSetData_H +#define ICU4XCodePointSetData_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCodePointSetData ICU4XCodePointSetData; +#ifdef __cplusplus +} // namespace capi +#endif +#include "CodePointRangeIterator.h" +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XCodePointSetData_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +bool ICU4XCodePointSetData_contains(const ICU4XCodePointSetData* self, char32_t cp); + +bool ICU4XCodePointSetData_contains32(const ICU4XCodePointSetData* self, uint32_t cp); + +CodePointRangeIterator* ICU4XCodePointSetData_iter_ranges(const ICU4XCodePointSetData* self); + +CodePointRangeIterator* ICU4XCodePointSetData_iter_ranges_complemented(const ICU4XCodePointSetData* self); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_for_general_category_group(const ICU4XDataProvider* provider, uint32_t group); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_ascii_hex_digit(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_alnum(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_alphabetic(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_bidi_control(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_bidi_mirrored(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_blank(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_cased(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_case_ignorable(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_full_composition_exclusion(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_changes_when_casefolded(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_changes_when_casemapped(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_changes_when_nfkc_casefolded(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_changes_when_lowercased(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_changes_when_titlecased(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_changes_when_uppercased(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_dash(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_deprecated(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_default_ignorable_code_point(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_diacritic(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_emoji_modifier_base(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_emoji_component(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_emoji_modifier(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_emoji(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_emoji_presentation(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_extender(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_extended_pictographic(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_graph(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_grapheme_base(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_grapheme_extend(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_grapheme_link(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_hex_digit(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_hyphen(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_id_continue(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_ideographic(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_id_start(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_ids_binary_operator(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_ids_trinary_operator(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_join_control(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_logical_order_exception(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_lowercase(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_math(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_noncharacter_code_point(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_nfc_inert(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_nfd_inert(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_nfkc_inert(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_nfkd_inert(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_pattern_syntax(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_pattern_white_space(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_prepended_concatenation_mark(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_print(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_quotation_mark(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_radical(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_regional_indicator(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_soft_dotted(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_segment_starter(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_case_sensitive(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_sentence_terminal(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_terminal_punctuation(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_unified_ideograph(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_uppercase(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_variation_selector(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_white_space(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_xdigit(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_xid_continue(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_xid_start(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XCodePointSetData_ICU4XError ICU4XCodePointSetData_load_for_ecma262(const ICU4XDataProvider* provider, const char* property_name_data, size_t property_name_len); +void ICU4XCodePointSetData_destroy(ICU4XCodePointSetData* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCodePointSetData.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XCodePointSetData.hpp new file mode 100644 index 000000000000..d46d6bba10a6 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCodePointSetData.hpp @@ -0,0 +1,1239 @@ +#ifndef ICU4XCodePointSetData_HPP +#define ICU4XCodePointSetData_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XCodePointSetData.h" + +class CodePointRangeIterator; +class ICU4XDataProvider; +class ICU4XCodePointSetData; +#include "ICU4XError.hpp" + +/** + * A destruction policy for using ICU4XCodePointSetData with std::unique_ptr. + */ +struct ICU4XCodePointSetDataDeleter { + void operator()(capi::ICU4XCodePointSetData* l) const noexcept { + capi::ICU4XCodePointSetData_destroy(l); + } +}; + +/** + * An ICU4X Unicode Set Property object, capable of querying whether a code point is contained in a set based on a Unicode property. + * + * See the [Rust documentation for `properties`](https://docs.rs/icu/latest/icu/properties/index.html) for more information. + * + * See the [Rust documentation for `CodePointSetData`](https://docs.rs/icu/latest/icu/properties/sets/struct.CodePointSetData.html) for more information. + * + * See the [Rust documentation for `CodePointSetDataBorrowed`](https://docs.rs/icu/latest/icu/properties/sets/struct.CodePointSetDataBorrowed.html) for more information. + */ +class ICU4XCodePointSetData { + public: + + /** + * Checks whether the code point is in the set. + * + * See the [Rust documentation for `contains`](https://docs.rs/icu/latest/icu/properties/sets/struct.CodePointSetDataBorrowed.html#method.contains) for more information. + */ + bool contains(char32_t cp) const; + + /** + * Checks whether the code point (specified as a 32 bit integer, in UTF-32) is in the set. + */ + bool contains32(uint32_t cp) const; + + /** + * Produces an iterator over ranges of code points contained in this set + * + * See the [Rust documentation for `iter_ranges`](https://docs.rs/icu/latest/icu/properties/sets/struct.CodePointSetDataBorrowed.html#method.iter_ranges) for more information. + * + * Lifetimes: `this` must live at least as long as the output. + */ + CodePointRangeIterator iter_ranges() const; + + /** + * Produces an iterator over ranges of code points not contained in this set + * + * See the [Rust documentation for `iter_ranges_complemented`](https://docs.rs/icu/latest/icu/properties/sets/struct.CodePointSetDataBorrowed.html#method.iter_ranges_complemented) for more information. + * + * Lifetimes: `this` must live at least as long as the output. + */ + CodePointRangeIterator iter_ranges_complemented() const; + + /** + * which is a mask with the same format as the `U_GC_XX_MASK` mask in ICU4C + * + * See the [Rust documentation for `load_for_general_category_group`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_for_general_category_group.html) for more information. + */ + static diplomat::result load_for_general_category_group(const ICU4XDataProvider& provider, uint32_t group); + + /** + * + * + * See the [Rust documentation for `load_ascii_hex_digit`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_ascii_hex_digit.html) for more information. + */ + static diplomat::result load_ascii_hex_digit(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_alnum`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_alnum.html) for more information. + */ + static diplomat::result load_alnum(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_alphabetic`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_alphabetic.html) for more information. + */ + static diplomat::result load_alphabetic(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_bidi_control`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_bidi_control.html) for more information. + */ + static diplomat::result load_bidi_control(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_bidi_mirrored`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_bidi_mirrored.html) for more information. + */ + static diplomat::result load_bidi_mirrored(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_blank`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_blank.html) for more information. + */ + static diplomat::result load_blank(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_cased`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_cased.html) for more information. + */ + static diplomat::result load_cased(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_case_ignorable`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_case_ignorable.html) for more information. + */ + static diplomat::result load_case_ignorable(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_full_composition_exclusion`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_full_composition_exclusion.html) for more information. + */ + static diplomat::result load_full_composition_exclusion(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_changes_when_casefolded`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_changes_when_casefolded.html) for more information. + */ + static diplomat::result load_changes_when_casefolded(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_changes_when_casemapped`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_changes_when_casemapped.html) for more information. + */ + static diplomat::result load_changes_when_casemapped(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_changes_when_nfkc_casefolded`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_changes_when_nfkc_casefolded.html) for more information. + */ + static diplomat::result load_changes_when_nfkc_casefolded(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_changes_when_lowercased`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_changes_when_lowercased.html) for more information. + */ + static diplomat::result load_changes_when_lowercased(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_changes_when_titlecased`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_changes_when_titlecased.html) for more information. + */ + static diplomat::result load_changes_when_titlecased(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_changes_when_uppercased`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_changes_when_uppercased.html) for more information. + */ + static diplomat::result load_changes_when_uppercased(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_dash`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_dash.html) for more information. + */ + static diplomat::result load_dash(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_deprecated`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_deprecated.html) for more information. + */ + static diplomat::result load_deprecated(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_default_ignorable_code_point`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_default_ignorable_code_point.html) for more information. + */ + static diplomat::result load_default_ignorable_code_point(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_diacritic`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_diacritic.html) for more information. + */ + static diplomat::result load_diacritic(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_emoji_modifier_base`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_emoji_modifier_base.html) for more information. + */ + static diplomat::result load_emoji_modifier_base(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_emoji_component`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_emoji_component.html) for more information. + */ + static diplomat::result load_emoji_component(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_emoji_modifier`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_emoji_modifier.html) for more information. + */ + static diplomat::result load_emoji_modifier(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_emoji`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_emoji.html) for more information. + */ + static diplomat::result load_emoji(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_emoji_presentation`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_emoji_presentation.html) for more information. + */ + static diplomat::result load_emoji_presentation(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_extender`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_extender.html) for more information. + */ + static diplomat::result load_extender(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_extended_pictographic`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_extended_pictographic.html) for more information. + */ + static diplomat::result load_extended_pictographic(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_graph`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_graph.html) for more information. + */ + static diplomat::result load_graph(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_grapheme_base`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_grapheme_base.html) for more information. + */ + static diplomat::result load_grapheme_base(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_grapheme_extend`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_grapheme_extend.html) for more information. + */ + static diplomat::result load_grapheme_extend(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_grapheme_link`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_grapheme_link.html) for more information. + */ + static diplomat::result load_grapheme_link(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_hex_digit`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_hex_digit.html) for more information. + */ + static diplomat::result load_hex_digit(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_hyphen`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_hyphen.html) for more information. + */ + static diplomat::result load_hyphen(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_id_continue`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_id_continue.html) for more information. + */ + static diplomat::result load_id_continue(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_ideographic`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_ideographic.html) for more information. + */ + static diplomat::result load_ideographic(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_id_start`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_id_start.html) for more information. + */ + static diplomat::result load_id_start(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_ids_binary_operator`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_ids_binary_operator.html) for more information. + */ + static diplomat::result load_ids_binary_operator(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_ids_trinary_operator`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_ids_trinary_operator.html) for more information. + */ + static diplomat::result load_ids_trinary_operator(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_join_control`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_join_control.html) for more information. + */ + static diplomat::result load_join_control(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_logical_order_exception`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_logical_order_exception.html) for more information. + */ + static diplomat::result load_logical_order_exception(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_lowercase`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_lowercase.html) for more information. + */ + static diplomat::result load_lowercase(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_math`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_math.html) for more information. + */ + static diplomat::result load_math(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_noncharacter_code_point`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_noncharacter_code_point.html) for more information. + */ + static diplomat::result load_noncharacter_code_point(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_nfc_inert`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_nfc_inert.html) for more information. + */ + static diplomat::result load_nfc_inert(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_nfd_inert`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_nfd_inert.html) for more information. + */ + static diplomat::result load_nfd_inert(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_nfkc_inert`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_nfkc_inert.html) for more information. + */ + static diplomat::result load_nfkc_inert(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_nfkd_inert`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_nfkd_inert.html) for more information. + */ + static diplomat::result load_nfkd_inert(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_pattern_syntax`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_pattern_syntax.html) for more information. + */ + static diplomat::result load_pattern_syntax(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_pattern_white_space`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_pattern_white_space.html) for more information. + */ + static diplomat::result load_pattern_white_space(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_prepended_concatenation_mark`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_prepended_concatenation_mark.html) for more information. + */ + static diplomat::result load_prepended_concatenation_mark(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_print`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_print.html) for more information. + */ + static diplomat::result load_print(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_quotation_mark`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_quotation_mark.html) for more information. + */ + static diplomat::result load_quotation_mark(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_radical`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_radical.html) for more information. + */ + static diplomat::result load_radical(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_regional_indicator`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_regional_indicator.html) for more information. + */ + static diplomat::result load_regional_indicator(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_soft_dotted`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_soft_dotted.html) for more information. + */ + static diplomat::result load_soft_dotted(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_segment_starter`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_segment_starter.html) for more information. + */ + static diplomat::result load_segment_starter(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_case_sensitive`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_case_sensitive.html) for more information. + */ + static diplomat::result load_case_sensitive(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_sentence_terminal`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_sentence_terminal.html) for more information. + */ + static diplomat::result load_sentence_terminal(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_terminal_punctuation`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_terminal_punctuation.html) for more information. + */ + static diplomat::result load_terminal_punctuation(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_unified_ideograph`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_unified_ideograph.html) for more information. + */ + static diplomat::result load_unified_ideograph(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_uppercase`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_uppercase.html) for more information. + */ + static diplomat::result load_uppercase(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_variation_selector`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_variation_selector.html) for more information. + */ + static diplomat::result load_variation_selector(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_white_space`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_white_space.html) for more information. + */ + static diplomat::result load_white_space(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_xdigit`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_xdigit.html) for more information. + */ + static diplomat::result load_xdigit(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_xid_continue`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_xid_continue.html) for more information. + */ + static diplomat::result load_xid_continue(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_xid_start`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_xid_start.html) for more information. + */ + static diplomat::result load_xid_start(const ICU4XDataProvider& provider); + + /** + * Loads data for a property specified as a string as long as it is one of the + * [ECMA-262 binary properties][ecma] (not including Any, ASCII, and Assigned pseudoproperties). + * + * Returns `ICU4XError::PropertyUnexpectedPropertyNameError` in case the string does not + * match any property in the list + * + * [ecma]: https://tc39.es/ecma262/#table-binary-unicode-properties + * + * See the [Rust documentation for `load_for_ecma262_unstable`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_for_ecma262_unstable.html) for more information. + */ + static diplomat::result load_for_ecma262(const ICU4XDataProvider& provider, const std::string_view property_name); + inline const capi::ICU4XCodePointSetData* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XCodePointSetData* AsFFIMut() { return this->inner.get(); } + inline ICU4XCodePointSetData(capi::ICU4XCodePointSetData* i) : inner(i) {} + ICU4XCodePointSetData() = default; + ICU4XCodePointSetData(ICU4XCodePointSetData&&) noexcept = default; + ICU4XCodePointSetData& operator=(ICU4XCodePointSetData&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "CodePointRangeIterator.hpp" +#include "ICU4XDataProvider.hpp" + +inline bool ICU4XCodePointSetData::contains(char32_t cp) const { + return capi::ICU4XCodePointSetData_contains(this->inner.get(), cp); +} +inline bool ICU4XCodePointSetData::contains32(uint32_t cp) const { + return capi::ICU4XCodePointSetData_contains32(this->inner.get(), cp); +} +inline CodePointRangeIterator ICU4XCodePointSetData::iter_ranges() const { + return CodePointRangeIterator(capi::ICU4XCodePointSetData_iter_ranges(this->inner.get())); +} +inline CodePointRangeIterator ICU4XCodePointSetData::iter_ranges_complemented() const { + return CodePointRangeIterator(capi::ICU4XCodePointSetData_iter_ranges_complemented(this->inner.get())); +} +inline diplomat::result ICU4XCodePointSetData::load_for_general_category_group(const ICU4XDataProvider& provider, uint32_t group) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_for_general_category_group(provider.AsFFI(), group); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_ascii_hex_digit(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_ascii_hex_digit(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_alnum(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_alnum(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_alphabetic(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_alphabetic(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_bidi_control(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_bidi_control(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_bidi_mirrored(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_bidi_mirrored(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_blank(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_blank(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_cased(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_cased(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_case_ignorable(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_case_ignorable(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_full_composition_exclusion(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_full_composition_exclusion(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_changes_when_casefolded(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_changes_when_casefolded(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_changes_when_casemapped(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_changes_when_casemapped(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_changes_when_nfkc_casefolded(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_changes_when_nfkc_casefolded(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_changes_when_lowercased(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_changes_when_lowercased(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_changes_when_titlecased(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_changes_when_titlecased(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_changes_when_uppercased(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_changes_when_uppercased(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_dash(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_dash(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_deprecated(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_deprecated(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_default_ignorable_code_point(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_default_ignorable_code_point(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_diacritic(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_diacritic(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_emoji_modifier_base(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_emoji_modifier_base(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_emoji_component(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_emoji_component(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_emoji_modifier(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_emoji_modifier(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_emoji(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_emoji(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_emoji_presentation(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_emoji_presentation(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_extender(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_extender(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_extended_pictographic(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_extended_pictographic(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_graph(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_graph(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_grapheme_base(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_grapheme_base(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_grapheme_extend(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_grapheme_extend(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_grapheme_link(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_grapheme_link(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_hex_digit(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_hex_digit(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_hyphen(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_hyphen(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_id_continue(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_id_continue(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_ideographic(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_ideographic(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_id_start(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_id_start(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_ids_binary_operator(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_ids_binary_operator(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_ids_trinary_operator(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_ids_trinary_operator(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_join_control(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_join_control(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_logical_order_exception(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_logical_order_exception(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_lowercase(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_lowercase(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_math(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_math(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_noncharacter_code_point(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_noncharacter_code_point(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_nfc_inert(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_nfc_inert(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_nfd_inert(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_nfd_inert(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_nfkc_inert(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_nfkc_inert(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_nfkd_inert(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_nfkd_inert(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_pattern_syntax(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_pattern_syntax(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_pattern_white_space(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_pattern_white_space(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_prepended_concatenation_mark(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_prepended_concatenation_mark(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_print(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_print(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_quotation_mark(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_quotation_mark(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_radical(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_radical(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_regional_indicator(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_regional_indicator(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_soft_dotted(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_soft_dotted(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_segment_starter(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_segment_starter(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_case_sensitive(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_case_sensitive(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_sentence_terminal(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_sentence_terminal(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_terminal_punctuation(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_terminal_punctuation(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_unified_ideograph(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_unified_ideograph(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_uppercase(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_uppercase(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_variation_selector(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_variation_selector(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_white_space(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_white_space(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_xdigit(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_xdigit(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_xid_continue(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_xid_continue(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_xid_start(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_xid_start(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCodePointSetData::load_for_ecma262(const ICU4XDataProvider& provider, const std::string_view property_name) { + auto diplomat_result_raw_out_value = capi::ICU4XCodePointSetData_load_for_ecma262(provider.AsFFI(), property_name.data(), property_name.size()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCodePointSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCollator.h b/third_party/rust/icu_capi/cpp/include/ICU4XCollator.h new file mode 100644 index 000000000000..973c2cedd96a --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCollator.h @@ -0,0 +1,40 @@ +#ifndef ICU4XCollator_H +#define ICU4XCollator_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCollator ICU4XCollator; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XCollatorOptionsV1.h" +#include "diplomat_result_box_ICU4XCollator_ICU4XError.h" +#include "ICU4XOrdering.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XCollator_ICU4XError ICU4XCollator_create_v1(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XCollatorOptionsV1 options); + +ICU4XOrdering ICU4XCollator_compare(const ICU4XCollator* self, const char* left_data, size_t left_len, const char* right_data, size_t right_len); + +ICU4XOrdering ICU4XCollator_compare_valid_utf8(const ICU4XCollator* self, const char* left_data, size_t left_len, const char* right_data, size_t right_len); + +ICU4XOrdering ICU4XCollator_compare_utf16(const ICU4XCollator* self, const uint16_t* left_data, size_t left_len, const uint16_t* right_data, size_t right_len); +void ICU4XCollator_destroy(ICU4XCollator* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCollator.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XCollator.hpp new file mode 100644 index 000000000000..daba03c9f124 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCollator.hpp @@ -0,0 +1,107 @@ +#ifndef ICU4XCollator_HPP +#define ICU4XCollator_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XCollator.h" + +class ICU4XDataProvider; +class ICU4XLocale; +struct ICU4XCollatorOptionsV1; +class ICU4XCollator; +#include "ICU4XError.hpp" +#include "ICU4XOrdering.hpp" + +/** + * A destruction policy for using ICU4XCollator with std::unique_ptr. + */ +struct ICU4XCollatorDeleter { + void operator()(capi::ICU4XCollator* l) const noexcept { + capi::ICU4XCollator_destroy(l); + } +}; + +/** + * + * + * See the [Rust documentation for `Collator`](https://docs.rs/icu/latest/icu/collator/struct.Collator.html) for more information. + */ +class ICU4XCollator { + public: + + /** + * Construct a new Collator instance. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/collator/struct.Collator.html#method.try_new_unstable) for more information. + */ + static diplomat::result create_v1(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XCollatorOptionsV1 options); + + /** + * Compare potentially ill-formed UTF-8 strings. + * + * Ill-formed input is compared + * as if errors had been replaced with REPLACEMENT CHARACTERs according + * to the WHATWG Encoding Standard. + * + * See the [Rust documentation for `compare_utf8`](https://docs.rs/icu/latest/icu/collator/struct.Collator.html#method.compare_utf8) for more information. + */ + ICU4XOrdering compare(const std::string_view left, const std::string_view right) const; + + /** + * Compare guaranteed well-formed UTF-8 strings. + * + * Note: In C++, passing ill-formed UTF-8 strings is undefined behavior + * (and may be memory-unsafe to do so, too). + * + * See the [Rust documentation for `compare`](https://docs.rs/icu/latest/icu/collator/struct.Collator.html#method.compare) for more information. + */ + ICU4XOrdering compare_valid_utf8(const std::string_view left, const std::string_view right) const; + + /** + * Compare potentially ill-formed UTF-16 strings, with unpaired surrogates + * compared as REPLACEMENT CHARACTER. + * + * See the [Rust documentation for `compare_utf16`](https://docs.rs/icu/latest/icu/collator/struct.Collator.html#method.compare_utf16) for more information. + */ + ICU4XOrdering compare_utf16(const diplomat::span left, const diplomat::span right) const; + inline const capi::ICU4XCollator* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XCollator* AsFFIMut() { return this->inner.get(); } + inline ICU4XCollator(capi::ICU4XCollator* i) : inner(i) {} + ICU4XCollator() = default; + ICU4XCollator(ICU4XCollator&&) noexcept = default; + ICU4XCollator& operator=(ICU4XCollator&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" +#include "ICU4XCollatorOptionsV1.hpp" + +inline diplomat::result ICU4XCollator::create_v1(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XCollatorOptionsV1 options) { + ICU4XCollatorOptionsV1 diplomat_wrapped_struct_options = options; + auto diplomat_result_raw_out_value = capi::ICU4XCollator_create_v1(provider.AsFFI(), locale.AsFFI(), capi::ICU4XCollatorOptionsV1{ .strength = static_cast(diplomat_wrapped_struct_options.strength), .alternate_handling = static_cast(diplomat_wrapped_struct_options.alternate_handling), .case_first = static_cast(diplomat_wrapped_struct_options.case_first), .max_variable = static_cast(diplomat_wrapped_struct_options.max_variable), .case_level = static_cast(diplomat_wrapped_struct_options.case_level), .numeric = static_cast(diplomat_wrapped_struct_options.numeric), .backward_second_level = static_cast(diplomat_wrapped_struct_options.backward_second_level) }); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCollator(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XOrdering ICU4XCollator::compare(const std::string_view left, const std::string_view right) const { + return static_cast(capi::ICU4XCollator_compare(this->inner.get(), left.data(), left.size(), right.data(), right.size())); +} +inline ICU4XOrdering ICU4XCollator::compare_valid_utf8(const std::string_view left, const std::string_view right) const { + return static_cast(capi::ICU4XCollator_compare_valid_utf8(this->inner.get(), left.data(), left.size(), right.data(), right.size())); +} +inline ICU4XOrdering ICU4XCollator::compare_utf16(const diplomat::span left, const diplomat::span right) const { + return static_cast(capi::ICU4XCollator_compare_utf16(this->inner.get(), left.data(), left.size(), right.data(), right.size())); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCollatorAlternateHandling.h b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorAlternateHandling.h new file mode 100644 index 000000000000..dfc3d595eb2a --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorAlternateHandling.h @@ -0,0 +1,32 @@ +#ifndef ICU4XCollatorAlternateHandling_H +#define ICU4XCollatorAlternateHandling_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XCollatorAlternateHandling { + ICU4XCollatorAlternateHandling_Auto = 0, + ICU4XCollatorAlternateHandling_NonIgnorable = 1, + ICU4XCollatorAlternateHandling_Shifted = 2, +} ICU4XCollatorAlternateHandling; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XCollatorAlternateHandling_destroy(ICU4XCollatorAlternateHandling* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCollatorAlternateHandling.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorAlternateHandling.hpp new file mode 100644 index 000000000000..f48e89367a2b --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorAlternateHandling.hpp @@ -0,0 +1,27 @@ +#ifndef ICU4XCollatorAlternateHandling_HPP +#define ICU4XCollatorAlternateHandling_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XCollatorAlternateHandling.h" + + + +/** + * + * + * See the [Rust documentation for `AlternateHandling`](https://docs.rs/icu/latest/icu/collator/enum.AlternateHandling.html) for more information. + */ +enum struct ICU4XCollatorAlternateHandling { + Auto = 0, + NonIgnorable = 1, + Shifted = 2, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCollatorBackwardSecondLevel.h b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorBackwardSecondLevel.h new file mode 100644 index 000000000000..659f9b2f1093 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorBackwardSecondLevel.h @@ -0,0 +1,32 @@ +#ifndef ICU4XCollatorBackwardSecondLevel_H +#define ICU4XCollatorBackwardSecondLevel_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XCollatorBackwardSecondLevel { + ICU4XCollatorBackwardSecondLevel_Auto = 0, + ICU4XCollatorBackwardSecondLevel_Off = 1, + ICU4XCollatorBackwardSecondLevel_On = 2, +} ICU4XCollatorBackwardSecondLevel; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XCollatorBackwardSecondLevel_destroy(ICU4XCollatorBackwardSecondLevel* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCollatorBackwardSecondLevel.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorBackwardSecondLevel.hpp new file mode 100644 index 000000000000..ecab822487cc --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorBackwardSecondLevel.hpp @@ -0,0 +1,27 @@ +#ifndef ICU4XCollatorBackwardSecondLevel_HPP +#define ICU4XCollatorBackwardSecondLevel_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XCollatorBackwardSecondLevel.h" + + + +/** + * + * + * See the [Rust documentation for `BackwardSecondLevel`](https://docs.rs/icu/latest/icu/collator/enum.BackwardSecondLevel.html) for more information. + */ +enum struct ICU4XCollatorBackwardSecondLevel { + Auto = 0, + Off = 1, + On = 2, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCollatorCaseFirst.h b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorCaseFirst.h new file mode 100644 index 000000000000..c01eb216d09d --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorCaseFirst.h @@ -0,0 +1,33 @@ +#ifndef ICU4XCollatorCaseFirst_H +#define ICU4XCollatorCaseFirst_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XCollatorCaseFirst { + ICU4XCollatorCaseFirst_Auto = 0, + ICU4XCollatorCaseFirst_Off = 1, + ICU4XCollatorCaseFirst_LowerFirst = 2, + ICU4XCollatorCaseFirst_UpperFirst = 3, +} ICU4XCollatorCaseFirst; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XCollatorCaseFirst_destroy(ICU4XCollatorCaseFirst* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCollatorCaseFirst.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorCaseFirst.hpp new file mode 100644 index 000000000000..d93c67b4e907 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorCaseFirst.hpp @@ -0,0 +1,28 @@ +#ifndef ICU4XCollatorCaseFirst_HPP +#define ICU4XCollatorCaseFirst_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XCollatorCaseFirst.h" + + + +/** + * + * + * See the [Rust documentation for `CaseFirst`](https://docs.rs/icu/latest/icu/collator/enum.CaseFirst.html) for more information. + */ +enum struct ICU4XCollatorCaseFirst { + Auto = 0, + Off = 1, + LowerFirst = 2, + UpperFirst = 3, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCollatorCaseLevel.h b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorCaseLevel.h new file mode 100644 index 000000000000..cbf686596775 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorCaseLevel.h @@ -0,0 +1,32 @@ +#ifndef ICU4XCollatorCaseLevel_H +#define ICU4XCollatorCaseLevel_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XCollatorCaseLevel { + ICU4XCollatorCaseLevel_Auto = 0, + ICU4XCollatorCaseLevel_Off = 1, + ICU4XCollatorCaseLevel_On = 2, +} ICU4XCollatorCaseLevel; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XCollatorCaseLevel_destroy(ICU4XCollatorCaseLevel* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCollatorCaseLevel.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorCaseLevel.hpp new file mode 100644 index 000000000000..30670910c817 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorCaseLevel.hpp @@ -0,0 +1,27 @@ +#ifndef ICU4XCollatorCaseLevel_HPP +#define ICU4XCollatorCaseLevel_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XCollatorCaseLevel.h" + + + +/** + * + * + * See the [Rust documentation for `CaseLevel`](https://docs.rs/icu/latest/icu/collator/enum.CaseLevel.html) for more information. + */ +enum struct ICU4XCollatorCaseLevel { + Auto = 0, + Off = 1, + On = 2, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCollatorMaxVariable.h b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorMaxVariable.h new file mode 100644 index 000000000000..0e5a3a516fec --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorMaxVariable.h @@ -0,0 +1,34 @@ +#ifndef ICU4XCollatorMaxVariable_H +#define ICU4XCollatorMaxVariable_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XCollatorMaxVariable { + ICU4XCollatorMaxVariable_Auto = 0, + ICU4XCollatorMaxVariable_Space = 1, + ICU4XCollatorMaxVariable_Punctuation = 2, + ICU4XCollatorMaxVariable_Symbol = 3, + ICU4XCollatorMaxVariable_Currency = 4, +} ICU4XCollatorMaxVariable; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XCollatorMaxVariable_destroy(ICU4XCollatorMaxVariable* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCollatorMaxVariable.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorMaxVariable.hpp new file mode 100644 index 000000000000..60ce7e267e7d --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorMaxVariable.hpp @@ -0,0 +1,29 @@ +#ifndef ICU4XCollatorMaxVariable_HPP +#define ICU4XCollatorMaxVariable_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XCollatorMaxVariable.h" + + + +/** + * + * + * See the [Rust documentation for `MaxVariable`](https://docs.rs/icu/latest/icu/collator/enum.MaxVariable.html) for more information. + */ +enum struct ICU4XCollatorMaxVariable { + Auto = 0, + Space = 1, + Punctuation = 2, + Symbol = 3, + Currency = 4, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCollatorNumeric.h b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorNumeric.h new file mode 100644 index 000000000000..4dd2ec0408f2 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorNumeric.h @@ -0,0 +1,32 @@ +#ifndef ICU4XCollatorNumeric_H +#define ICU4XCollatorNumeric_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XCollatorNumeric { + ICU4XCollatorNumeric_Auto = 0, + ICU4XCollatorNumeric_Off = 1, + ICU4XCollatorNumeric_On = 2, +} ICU4XCollatorNumeric; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XCollatorNumeric_destroy(ICU4XCollatorNumeric* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCollatorNumeric.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorNumeric.hpp new file mode 100644 index 000000000000..c7def97bb3bc --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorNumeric.hpp @@ -0,0 +1,27 @@ +#ifndef ICU4XCollatorNumeric_HPP +#define ICU4XCollatorNumeric_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XCollatorNumeric.h" + + + +/** + * + * + * See the [Rust documentation for `Numeric`](https://docs.rs/icu/latest/icu/collator/enum.Numeric.html) for more information. + */ +enum struct ICU4XCollatorNumeric { + Auto = 0, + Off = 1, + On = 2, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCollatorOptionsV1.h b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorOptionsV1.h new file mode 100644 index 000000000000..dc73557efe67 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorOptionsV1.h @@ -0,0 +1,50 @@ +#ifndef ICU4XCollatorOptionsV1_H +#define ICU4XCollatorOptionsV1_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XCollatorStrength.h" +#include "ICU4XCollatorAlternateHandling.h" +#include "ICU4XCollatorCaseFirst.h" +#include "ICU4XCollatorMaxVariable.h" +#include "ICU4XCollatorCaseLevel.h" +#include "ICU4XCollatorNumeric.h" +#include "ICU4XCollatorBackwardSecondLevel.h" +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCollatorOptionsV1 { + ICU4XCollatorStrength strength; + ICU4XCollatorAlternateHandling alternate_handling; + ICU4XCollatorCaseFirst case_first; + ICU4XCollatorMaxVariable max_variable; + ICU4XCollatorCaseLevel case_level; + ICU4XCollatorNumeric numeric; + ICU4XCollatorBackwardSecondLevel backward_second_level; +} ICU4XCollatorOptionsV1; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XCollatorStrength.h" +#include "ICU4XCollatorAlternateHandling.h" +#include "ICU4XCollatorCaseFirst.h" +#include "ICU4XCollatorMaxVariable.h" +#include "ICU4XCollatorCaseLevel.h" +#include "ICU4XCollatorNumeric.h" +#include "ICU4XCollatorBackwardSecondLevel.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XCollatorOptionsV1_destroy(ICU4XCollatorOptionsV1* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCollatorOptionsV1.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorOptionsV1.hpp new file mode 100644 index 000000000000..fdffa2c9c1a8 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorOptionsV1.hpp @@ -0,0 +1,40 @@ +#ifndef ICU4XCollatorOptionsV1_HPP +#define ICU4XCollatorOptionsV1_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XCollatorOptionsV1.h" + +#include "ICU4XCollatorStrength.hpp" +#include "ICU4XCollatorAlternateHandling.hpp" +#include "ICU4XCollatorCaseFirst.hpp" +#include "ICU4XCollatorMaxVariable.hpp" +#include "ICU4XCollatorCaseLevel.hpp" +#include "ICU4XCollatorNumeric.hpp" +#include "ICU4XCollatorBackwardSecondLevel.hpp" + + +/** + * + * + * See the [Rust documentation for `CollatorOptions`](https://docs.rs/icu/latest/icu/collator/struct.CollatorOptions.html) for more information. + */ +struct ICU4XCollatorOptionsV1 { + public: + ICU4XCollatorStrength strength; + ICU4XCollatorAlternateHandling alternate_handling; + ICU4XCollatorCaseFirst case_first; + ICU4XCollatorMaxVariable max_variable; + ICU4XCollatorCaseLevel case_level; + ICU4XCollatorNumeric numeric; + ICU4XCollatorBackwardSecondLevel backward_second_level; +}; + + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCollatorStrength.h b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorStrength.h new file mode 100644 index 000000000000..f230214febad --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorStrength.h @@ -0,0 +1,35 @@ +#ifndef ICU4XCollatorStrength_H +#define ICU4XCollatorStrength_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XCollatorStrength { + ICU4XCollatorStrength_Auto = 0, + ICU4XCollatorStrength_Primary = 1, + ICU4XCollatorStrength_Secondary = 2, + ICU4XCollatorStrength_Tertiary = 3, + ICU4XCollatorStrength_Quaternary = 4, + ICU4XCollatorStrength_Identical = 5, +} ICU4XCollatorStrength; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XCollatorStrength_destroy(ICU4XCollatorStrength* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCollatorStrength.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorStrength.hpp new file mode 100644 index 000000000000..dd9ace1ae8a8 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCollatorStrength.hpp @@ -0,0 +1,30 @@ +#ifndef ICU4XCollatorStrength_HPP +#define ICU4XCollatorStrength_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XCollatorStrength.h" + + + +/** + * + * + * See the [Rust documentation for `Strength`](https://docs.rs/icu/latest/icu/collator/enum.Strength.html) for more information. + */ +enum struct ICU4XCollatorStrength { + Auto = 0, + Primary = 1, + Secondary = 2, + Tertiary = 3, + Quaternary = 4, + Identical = 5, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XComposingNormalizer.h b/third_party/rust/icu_capi/cpp/include/ICU4XComposingNormalizer.h new file mode 100644 index 000000000000..1798af0d8e3e --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XComposingNormalizer.h @@ -0,0 +1,38 @@ +#ifndef ICU4XComposingNormalizer_H +#define ICU4XComposingNormalizer_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XComposingNormalizer ICU4XComposingNormalizer; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XComposingNormalizer_ICU4XError.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XComposingNormalizer_ICU4XError ICU4XComposingNormalizer_create_nfc(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XComposingNormalizer_ICU4XError ICU4XComposingNormalizer_create_nfkc(const ICU4XDataProvider* provider); + +diplomat_result_void_ICU4XError ICU4XComposingNormalizer_normalize(const ICU4XComposingNormalizer* self, const char* s_data, size_t s_len, DiplomatWriteable* write); + +bool ICU4XComposingNormalizer_is_normalized(const ICU4XComposingNormalizer* self, const char* s_data, size_t s_len); +void ICU4XComposingNormalizer_destroy(ICU4XComposingNormalizer* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XComposingNormalizer.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XComposingNormalizer.hpp new file mode 100644 index 000000000000..7089a7d1f317 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XComposingNormalizer.hpp @@ -0,0 +1,133 @@ +#ifndef ICU4XComposingNormalizer_HPP +#define ICU4XComposingNormalizer_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XComposingNormalizer.h" + +class ICU4XDataProvider; +class ICU4XComposingNormalizer; +#include "ICU4XError.hpp" + +/** + * A destruction policy for using ICU4XComposingNormalizer with std::unique_ptr. + */ +struct ICU4XComposingNormalizerDeleter { + void operator()(capi::ICU4XComposingNormalizer* l) const noexcept { + capi::ICU4XComposingNormalizer_destroy(l); + } +}; + +/** + * + * + * See the [Rust documentation for `ComposingNormalizer`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html) for more information. + */ +class ICU4XComposingNormalizer { + public: + + /** + * Construct a new ICU4XComposingNormalizer instance for NFC + * + * See the [Rust documentation for `try_new_nfc_unstable`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html#method.try_new_nfc_unstable) for more information. + */ + static diplomat::result create_nfc(const ICU4XDataProvider& provider); + + /** + * Construct a new ICU4XComposingNormalizer instance for NFKC + * + * See the [Rust documentation for `try_new_nfkc_unstable`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html#method.try_new_nfkc_unstable) for more information. + */ + static diplomat::result create_nfkc(const ICU4XDataProvider& provider); + + /** + * Normalize a (potentially ill-formed) UTF8 string + * + * Errors are mapped to REPLACEMENT CHARACTER + * + * See the [Rust documentation for `normalize_utf8`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html#method.normalize_utf8) for more information. + */ + template diplomat::result normalize_to_writeable(const std::string_view s, W& write) const; + + /** + * Normalize a (potentially ill-formed) UTF8 string + * + * Errors are mapped to REPLACEMENT CHARACTER + * + * See the [Rust documentation for `normalize_utf8`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html#method.normalize_utf8) for more information. + */ + diplomat::result normalize(const std::string_view s) const; + + /** + * Check if a (potentially ill-formed) UTF8 string is normalized + * + * Errors are mapped to REPLACEMENT CHARACTER + * + * See the [Rust documentation for `is_normalized_utf8`](https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html#method.is_normalized_utf8) for more information. + */ + bool is_normalized(const std::string_view s) const; + inline const capi::ICU4XComposingNormalizer* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XComposingNormalizer* AsFFIMut() { return this->inner.get(); } + inline ICU4XComposingNormalizer(capi::ICU4XComposingNormalizer* i) : inner(i) {} + ICU4XComposingNormalizer() = default; + ICU4XComposingNormalizer(ICU4XComposingNormalizer&&) noexcept = default; + ICU4XComposingNormalizer& operator=(ICU4XComposingNormalizer&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" + +inline diplomat::result ICU4XComposingNormalizer::create_nfc(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XComposingNormalizer_create_nfc(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XComposingNormalizer(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XComposingNormalizer::create_nfkc(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XComposingNormalizer_create_nfkc(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XComposingNormalizer(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +template inline diplomat::result ICU4XComposingNormalizer::normalize_to_writeable(const std::string_view s, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XComposingNormalizer_normalize(this->inner.get(), s.data(), s.size(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XComposingNormalizer::normalize(const std::string_view s) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XComposingNormalizer_normalize(this->inner.get(), s.data(), s.size(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +inline bool ICU4XComposingNormalizer::is_normalized(const std::string_view s) const { + return capi::ICU4XComposingNormalizer_is_normalized(this->inner.get(), s.data(), s.size()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCustomTimeZone.h b/third_party/rust/icu_capi/cpp/include/ICU4XCustomTimeZone.h new file mode 100644 index 000000000000..fe6181a1049b --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCustomTimeZone.h @@ -0,0 +1,81 @@ +#ifndef ICU4XCustomTimeZone_H +#define ICU4XCustomTimeZone_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XCustomTimeZone ICU4XCustomTimeZone; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_box_ICU4XCustomTimeZone_ICU4XError.h" +#include "diplomat_result_void_ICU4XError.h" +#include "diplomat_result_int32_t_ICU4XError.h" +#include "diplomat_result_bool_ICU4XError.h" +#include "ICU4XMetazoneCalculator.h" +#include "ICU4XIsoDateTime.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XCustomTimeZone_ICU4XError ICU4XCustomTimeZone_create_from_string(const char* s_data, size_t s_len); + +ICU4XCustomTimeZone* ICU4XCustomTimeZone_create_empty(); + +ICU4XCustomTimeZone* ICU4XCustomTimeZone_create_utc(); + +diplomat_result_void_ICU4XError ICU4XCustomTimeZone_try_set_gmt_offset_seconds(ICU4XCustomTimeZone* self, int32_t offset_seconds); + +void ICU4XCustomTimeZone_clear_gmt_offset(ICU4XCustomTimeZone* self); + +diplomat_result_int32_t_ICU4XError ICU4XCustomTimeZone_gmt_offset_seconds(const ICU4XCustomTimeZone* self); + +diplomat_result_bool_ICU4XError ICU4XCustomTimeZone_is_gmt_offset_positive(const ICU4XCustomTimeZone* self); + +diplomat_result_bool_ICU4XError ICU4XCustomTimeZone_is_gmt_offset_zero(const ICU4XCustomTimeZone* self); + +diplomat_result_bool_ICU4XError ICU4XCustomTimeZone_gmt_offset_has_minutes(const ICU4XCustomTimeZone* self); + +diplomat_result_bool_ICU4XError ICU4XCustomTimeZone_gmt_offset_has_seconds(const ICU4XCustomTimeZone* self); + +diplomat_result_void_ICU4XError ICU4XCustomTimeZone_try_set_time_zone_id(ICU4XCustomTimeZone* self, const char* id_data, size_t id_len); + +void ICU4XCustomTimeZone_clear_time_zone_id(ICU4XCustomTimeZone* self); + +diplomat_result_void_ICU4XError ICU4XCustomTimeZone_time_zone_id(const ICU4XCustomTimeZone* self, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XCustomTimeZone_try_set_metazone_id(ICU4XCustomTimeZone* self, const char* id_data, size_t id_len); + +void ICU4XCustomTimeZone_clear_metazone_id(ICU4XCustomTimeZone* self); + +diplomat_result_void_ICU4XError ICU4XCustomTimeZone_metazone_id(const ICU4XCustomTimeZone* self, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XCustomTimeZone_try_set_zone_variant(ICU4XCustomTimeZone* self, const char* id_data, size_t id_len); + +void ICU4XCustomTimeZone_clear_zone_variant(ICU4XCustomTimeZone* self); + +diplomat_result_void_ICU4XError ICU4XCustomTimeZone_zone_variant(const ICU4XCustomTimeZone* self, DiplomatWriteable* write); + +void ICU4XCustomTimeZone_set_standard_time(ICU4XCustomTimeZone* self); + +void ICU4XCustomTimeZone_set_daylight_time(ICU4XCustomTimeZone* self); + +diplomat_result_bool_ICU4XError ICU4XCustomTimeZone_is_standard_time(const ICU4XCustomTimeZone* self); + +diplomat_result_bool_ICU4XError ICU4XCustomTimeZone_is_daylight_time(const ICU4XCustomTimeZone* self); + +void ICU4XCustomTimeZone_maybe_calculate_metazone(ICU4XCustomTimeZone* self, const ICU4XMetazoneCalculator* metazone_calculator, const ICU4XIsoDateTime* local_datetime); +void ICU4XCustomTimeZone_destroy(ICU4XCustomTimeZone* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XCustomTimeZone.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XCustomTimeZone.hpp new file mode 100644 index 000000000000..fc1ccea36fdc --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XCustomTimeZone.hpp @@ -0,0 +1,527 @@ +#ifndef ICU4XCustomTimeZone_HPP +#define ICU4XCustomTimeZone_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XCustomTimeZone.h" + +class ICU4XCustomTimeZone; +#include "ICU4XError.hpp" +class ICU4XMetazoneCalculator; +class ICU4XIsoDateTime; + +/** + * A destruction policy for using ICU4XCustomTimeZone with std::unique_ptr. + */ +struct ICU4XCustomTimeZoneDeleter { + void operator()(capi::ICU4XCustomTimeZone* l) const noexcept { + capi::ICU4XCustomTimeZone_destroy(l); + } +}; + +/** + * + * + * See the [Rust documentation for `CustomTimeZone`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html) for more information. + */ +class ICU4XCustomTimeZone { + public: + + /** + * Creates a time zone from an offset string. + * + * See the [Rust documentation for `from_str`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.from_str) for more information. + */ + static diplomat::result create_from_string(const std::string_view s); + + /** + * Creates a time zone with no information. + * + * See the [Rust documentation for `new_empty`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.new_empty) for more information. + */ + static ICU4XCustomTimeZone create_empty(); + + /** + * Creates a time zone for UTC. + * + * See the [Rust documentation for `utc`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.utc) for more information. + */ + static ICU4XCustomTimeZone create_utc(); + + /** + * Sets the `gmt_offset` field from offset seconds. + * + * Errors if the offset seconds are out of range. + * + * See the [Rust documentation for `try_from_offset_seconds`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.try_from_offset_seconds) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html) + */ + diplomat::result try_set_gmt_offset_seconds(int32_t offset_seconds); + + /** + * Clears the `gmt_offset` field. + * + * See the [Rust documentation for `offset_seconds`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.offset_seconds) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html) + */ + void clear_gmt_offset(); + + /** + * Returns the value of the `gmt_offset` field as offset seconds. + * + * Errors if the `gmt_offset` field is empty. + * + * See the [Rust documentation for `offset_seconds`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.offset_seconds) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html) + */ + diplomat::result gmt_offset_seconds() const; + + /** + * Returns whether the `gmt_offset` field is positive. + * + * Errors if the `gmt_offset` field is empty. + * + * See the [Rust documentation for `is_positive`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.is_positive) for more information. + */ + diplomat::result is_gmt_offset_positive() const; + + /** + * Returns whether the `gmt_offset` field is zero. + * + * Errors if the `gmt_offset` field is empty (which is not the same as zero). + * + * See the [Rust documentation for `is_zero`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.is_zero) for more information. + */ + diplomat::result is_gmt_offset_zero() const; + + /** + * Returns whether the `gmt_offset` field has nonzero minutes. + * + * Errors if the `gmt_offset` field is empty. + * + * See the [Rust documentation for `has_minutes`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.has_minutes) for more information. + */ + diplomat::result gmt_offset_has_minutes() const; + + /** + * Returns whether the `gmt_offset` field has nonzero seconds. + * + * Errors if the `gmt_offset` field is empty. + * + * See the [Rust documentation for `has_seconds`](https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.has_seconds) for more information. + */ + diplomat::result gmt_offset_has_seconds() const; + + /** + * Sets the `time_zone_id` field from a string. + * + * Errors if the string is not a valid BCP-47 time zone ID. + * + * See the [Rust documentation for `time_zone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.time_zone_id) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneBcp47Id.html) + */ + diplomat::result try_set_time_zone_id(const std::string_view id); + + /** + * Clears the `time_zone_id` field. + * + * See the [Rust documentation for `time_zone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.time_zone_id) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneBcp47Id.html) + */ + void clear_time_zone_id(); + + /** + * Writes the value of the `time_zone_id` field as a string. + * + * Errors if the `time_zone_id` field is empty. + * + * See the [Rust documentation for `time_zone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.time_zone_id) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneBcp47Id.html) + */ + template diplomat::result time_zone_id_to_writeable(W& write) const; + + /** + * Writes the value of the `time_zone_id` field as a string. + * + * Errors if the `time_zone_id` field is empty. + * + * See the [Rust documentation for `time_zone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.time_zone_id) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneBcp47Id.html) + */ + diplomat::result time_zone_id() const; + + /** + * Sets the `metazone_id` field from a string. + * + * Errors if the string is not a valid BCP-47 metazone ID. + * + * See the [Rust documentation for `metazone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.metazone_id) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneId.html) + */ + diplomat::result try_set_metazone_id(const std::string_view id); + + /** + * Clears the `metazone_id` field. + * + * See the [Rust documentation for `metazone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.metazone_id) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneId.html) + */ + void clear_metazone_id(); + + /** + * Writes the value of the `metazone_id` field as a string. + * + * Errors if the `metazone_id` field is empty. + * + * See the [Rust documentation for `metazone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.metazone_id) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneId.html) + */ + template diplomat::result metazone_id_to_writeable(W& write) const; + + /** + * Writes the value of the `metazone_id` field as a string. + * + * Errors if the `metazone_id` field is empty. + * + * See the [Rust documentation for `metazone_id`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.metazone_id) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneId.html) + */ + diplomat::result metazone_id() const; + + /** + * Sets the `zone_variant` field from a string. + * + * Errors if the string is not a valid zone variant. + * + * See the [Rust documentation for `zone_variant`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html) + */ + diplomat::result try_set_zone_variant(const std::string_view id); + + /** + * Clears the `zone_variant` field. + * + * See the [Rust documentation for `zone_variant`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html) + */ + void clear_zone_variant(); + + /** + * Writes the value of the `zone_variant` field as a string. + * + * Errors if the `zone_variant` field is empty. + * + * See the [Rust documentation for `zone_variant`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html) + */ + template diplomat::result zone_variant_to_writeable(W& write) const; + + /** + * Writes the value of the `zone_variant` field as a string. + * + * Errors if the `zone_variant` field is empty. + * + * See the [Rust documentation for `zone_variant`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html) + */ + diplomat::result zone_variant() const; + + /** + * Sets the `zone_variant` field to standard time. + * + * See the [Rust documentation for `standard`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.standard) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) + */ + void set_standard_time(); + + /** + * Sets the `zone_variant` field to daylight time. + * + * See the [Rust documentation for `daylight`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.daylight) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) + */ + void set_daylight_time(); + + /** + * Returns whether the `zone_variant` field is standard time. + * + * Errors if the `zone_variant` field is empty. + * + * See the [Rust documentation for `standard`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.standard) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) + */ + diplomat::result is_standard_time() const; + + /** + * Returns whether the `zone_variant` field is daylight time. + * + * Errors if the `zone_variant` field is empty. + * + * See the [Rust documentation for `daylight`](https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.daylight) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant) + */ + diplomat::result is_daylight_time() const; + + /** + * Sets the metazone based on the time zone and the local timestamp. + * + * See the [Rust documentation for `maybe_calculate_metazone`](https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.maybe_calculate_metazone) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneCalculator.html#method.compute_metazone_from_time_zone) + */ + void maybe_calculate_metazone(const ICU4XMetazoneCalculator& metazone_calculator, const ICU4XIsoDateTime& local_datetime); + inline const capi::ICU4XCustomTimeZone* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XCustomTimeZone* AsFFIMut() { return this->inner.get(); } + inline ICU4XCustomTimeZone(capi::ICU4XCustomTimeZone* i) : inner(i) {} + ICU4XCustomTimeZone() = default; + ICU4XCustomTimeZone(ICU4XCustomTimeZone&&) noexcept = default; + ICU4XCustomTimeZone& operator=(ICU4XCustomTimeZone&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XMetazoneCalculator.hpp" +#include "ICU4XIsoDateTime.hpp" + +inline diplomat::result ICU4XCustomTimeZone::create_from_string(const std::string_view s) { + auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_create_from_string(s.data(), s.size()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XCustomTimeZone(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XCustomTimeZone ICU4XCustomTimeZone::create_empty() { + return ICU4XCustomTimeZone(capi::ICU4XCustomTimeZone_create_empty()); +} +inline ICU4XCustomTimeZone ICU4XCustomTimeZone::create_utc() { + return ICU4XCustomTimeZone(capi::ICU4XCustomTimeZone_create_utc()); +} +inline diplomat::result ICU4XCustomTimeZone::try_set_gmt_offset_seconds(int32_t offset_seconds) { + auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_try_set_gmt_offset_seconds(this->inner.get(), offset_seconds); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline void ICU4XCustomTimeZone::clear_gmt_offset() { + capi::ICU4XCustomTimeZone_clear_gmt_offset(this->inner.get()); +} +inline diplomat::result ICU4XCustomTimeZone::gmt_offset_seconds() const { + auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_gmt_offset_seconds(this->inner.get()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(diplomat_result_raw_out_value.ok)); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCustomTimeZone::is_gmt_offset_positive() const { + auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_is_gmt_offset_positive(this->inner.get()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(diplomat_result_raw_out_value.ok)); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCustomTimeZone::is_gmt_offset_zero() const { + auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_is_gmt_offset_zero(this->inner.get()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(diplomat_result_raw_out_value.ok)); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCustomTimeZone::gmt_offset_has_minutes() const { + auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_gmt_offset_has_minutes(this->inner.get()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(diplomat_result_raw_out_value.ok)); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCustomTimeZone::gmt_offset_has_seconds() const { + auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_gmt_offset_has_seconds(this->inner.get()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(diplomat_result_raw_out_value.ok)); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCustomTimeZone::try_set_time_zone_id(const std::string_view id) { + auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_try_set_time_zone_id(this->inner.get(), id.data(), id.size()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline void ICU4XCustomTimeZone::clear_time_zone_id() { + capi::ICU4XCustomTimeZone_clear_time_zone_id(this->inner.get()); +} +template inline diplomat::result ICU4XCustomTimeZone::time_zone_id_to_writeable(W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_time_zone_id(this->inner.get(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCustomTimeZone::time_zone_id() const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_time_zone_id(this->inner.get(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +inline diplomat::result ICU4XCustomTimeZone::try_set_metazone_id(const std::string_view id) { + auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_try_set_metazone_id(this->inner.get(), id.data(), id.size()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline void ICU4XCustomTimeZone::clear_metazone_id() { + capi::ICU4XCustomTimeZone_clear_metazone_id(this->inner.get()); +} +template inline diplomat::result ICU4XCustomTimeZone::metazone_id_to_writeable(W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_metazone_id(this->inner.get(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCustomTimeZone::metazone_id() const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_metazone_id(this->inner.get(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +inline diplomat::result ICU4XCustomTimeZone::try_set_zone_variant(const std::string_view id) { + auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_try_set_zone_variant(this->inner.get(), id.data(), id.size()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline void ICU4XCustomTimeZone::clear_zone_variant() { + capi::ICU4XCustomTimeZone_clear_zone_variant(this->inner.get()); +} +template inline diplomat::result ICU4XCustomTimeZone::zone_variant_to_writeable(W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_zone_variant(this->inner.get(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCustomTimeZone::zone_variant() const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_zone_variant(this->inner.get(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +inline void ICU4XCustomTimeZone::set_standard_time() { + capi::ICU4XCustomTimeZone_set_standard_time(this->inner.get()); +} +inline void ICU4XCustomTimeZone::set_daylight_time() { + capi::ICU4XCustomTimeZone_set_daylight_time(this->inner.get()); +} +inline diplomat::result ICU4XCustomTimeZone::is_standard_time() const { + auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_is_standard_time(this->inner.get()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(diplomat_result_raw_out_value.ok)); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XCustomTimeZone::is_daylight_time() const { + auto diplomat_result_raw_out_value = capi::ICU4XCustomTimeZone_is_daylight_time(this->inner.get()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(diplomat_result_raw_out_value.ok)); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline void ICU4XCustomTimeZone::maybe_calculate_metazone(const ICU4XMetazoneCalculator& metazone_calculator, const ICU4XIsoDateTime& local_datetime) { + capi::ICU4XCustomTimeZone_maybe_calculate_metazone(this->inner.get(), metazone_calculator.AsFFI(), local_datetime.AsFFI()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDataProvider.h b/third_party/rust/icu_capi/cpp/include/ICU4XDataProvider.h new file mode 100644 index 000000000000..fd8b35b78778 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDataProvider.h @@ -0,0 +1,46 @@ +#ifndef ICU4XDataProvider_H +#define ICU4XDataProvider_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XDataProvider ICU4XDataProvider; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_box_ICU4XDataProvider_ICU4XError.h" +#include "diplomat_result_void_ICU4XError.h" +#include "ICU4XLocaleFallbacker.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XDataProvider_ICU4XError ICU4XDataProvider_create_fs(const char* path_data, size_t path_len); + +ICU4XDataProvider* ICU4XDataProvider_create_test(); + +diplomat_result_box_ICU4XDataProvider_ICU4XError ICU4XDataProvider_create_from_byte_slice(const uint8_t* blob_data, size_t blob_len); + +ICU4XDataProvider* ICU4XDataProvider_create_empty(); + +diplomat_result_void_ICU4XError ICU4XDataProvider_fork_by_key(ICU4XDataProvider* self, ICU4XDataProvider* other); + +diplomat_result_void_ICU4XError ICU4XDataProvider_fork_by_locale(ICU4XDataProvider* self, ICU4XDataProvider* other); + +diplomat_result_void_ICU4XError ICU4XDataProvider_enable_locale_fallback(ICU4XDataProvider* self); + +diplomat_result_void_ICU4XError ICU4XDataProvider_enable_locale_fallback_with(ICU4XDataProvider* self, const ICU4XLocaleFallbacker* fallbacker); +void ICU4XDataProvider_destroy(ICU4XDataProvider* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDataProvider.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XDataProvider.hpp new file mode 100644 index 000000000000..81cb2ea8551a --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDataProvider.hpp @@ -0,0 +1,186 @@ +#ifndef ICU4XDataProvider_HPP +#define ICU4XDataProvider_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XDataProvider.h" + +class ICU4XDataProvider; +#include "ICU4XError.hpp" +class ICU4XLocaleFallbacker; + +/** + * A destruction policy for using ICU4XDataProvider with std::unique_ptr. + */ +struct ICU4XDataProviderDeleter { + void operator()(capi::ICU4XDataProvider* l) const noexcept { + capi::ICU4XDataProvider_destroy(l); + } +}; + +/** + * 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. + */ +class ICU4XDataProvider { + public: + + /** + * Constructs an `FsDataProvider` and returns it as an [`ICU4XDataProvider`]. + * Requires the `provider_fs` Cargo feature. + * Not supported in WASM. + * + * See the [Rust documentation for `FsDataProvider`](https://docs.rs/icu_provider_fs/latest/icu_provider_fs/struct.FsDataProvider.html) for more information. + */ + static diplomat::result create_fs(const std::string_view path); + + /** + * Constructs a testdata provider and returns it as an [`ICU4XDataProvider`]. + * Requires the `provider_test` and one of `any_provider` or `buffer_provider` Cargo features. + * + * See the [Rust documentation for `icu_testdata`](https://docs.rs/icu_testdata/latest/icu_testdata/index.html) for more information. + */ + static ICU4XDataProvider create_test(); + + /** + * Constructs a `BlobDataProvider` and returns it as an [`ICU4XDataProvider`]. + * + * See the [Rust documentation for `BlobDataProvider`](https://docs.rs/icu_provider_blob/latest/icu_provider_blob/struct.BlobDataProvider.html) for more information. + * + * Lifetimes: `blob` must live for the duration of the program. + */ + static diplomat::result create_from_byte_slice(const diplomat::span blob); + + /** + * Constructs an empty [`ICU4XDataProvider`]. + * + * See the [Rust documentation for `EmptyDataProvider`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/empty/struct.EmptyDataProvider.html) for more information. + */ + static ICU4XDataProvider create_empty(); + + /** + * Creates a provider that tries the current provider and then, if the current provider + * doesn't support the data key, another provider `other`. + * + * This takes ownership of the `other` provider, leaving an empty provider in its place. + * + * The providers must be the same type (Any or Buffer). This condition is satisfied if + * both providers originate from the same constructor, such as `create_from_byte_slice` + * or `create_fs`. If the condition is not upheld, a runtime error occurs. + * + * See the [Rust documentation for `ForkByKeyProvider`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fork/type.ForkByKeyProvider.html) for more information. + */ + diplomat::result fork_by_key(ICU4XDataProvider& other); + + /** + * Same as `fork_by_key` but forks by locale instead of key. + * + * See the [Rust documentation for `MissingLocalePredicate`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fork/predicates/struct.MissingLocalePredicate.html) for more information. + */ + diplomat::result fork_by_locale(ICU4XDataProvider& other); + + /** + * Enables locale fallbacking for data requests made to this provider. + * + * Note that the test provider (from `create_test`) already has fallbacking enabled. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html#method.try_new_unstable) for more information. + * + * Additional information: [1](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html) + */ + diplomat::result enable_locale_fallback(); + + /** + * + * + * See the [Rust documentation for `new_with_fallbacker`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html#method.new_with_fallbacker) for more information. + * + * Additional information: [1](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html) + */ + diplomat::result enable_locale_fallback_with(const ICU4XLocaleFallbacker& fallbacker); + inline const capi::ICU4XDataProvider* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XDataProvider* AsFFIMut() { return this->inner.get(); } + inline ICU4XDataProvider(capi::ICU4XDataProvider* i) : inner(i) {} + ICU4XDataProvider() = default; + ICU4XDataProvider(ICU4XDataProvider&&) noexcept = default; + ICU4XDataProvider& operator=(ICU4XDataProvider&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XLocaleFallbacker.hpp" + +inline diplomat::result ICU4XDataProvider::create_fs(const std::string_view path) { + auto diplomat_result_raw_out_value = capi::ICU4XDataProvider_create_fs(path.data(), path.size()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XDataProvider(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XDataProvider ICU4XDataProvider::create_test() { + return ICU4XDataProvider(capi::ICU4XDataProvider_create_test()); +} +inline diplomat::result ICU4XDataProvider::create_from_byte_slice(const diplomat::span blob) { + auto diplomat_result_raw_out_value = capi::ICU4XDataProvider_create_from_byte_slice(blob.data(), blob.size()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XDataProvider(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XDataProvider ICU4XDataProvider::create_empty() { + return ICU4XDataProvider(capi::ICU4XDataProvider_create_empty()); +} +inline diplomat::result ICU4XDataProvider::fork_by_key(ICU4XDataProvider& other) { + auto diplomat_result_raw_out_value = capi::ICU4XDataProvider_fork_by_key(this->inner.get(), other.AsFFIMut()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XDataProvider::fork_by_locale(ICU4XDataProvider& other) { + auto diplomat_result_raw_out_value = capi::ICU4XDataProvider_fork_by_locale(this->inner.get(), other.AsFFIMut()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XDataProvider::enable_locale_fallback() { + auto diplomat_result_raw_out_value = capi::ICU4XDataProvider_enable_locale_fallback(this->inner.get()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XDataProvider::enable_locale_fallback_with(const ICU4XLocaleFallbacker& fallbacker) { + auto diplomat_result_raw_out_value = capi::ICU4XDataProvider_enable_locale_fallback_with(this->inner.get(), fallbacker.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDataStruct.h b/third_party/rust/icu_capi/cpp/include/ICU4XDataStruct.h new file mode 100644 index 000000000000..a07ff02fb8e4 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDataStruct.h @@ -0,0 +1,30 @@ +#ifndef ICU4XDataStruct_H +#define ICU4XDataStruct_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XDataStruct ICU4XDataStruct; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_box_ICU4XDataStruct_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XDataStruct_ICU4XError ICU4XDataStruct_create_decimal_symbols_v1(const char* plus_sign_prefix_data, size_t plus_sign_prefix_len, const char* plus_sign_suffix_data, size_t plus_sign_suffix_len, const char* minus_sign_prefix_data, size_t minus_sign_prefix_len, const char* minus_sign_suffix_data, size_t minus_sign_suffix_len, const char* decimal_separator_data, size_t decimal_separator_len, const char* grouping_separator_data, size_t grouping_separator_len, uint8_t primary_group_size, uint8_t secondary_group_size, uint8_t min_group_size, const char32_t* digits_data, size_t digits_len); +void ICU4XDataStruct_destroy(ICU4XDataStruct* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDataStruct.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XDataStruct.hpp new file mode 100644 index 000000000000..cff3bf0373ba --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDataStruct.hpp @@ -0,0 +1,63 @@ +#ifndef ICU4XDataStruct_HPP +#define ICU4XDataStruct_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XDataStruct.h" + +class ICU4XDataStruct; +#include "ICU4XError.hpp" + +/** + * A destruction policy for using ICU4XDataStruct with std::unique_ptr. + */ +struct ICU4XDataStructDeleter { + void operator()(capi::ICU4XDataStruct* l) const noexcept { + capi::ICU4XDataStruct_destroy(l); + } +}; + +/** + * A generic data struct to be used by ICU4X + * + * This can be used to construct a StructDataProvider. + */ +class ICU4XDataStruct { + public: + + /** + * Construct a new DecimalSymbolsV1 data struct. + * + * C++ users: All string arguments must be valid UTF8 + * + * See the [Rust documentation for `DecimalSymbolsV1`](https://docs.rs/icu/latest/icu/decimal/provider/struct.DecimalSymbolsV1.html) for more information. + */ + static diplomat::result create_decimal_symbols_v1(const std::string_view plus_sign_prefix, const std::string_view plus_sign_suffix, const std::string_view minus_sign_prefix, const std::string_view minus_sign_suffix, const std::string_view decimal_separator, const std::string_view grouping_separator, uint8_t primary_group_size, uint8_t secondary_group_size, uint8_t min_group_size, const diplomat::span digits); + inline const capi::ICU4XDataStruct* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XDataStruct* AsFFIMut() { return this->inner.get(); } + inline ICU4XDataStruct(capi::ICU4XDataStruct* i) : inner(i) {} + ICU4XDataStruct() = default; + ICU4XDataStruct(ICU4XDataStruct&&) noexcept = default; + ICU4XDataStruct& operator=(ICU4XDataStruct&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline diplomat::result ICU4XDataStruct::create_decimal_symbols_v1(const std::string_view plus_sign_prefix, const std::string_view plus_sign_suffix, const std::string_view minus_sign_prefix, const std::string_view minus_sign_suffix, const std::string_view decimal_separator, const std::string_view grouping_separator, uint8_t primary_group_size, uint8_t secondary_group_size, uint8_t min_group_size, const diplomat::span digits) { + auto diplomat_result_raw_out_value = capi::ICU4XDataStruct_create_decimal_symbols_v1(plus_sign_prefix.data(), plus_sign_prefix.size(), plus_sign_suffix.data(), plus_sign_suffix.size(), minus_sign_prefix.data(), minus_sign_prefix.size(), minus_sign_suffix.data(), minus_sign_suffix.size(), decimal_separator.data(), decimal_separator.size(), grouping_separator.data(), grouping_separator.size(), primary_group_size, secondary_group_size, min_group_size, digits.data(), digits.size()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XDataStruct(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDate.h b/third_party/rust/icu_capi/cpp/include/ICU4XDate.h new file mode 100644 index 000000000000..e88128678899 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDate.h @@ -0,0 +1,66 @@ +#ifndef ICU4XDate_H +#define ICU4XDate_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XDate ICU4XDate; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XCalendar.h" +#include "diplomat_result_box_ICU4XDate_ICU4XError.h" +#include "ICU4XIsoDate.h" +#include "ICU4XIsoWeekday.h" +#include "ICU4XWeekCalculator.h" +#include "diplomat_result_ICU4XWeekOf_ICU4XError.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XDate_ICU4XError ICU4XDate_create_from_iso_in_calendar(int32_t year, uint8_t month, uint8_t day, const ICU4XCalendar* calendar); + +diplomat_result_box_ICU4XDate_ICU4XError ICU4XDate_create_from_codes_in_calendar(const char* era_code_data, size_t era_code_len, int32_t year, const char* month_code_data, size_t month_code_len, uint8_t day, const ICU4XCalendar* calendar); + +ICU4XDate* ICU4XDate_to_calendar(const ICU4XDate* self, const ICU4XCalendar* calendar); + +ICU4XIsoDate* ICU4XDate_to_iso(const ICU4XDate* self); + +uint32_t ICU4XDate_day_of_month(const ICU4XDate* self); + +ICU4XIsoWeekday ICU4XDate_day_of_week(const ICU4XDate* self); + +uint32_t ICU4XDate_week_of_month(const ICU4XDate* self, ICU4XIsoWeekday first_weekday); + +diplomat_result_ICU4XWeekOf_ICU4XError ICU4XDate_week_of_year(const ICU4XDate* self, const ICU4XWeekCalculator* calculator); + +uint32_t ICU4XDate_ordinal_month(const ICU4XDate* self); + +diplomat_result_void_ICU4XError ICU4XDate_month_code(const ICU4XDate* self, DiplomatWriteable* write); + +int32_t ICU4XDate_year_in_era(const ICU4XDate* self); + +diplomat_result_void_ICU4XError ICU4XDate_era(const ICU4XDate* self, DiplomatWriteable* write); + +uint8_t ICU4XDate_months_in_year(const ICU4XDate* self); + +uint8_t ICU4XDate_days_in_month(const ICU4XDate* self); + +uint32_t ICU4XDate_days_in_year(const ICU4XDate* self); + +ICU4XCalendar* ICU4XDate_calendar(const ICU4XDate* self); +void ICU4XDate_destroy(ICU4XDate* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDate.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XDate.hpp new file mode 100644 index 000000000000..440236a53ca3 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDate.hpp @@ -0,0 +1,303 @@ +#ifndef ICU4XDate_HPP +#define ICU4XDate_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XDate.h" + +class ICU4XCalendar; +class ICU4XDate; +#include "ICU4XError.hpp" +class ICU4XIsoDate; +#include "ICU4XIsoWeekday.hpp" +class ICU4XWeekCalculator; +struct ICU4XWeekOf; + +/** + * A destruction policy for using ICU4XDate with std::unique_ptr. + */ +struct ICU4XDateDeleter { + void operator()(capi::ICU4XDate* l) const noexcept { + capi::ICU4XDate_destroy(l); + } +}; + +/** + * 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. + */ +class ICU4XDate { + public: + + /** + * Creates a new [`ICU4XDate`] representing the ISO date and time + * given but in a given calendar + * + * See the [Rust documentation for `new_from_iso`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.new_from_iso) for more information. + */ + static diplomat::result create_from_iso_in_calendar(int32_t year, uint8_t month, uint8_t day, const ICU4XCalendar& calendar); + + /** + * Creates a new [`ICU4XDate`] from the given codes, which are interpreted in the given calendar system + * + * See the [Rust documentation for `try_new_from_codes`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.try_new_from_codes) for more information. + */ + static diplomat::result create_from_codes_in_calendar(const std::string_view era_code, int32_t year, const std::string_view month_code, uint8_t day, const ICU4XCalendar& calendar); + + /** + * 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. + */ + ICU4XDate to_calendar(const ICU4XCalendar& calendar) const; + + /** + * 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. + */ + ICU4XIsoDate to_iso() const; + + /** + * 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. + */ + uint32_t day_of_month() const; + + /** + * Returns the day in the week for this day + * + * See the [Rust documentation for `day_of_week`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_week) for more information. + */ + ICU4XIsoWeekday day_of_week() const; + + /** + * Returns the week number in this month, 1-indexed, based on what + * is considered the first day of the week (often a locale preference). + * + * `first_weekday` can be obtained via `first_weekday()` on [`ICU4XWeekCalculator`] + * + * 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. + */ + uint32_t week_of_month(ICU4XIsoWeekday first_weekday) const; + + /** + * Returns the week number in this year, using week data + * + * See the [Rust documentation for `week_of_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_year) for more information. + */ + diplomat::result week_of_year(const ICU4XWeekCalculator& calculator) const; + + /** + * Returns 1-indexed number of the month of this date in its year + * + * Note that for lunar calendars this may not lead to the same month + * having the same ordinal month across years; use month_code if you care + * about month identity. + * + * See the [Rust documentation for `month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month) for more information. + */ + uint32_t ordinal_month() const; + + /** + * Returns the month code for this date. Typically something + * like "M01", "M02", but can be more complicated for lunar calendars. + * + * See the [Rust documentation for `month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month) for more information. + */ + template diplomat::result month_code_to_writeable(W& write) const; + + /** + * Returns the month code for this date. Typically something + * like "M01", "M02", but can be more complicated for lunar calendars. + * + * See the [Rust documentation for `month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month) for more information. + */ + diplomat::result month_code() const; + + /** + * Returns the year number in the current era for this date + * + * See the [Rust documentation for `year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year) for more information. + */ + int32_t year_in_era() const; + + /** + * Returns the era for this date, + * + * See the [Rust documentation for `year`](https://docs.rs/icu/latest/icu/struct.Date.html#method.year) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/types/struct.Era.html) + */ + template diplomat::result era_to_writeable(W& write) const; + + /** + * Returns the era for this date, + * + * See the [Rust documentation for `year`](https://docs.rs/icu/latest/icu/struct.Date.html#method.year) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/types/struct.Era.html) + */ + diplomat::result era() const; + + /** + * Returns the number of months in the year represented by this date + * + * See the [Rust documentation for `months_in_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.months_in_year) for more information. + */ + uint8_t months_in_year() const; + + /** + * Returns the number of days in the month represented by this date + * + * See the [Rust documentation for `days_in_month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_month) for more information. + */ + uint8_t days_in_month() const; + + /** + * Returns the number of days in the year represented by this date + * + * See the [Rust documentation for `days_in_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_year) for more information. + */ + uint32_t days_in_year() const; + + /** + * Returns the [`ICU4XCalendar`] object backing this date + * + * See the [Rust documentation for `calendar`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.calendar) for more information. + */ + ICU4XCalendar calendar() const; + inline const capi::ICU4XDate* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XDate* AsFFIMut() { return this->inner.get(); } + inline ICU4XDate(capi::ICU4XDate* i) : inner(i) {} + ICU4XDate() = default; + ICU4XDate(ICU4XDate&&) noexcept = default; + ICU4XDate& operator=(ICU4XDate&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XCalendar.hpp" +#include "ICU4XIsoDate.hpp" +#include "ICU4XWeekCalculator.hpp" +#include "ICU4XWeekOf.hpp" + +inline diplomat::result ICU4XDate::create_from_iso_in_calendar(int32_t year, uint8_t month, uint8_t day, const ICU4XCalendar& calendar) { + auto diplomat_result_raw_out_value = capi::ICU4XDate_create_from_iso_in_calendar(year, month, day, calendar.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XDate(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XDate::create_from_codes_in_calendar(const std::string_view era_code, int32_t year, const std::string_view month_code, uint8_t day, const ICU4XCalendar& calendar) { + auto diplomat_result_raw_out_value = capi::ICU4XDate_create_from_codes_in_calendar(era_code.data(), era_code.size(), year, month_code.data(), month_code.size(), day, calendar.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XDate(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XDate ICU4XDate::to_calendar(const ICU4XCalendar& calendar) const { + return ICU4XDate(capi::ICU4XDate_to_calendar(this->inner.get(), calendar.AsFFI())); +} +inline ICU4XIsoDate ICU4XDate::to_iso() const { + return ICU4XIsoDate(capi::ICU4XDate_to_iso(this->inner.get())); +} +inline uint32_t ICU4XDate::day_of_month() const { + return capi::ICU4XDate_day_of_month(this->inner.get()); +} +inline ICU4XIsoWeekday ICU4XDate::day_of_week() const { + return static_cast(capi::ICU4XDate_day_of_week(this->inner.get())); +} +inline uint32_t ICU4XDate::week_of_month(ICU4XIsoWeekday first_weekday) const { + return capi::ICU4XDate_week_of_month(this->inner.get(), static_cast(first_weekday)); +} +inline diplomat::result ICU4XDate::week_of_year(const ICU4XWeekCalculator& calculator) const { + auto diplomat_result_raw_out_value = capi::ICU4XDate_week_of_year(this->inner.get(), calculator.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + capi::ICU4XWeekOf diplomat_raw_struct_out_value = diplomat_result_raw_out_value.ok; + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XWeekOf{ .week = std::move(diplomat_raw_struct_out_value.week), .unit = std::move(static_cast(diplomat_raw_struct_out_value.unit)) })); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline uint32_t ICU4XDate::ordinal_month() const { + return capi::ICU4XDate_ordinal_month(this->inner.get()); +} +template inline diplomat::result ICU4XDate::month_code_to_writeable(W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XDate_month_code(this->inner.get(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XDate::month_code() const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XDate_month_code(this->inner.get(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +inline int32_t ICU4XDate::year_in_era() const { + return capi::ICU4XDate_year_in_era(this->inner.get()); +} +template inline diplomat::result ICU4XDate::era_to_writeable(W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XDate_era(this->inner.get(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XDate::era() const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XDate_era(this->inner.get(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +inline uint8_t ICU4XDate::months_in_year() const { + return capi::ICU4XDate_months_in_year(this->inner.get()); +} +inline uint8_t ICU4XDate::days_in_month() const { + return capi::ICU4XDate_days_in_month(this->inner.get()); +} +inline uint32_t ICU4XDate::days_in_year() const { + return capi::ICU4XDate_days_in_year(this->inner.get()); +} +inline ICU4XCalendar ICU4XDate::calendar() const { + return ICU4XCalendar(capi::ICU4XDate_calendar(this->inner.get())); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDateFormatter.h b/third_party/rust/icu_capi/cpp/include/ICU4XDateFormatter.h new file mode 100644 index 000000000000..8dc5316e4789 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDateFormatter.h @@ -0,0 +1,46 @@ +#ifndef ICU4XDateFormatter_H +#define ICU4XDateFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XDateFormatter ICU4XDateFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XDateLength.h" +#include "diplomat_result_box_ICU4XDateFormatter_ICU4XError.h" +#include "ICU4XDate.h" +#include "diplomat_result_void_ICU4XError.h" +#include "ICU4XIsoDate.h" +#include "ICU4XDateTime.h" +#include "ICU4XIsoDateTime.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XDateFormatter_ICU4XError ICU4XDateFormatter_create_with_length(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XDateLength date_length); + +diplomat_result_void_ICU4XError ICU4XDateFormatter_format_date(const ICU4XDateFormatter* self, const ICU4XDate* value, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XDateFormatter_format_iso_date(const ICU4XDateFormatter* self, const ICU4XIsoDate* value, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XDateFormatter_format_datetime(const ICU4XDateFormatter* self, const ICU4XDateTime* value, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XDateFormatter_format_iso_datetime(const ICU4XDateFormatter* self, const ICU4XIsoDateTime* value, DiplomatWriteable* write); +void ICU4XDateFormatter_destroy(ICU4XDateFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDateFormatter.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XDateFormatter.hpp new file mode 100644 index 000000000000..e230bf29ab00 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDateFormatter.hpp @@ -0,0 +1,231 @@ +#ifndef ICU4XDateFormatter_HPP +#define ICU4XDateFormatter_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XDateFormatter.h" + +class ICU4XDataProvider; +class ICU4XLocale; +#include "ICU4XDateLength.hpp" +class ICU4XDateFormatter; +#include "ICU4XError.hpp" +class ICU4XDate; +class ICU4XIsoDate; +class ICU4XDateTime; +class ICU4XIsoDateTime; + +/** + * A destruction policy for using ICU4XDateFormatter with std::unique_ptr. + */ +struct ICU4XDateFormatterDeleter { + void operator()(capi::ICU4XDateFormatter* l) const noexcept { + capi::ICU4XDateFormatter_destroy(l); + } +}; + +/** + * An ICU4X DateFormatter object capable of formatting a [`ICU4XDate`] as a string, + * using some calendar specified at runtime in the locale. + * + * See the [Rust documentation for `DateFormatter`](https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html) for more information. + */ +class ICU4XDateFormatter { + public: + + /** + * Creates a new [`ICU4XDateFormatter`] from locale data. + * + * See the [Rust documentation for `try_new_with_length_unstable`](https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.try_new_with_length_unstable) for more information. + */ + static diplomat::result create_with_length(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XDateLength date_length); + + /** + * Formats a [`ICU4XDate`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.format) for more information. + */ + template diplomat::result format_date_to_writeable(const ICU4XDate& value, W& write) const; + + /** + * Formats a [`ICU4XDate`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.format) for more information. + */ + diplomat::result format_date(const ICU4XDate& value) const; + + /** + * Formats a [`ICU4XIsoDate`] to a string. + * + * Will convert to this formatter's calendar first + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.format) for more information. + */ + template diplomat::result format_iso_date_to_writeable(const ICU4XIsoDate& value, W& write) const; + + /** + * Formats a [`ICU4XIsoDate`] to a string. + * + * Will convert to this formatter's calendar first + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.format) for more information. + */ + diplomat::result format_iso_date(const ICU4XIsoDate& value) const; + + /** + * Formats a [`ICU4XDateTime`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.format) for more information. + */ + template diplomat::result format_datetime_to_writeable(const ICU4XDateTime& value, W& write) const; + + /** + * Formats a [`ICU4XDateTime`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.format) for more information. + */ + diplomat::result format_datetime(const ICU4XDateTime& value) const; + + /** + * Formats a [`ICU4XIsoDateTime`] to a string. + * + * Will convert to this formatter's calendar first + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.format) for more information. + */ + template diplomat::result format_iso_datetime_to_writeable(const ICU4XIsoDateTime& value, W& write) const; + + /** + * Formats a [`ICU4XIsoDateTime`] to a string. + * + * Will convert to this formatter's calendar first + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.format) for more information. + */ + diplomat::result format_iso_datetime(const ICU4XIsoDateTime& value) const; + inline const capi::ICU4XDateFormatter* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XDateFormatter* AsFFIMut() { return this->inner.get(); } + inline ICU4XDateFormatter(capi::ICU4XDateFormatter* i) : inner(i) {} + ICU4XDateFormatter() = default; + ICU4XDateFormatter(ICU4XDateFormatter&&) noexcept = default; + ICU4XDateFormatter& operator=(ICU4XDateFormatter&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" +#include "ICU4XDate.hpp" +#include "ICU4XIsoDate.hpp" +#include "ICU4XDateTime.hpp" +#include "ICU4XIsoDateTime.hpp" + +inline diplomat::result ICU4XDateFormatter::create_with_length(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XDateLength date_length) { + auto diplomat_result_raw_out_value = capi::ICU4XDateFormatter_create_with_length(provider.AsFFI(), locale.AsFFI(), static_cast(date_length)); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XDateFormatter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +template inline diplomat::result ICU4XDateFormatter::format_date_to_writeable(const ICU4XDate& value, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XDateFormatter_format_date(this->inner.get(), value.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XDateFormatter::format_date(const ICU4XDate& value) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XDateFormatter_format_date(this->inner.get(), value.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +template inline diplomat::result ICU4XDateFormatter::format_iso_date_to_writeable(const ICU4XIsoDate& value, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XDateFormatter_format_iso_date(this->inner.get(), value.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XDateFormatter::format_iso_date(const ICU4XIsoDate& value) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XDateFormatter_format_iso_date(this->inner.get(), value.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +template inline diplomat::result ICU4XDateFormatter::format_datetime_to_writeable(const ICU4XDateTime& value, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XDateFormatter_format_datetime(this->inner.get(), value.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XDateFormatter::format_datetime(const ICU4XDateTime& value) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XDateFormatter_format_datetime(this->inner.get(), value.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +template inline diplomat::result ICU4XDateFormatter::format_iso_datetime_to_writeable(const ICU4XIsoDateTime& value, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XDateFormatter_format_iso_datetime(this->inner.get(), value.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XDateFormatter::format_iso_datetime(const ICU4XIsoDateTime& value) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XDateFormatter_format_iso_datetime(this->inner.get(), value.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDateLength.h b/third_party/rust/icu_capi/cpp/include/ICU4XDateLength.h new file mode 100644 index 000000000000..b2ca91823365 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDateLength.h @@ -0,0 +1,33 @@ +#ifndef ICU4XDateLength_H +#define ICU4XDateLength_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XDateLength { + ICU4XDateLength_Full = 0, + ICU4XDateLength_Long = 1, + ICU4XDateLength_Medium = 2, + ICU4XDateLength_Short = 3, +} ICU4XDateLength; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XDateLength_destroy(ICU4XDateLength* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDateLength.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XDateLength.hpp new file mode 100644 index 000000000000..0e6a33326e46 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDateLength.hpp @@ -0,0 +1,28 @@ +#ifndef ICU4XDateLength_HPP +#define ICU4XDateLength_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XDateLength.h" + + + +/** + * + * + * See the [Rust documentation for `Date`](https://docs.rs/icu/latest/icu/datetime/options/length/enum.Date.html) for more information. + */ +enum struct ICU4XDateLength { + Full = 0, + Long = 1, + Medium = 2, + Short = 3, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDateTime.h b/third_party/rust/icu_capi/cpp/include/ICU4XDateTime.h new file mode 100644 index 000000000000..a9dc1cee7160 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDateTime.h @@ -0,0 +1,82 @@ +#ifndef ICU4XDateTime_H +#define ICU4XDateTime_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XDateTime ICU4XDateTime; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XCalendar.h" +#include "diplomat_result_box_ICU4XDateTime_ICU4XError.h" +#include "ICU4XDate.h" +#include "ICU4XTime.h" +#include "ICU4XIsoDateTime.h" +#include "ICU4XIsoWeekday.h" +#include "ICU4XWeekCalculator.h" +#include "diplomat_result_ICU4XWeekOf_ICU4XError.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XDateTime_ICU4XError ICU4XDateTime_create_from_iso_in_calendar(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const ICU4XCalendar* calendar); + +diplomat_result_box_ICU4XDateTime_ICU4XError ICU4XDateTime_create_from_codes_in_calendar(const char* era_code_data, size_t era_code_len, int32_t year, const char* month_code_data, size_t month_code_len, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const ICU4XCalendar* calendar); + +ICU4XDateTime* ICU4XDateTime_create_from_date_and_time(const ICU4XDate* date, const ICU4XTime* time); + +ICU4XDate* ICU4XDateTime_date(const ICU4XDateTime* self); + +ICU4XTime* ICU4XDateTime_time(const ICU4XDateTime* self); + +ICU4XIsoDateTime* ICU4XDateTime_to_iso(const ICU4XDateTime* self); + +ICU4XDateTime* ICU4XDateTime_to_calendar(const ICU4XDateTime* self, const ICU4XCalendar* calendar); + +uint8_t ICU4XDateTime_hour(const ICU4XDateTime* self); + +uint8_t ICU4XDateTime_minute(const ICU4XDateTime* self); + +uint8_t ICU4XDateTime_second(const ICU4XDateTime* self); + +uint32_t ICU4XDateTime_nanosecond(const ICU4XDateTime* self); + +uint32_t ICU4XDateTime_day_of_month(const ICU4XDateTime* self); + +ICU4XIsoWeekday ICU4XDateTime_day_of_week(const ICU4XDateTime* self); + +uint32_t ICU4XDateTime_week_of_month(const ICU4XDateTime* self, ICU4XIsoWeekday first_weekday); + +diplomat_result_ICU4XWeekOf_ICU4XError ICU4XDateTime_week_of_year(const ICU4XDateTime* self, const ICU4XWeekCalculator* calculator); + +uint32_t ICU4XDateTime_ordinal_month(const ICU4XDateTime* self); + +diplomat_result_void_ICU4XError ICU4XDateTime_month_code(const ICU4XDateTime* self, DiplomatWriteable* write); + +int32_t ICU4XDateTime_year_in_era(const ICU4XDateTime* self); + +diplomat_result_void_ICU4XError ICU4XDateTime_era(const ICU4XDateTime* self, DiplomatWriteable* write); + +uint8_t ICU4XDateTime_months_in_year(const ICU4XDateTime* self); + +uint8_t ICU4XDateTime_days_in_month(const ICU4XDateTime* self); + +uint32_t ICU4XDateTime_days_in_year(const ICU4XDateTime* self); + +ICU4XCalendar* ICU4XDateTime_calendar(const ICU4XDateTime* self); +void ICU4XDateTime_destroy(ICU4XDateTime* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDateTime.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XDateTime.hpp new file mode 100644 index 000000000000..5f26e0f4e604 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDateTime.hpp @@ -0,0 +1,373 @@ +#ifndef ICU4XDateTime_HPP +#define ICU4XDateTime_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XDateTime.h" + +class ICU4XCalendar; +class ICU4XDateTime; +#include "ICU4XError.hpp" +class ICU4XDate; +class ICU4XTime; +class ICU4XIsoDateTime; +#include "ICU4XIsoWeekday.hpp" +class ICU4XWeekCalculator; +struct ICU4XWeekOf; + +/** + * A destruction policy for using ICU4XDateTime with std::unique_ptr. + */ +struct ICU4XDateTimeDeleter { + void operator()(capi::ICU4XDateTime* l) const noexcept { + capi::ICU4XDateTime_destroy(l); + } +}; + +/** + * 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. + */ +class ICU4XDateTime { + public: + + /** + * Creates a new [`ICU4XDateTime`] representing the ISO date and time + * given but in a given calendar + * + * See the [Rust documentation for `new_from_iso`](https://docs.rs/icu/latest/icu/struct.DateTime.html#method.new_from_iso) for more information. + */ + static diplomat::result create_from_iso_in_calendar(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const ICU4XCalendar& calendar); + + /** + * Creates a new [`ICU4XDateTime`] from the given codes, which are interpreted in the given calendar system + * + * See the [Rust documentation for `try_new_from_codes`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.try_new_from_codes) for more information. + */ + static diplomat::result create_from_codes_in_calendar(const std::string_view era_code, int32_t year, const std::string_view month_code, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const ICU4XCalendar& calendar); + + /** + * Creates a new [`ICU4XDateTime`] from an [`ICU4XDate`] and [`ICU4XTime`] object + * + * See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.new) for more information. + */ + static ICU4XDateTime create_from_date_and_time(const ICU4XDate& date, const ICU4XTime& time); + + /** + * 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. + */ + ICU4XDate date() const; + + /** + * 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. + */ + ICU4XTime time() const; + + /** + * 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. + */ + ICU4XIsoDateTime to_iso() const; + + /** + * 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. + */ + ICU4XDateTime to_calendar(const ICU4XCalendar& calendar) const; + + /** + * 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. + */ + uint8_t hour() const; + + /** + * Returns the minute in this time + * + * See the [Rust documentation for `minute`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.minute) for more information. + */ + uint8_t minute() const; + + /** + * Returns the second in this time + * + * See the [Rust documentation for `second`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.second) for more information. + */ + uint8_t second() const; + + /** + * Returns the nanosecond in this time + * + * See the [Rust documentation for `nanosecond`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.nanosecond) for more information. + */ + uint32_t nanosecond() const; + + /** + * 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. + */ + uint32_t day_of_month() const; + + /** + * Returns the day in the week for this day + * + * See the [Rust documentation for `day_of_week`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_week) for more information. + */ + ICU4XIsoWeekday day_of_week() const; + + /** + * Returns the week number in this month, 1-indexed, based on what + * is considered the first day of the week (often a locale preference). + * + * `first_weekday` can be obtained via `first_weekday()` on [`ICU4XWeekCalculator`] + * + * 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. + */ + uint32_t week_of_month(ICU4XIsoWeekday first_weekday) const; + + /** + * Returns the week number in this year, using week data + * + * See the [Rust documentation for `week_of_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_year) for more information. + */ + diplomat::result week_of_year(const ICU4XWeekCalculator& calculator) const; + + /** + * Returns 1-indexed number of the month of this date in its year + * + * Note that for lunar calendars this may not lead to the same month + * having the same ordinal month across years; use month_code if you care + * about month identity. + * + * See the [Rust documentation for `month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month) for more information. + */ + uint32_t ordinal_month() const; + + /** + * Returns the month code for this date. Typically something + * like "M01", "M02", but can be more complicated for lunar calendars. + * + * See the [Rust documentation for `month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month) for more information. + */ + template diplomat::result month_code_to_writeable(W& write) const; + + /** + * Returns the month code for this date. Typically something + * like "M01", "M02", but can be more complicated for lunar calendars. + * + * See the [Rust documentation for `month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month) for more information. + */ + diplomat::result month_code() const; + + /** + * Returns the year number in the current era for this date + * + * See the [Rust documentation for `year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year) for more information. + */ + int32_t year_in_era() const; + + /** + * Returns the era for this date, + * + * See the [Rust documentation for `year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year) for more information. + */ + template diplomat::result era_to_writeable(W& write) const; + + /** + * Returns the era for this date, + * + * See the [Rust documentation for `year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year) for more information. + */ + diplomat::result era() const; + + /** + * Returns the number of months in the year represented by this date + * + * See the [Rust documentation for `months_in_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.months_in_year) for more information. + */ + uint8_t months_in_year() const; + + /** + * Returns the number of days in the month represented by this date + * + * See the [Rust documentation for `days_in_month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_month) for more information. + */ + uint8_t days_in_month() const; + + /** + * Returns the number of days in the year represented by this date + * + * See the [Rust documentation for `days_in_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_year) for more information. + */ + uint32_t days_in_year() const; + + /** + * Returns the [`ICU4XCalendar`] object backing this date + * + * See the [Rust documentation for `calendar`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.calendar) for more information. + */ + ICU4XCalendar calendar() const; + inline const capi::ICU4XDateTime* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XDateTime* AsFFIMut() { return this->inner.get(); } + inline ICU4XDateTime(capi::ICU4XDateTime* i) : inner(i) {} + ICU4XDateTime() = default; + ICU4XDateTime(ICU4XDateTime&&) noexcept = default; + ICU4XDateTime& operator=(ICU4XDateTime&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XCalendar.hpp" +#include "ICU4XDate.hpp" +#include "ICU4XTime.hpp" +#include "ICU4XIsoDateTime.hpp" +#include "ICU4XWeekCalculator.hpp" +#include "ICU4XWeekOf.hpp" + +inline diplomat::result ICU4XDateTime::create_from_iso_in_calendar(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const ICU4XCalendar& calendar) { + auto diplomat_result_raw_out_value = capi::ICU4XDateTime_create_from_iso_in_calendar(year, month, day, hour, minute, second, nanosecond, calendar.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XDateTime(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XDateTime::create_from_codes_in_calendar(const std::string_view era_code, int32_t year, const std::string_view month_code, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond, const ICU4XCalendar& calendar) { + auto diplomat_result_raw_out_value = capi::ICU4XDateTime_create_from_codes_in_calendar(era_code.data(), era_code.size(), year, month_code.data(), month_code.size(), day, hour, minute, second, nanosecond, calendar.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XDateTime(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XDateTime ICU4XDateTime::create_from_date_and_time(const ICU4XDate& date, const ICU4XTime& time) { + return ICU4XDateTime(capi::ICU4XDateTime_create_from_date_and_time(date.AsFFI(), time.AsFFI())); +} +inline ICU4XDate ICU4XDateTime::date() const { + return ICU4XDate(capi::ICU4XDateTime_date(this->inner.get())); +} +inline ICU4XTime ICU4XDateTime::time() const { + return ICU4XTime(capi::ICU4XDateTime_time(this->inner.get())); +} +inline ICU4XIsoDateTime ICU4XDateTime::to_iso() const { + return ICU4XIsoDateTime(capi::ICU4XDateTime_to_iso(this->inner.get())); +} +inline ICU4XDateTime ICU4XDateTime::to_calendar(const ICU4XCalendar& calendar) const { + return ICU4XDateTime(capi::ICU4XDateTime_to_calendar(this->inner.get(), calendar.AsFFI())); +} +inline uint8_t ICU4XDateTime::hour() const { + return capi::ICU4XDateTime_hour(this->inner.get()); +} +inline uint8_t ICU4XDateTime::minute() const { + return capi::ICU4XDateTime_minute(this->inner.get()); +} +inline uint8_t ICU4XDateTime::second() const { + return capi::ICU4XDateTime_second(this->inner.get()); +} +inline uint32_t ICU4XDateTime::nanosecond() const { + return capi::ICU4XDateTime_nanosecond(this->inner.get()); +} +inline uint32_t ICU4XDateTime::day_of_month() const { + return capi::ICU4XDateTime_day_of_month(this->inner.get()); +} +inline ICU4XIsoWeekday ICU4XDateTime::day_of_week() const { + return static_cast(capi::ICU4XDateTime_day_of_week(this->inner.get())); +} +inline uint32_t ICU4XDateTime::week_of_month(ICU4XIsoWeekday first_weekday) const { + return capi::ICU4XDateTime_week_of_month(this->inner.get(), static_cast(first_weekday)); +} +inline diplomat::result ICU4XDateTime::week_of_year(const ICU4XWeekCalculator& calculator) const { + auto diplomat_result_raw_out_value = capi::ICU4XDateTime_week_of_year(this->inner.get(), calculator.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + capi::ICU4XWeekOf diplomat_raw_struct_out_value = diplomat_result_raw_out_value.ok; + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XWeekOf{ .week = std::move(diplomat_raw_struct_out_value.week), .unit = std::move(static_cast(diplomat_raw_struct_out_value.unit)) })); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline uint32_t ICU4XDateTime::ordinal_month() const { + return capi::ICU4XDateTime_ordinal_month(this->inner.get()); +} +template inline diplomat::result ICU4XDateTime::month_code_to_writeable(W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XDateTime_month_code(this->inner.get(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XDateTime::month_code() const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XDateTime_month_code(this->inner.get(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +inline int32_t ICU4XDateTime::year_in_era() const { + return capi::ICU4XDateTime_year_in_era(this->inner.get()); +} +template inline diplomat::result ICU4XDateTime::era_to_writeable(W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XDateTime_era(this->inner.get(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XDateTime::era() const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XDateTime_era(this->inner.get(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +inline uint8_t ICU4XDateTime::months_in_year() const { + return capi::ICU4XDateTime_months_in_year(this->inner.get()); +} +inline uint8_t ICU4XDateTime::days_in_month() const { + return capi::ICU4XDateTime_days_in_month(this->inner.get()); +} +inline uint32_t ICU4XDateTime::days_in_year() const { + return capi::ICU4XDateTime_days_in_year(this->inner.get()); +} +inline ICU4XCalendar ICU4XDateTime::calendar() const { + return ICU4XCalendar(capi::ICU4XDateTime_calendar(this->inner.get())); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDateTimeFormatter.h b/third_party/rust/icu_capi/cpp/include/ICU4XDateTimeFormatter.h new file mode 100644 index 000000000000..5f0af4ddba1e --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDateTimeFormatter.h @@ -0,0 +1,41 @@ +#ifndef ICU4XDateTimeFormatter_H +#define ICU4XDateTimeFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XDateTimeFormatter ICU4XDateTimeFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XDateLength.h" +#include "ICU4XTimeLength.h" +#include "diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError.h" +#include "ICU4XDateTime.h" +#include "diplomat_result_void_ICU4XError.h" +#include "ICU4XIsoDateTime.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError ICU4XDateTimeFormatter_create_with_lengths(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XDateLength date_length, ICU4XTimeLength time_length); + +diplomat_result_void_ICU4XError ICU4XDateTimeFormatter_format_datetime(const ICU4XDateTimeFormatter* self, const ICU4XDateTime* value, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XDateTimeFormatter_format_iso_datetime(const ICU4XDateTimeFormatter* self, const ICU4XIsoDateTime* value, DiplomatWriteable* write); +void ICU4XDateTimeFormatter_destroy(ICU4XDateTimeFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDateTimeFormatter.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XDateTimeFormatter.hpp new file mode 100644 index 000000000000..93224309ff15 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDateTimeFormatter.hpp @@ -0,0 +1,150 @@ +#ifndef ICU4XDateTimeFormatter_HPP +#define ICU4XDateTimeFormatter_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XDateTimeFormatter.h" + +class ICU4XDataProvider; +class ICU4XLocale; +#include "ICU4XDateLength.hpp" +#include "ICU4XTimeLength.hpp" +class ICU4XDateTimeFormatter; +#include "ICU4XError.hpp" +class ICU4XDateTime; +class ICU4XIsoDateTime; + +/** + * A destruction policy for using ICU4XDateTimeFormatter with std::unique_ptr. + */ +struct ICU4XDateTimeFormatterDeleter { + void operator()(capi::ICU4XDateTimeFormatter* l) const noexcept { + capi::ICU4XDateTimeFormatter_destroy(l); + } +}; + +/** + * An ICU4X DateFormatter object capable of formatting a [`ICU4XDateTime`] as a string, + * using some calendar specified at runtime in the locale. + * + * See the [Rust documentation for `DateTimeFormatter`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html) for more information. + */ +class ICU4XDateTimeFormatter { + public: + + /** + * Creates a new [`ICU4XDateTimeFormatter`] from locale data. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new_unstable) for more information. + */ + static diplomat::result create_with_lengths(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XDateLength date_length, ICU4XTimeLength time_length); + + /** + * Formats a [`ICU4XDateTime`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.format) for more information. + */ + template diplomat::result format_datetime_to_writeable(const ICU4XDateTime& value, W& write) const; + + /** + * Formats a [`ICU4XDateTime`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.format) for more information. + */ + diplomat::result format_datetime(const ICU4XDateTime& value) const; + + /** + * Formats a [`ICU4XIsoDateTime`] to a string. + * + * Will convert to this formatter's calendar first + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.format) for more information. + */ + template diplomat::result format_iso_datetime_to_writeable(const ICU4XIsoDateTime& value, W& write) const; + + /** + * Formats a [`ICU4XIsoDateTime`] to a string. + * + * Will convert to this formatter's calendar first + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.format) for more information. + */ + diplomat::result format_iso_datetime(const ICU4XIsoDateTime& value) const; + inline const capi::ICU4XDateTimeFormatter* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XDateTimeFormatter* AsFFIMut() { return this->inner.get(); } + inline ICU4XDateTimeFormatter(capi::ICU4XDateTimeFormatter* i) : inner(i) {} + ICU4XDateTimeFormatter() = default; + ICU4XDateTimeFormatter(ICU4XDateTimeFormatter&&) noexcept = default; + ICU4XDateTimeFormatter& operator=(ICU4XDateTimeFormatter&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" +#include "ICU4XDateTime.hpp" +#include "ICU4XIsoDateTime.hpp" + +inline diplomat::result ICU4XDateTimeFormatter::create_with_lengths(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XDateLength date_length, ICU4XTimeLength time_length) { + auto diplomat_result_raw_out_value = capi::ICU4XDateTimeFormatter_create_with_lengths(provider.AsFFI(), locale.AsFFI(), static_cast(date_length), static_cast(time_length)); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XDateTimeFormatter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +template inline diplomat::result ICU4XDateTimeFormatter::format_datetime_to_writeable(const ICU4XDateTime& value, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XDateTimeFormatter_format_datetime(this->inner.get(), value.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XDateTimeFormatter::format_datetime(const ICU4XDateTime& value) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XDateTimeFormatter_format_datetime(this->inner.get(), value.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +template inline diplomat::result ICU4XDateTimeFormatter::format_iso_datetime_to_writeable(const ICU4XIsoDateTime& value, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XDateTimeFormatter_format_iso_datetime(this->inner.get(), value.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XDateTimeFormatter::format_iso_datetime(const ICU4XIsoDateTime& value) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XDateTimeFormatter_format_iso_datetime(this->inner.get(), value.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDecomposed.h b/third_party/rust/icu_capi/cpp/include/ICU4XDecomposed.h new file mode 100644 index 000000000000..3f287e8192a9 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDecomposed.h @@ -0,0 +1,31 @@ +#ifndef ICU4XDecomposed_H +#define ICU4XDecomposed_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XDecomposed { + char32_t first; + char32_t second; +} ICU4XDecomposed; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XDecomposed_destroy(ICU4XDecomposed* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDecomposed.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XDecomposed.hpp new file mode 100644 index 000000000000..5628ae2be9f7 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDecomposed.hpp @@ -0,0 +1,30 @@ +#ifndef ICU4XDecomposed_HPP +#define ICU4XDecomposed_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XDecomposed.h" + + + +/** + * The outcome of non-recursive canonical decomposition of a character. + * `second` will be NUL when the decomposition expands to a single character + * (which may or may not be the original one) + * + * See the [Rust documentation for `Decomposed`](https://docs.rs/icu/latest/icu/normalizer/properties/enum.Decomposed.html) for more information. + */ +struct ICU4XDecomposed { + public: + char32_t first; + char32_t second; +}; + + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDecomposingNormalizer.h b/third_party/rust/icu_capi/cpp/include/ICU4XDecomposingNormalizer.h new file mode 100644 index 000000000000..f542f7a7302e --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDecomposingNormalizer.h @@ -0,0 +1,38 @@ +#ifndef ICU4XDecomposingNormalizer_H +#define ICU4XDecomposingNormalizer_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XDecomposingNormalizer ICU4XDecomposingNormalizer; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError ICU4XDecomposingNormalizer_create_nfd(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError ICU4XDecomposingNormalizer_create_nfkd(const ICU4XDataProvider* provider); + +diplomat_result_void_ICU4XError ICU4XDecomposingNormalizer_normalize(const ICU4XDecomposingNormalizer* self, const char* s_data, size_t s_len, DiplomatWriteable* write); + +bool ICU4XDecomposingNormalizer_is_normalized(const ICU4XDecomposingNormalizer* self, const char* s_data, size_t s_len); +void ICU4XDecomposingNormalizer_destroy(ICU4XDecomposingNormalizer* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDecomposingNormalizer.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XDecomposingNormalizer.hpp new file mode 100644 index 000000000000..59bdf422b7a1 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDecomposingNormalizer.hpp @@ -0,0 +1,133 @@ +#ifndef ICU4XDecomposingNormalizer_HPP +#define ICU4XDecomposingNormalizer_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XDecomposingNormalizer.h" + +class ICU4XDataProvider; +class ICU4XDecomposingNormalizer; +#include "ICU4XError.hpp" + +/** + * A destruction policy for using ICU4XDecomposingNormalizer with std::unique_ptr. + */ +struct ICU4XDecomposingNormalizerDeleter { + void operator()(capi::ICU4XDecomposingNormalizer* l) const noexcept { + capi::ICU4XDecomposingNormalizer_destroy(l); + } +}; + +/** + * + * + * See the [Rust documentation for `DecomposingNormalizer`](https://docs.rs/icu/latest/icu/normalizer/struct.DecomposingNormalizer.html) for more information. + */ +class ICU4XDecomposingNormalizer { + public: + + /** + * Construct a new ICU4XDecomposingNormalizer instance for NFC + * + * See the [Rust documentation for `try_new_nfd_unstable`](https://docs.rs/icu/latest/icu/normalizer/struct.DecomposingNormalizer.html#method.try_new_nfd_unstable) for more information. + */ + static diplomat::result create_nfd(const ICU4XDataProvider& provider); + + /** + * Construct a new ICU4XDecomposingNormalizer instance for NFKC + * + * See the [Rust documentation for `try_new_nfkd_unstable`](https://docs.rs/icu/latest/icu/normalizer/struct.DecomposingNormalizer.html#method.try_new_nfkd_unstable) for more information. + */ + static diplomat::result create_nfkd(const ICU4XDataProvider& provider); + + /** + * Normalize a (potentially ill-formed) UTF8 string + * + * Errors are mapped to REPLACEMENT CHARACTER + * + * See the [Rust documentation for `normalize_utf8`](https://docs.rs/icu/latest/icu/normalizer/struct.DecomposingNormalizer.html#method.normalize_utf8) for more information. + */ + template diplomat::result normalize_to_writeable(const std::string_view s, W& write) const; + + /** + * Normalize a (potentially ill-formed) UTF8 string + * + * Errors are mapped to REPLACEMENT CHARACTER + * + * See the [Rust documentation for `normalize_utf8`](https://docs.rs/icu/latest/icu/normalizer/struct.DecomposingNormalizer.html#method.normalize_utf8) for more information. + */ + diplomat::result normalize(const std::string_view s) const; + + /** + * Check if a (potentially ill-formed) UTF8 string is normalized + * + * Errors are mapped to REPLACEMENT CHARACTER + * + * See the [Rust documentation for `is_normalized_utf8`](https://docs.rs/icu/latest/icu/normalizer/struct.DecomposingNormalizer.html#method.is_normalized_utf8) for more information. + */ + bool is_normalized(const std::string_view s) const; + inline const capi::ICU4XDecomposingNormalizer* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XDecomposingNormalizer* AsFFIMut() { return this->inner.get(); } + inline ICU4XDecomposingNormalizer(capi::ICU4XDecomposingNormalizer* i) : inner(i) {} + ICU4XDecomposingNormalizer() = default; + ICU4XDecomposingNormalizer(ICU4XDecomposingNormalizer&&) noexcept = default; + ICU4XDecomposingNormalizer& operator=(ICU4XDecomposingNormalizer&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" + +inline diplomat::result ICU4XDecomposingNormalizer::create_nfd(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XDecomposingNormalizer_create_nfd(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XDecomposingNormalizer(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XDecomposingNormalizer::create_nfkd(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XDecomposingNormalizer_create_nfkd(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XDecomposingNormalizer(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +template inline diplomat::result ICU4XDecomposingNormalizer::normalize_to_writeable(const std::string_view s, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XDecomposingNormalizer_normalize(this->inner.get(), s.data(), s.size(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XDecomposingNormalizer::normalize(const std::string_view s) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XDecomposingNormalizer_normalize(this->inner.get(), s.data(), s.size(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +inline bool ICU4XDecomposingNormalizer::is_normalized(const std::string_view s) const { + return capi::ICU4XDecomposingNormalizer_is_normalized(this->inner.get(), s.data(), s.size()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesFallback.h b/third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesFallback.h new file mode 100644 index 000000000000..085fc8de5dde --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesFallback.h @@ -0,0 +1,31 @@ +#ifndef ICU4XDisplayNamesFallback_H +#define ICU4XDisplayNamesFallback_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XDisplayNamesFallback { + ICU4XDisplayNamesFallback_Code = 0, + ICU4XDisplayNamesFallback_None = 1, +} ICU4XDisplayNamesFallback; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XDisplayNamesFallback_destroy(ICU4XDisplayNamesFallback* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesFallback.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesFallback.hpp new file mode 100644 index 000000000000..f328622befbd --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesFallback.hpp @@ -0,0 +1,26 @@ +#ifndef ICU4XDisplayNamesFallback_HPP +#define ICU4XDisplayNamesFallback_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XDisplayNamesFallback.h" + + + +/** + * + * + * See the [Rust documentation for `Fallback`](https://docs.rs/icu/latest/icu/displaynames/options/enum.Fallback.html) for more information. + */ +enum struct ICU4XDisplayNamesFallback { + Code = 0, + None = 1, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesOptionsV1.h b/third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesOptionsV1.h new file mode 100644 index 000000000000..e998cde0e779 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesOptionsV1.h @@ -0,0 +1,38 @@ +#ifndef ICU4XDisplayNamesOptionsV1_H +#define ICU4XDisplayNamesOptionsV1_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XDisplayNamesStyle.h" +#include "ICU4XDisplayNamesFallback.h" +#include "ICU4XLanguageDisplay.h" +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XDisplayNamesOptionsV1 { + ICU4XDisplayNamesStyle style; + ICU4XDisplayNamesFallback fallback; + ICU4XLanguageDisplay language_display; +} ICU4XDisplayNamesOptionsV1; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDisplayNamesStyle.h" +#include "ICU4XDisplayNamesFallback.h" +#include "ICU4XLanguageDisplay.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XDisplayNamesOptionsV1_destroy(ICU4XDisplayNamesOptionsV1* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesOptionsV1.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesOptionsV1.hpp new file mode 100644 index 000000000000..9a49f2eef1fe --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesOptionsV1.hpp @@ -0,0 +1,45 @@ +#ifndef ICU4XDisplayNamesOptionsV1_HPP +#define ICU4XDisplayNamesOptionsV1_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XDisplayNamesOptionsV1.h" + +#include "ICU4XDisplayNamesStyle.hpp" +#include "ICU4XDisplayNamesFallback.hpp" +#include "ICU4XLanguageDisplay.hpp" + + +/** + * + * + * See the [Rust documentation for `DisplayNamesOptions`](https://docs.rs/icu/latest/icu/displaynames/options/struct.DisplayNamesOptions.html) for more information. + */ +struct ICU4XDisplayNamesOptionsV1 { + public: + + /** + * The optional formatting style to use for display name. + */ + ICU4XDisplayNamesStyle style; + + /** + * The fallback return when the system does not have the + * requested display name, defaults to "code". + */ + ICU4XDisplayNamesFallback fallback; + + /** + * The language display kind, defaults to "dialect". + */ + ICU4XLanguageDisplay language_display; +}; + + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesStyle.h b/third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesStyle.h new file mode 100644 index 000000000000..048da455daf4 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesStyle.h @@ -0,0 +1,34 @@ +#ifndef ICU4XDisplayNamesStyle_H +#define ICU4XDisplayNamesStyle_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XDisplayNamesStyle { + ICU4XDisplayNamesStyle_Auto = 0, + ICU4XDisplayNamesStyle_Narrow = 1, + ICU4XDisplayNamesStyle_Short = 2, + ICU4XDisplayNamesStyle_Long = 3, + ICU4XDisplayNamesStyle_Menu = 4, +} ICU4XDisplayNamesStyle; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XDisplayNamesStyle_destroy(ICU4XDisplayNamesStyle* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesStyle.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesStyle.hpp new file mode 100644 index 000000000000..8cc64081bdf5 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XDisplayNamesStyle.hpp @@ -0,0 +1,29 @@ +#ifndef ICU4XDisplayNamesStyle_HPP +#define ICU4XDisplayNamesStyle_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XDisplayNamesStyle.h" + + + +/** + * + * + * See the [Rust documentation for `Style`](https://docs.rs/icu/latest/icu/displaynames/options/enum.Style.html) for more information. + */ +enum struct ICU4XDisplayNamesStyle { + Auto = 0, + Narrow = 1, + Short = 2, + Long = 3, + Menu = 4, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XError.h b/third_party/rust/icu_capi/cpp/include/ICU4XError.h new file mode 100644 index 000000000000..65e1c04a25c2 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XError.h @@ -0,0 +1,83 @@ +#ifndef ICU4XError_H +#define ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XError { + ICU4XError_UnknownError = 0, + ICU4XError_WriteableError = 1, + ICU4XError_OutOfBoundsError = 2, + ICU4XError_DataMissingDataKeyError = 256, + ICU4XError_DataMissingVariantError = 257, + ICU4XError_DataMissingLocaleError = 258, + ICU4XError_DataNeedsVariantError = 259, + ICU4XError_DataNeedsLocaleError = 260, + ICU4XError_DataExtraneousLocaleError = 261, + ICU4XError_DataFilteredResourceError = 262, + ICU4XError_DataMismatchedTypeError = 263, + ICU4XError_DataMissingPayloadError = 264, + ICU4XError_DataInvalidStateError = 265, + ICU4XError_DataCustomError = 266, + ICU4XError_DataIoError = 267, + ICU4XError_DataUnavailableBufferFormatError = 268, + ICU4XError_DataMismatchedAnyBufferError = 269, + ICU4XError_LocaleUndefinedSubtagError = 512, + ICU4XError_LocaleParserLanguageError = 513, + ICU4XError_LocaleParserSubtagError = 514, + ICU4XError_LocaleParserExtensionError = 515, + ICU4XError_DataStructValidityError = 768, + ICU4XError_PropertyUnknownScriptIdError = 1024, + ICU4XError_PropertyUnknownGeneralCategoryGroupError = 1025, + ICU4XError_PropertyUnexpectedPropertyNameError = 1026, + ICU4XError_FixedDecimalLimitError = 1280, + ICU4XError_FixedDecimalSyntaxError = 1281, + ICU4XError_PluralsParserError = 1536, + ICU4XError_CalendarParseError = 1792, + ICU4XError_CalendarOverflowError = 1793, + ICU4XError_CalendarUnderflowError = 1794, + ICU4XError_CalendarOutOfRangeError = 1795, + ICU4XError_CalendarUnknownEraError = 1796, + ICU4XError_CalendarUnknownMonthCodeError = 1797, + ICU4XError_CalendarMissingInputError = 1798, + ICU4XError_CalendarUnknownKindError = 1799, + ICU4XError_CalendarMissingError = 1800, + ICU4XError_DateTimePatternError = 2048, + ICU4XError_DateTimeMissingInputFieldError = 2049, + ICU4XError_DateTimeSkeletonError = 2050, + ICU4XError_DateTimeUnsupportedFieldError = 2051, + ICU4XError_DateTimeUnsupportedOptionsError = 2052, + ICU4XError_DateTimeMissingWeekdaySymbolError = 2053, + ICU4XError_DateTimeMissingMonthSymbolError = 2054, + ICU4XError_DateTimeFixedDecimalError = 2055, + ICU4XError_DateTimeMismatchedCalendarError = 2056, + ICU4XError_TinyStrTooLargeError = 2304, + ICU4XError_TinyStrContainsNullError = 2305, + ICU4XError_TinyStrNonAsciiError = 2306, + ICU4XError_TimeZoneOffsetOutOfBoundsError = 2560, + ICU4XError_TimeZoneInvalidOffsetError = 2561, + ICU4XError_TimeZoneMissingInputError = 2562, + ICU4XError_NormalizerFutureExtensionError = 2816, + ICU4XError_NormalizerValidationError = 2817, +} ICU4XError; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XError_destroy(ICU4XError* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XError.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XError.hpp new file mode 100644 index 000000000000..74f4ac9b9571 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XError.hpp @@ -0,0 +1,103 @@ +#ifndef ICU4XError_HPP +#define ICU4XError_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XError.h" + + + +/** + * A common enum for errors that ICU4X may return, organized by API + * + * The error names are stable and can be checked against as strings in the JS API + * + * Additional information: [1](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.Error.html), [2](https://docs.rs/icu/latest/icu/calendar/enum.CalendarError.html), [3](https://docs.rs/icu/latest/icu/collator/enum.CollatorError.html), [4](https://docs.rs/icu/latest/icu/datetime/enum.DateTimeError.html), [5](https://docs.rs/icu/latest/icu/decimal/enum.DecimalError.html), [6](https://docs.rs/icu/latest/icu/list/enum.ListError.html), [7](https://docs.rs/icu/latest/icu/locid/enum.ParserError.html), [8](https://docs.rs/icu/latest/icu/locid_transform/enum.LocaleTransformError.html), [9](https://docs.rs/icu/latest/icu/normalizer/enum.NormalizerError.html), [10](https://docs.rs/icu/latest/icu/plurals/enum.PluralsError.html), [11](https://docs.rs/icu/latest/icu/properties/enum.PropertiesError.html), [12](https://docs.rs/icu/latest/icu/provider/struct.DataError.html), [13](https://docs.rs/icu/latest/icu/provider/enum.DataErrorKind.html), [14](https://docs.rs/icu/latest/icu/segmenter/enum.SegmenterError.html), [15](https://docs.rs/icu/latest/icu/timezone/enum.TimeZoneError.html) + */ +enum struct ICU4XError { + + /** + * The error is not currently categorized as ICU4XError. + * Please file a bug + */ + UnknownError = 0, + + /** + * An error arising from writing to a string + * Typically found when not enough space is allocated + * Most APIs that return a string may return this error + */ + WriteableError = 1, + OutOfBoundsError = 2, + DataMissingDataKeyError = 256, + DataMissingVariantError = 257, + DataMissingLocaleError = 258, + DataNeedsVariantError = 259, + DataNeedsLocaleError = 260, + DataExtraneousLocaleError = 261, + DataFilteredResourceError = 262, + DataMismatchedTypeError = 263, + DataMissingPayloadError = 264, + DataInvalidStateError = 265, + DataCustomError = 266, + DataIoError = 267, + DataUnavailableBufferFormatError = 268, + DataMismatchedAnyBufferError = 269, + + /** + * The subtag being requested was not set + */ + LocaleUndefinedSubtagError = 512, + + /** + * The locale or subtag string failed to parse + */ + LocaleParserLanguageError = 513, + LocaleParserSubtagError = 514, + LocaleParserExtensionError = 515, + + /** + * Attempted to construct an invalid data struct + */ + DataStructValidityError = 768, + PropertyUnknownScriptIdError = 1024, + PropertyUnknownGeneralCategoryGroupError = 1025, + PropertyUnexpectedPropertyNameError = 1026, + FixedDecimalLimitError = 1280, + FixedDecimalSyntaxError = 1281, + PluralsParserError = 1536, + CalendarParseError = 1792, + CalendarOverflowError = 1793, + CalendarUnderflowError = 1794, + CalendarOutOfRangeError = 1795, + CalendarUnknownEraError = 1796, + CalendarUnknownMonthCodeError = 1797, + CalendarMissingInputError = 1798, + CalendarUnknownKindError = 1799, + CalendarMissingError = 1800, + DateTimePatternError = 2048, + DateTimeMissingInputFieldError = 2049, + DateTimeSkeletonError = 2050, + DateTimeUnsupportedFieldError = 2051, + DateTimeUnsupportedOptionsError = 2052, + DateTimeMissingWeekdaySymbolError = 2053, + DateTimeMissingMonthSymbolError = 2054, + DateTimeFixedDecimalError = 2055, + DateTimeMismatchedCalendarError = 2056, + TinyStrTooLargeError = 2304, + TinyStrContainsNullError = 2305, + TinyStrNonAsciiError = 2306, + TimeZoneOffsetOutOfBoundsError = 2560, + TimeZoneInvalidOffsetError = 2561, + TimeZoneMissingInputError = 2562, + NormalizerFutureExtensionError = 2816, + NormalizerValidationError = 2817, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimal.h b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimal.h new file mode 100644 index 000000000000..361294b68748 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimal.h @@ -0,0 +1,101 @@ +#ifndef ICU4XFixedDecimal_H +#define ICU4XFixedDecimal_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XFixedDecimal ICU4XFixedDecimal; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_box_ICU4XFixedDecimal_ICU4XError.h" +#include "ICU4XFixedDecimalSign.h" +#include "ICU4XFixedDecimalSignDisplay.h" +#include "diplomat_result_void_void.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +ICU4XFixedDecimal* ICU4XFixedDecimal_create_from_i32(int32_t v); + +ICU4XFixedDecimal* ICU4XFixedDecimal_create_from_u32(uint32_t v); + +ICU4XFixedDecimal* ICU4XFixedDecimal_create_from_i64(int64_t v); + +ICU4XFixedDecimal* ICU4XFixedDecimal_create_from_u64(uint64_t v); + +diplomat_result_box_ICU4XFixedDecimal_ICU4XError ICU4XFixedDecimal_create_from_f64_with_integer_precision(double f); + +diplomat_result_box_ICU4XFixedDecimal_ICU4XError ICU4XFixedDecimal_create_from_f64_with_lower_magnitude(double f, int16_t magnitude); + +diplomat_result_box_ICU4XFixedDecimal_ICU4XError ICU4XFixedDecimal_create_from_f64_with_significant_digits(double f, uint8_t digits); + +diplomat_result_box_ICU4XFixedDecimal_ICU4XError ICU4XFixedDecimal_create_from_f64_with_floating_precision(double f); + +diplomat_result_box_ICU4XFixedDecimal_ICU4XError ICU4XFixedDecimal_create_from_string(const char* v_data, size_t v_len); + +uint8_t ICU4XFixedDecimal_digit_at(const ICU4XFixedDecimal* self, int16_t magnitude); + +int16_t ICU4XFixedDecimal_magnitude_start(const ICU4XFixedDecimal* self); + +int16_t ICU4XFixedDecimal_magnitude_end(const ICU4XFixedDecimal* self); + +int16_t ICU4XFixedDecimal_nonzero_magnitude_start(const ICU4XFixedDecimal* self); + +int16_t ICU4XFixedDecimal_nonzero_magnitude_end(const ICU4XFixedDecimal* self); + +bool ICU4XFixedDecimal_is_zero(const ICU4XFixedDecimal* self); + +void ICU4XFixedDecimal_multiply_pow10(ICU4XFixedDecimal* self, int16_t power); + +ICU4XFixedDecimalSign ICU4XFixedDecimal_sign(const ICU4XFixedDecimal* self); + +void ICU4XFixedDecimal_set_sign(ICU4XFixedDecimal* self, ICU4XFixedDecimalSign sign); + +void ICU4XFixedDecimal_apply_sign_display(ICU4XFixedDecimal* self, ICU4XFixedDecimalSignDisplay sign_display); + +void ICU4XFixedDecimal_trim_start(ICU4XFixedDecimal* self); + +void ICU4XFixedDecimal_trim_end(ICU4XFixedDecimal* self); + +void ICU4XFixedDecimal_pad_start(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_pad_end(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_set_max_position(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_trunc(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_half_trunc(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_expand(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_half_expand(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_ceil(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_half_ceil(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_floor(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_half_floor(ICU4XFixedDecimal* self, int16_t position); + +void ICU4XFixedDecimal_half_even(ICU4XFixedDecimal* self, int16_t position); + +diplomat_result_void_void ICU4XFixedDecimal_concatenate_end(ICU4XFixedDecimal* self, ICU4XFixedDecimal* other); + +void ICU4XFixedDecimal_to_string(const ICU4XFixedDecimal* self, DiplomatWriteable* to); +void ICU4XFixedDecimal_destroy(ICU4XFixedDecimal* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimal.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimal.hpp new file mode 100644 index 000000000000..b9d1a041d6b7 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimal.hpp @@ -0,0 +1,466 @@ +#ifndef ICU4XFixedDecimal_HPP +#define ICU4XFixedDecimal_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XFixedDecimal.h" + +class ICU4XFixedDecimal; +#include "ICU4XError.hpp" +#include "ICU4XFixedDecimalSign.hpp" +#include "ICU4XFixedDecimalSignDisplay.hpp" + +/** + * A destruction policy for using ICU4XFixedDecimal with std::unique_ptr. + */ +struct ICU4XFixedDecimalDeleter { + void operator()(capi::ICU4XFixedDecimal* l) const noexcept { + capi::ICU4XFixedDecimal_destroy(l); + } +}; + +/** + * + * + * See the [Rust documentation for `FixedDecimal`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html) for more information. + */ +class ICU4XFixedDecimal { + public: + + /** + * Construct an [`ICU4XFixedDecimal`] from an integer. + * + * See the [Rust documentation for `FixedDecimal`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html) for more information. + */ + static ICU4XFixedDecimal create_from_i32(int32_t v); + + /** + * Construct an [`ICU4XFixedDecimal`] from an integer. + * + * See the [Rust documentation for `FixedDecimal`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html) for more information. + */ + static ICU4XFixedDecimal create_from_u32(uint32_t v); + + /** + * Construct an [`ICU4XFixedDecimal`] from an integer. + * + * See the [Rust documentation for `FixedDecimal`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html) for more information. + */ + static ICU4XFixedDecimal create_from_i64(int64_t v); + + /** + * Construct an [`ICU4XFixedDecimal`] from an integer. + * + * See the [Rust documentation for `FixedDecimal`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html) for more information. + */ + static ICU4XFixedDecimal create_from_u64(uint64_t v); + + /** + * Construct an [`ICU4XFixedDecimal`] from an integer-valued float + * + * See the [Rust documentation for `try_from_f64`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.try_from_f64) for more information. + * + * See the [Rust documentation for `DoublePrecision`](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.DoublePrecision.html) for more information. + */ + static diplomat::result create_from_f64_with_integer_precision(double f); + + /** + * Construct an [`ICU4XFixedDecimal`] from an float, with a given power of 10 for the lower magnitude + * + * See the [Rust documentation for `try_from_f64`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.try_from_f64) for more information. + * + * See the [Rust documentation for `DoublePrecision`](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.DoublePrecision.html) for more information. + */ + static diplomat::result create_from_f64_with_lower_magnitude(double f, int16_t magnitude); + + /** + * Construct an [`ICU4XFixedDecimal`] from an float, for a given number of significant digits + * + * See the [Rust documentation for `try_from_f64`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.try_from_f64) for more information. + * + * See the [Rust documentation for `DoublePrecision`](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.DoublePrecision.html) for more information. + */ + static diplomat::result create_from_f64_with_significant_digits(double f, uint8_t digits); + + /** + * Construct an [`ICU4XFixedDecimal`] from an float, with enough digits to recover + * the original floating point in IEEE 754 without needing trailing zeros + * + * See the [Rust documentation for `try_from_f64`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.try_from_f64) for more information. + * + * See the [Rust documentation for `DoublePrecision`](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.DoublePrecision.html) for more information. + */ + static diplomat::result create_from_f64_with_floating_precision(double f); + + /** + * Construct an [`ICU4XFixedDecimal`] from a string. + * + * See the [Rust documentation for `from_str`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.from_str) for more information. + */ + static diplomat::result create_from_string(const std::string_view v); + + /** + * + * + * See the [Rust documentation for `digit_at`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.digit_at) for more information. + */ + uint8_t digit_at(int16_t magnitude) const; + + /** + * + * + * See the [Rust documentation for `magnitude_range`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.magnitude_range) for more information. + */ + int16_t magnitude_start() const; + + /** + * + * + * See the [Rust documentation for `magnitude_range`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.magnitude_range) for more information. + */ + int16_t magnitude_end() const; + + /** + * + * + * 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. + */ + int16_t nonzero_magnitude_start() const; + + /** + * + * + * 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. + */ + int16_t nonzero_magnitude_end() const; + + /** + * + * + * 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 is_zero() const; + + /** + * Multiply the [`ICU4XFixedDecimal`] by a given power of ten. + * + * See the [Rust documentation for `multiply_pow10`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.multiply_pow10) for more information. + */ + void multiply_pow10(int16_t power); + + /** + * + * + * See the [Rust documentation for `sign`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.sign) for more information. + */ + ICU4XFixedDecimalSign sign() const; + + /** + * Set the sign of the [`ICU4XFixedDecimal`]. + * + * See the [Rust documentation for `set_sign`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.set_sign) for more information. + */ + void set_sign(ICU4XFixedDecimalSign sign); + + /** + * + * + * 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 apply_sign_display(ICU4XFixedDecimalSignDisplay sign_display); + + /** + * + * + * 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 trim_start(); + + /** + * + * + * 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 trim_end(); + + /** + * Zero-pad the [`ICU4XFixedDecimal`] 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 pad_start(int16_t position); + + /** + * Zero-pad the [`ICU4XFixedDecimal`] 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 pad_end(int16_t position); + + /** + * Truncate the [`ICU4XFixedDecimal`] on the left to a particular position, deleting digits if necessary. This is useful for, e.g. abbreviating years + * ("2022" -> "22") + * + * See the [Rust documentation for `set_max_position`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.set_max_position) for more information. + */ + void set_max_position(int16_t 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(int16_t position); + + /** + * + * + * 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 half_trunc(int16_t position); + + /** + * + * + * See the [Rust documentation for `expand`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.expand) for more information. + */ + void expand(int16_t position); + + /** + * + * + * 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 half_expand(int16_t position); + + /** + * + * + * See the [Rust documentation for `ceil`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.ceil) for more information. + */ + void ceil(int16_t position); + + /** + * + * + * 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 half_ceil(int16_t position); + + /** + * + * + * See the [Rust documentation for `floor`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.floor) for more information. + */ + void floor(int16_t position); + + /** + * + * + * 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 half_floor(int16_t position); + + /** + * + * + * 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 half_even(int16_t position); + + /** + * Concatenates `other` to the end of `self`. + * + * If successful, `other` will be set to 0 and a successful status is returned. + * + * If not successful, `other` will be unchanged and an error is returned. + * + * See the [Rust documentation for `concatenate_end`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.concatenate_end) for more information. + */ + diplomat::result concatenate_end(ICU4XFixedDecimal& other); + + /** + * Format the [`ICU4XFixedDecimal`] as a string. + * + * See the [Rust documentation for `write_to`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.write_to) for more information. + */ + template void to_string_to_writeable(W& to) const; + + /** + * Format the [`ICU4XFixedDecimal`] as a string. + * + * See the [Rust documentation for `write_to`](https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.write_to) for more information. + */ + std::string to_string() const; + inline const capi::ICU4XFixedDecimal* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XFixedDecimal* AsFFIMut() { return this->inner.get(); } + inline ICU4XFixedDecimal(capi::ICU4XFixedDecimal* i) : inner(i) {} + ICU4XFixedDecimal() = default; + ICU4XFixedDecimal(ICU4XFixedDecimal&&) noexcept = default; + ICU4XFixedDecimal& operator=(ICU4XFixedDecimal&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline ICU4XFixedDecimal ICU4XFixedDecimal::create_from_i32(int32_t v) { + return ICU4XFixedDecimal(capi::ICU4XFixedDecimal_create_from_i32(v)); +} +inline ICU4XFixedDecimal ICU4XFixedDecimal::create_from_u32(uint32_t v) { + return ICU4XFixedDecimal(capi::ICU4XFixedDecimal_create_from_u32(v)); +} +inline ICU4XFixedDecimal ICU4XFixedDecimal::create_from_i64(int64_t v) { + return ICU4XFixedDecimal(capi::ICU4XFixedDecimal_create_from_i64(v)); +} +inline ICU4XFixedDecimal ICU4XFixedDecimal::create_from_u64(uint64_t v) { + return ICU4XFixedDecimal(capi::ICU4XFixedDecimal_create_from_u64(v)); +} +inline diplomat::result ICU4XFixedDecimal::create_from_f64_with_integer_precision(double f) { + auto diplomat_result_raw_out_value = capi::ICU4XFixedDecimal_create_from_f64_with_integer_precision(f); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XFixedDecimal(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XFixedDecimal::create_from_f64_with_lower_magnitude(double f, int16_t magnitude) { + auto diplomat_result_raw_out_value = capi::ICU4XFixedDecimal_create_from_f64_with_lower_magnitude(f, magnitude); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XFixedDecimal(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XFixedDecimal::create_from_f64_with_significant_digits(double f, uint8_t digits) { + auto diplomat_result_raw_out_value = capi::ICU4XFixedDecimal_create_from_f64_with_significant_digits(f, digits); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XFixedDecimal(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XFixedDecimal::create_from_f64_with_floating_precision(double f) { + auto diplomat_result_raw_out_value = capi::ICU4XFixedDecimal_create_from_f64_with_floating_precision(f); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XFixedDecimal(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XFixedDecimal::create_from_string(const std::string_view v) { + auto diplomat_result_raw_out_value = capi::ICU4XFixedDecimal_create_from_string(v.data(), v.size()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XFixedDecimal(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline uint8_t ICU4XFixedDecimal::digit_at(int16_t magnitude) const { + return capi::ICU4XFixedDecimal_digit_at(this->inner.get(), magnitude); +} +inline int16_t ICU4XFixedDecimal::magnitude_start() const { + return capi::ICU4XFixedDecimal_magnitude_start(this->inner.get()); +} +inline int16_t ICU4XFixedDecimal::magnitude_end() const { + return capi::ICU4XFixedDecimal_magnitude_end(this->inner.get()); +} +inline int16_t ICU4XFixedDecimal::nonzero_magnitude_start() const { + return capi::ICU4XFixedDecimal_nonzero_magnitude_start(this->inner.get()); +} +inline int16_t ICU4XFixedDecimal::nonzero_magnitude_end() const { + return capi::ICU4XFixedDecimal_nonzero_magnitude_end(this->inner.get()); +} +inline bool ICU4XFixedDecimal::is_zero() const { + return capi::ICU4XFixedDecimal_is_zero(this->inner.get()); +} +inline void ICU4XFixedDecimal::multiply_pow10(int16_t power) { + capi::ICU4XFixedDecimal_multiply_pow10(this->inner.get(), power); +} +inline ICU4XFixedDecimalSign ICU4XFixedDecimal::sign() const { + return static_cast(capi::ICU4XFixedDecimal_sign(this->inner.get())); +} +inline void ICU4XFixedDecimal::set_sign(ICU4XFixedDecimalSign sign) { + capi::ICU4XFixedDecimal_set_sign(this->inner.get(), static_cast(sign)); +} +inline void ICU4XFixedDecimal::apply_sign_display(ICU4XFixedDecimalSignDisplay sign_display) { + capi::ICU4XFixedDecimal_apply_sign_display(this->inner.get(), static_cast(sign_display)); +} +inline void ICU4XFixedDecimal::trim_start() { + capi::ICU4XFixedDecimal_trim_start(this->inner.get()); +} +inline void ICU4XFixedDecimal::trim_end() { + capi::ICU4XFixedDecimal_trim_end(this->inner.get()); +} +inline void ICU4XFixedDecimal::pad_start(int16_t position) { + capi::ICU4XFixedDecimal_pad_start(this->inner.get(), position); +} +inline void ICU4XFixedDecimal::pad_end(int16_t position) { + capi::ICU4XFixedDecimal_pad_end(this->inner.get(), position); +} +inline void ICU4XFixedDecimal::set_max_position(int16_t position) { + capi::ICU4XFixedDecimal_set_max_position(this->inner.get(), position); +} +inline void ICU4XFixedDecimal::trunc(int16_t position) { + capi::ICU4XFixedDecimal_trunc(this->inner.get(), position); +} +inline void ICU4XFixedDecimal::half_trunc(int16_t position) { + capi::ICU4XFixedDecimal_half_trunc(this->inner.get(), position); +} +inline void ICU4XFixedDecimal::expand(int16_t position) { + capi::ICU4XFixedDecimal_expand(this->inner.get(), position); +} +inline void ICU4XFixedDecimal::half_expand(int16_t position) { + capi::ICU4XFixedDecimal_half_expand(this->inner.get(), position); +} +inline void ICU4XFixedDecimal::ceil(int16_t position) { + capi::ICU4XFixedDecimal_ceil(this->inner.get(), position); +} +inline void ICU4XFixedDecimal::half_ceil(int16_t position) { + capi::ICU4XFixedDecimal_half_ceil(this->inner.get(), position); +} +inline void ICU4XFixedDecimal::floor(int16_t position) { + capi::ICU4XFixedDecimal_floor(this->inner.get(), position); +} +inline void ICU4XFixedDecimal::half_floor(int16_t position) { + capi::ICU4XFixedDecimal_half_floor(this->inner.get(), position); +} +inline void ICU4XFixedDecimal::half_even(int16_t position) { + capi::ICU4XFixedDecimal_half_even(this->inner.get(), position); +} +inline diplomat::result ICU4XFixedDecimal::concatenate_end(ICU4XFixedDecimal& other) { + auto diplomat_result_raw_out_value = capi::ICU4XFixedDecimal_concatenate_end(this->inner.get(), other.AsFFIMut()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::monostate()); + } + return diplomat_result_out_value; +} +template inline void ICU4XFixedDecimal::to_string_to_writeable(W& to) const { + capi::DiplomatWriteable to_writer = diplomat::WriteableTrait::Construct(to); + capi::ICU4XFixedDecimal_to_string(this->inner.get(), &to_writer); +} +inline std::string ICU4XFixedDecimal::to_string() const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + capi::ICU4XFixedDecimal_to_string(this->inner.get(), &diplomat_writeable_out); + return diplomat_writeable_string; +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalFormatter.h b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalFormatter.h new file mode 100644 index 000000000000..aa1cfd6a48c5 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalFormatter.h @@ -0,0 +1,40 @@ +#ifndef ICU4XFixedDecimalFormatter_H +#define ICU4XFixedDecimalFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XFixedDecimalFormatter ICU4XFixedDecimalFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XFixedDecimalGroupingStrategy.h" +#include "diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError.h" +#include "ICU4XDataStruct.h" +#include "ICU4XFixedDecimal.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError ICU4XFixedDecimalFormatter_create_with_grouping_strategy(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XFixedDecimalGroupingStrategy grouping_strategy); + +diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError ICU4XFixedDecimalFormatter_create_with_decimal_symbols_v1(const ICU4XDataStruct* data_struct, ICU4XFixedDecimalGroupingStrategy grouping_strategy); + +diplomat_result_void_ICU4XError ICU4XFixedDecimalFormatter_format(const ICU4XFixedDecimalFormatter* self, const ICU4XFixedDecimal* value, DiplomatWriteable* write); +void ICU4XFixedDecimalFormatter_destroy(ICU4XFixedDecimalFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalFormatter.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalFormatter.hpp new file mode 100644 index 000000000000..1b011cd9b773 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalFormatter.hpp @@ -0,0 +1,126 @@ +#ifndef ICU4XFixedDecimalFormatter_HPP +#define ICU4XFixedDecimalFormatter_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XFixedDecimalFormatter.h" + +class ICU4XDataProvider; +class ICU4XLocale; +#include "ICU4XFixedDecimalGroupingStrategy.hpp" +class ICU4XFixedDecimalFormatter; +#include "ICU4XError.hpp" +class ICU4XDataStruct; +class ICU4XFixedDecimal; + +/** + * A destruction policy for using ICU4XFixedDecimalFormatter with std::unique_ptr. + */ +struct ICU4XFixedDecimalFormatterDeleter { + void operator()(capi::ICU4XFixedDecimalFormatter* l) const noexcept { + capi::ICU4XFixedDecimalFormatter_destroy(l); + } +}; + +/** + * An ICU4X Fixed Decimal Format object, capable of formatting a [`ICU4XFixedDecimal`] as a string. + * + * See the [Rust documentation for `FixedDecimalFormatter`](https://docs.rs/icu/latest/icu/decimal/struct.FixedDecimalFormatter.html) for more information. + */ +class ICU4XFixedDecimalFormatter { + public: + + /** + * Creates a new [`ICU4XFixedDecimalFormatter`] from locale data. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/decimal/struct.FixedDecimalFormatter.html#method.try_new_unstable) for more information. + */ + static diplomat::result create_with_grouping_strategy(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XFixedDecimalGroupingStrategy grouping_strategy); + + /** + * Creates a new [`ICU4XFixedDecimalFormatter`] from preconstructed locale data in the form of an [`ICU4XDataStruct`] + * constructed from `ICU4XDataStruct::create_decimal_symbols()`. + * + * The contents of the data struct will be consumed: if you wish to use the struct again it will have to be reconstructed. + * Passing a consumed struct to this method will return an error. + */ + static diplomat::result create_with_decimal_symbols_v1(const ICU4XDataStruct& data_struct, ICU4XFixedDecimalGroupingStrategy grouping_strategy); + + /** + * Formats a [`ICU4XFixedDecimal`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/decimal/struct.FixedDecimalFormatter.html#method.format) for more information. + */ + template diplomat::result format_to_writeable(const ICU4XFixedDecimal& value, W& write) const; + + /** + * Formats a [`ICU4XFixedDecimal`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/decimal/struct.FixedDecimalFormatter.html#method.format) for more information. + */ + diplomat::result format(const ICU4XFixedDecimal& value) const; + inline const capi::ICU4XFixedDecimalFormatter* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XFixedDecimalFormatter* AsFFIMut() { return this->inner.get(); } + inline ICU4XFixedDecimalFormatter(capi::ICU4XFixedDecimalFormatter* i) : inner(i) {} + ICU4XFixedDecimalFormatter() = default; + ICU4XFixedDecimalFormatter(ICU4XFixedDecimalFormatter&&) noexcept = default; + ICU4XFixedDecimalFormatter& operator=(ICU4XFixedDecimalFormatter&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" +#include "ICU4XDataStruct.hpp" +#include "ICU4XFixedDecimal.hpp" + +inline diplomat::result ICU4XFixedDecimalFormatter::create_with_grouping_strategy(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XFixedDecimalGroupingStrategy grouping_strategy) { + auto diplomat_result_raw_out_value = capi::ICU4XFixedDecimalFormatter_create_with_grouping_strategy(provider.AsFFI(), locale.AsFFI(), static_cast(grouping_strategy)); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XFixedDecimalFormatter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XFixedDecimalFormatter::create_with_decimal_symbols_v1(const ICU4XDataStruct& data_struct, ICU4XFixedDecimalGroupingStrategy grouping_strategy) { + auto diplomat_result_raw_out_value = capi::ICU4XFixedDecimalFormatter_create_with_decimal_symbols_v1(data_struct.AsFFI(), static_cast(grouping_strategy)); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XFixedDecimalFormatter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +template inline diplomat::result ICU4XFixedDecimalFormatter::format_to_writeable(const ICU4XFixedDecimal& value, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XFixedDecimalFormatter_format(this->inner.get(), value.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XFixedDecimalFormatter::format(const ICU4XFixedDecimal& value) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XFixedDecimalFormatter_format(this->inner.get(), value.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalGroupingStrategy.h b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalGroupingStrategy.h new file mode 100644 index 000000000000..7648892cc5bb --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalGroupingStrategy.h @@ -0,0 +1,33 @@ +#ifndef ICU4XFixedDecimalGroupingStrategy_H +#define ICU4XFixedDecimalGroupingStrategy_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XFixedDecimalGroupingStrategy { + ICU4XFixedDecimalGroupingStrategy_Auto = 0, + ICU4XFixedDecimalGroupingStrategy_Never = 1, + ICU4XFixedDecimalGroupingStrategy_Always = 2, + ICU4XFixedDecimalGroupingStrategy_Min2 = 3, +} ICU4XFixedDecimalGroupingStrategy; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XFixedDecimalGroupingStrategy_destroy(ICU4XFixedDecimalGroupingStrategy* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalGroupingStrategy.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalGroupingStrategy.hpp new file mode 100644 index 000000000000..8132871e5ab3 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalGroupingStrategy.hpp @@ -0,0 +1,28 @@ +#ifndef ICU4XFixedDecimalGroupingStrategy_HPP +#define ICU4XFixedDecimalGroupingStrategy_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XFixedDecimalGroupingStrategy.h" + + + +/** + * + * + * See the [Rust documentation for `GroupingStrategy`](https://docs.rs/icu/latest/icu/decimal/options/enum.GroupingStrategy.html) for more information. + */ +enum struct ICU4XFixedDecimalGroupingStrategy { + Auto = 0, + Never = 1, + Always = 2, + Min2 = 3, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalSign.h b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalSign.h new file mode 100644 index 000000000000..12fff3cf1cee --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalSign.h @@ -0,0 +1,32 @@ +#ifndef ICU4XFixedDecimalSign_H +#define ICU4XFixedDecimalSign_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XFixedDecimalSign { + ICU4XFixedDecimalSign_None = 0, + ICU4XFixedDecimalSign_Negative = 1, + ICU4XFixedDecimalSign_Positive = 2, +} ICU4XFixedDecimalSign; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XFixedDecimalSign_destroy(ICU4XFixedDecimalSign* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalSign.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalSign.hpp new file mode 100644 index 000000000000..b56cdfc4b692 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalSign.hpp @@ -0,0 +1,39 @@ +#ifndef ICU4XFixedDecimalSign_HPP +#define ICU4XFixedDecimalSign_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XFixedDecimalSign.h" + + + +/** + * The sign of a FixedDecimal, as shown in formatting. + * + * See the [Rust documentation for `Sign`](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.Sign.html) for more information. + */ +enum struct ICU4XFixedDecimalSign { + + /** + * No sign (implicitly positive, e.g., 1729). + */ + None = 0, + + /** + * A negative sign, e.g., -1729. + */ + Negative = 1, + + /** + * An explicit positive sign, e.g., +1729. + */ + Positive = 2, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalSignDisplay.h b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalSignDisplay.h new file mode 100644 index 000000000000..8c2612e51628 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalSignDisplay.h @@ -0,0 +1,34 @@ +#ifndef ICU4XFixedDecimalSignDisplay_H +#define ICU4XFixedDecimalSignDisplay_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XFixedDecimalSignDisplay { + ICU4XFixedDecimalSignDisplay_Auto = 0, + ICU4XFixedDecimalSignDisplay_Never = 1, + ICU4XFixedDecimalSignDisplay_Always = 2, + ICU4XFixedDecimalSignDisplay_ExceptZero = 3, + ICU4XFixedDecimalSignDisplay_Negative = 4, +} ICU4XFixedDecimalSignDisplay; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XFixedDecimalSignDisplay_destroy(ICU4XFixedDecimalSignDisplay* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalSignDisplay.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalSignDisplay.hpp new file mode 100644 index 000000000000..6261edacea6b --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XFixedDecimalSignDisplay.hpp @@ -0,0 +1,29 @@ +#ifndef ICU4XFixedDecimalSignDisplay_HPP +#define ICU4XFixedDecimalSignDisplay_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XFixedDecimalSignDisplay.h" + + + +/** + * ECMA-402 compatible sign display preference. + * + * See the [Rust documentation for `SignDisplay`](https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.SignDisplay.html) for more information. + */ +enum struct ICU4XFixedDecimalSignDisplay { + Auto = 0, + Never = 1, + Always = 2, + ExceptZero = 3, + Negative = 4, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XGeneralCategoryNameToMaskMapper.h b/third_party/rust/icu_capi/cpp/include/ICU4XGeneralCategoryNameToMaskMapper.h new file mode 100644 index 000000000000..3a4e2d4d13aa --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XGeneralCategoryNameToMaskMapper.h @@ -0,0 +1,35 @@ +#ifndef ICU4XGeneralCategoryNameToMaskMapper_H +#define ICU4XGeneralCategoryNameToMaskMapper_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XGeneralCategoryNameToMaskMapper ICU4XGeneralCategoryNameToMaskMapper; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +uint32_t ICU4XGeneralCategoryNameToMaskMapper_get_strict(const ICU4XGeneralCategoryNameToMaskMapper* self, const char* name_data, size_t name_len); + +uint32_t ICU4XGeneralCategoryNameToMaskMapper_get_loose(const ICU4XGeneralCategoryNameToMaskMapper* self, const char* name_data, size_t name_len); + +diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError ICU4XGeneralCategoryNameToMaskMapper_load(const ICU4XDataProvider* provider); +void ICU4XGeneralCategoryNameToMaskMapper_destroy(ICU4XGeneralCategoryNameToMaskMapper* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XGeneralCategoryNameToMaskMapper.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XGeneralCategoryNameToMaskMapper.hpp new file mode 100644 index 000000000000..c2462bf41752 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XGeneralCategoryNameToMaskMapper.hpp @@ -0,0 +1,85 @@ +#ifndef ICU4XGeneralCategoryNameToMaskMapper_HPP +#define ICU4XGeneralCategoryNameToMaskMapper_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XGeneralCategoryNameToMaskMapper.h" + +class ICU4XDataProvider; +class ICU4XGeneralCategoryNameToMaskMapper; +#include "ICU4XError.hpp" + +/** + * A destruction policy for using ICU4XGeneralCategoryNameToMaskMapper with std::unique_ptr. + */ +struct ICU4XGeneralCategoryNameToMaskMapperDeleter { + void operator()(capi::ICU4XGeneralCategoryNameToMaskMapper* l) const noexcept { + capi::ICU4XGeneralCategoryNameToMaskMapper_destroy(l); + } +}; + +/** + * A type capable of looking up General Category mask values from a string name. + * + * See the [Rust documentation for `get_name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.GeneralCategoryGroup.html#method.get_name_to_enum_mapper) for more information. + * + * See the [Rust documentation for `PropertyValueNameToEnumMapper`](https://docs.rs/icu/latest/icu/properties/names/struct.PropertyValueNameToEnumMapper.html) for more information. + */ +class ICU4XGeneralCategoryNameToMaskMapper { + public: + + /** + * Get the mask value matching the given name, using strict matching + * + * Returns 0 if the name is unknown for this property + */ + uint32_t get_strict(const std::string_view name) const; + + /** + * Get the mask value matching the given name, using loose matching + * + * Returns 0 if the name is unknown for this property + */ + uint32_t get_loose(const std::string_view name) const; + + /** + * + * + * See the [Rust documentation for `get_name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.GeneralCategoryGroup.html#method.get_name_to_enum_mapper) for more information. + */ + static diplomat::result load(const ICU4XDataProvider& provider); + inline const capi::ICU4XGeneralCategoryNameToMaskMapper* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XGeneralCategoryNameToMaskMapper* AsFFIMut() { return this->inner.get(); } + inline ICU4XGeneralCategoryNameToMaskMapper(capi::ICU4XGeneralCategoryNameToMaskMapper* i) : inner(i) {} + ICU4XGeneralCategoryNameToMaskMapper() = default; + ICU4XGeneralCategoryNameToMaskMapper(ICU4XGeneralCategoryNameToMaskMapper&&) noexcept = default; + ICU4XGeneralCategoryNameToMaskMapper& operator=(ICU4XGeneralCategoryNameToMaskMapper&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" + +inline uint32_t ICU4XGeneralCategoryNameToMaskMapper::get_strict(const std::string_view name) const { + return capi::ICU4XGeneralCategoryNameToMaskMapper_get_strict(this->inner.get(), name.data(), name.size()); +} +inline uint32_t ICU4XGeneralCategoryNameToMaskMapper::get_loose(const std::string_view name) const { + return capi::ICU4XGeneralCategoryNameToMaskMapper_get_loose(this->inner.get(), name.data(), name.size()); +} +inline diplomat::result ICU4XGeneralCategoryNameToMaskMapper::load(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XGeneralCategoryNameToMaskMapper_load(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XGeneralCategoryNameToMaskMapper(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorLatin1.h b/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorLatin1.h new file mode 100644 index 000000000000..9e23489fd3dd --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorLatin1.h @@ -0,0 +1,29 @@ +#ifndef ICU4XGraphemeClusterBreakIteratorLatin1_H +#define ICU4XGraphemeClusterBreakIteratorLatin1_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XGraphemeClusterBreakIteratorLatin1 ICU4XGraphemeClusterBreakIteratorLatin1; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XGraphemeClusterBreakIteratorLatin1_next(ICU4XGraphemeClusterBreakIteratorLatin1* self); +void ICU4XGraphemeClusterBreakIteratorLatin1_destroy(ICU4XGraphemeClusterBreakIteratorLatin1* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorLatin1.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorLatin1.hpp new file mode 100644 index 000000000000..a690af053930 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorLatin1.hpp @@ -0,0 +1,53 @@ +#ifndef ICU4XGraphemeClusterBreakIteratorLatin1_HPP +#define ICU4XGraphemeClusterBreakIteratorLatin1_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XGraphemeClusterBreakIteratorLatin1.h" + + +/** + * A destruction policy for using ICU4XGraphemeClusterBreakIteratorLatin1 with std::unique_ptr. + */ +struct ICU4XGraphemeClusterBreakIteratorLatin1Deleter { + void operator()(capi::ICU4XGraphemeClusterBreakIteratorLatin1* l) const noexcept { + capi::ICU4XGraphemeClusterBreakIteratorLatin1_destroy(l); + } +}; + +/** + * + * + * See the [Rust documentation for `GraphemeClusterBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterBreakIterator.html) for more information. + */ +class ICU4XGraphemeClusterBreakIteratorLatin1 { + public: + + /** + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + * out of range of a 32-bit signed integer. + * + * See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterBreakIterator.html#method.next) for more information. + */ + int32_t next(); + inline const capi::ICU4XGraphemeClusterBreakIteratorLatin1* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XGraphemeClusterBreakIteratorLatin1* AsFFIMut() { return this->inner.get(); } + inline ICU4XGraphemeClusterBreakIteratorLatin1(capi::ICU4XGraphemeClusterBreakIteratorLatin1* i) : inner(i) {} + ICU4XGraphemeClusterBreakIteratorLatin1() = default; + ICU4XGraphemeClusterBreakIteratorLatin1(ICU4XGraphemeClusterBreakIteratorLatin1&&) noexcept = default; + ICU4XGraphemeClusterBreakIteratorLatin1& operator=(ICU4XGraphemeClusterBreakIteratorLatin1&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline int32_t ICU4XGraphemeClusterBreakIteratorLatin1::next() { + return capi::ICU4XGraphemeClusterBreakIteratorLatin1_next(this->inner.get()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorUtf16.h b/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorUtf16.h new file mode 100644 index 000000000000..f0de4c0214d6 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorUtf16.h @@ -0,0 +1,29 @@ +#ifndef ICU4XGraphemeClusterBreakIteratorUtf16_H +#define ICU4XGraphemeClusterBreakIteratorUtf16_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XGraphemeClusterBreakIteratorUtf16 ICU4XGraphemeClusterBreakIteratorUtf16; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XGraphemeClusterBreakIteratorUtf16_next(ICU4XGraphemeClusterBreakIteratorUtf16* self); +void ICU4XGraphemeClusterBreakIteratorUtf16_destroy(ICU4XGraphemeClusterBreakIteratorUtf16* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorUtf16.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorUtf16.hpp new file mode 100644 index 000000000000..930e38aebf3f --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorUtf16.hpp @@ -0,0 +1,53 @@ +#ifndef ICU4XGraphemeClusterBreakIteratorUtf16_HPP +#define ICU4XGraphemeClusterBreakIteratorUtf16_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XGraphemeClusterBreakIteratorUtf16.h" + + +/** + * A destruction policy for using ICU4XGraphemeClusterBreakIteratorUtf16 with std::unique_ptr. + */ +struct ICU4XGraphemeClusterBreakIteratorUtf16Deleter { + void operator()(capi::ICU4XGraphemeClusterBreakIteratorUtf16* l) const noexcept { + capi::ICU4XGraphemeClusterBreakIteratorUtf16_destroy(l); + } +}; + +/** + * + * + * See the [Rust documentation for `GraphemeClusterBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterBreakIterator.html) for more information. + */ +class ICU4XGraphemeClusterBreakIteratorUtf16 { + public: + + /** + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + * out of range of a 32-bit signed integer. + * + * See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterBreakIterator.html#method.next) for more information. + */ + int32_t next(); + inline const capi::ICU4XGraphemeClusterBreakIteratorUtf16* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XGraphemeClusterBreakIteratorUtf16* AsFFIMut() { return this->inner.get(); } + inline ICU4XGraphemeClusterBreakIteratorUtf16(capi::ICU4XGraphemeClusterBreakIteratorUtf16* i) : inner(i) {} + ICU4XGraphemeClusterBreakIteratorUtf16() = default; + ICU4XGraphemeClusterBreakIteratorUtf16(ICU4XGraphemeClusterBreakIteratorUtf16&&) noexcept = default; + ICU4XGraphemeClusterBreakIteratorUtf16& operator=(ICU4XGraphemeClusterBreakIteratorUtf16&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline int32_t ICU4XGraphemeClusterBreakIteratorUtf16::next() { + return capi::ICU4XGraphemeClusterBreakIteratorUtf16_next(this->inner.get()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorUtf8.h b/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorUtf8.h new file mode 100644 index 000000000000..331b17eac783 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorUtf8.h @@ -0,0 +1,29 @@ +#ifndef ICU4XGraphemeClusterBreakIteratorUtf8_H +#define ICU4XGraphemeClusterBreakIteratorUtf8_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XGraphemeClusterBreakIteratorUtf8 ICU4XGraphemeClusterBreakIteratorUtf8; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XGraphemeClusterBreakIteratorUtf8_next(ICU4XGraphemeClusterBreakIteratorUtf8* self); +void ICU4XGraphemeClusterBreakIteratorUtf8_destroy(ICU4XGraphemeClusterBreakIteratorUtf8* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorUtf8.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorUtf8.hpp new file mode 100644 index 000000000000..7a61a2884011 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterBreakIteratorUtf8.hpp @@ -0,0 +1,53 @@ +#ifndef ICU4XGraphemeClusterBreakIteratorUtf8_HPP +#define ICU4XGraphemeClusterBreakIteratorUtf8_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XGraphemeClusterBreakIteratorUtf8.h" + + +/** + * A destruction policy for using ICU4XGraphemeClusterBreakIteratorUtf8 with std::unique_ptr. + */ +struct ICU4XGraphemeClusterBreakIteratorUtf8Deleter { + void operator()(capi::ICU4XGraphemeClusterBreakIteratorUtf8* l) const noexcept { + capi::ICU4XGraphemeClusterBreakIteratorUtf8_destroy(l); + } +}; + +/** + * + * + * See the [Rust documentation for `GraphemeClusterBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterBreakIterator.html) for more information. + */ +class ICU4XGraphemeClusterBreakIteratorUtf8 { + public: + + /** + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + * out of range of a 32-bit signed integer. + * + * See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterBreakIterator.html#method.next) for more information. + */ + int32_t next(); + inline const capi::ICU4XGraphemeClusterBreakIteratorUtf8* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XGraphemeClusterBreakIteratorUtf8* AsFFIMut() { return this->inner.get(); } + inline ICU4XGraphemeClusterBreakIteratorUtf8(capi::ICU4XGraphemeClusterBreakIteratorUtf8* i) : inner(i) {} + ICU4XGraphemeClusterBreakIteratorUtf8() = default; + ICU4XGraphemeClusterBreakIteratorUtf8(ICU4XGraphemeClusterBreakIteratorUtf8&&) noexcept = default; + ICU4XGraphemeClusterBreakIteratorUtf8& operator=(ICU4XGraphemeClusterBreakIteratorUtf8&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline int32_t ICU4XGraphemeClusterBreakIteratorUtf8::next() { + return capi::ICU4XGraphemeClusterBreakIteratorUtf8_next(this->inner.get()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterSegmenter.h b/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterSegmenter.h new file mode 100644 index 000000000000..1805090bfbdc --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterSegmenter.h @@ -0,0 +1,40 @@ +#ifndef ICU4XGraphemeClusterSegmenter_H +#define ICU4XGraphemeClusterSegmenter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XGraphemeClusterSegmenter ICU4XGraphemeClusterSegmenter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError.h" +#include "ICU4XGraphemeClusterBreakIteratorUtf8.h" +#include "ICU4XGraphemeClusterBreakIteratorUtf16.h" +#include "ICU4XGraphemeClusterBreakIteratorLatin1.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError ICU4XGraphemeClusterSegmenter_create(const ICU4XDataProvider* provider); + +ICU4XGraphemeClusterBreakIteratorUtf8* ICU4XGraphemeClusterSegmenter_segment_utf8(const ICU4XGraphemeClusterSegmenter* self, const char* input_data, size_t input_len); + +ICU4XGraphemeClusterBreakIteratorUtf16* ICU4XGraphemeClusterSegmenter_segment_utf16(const ICU4XGraphemeClusterSegmenter* self, const uint16_t* input_data, size_t input_len); + +ICU4XGraphemeClusterBreakIteratorLatin1* ICU4XGraphemeClusterSegmenter_segment_latin1(const ICU4XGraphemeClusterSegmenter* self, const uint8_t* input_data, size_t input_len); +void ICU4XGraphemeClusterSegmenter_destroy(ICU4XGraphemeClusterSegmenter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterSegmenter.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterSegmenter.hpp new file mode 100644 index 000000000000..c42f4e801070 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XGraphemeClusterSegmenter.hpp @@ -0,0 +1,106 @@ +#ifndef ICU4XGraphemeClusterSegmenter_HPP +#define ICU4XGraphemeClusterSegmenter_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XGraphemeClusterSegmenter.h" + +class ICU4XDataProvider; +class ICU4XGraphemeClusterSegmenter; +#include "ICU4XError.hpp" +class ICU4XGraphemeClusterBreakIteratorUtf8; +class ICU4XGraphemeClusterBreakIteratorUtf16; +class ICU4XGraphemeClusterBreakIteratorLatin1; + +/** + * A destruction policy for using ICU4XGraphemeClusterSegmenter with std::unique_ptr. + */ +struct ICU4XGraphemeClusterSegmenterDeleter { + void operator()(capi::ICU4XGraphemeClusterSegmenter* l) const noexcept { + capi::ICU4XGraphemeClusterSegmenter_destroy(l); + } +}; + +/** + * An ICU4X grapheme-cluster-break segmenter, capable of finding grapheme cluster breakpoints + * in strings. + * + * See the [Rust documentation for `GraphemeClusterSegmenter`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterSegmenter.html) for more information. + */ +class ICU4XGraphemeClusterSegmenter { + public: + + /** + * Construct an [`ICU4XGraphemeClusterSegmenter`]. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterSegmenter.html#method.try_new_unstable) for more information. + */ + static diplomat::result create(const ICU4XDataProvider& provider); + + /** + * Segments a (potentially ill-formed) UTF-8 string. + * + * See the [Rust documentation for `segment_utf8`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterSegmenter.html#method.segment_utf8) for more information. + * + * Lifetimes: `this`, `input` must live at least as long as the output. + */ + ICU4XGraphemeClusterBreakIteratorUtf8 segment_utf8(const std::string_view input) const; + + /** + * Segments a UTF-16 string. + * + * See the [Rust documentation for `segment_utf16`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterSegmenter.html#method.segment_utf16) for more information. + * + * Lifetimes: `this`, `input` must live at least as long as the output. + */ + ICU4XGraphemeClusterBreakIteratorUtf16 segment_utf16(const diplomat::span input) const; + + /** + * Segments a Latin-1 string. + * + * See the [Rust documentation for `segment_latin1`](https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterSegmenter.html#method.segment_latin1) for more information. + * + * Lifetimes: `this`, `input` must live at least as long as the output. + */ + ICU4XGraphemeClusterBreakIteratorLatin1 segment_latin1(const diplomat::span input) const; + inline const capi::ICU4XGraphemeClusterSegmenter* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XGraphemeClusterSegmenter* AsFFIMut() { return this->inner.get(); } + inline ICU4XGraphemeClusterSegmenter(capi::ICU4XGraphemeClusterSegmenter* i) : inner(i) {} + ICU4XGraphemeClusterSegmenter() = default; + ICU4XGraphemeClusterSegmenter(ICU4XGraphemeClusterSegmenter&&) noexcept = default; + ICU4XGraphemeClusterSegmenter& operator=(ICU4XGraphemeClusterSegmenter&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XGraphemeClusterBreakIteratorUtf8.hpp" +#include "ICU4XGraphemeClusterBreakIteratorUtf16.hpp" +#include "ICU4XGraphemeClusterBreakIteratorLatin1.hpp" + +inline diplomat::result ICU4XGraphemeClusterSegmenter::create(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XGraphemeClusterSegmenter_create(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XGraphemeClusterSegmenter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XGraphemeClusterBreakIteratorUtf8 ICU4XGraphemeClusterSegmenter::segment_utf8(const std::string_view input) const { + return ICU4XGraphemeClusterBreakIteratorUtf8(capi::ICU4XGraphemeClusterSegmenter_segment_utf8(this->inner.get(), input.data(), input.size())); +} +inline ICU4XGraphemeClusterBreakIteratorUtf16 ICU4XGraphemeClusterSegmenter::segment_utf16(const diplomat::span input) const { + return ICU4XGraphemeClusterBreakIteratorUtf16(capi::ICU4XGraphemeClusterSegmenter_segment_utf16(this->inner.get(), input.data(), input.size())); +} +inline ICU4XGraphemeClusterBreakIteratorLatin1 ICU4XGraphemeClusterSegmenter::segment_latin1(const diplomat::span input) const { + return ICU4XGraphemeClusterBreakIteratorLatin1(capi::ICU4XGraphemeClusterSegmenter_segment_latin1(this->inner.get(), input.data(), input.size())); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XGregorianDateFormatter.h b/third_party/rust/icu_capi/cpp/include/ICU4XGregorianDateFormatter.h new file mode 100644 index 000000000000..cf3ad9e9f4ae --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XGregorianDateFormatter.h @@ -0,0 +1,40 @@ +#ifndef ICU4XGregorianDateFormatter_H +#define ICU4XGregorianDateFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XGregorianDateFormatter ICU4XGregorianDateFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XDateLength.h" +#include "diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError.h" +#include "ICU4XIsoDate.h" +#include "diplomat_result_void_ICU4XError.h" +#include "ICU4XIsoDateTime.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError ICU4XGregorianDateFormatter_create_with_length(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XDateLength length); + +diplomat_result_void_ICU4XError ICU4XGregorianDateFormatter_format_iso_date(const ICU4XGregorianDateFormatter* self, const ICU4XIsoDate* value, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XGregorianDateFormatter_format_iso_datetime(const ICU4XGregorianDateFormatter* self, const ICU4XIsoDateTime* value, DiplomatWriteable* write); +void ICU4XGregorianDateFormatter_destroy(ICU4XGregorianDateFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XGregorianDateFormatter.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XGregorianDateFormatter.hpp new file mode 100644 index 000000000000..802e39bfe20b --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XGregorianDateFormatter.hpp @@ -0,0 +1,145 @@ +#ifndef ICU4XGregorianDateFormatter_HPP +#define ICU4XGregorianDateFormatter_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XGregorianDateFormatter.h" + +class ICU4XDataProvider; +class ICU4XLocale; +#include "ICU4XDateLength.hpp" +class ICU4XGregorianDateFormatter; +#include "ICU4XError.hpp" +class ICU4XIsoDate; +class ICU4XIsoDateTime; + +/** + * A destruction policy for using ICU4XGregorianDateFormatter with std::unique_ptr. + */ +struct ICU4XGregorianDateFormatterDeleter { + void operator()(capi::ICU4XGregorianDateFormatter* l) const noexcept { + capi::ICU4XGregorianDateFormatter_destroy(l); + } +}; + +/** + * An ICU4X TypedDateFormatter object capable of formatting a [`ICU4XIsoDateTime`] as a string, + * using the Gregorian Calendar. + * + * See the [Rust documentation for `TypedDateFormatter`](https://docs.rs/icu/latest/icu/datetime/struct.TypedDateFormatter.html) for more information. + */ +class ICU4XGregorianDateFormatter { + public: + + /** + * Creates a new [`ICU4XGregorianDateFormatter`] from locale data. + * + * See the [Rust documentation for `try_new_with_length_unstable`](https://docs.rs/icu/latest/icu/datetime/struct.TypedDateFormatter.html#method.try_new_with_length_unstable) for more information. + */ + static diplomat::result create_with_length(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XDateLength length); + + /** + * Formats a [`ICU4XIsoDate`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TypedDateFormatter.html#method.format) for more information. + */ + template diplomat::result format_iso_date_to_writeable(const ICU4XIsoDate& value, W& write) const; + + /** + * Formats a [`ICU4XIsoDate`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TypedDateFormatter.html#method.format) for more information. + */ + diplomat::result format_iso_date(const ICU4XIsoDate& value) const; + + /** + * Formats a [`ICU4XIsoDateTime`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TypedDateFormatter.html#method.format) for more information. + */ + template diplomat::result format_iso_datetime_to_writeable(const ICU4XIsoDateTime& value, W& write) const; + + /** + * Formats a [`ICU4XIsoDateTime`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TypedDateFormatter.html#method.format) for more information. + */ + diplomat::result format_iso_datetime(const ICU4XIsoDateTime& value) const; + inline const capi::ICU4XGregorianDateFormatter* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XGregorianDateFormatter* AsFFIMut() { return this->inner.get(); } + inline ICU4XGregorianDateFormatter(capi::ICU4XGregorianDateFormatter* i) : inner(i) {} + ICU4XGregorianDateFormatter() = default; + ICU4XGregorianDateFormatter(ICU4XGregorianDateFormatter&&) noexcept = default; + ICU4XGregorianDateFormatter& operator=(ICU4XGregorianDateFormatter&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" +#include "ICU4XIsoDate.hpp" +#include "ICU4XIsoDateTime.hpp" + +inline diplomat::result ICU4XGregorianDateFormatter::create_with_length(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XDateLength length) { + auto diplomat_result_raw_out_value = capi::ICU4XGregorianDateFormatter_create_with_length(provider.AsFFI(), locale.AsFFI(), static_cast(length)); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XGregorianDateFormatter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +template inline diplomat::result ICU4XGregorianDateFormatter::format_iso_date_to_writeable(const ICU4XIsoDate& value, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XGregorianDateFormatter_format_iso_date(this->inner.get(), value.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XGregorianDateFormatter::format_iso_date(const ICU4XIsoDate& value) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XGregorianDateFormatter_format_iso_date(this->inner.get(), value.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +template inline diplomat::result ICU4XGregorianDateFormatter::format_iso_datetime_to_writeable(const ICU4XIsoDateTime& value, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XGregorianDateFormatter_format_iso_datetime(this->inner.get(), value.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XGregorianDateFormatter::format_iso_datetime(const ICU4XIsoDateTime& value) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XGregorianDateFormatter_format_iso_datetime(this->inner.get(), value.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XGregorianDateTimeFormatter.h b/third_party/rust/icu_capi/cpp/include/ICU4XGregorianDateTimeFormatter.h new file mode 100644 index 000000000000..0b56ddc3934b --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XGregorianDateTimeFormatter.h @@ -0,0 +1,38 @@ +#ifndef ICU4XGregorianDateTimeFormatter_H +#define ICU4XGregorianDateTimeFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XGregorianDateTimeFormatter ICU4XGregorianDateTimeFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XDateLength.h" +#include "ICU4XTimeLength.h" +#include "diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError.h" +#include "ICU4XIsoDateTime.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError ICU4XGregorianDateTimeFormatter_create_with_lengths(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XDateLength date_length, ICU4XTimeLength time_length); + +diplomat_result_void_ICU4XError ICU4XGregorianDateTimeFormatter_format_iso_datetime(const ICU4XGregorianDateTimeFormatter* self, const ICU4XIsoDateTime* value, DiplomatWriteable* write); +void ICU4XGregorianDateTimeFormatter_destroy(ICU4XGregorianDateTimeFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XGregorianDateTimeFormatter.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XGregorianDateTimeFormatter.hpp new file mode 100644 index 000000000000..f9b50f4d9629 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XGregorianDateTimeFormatter.hpp @@ -0,0 +1,107 @@ +#ifndef ICU4XGregorianDateTimeFormatter_HPP +#define ICU4XGregorianDateTimeFormatter_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XGregorianDateTimeFormatter.h" + +class ICU4XDataProvider; +class ICU4XLocale; +#include "ICU4XDateLength.hpp" +#include "ICU4XTimeLength.hpp" +class ICU4XGregorianDateTimeFormatter; +#include "ICU4XError.hpp" +class ICU4XIsoDateTime; + +/** + * A destruction policy for using ICU4XGregorianDateTimeFormatter with std::unique_ptr. + */ +struct ICU4XGregorianDateTimeFormatterDeleter { + void operator()(capi::ICU4XGregorianDateTimeFormatter* l) const noexcept { + capi::ICU4XGregorianDateTimeFormatter_destroy(l); + } +}; + +/** + * An ICU4X TypedDateTimeFormatter object capable of formatting a [`ICU4XIsoDateTime`] as a string, + * using the Gregorian Calendar. + * + * See the [Rust documentation for `TypedDateTimeFormatter`](https://docs.rs/icu/latest/icu/datetime/struct.TypedDateTimeFormatter.html) for more information. + */ +class ICU4XGregorianDateTimeFormatter { + public: + + /** + * Creates a new [`ICU4XGregorianDateFormatter`] from locale data. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/datetime/struct.TypedDateTimeFormatter.html#method.try_new_unstable) for more information. + */ + static diplomat::result create_with_lengths(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XDateLength date_length, ICU4XTimeLength time_length); + + /** + * Formats a [`ICU4XIsoDateTime`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TypedDateTimeFormatter.html#method.format) for more information. + */ + template diplomat::result format_iso_datetime_to_writeable(const ICU4XIsoDateTime& value, W& write) const; + + /** + * Formats a [`ICU4XIsoDateTime`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TypedDateTimeFormatter.html#method.format) for more information. + */ + diplomat::result format_iso_datetime(const ICU4XIsoDateTime& value) const; + inline const capi::ICU4XGregorianDateTimeFormatter* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XGregorianDateTimeFormatter* AsFFIMut() { return this->inner.get(); } + inline ICU4XGregorianDateTimeFormatter(capi::ICU4XGregorianDateTimeFormatter* i) : inner(i) {} + ICU4XGregorianDateTimeFormatter() = default; + ICU4XGregorianDateTimeFormatter(ICU4XGregorianDateTimeFormatter&&) noexcept = default; + ICU4XGregorianDateTimeFormatter& operator=(ICU4XGregorianDateTimeFormatter&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" +#include "ICU4XIsoDateTime.hpp" + +inline diplomat::result ICU4XGregorianDateTimeFormatter::create_with_lengths(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XDateLength date_length, ICU4XTimeLength time_length) { + auto diplomat_result_raw_out_value = capi::ICU4XGregorianDateTimeFormatter_create_with_lengths(provider.AsFFI(), locale.AsFFI(), static_cast(date_length), static_cast(time_length)); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XGregorianDateTimeFormatter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +template inline diplomat::result ICU4XGregorianDateTimeFormatter::format_iso_datetime_to_writeable(const ICU4XIsoDateTime& value, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XGregorianDateTimeFormatter_format_iso_datetime(this->inner.get(), value.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XGregorianDateTimeFormatter::format_iso_datetime(const ICU4XIsoDateTime& value) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XGregorianDateTimeFormatter_format_iso_datetime(this->inner.get(), value.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XGregorianZonedDateTimeFormatter.h b/third_party/rust/icu_capi/cpp/include/ICU4XGregorianZonedDateTimeFormatter.h new file mode 100644 index 000000000000..4be60c2b0b27 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XGregorianZonedDateTimeFormatter.h @@ -0,0 +1,42 @@ +#ifndef ICU4XGregorianZonedDateTimeFormatter_H +#define ICU4XGregorianZonedDateTimeFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XGregorianZonedDateTimeFormatter ICU4XGregorianZonedDateTimeFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XDateLength.h" +#include "ICU4XTimeLength.h" +#include "diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError.h" +#include "ICU4XIsoTimeZoneOptions.h" +#include "ICU4XIsoDateTime.h" +#include "ICU4XCustomTimeZone.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError ICU4XGregorianZonedDateTimeFormatter_create_with_lengths(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XDateLength date_length, ICU4XTimeLength time_length); + +diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError ICU4XGregorianZonedDateTimeFormatter_create_with_lengths_and_iso_8601_time_zone_fallback(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XDateLength date_length, ICU4XTimeLength time_length, ICU4XIsoTimeZoneOptions zone_options); + +diplomat_result_void_ICU4XError ICU4XGregorianZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone(const ICU4XGregorianZonedDateTimeFormatter* self, const ICU4XIsoDateTime* datetime, const ICU4XCustomTimeZone* time_zone, DiplomatWriteable* write); +void ICU4XGregorianZonedDateTimeFormatter_destroy(ICU4XGregorianZonedDateTimeFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XGregorianZonedDateTimeFormatter.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XGregorianZonedDateTimeFormatter.hpp new file mode 100644 index 000000000000..fbc41f9885d7 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XGregorianZonedDateTimeFormatter.hpp @@ -0,0 +1,134 @@ +#ifndef ICU4XGregorianZonedDateTimeFormatter_HPP +#define ICU4XGregorianZonedDateTimeFormatter_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XGregorianZonedDateTimeFormatter.h" + +class ICU4XDataProvider; +class ICU4XLocale; +#include "ICU4XDateLength.hpp" +#include "ICU4XTimeLength.hpp" +class ICU4XGregorianZonedDateTimeFormatter; +#include "ICU4XError.hpp" +struct ICU4XIsoTimeZoneOptions; +class ICU4XIsoDateTime; +class ICU4XCustomTimeZone; + +/** + * A destruction policy for using ICU4XGregorianZonedDateTimeFormatter with std::unique_ptr. + */ +struct ICU4XGregorianZonedDateTimeFormatterDeleter { + void operator()(capi::ICU4XGregorianZonedDateTimeFormatter* l) const noexcept { + capi::ICU4XGregorianZonedDateTimeFormatter_destroy(l); + } +}; + +/** + * 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. + */ +class ICU4XGregorianZonedDateTimeFormatter { + public: + + /** + * Creates a new [`ICU4XGregorianZonedDateTimeFormatter`] from locale data. + * + * This function has `date_length` and `time_length` arguments and uses default options + * for the time zone. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/datetime/struct.TypedZonedDateTimeFormatter.html#method.try_new_unstable) for more information. + */ + static diplomat::result create_with_lengths(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XDateLength date_length, ICU4XTimeLength time_length); + + /** + * Creates a new [`ICU4XGregorianZonedDateTimeFormatter`] from locale data. + * + * This function has `date_length` and `time_length` arguments and uses an ISO-8601 style + * fallback for the time zone with the given configurations. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/datetime/struct.TypedZonedDateTimeFormatter.html#method.try_new_unstable) for more information. + */ + static diplomat::result create_with_lengths_and_iso_8601_time_zone_fallback(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XDateLength date_length, ICU4XTimeLength time_length, ICU4XIsoTimeZoneOptions zone_options); + + /** + * Formats a [`ICU4XIsoDateTime`] and [`ICU4XCustomTimeZone`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TypedZonedDateTimeFormatter.html#method.format) for more information. + */ + template diplomat::result format_iso_datetime_with_custom_time_zone_to_writeable(const ICU4XIsoDateTime& datetime, const ICU4XCustomTimeZone& time_zone, W& write) const; + + /** + * Formats a [`ICU4XIsoDateTime`] and [`ICU4XCustomTimeZone`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TypedZonedDateTimeFormatter.html#method.format) for more information. + */ + diplomat::result format_iso_datetime_with_custom_time_zone(const ICU4XIsoDateTime& datetime, const ICU4XCustomTimeZone& time_zone) const; + inline const capi::ICU4XGregorianZonedDateTimeFormatter* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XGregorianZonedDateTimeFormatter* AsFFIMut() { return this->inner.get(); } + inline ICU4XGregorianZonedDateTimeFormatter(capi::ICU4XGregorianZonedDateTimeFormatter* i) : inner(i) {} + ICU4XGregorianZonedDateTimeFormatter() = default; + ICU4XGregorianZonedDateTimeFormatter(ICU4XGregorianZonedDateTimeFormatter&&) noexcept = default; + ICU4XGregorianZonedDateTimeFormatter& operator=(ICU4XGregorianZonedDateTimeFormatter&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" +#include "ICU4XIsoTimeZoneOptions.hpp" +#include "ICU4XIsoDateTime.hpp" +#include "ICU4XCustomTimeZone.hpp" + +inline diplomat::result ICU4XGregorianZonedDateTimeFormatter::create_with_lengths(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XDateLength date_length, ICU4XTimeLength time_length) { + auto diplomat_result_raw_out_value = capi::ICU4XGregorianZonedDateTimeFormatter_create_with_lengths(provider.AsFFI(), locale.AsFFI(), static_cast(date_length), static_cast(time_length)); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XGregorianZonedDateTimeFormatter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XGregorianZonedDateTimeFormatter::create_with_lengths_and_iso_8601_time_zone_fallback(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XDateLength date_length, ICU4XTimeLength time_length, ICU4XIsoTimeZoneOptions zone_options) { + ICU4XIsoTimeZoneOptions diplomat_wrapped_struct_zone_options = zone_options; + auto diplomat_result_raw_out_value = capi::ICU4XGregorianZonedDateTimeFormatter_create_with_lengths_and_iso_8601_time_zone_fallback(provider.AsFFI(), locale.AsFFI(), static_cast(date_length), static_cast(time_length), capi::ICU4XIsoTimeZoneOptions{ .format = static_cast(diplomat_wrapped_struct_zone_options.format), .minutes = static_cast(diplomat_wrapped_struct_zone_options.minutes), .seconds = static_cast(diplomat_wrapped_struct_zone_options.seconds) }); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XGregorianZonedDateTimeFormatter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +template inline diplomat::result ICU4XGregorianZonedDateTimeFormatter::format_iso_datetime_with_custom_time_zone_to_writeable(const ICU4XIsoDateTime& datetime, const ICU4XCustomTimeZone& time_zone, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XGregorianZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone(this->inner.get(), datetime.AsFFI(), time_zone.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XGregorianZonedDateTimeFormatter::format_iso_datetime_with_custom_time_zone(const ICU4XIsoDateTime& datetime, const ICU4XCustomTimeZone& time_zone) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XGregorianZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone(this->inner.get(), datetime.AsFFI(), time_zone.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XIsoDate.h b/third_party/rust/icu_capi/cpp/include/ICU4XIsoDate.h new file mode 100644 index 000000000000..aadc7590bad9 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XIsoDate.h @@ -0,0 +1,57 @@ +#ifndef ICU4XIsoDate_H +#define ICU4XIsoDate_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XIsoDate ICU4XIsoDate; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_box_ICU4XIsoDate_ICU4XError.h" +#include "ICU4XCalendar.h" +#include "ICU4XDate.h" +#include "ICU4XIsoWeekday.h" +#include "ICU4XWeekCalculator.h" +#include "diplomat_result_ICU4XWeekOf_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XIsoDate_ICU4XError ICU4XIsoDate_create(int32_t year, uint8_t month, uint8_t day); + +ICU4XDate* ICU4XIsoDate_to_calendar(const ICU4XIsoDate* self, const ICU4XCalendar* calendar); + +ICU4XDate* ICU4XIsoDate_to_any(const ICU4XIsoDate* self); + +uint32_t ICU4XIsoDate_day_of_month(const ICU4XIsoDate* self); + +ICU4XIsoWeekday ICU4XIsoDate_day_of_week(const ICU4XIsoDate* self); + +uint32_t ICU4XIsoDate_week_of_month(const ICU4XIsoDate* self, ICU4XIsoWeekday first_weekday); + +diplomat_result_ICU4XWeekOf_ICU4XError ICU4XIsoDate_week_of_year(const ICU4XIsoDate* self, const ICU4XWeekCalculator* calculator); + +uint32_t ICU4XIsoDate_month(const ICU4XIsoDate* self); + +int32_t ICU4XIsoDate_year(const ICU4XIsoDate* self); + +uint8_t ICU4XIsoDate_months_in_year(const ICU4XIsoDate* self); + +uint8_t ICU4XIsoDate_days_in_month(const ICU4XIsoDate* self); + +uint32_t ICU4XIsoDate_days_in_year(const ICU4XIsoDate* self); +void ICU4XIsoDate_destroy(ICU4XIsoDate* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XIsoDate.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XIsoDate.hpp new file mode 100644 index 000000000000..83db48655a8f --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XIsoDate.hpp @@ -0,0 +1,191 @@ +#ifndef ICU4XIsoDate_HPP +#define ICU4XIsoDate_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XIsoDate.h" + +class ICU4XIsoDate; +#include "ICU4XError.hpp" +class ICU4XCalendar; +class ICU4XDate; +#include "ICU4XIsoWeekday.hpp" +class ICU4XWeekCalculator; +struct ICU4XWeekOf; + +/** + * A destruction policy for using ICU4XIsoDate with std::unique_ptr. + */ +struct ICU4XIsoDateDeleter { + void operator()(capi::ICU4XIsoDate* l) const noexcept { + capi::ICU4XIsoDate_destroy(l); + } +}; + +/** + * 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. + */ +class ICU4XIsoDate { + public: + + /** + * Creates a new [`ICU4XIsoDate`] from the specified date and time. + * + * See the [Rust documentation for `try_new_iso_date`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.try_new_iso_date) for more information. + */ + static diplomat::result create(int32_t year, uint8_t month, uint8_t day); + + /** + * 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. + */ + ICU4XDate to_calendar(const ICU4XCalendar& calendar) const; + + /** + * + * + * See the [Rust documentation for `to_any`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.to_any) for more information. + */ + ICU4XDate to_any() const; + + /** + * 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. + */ + uint32_t day_of_month() const; + + /** + * Returns the day in the week for this day + * + * See the [Rust documentation for `day_of_week`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_week) for more information. + */ + ICU4XIsoWeekday day_of_week() const; + + /** + * Returns the week number in this month, 1-indexed, based on what + * is considered the first day of the week (often a locale preference). + * + * `first_weekday` can be obtained via `first_weekday()` on [`ICU4XWeekCalculator`] + * + * 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. + */ + uint32_t week_of_month(ICU4XIsoWeekday first_weekday) const; + + /** + * Returns the week number in this year, using week data + * + * See the [Rust documentation for `week_of_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_year) for more information. + */ + diplomat::result week_of_year(const ICU4XWeekCalculator& calculator) const; + + /** + * 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. + */ + uint32_t month() const; + + /** + * Returns the year number for this date + * + * See the [Rust documentation for `year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year) for more information. + */ + int32_t year() const; + + /** + * Returns the number of months in the year represented by this date + * + * See the [Rust documentation for `months_in_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.months_in_year) for more information. + */ + uint8_t months_in_year() const; + + /** + * Returns the number of days in the month represented by this date + * + * See the [Rust documentation for `days_in_month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_month) for more information. + */ + uint8_t days_in_month() const; + + /** + * Returns the number of days in the year represented by this date + * + * See the [Rust documentation for `days_in_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_year) for more information. + */ + uint32_t days_in_year() const; + inline const capi::ICU4XIsoDate* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XIsoDate* AsFFIMut() { return this->inner.get(); } + inline ICU4XIsoDate(capi::ICU4XIsoDate* i) : inner(i) {} + ICU4XIsoDate() = default; + ICU4XIsoDate(ICU4XIsoDate&&) noexcept = default; + ICU4XIsoDate& operator=(ICU4XIsoDate&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XCalendar.hpp" +#include "ICU4XDate.hpp" +#include "ICU4XWeekCalculator.hpp" +#include "ICU4XWeekOf.hpp" + +inline diplomat::result ICU4XIsoDate::create(int32_t year, uint8_t month, uint8_t day) { + auto diplomat_result_raw_out_value = capi::ICU4XIsoDate_create(year, month, day); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XIsoDate(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XDate ICU4XIsoDate::to_calendar(const ICU4XCalendar& calendar) const { + return ICU4XDate(capi::ICU4XIsoDate_to_calendar(this->inner.get(), calendar.AsFFI())); +} +inline ICU4XDate ICU4XIsoDate::to_any() const { + return ICU4XDate(capi::ICU4XIsoDate_to_any(this->inner.get())); +} +inline uint32_t ICU4XIsoDate::day_of_month() const { + return capi::ICU4XIsoDate_day_of_month(this->inner.get()); +} +inline ICU4XIsoWeekday ICU4XIsoDate::day_of_week() const { + return static_cast(capi::ICU4XIsoDate_day_of_week(this->inner.get())); +} +inline uint32_t ICU4XIsoDate::week_of_month(ICU4XIsoWeekday first_weekday) const { + return capi::ICU4XIsoDate_week_of_month(this->inner.get(), static_cast(first_weekday)); +} +inline diplomat::result ICU4XIsoDate::week_of_year(const ICU4XWeekCalculator& calculator) const { + auto diplomat_result_raw_out_value = capi::ICU4XIsoDate_week_of_year(this->inner.get(), calculator.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + capi::ICU4XWeekOf diplomat_raw_struct_out_value = diplomat_result_raw_out_value.ok; + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XWeekOf{ .week = std::move(diplomat_raw_struct_out_value.week), .unit = std::move(static_cast(diplomat_raw_struct_out_value.unit)) })); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline uint32_t ICU4XIsoDate::month() const { + return capi::ICU4XIsoDate_month(this->inner.get()); +} +inline int32_t ICU4XIsoDate::year() const { + return capi::ICU4XIsoDate_year(this->inner.get()); +} +inline uint8_t ICU4XIsoDate::months_in_year() const { + return capi::ICU4XIsoDate_months_in_year(this->inner.get()); +} +inline uint8_t ICU4XIsoDate::days_in_month() const { + return capi::ICU4XIsoDate_days_in_month(this->inner.get()); +} +inline uint32_t ICU4XIsoDate::days_in_year() const { + return capi::ICU4XIsoDate_days_in_year(this->inner.get()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XIsoDateTime.h b/third_party/rust/icu_capi/cpp/include/ICU4XIsoDateTime.h new file mode 100644 index 000000000000..6f1a2acbe2d6 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XIsoDateTime.h @@ -0,0 +1,77 @@ +#ifndef ICU4XIsoDateTime_H +#define ICU4XIsoDateTime_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XIsoDateTime ICU4XIsoDateTime; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_box_ICU4XIsoDateTime_ICU4XError.h" +#include "ICU4XIsoDate.h" +#include "ICU4XTime.h" +#include "ICU4XDateTime.h" +#include "ICU4XCalendar.h" +#include "ICU4XIsoWeekday.h" +#include "ICU4XWeekCalculator.h" +#include "diplomat_result_ICU4XWeekOf_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XIsoDateTime_ICU4XError ICU4XIsoDateTime_create(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond); + +ICU4XIsoDateTime* ICU4XIsoDateTime_crate_from_date_and_time(const ICU4XIsoDate* date, const ICU4XTime* time); + +ICU4XIsoDateTime* ICU4XIsoDateTime_create_from_minutes_since_local_unix_epoch(int32_t minutes); + +ICU4XIsoDate* ICU4XIsoDateTime_date(const ICU4XIsoDateTime* self); + +ICU4XTime* ICU4XIsoDateTime_time(const ICU4XIsoDateTime* self); + +ICU4XDateTime* ICU4XIsoDateTime_to_any(const ICU4XIsoDateTime* self); + +int32_t ICU4XIsoDateTime_minutes_since_local_unix_epoch(const ICU4XIsoDateTime* self); + +ICU4XDateTime* ICU4XIsoDateTime_to_calendar(const ICU4XIsoDateTime* self, const ICU4XCalendar* calendar); + +uint8_t ICU4XIsoDateTime_hour(const ICU4XIsoDateTime* self); + +uint8_t ICU4XIsoDateTime_minute(const ICU4XIsoDateTime* self); + +uint8_t ICU4XIsoDateTime_second(const ICU4XIsoDateTime* self); + +uint32_t ICU4XIsoDateTime_nanosecond(const ICU4XIsoDateTime* self); + +uint32_t ICU4XIsoDateTime_day_of_month(const ICU4XIsoDateTime* self); + +ICU4XIsoWeekday ICU4XIsoDateTime_day_of_week(const ICU4XIsoDateTime* self); + +uint32_t ICU4XIsoDateTime_week_of_month(const ICU4XIsoDateTime* self, ICU4XIsoWeekday first_weekday); + +diplomat_result_ICU4XWeekOf_ICU4XError ICU4XIsoDateTime_week_of_year(const ICU4XIsoDateTime* self, const ICU4XWeekCalculator* calculator); + +uint32_t ICU4XIsoDateTime_month(const ICU4XIsoDateTime* self); + +int32_t ICU4XIsoDateTime_year(const ICU4XIsoDateTime* self); + +uint8_t ICU4XIsoDateTime_months_in_year(const ICU4XIsoDateTime* self); + +uint8_t ICU4XIsoDateTime_days_in_month(const ICU4XIsoDateTime* self); + +uint32_t ICU4XIsoDateTime_days_in_year(const ICU4XIsoDateTime* self); +void ICU4XIsoDateTime_destroy(ICU4XIsoDateTime* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XIsoDateTime.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XIsoDateTime.hpp new file mode 100644 index 000000000000..0d744f69a1e8 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XIsoDateTime.hpp @@ -0,0 +1,286 @@ +#ifndef ICU4XIsoDateTime_HPP +#define ICU4XIsoDateTime_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XIsoDateTime.h" + +class ICU4XIsoDateTime; +#include "ICU4XError.hpp" +class ICU4XIsoDate; +class ICU4XTime; +class ICU4XDateTime; +class ICU4XCalendar; +#include "ICU4XIsoWeekday.hpp" +class ICU4XWeekCalculator; +struct ICU4XWeekOf; + +/** + * A destruction policy for using ICU4XIsoDateTime with std::unique_ptr. + */ +struct ICU4XIsoDateTimeDeleter { + void operator()(capi::ICU4XIsoDateTime* l) const noexcept { + capi::ICU4XIsoDateTime_destroy(l); + } +}; + +/** + * 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. + */ +class ICU4XIsoDateTime { + public: + + /** + * Creates a new [`ICU4XIsoDateTime`] from the specified date and time. + * + * See the [Rust documentation for `try_new_iso_datetime`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.try_new_iso_datetime) for more information. + */ + static diplomat::result create(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond); + + /** + * Creates a new [`ICU4XIsoDateTime`] from an [`ICU4XIsoDate`] and [`ICU4XTime`] object + * + * See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.new) for more information. + */ + static ICU4XIsoDateTime crate_from_date_and_time(const ICU4XIsoDate& date, const ICU4XTime& time); + + /** + * Construct from the minutes since the local unix epoch for this date (Jan 1 1970, 00:00) + * + * See the [Rust documentation for `from_minutes_since_local_unix_epoch`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.from_minutes_since_local_unix_epoch) for more information. + */ + static ICU4XIsoDateTime create_from_minutes_since_local_unix_epoch(int32_t minutes); + + /** + * 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. + */ + ICU4XIsoDate date() const; + + /** + * 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. + */ + ICU4XTime time() const; + + /** + * Converts this to an [`ICU4XDateTime`] capable of being mixed with dates of + * other calendars + * + * See the [Rust documentation for `to_any`](https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.to_any) for more information. + */ + ICU4XDateTime to_any() const; + + /** + * 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. + */ + int32_t minutes_since_local_unix_epoch() const; + + /** + * 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. + */ + ICU4XDateTime to_calendar(const ICU4XCalendar& calendar) const; + + /** + * 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. + */ + uint8_t hour() const; + + /** + * Returns the minute in this time + * + * See the [Rust documentation for `minute`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.minute) for more information. + */ + uint8_t minute() const; + + /** + * Returns the second in this time + * + * See the [Rust documentation for `second`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.second) for more information. + */ + uint8_t second() const; + + /** + * Returns the nanosecond in this time + * + * See the [Rust documentation for `nanosecond`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.nanosecond) for more information. + */ + uint32_t nanosecond() const; + + /** + * 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. + */ + uint32_t day_of_month() const; + + /** + * Returns the day in the week for this day + * + * See the [Rust documentation for `day_of_week`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_week) for more information. + */ + ICU4XIsoWeekday day_of_week() const; + + /** + * Returns the week number in this month, 1-indexed, based on what + * is considered the first day of the week (often a locale preference). + * + * `first_weekday` can be obtained via `first_weekday()` on [`ICU4XWeekCalculator`] + * + * 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. + */ + uint32_t week_of_month(ICU4XIsoWeekday first_weekday) const; + + /** + * Returns the week number in this year, using week data + * + * See the [Rust documentation for `week_of_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_year) for more information. + */ + diplomat::result week_of_year(const ICU4XWeekCalculator& calculator) const; + + /** + * 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. + */ + uint32_t month() const; + + /** + * Returns the year number for this date + * + * See the [Rust documentation for `year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year) for more information. + */ + int32_t year() const; + + /** + * Returns the number of months in the year represented by this date + * + * See the [Rust documentation for `months_in_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.months_in_year) for more information. + */ + uint8_t months_in_year() const; + + /** + * Returns the number of days in the month represented by this date + * + * See the [Rust documentation for `days_in_month`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_month) for more information. + */ + uint8_t days_in_month() const; + + /** + * Returns the number of days in the year represented by this date + * + * See the [Rust documentation for `days_in_year`](https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_year) for more information. + */ + uint32_t days_in_year() const; + inline const capi::ICU4XIsoDateTime* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XIsoDateTime* AsFFIMut() { return this->inner.get(); } + inline ICU4XIsoDateTime(capi::ICU4XIsoDateTime* i) : inner(i) {} + ICU4XIsoDateTime() = default; + ICU4XIsoDateTime(ICU4XIsoDateTime&&) noexcept = default; + ICU4XIsoDateTime& operator=(ICU4XIsoDateTime&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XIsoDate.hpp" +#include "ICU4XTime.hpp" +#include "ICU4XDateTime.hpp" +#include "ICU4XCalendar.hpp" +#include "ICU4XWeekCalculator.hpp" +#include "ICU4XWeekOf.hpp" + +inline diplomat::result ICU4XIsoDateTime::create(int32_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond) { + auto diplomat_result_raw_out_value = capi::ICU4XIsoDateTime_create(year, month, day, hour, minute, second, nanosecond); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XIsoDateTime(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XIsoDateTime ICU4XIsoDateTime::crate_from_date_and_time(const ICU4XIsoDate& date, const ICU4XTime& time) { + return ICU4XIsoDateTime(capi::ICU4XIsoDateTime_crate_from_date_and_time(date.AsFFI(), time.AsFFI())); +} +inline ICU4XIsoDateTime ICU4XIsoDateTime::create_from_minutes_since_local_unix_epoch(int32_t minutes) { + return ICU4XIsoDateTime(capi::ICU4XIsoDateTime_create_from_minutes_since_local_unix_epoch(minutes)); +} +inline ICU4XIsoDate ICU4XIsoDateTime::date() const { + return ICU4XIsoDate(capi::ICU4XIsoDateTime_date(this->inner.get())); +} +inline ICU4XTime ICU4XIsoDateTime::time() const { + return ICU4XTime(capi::ICU4XIsoDateTime_time(this->inner.get())); +} +inline ICU4XDateTime ICU4XIsoDateTime::to_any() const { + return ICU4XDateTime(capi::ICU4XIsoDateTime_to_any(this->inner.get())); +} +inline int32_t ICU4XIsoDateTime::minutes_since_local_unix_epoch() const { + return capi::ICU4XIsoDateTime_minutes_since_local_unix_epoch(this->inner.get()); +} +inline ICU4XDateTime ICU4XIsoDateTime::to_calendar(const ICU4XCalendar& calendar) const { + return ICU4XDateTime(capi::ICU4XIsoDateTime_to_calendar(this->inner.get(), calendar.AsFFI())); +} +inline uint8_t ICU4XIsoDateTime::hour() const { + return capi::ICU4XIsoDateTime_hour(this->inner.get()); +} +inline uint8_t ICU4XIsoDateTime::minute() const { + return capi::ICU4XIsoDateTime_minute(this->inner.get()); +} +inline uint8_t ICU4XIsoDateTime::second() const { + return capi::ICU4XIsoDateTime_second(this->inner.get()); +} +inline uint32_t ICU4XIsoDateTime::nanosecond() const { + return capi::ICU4XIsoDateTime_nanosecond(this->inner.get()); +} +inline uint32_t ICU4XIsoDateTime::day_of_month() const { + return capi::ICU4XIsoDateTime_day_of_month(this->inner.get()); +} +inline ICU4XIsoWeekday ICU4XIsoDateTime::day_of_week() const { + return static_cast(capi::ICU4XIsoDateTime_day_of_week(this->inner.get())); +} +inline uint32_t ICU4XIsoDateTime::week_of_month(ICU4XIsoWeekday first_weekday) const { + return capi::ICU4XIsoDateTime_week_of_month(this->inner.get(), static_cast(first_weekday)); +} +inline diplomat::result ICU4XIsoDateTime::week_of_year(const ICU4XWeekCalculator& calculator) const { + auto diplomat_result_raw_out_value = capi::ICU4XIsoDateTime_week_of_year(this->inner.get(), calculator.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + capi::ICU4XWeekOf diplomat_raw_struct_out_value = diplomat_result_raw_out_value.ok; + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XWeekOf{ .week = std::move(diplomat_raw_struct_out_value.week), .unit = std::move(static_cast(diplomat_raw_struct_out_value.unit)) })); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline uint32_t ICU4XIsoDateTime::month() const { + return capi::ICU4XIsoDateTime_month(this->inner.get()); +} +inline int32_t ICU4XIsoDateTime::year() const { + return capi::ICU4XIsoDateTime_year(this->inner.get()); +} +inline uint8_t ICU4XIsoDateTime::months_in_year() const { + return capi::ICU4XIsoDateTime_months_in_year(this->inner.get()); +} +inline uint8_t ICU4XIsoDateTime::days_in_month() const { + return capi::ICU4XIsoDateTime_days_in_month(this->inner.get()); +} +inline uint32_t ICU4XIsoDateTime::days_in_year() const { + return capi::ICU4XIsoDateTime_days_in_year(this->inner.get()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneFormat.h b/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneFormat.h new file mode 100644 index 000000000000..e48a1142f213 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneFormat.h @@ -0,0 +1,33 @@ +#ifndef ICU4XIsoTimeZoneFormat_H +#define ICU4XIsoTimeZoneFormat_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XIsoTimeZoneFormat { + ICU4XIsoTimeZoneFormat_Basic = 0, + ICU4XIsoTimeZoneFormat_Extended = 1, + ICU4XIsoTimeZoneFormat_UtcBasic = 2, + ICU4XIsoTimeZoneFormat_UtcExtended = 3, +} ICU4XIsoTimeZoneFormat; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XIsoTimeZoneFormat_destroy(ICU4XIsoTimeZoneFormat* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneFormat.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneFormat.hpp new file mode 100644 index 000000000000..700806d92942 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneFormat.hpp @@ -0,0 +1,28 @@ +#ifndef ICU4XIsoTimeZoneFormat_HPP +#define ICU4XIsoTimeZoneFormat_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XIsoTimeZoneFormat.h" + + + +/** + * + * + * See the [Rust documentation for `IsoFormat`](https://docs.rs/icu/latest/icu/datetime/time_zone/enum.IsoFormat.html) for more information. + */ +enum struct ICU4XIsoTimeZoneFormat { + Basic = 0, + Extended = 1, + UtcBasic = 2, + UtcExtended = 3, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneMinuteDisplay.h b/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneMinuteDisplay.h new file mode 100644 index 000000000000..edeee9701913 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneMinuteDisplay.h @@ -0,0 +1,31 @@ +#ifndef ICU4XIsoTimeZoneMinuteDisplay_H +#define ICU4XIsoTimeZoneMinuteDisplay_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XIsoTimeZoneMinuteDisplay { + ICU4XIsoTimeZoneMinuteDisplay_Required = 0, + ICU4XIsoTimeZoneMinuteDisplay_Optional = 1, +} ICU4XIsoTimeZoneMinuteDisplay; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XIsoTimeZoneMinuteDisplay_destroy(ICU4XIsoTimeZoneMinuteDisplay* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneMinuteDisplay.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneMinuteDisplay.hpp new file mode 100644 index 000000000000..f395f823f3e0 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneMinuteDisplay.hpp @@ -0,0 +1,26 @@ +#ifndef ICU4XIsoTimeZoneMinuteDisplay_HPP +#define ICU4XIsoTimeZoneMinuteDisplay_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XIsoTimeZoneMinuteDisplay.h" + + + +/** + * + * + * See the [Rust documentation for `IsoMinutes`](https://docs.rs/icu/latest/icu/datetime/time_zone/enum.IsoMinutes.html) for more information. + */ +enum struct ICU4XIsoTimeZoneMinuteDisplay { + Required = 0, + Optional = 1, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneOptions.h b/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneOptions.h new file mode 100644 index 000000000000..7ba051c3e617 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneOptions.h @@ -0,0 +1,38 @@ +#ifndef ICU4XIsoTimeZoneOptions_H +#define ICU4XIsoTimeZoneOptions_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XIsoTimeZoneFormat.h" +#include "ICU4XIsoTimeZoneMinuteDisplay.h" +#include "ICU4XIsoTimeZoneSecondDisplay.h" +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XIsoTimeZoneOptions { + ICU4XIsoTimeZoneFormat format; + ICU4XIsoTimeZoneMinuteDisplay minutes; + ICU4XIsoTimeZoneSecondDisplay seconds; +} ICU4XIsoTimeZoneOptions; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XIsoTimeZoneFormat.h" +#include "ICU4XIsoTimeZoneMinuteDisplay.h" +#include "ICU4XIsoTimeZoneSecondDisplay.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XIsoTimeZoneOptions_destroy(ICU4XIsoTimeZoneOptions* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneOptions.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneOptions.hpp new file mode 100644 index 000000000000..50826833290d --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneOptions.hpp @@ -0,0 +1,26 @@ +#ifndef ICU4XIsoTimeZoneOptions_HPP +#define ICU4XIsoTimeZoneOptions_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XIsoTimeZoneOptions.h" + +#include "ICU4XIsoTimeZoneFormat.hpp" +#include "ICU4XIsoTimeZoneMinuteDisplay.hpp" +#include "ICU4XIsoTimeZoneSecondDisplay.hpp" + +struct ICU4XIsoTimeZoneOptions { + public: + ICU4XIsoTimeZoneFormat format; + ICU4XIsoTimeZoneMinuteDisplay minutes; + ICU4XIsoTimeZoneSecondDisplay seconds; +}; + + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneSecondDisplay.h b/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneSecondDisplay.h new file mode 100644 index 000000000000..487a248f958a --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneSecondDisplay.h @@ -0,0 +1,31 @@ +#ifndef ICU4XIsoTimeZoneSecondDisplay_H +#define ICU4XIsoTimeZoneSecondDisplay_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XIsoTimeZoneSecondDisplay { + ICU4XIsoTimeZoneSecondDisplay_Optional = 0, + ICU4XIsoTimeZoneSecondDisplay_Never = 1, +} ICU4XIsoTimeZoneSecondDisplay; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XIsoTimeZoneSecondDisplay_destroy(ICU4XIsoTimeZoneSecondDisplay* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneSecondDisplay.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneSecondDisplay.hpp new file mode 100644 index 000000000000..68f571211f50 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XIsoTimeZoneSecondDisplay.hpp @@ -0,0 +1,26 @@ +#ifndef ICU4XIsoTimeZoneSecondDisplay_HPP +#define ICU4XIsoTimeZoneSecondDisplay_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XIsoTimeZoneSecondDisplay.h" + + + +/** + * + * + * See the [Rust documentation for `IsoSeconds`](https://docs.rs/icu/latest/icu/datetime/time_zone/enum.IsoSeconds.html) for more information. + */ +enum struct ICU4XIsoTimeZoneSecondDisplay { + Optional = 0, + Never = 1, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XIsoWeekday.h b/third_party/rust/icu_capi/cpp/include/ICU4XIsoWeekday.h new file mode 100644 index 000000000000..a23d0a3b9e92 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XIsoWeekday.h @@ -0,0 +1,36 @@ +#ifndef ICU4XIsoWeekday_H +#define ICU4XIsoWeekday_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XIsoWeekday { + ICU4XIsoWeekday_Monday = 1, + ICU4XIsoWeekday_Tuesday = 2, + ICU4XIsoWeekday_Wednesday = 3, + ICU4XIsoWeekday_Thursday = 4, + ICU4XIsoWeekday_Friday = 5, + ICU4XIsoWeekday_Saturday = 6, + ICU4XIsoWeekday_Sunday = 7, +} ICU4XIsoWeekday; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XIsoWeekday_destroy(ICU4XIsoWeekday* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XIsoWeekday.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XIsoWeekday.hpp new file mode 100644 index 000000000000..ec33e4a80ec0 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XIsoWeekday.hpp @@ -0,0 +1,25 @@ +#ifndef ICU4XIsoWeekday_HPP +#define ICU4XIsoWeekday_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XIsoWeekday.h" + + +enum struct ICU4XIsoWeekday { + Monday = 1, + Tuesday = 2, + Wednesday = 3, + Thursday = 4, + Friday = 5, + Saturday = 6, + Sunday = 7, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLanguageDisplay.h b/third_party/rust/icu_capi/cpp/include/ICU4XLanguageDisplay.h new file mode 100644 index 000000000000..0b921351fefa --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLanguageDisplay.h @@ -0,0 +1,31 @@ +#ifndef ICU4XLanguageDisplay_H +#define ICU4XLanguageDisplay_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XLanguageDisplay { + ICU4XLanguageDisplay_Dialect = 0, + ICU4XLanguageDisplay_Standard = 1, +} ICU4XLanguageDisplay; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XLanguageDisplay_destroy(ICU4XLanguageDisplay* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLanguageDisplay.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XLanguageDisplay.hpp new file mode 100644 index 000000000000..52d9a78ec039 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLanguageDisplay.hpp @@ -0,0 +1,26 @@ +#ifndef ICU4XLanguageDisplay_HPP +#define ICU4XLanguageDisplay_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XLanguageDisplay.h" + + + +/** + * + * + * See the [Rust documentation for `LanguageDisplay`](https://docs.rs/icu/latest/icu/displaynames/options/enum.LanguageDisplay.html) for more information. + */ +enum struct ICU4XLanguageDisplay { + Dialect = 0, + Standard = 1, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorLatin1.h b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorLatin1.h new file mode 100644 index 000000000000..c1a4c391318f --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorLatin1.h @@ -0,0 +1,29 @@ +#ifndef ICU4XLineBreakIteratorLatin1_H +#define ICU4XLineBreakIteratorLatin1_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLineBreakIteratorLatin1 ICU4XLineBreakIteratorLatin1; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XLineBreakIteratorLatin1_next(ICU4XLineBreakIteratorLatin1* self); +void ICU4XLineBreakIteratorLatin1_destroy(ICU4XLineBreakIteratorLatin1* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorLatin1.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorLatin1.hpp new file mode 100644 index 000000000000..40ff1426a058 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorLatin1.hpp @@ -0,0 +1,55 @@ +#ifndef ICU4XLineBreakIteratorLatin1_HPP +#define ICU4XLineBreakIteratorLatin1_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XLineBreakIteratorLatin1.h" + + +/** + * A destruction policy for using ICU4XLineBreakIteratorLatin1 with std::unique_ptr. + */ +struct ICU4XLineBreakIteratorLatin1Deleter { + void operator()(capi::ICU4XLineBreakIteratorLatin1* l) const noexcept { + capi::ICU4XLineBreakIteratorLatin1_destroy(l); + } +}; + +/** + * + * + * 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) + */ +class ICU4XLineBreakIteratorLatin1 { + public: + + /** + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + * out of range of a 32-bit signed integer. + * + * See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakIterator.html#method.next) for more information. + */ + int32_t next(); + inline const capi::ICU4XLineBreakIteratorLatin1* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XLineBreakIteratorLatin1* AsFFIMut() { return this->inner.get(); } + inline ICU4XLineBreakIteratorLatin1(capi::ICU4XLineBreakIteratorLatin1* i) : inner(i) {} + ICU4XLineBreakIteratorLatin1() = default; + ICU4XLineBreakIteratorLatin1(ICU4XLineBreakIteratorLatin1&&) noexcept = default; + ICU4XLineBreakIteratorLatin1& operator=(ICU4XLineBreakIteratorLatin1&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline int32_t ICU4XLineBreakIteratorLatin1::next() { + return capi::ICU4XLineBreakIteratorLatin1_next(this->inner.get()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorUtf16.h b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorUtf16.h new file mode 100644 index 000000000000..78ae12c7e4b4 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorUtf16.h @@ -0,0 +1,29 @@ +#ifndef ICU4XLineBreakIteratorUtf16_H +#define ICU4XLineBreakIteratorUtf16_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLineBreakIteratorUtf16 ICU4XLineBreakIteratorUtf16; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XLineBreakIteratorUtf16_next(ICU4XLineBreakIteratorUtf16* self); +void ICU4XLineBreakIteratorUtf16_destroy(ICU4XLineBreakIteratorUtf16* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorUtf16.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorUtf16.hpp new file mode 100644 index 000000000000..4ec04307445e --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorUtf16.hpp @@ -0,0 +1,55 @@ +#ifndef ICU4XLineBreakIteratorUtf16_HPP +#define ICU4XLineBreakIteratorUtf16_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XLineBreakIteratorUtf16.h" + + +/** + * A destruction policy for using ICU4XLineBreakIteratorUtf16 with std::unique_ptr. + */ +struct ICU4XLineBreakIteratorUtf16Deleter { + void operator()(capi::ICU4XLineBreakIteratorUtf16* l) const noexcept { + capi::ICU4XLineBreakIteratorUtf16_destroy(l); + } +}; + +/** + * + * + * 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) + */ +class ICU4XLineBreakIteratorUtf16 { + public: + + /** + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + * out of range of a 32-bit signed integer. + * + * See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakIterator.html#method.next) for more information. + */ + int32_t next(); + inline const capi::ICU4XLineBreakIteratorUtf16* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XLineBreakIteratorUtf16* AsFFIMut() { return this->inner.get(); } + inline ICU4XLineBreakIteratorUtf16(capi::ICU4XLineBreakIteratorUtf16* i) : inner(i) {} + ICU4XLineBreakIteratorUtf16() = default; + ICU4XLineBreakIteratorUtf16(ICU4XLineBreakIteratorUtf16&&) noexcept = default; + ICU4XLineBreakIteratorUtf16& operator=(ICU4XLineBreakIteratorUtf16&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline int32_t ICU4XLineBreakIteratorUtf16::next() { + return capi::ICU4XLineBreakIteratorUtf16_next(this->inner.get()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorUtf8.h b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorUtf8.h new file mode 100644 index 000000000000..3a08c5ad232b --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorUtf8.h @@ -0,0 +1,29 @@ +#ifndef ICU4XLineBreakIteratorUtf8_H +#define ICU4XLineBreakIteratorUtf8_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLineBreakIteratorUtf8 ICU4XLineBreakIteratorUtf8; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XLineBreakIteratorUtf8_next(ICU4XLineBreakIteratorUtf8* self); +void ICU4XLineBreakIteratorUtf8_destroy(ICU4XLineBreakIteratorUtf8* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorUtf8.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorUtf8.hpp new file mode 100644 index 000000000000..a11467441824 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakIteratorUtf8.hpp @@ -0,0 +1,55 @@ +#ifndef ICU4XLineBreakIteratorUtf8_HPP +#define ICU4XLineBreakIteratorUtf8_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XLineBreakIteratorUtf8.h" + + +/** + * A destruction policy for using ICU4XLineBreakIteratorUtf8 with std::unique_ptr. + */ +struct ICU4XLineBreakIteratorUtf8Deleter { + void operator()(capi::ICU4XLineBreakIteratorUtf8* l) const noexcept { + capi::ICU4XLineBreakIteratorUtf8_destroy(l); + } +}; + +/** + * + * + * 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) + */ +class ICU4XLineBreakIteratorUtf8 { + public: + + /** + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + * out of range of a 32-bit signed integer. + * + * See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakIterator.html#method.next) for more information. + */ + int32_t next(); + inline const capi::ICU4XLineBreakIteratorUtf8* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XLineBreakIteratorUtf8* AsFFIMut() { return this->inner.get(); } + inline ICU4XLineBreakIteratorUtf8(capi::ICU4XLineBreakIteratorUtf8* i) : inner(i) {} + ICU4XLineBreakIteratorUtf8() = default; + ICU4XLineBreakIteratorUtf8(ICU4XLineBreakIteratorUtf8&&) noexcept = default; + ICU4XLineBreakIteratorUtf8& operator=(ICU4XLineBreakIteratorUtf8&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline int32_t ICU4XLineBreakIteratorUtf8::next() { + return capi::ICU4XLineBreakIteratorUtf8_next(this->inner.get()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakOptionsV1.h b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakOptionsV1.h new file mode 100644 index 000000000000..5fbf4b581426 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakOptionsV1.h @@ -0,0 +1,36 @@ +#ifndef ICU4XLineBreakOptionsV1_H +#define ICU4XLineBreakOptionsV1_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XLineBreakStrictness.h" +#include "ICU4XLineBreakWordOption.h" +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLineBreakOptionsV1 { + ICU4XLineBreakStrictness strictness; + ICU4XLineBreakWordOption word_option; + bool ja_zh; +} ICU4XLineBreakOptionsV1; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XLineBreakStrictness.h" +#include "ICU4XLineBreakWordOption.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XLineBreakOptionsV1_destroy(ICU4XLineBreakOptionsV1* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakOptionsV1.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakOptionsV1.hpp new file mode 100644 index 000000000000..345b2380d351 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakOptionsV1.hpp @@ -0,0 +1,31 @@ +#ifndef ICU4XLineBreakOptionsV1_HPP +#define ICU4XLineBreakOptionsV1_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XLineBreakOptionsV1.h" + +#include "ICU4XLineBreakStrictness.hpp" +#include "ICU4XLineBreakWordOption.hpp" + + +/** + * + * + * See the [Rust documentation for `LineBreakOptions`](https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakOptions.html) for more information. + */ +struct ICU4XLineBreakOptionsV1 { + public: + ICU4XLineBreakStrictness strictness; + ICU4XLineBreakWordOption word_option; + bool ja_zh; +}; + + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakStrictness.h b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakStrictness.h new file mode 100644 index 000000000000..e3534b7ec733 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakStrictness.h @@ -0,0 +1,33 @@ +#ifndef ICU4XLineBreakStrictness_H +#define ICU4XLineBreakStrictness_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XLineBreakStrictness { + ICU4XLineBreakStrictness_Loose = 0, + ICU4XLineBreakStrictness_Normal = 1, + ICU4XLineBreakStrictness_Strict = 2, + ICU4XLineBreakStrictness_Anywhere = 3, +} ICU4XLineBreakStrictness; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XLineBreakStrictness_destroy(ICU4XLineBreakStrictness* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakStrictness.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakStrictness.hpp new file mode 100644 index 000000000000..63f169beab3b --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakStrictness.hpp @@ -0,0 +1,28 @@ +#ifndef ICU4XLineBreakStrictness_HPP +#define ICU4XLineBreakStrictness_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XLineBreakStrictness.h" + + + +/** + * + * + * See the [Rust documentation for `LineBreakStrictness`](https://docs.rs/icu/latest/icu/segmenter/enum.LineBreakStrictness.html) for more information. + */ +enum struct ICU4XLineBreakStrictness { + Loose = 0, + Normal = 1, + Strict = 2, + Anywhere = 3, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakWordOption.h b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakWordOption.h new file mode 100644 index 000000000000..02a6ca6f2d41 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakWordOption.h @@ -0,0 +1,32 @@ +#ifndef ICU4XLineBreakWordOption_H +#define ICU4XLineBreakWordOption_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XLineBreakWordOption { + ICU4XLineBreakWordOption_Normal = 0, + ICU4XLineBreakWordOption_BreakAll = 1, + ICU4XLineBreakWordOption_KeepAll = 2, +} ICU4XLineBreakWordOption; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XLineBreakWordOption_destroy(ICU4XLineBreakWordOption* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakWordOption.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakWordOption.hpp new file mode 100644 index 000000000000..8cefca8797b4 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLineBreakWordOption.hpp @@ -0,0 +1,27 @@ +#ifndef ICU4XLineBreakWordOption_HPP +#define ICU4XLineBreakWordOption_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XLineBreakWordOption.h" + + + +/** + * + * + * See the [Rust documentation for `LineBreakWordOption`](https://docs.rs/icu/latest/icu/segmenter/enum.LineBreakWordOption.html) for more information. + */ +enum struct ICU4XLineBreakWordOption { + Normal = 0, + BreakAll = 1, + KeepAll = 2, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLineSegmenter.h b/third_party/rust/icu_capi/cpp/include/ICU4XLineSegmenter.h new file mode 100644 index 000000000000..f734ec78f827 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLineSegmenter.h @@ -0,0 +1,51 @@ +#ifndef ICU4XLineSegmenter_H +#define ICU4XLineSegmenter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLineSegmenter ICU4XLineSegmenter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XLineSegmenter_ICU4XError.h" +#include "ICU4XLineBreakOptionsV1.h" +#include "ICU4XLineBreakIteratorUtf8.h" +#include "ICU4XLineBreakIteratorUtf16.h" +#include "ICU4XLineBreakIteratorLatin1.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XLineSegmenter_ICU4XError ICU4XLineSegmenter_create_auto(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XLineSegmenter_ICU4XError ICU4XLineSegmenter_create_lstm(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XLineSegmenter_ICU4XError ICU4XLineSegmenter_create_dictionary(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XLineSegmenter_ICU4XError ICU4XLineSegmenter_create_auto_with_options_v1(const ICU4XDataProvider* provider, ICU4XLineBreakOptionsV1 options); + +diplomat_result_box_ICU4XLineSegmenter_ICU4XError ICU4XLineSegmenter_create_lstm_with_options_v1(const ICU4XDataProvider* provider, ICU4XLineBreakOptionsV1 options); + +diplomat_result_box_ICU4XLineSegmenter_ICU4XError ICU4XLineSegmenter_create_dictionary_with_options_v1(const ICU4XDataProvider* provider, ICU4XLineBreakOptionsV1 options); + +ICU4XLineBreakIteratorUtf8* ICU4XLineSegmenter_segment_utf8(const ICU4XLineSegmenter* self, const char* input_data, size_t input_len); + +ICU4XLineBreakIteratorUtf16* ICU4XLineSegmenter_segment_utf16(const ICU4XLineSegmenter* self, const uint16_t* input_data, size_t input_len); + +ICU4XLineBreakIteratorLatin1* ICU4XLineSegmenter_segment_latin1(const ICU4XLineSegmenter* self, const uint8_t* input_data, size_t input_len); +void ICU4XLineSegmenter_destroy(ICU4XLineSegmenter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLineSegmenter.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XLineSegmenter.hpp new file mode 100644 index 000000000000..262aa69a793d --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLineSegmenter.hpp @@ -0,0 +1,201 @@ +#ifndef ICU4XLineSegmenter_HPP +#define ICU4XLineSegmenter_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XLineSegmenter.h" + +class ICU4XDataProvider; +class ICU4XLineSegmenter; +#include "ICU4XError.hpp" +struct ICU4XLineBreakOptionsV1; +class ICU4XLineBreakIteratorUtf8; +class ICU4XLineBreakIteratorUtf16; +class ICU4XLineBreakIteratorLatin1; + +/** + * A destruction policy for using ICU4XLineSegmenter with std::unique_ptr. + */ +struct ICU4XLineSegmenterDeleter { + void operator()(capi::ICU4XLineSegmenter* l) const noexcept { + capi::ICU4XLineSegmenter_destroy(l); + } +}; + +/** + * 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. + */ +class ICU4XLineSegmenter { + public: + + /** + * Construct a [`ICU4XLineSegmenter`] with default options. It automatically loads the best + * available payload data for Burmese, Khmer, Lao, and Thai. + * + * See the [Rust documentation for `try_new_auto_unstable`](https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.try_new_auto_unstable) for more information. + */ + static diplomat::result create_auto(const ICU4XDataProvider& provider); + + /** + * Construct a [`ICU4XLineSegmenter`] with default options and LSTM payload data for + * Burmese, Khmer, Lao, and Thai. + * + * See the [Rust documentation for `try_new_lstm_unstable`](https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.try_new_lstm_unstable) for more information. + */ + static diplomat::result create_lstm(const ICU4XDataProvider& provider); + + /** + * Construct a [`ICU4XLineSegmenter`] with default options and dictionary payload data for + * Burmese, Khmer, Lao, and Thai.. + * + * See the [Rust documentation for `try_new_dictionary_unstable`](https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.try_new_dictionary_unstable) for more information. + */ + static diplomat::result create_dictionary(const ICU4XDataProvider& provider); + + /** + * Construct a [`ICU4XLineSegmenter`] with custom options. It automatically loads the best + * available payload data for Burmese, Khmer, Lao, and Thai. + * + * See the [Rust documentation for `try_new_auto_with_options_unstable`](https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.try_new_auto_with_options_unstable) for more information. + */ + static diplomat::result create_auto_with_options_v1(const ICU4XDataProvider& provider, ICU4XLineBreakOptionsV1 options); + + /** + * Construct a [`ICU4XLineSegmenter`] with custom options and LSTM payload data for + * Burmese, Khmer, Lao, and Thai. + * + * See the [Rust documentation for `try_new_lstm_with_options_unstable`](https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.try_new_lstm_with_options_unstable) for more information. + */ + static diplomat::result create_lstm_with_options_v1(const ICU4XDataProvider& provider, ICU4XLineBreakOptionsV1 options); + + /** + * Construct a [`ICU4XLineSegmenter`] with custom options and dictionary payload data for + * Burmese, Khmer, Lao, and Thai. + * + * See the [Rust documentation for `try_new_dictionary_with_options_unstable`](https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.try_new_dictionary_with_options_unstable) for more information. + */ + static diplomat::result create_dictionary_with_options_v1(const ICU4XDataProvider& provider, ICU4XLineBreakOptionsV1 options); + + /** + * Segments a (potentially ill-formed) UTF-8 string. + * + * See the [Rust documentation for `segment_utf8`](https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.segment_utf8) for more information. + * + * Lifetimes: `this`, `input` must live at least as long as the output. + */ + ICU4XLineBreakIteratorUtf8 segment_utf8(const std::string_view input) const; + + /** + * Segments a UTF-16 string. + * + * See the [Rust documentation for `segment_utf16`](https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.segment_utf16) for more information. + * + * Lifetimes: `this`, `input` must live at least as long as the output. + */ + ICU4XLineBreakIteratorUtf16 segment_utf16(const diplomat::span input) const; + + /** + * Segments a Latin-1 string. + * + * See the [Rust documentation for `segment_latin1`](https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.segment_latin1) for more information. + * + * Lifetimes: `this`, `input` must live at least as long as the output. + */ + ICU4XLineBreakIteratorLatin1 segment_latin1(const diplomat::span input) const; + inline const capi::ICU4XLineSegmenter* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XLineSegmenter* AsFFIMut() { return this->inner.get(); } + inline ICU4XLineSegmenter(capi::ICU4XLineSegmenter* i) : inner(i) {} + ICU4XLineSegmenter() = default; + ICU4XLineSegmenter(ICU4XLineSegmenter&&) noexcept = default; + ICU4XLineSegmenter& operator=(ICU4XLineSegmenter&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLineBreakOptionsV1.hpp" +#include "ICU4XLineBreakIteratorUtf8.hpp" +#include "ICU4XLineBreakIteratorUtf16.hpp" +#include "ICU4XLineBreakIteratorLatin1.hpp" + +inline diplomat::result ICU4XLineSegmenter::create_auto(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XLineSegmenter_create_auto(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XLineSegmenter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XLineSegmenter::create_lstm(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XLineSegmenter_create_lstm(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XLineSegmenter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XLineSegmenter::create_dictionary(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XLineSegmenter_create_dictionary(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XLineSegmenter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XLineSegmenter::create_auto_with_options_v1(const ICU4XDataProvider& provider, ICU4XLineBreakOptionsV1 options) { + ICU4XLineBreakOptionsV1 diplomat_wrapped_struct_options = options; + auto diplomat_result_raw_out_value = capi::ICU4XLineSegmenter_create_auto_with_options_v1(provider.AsFFI(), capi::ICU4XLineBreakOptionsV1{ .strictness = static_cast(diplomat_wrapped_struct_options.strictness), .word_option = static_cast(diplomat_wrapped_struct_options.word_option), .ja_zh = diplomat_wrapped_struct_options.ja_zh }); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XLineSegmenter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XLineSegmenter::create_lstm_with_options_v1(const ICU4XDataProvider& provider, ICU4XLineBreakOptionsV1 options) { + ICU4XLineBreakOptionsV1 diplomat_wrapped_struct_options = options; + auto diplomat_result_raw_out_value = capi::ICU4XLineSegmenter_create_lstm_with_options_v1(provider.AsFFI(), capi::ICU4XLineBreakOptionsV1{ .strictness = static_cast(diplomat_wrapped_struct_options.strictness), .word_option = static_cast(diplomat_wrapped_struct_options.word_option), .ja_zh = diplomat_wrapped_struct_options.ja_zh }); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XLineSegmenter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XLineSegmenter::create_dictionary_with_options_v1(const ICU4XDataProvider& provider, ICU4XLineBreakOptionsV1 options) { + ICU4XLineBreakOptionsV1 diplomat_wrapped_struct_options = options; + auto diplomat_result_raw_out_value = capi::ICU4XLineSegmenter_create_dictionary_with_options_v1(provider.AsFFI(), capi::ICU4XLineBreakOptionsV1{ .strictness = static_cast(diplomat_wrapped_struct_options.strictness), .word_option = static_cast(diplomat_wrapped_struct_options.word_option), .ja_zh = diplomat_wrapped_struct_options.ja_zh }); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XLineSegmenter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XLineBreakIteratorUtf8 ICU4XLineSegmenter::segment_utf8(const std::string_view input) const { + return ICU4XLineBreakIteratorUtf8(capi::ICU4XLineSegmenter_segment_utf8(this->inner.get(), input.data(), input.size())); +} +inline ICU4XLineBreakIteratorUtf16 ICU4XLineSegmenter::segment_utf16(const diplomat::span input) const { + return ICU4XLineBreakIteratorUtf16(capi::ICU4XLineSegmenter_segment_utf16(this->inner.get(), input.data(), input.size())); +} +inline ICU4XLineBreakIteratorLatin1 ICU4XLineSegmenter::segment_latin1(const diplomat::span input) const { + return ICU4XLineBreakIteratorLatin1(capi::ICU4XLineSegmenter_segment_latin1(this->inner.get(), input.data(), input.size())); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XList.h b/third_party/rust/icu_capi/cpp/include/ICU4XList.h new file mode 100644 index 000000000000..6549561c37ba --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XList.h @@ -0,0 +1,35 @@ +#ifndef ICU4XList_H +#define ICU4XList_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XList ICU4XList; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +ICU4XList* ICU4XList_create(); + +ICU4XList* ICU4XList_create_with_capacity(size_t capacity); + +void ICU4XList_push(ICU4XList* self, const char* val_data, size_t val_len); + +size_t ICU4XList_len(const ICU4XList* self); +void ICU4XList_destroy(ICU4XList* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XList.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XList.hpp new file mode 100644 index 000000000000..e2212c021ad9 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XList.hpp @@ -0,0 +1,77 @@ +#ifndef ICU4XList_HPP +#define ICU4XList_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XList.h" + +class ICU4XList; + +/** + * A destruction policy for using ICU4XList with std::unique_ptr. + */ +struct ICU4XListDeleter { + void operator()(capi::ICU4XList* l) const noexcept { + capi::ICU4XList_destroy(l); + } +}; + +/** + * A list of strings + */ +class ICU4XList { + public: + + /** + * Create a new list of strings + */ + static ICU4XList create(); + + /** + * Create a new list of strings with preallocated space to hold + * at least `capacity` elements + */ + static ICU4XList create_with_capacity(size_t capacity); + + /** + * Push a string to the list + * + * For C++ users, potentially invalid UTF8 will be handled via + * REPLACEMENT CHARACTERs + */ + void push(const std::string_view val); + + /** + * The number of elements in this list + */ + size_t len() const; + inline const capi::ICU4XList* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XList* AsFFIMut() { return this->inner.get(); } + inline ICU4XList(capi::ICU4XList* i) : inner(i) {} + ICU4XList() = default; + ICU4XList(ICU4XList&&) noexcept = default; + ICU4XList& operator=(ICU4XList&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline ICU4XList ICU4XList::create() { + return ICU4XList(capi::ICU4XList_create()); +} +inline ICU4XList ICU4XList::create_with_capacity(size_t capacity) { + return ICU4XList(capi::ICU4XList_create_with_capacity(capacity)); +} +inline void ICU4XList::push(const std::string_view val) { + capi::ICU4XList_push(this->inner.get(), val.data(), val.size()); +} +inline size_t ICU4XList::len() const { + return capi::ICU4XList_len(this->inner.get()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XListFormatter.h b/third_party/rust/icu_capi/cpp/include/ICU4XListFormatter.h new file mode 100644 index 000000000000..ee358dc254cc --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XListFormatter.h @@ -0,0 +1,41 @@ +#ifndef ICU4XListFormatter_H +#define ICU4XListFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XListFormatter ICU4XListFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XListLength.h" +#include "diplomat_result_box_ICU4XListFormatter_ICU4XError.h" +#include "ICU4XList.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XListFormatter_ICU4XError ICU4XListFormatter_create_and_with_length(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XListLength length); + +diplomat_result_box_ICU4XListFormatter_ICU4XError ICU4XListFormatter_create_or_with_length(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XListLength length); + +diplomat_result_box_ICU4XListFormatter_ICU4XError ICU4XListFormatter_create_unit_with_length(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XListLength length); + +diplomat_result_void_ICU4XError ICU4XListFormatter_format(const ICU4XListFormatter* self, const ICU4XList* list, DiplomatWriteable* write); +void ICU4XListFormatter_destroy(ICU4XListFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XListFormatter.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XListFormatter.hpp new file mode 100644 index 000000000000..463f7d14d34c --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XListFormatter.hpp @@ -0,0 +1,139 @@ +#ifndef ICU4XListFormatter_HPP +#define ICU4XListFormatter_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XListFormatter.h" + +class ICU4XDataProvider; +class ICU4XLocale; +#include "ICU4XListLength.hpp" +class ICU4XListFormatter; +#include "ICU4XError.hpp" +class ICU4XList; + +/** + * A destruction policy for using ICU4XListFormatter with std::unique_ptr. + */ +struct ICU4XListFormatterDeleter { + void operator()(capi::ICU4XListFormatter* l) const noexcept { + capi::ICU4XListFormatter_destroy(l); + } +}; + +/** + * + * + * See the [Rust documentation for `ListFormatter`](https://docs.rs/icu/latest/icu/list/struct.ListFormatter.html) for more information. + */ +class ICU4XListFormatter { + public: + + /** + * Construct a new ICU4XListFormatter instance for And patterns + * + * See the [Rust documentation for `try_new_and_with_length_unstable`](https://docs.rs/icu/latest/icu/normalizer/struct.ListFormatter.html#method.try_new_and_with_length_unstable) for more information. + */ + static diplomat::result create_and_with_length(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XListLength length); + + /** + * Construct a new ICU4XListFormatter instance for And patterns + * + * See the [Rust documentation for `try_new_or_with_length_unstable`](https://docs.rs/icu/latest/icu/normalizer/struct.ListFormatter.html#method.try_new_or_with_length_unstable) for more information. + */ + static diplomat::result create_or_with_length(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XListLength length); + + /** + * Construct a new ICU4XListFormatter instance for And patterns + * + * See the [Rust documentation for `try_new_unit_with_length_unstable`](https://docs.rs/icu/latest/icu/normalizer/struct.ListFormatter.html#method.try_new_unit_with_length_unstable) for more information. + */ + static diplomat::result create_unit_with_length(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XListLength length); + + /** + * + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/normalizer/struct.ListFormatter.html#method.format) for more information. + */ + template diplomat::result format_to_writeable(const ICU4XList& list, W& write) const; + + /** + * + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/normalizer/struct.ListFormatter.html#method.format) for more information. + */ + diplomat::result format(const ICU4XList& list) const; + inline const capi::ICU4XListFormatter* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XListFormatter* AsFFIMut() { return this->inner.get(); } + inline ICU4XListFormatter(capi::ICU4XListFormatter* i) : inner(i) {} + ICU4XListFormatter() = default; + ICU4XListFormatter(ICU4XListFormatter&&) noexcept = default; + ICU4XListFormatter& operator=(ICU4XListFormatter&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" +#include "ICU4XList.hpp" + +inline diplomat::result ICU4XListFormatter::create_and_with_length(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XListLength length) { + auto diplomat_result_raw_out_value = capi::ICU4XListFormatter_create_and_with_length(provider.AsFFI(), locale.AsFFI(), static_cast(length)); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XListFormatter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XListFormatter::create_or_with_length(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XListLength length) { + auto diplomat_result_raw_out_value = capi::ICU4XListFormatter_create_or_with_length(provider.AsFFI(), locale.AsFFI(), static_cast(length)); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XListFormatter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XListFormatter::create_unit_with_length(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XListLength length) { + auto diplomat_result_raw_out_value = capi::ICU4XListFormatter_create_unit_with_length(provider.AsFFI(), locale.AsFFI(), static_cast(length)); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XListFormatter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +template inline diplomat::result ICU4XListFormatter::format_to_writeable(const ICU4XList& list, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XListFormatter_format(this->inner.get(), list.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XListFormatter::format(const ICU4XList& list) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XListFormatter_format(this->inner.get(), list.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XListLength.h b/third_party/rust/icu_capi/cpp/include/ICU4XListLength.h new file mode 100644 index 000000000000..7092f6d9dfd7 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XListLength.h @@ -0,0 +1,32 @@ +#ifndef ICU4XListLength_H +#define ICU4XListLength_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XListLength { + ICU4XListLength_Wide = 0, + ICU4XListLength_Short = 1, + ICU4XListLength_Narrow = 2, +} ICU4XListLength; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XListLength_destroy(ICU4XListLength* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XListLength.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XListLength.hpp new file mode 100644 index 000000000000..19fcc5d64c29 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XListLength.hpp @@ -0,0 +1,27 @@ +#ifndef ICU4XListLength_HPP +#define ICU4XListLength_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XListLength.h" + + + +/** + * + * + * See the [Rust documentation for `ListLength`](https://docs.rs/icu/latest/icu/list/enum.ListLength.html) for more information. + */ +enum struct ICU4XListLength { + Wide = 0, + Short = 1, + Narrow = 2, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLocale.h b/third_party/rust/icu_capi/cpp/include/ICU4XLocale.h new file mode 100644 index 000000000000..dea8d196b5cd --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLocale.h @@ -0,0 +1,64 @@ +#ifndef ICU4XLocale_H +#define ICU4XLocale_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLocale ICU4XLocale; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_box_ICU4XLocale_ICU4XError.h" +#include "diplomat_result_void_ICU4XError.h" +#include "ICU4XOrdering.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XLocale_ICU4XError ICU4XLocale_create_from_string(const char* name_data, size_t name_len); + +ICU4XLocale* ICU4XLocale_create_und(); + +ICU4XLocale* ICU4XLocale_clone(const ICU4XLocale* self); + +diplomat_result_void_ICU4XError ICU4XLocale_basename(const ICU4XLocale* self, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XLocale_get_unicode_extension(const ICU4XLocale* self, const char* bytes_data, size_t bytes_len, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XLocale_language(const ICU4XLocale* self, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XLocale_set_language(ICU4XLocale* self, const char* bytes_data, size_t bytes_len); + +diplomat_result_void_ICU4XError ICU4XLocale_region(const ICU4XLocale* self, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XLocale_set_region(ICU4XLocale* self, const char* bytes_data, size_t bytes_len); + +diplomat_result_void_ICU4XError ICU4XLocale_script(const ICU4XLocale* self, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XLocale_set_script(ICU4XLocale* self, const char* bytes_data, size_t bytes_len); + +diplomat_result_void_ICU4XError ICU4XLocale_canonicalize(const char* bytes_data, size_t bytes_len, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XLocale_to_string(const ICU4XLocale* self, DiplomatWriteable* write); + +bool ICU4XLocale_normalizing_eq(const ICU4XLocale* self, const char* other_data, size_t other_len); + +ICU4XOrdering ICU4XLocale_strict_cmp(const ICU4XLocale* self, const char* other_data, size_t other_len); + +ICU4XLocale* ICU4XLocale_create_en(); + +ICU4XLocale* ICU4XLocale_create_bn(); +void ICU4XLocale_destroy(ICU4XLocale* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLocale.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XLocale.hpp new file mode 100644 index 000000000000..cae7cc2dfe84 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLocale.hpp @@ -0,0 +1,444 @@ +#ifndef ICU4XLocale_HPP +#define ICU4XLocale_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XLocale.h" + +class ICU4XLocale; +#include "ICU4XError.hpp" +#include "ICU4XOrdering.hpp" + +/** + * A destruction policy for using ICU4XLocale with std::unique_ptr. + */ +struct ICU4XLocaleDeleter { + void operator()(capi::ICU4XLocale* l) const noexcept { + capi::ICU4XLocale_destroy(l); + } +}; + +/** + * 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. + */ +class ICU4XLocale { + public: + + /** + * Construct an [`ICU4XLocale`] from an locale identifier. + * + * This will run the complete locale parsing algorithm. If code size and + * performance are critical and the locale is of a known shape (such as + * `aa-BB`) use `create_und`, `set_language`, `set_script`, and `set_region`. + * + * See the [Rust documentation for `try_from_bytes`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.try_from_bytes) for more information. + */ + static diplomat::result create_from_string(const std::string_view name); + + /** + * Construct a default undefined [`ICU4XLocale`] "und". + * + * See the [Rust documentation for `UND`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#associatedconstant.UND) for more information. + */ + static ICU4XLocale create_und(); + + /** + * Clones the [`ICU4XLocale`]. + * + * See the [Rust documentation for `Locale`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html) for more information. + */ + ICU4XLocale clone() const; + + /** + * Write a string representation of the `LanguageIdentifier` part of + * [`ICU4XLocale`] to `write`. + * + * See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.id) for more information. + */ + template diplomat::result basename_to_writeable(W& write) const; + + /** + * Write a string representation of the `LanguageIdentifier` part of + * [`ICU4XLocale`] to `write`. + * + * See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.id) for more information. + */ + diplomat::result basename() const; + + /** + * Write a string representation of the unicode extension to `write` + * + * See the [Rust documentation for `extensions`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.extensions) for more information. + */ + template diplomat::result get_unicode_extension_to_writeable(const std::string_view bytes, W& write) const; + + /** + * Write a string representation of the unicode extension to `write` + * + * See the [Rust documentation for `extensions`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.extensions) for more information. + */ + diplomat::result get_unicode_extension(const std::string_view bytes) const; + + /** + * Write a string representation of [`ICU4XLocale`] language to `write` + * + * See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.id) for more information. + */ + template diplomat::result language_to_writeable(W& write) const; + + /** + * Write a string representation of [`ICU4XLocale`] language to `write` + * + * See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.id) for more information. + */ + diplomat::result language() const; + + /** + * Set the language part of the [`ICU4XLocale`]. + * + * See the [Rust documentation for `try_from_bytes`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.try_from_bytes) for more information. + */ + diplomat::result set_language(const std::string_view bytes); + + /** + * Write a string representation of [`ICU4XLocale`] region to `write` + * + * See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.id) for more information. + */ + template diplomat::result region_to_writeable(W& write) const; + + /** + * Write a string representation of [`ICU4XLocale`] region to `write` + * + * See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.id) for more information. + */ + diplomat::result region() const; + + /** + * Set the region part of the [`ICU4XLocale`]. + * + * See the [Rust documentation for `try_from_bytes`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.try_from_bytes) for more information. + */ + diplomat::result set_region(const std::string_view bytes); + + /** + * Write a string representation of [`ICU4XLocale`] script to `write` + * + * See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.id) for more information. + */ + template diplomat::result script_to_writeable(W& write) const; + + /** + * Write a string representation of [`ICU4XLocale`] script to `write` + * + * See the [Rust documentation for `id`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.id) for more information. + */ + diplomat::result script() const; + + /** + * Set the script part of the [`ICU4XLocale`]. Pass an empty string to remove the script. + * + * See the [Rust documentation for `try_from_bytes`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.try_from_bytes) for more information. + */ + diplomat::result set_script(const std::string_view bytes); + + /** + * Best effort locale canonicalizer that doesn't need any data + * + * Use ICU4XLocaleCanonicalizer for better control and functionality + * + * See the [Rust documentation for `canonicalize`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.canonicalize) for more information. + */ + template static diplomat::result canonicalize_to_writeable(const std::string_view bytes, W& write); + + /** + * Best effort locale canonicalizer that doesn't need any data + * + * Use ICU4XLocaleCanonicalizer for better control and functionality + * + * See the [Rust documentation for `canonicalize`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.canonicalize) for more information. + */ + static diplomat::result canonicalize(const std::string_view bytes); + + /** + * Write a string representation of [`ICU4XLocale`] to `write` + * + * See the [Rust documentation for `write_to`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.write_to) for more information. + */ + template diplomat::result to_string_to_writeable(W& write) const; + + /** + * Write a string representation of [`ICU4XLocale`] to `write` + * + * See the [Rust documentation for `write_to`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.write_to) for more information. + */ + diplomat::result to_string() const; + + /** + * + * + * See the [Rust documentation for `normalizing_eq`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.normalizing_eq) for more information. + */ + bool normalizing_eq(const std::string_view other) const; + + /** + * + * + * See the [Rust documentation for `strict_cmp`](https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.strict_cmp) for more information. + */ + ICU4XOrdering strict_cmp(const std::string_view other) const; + + /** + * Construct an [`ICU4XLocale`] for the English language. + * + * This convenience constructor is intended for testing only + * and requires the `provider_test` feature. + */ + static ICU4XLocale create_en(); + + /** + * Construct an [`ICU4XLocale`] for the Bangla language. + * + * This convenience constructor is intended for testing only + * and requires the `provider_test` feature. + */ + static ICU4XLocale create_bn(); + inline const capi::ICU4XLocale* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XLocale* AsFFIMut() { return this->inner.get(); } + inline ICU4XLocale(capi::ICU4XLocale* i) : inner(i) {} + ICU4XLocale() = default; + ICU4XLocale(ICU4XLocale&&) noexcept = default; + ICU4XLocale& operator=(ICU4XLocale&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline diplomat::result ICU4XLocale::create_from_string(const std::string_view name) { + auto diplomat_result_raw_out_value = capi::ICU4XLocale_create_from_string(name.data(), name.size()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XLocale(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XLocale ICU4XLocale::create_und() { + return ICU4XLocale(capi::ICU4XLocale_create_und()); +} +inline ICU4XLocale ICU4XLocale::clone() const { + return ICU4XLocale(capi::ICU4XLocale_clone(this->inner.get())); +} +template inline diplomat::result ICU4XLocale::basename_to_writeable(W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XLocale_basename(this->inner.get(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XLocale::basename() const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XLocale_basename(this->inner.get(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +template inline diplomat::result ICU4XLocale::get_unicode_extension_to_writeable(const std::string_view bytes, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XLocale_get_unicode_extension(this->inner.get(), bytes.data(), bytes.size(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XLocale::get_unicode_extension(const std::string_view bytes) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XLocale_get_unicode_extension(this->inner.get(), bytes.data(), bytes.size(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +template inline diplomat::result ICU4XLocale::language_to_writeable(W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XLocale_language(this->inner.get(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XLocale::language() const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XLocale_language(this->inner.get(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +inline diplomat::result ICU4XLocale::set_language(const std::string_view bytes) { + auto diplomat_result_raw_out_value = capi::ICU4XLocale_set_language(this->inner.get(), bytes.data(), bytes.size()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +template inline diplomat::result ICU4XLocale::region_to_writeable(W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XLocale_region(this->inner.get(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XLocale::region() const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XLocale_region(this->inner.get(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +inline diplomat::result ICU4XLocale::set_region(const std::string_view bytes) { + auto diplomat_result_raw_out_value = capi::ICU4XLocale_set_region(this->inner.get(), bytes.data(), bytes.size()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +template inline diplomat::result ICU4XLocale::script_to_writeable(W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XLocale_script(this->inner.get(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XLocale::script() const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XLocale_script(this->inner.get(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +inline diplomat::result ICU4XLocale::set_script(const std::string_view bytes) { + auto diplomat_result_raw_out_value = capi::ICU4XLocale_set_script(this->inner.get(), bytes.data(), bytes.size()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +template inline diplomat::result ICU4XLocale::canonicalize_to_writeable(const std::string_view bytes, W& write) { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XLocale_canonicalize(bytes.data(), bytes.size(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XLocale::canonicalize(const std::string_view bytes) { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XLocale_canonicalize(bytes.data(), bytes.size(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +template inline diplomat::result ICU4XLocale::to_string_to_writeable(W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XLocale_to_string(this->inner.get(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XLocale::to_string() const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XLocale_to_string(this->inner.get(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +inline bool ICU4XLocale::normalizing_eq(const std::string_view other) const { + return capi::ICU4XLocale_normalizing_eq(this->inner.get(), other.data(), other.size()); +} +inline ICU4XOrdering ICU4XLocale::strict_cmp(const std::string_view other) const { + return static_cast(capi::ICU4XLocale_strict_cmp(this->inner.get(), other.data(), other.size())); +} +inline ICU4XLocale ICU4XLocale::create_en() { + return ICU4XLocale(capi::ICU4XLocale_create_en()); +} +inline ICU4XLocale ICU4XLocale::create_bn() { + return ICU4XLocale(capi::ICU4XLocale_create_bn()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLocaleCanonicalizer.h b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleCanonicalizer.h new file mode 100644 index 000000000000..8b48ad8bb602 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleCanonicalizer.h @@ -0,0 +1,37 @@ +#ifndef ICU4XLocaleCanonicalizer_H +#define ICU4XLocaleCanonicalizer_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLocaleCanonicalizer ICU4XLocaleCanonicalizer; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError.h" +#include "ICU4XLocale.h" +#include "ICU4XTransformResult.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError ICU4XLocaleCanonicalizer_create(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError ICU4XLocaleCanonicalizer_create_extended(const ICU4XDataProvider* provider); + +ICU4XTransformResult ICU4XLocaleCanonicalizer_canonicalize(const ICU4XLocaleCanonicalizer* self, ICU4XLocale* locale); +void ICU4XLocaleCanonicalizer_destroy(ICU4XLocaleCanonicalizer* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLocaleCanonicalizer.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleCanonicalizer.hpp new file mode 100644 index 000000000000..2508a9219a93 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleCanonicalizer.hpp @@ -0,0 +1,93 @@ +#ifndef ICU4XLocaleCanonicalizer_HPP +#define ICU4XLocaleCanonicalizer_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XLocaleCanonicalizer.h" + +class ICU4XDataProvider; +class ICU4XLocaleCanonicalizer; +#include "ICU4XError.hpp" +class ICU4XLocale; +#include "ICU4XTransformResult.hpp" + +/** + * A destruction policy for using ICU4XLocaleCanonicalizer with std::unique_ptr. + */ +struct ICU4XLocaleCanonicalizerDeleter { + void operator()(capi::ICU4XLocaleCanonicalizer* l) const noexcept { + capi::ICU4XLocaleCanonicalizer_destroy(l); + } +}; + +/** + * A locale canonicalizer. + * + * See the [Rust documentation for `LocaleCanonicalizer`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleCanonicalizer.html) for more information. + */ +class ICU4XLocaleCanonicalizer { + public: + + /** + * Create a new [`ICU4XLocaleCanonicalizer`]. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleCanonicalizer.html#method.try_new_unstable) for more information. + */ + static diplomat::result create(const ICU4XDataProvider& provider); + + /** + * Create a new [`ICU4XLocaleCanonicalizer`] with extended data. + * + * See the [Rust documentation for `try_new_with_expander_unstable`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleCanonicalizer.html#method.try_new_with_expander_unstable) for more information. + */ + static diplomat::result create_extended(const ICU4XDataProvider& provider); + + /** + * FFI version of `LocaleCanonicalizer::canonicalize()`. + * + * See the [Rust documentation for `canonicalize`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleCanonicalizer.html#method.canonicalize) for more information. + */ + ICU4XTransformResult canonicalize(ICU4XLocale& locale) const; + inline const capi::ICU4XLocaleCanonicalizer* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XLocaleCanonicalizer* AsFFIMut() { return this->inner.get(); } + inline ICU4XLocaleCanonicalizer(capi::ICU4XLocaleCanonicalizer* i) : inner(i) {} + ICU4XLocaleCanonicalizer() = default; + ICU4XLocaleCanonicalizer(ICU4XLocaleCanonicalizer&&) noexcept = default; + ICU4XLocaleCanonicalizer& operator=(ICU4XLocaleCanonicalizer&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" + +inline diplomat::result ICU4XLocaleCanonicalizer::create(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XLocaleCanonicalizer_create(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XLocaleCanonicalizer(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XLocaleCanonicalizer::create_extended(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XLocaleCanonicalizer_create_extended(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XLocaleCanonicalizer(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XTransformResult ICU4XLocaleCanonicalizer::canonicalize(ICU4XLocale& locale) const { + return static_cast(capi::ICU4XLocaleCanonicalizer_canonicalize(this->inner.get(), locale.AsFFIMut())); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLocaleDisplayNamesFormatter.h b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleDisplayNamesFormatter.h new file mode 100644 index 000000000000..0e164017f485 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleDisplayNamesFormatter.h @@ -0,0 +1,36 @@ +#ifndef ICU4XLocaleDisplayNamesFormatter_H +#define ICU4XLocaleDisplayNamesFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLocaleDisplayNamesFormatter ICU4XLocaleDisplayNamesFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XDisplayNamesOptionsV1.h" +#include "diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError ICU4XLocaleDisplayNamesFormatter_try_new_unstable(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XDisplayNamesOptionsV1 options); + +diplomat_result_void_ICU4XError ICU4XLocaleDisplayNamesFormatter_of(const ICU4XLocaleDisplayNamesFormatter* self, const ICU4XLocale* locale, DiplomatWriteable* write); +void ICU4XLocaleDisplayNamesFormatter_destroy(ICU4XLocaleDisplayNamesFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLocaleDisplayNamesFormatter.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleDisplayNamesFormatter.hpp new file mode 100644 index 000000000000..b57493da212c --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleDisplayNamesFormatter.hpp @@ -0,0 +1,105 @@ +#ifndef ICU4XLocaleDisplayNamesFormatter_HPP +#define ICU4XLocaleDisplayNamesFormatter_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XLocaleDisplayNamesFormatter.h" + +class ICU4XDataProvider; +class ICU4XLocale; +struct ICU4XDisplayNamesOptionsV1; +class ICU4XLocaleDisplayNamesFormatter; +#include "ICU4XError.hpp" + +/** + * A destruction policy for using ICU4XLocaleDisplayNamesFormatter with std::unique_ptr. + */ +struct ICU4XLocaleDisplayNamesFormatterDeleter { + void operator()(capi::ICU4XLocaleDisplayNamesFormatter* l) const noexcept { + capi::ICU4XLocaleDisplayNamesFormatter_destroy(l); + } +}; + +/** + * + * + * See the [Rust documentation for `LocaleDisplayNamesFormatter`](https://docs.rs/icu/latest/icu/displaynames/struct.LocaleDisplayNamesFormatter.html) for more information. + */ +class ICU4XLocaleDisplayNamesFormatter { + public: + + /** + * Creates a new `LocaleDisplayNamesFormatter` from locale data and an options bag. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/displaynames/struct.LocaleDisplayNamesFormatter.html#method.try_new_unstable) for more information. + */ + static diplomat::result try_new_unstable(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XDisplayNamesOptionsV1 options); + + /** + * Returns the locale-specific display name of a locale. + * + * See the [Rust documentation for `of`](https://docs.rs/icu/latest/icu/displaynames/struct.LocaleDisplayNamesFormatter.html#method.of) for more information. + */ + template diplomat::result of_to_writeable(const ICU4XLocale& locale, W& write) const; + + /** + * Returns the locale-specific display name of a locale. + * + * See the [Rust documentation for `of`](https://docs.rs/icu/latest/icu/displaynames/struct.LocaleDisplayNamesFormatter.html#method.of) for more information. + */ + diplomat::result of(const ICU4XLocale& locale) const; + inline const capi::ICU4XLocaleDisplayNamesFormatter* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XLocaleDisplayNamesFormatter* AsFFIMut() { return this->inner.get(); } + inline ICU4XLocaleDisplayNamesFormatter(capi::ICU4XLocaleDisplayNamesFormatter* i) : inner(i) {} + ICU4XLocaleDisplayNamesFormatter() = default; + ICU4XLocaleDisplayNamesFormatter(ICU4XLocaleDisplayNamesFormatter&&) noexcept = default; + ICU4XLocaleDisplayNamesFormatter& operator=(ICU4XLocaleDisplayNamesFormatter&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" +#include "ICU4XDisplayNamesOptionsV1.hpp" + +inline diplomat::result ICU4XLocaleDisplayNamesFormatter::try_new_unstable(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XDisplayNamesOptionsV1 options) { + ICU4XDisplayNamesOptionsV1 diplomat_wrapped_struct_options = options; + auto diplomat_result_raw_out_value = capi::ICU4XLocaleDisplayNamesFormatter_try_new_unstable(provider.AsFFI(), locale.AsFFI(), capi::ICU4XDisplayNamesOptionsV1{ .style = static_cast(diplomat_wrapped_struct_options.style), .fallback = static_cast(diplomat_wrapped_struct_options.fallback), .language_display = static_cast(diplomat_wrapped_struct_options.language_display) }); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XLocaleDisplayNamesFormatter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +template inline diplomat::result ICU4XLocaleDisplayNamesFormatter::of_to_writeable(const ICU4XLocale& locale, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XLocaleDisplayNamesFormatter_of(this->inner.get(), locale.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XLocaleDisplayNamesFormatter::of(const ICU4XLocale& locale) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XLocaleDisplayNamesFormatter_of(this->inner.get(), locale.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLocaleExpander.h b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleExpander.h new file mode 100644 index 000000000000..a7de7be16b91 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleExpander.h @@ -0,0 +1,39 @@ +#ifndef ICU4XLocaleExpander_H +#define ICU4XLocaleExpander_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLocaleExpander ICU4XLocaleExpander; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XLocaleExpander_ICU4XError.h" +#include "ICU4XLocale.h" +#include "ICU4XTransformResult.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XLocaleExpander_ICU4XError ICU4XLocaleExpander_create(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XLocaleExpander_ICU4XError ICU4XLocaleExpander_create_extended(const ICU4XDataProvider* provider); + +ICU4XTransformResult ICU4XLocaleExpander_maximize(const ICU4XLocaleExpander* self, ICU4XLocale* locale); + +ICU4XTransformResult ICU4XLocaleExpander_minimize(const ICU4XLocaleExpander* self, ICU4XLocale* locale); +void ICU4XLocaleExpander_destroy(ICU4XLocaleExpander* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLocaleExpander.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleExpander.hpp new file mode 100644 index 000000000000..37b6fce71ab9 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleExpander.hpp @@ -0,0 +1,103 @@ +#ifndef ICU4XLocaleExpander_HPP +#define ICU4XLocaleExpander_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XLocaleExpander.h" + +class ICU4XDataProvider; +class ICU4XLocaleExpander; +#include "ICU4XError.hpp" +class ICU4XLocale; +#include "ICU4XTransformResult.hpp" + +/** + * A destruction policy for using ICU4XLocaleExpander with std::unique_ptr. + */ +struct ICU4XLocaleExpanderDeleter { + void operator()(capi::ICU4XLocaleExpander* l) const noexcept { + capi::ICU4XLocaleExpander_destroy(l); + } +}; + +/** + * A locale expander. + * + * See the [Rust documentation for `LocaleExpander`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html) for more information. + */ +class ICU4XLocaleExpander { + public: + + /** + * Create a new [`ICU4XLocaleExpander`]. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html#method.try_new_unstable) for more information. + */ + static diplomat::result create(const ICU4XDataProvider& provider); + + /** + * Create a new [`ICU4XLocaleExpander`] with extended data. + * + * See the [Rust documentation for `try_new_extended_unstable`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html#method.try_new_extended_unstable) for more information. + */ + static diplomat::result create_extended(const ICU4XDataProvider& provider); + + /** + * FFI version of `LocaleExpander::maximize()`. + * + * See the [Rust documentation for `maximize`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html#method.maximize) for more information. + */ + ICU4XTransformResult maximize(ICU4XLocale& locale) const; + + /** + * FFI version of `LocaleExpander::minimize()`. + * + * See the [Rust documentation for `minimize`](https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html#method.minimize) for more information. + */ + ICU4XTransformResult minimize(ICU4XLocale& locale) const; + inline const capi::ICU4XLocaleExpander* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XLocaleExpander* AsFFIMut() { return this->inner.get(); } + inline ICU4XLocaleExpander(capi::ICU4XLocaleExpander* i) : inner(i) {} + ICU4XLocaleExpander() = default; + ICU4XLocaleExpander(ICU4XLocaleExpander&&) noexcept = default; + ICU4XLocaleExpander& operator=(ICU4XLocaleExpander&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" + +inline diplomat::result ICU4XLocaleExpander::create(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XLocaleExpander_create(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XLocaleExpander(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XLocaleExpander::create_extended(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XLocaleExpander_create_extended(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XLocaleExpander(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XTransformResult ICU4XLocaleExpander::maximize(ICU4XLocale& locale) const { + return static_cast(capi::ICU4XLocaleExpander_maximize(this->inner.get(), locale.AsFFIMut())); +} +inline ICU4XTransformResult ICU4XLocaleExpander::minimize(ICU4XLocale& locale) const { + return static_cast(capi::ICU4XLocaleExpander_minimize(this->inner.get(), locale.AsFFIMut())); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackConfig.h b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackConfig.h new file mode 100644 index 000000000000..b3741e6bf0f5 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackConfig.h @@ -0,0 +1,33 @@ +#ifndef ICU4XLocaleFallbackConfig_H +#define ICU4XLocaleFallbackConfig_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XLocaleFallbackPriority.h" +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLocaleFallbackConfig { + ICU4XLocaleFallbackPriority priority; + DiplomatStringView extension_key; +} ICU4XLocaleFallbackConfig; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XLocaleFallbackPriority.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XLocaleFallbackConfig_destroy(ICU4XLocaleFallbackConfig* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackConfig.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackConfig.hpp new file mode 100644 index 000000000000..fc137c1335e3 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackConfig.hpp @@ -0,0 +1,37 @@ +#ifndef ICU4XLocaleFallbackConfig_HPP +#define ICU4XLocaleFallbackConfig_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XLocaleFallbackConfig.h" + +#include "ICU4XLocaleFallbackPriority.hpp" + + +/** + * Collection of configurations for the ICU4X fallback algorithm. + * + * See the [Rust documentation for `LocaleFallbackConfig`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackConfig.html) for more information. + */ +struct ICU4XLocaleFallbackConfig { + public: + + /** + * Choice of priority mode. + */ + ICU4XLocaleFallbackPriority priority; + + /** + * An empty string is considered `None`. + */ + std::string_view extension_key; +}; + + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackIterator.h b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackIterator.h new file mode 100644 index 000000000000..e2dd7a1a3bab --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackIterator.h @@ -0,0 +1,32 @@ +#ifndef ICU4XLocaleFallbackIterator_H +#define ICU4XLocaleFallbackIterator_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLocaleFallbackIterator ICU4XLocaleFallbackIterator; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XLocale.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +ICU4XLocale* ICU4XLocaleFallbackIterator_get(const ICU4XLocaleFallbackIterator* self); + +void ICU4XLocaleFallbackIterator_step(ICU4XLocaleFallbackIterator* self); +void ICU4XLocaleFallbackIterator_destroy(ICU4XLocaleFallbackIterator* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackIterator.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackIterator.hpp new file mode 100644 index 000000000000..bd44d40a94db --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackIterator.hpp @@ -0,0 +1,64 @@ +#ifndef ICU4XLocaleFallbackIterator_HPP +#define ICU4XLocaleFallbackIterator_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XLocaleFallbackIterator.h" + +class ICU4XLocale; + +/** + * A destruction policy for using ICU4XLocaleFallbackIterator with std::unique_ptr. + */ +struct ICU4XLocaleFallbackIteratorDeleter { + void operator()(capi::ICU4XLocaleFallbackIterator* l) const noexcept { + capi::ICU4XLocaleFallbackIterator_destroy(l); + } +}; + +/** + * An iterator over the locale under fallback. + * + * See the [Rust documentation for `LocaleFallbackIterator`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackIterator.html) for more information. + */ +class ICU4XLocaleFallbackIterator { + public: + + /** + * Gets a snapshot of the current state of the locale. + * + * See the [Rust documentation for `get`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackIterator.html#method.get) for more information. + */ + ICU4XLocale get() const; + + /** + * Performs one step of the fallback algorithm, mutating the locale. + * + * See the [Rust documentation for `step`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackIterator.html#method.step) for more information. + */ + void step(); + inline const capi::ICU4XLocaleFallbackIterator* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XLocaleFallbackIterator* AsFFIMut() { return this->inner.get(); } + inline ICU4XLocaleFallbackIterator(capi::ICU4XLocaleFallbackIterator* i) : inner(i) {} + ICU4XLocaleFallbackIterator() = default; + ICU4XLocaleFallbackIterator(ICU4XLocaleFallbackIterator&&) noexcept = default; + ICU4XLocaleFallbackIterator& operator=(ICU4XLocaleFallbackIterator&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XLocale.hpp" + +inline ICU4XLocale ICU4XLocaleFallbackIterator::get() const { + return ICU4XLocale(capi::ICU4XLocaleFallbackIterator_get(this->inner.get())); +} +inline void ICU4XLocaleFallbackIterator::step() { + capi::ICU4XLocaleFallbackIterator_step(this->inner.get()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackPriority.h b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackPriority.h new file mode 100644 index 000000000000..e4ab748065c8 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackPriority.h @@ -0,0 +1,32 @@ +#ifndef ICU4XLocaleFallbackPriority_H +#define ICU4XLocaleFallbackPriority_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XLocaleFallbackPriority { + ICU4XLocaleFallbackPriority_Language = 0, + ICU4XLocaleFallbackPriority_Region = 1, + ICU4XLocaleFallbackPriority_Collation = 2, +} ICU4XLocaleFallbackPriority; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XLocaleFallbackPriority_destroy(ICU4XLocaleFallbackPriority* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackPriority.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackPriority.hpp new file mode 100644 index 000000000000..5350a6697345 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackPriority.hpp @@ -0,0 +1,27 @@ +#ifndef ICU4XLocaleFallbackPriority_HPP +#define ICU4XLocaleFallbackPriority_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XLocaleFallbackPriority.h" + + + +/** + * Priority mode for the ICU4X fallback algorithm. + * + * See the [Rust documentation for `FallbackPriority`](https://docs.rs/icu_provider/latest/icu_provider/enum.FallbackPriority.html) for more information. + */ +enum struct ICU4XLocaleFallbackPriority { + Language = 0, + Region = 1, + Collation = 2, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbacker.h b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbacker.h new file mode 100644 index 000000000000..24efb0602f66 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbacker.h @@ -0,0 +1,37 @@ +#ifndef ICU4XLocaleFallbacker_H +#define ICU4XLocaleFallbacker_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLocaleFallbacker ICU4XLocaleFallbacker; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError.h" +#include "ICU4XLocaleFallbackConfig.h" +#include "diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError ICU4XLocaleFallbacker_create(const ICU4XDataProvider* provider); + +ICU4XLocaleFallbacker* ICU4XLocaleFallbacker_create_without_data(); + +diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError ICU4XLocaleFallbacker_for_config(const ICU4XLocaleFallbacker* self, ICU4XLocaleFallbackConfig config); +void ICU4XLocaleFallbacker_destroy(ICU4XLocaleFallbacker* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbacker.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbacker.hpp new file mode 100644 index 000000000000..1338622fc3d9 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbacker.hpp @@ -0,0 +1,97 @@ +#ifndef ICU4XLocaleFallbacker_HPP +#define ICU4XLocaleFallbacker_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XLocaleFallbacker.h" + +class ICU4XDataProvider; +class ICU4XLocaleFallbacker; +#include "ICU4XError.hpp" +struct ICU4XLocaleFallbackConfig; +class ICU4XLocaleFallbackerWithConfig; + +/** + * A destruction policy for using ICU4XLocaleFallbacker with std::unique_ptr. + */ +struct ICU4XLocaleFallbackerDeleter { + void operator()(capi::ICU4XLocaleFallbacker* l) const noexcept { + capi::ICU4XLocaleFallbacker_destroy(l); + } +}; + +/** + * An object that runs the ICU4X locale fallback algorithm. + * + * See the [Rust documentation for `LocaleFallbacker`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbacker.html) for more information. + */ +class ICU4XLocaleFallbacker { + public: + + /** + * Creates a new `ICU4XLocaleFallbacker` from a data provider. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbacker.html#method.try_new_unstable) for more information. + */ + static diplomat::result create(const ICU4XDataProvider& provider); + + /** + * Creates a new `ICU4XLocaleFallbacker` without data for limited functionality. + * + * See the [Rust documentation for `new_without_data`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbacker.html#method.new_without_data) for more information. + */ + static ICU4XLocaleFallbacker create_without_data(); + + /** + * Associates this `ICU4XLocaleFallbacker` with configuration options. + * + * See the [Rust documentation for `for_config`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbacker.html#method.for_config) for more information. + * + * Lifetimes: `this` must live at least as long as the output. + */ + diplomat::result for_config(ICU4XLocaleFallbackConfig config) const; + inline const capi::ICU4XLocaleFallbacker* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XLocaleFallbacker* AsFFIMut() { return this->inner.get(); } + inline ICU4XLocaleFallbacker(capi::ICU4XLocaleFallbacker* i) : inner(i) {} + ICU4XLocaleFallbacker() = default; + ICU4XLocaleFallbacker(ICU4XLocaleFallbacker&&) noexcept = default; + ICU4XLocaleFallbacker& operator=(ICU4XLocaleFallbacker&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocaleFallbackConfig.hpp" +#include "ICU4XLocaleFallbackerWithConfig.hpp" + +inline diplomat::result ICU4XLocaleFallbacker::create(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XLocaleFallbacker_create(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XLocaleFallbacker(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XLocaleFallbacker ICU4XLocaleFallbacker::create_without_data() { + return ICU4XLocaleFallbacker(capi::ICU4XLocaleFallbacker_create_without_data()); +} +inline diplomat::result ICU4XLocaleFallbacker::for_config(ICU4XLocaleFallbackConfig config) const { + ICU4XLocaleFallbackConfig diplomat_wrapped_struct_config = config; + auto diplomat_result_raw_out_value = capi::ICU4XLocaleFallbacker_for_config(this->inner.get(), capi::ICU4XLocaleFallbackConfig{ .priority = static_cast(diplomat_wrapped_struct_config.priority), .extension_key = { diplomat_wrapped_struct_config.extension_key.data(), diplomat_wrapped_struct_config.extension_key.size() } }); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XLocaleFallbackerWithConfig(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackerWithConfig.h b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackerWithConfig.h new file mode 100644 index 000000000000..e8baa9563e86 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackerWithConfig.h @@ -0,0 +1,31 @@ +#ifndef ICU4XLocaleFallbackerWithConfig_H +#define ICU4XLocaleFallbackerWithConfig_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLocaleFallbackerWithConfig ICU4XLocaleFallbackerWithConfig; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XLocale.h" +#include "ICU4XLocaleFallbackIterator.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +ICU4XLocaleFallbackIterator* ICU4XLocaleFallbackerWithConfig_fallback_for_locale(const ICU4XLocaleFallbackerWithConfig* self, const ICU4XLocale* locale); +void ICU4XLocaleFallbackerWithConfig_destroy(ICU4XLocaleFallbackerWithConfig* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackerWithConfig.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackerWithConfig.hpp new file mode 100644 index 000000000000..e885a806bb9b --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLocaleFallbackerWithConfig.hpp @@ -0,0 +1,58 @@ +#ifndef ICU4XLocaleFallbackerWithConfig_HPP +#define ICU4XLocaleFallbackerWithConfig_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XLocaleFallbackerWithConfig.h" + +class ICU4XLocale; +class ICU4XLocaleFallbackIterator; + +/** + * A destruction policy for using ICU4XLocaleFallbackerWithConfig with std::unique_ptr. + */ +struct ICU4XLocaleFallbackerWithConfigDeleter { + void operator()(capi::ICU4XLocaleFallbackerWithConfig* l) const noexcept { + capi::ICU4XLocaleFallbackerWithConfig_destroy(l); + } +}; + +/** + * An object that runs the ICU4X locale fallback algorithm with specific configurations. + * + * See the [Rust documentation for `LocaleFallbackerWithConfig`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackerWithConfig.html) for more information. + */ +class ICU4XLocaleFallbackerWithConfig { + public: + + /** + * Creates an iterator from a locale with each step of fallback. + * + * See the [Rust documentation for `fallback_for`](https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackerWithConfig.html#method.fallback_for) for more information. + * + * Lifetimes: `this` must live at least as long as the output. + */ + ICU4XLocaleFallbackIterator fallback_for_locale(const ICU4XLocale& locale) const; + inline const capi::ICU4XLocaleFallbackerWithConfig* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XLocaleFallbackerWithConfig* AsFFIMut() { return this->inner.get(); } + inline ICU4XLocaleFallbackerWithConfig(capi::ICU4XLocaleFallbackerWithConfig* i) : inner(i) {} + ICU4XLocaleFallbackerWithConfig() = default; + ICU4XLocaleFallbackerWithConfig(ICU4XLocaleFallbackerWithConfig&&) noexcept = default; + ICU4XLocaleFallbackerWithConfig& operator=(ICU4XLocaleFallbackerWithConfig&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XLocale.hpp" +#include "ICU4XLocaleFallbackIterator.hpp" + +inline ICU4XLocaleFallbackIterator ICU4XLocaleFallbackerWithConfig::fallback_for_locale(const ICU4XLocale& locale) const { + return ICU4XLocaleFallbackIterator(capi::ICU4XLocaleFallbackerWithConfig_fallback_for_locale(this->inner.get(), locale.AsFFI())); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLogger.h b/third_party/rust/icu_capi/cpp/include/ICU4XLogger.h new file mode 100644 index 000000000000..3c3a1b8fa321 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLogger.h @@ -0,0 +1,29 @@ +#ifndef ICU4XLogger_H +#define ICU4XLogger_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XLogger ICU4XLogger; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +bool ICU4XLogger_init_simple_logger(); +void ICU4XLogger_destroy(ICU4XLogger* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XLogger.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XLogger.hpp new file mode 100644 index 000000000000..0b894059c215 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XLogger.hpp @@ -0,0 +1,50 @@ +#ifndef ICU4XLogger_HPP +#define ICU4XLogger_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XLogger.h" + + +/** + * A destruction policy for using ICU4XLogger with std::unique_ptr. + */ +struct ICU4XLoggerDeleter { + void operator()(capi::ICU4XLogger* l) const noexcept { + capi::ICU4XLogger_destroy(l); + } +}; + +/** + * An object allowing control over the logging used + */ +class ICU4XLogger { + public: + + /** + * Initialize the logger from the `simple_logger` crate, which simply logs to + * stdout. Returns `false` if there was already a logger set, or if logging has not been + * compiled into the platform + */ + static bool init_simple_logger(); + inline const capi::ICU4XLogger* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XLogger* AsFFIMut() { return this->inner.get(); } + inline ICU4XLogger(capi::ICU4XLogger* i) : inner(i) {} + ICU4XLogger() = default; + ICU4XLogger(ICU4XLogger&&) noexcept = default; + ICU4XLogger& operator=(ICU4XLogger&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline bool ICU4XLogger::init_simple_logger() { + return capi::ICU4XLogger_init_simple_logger(); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XMetazoneCalculator.h b/third_party/rust/icu_capi/cpp/include/ICU4XMetazoneCalculator.h new file mode 100644 index 000000000000..9c66754e90eb --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XMetazoneCalculator.h @@ -0,0 +1,31 @@ +#ifndef ICU4XMetazoneCalculator_H +#define ICU4XMetazoneCalculator_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XMetazoneCalculator ICU4XMetazoneCalculator; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError ICU4XMetazoneCalculator_create(const ICU4XDataProvider* provider); +void ICU4XMetazoneCalculator_destroy(ICU4XMetazoneCalculator* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XMetazoneCalculator.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XMetazoneCalculator.hpp new file mode 100644 index 000000000000..c652bf876338 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XMetazoneCalculator.hpp @@ -0,0 +1,67 @@ +#ifndef ICU4XMetazoneCalculator_HPP +#define ICU4XMetazoneCalculator_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XMetazoneCalculator.h" + +class ICU4XDataProvider; +class ICU4XMetazoneCalculator; +#include "ICU4XError.hpp" + +/** + * A destruction policy for using ICU4XMetazoneCalculator with std::unique_ptr. + */ +struct ICU4XMetazoneCalculatorDeleter { + void operator()(capi::ICU4XMetazoneCalculator* l) const noexcept { + capi::ICU4XMetazoneCalculator_destroy(l); + } +}; + +/** + * An object capable of computing the metazone from a timezone. + * + * This can be used via `maybe_calculate_metazone()` on [`ICU4XCustomTimeZone`]. + * + * [`ICU4XCustomTimeZone`]: crate::timezone::ffi::ICU4XCustomTimeZone; + * + * See the [Rust documentation for `MetazoneCalculator`](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneCalculator.html) for more information. + */ +class ICU4XMetazoneCalculator { + public: + + /** + * + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/timezone/struct.MetazoneCalculator.html#method.try_new_unstable) for more information. + */ + static diplomat::result create(const ICU4XDataProvider& provider); + inline const capi::ICU4XMetazoneCalculator* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XMetazoneCalculator* AsFFIMut() { return this->inner.get(); } + inline ICU4XMetazoneCalculator(capi::ICU4XMetazoneCalculator* i) : inner(i) {} + ICU4XMetazoneCalculator() = default; + ICU4XMetazoneCalculator(ICU4XMetazoneCalculator&&) noexcept = default; + ICU4XMetazoneCalculator& operator=(ICU4XMetazoneCalculator&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" + +inline diplomat::result ICU4XMetazoneCalculator::create(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XMetazoneCalculator_create(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XMetazoneCalculator(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XOrdering.h b/third_party/rust/icu_capi/cpp/include/ICU4XOrdering.h new file mode 100644 index 000000000000..2c1885f43e2b --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XOrdering.h @@ -0,0 +1,32 @@ +#ifndef ICU4XOrdering_H +#define ICU4XOrdering_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XOrdering { + ICU4XOrdering_Less = -1, + ICU4XOrdering_Equal = 0, + ICU4XOrdering_Greater = 1, +} ICU4XOrdering; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XOrdering_destroy(ICU4XOrdering* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XOrdering.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XOrdering.hpp new file mode 100644 index 000000000000..9ca362aa6f99 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XOrdering.hpp @@ -0,0 +1,27 @@ +#ifndef ICU4XOrdering_HPP +#define ICU4XOrdering_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XOrdering.h" + + + +/** + * + * + * See the [Rust documentation for `Ordering`](https://docs.rs/core/latest/core/cmp/enum.Ordering.html) for more information. + */ +enum struct ICU4XOrdering { + Less = -1, + Equal = 0, + Greater = 1, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XPluralCategories.h b/third_party/rust/icu_capi/cpp/include/ICU4XPluralCategories.h new file mode 100644 index 000000000000..931ea2daa794 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XPluralCategories.h @@ -0,0 +1,35 @@ +#ifndef ICU4XPluralCategories_H +#define ICU4XPluralCategories_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XPluralCategories { + bool zero; + bool one; + bool two; + bool few; + bool many; + bool other; +} ICU4XPluralCategories; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XPluralCategories_destroy(ICU4XPluralCategories* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XPluralCategories.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XPluralCategories.hpp new file mode 100644 index 000000000000..c8b4a767a4e1 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XPluralCategories.hpp @@ -0,0 +1,30 @@ +#ifndef ICU4XPluralCategories_HPP +#define ICU4XPluralCategories_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XPluralCategories.h" + + + +/** + * FFI version of `PluralRules::categories()` data. + */ +struct ICU4XPluralCategories { + public: + bool zero; + bool one; + bool two; + bool few; + bool many; + bool other; +}; + + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XPluralCategory.h b/third_party/rust/icu_capi/cpp/include/ICU4XPluralCategory.h new file mode 100644 index 000000000000..543681c74646 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XPluralCategory.h @@ -0,0 +1,37 @@ +#ifndef ICU4XPluralCategory_H +#define ICU4XPluralCategory_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XPluralCategory { + ICU4XPluralCategory_Zero = 0, + ICU4XPluralCategory_One = 1, + ICU4XPluralCategory_Two = 2, + ICU4XPluralCategory_Few = 3, + ICU4XPluralCategory_Many = 4, + ICU4XPluralCategory_Other = 5, +} ICU4XPluralCategory; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_ICU4XPluralCategory_void.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_ICU4XPluralCategory_void ICU4XPluralCategory_get_for_cldr_string(const char* s_data, size_t s_len); +void ICU4XPluralCategory_destroy(ICU4XPluralCategory* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XPluralCategory.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XPluralCategory.hpp new file mode 100644 index 000000000000..24db42ec21bf --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XPluralCategory.hpp @@ -0,0 +1,30 @@ +#ifndef ICU4XPluralCategory_HPP +#define ICU4XPluralCategory_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XPluralCategory.h" + + + +/** + * FFI version of `PluralCategory`. + * + * See the [Rust documentation for `PluralCategory`](https://docs.rs/icu/latest/icu/plurals/enum.PluralCategory.html) for more information. + */ +enum struct ICU4XPluralCategory { + Zero = 0, + One = 1, + Two = 2, + Few = 3, + Many = 4, + Other = 5, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XPluralOperands.h b/third_party/rust/icu_capi/cpp/include/ICU4XPluralOperands.h new file mode 100644 index 000000000000..14d997555f78 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XPluralOperands.h @@ -0,0 +1,30 @@ +#ifndef ICU4XPluralOperands_H +#define ICU4XPluralOperands_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XPluralOperands ICU4XPluralOperands; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_box_ICU4XPluralOperands_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XPluralOperands_ICU4XError ICU4XPluralOperands_create_from_string(const char* s_data, size_t s_len); +void ICU4XPluralOperands_destroy(ICU4XPluralOperands* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XPluralOperands.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XPluralOperands.hpp new file mode 100644 index 000000000000..42fda2c94d00 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XPluralOperands.hpp @@ -0,0 +1,61 @@ +#ifndef ICU4XPluralOperands_HPP +#define ICU4XPluralOperands_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XPluralOperands.h" + +class ICU4XPluralOperands; +#include "ICU4XError.hpp" + +/** + * A destruction policy for using ICU4XPluralOperands with std::unique_ptr. + */ +struct ICU4XPluralOperandsDeleter { + void operator()(capi::ICU4XPluralOperands* l) const noexcept { + capi::ICU4XPluralOperands_destroy(l); + } +}; + +/** + * FFI version of `PluralOperands`. + * + * See the [Rust documentation for `PluralOperands`](https://docs.rs/icu/latest/icu/plurals/struct.PluralOperands.html) for more information. + */ +class ICU4XPluralOperands { + public: + + /** + * Construct for a given string representing a number + * + * See the [Rust documentation for `from_str`](https://docs.rs/icu/latest/icu/plurals/struct.PluralOperands.html#method.from_str) for more information. + */ + static diplomat::result create_from_string(const std::string_view s); + inline const capi::ICU4XPluralOperands* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XPluralOperands* AsFFIMut() { return this->inner.get(); } + inline ICU4XPluralOperands(capi::ICU4XPluralOperands* i) : inner(i) {} + ICU4XPluralOperands() = default; + ICU4XPluralOperands(ICU4XPluralOperands&&) noexcept = default; + ICU4XPluralOperands& operator=(ICU4XPluralOperands&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline diplomat::result ICU4XPluralOperands::create_from_string(const std::string_view s) { + auto diplomat_result_raw_out_value = capi::ICU4XPluralOperands_create_from_string(s.data(), s.size()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XPluralOperands(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XPluralRules.h b/third_party/rust/icu_capi/cpp/include/ICU4XPluralRules.h new file mode 100644 index 000000000000..0794a7ac8ef3 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XPluralRules.h @@ -0,0 +1,41 @@ +#ifndef ICU4XPluralRules_H +#define ICU4XPluralRules_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XPluralRules ICU4XPluralRules; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "diplomat_result_box_ICU4XPluralRules_ICU4XError.h" +#include "ICU4XPluralOperands.h" +#include "ICU4XPluralCategory.h" +#include "ICU4XPluralCategories.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XPluralRules_ICU4XError ICU4XPluralRules_create_cardinal(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +diplomat_result_box_ICU4XPluralRules_ICU4XError ICU4XPluralRules_create_ordinal(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +ICU4XPluralCategory ICU4XPluralRules_category_for(const ICU4XPluralRules* self, const ICU4XPluralOperands* op); + +ICU4XPluralCategories ICU4XPluralRules_categories(const ICU4XPluralRules* self); +void ICU4XPluralRules_destroy(ICU4XPluralRules* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XPluralRules.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XPluralRules.hpp new file mode 100644 index 000000000000..63929dc528fb --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XPluralRules.hpp @@ -0,0 +1,108 @@ +#ifndef ICU4XPluralRules_HPP +#define ICU4XPluralRules_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XPluralRules.h" + +class ICU4XDataProvider; +class ICU4XLocale; +class ICU4XPluralRules; +#include "ICU4XError.hpp" +class ICU4XPluralOperands; +#include "ICU4XPluralCategory.hpp" +struct ICU4XPluralCategories; + +/** + * A destruction policy for using ICU4XPluralRules with std::unique_ptr. + */ +struct ICU4XPluralRulesDeleter { + void operator()(capi::ICU4XPluralRules* l) const noexcept { + capi::ICU4XPluralRules_destroy(l); + } +}; + +/** + * FFI version of `PluralRules`. + * + * See the [Rust documentation for `PluralRules`](https://docs.rs/icu/latest/icu/plurals/struct.PluralRules.html) for more information. + */ +class ICU4XPluralRules { + public: + + /** + * Construct an [`ICU4XPluralRules`] for the given locale, for cardinal numbers + * + * See the [Rust documentation for `try_new_cardinal_unstable`](https://docs.rs/icu/latest/icu/plurals/struct.PluralRules.html#method.try_new_cardinal_unstable) for more information. + */ + static diplomat::result create_cardinal(const ICU4XDataProvider& provider, const ICU4XLocale& locale); + + /** + * Construct an [`ICU4XPluralRules`] for the given locale, for ordinal numbers + * + * See the [Rust documentation for `try_new_ordinal_unstable`](https://docs.rs/icu/latest/icu/plurals/struct.PluralRules.html#method.try_new_ordinal_unstable) for more information. + */ + static diplomat::result create_ordinal(const ICU4XDataProvider& provider, const ICU4XLocale& locale); + + /** + * 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. + */ + ICU4XPluralCategory category_for(const ICU4XPluralOperands& op) const; + + /** + * Get all of the categories needed in the current locale + * + * See the [Rust documentation for `categories`](https://docs.rs/icu/latest/icu/plurals/struct.PluralRules.html#method.categories) for more information. + */ + ICU4XPluralCategories categories() const; + inline const capi::ICU4XPluralRules* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XPluralRules* AsFFIMut() { return this->inner.get(); } + inline ICU4XPluralRules(capi::ICU4XPluralRules* i) : inner(i) {} + ICU4XPluralRules() = default; + ICU4XPluralRules(ICU4XPluralRules&&) noexcept = default; + ICU4XPluralRules& operator=(ICU4XPluralRules&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" +#include "ICU4XPluralOperands.hpp" +#include "ICU4XPluralCategories.hpp" + +inline diplomat::result ICU4XPluralRules::create_cardinal(const ICU4XDataProvider& provider, const ICU4XLocale& locale) { + auto diplomat_result_raw_out_value = capi::ICU4XPluralRules_create_cardinal(provider.AsFFI(), locale.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XPluralRules(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XPluralRules::create_ordinal(const ICU4XDataProvider& provider, const ICU4XLocale& locale) { + auto diplomat_result_raw_out_value = capi::ICU4XPluralRules_create_ordinal(provider.AsFFI(), locale.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XPluralRules(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XPluralCategory ICU4XPluralRules::category_for(const ICU4XPluralOperands& op) const { + return static_cast(capi::ICU4XPluralRules_category_for(this->inner.get(), op.AsFFI())); +} +inline ICU4XPluralCategories ICU4XPluralRules::categories() const { + capi::ICU4XPluralCategories diplomat_raw_struct_out_value = capi::ICU4XPluralRules_categories(this->inner.get()); + return ICU4XPluralCategories{ .zero = std::move(diplomat_raw_struct_out_value.zero), .one = std::move(diplomat_raw_struct_out_value.one), .two = std::move(diplomat_raw_struct_out_value.two), .few = std::move(diplomat_raw_struct_out_value.few), .many = std::move(diplomat_raw_struct_out_value.many), .other = std::move(diplomat_raw_struct_out_value.other) }; +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XPropertyValueNameToEnumMapper.h b/third_party/rust/icu_capi/cpp/include/ICU4XPropertyValueNameToEnumMapper.h new file mode 100644 index 000000000000..7598c1837204 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XPropertyValueNameToEnumMapper.h @@ -0,0 +1,49 @@ +#ifndef ICU4XPropertyValueNameToEnumMapper_H +#define ICU4XPropertyValueNameToEnumMapper_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XPropertyValueNameToEnumMapper ICU4XPropertyValueNameToEnumMapper; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int16_t ICU4XPropertyValueNameToEnumMapper_get_strict(const ICU4XPropertyValueNameToEnumMapper* self, const char* name_data, size_t name_len); + +int16_t ICU4XPropertyValueNameToEnumMapper_get_loose(const ICU4XPropertyValueNameToEnumMapper* self, const char* name_data, size_t name_len); + +diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError ICU4XPropertyValueNameToEnumMapper_load_general_category(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError ICU4XPropertyValueNameToEnumMapper_load_bidi_class(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError ICU4XPropertyValueNameToEnumMapper_load_east_asian_width(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError ICU4XPropertyValueNameToEnumMapper_load_line_break(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError ICU4XPropertyValueNameToEnumMapper_load_grapheme_cluster_break(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError ICU4XPropertyValueNameToEnumMapper_load_word_break(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError ICU4XPropertyValueNameToEnumMapper_load_sentence_break(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError ICU4XPropertyValueNameToEnumMapper_load_script(const ICU4XDataProvider* provider); +void ICU4XPropertyValueNameToEnumMapper_destroy(ICU4XPropertyValueNameToEnumMapper* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XPropertyValueNameToEnumMapper.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XPropertyValueNameToEnumMapper.hpp new file mode 100644 index 000000000000..407780c36734 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XPropertyValueNameToEnumMapper.hpp @@ -0,0 +1,208 @@ +#ifndef ICU4XPropertyValueNameToEnumMapper_HPP +#define ICU4XPropertyValueNameToEnumMapper_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XPropertyValueNameToEnumMapper.h" + +class ICU4XDataProvider; +class ICU4XPropertyValueNameToEnumMapper; +#include "ICU4XError.hpp" + +/** + * A destruction policy for using ICU4XPropertyValueNameToEnumMapper with std::unique_ptr. + */ +struct ICU4XPropertyValueNameToEnumMapperDeleter { + void operator()(capi::ICU4XPropertyValueNameToEnumMapper* l) const noexcept { + capi::ICU4XPropertyValueNameToEnumMapper_destroy(l); + } +}; + +/** + * A type capable of looking up a property value from a string name. + * + * See the [Rust documentation for `PropertyValueNameToEnumMapper`](https://docs.rs/icu/latest/icu/properties/names/struct.PropertyValueNameToEnumMapper.html) for more information. + * + * See the [Rust documentation for `PropertyValueNameToEnumMapperBorrowed`](https://docs.rs/icu/latest/icu/properties/names/struct.PropertyValueNameToEnumMapperBorrowed.html) for more information. + */ +class ICU4XPropertyValueNameToEnumMapper { + public: + + /** + * Get the property value matching the given name, using strict matching + * + * Returns -1 if the name is unknown for this property + * + * See the [Rust documentation for `get_strict`](https://docs.rs/icu/latest/icu/properties/names/struct.PropertyValueNameToEnumMapperBorrowed.html#method.get_strict) for more information. + */ + int16_t get_strict(const std::string_view name) const; + + /** + * Get the property value matching the given name, using loose matching + * + * Returns -1 if the name is unknown for this property + * + * See the [Rust documentation for `get_loose`](https://docs.rs/icu/latest/icu/properties/names/struct.PropertyValueNameToEnumMapperBorrowed.html#method.get_loose) for more information. + */ + int16_t get_loose(const std::string_view name) const; + + /** + * + * + * See the [Rust documentation for `get_name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.GeneralCategory.html#method.get_name_to_enum_mapper) for more information. + */ + static diplomat::result load_general_category(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `get_name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.BidiClass.html#method.get_name_to_enum_mapper) for more information. + */ + static diplomat::result load_bidi_class(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `get_name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.EastAsianWidth.html#method.get_name_to_enum_mapper) for more information. + */ + static diplomat::result load_east_asian_width(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `get_name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.LineBreak.html#method.get_name_to_enum_mapper) for more information. + */ + static diplomat::result load_line_break(const ICU4XDataProvider& provider); + + /** + * + * + * 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. + */ + static diplomat::result load_grapheme_cluster_break(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `get_name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.WordBreak.html#method.get_name_to_enum_mapper) for more information. + */ + static diplomat::result load_word_break(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `get_name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.SentenceBreak.html#method.get_name_to_enum_mapper) for more information. + */ + static diplomat::result load_sentence_break(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `get_name_to_enum_mapper`](https://docs.rs/icu/latest/icu/properties/struct.Script.html#method.get_name_to_enum_mapper) for more information. + */ + static diplomat::result load_script(const ICU4XDataProvider& provider); + inline const capi::ICU4XPropertyValueNameToEnumMapper* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XPropertyValueNameToEnumMapper* AsFFIMut() { return this->inner.get(); } + inline ICU4XPropertyValueNameToEnumMapper(capi::ICU4XPropertyValueNameToEnumMapper* i) : inner(i) {} + ICU4XPropertyValueNameToEnumMapper() = default; + ICU4XPropertyValueNameToEnumMapper(ICU4XPropertyValueNameToEnumMapper&&) noexcept = default; + ICU4XPropertyValueNameToEnumMapper& operator=(ICU4XPropertyValueNameToEnumMapper&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" + +inline int16_t ICU4XPropertyValueNameToEnumMapper::get_strict(const std::string_view name) const { + return capi::ICU4XPropertyValueNameToEnumMapper_get_strict(this->inner.get(), name.data(), name.size()); +} +inline int16_t ICU4XPropertyValueNameToEnumMapper::get_loose(const std::string_view name) const { + return capi::ICU4XPropertyValueNameToEnumMapper_get_loose(this->inner.get(), name.data(), name.size()); +} +inline diplomat::result ICU4XPropertyValueNameToEnumMapper::load_general_category(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XPropertyValueNameToEnumMapper_load_general_category(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XPropertyValueNameToEnumMapper(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XPropertyValueNameToEnumMapper::load_bidi_class(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XPropertyValueNameToEnumMapper_load_bidi_class(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XPropertyValueNameToEnumMapper(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XPropertyValueNameToEnumMapper::load_east_asian_width(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XPropertyValueNameToEnumMapper_load_east_asian_width(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XPropertyValueNameToEnumMapper(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XPropertyValueNameToEnumMapper::load_line_break(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XPropertyValueNameToEnumMapper_load_line_break(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XPropertyValueNameToEnumMapper(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XPropertyValueNameToEnumMapper::load_grapheme_cluster_break(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XPropertyValueNameToEnumMapper_load_grapheme_cluster_break(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XPropertyValueNameToEnumMapper(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XPropertyValueNameToEnumMapper::load_word_break(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XPropertyValueNameToEnumMapper_load_word_break(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XPropertyValueNameToEnumMapper(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XPropertyValueNameToEnumMapper::load_sentence_break(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XPropertyValueNameToEnumMapper_load_sentence_break(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XPropertyValueNameToEnumMapper(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XPropertyValueNameToEnumMapper::load_script(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XPropertyValueNameToEnumMapper_load_script(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XPropertyValueNameToEnumMapper(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XRegionDisplayNames.h b/third_party/rust/icu_capi/cpp/include/ICU4XRegionDisplayNames.h new file mode 100644 index 000000000000..aa8a65020395 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XRegionDisplayNames.h @@ -0,0 +1,35 @@ +#ifndef ICU4XRegionDisplayNames_H +#define ICU4XRegionDisplayNames_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XRegionDisplayNames ICU4XRegionDisplayNames; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError.h" +#include "diplomat_result_void_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError ICU4XRegionDisplayNames_try_new_unstable(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +diplomat_result_void_ICU4XError ICU4XRegionDisplayNames_of(const ICU4XRegionDisplayNames* self, const char* region_data, size_t region_len, DiplomatWriteable* write); +void ICU4XRegionDisplayNames_destroy(ICU4XRegionDisplayNames* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XRegionDisplayNames.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XRegionDisplayNames.hpp new file mode 100644 index 000000000000..44cc8625a73b --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XRegionDisplayNames.hpp @@ -0,0 +1,106 @@ +#ifndef ICU4XRegionDisplayNames_HPP +#define ICU4XRegionDisplayNames_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XRegionDisplayNames.h" + +class ICU4XDataProvider; +class ICU4XLocale; +class ICU4XRegionDisplayNames; +#include "ICU4XError.hpp" + +/** + * A destruction policy for using ICU4XRegionDisplayNames with std::unique_ptr. + */ +struct ICU4XRegionDisplayNamesDeleter { + void operator()(capi::ICU4XRegionDisplayNames* l) const noexcept { + capi::ICU4XRegionDisplayNames_destroy(l); + } +}; + +/** + * + * + * See the [Rust documentation for `RegionDisplayNames`](https://docs.rs/icu/latest/icu/displaynames/struct.RegionDisplayNames.html) for more information. + */ +class ICU4XRegionDisplayNames { + public: + + /** + * Creates a new `RegionDisplayNames` from locale data and an options bag. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/displaynames/struct.RegionDisplayNames.html#method.try_new_unstable) for more information. + */ + static diplomat::result try_new_unstable(const ICU4XDataProvider& provider, const ICU4XLocale& locale); + + /** + * Returns the locale specific display name of a region. + * Note that the funtion returns an empty string in case the display name for a given + * region code is not found. + * + * See the [Rust documentation for `of`](https://docs.rs/icu/latest/icu/displaynames/struct.RegionDisplayNames.html#method.of) for more information. + */ + template diplomat::result of_to_writeable(const std::string_view region, W& write) const; + + /** + * Returns the locale specific display name of a region. + * Note that the funtion returns an empty string in case the display name for a given + * region code is not found. + * + * See the [Rust documentation for `of`](https://docs.rs/icu/latest/icu/displaynames/struct.RegionDisplayNames.html#method.of) for more information. + */ + diplomat::result of(const std::string_view region) const; + inline const capi::ICU4XRegionDisplayNames* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XRegionDisplayNames* AsFFIMut() { return this->inner.get(); } + inline ICU4XRegionDisplayNames(capi::ICU4XRegionDisplayNames* i) : inner(i) {} + ICU4XRegionDisplayNames() = default; + ICU4XRegionDisplayNames(ICU4XRegionDisplayNames&&) noexcept = default; + ICU4XRegionDisplayNames& operator=(ICU4XRegionDisplayNames&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" + +inline diplomat::result ICU4XRegionDisplayNames::try_new_unstable(const ICU4XDataProvider& provider, const ICU4XLocale& locale) { + auto diplomat_result_raw_out_value = capi::ICU4XRegionDisplayNames_try_new_unstable(provider.AsFFI(), locale.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XRegionDisplayNames(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +template inline diplomat::result ICU4XRegionDisplayNames::of_to_writeable(const std::string_view region, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XRegionDisplayNames_of(this->inner.get(), region.data(), region.size(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XRegionDisplayNames::of(const std::string_view region) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XRegionDisplayNames_of(this->inner.get(), region.data(), region.size(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XReorderedIndexMap.h b/third_party/rust/icu_capi/cpp/include/ICU4XReorderedIndexMap.h new file mode 100644 index 000000000000..f5507a72178f --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XReorderedIndexMap.h @@ -0,0 +1,33 @@ +#ifndef ICU4XReorderedIndexMap_H +#define ICU4XReorderedIndexMap_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XReorderedIndexMap ICU4XReorderedIndexMap; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +DiplomatUsizeView ICU4XReorderedIndexMap_as_slice(const ICU4XReorderedIndexMap* self); + +size_t ICU4XReorderedIndexMap_len(const ICU4XReorderedIndexMap* self); + +size_t ICU4XReorderedIndexMap_get(const ICU4XReorderedIndexMap* self, size_t index); +void ICU4XReorderedIndexMap_destroy(ICU4XReorderedIndexMap* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XReorderedIndexMap.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XReorderedIndexMap.hpp new file mode 100644 index 000000000000..1fe4270baa8f --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XReorderedIndexMap.hpp @@ -0,0 +1,74 @@ +#ifndef ICU4XReorderedIndexMap_HPP +#define ICU4XReorderedIndexMap_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XReorderedIndexMap.h" + + +/** + * A destruction policy for using ICU4XReorderedIndexMap with std::unique_ptr. + */ +struct ICU4XReorderedIndexMapDeleter { + void operator()(capi::ICU4XReorderedIndexMap* l) const noexcept { + capi::ICU4XReorderedIndexMap_destroy(l); + } +}; + +/** + * Thin wrapper around a vector that maps visual indices to source indices + * + * `map[visualIndex] = sourceIndex` + * + * Produced by `reorder_visual()` on [`ICU4XBidi`]. + */ +class ICU4XReorderedIndexMap { + public: + + /** + * Get this as a slice/array of indices + * + * Lifetimes: `this` must live at least as long as the output. + */ + const diplomat::span as_slice() const; + + /** + * The length of this map + */ + size_t len() const; + + /** + * Get element at `index`. Returns 0 when out of bounds + * (note that 0 is also a valid in-bounds value, please use `len()` + * to avoid out-of-bounds) + */ + size_t get(size_t index) const; + inline const capi::ICU4XReorderedIndexMap* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XReorderedIndexMap* AsFFIMut() { return this->inner.get(); } + inline ICU4XReorderedIndexMap(capi::ICU4XReorderedIndexMap* i) : inner(i) {} + ICU4XReorderedIndexMap() = default; + ICU4XReorderedIndexMap(ICU4XReorderedIndexMap&&) noexcept = default; + ICU4XReorderedIndexMap& operator=(ICU4XReorderedIndexMap&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline const diplomat::span ICU4XReorderedIndexMap::as_slice() const { + capi::DiplomatUsizeView diplomat_slice_raw_out_value = capi::ICU4XReorderedIndexMap_as_slice(this->inner.get()); + diplomat::span slice(diplomat_slice_raw_out_value.data, diplomat_slice_raw_out_value.len); + return slice; +} +inline size_t ICU4XReorderedIndexMap::len() const { + return capi::ICU4XReorderedIndexMap_len(this->inner.get()); +} +inline size_t ICU4XReorderedIndexMap::get(size_t index) const { + return capi::ICU4XReorderedIndexMap_get(this->inner.get(), index); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XScriptExtensionsSet.h b/third_party/rust/icu_capi/cpp/include/ICU4XScriptExtensionsSet.h new file mode 100644 index 000000000000..b4982dc22c34 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XScriptExtensionsSet.h @@ -0,0 +1,34 @@ +#ifndef ICU4XScriptExtensionsSet_H +#define ICU4XScriptExtensionsSet_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XScriptExtensionsSet ICU4XScriptExtensionsSet; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_uint16_t_void.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +bool ICU4XScriptExtensionsSet_contains(const ICU4XScriptExtensionsSet* self, uint16_t script); + +size_t ICU4XScriptExtensionsSet_count(const ICU4XScriptExtensionsSet* self); + +diplomat_result_uint16_t_void ICU4XScriptExtensionsSet_script_at(const ICU4XScriptExtensionsSet* self, size_t index); +void ICU4XScriptExtensionsSet_destroy(ICU4XScriptExtensionsSet* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XScriptExtensionsSet.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XScriptExtensionsSet.hpp new file mode 100644 index 000000000000..6eff599705aa --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XScriptExtensionsSet.hpp @@ -0,0 +1,79 @@ +#ifndef ICU4XScriptExtensionsSet_HPP +#define ICU4XScriptExtensionsSet_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XScriptExtensionsSet.h" + + +/** + * A destruction policy for using ICU4XScriptExtensionsSet with std::unique_ptr. + */ +struct ICU4XScriptExtensionsSetDeleter { + void operator()(capi::ICU4XScriptExtensionsSet* l) const noexcept { + capi::ICU4XScriptExtensionsSet_destroy(l); + } +}; + +/** + * 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. + */ +class ICU4XScriptExtensionsSet { + public: + + /** + * Check if the Script_Extensions property of the given code point covers the given script + * + * See the [Rust documentation for `contains`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html#method.contains) for more information. + */ + bool contains(uint16_t script) const; + + /** + * Get the number of scripts contained in here + * + * See the [Rust documentation for `iter`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html#method.iter) for more information. + */ + size_t count() const; + + /** + * Get script at index, returning an error if out of bounds + * + * See the [Rust documentation for `iter`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html#method.iter) for more information. + */ + diplomat::result script_at(size_t index) const; + inline const capi::ICU4XScriptExtensionsSet* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XScriptExtensionsSet* AsFFIMut() { return this->inner.get(); } + inline ICU4XScriptExtensionsSet(capi::ICU4XScriptExtensionsSet* i) : inner(i) {} + ICU4XScriptExtensionsSet() = default; + ICU4XScriptExtensionsSet(ICU4XScriptExtensionsSet&&) noexcept = default; + ICU4XScriptExtensionsSet& operator=(ICU4XScriptExtensionsSet&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline bool ICU4XScriptExtensionsSet::contains(uint16_t script) const { + return capi::ICU4XScriptExtensionsSet_contains(this->inner.get(), script); +} +inline size_t ICU4XScriptExtensionsSet::count() const { + return capi::ICU4XScriptExtensionsSet_count(this->inner.get()); +} +inline diplomat::result ICU4XScriptExtensionsSet::script_at(size_t index) const { + auto diplomat_result_raw_out_value = capi::ICU4XScriptExtensionsSet_script_at(this->inner.get(), index); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(diplomat_result_raw_out_value.ok)); + } else { + diplomat_result_out_value = diplomat::Err(std::monostate()); + } + return diplomat_result_out_value; +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XScriptWithExtensions.h b/third_party/rust/icu_capi/cpp/include/ICU4XScriptWithExtensions.h new file mode 100644 index 000000000000..df2dd5394649 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XScriptWithExtensions.h @@ -0,0 +1,41 @@ +#ifndef ICU4XScriptWithExtensions_H +#define ICU4XScriptWithExtensions_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XScriptWithExtensions ICU4XScriptWithExtensions; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError.h" +#include "ICU4XScriptWithExtensionsBorrowed.h" +#include "CodePointRangeIterator.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError ICU4XScriptWithExtensions_create(const ICU4XDataProvider* provider); + +uint16_t ICU4XScriptWithExtensions_get_script_val(const ICU4XScriptWithExtensions* self, uint32_t code_point); + +bool ICU4XScriptWithExtensions_has_script(const ICU4XScriptWithExtensions* self, uint32_t code_point, uint16_t script); + +ICU4XScriptWithExtensionsBorrowed* ICU4XScriptWithExtensions_as_borrowed(const ICU4XScriptWithExtensions* self); + +CodePointRangeIterator* ICU4XScriptWithExtensions_iter_ranges_for_script(const ICU4XScriptWithExtensions* self, uint16_t script); +void ICU4XScriptWithExtensions_destroy(ICU4XScriptWithExtensions* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XScriptWithExtensions.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XScriptWithExtensions.hpp new file mode 100644 index 000000000000..d548d197f0f7 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XScriptWithExtensions.hpp @@ -0,0 +1,111 @@ +#ifndef ICU4XScriptWithExtensions_HPP +#define ICU4XScriptWithExtensions_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XScriptWithExtensions.h" + +class ICU4XDataProvider; +class ICU4XScriptWithExtensions; +#include "ICU4XError.hpp" +class ICU4XScriptWithExtensionsBorrowed; +class CodePointRangeIterator; + +/** + * A destruction policy for using ICU4XScriptWithExtensions with std::unique_ptr. + */ +struct ICU4XScriptWithExtensionsDeleter { + void operator()(capi::ICU4XScriptWithExtensions* l) const noexcept { + capi::ICU4XScriptWithExtensions_destroy(l); + } +}; + +/** + * 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. + */ +class ICU4XScriptWithExtensions { + public: + + /** + * + * + * See the [Rust documentation for `load_script_with_extensions_unstable`](https://docs.rs/icu/latest/icu/properties/script/fn.load_script_with_extensions_unstable.html) for more information. + */ + static diplomat::result create(const ICU4XDataProvider& provider); + + /** + * 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. + */ + uint16_t get_script_val(uint32_t code_point) const; + + /** + * 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 has_script(uint32_t code_point, uint16_t script) const; + + /** + * Borrow this object for a slightly faster variant with more operations + * + * See the [Rust documentation for `as_borrowed`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensions.html#method.as_borrowed) for more information. + * + * Lifetimes: `this` must live at least as long as the output. + */ + ICU4XScriptWithExtensionsBorrowed as_borrowed() const; + + /** + * Get a list of ranges of code points that contain this script in their Script_Extensions values + * + * See the [Rust documentation for `get_script_extensions_ranges`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.get_script_extensions_ranges) for more information. + * + * Lifetimes: `this` must live at least as long as the output. + */ + CodePointRangeIterator iter_ranges_for_script(uint16_t script) const; + inline const capi::ICU4XScriptWithExtensions* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XScriptWithExtensions* AsFFIMut() { return this->inner.get(); } + inline ICU4XScriptWithExtensions(capi::ICU4XScriptWithExtensions* i) : inner(i) {} + ICU4XScriptWithExtensions() = default; + ICU4XScriptWithExtensions(ICU4XScriptWithExtensions&&) noexcept = default; + ICU4XScriptWithExtensions& operator=(ICU4XScriptWithExtensions&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XScriptWithExtensionsBorrowed.hpp" +#include "CodePointRangeIterator.hpp" + +inline diplomat::result ICU4XScriptWithExtensions::create(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XScriptWithExtensions_create(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XScriptWithExtensions(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline uint16_t ICU4XScriptWithExtensions::get_script_val(uint32_t code_point) const { + return capi::ICU4XScriptWithExtensions_get_script_val(this->inner.get(), code_point); +} +inline bool ICU4XScriptWithExtensions::has_script(uint32_t code_point, uint16_t script) const { + return capi::ICU4XScriptWithExtensions_has_script(this->inner.get(), code_point, script); +} +inline ICU4XScriptWithExtensionsBorrowed ICU4XScriptWithExtensions::as_borrowed() const { + return ICU4XScriptWithExtensionsBorrowed(capi::ICU4XScriptWithExtensions_as_borrowed(this->inner.get())); +} +inline CodePointRangeIterator ICU4XScriptWithExtensions::iter_ranges_for_script(uint16_t script) const { + return CodePointRangeIterator(capi::ICU4XScriptWithExtensions_iter_ranges_for_script(this->inner.get(), script)); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XScriptWithExtensionsBorrowed.h b/third_party/rust/icu_capi/cpp/include/ICU4XScriptWithExtensionsBorrowed.h new file mode 100644 index 000000000000..905b5ecc6bb0 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XScriptWithExtensionsBorrowed.h @@ -0,0 +1,34 @@ +#ifndef ICU4XScriptWithExtensionsBorrowed_H +#define ICU4XScriptWithExtensionsBorrowed_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XScriptWithExtensionsBorrowed ICU4XScriptWithExtensionsBorrowed; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XScriptExtensionsSet.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +uint16_t ICU4XScriptWithExtensionsBorrowed_get_script_val(const ICU4XScriptWithExtensionsBorrowed* self, uint32_t code_point); + +ICU4XScriptExtensionsSet* ICU4XScriptWithExtensionsBorrowed_get_script_extensions_val(const ICU4XScriptWithExtensionsBorrowed* self, uint32_t code_point); + +bool ICU4XScriptWithExtensionsBorrowed_has_script(const ICU4XScriptWithExtensionsBorrowed* self, uint32_t code_point, uint16_t script); +void ICU4XScriptWithExtensionsBorrowed_destroy(ICU4XScriptWithExtensionsBorrowed* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XScriptWithExtensionsBorrowed.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XScriptWithExtensionsBorrowed.hpp new file mode 100644 index 000000000000..dc889a2cd020 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XScriptWithExtensionsBorrowed.hpp @@ -0,0 +1,76 @@ +#ifndef ICU4XScriptWithExtensionsBorrowed_HPP +#define ICU4XScriptWithExtensionsBorrowed_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XScriptWithExtensionsBorrowed.h" + +class ICU4XScriptExtensionsSet; + +/** + * A destruction policy for using ICU4XScriptWithExtensionsBorrowed with std::unique_ptr. + */ +struct ICU4XScriptWithExtensionsBorrowedDeleter { + void operator()(capi::ICU4XScriptWithExtensionsBorrowed* l) const noexcept { + capi::ICU4XScriptWithExtensionsBorrowed_destroy(l); + } +}; + +/** + * 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. + */ +class ICU4XScriptWithExtensionsBorrowed { + public: + + /** + * 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. + */ + uint16_t get_script_val(uint32_t code_point) const; + + /** + * Get the Script property value for a code point + * + * See the [Rust documentation for `get_script_extensions_val`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.get_script_extensions_val) for more information. + * + * Lifetimes: `this` must live at least as long as the output. + */ + ICU4XScriptExtensionsSet get_script_extensions_val(uint32_t code_point) const; + + /** + * 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 has_script(uint32_t code_point, uint16_t script) const; + inline const capi::ICU4XScriptWithExtensionsBorrowed* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XScriptWithExtensionsBorrowed* AsFFIMut() { return this->inner.get(); } + inline ICU4XScriptWithExtensionsBorrowed(capi::ICU4XScriptWithExtensionsBorrowed* i) : inner(i) {} + ICU4XScriptWithExtensionsBorrowed() = default; + ICU4XScriptWithExtensionsBorrowed(ICU4XScriptWithExtensionsBorrowed&&) noexcept = default; + ICU4XScriptWithExtensionsBorrowed& operator=(ICU4XScriptWithExtensionsBorrowed&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XScriptExtensionsSet.hpp" + +inline uint16_t ICU4XScriptWithExtensionsBorrowed::get_script_val(uint32_t code_point) const { + return capi::ICU4XScriptWithExtensionsBorrowed_get_script_val(this->inner.get(), code_point); +} +inline ICU4XScriptExtensionsSet ICU4XScriptWithExtensionsBorrowed::get_script_extensions_val(uint32_t code_point) const { + return ICU4XScriptExtensionsSet(capi::ICU4XScriptWithExtensionsBorrowed_get_script_extensions_val(this->inner.get(), code_point)); +} +inline bool ICU4XScriptWithExtensionsBorrowed::has_script(uint32_t code_point, uint16_t script) const { + return capi::ICU4XScriptWithExtensionsBorrowed_has_script(this->inner.get(), code_point, script); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XSegmenterWordType.h b/third_party/rust/icu_capi/cpp/include/ICU4XSegmenterWordType.h new file mode 100644 index 000000000000..9f4f81cf10ce --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XSegmenterWordType.h @@ -0,0 +1,32 @@ +#ifndef ICU4XSegmenterWordType_H +#define ICU4XSegmenterWordType_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XSegmenterWordType { + ICU4XSegmenterWordType_None = 0, + ICU4XSegmenterWordType_Number = 1, + ICU4XSegmenterWordType_Letter = 2, +} ICU4XSegmenterWordType; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XSegmenterWordType_destroy(ICU4XSegmenterWordType* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XSegmenterWordType.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XSegmenterWordType.hpp new file mode 100644 index 000000000000..f204f8a045d7 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XSegmenterWordType.hpp @@ -0,0 +1,27 @@ +#ifndef ICU4XSegmenterWordType_HPP +#define ICU4XSegmenterWordType_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XSegmenterWordType.h" + + + +/** + * + * + * See the [Rust documentation for `WordType`](https://docs.rs/icu/latest/icu/segmenter/enum.WordType.html) for more information. + */ +enum struct ICU4XSegmenterWordType { + None = 0, + Number = 1, + Letter = 2, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorLatin1.h b/third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorLatin1.h new file mode 100644 index 000000000000..6dd7b132dc37 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorLatin1.h @@ -0,0 +1,29 @@ +#ifndef ICU4XSentenceBreakIteratorLatin1_H +#define ICU4XSentenceBreakIteratorLatin1_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XSentenceBreakIteratorLatin1 ICU4XSentenceBreakIteratorLatin1; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XSentenceBreakIteratorLatin1_next(ICU4XSentenceBreakIteratorLatin1* self); +void ICU4XSentenceBreakIteratorLatin1_destroy(ICU4XSentenceBreakIteratorLatin1* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorLatin1.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorLatin1.hpp new file mode 100644 index 000000000000..013c4ce0e2f2 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorLatin1.hpp @@ -0,0 +1,53 @@ +#ifndef ICU4XSentenceBreakIteratorLatin1_HPP +#define ICU4XSentenceBreakIteratorLatin1_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XSentenceBreakIteratorLatin1.h" + + +/** + * A destruction policy for using ICU4XSentenceBreakIteratorLatin1 with std::unique_ptr. + */ +struct ICU4XSentenceBreakIteratorLatin1Deleter { + void operator()(capi::ICU4XSentenceBreakIteratorLatin1* l) const noexcept { + capi::ICU4XSentenceBreakIteratorLatin1_destroy(l); + } +}; + +/** + * + * + * See the [Rust documentation for `SentenceBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceBreakIterator.html) for more information. + */ +class ICU4XSentenceBreakIteratorLatin1 { + public: + + /** + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + * out of range of a 32-bit signed integer. + * + * See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceBreakIterator.html#method.next) for more information. + */ + int32_t next(); + inline const capi::ICU4XSentenceBreakIteratorLatin1* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XSentenceBreakIteratorLatin1* AsFFIMut() { return this->inner.get(); } + inline ICU4XSentenceBreakIteratorLatin1(capi::ICU4XSentenceBreakIteratorLatin1* i) : inner(i) {} + ICU4XSentenceBreakIteratorLatin1() = default; + ICU4XSentenceBreakIteratorLatin1(ICU4XSentenceBreakIteratorLatin1&&) noexcept = default; + ICU4XSentenceBreakIteratorLatin1& operator=(ICU4XSentenceBreakIteratorLatin1&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline int32_t ICU4XSentenceBreakIteratorLatin1::next() { + return capi::ICU4XSentenceBreakIteratorLatin1_next(this->inner.get()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorUtf16.h b/third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorUtf16.h new file mode 100644 index 000000000000..3ed0dc18c34c --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorUtf16.h @@ -0,0 +1,29 @@ +#ifndef ICU4XSentenceBreakIteratorUtf16_H +#define ICU4XSentenceBreakIteratorUtf16_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XSentenceBreakIteratorUtf16 ICU4XSentenceBreakIteratorUtf16; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XSentenceBreakIteratorUtf16_next(ICU4XSentenceBreakIteratorUtf16* self); +void ICU4XSentenceBreakIteratorUtf16_destroy(ICU4XSentenceBreakIteratorUtf16* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorUtf16.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorUtf16.hpp new file mode 100644 index 000000000000..4b90871fdd89 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorUtf16.hpp @@ -0,0 +1,53 @@ +#ifndef ICU4XSentenceBreakIteratorUtf16_HPP +#define ICU4XSentenceBreakIteratorUtf16_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XSentenceBreakIteratorUtf16.h" + + +/** + * A destruction policy for using ICU4XSentenceBreakIteratorUtf16 with std::unique_ptr. + */ +struct ICU4XSentenceBreakIteratorUtf16Deleter { + void operator()(capi::ICU4XSentenceBreakIteratorUtf16* l) const noexcept { + capi::ICU4XSentenceBreakIteratorUtf16_destroy(l); + } +}; + +/** + * + * + * See the [Rust documentation for `SentenceBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceBreakIterator.html) for more information. + */ +class ICU4XSentenceBreakIteratorUtf16 { + public: + + /** + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + * out of range of a 32-bit signed integer. + * + * See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceBreakIterator.html#method.next) for more information. + */ + int32_t next(); + inline const capi::ICU4XSentenceBreakIteratorUtf16* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XSentenceBreakIteratorUtf16* AsFFIMut() { return this->inner.get(); } + inline ICU4XSentenceBreakIteratorUtf16(capi::ICU4XSentenceBreakIteratorUtf16* i) : inner(i) {} + ICU4XSentenceBreakIteratorUtf16() = default; + ICU4XSentenceBreakIteratorUtf16(ICU4XSentenceBreakIteratorUtf16&&) noexcept = default; + ICU4XSentenceBreakIteratorUtf16& operator=(ICU4XSentenceBreakIteratorUtf16&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline int32_t ICU4XSentenceBreakIteratorUtf16::next() { + return capi::ICU4XSentenceBreakIteratorUtf16_next(this->inner.get()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorUtf8.h b/third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorUtf8.h new file mode 100644 index 000000000000..655cb67b6cd1 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorUtf8.h @@ -0,0 +1,29 @@ +#ifndef ICU4XSentenceBreakIteratorUtf8_H +#define ICU4XSentenceBreakIteratorUtf8_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XSentenceBreakIteratorUtf8 ICU4XSentenceBreakIteratorUtf8; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XSentenceBreakIteratorUtf8_next(ICU4XSentenceBreakIteratorUtf8* self); +void ICU4XSentenceBreakIteratorUtf8_destroy(ICU4XSentenceBreakIteratorUtf8* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorUtf8.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorUtf8.hpp new file mode 100644 index 000000000000..df6f08b6c1ff --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XSentenceBreakIteratorUtf8.hpp @@ -0,0 +1,53 @@ +#ifndef ICU4XSentenceBreakIteratorUtf8_HPP +#define ICU4XSentenceBreakIteratorUtf8_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XSentenceBreakIteratorUtf8.h" + + +/** + * A destruction policy for using ICU4XSentenceBreakIteratorUtf8 with std::unique_ptr. + */ +struct ICU4XSentenceBreakIteratorUtf8Deleter { + void operator()(capi::ICU4XSentenceBreakIteratorUtf8* l) const noexcept { + capi::ICU4XSentenceBreakIteratorUtf8_destroy(l); + } +}; + +/** + * + * + * See the [Rust documentation for `SentenceBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceBreakIterator.html) for more information. + */ +class ICU4XSentenceBreakIteratorUtf8 { + public: + + /** + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + * out of range of a 32-bit signed integer. + * + * See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceBreakIterator.html#method.next) for more information. + */ + int32_t next(); + inline const capi::ICU4XSentenceBreakIteratorUtf8* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XSentenceBreakIteratorUtf8* AsFFIMut() { return this->inner.get(); } + inline ICU4XSentenceBreakIteratorUtf8(capi::ICU4XSentenceBreakIteratorUtf8* i) : inner(i) {} + ICU4XSentenceBreakIteratorUtf8() = default; + ICU4XSentenceBreakIteratorUtf8(ICU4XSentenceBreakIteratorUtf8&&) noexcept = default; + ICU4XSentenceBreakIteratorUtf8& operator=(ICU4XSentenceBreakIteratorUtf8&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline int32_t ICU4XSentenceBreakIteratorUtf8::next() { + return capi::ICU4XSentenceBreakIteratorUtf8_next(this->inner.get()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XSentenceSegmenter.h b/third_party/rust/icu_capi/cpp/include/ICU4XSentenceSegmenter.h new file mode 100644 index 000000000000..7701c9f04289 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XSentenceSegmenter.h @@ -0,0 +1,40 @@ +#ifndef ICU4XSentenceSegmenter_H +#define ICU4XSentenceSegmenter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XSentenceSegmenter ICU4XSentenceSegmenter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError.h" +#include "ICU4XSentenceBreakIteratorUtf8.h" +#include "ICU4XSentenceBreakIteratorUtf16.h" +#include "ICU4XSentenceBreakIteratorLatin1.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError ICU4XSentenceSegmenter_create(const ICU4XDataProvider* provider); + +ICU4XSentenceBreakIteratorUtf8* ICU4XSentenceSegmenter_segment_utf8(const ICU4XSentenceSegmenter* self, const char* input_data, size_t input_len); + +ICU4XSentenceBreakIteratorUtf16* ICU4XSentenceSegmenter_segment_utf16(const ICU4XSentenceSegmenter* self, const uint16_t* input_data, size_t input_len); + +ICU4XSentenceBreakIteratorLatin1* ICU4XSentenceSegmenter_segment_latin1(const ICU4XSentenceSegmenter* self, const uint8_t* input_data, size_t input_len); +void ICU4XSentenceSegmenter_destroy(ICU4XSentenceSegmenter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XSentenceSegmenter.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XSentenceSegmenter.hpp new file mode 100644 index 000000000000..e8332bd68067 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XSentenceSegmenter.hpp @@ -0,0 +1,105 @@ +#ifndef ICU4XSentenceSegmenter_HPP +#define ICU4XSentenceSegmenter_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XSentenceSegmenter.h" + +class ICU4XDataProvider; +class ICU4XSentenceSegmenter; +#include "ICU4XError.hpp" +class ICU4XSentenceBreakIteratorUtf8; +class ICU4XSentenceBreakIteratorUtf16; +class ICU4XSentenceBreakIteratorLatin1; + +/** + * A destruction policy for using ICU4XSentenceSegmenter with std::unique_ptr. + */ +struct ICU4XSentenceSegmenterDeleter { + void operator()(capi::ICU4XSentenceSegmenter* l) const noexcept { + capi::ICU4XSentenceSegmenter_destroy(l); + } +}; + +/** + * 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. + */ +class ICU4XSentenceSegmenter { + public: + + /** + * Construct an [`ICU4XSentenceSegmenter`]. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceSegmenter.html#method.try_new_unstable) for more information. + */ + static diplomat::result create(const ICU4XDataProvider& provider); + + /** + * Segments a (potentially ill-formed) UTF-8 string. + * + * See the [Rust documentation for `segment_utf8`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceSegmenter.html#method.segment_utf8) for more information. + * + * Lifetimes: `this`, `input` must live at least as long as the output. + */ + ICU4XSentenceBreakIteratorUtf8 segment_utf8(const std::string_view input) const; + + /** + * Segments a UTF-16 string. + * + * See the [Rust documentation for `segment_utf16`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceSegmenter.html#method.segment_utf16) for more information. + * + * Lifetimes: `this`, `input` must live at least as long as the output. + */ + ICU4XSentenceBreakIteratorUtf16 segment_utf16(const diplomat::span input) const; + + /** + * Segments a Latin-1 string. + * + * See the [Rust documentation for `segment_latin1`](https://docs.rs/icu/latest/icu/segmenter/struct.SentenceSegmenter.html#method.segment_latin1) for more information. + * + * Lifetimes: `this`, `input` must live at least as long as the output. + */ + ICU4XSentenceBreakIteratorLatin1 segment_latin1(const diplomat::span input) const; + inline const capi::ICU4XSentenceSegmenter* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XSentenceSegmenter* AsFFIMut() { return this->inner.get(); } + inline ICU4XSentenceSegmenter(capi::ICU4XSentenceSegmenter* i) : inner(i) {} + ICU4XSentenceSegmenter() = default; + ICU4XSentenceSegmenter(ICU4XSentenceSegmenter&&) noexcept = default; + ICU4XSentenceSegmenter& operator=(ICU4XSentenceSegmenter&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XSentenceBreakIteratorUtf8.hpp" +#include "ICU4XSentenceBreakIteratorUtf16.hpp" +#include "ICU4XSentenceBreakIteratorLatin1.hpp" + +inline diplomat::result ICU4XSentenceSegmenter::create(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XSentenceSegmenter_create(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XSentenceSegmenter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XSentenceBreakIteratorUtf8 ICU4XSentenceSegmenter::segment_utf8(const std::string_view input) const { + return ICU4XSentenceBreakIteratorUtf8(capi::ICU4XSentenceSegmenter_segment_utf8(this->inner.get(), input.data(), input.size())); +} +inline ICU4XSentenceBreakIteratorUtf16 ICU4XSentenceSegmenter::segment_utf16(const diplomat::span input) const { + return ICU4XSentenceBreakIteratorUtf16(capi::ICU4XSentenceSegmenter_segment_utf16(this->inner.get(), input.data(), input.size())); +} +inline ICU4XSentenceBreakIteratorLatin1 ICU4XSentenceSegmenter::segment_latin1(const diplomat::span input) const { + return ICU4XSentenceBreakIteratorLatin1(capi::ICU4XSentenceSegmenter_segment_latin1(this->inner.get(), input.data(), input.size())); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XTime.h b/third_party/rust/icu_capi/cpp/include/ICU4XTime.h new file mode 100644 index 000000000000..d92fef92e4b8 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XTime.h @@ -0,0 +1,38 @@ +#ifndef ICU4XTime_H +#define ICU4XTime_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XTime ICU4XTime; +#ifdef __cplusplus +} // namespace capi +#endif +#include "diplomat_result_box_ICU4XTime_ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XTime_ICU4XError ICU4XTime_create(uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond); + +uint8_t ICU4XTime_hour(const ICU4XTime* self); + +uint8_t ICU4XTime_minute(const ICU4XTime* self); + +uint8_t ICU4XTime_second(const ICU4XTime* self); + +uint32_t ICU4XTime_nanosecond(const ICU4XTime* self); +void ICU4XTime_destroy(ICU4XTime* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XTime.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XTime.hpp new file mode 100644 index 000000000000..424ceedfbfef --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XTime.hpp @@ -0,0 +1,101 @@ +#ifndef ICU4XTime_HPP +#define ICU4XTime_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XTime.h" + +class ICU4XTime; +#include "ICU4XError.hpp" + +/** + * A destruction policy for using ICU4XTime with std::unique_ptr. + */ +struct ICU4XTimeDeleter { + void operator()(capi::ICU4XTime* l) const noexcept { + capi::ICU4XTime_destroy(l); + } +}; + +/** + * 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. + */ +class ICU4XTime { + public: + + /** + * Creates a new [`ICU4XTime`] given field values + * + * See the [Rust documentation for `Time`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html) for more information. + */ + static diplomat::result create(uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond); + + /** + * 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. + */ + uint8_t hour() const; + + /** + * Returns the minute in this time + * + * See the [Rust documentation for `minute`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.minute) for more information. + */ + uint8_t minute() const; + + /** + * Returns the second in this time + * + * See the [Rust documentation for `second`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.second) for more information. + */ + uint8_t second() const; + + /** + * Returns the nanosecond in this time + * + * See the [Rust documentation for `nanosecond`](https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.nanosecond) for more information. + */ + uint32_t nanosecond() const; + inline const capi::ICU4XTime* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XTime* AsFFIMut() { return this->inner.get(); } + inline ICU4XTime(capi::ICU4XTime* i) : inner(i) {} + ICU4XTime() = default; + ICU4XTime(ICU4XTime&&) noexcept = default; + ICU4XTime& operator=(ICU4XTime&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline diplomat::result ICU4XTime::create(uint8_t hour, uint8_t minute, uint8_t second, uint32_t nanosecond) { + auto diplomat_result_raw_out_value = capi::ICU4XTime_create(hour, minute, second, nanosecond); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XTime(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline uint8_t ICU4XTime::hour() const { + return capi::ICU4XTime_hour(this->inner.get()); +} +inline uint8_t ICU4XTime::minute() const { + return capi::ICU4XTime_minute(this->inner.get()); +} +inline uint8_t ICU4XTime::second() const { + return capi::ICU4XTime_second(this->inner.get()); +} +inline uint32_t ICU4XTime::nanosecond() const { + return capi::ICU4XTime_nanosecond(this->inner.get()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XTimeFormatter.h b/third_party/rust/icu_capi/cpp/include/ICU4XTimeFormatter.h new file mode 100644 index 000000000000..d200881399fa --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XTimeFormatter.h @@ -0,0 +1,43 @@ +#ifndef ICU4XTimeFormatter_H +#define ICU4XTimeFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XTimeFormatter ICU4XTimeFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XTimeLength.h" +#include "diplomat_result_box_ICU4XTimeFormatter_ICU4XError.h" +#include "ICU4XTime.h" +#include "diplomat_result_void_ICU4XError.h" +#include "ICU4XDateTime.h" +#include "ICU4XIsoDateTime.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XTimeFormatter_ICU4XError ICU4XTimeFormatter_create_with_length(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XTimeLength length); + +diplomat_result_void_ICU4XError ICU4XTimeFormatter_format_time(const ICU4XTimeFormatter* self, const ICU4XTime* value, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XTimeFormatter_format_datetime(const ICU4XTimeFormatter* self, const ICU4XDateTime* value, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XTimeFormatter_format_iso_datetime(const ICU4XTimeFormatter* self, const ICU4XIsoDateTime* value, DiplomatWriteable* write); +void ICU4XTimeFormatter_destroy(ICU4XTimeFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XTimeFormatter.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XTimeFormatter.hpp new file mode 100644 index 000000000000..f036764f3892 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XTimeFormatter.hpp @@ -0,0 +1,183 @@ +#ifndef ICU4XTimeFormatter_HPP +#define ICU4XTimeFormatter_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XTimeFormatter.h" + +class ICU4XDataProvider; +class ICU4XLocale; +#include "ICU4XTimeLength.hpp" +class ICU4XTimeFormatter; +#include "ICU4XError.hpp" +class ICU4XTime; +class ICU4XDateTime; +class ICU4XIsoDateTime; + +/** + * A destruction policy for using ICU4XTimeFormatter with std::unique_ptr. + */ +struct ICU4XTimeFormatterDeleter { + void operator()(capi::ICU4XTimeFormatter* l) const noexcept { + capi::ICU4XTimeFormatter_destroy(l); + } +}; + +/** + * An ICU4X TimeFormatter object capable of formatting an [`ICU4XTime`] 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. + */ +class ICU4XTimeFormatter { + public: + + /** + * Creates a new [`ICU4XTimeFormatter`] from locale data. + * + * See the [Rust documentation for `try_new_with_length_unstable`](https://docs.rs/icu/latest/icu/datetime/struct.TimeFormatter.html#method.try_new_with_length_unstable) for more information. + */ + static diplomat::result create_with_length(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XTimeLength length); + + /** + * Formats a [`ICU4XTime`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TimeFormatter.html#method.format) for more information. + */ + template diplomat::result format_time_to_writeable(const ICU4XTime& value, W& write) const; + + /** + * Formats a [`ICU4XTime`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TimeFormatter.html#method.format) for more information. + */ + diplomat::result format_time(const ICU4XTime& value) const; + + /** + * Formats a [`ICU4XDateTime`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TimeFormatter.html#method.format) for more information. + */ + template diplomat::result format_datetime_to_writeable(const ICU4XDateTime& value, W& write) const; + + /** + * Formats a [`ICU4XDateTime`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TimeFormatter.html#method.format) for more information. + */ + diplomat::result format_datetime(const ICU4XDateTime& value) const; + + /** + * Formats a [`ICU4XIsoDateTime`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TimeFormatter.html#method.format) for more information. + */ + template diplomat::result format_iso_datetime_to_writeable(const ICU4XIsoDateTime& value, W& write) const; + + /** + * Formats a [`ICU4XIsoDateTime`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.TimeFormatter.html#method.format) for more information. + */ + diplomat::result format_iso_datetime(const ICU4XIsoDateTime& value) const; + inline const capi::ICU4XTimeFormatter* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XTimeFormatter* AsFFIMut() { return this->inner.get(); } + inline ICU4XTimeFormatter(capi::ICU4XTimeFormatter* i) : inner(i) {} + ICU4XTimeFormatter() = default; + ICU4XTimeFormatter(ICU4XTimeFormatter&&) noexcept = default; + ICU4XTimeFormatter& operator=(ICU4XTimeFormatter&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" +#include "ICU4XTime.hpp" +#include "ICU4XDateTime.hpp" +#include "ICU4XIsoDateTime.hpp" + +inline diplomat::result ICU4XTimeFormatter::create_with_length(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XTimeLength length) { + auto diplomat_result_raw_out_value = capi::ICU4XTimeFormatter_create_with_length(provider.AsFFI(), locale.AsFFI(), static_cast(length)); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XTimeFormatter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +template inline diplomat::result ICU4XTimeFormatter::format_time_to_writeable(const ICU4XTime& value, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XTimeFormatter_format_time(this->inner.get(), value.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XTimeFormatter::format_time(const ICU4XTime& value) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XTimeFormatter_format_time(this->inner.get(), value.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +template inline diplomat::result ICU4XTimeFormatter::format_datetime_to_writeable(const ICU4XDateTime& value, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XTimeFormatter_format_datetime(this->inner.get(), value.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XTimeFormatter::format_datetime(const ICU4XDateTime& value) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XTimeFormatter_format_datetime(this->inner.get(), value.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +template inline diplomat::result ICU4XTimeFormatter::format_iso_datetime_to_writeable(const ICU4XIsoDateTime& value, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XTimeFormatter_format_iso_datetime(this->inner.get(), value.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XTimeFormatter::format_iso_datetime(const ICU4XIsoDateTime& value) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XTimeFormatter_format_iso_datetime(this->inner.get(), value.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XTimeLength.h b/third_party/rust/icu_capi/cpp/include/ICU4XTimeLength.h new file mode 100644 index 000000000000..6d98bc8ccb59 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XTimeLength.h @@ -0,0 +1,33 @@ +#ifndef ICU4XTimeLength_H +#define ICU4XTimeLength_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XTimeLength { + ICU4XTimeLength_Full = 0, + ICU4XTimeLength_Long = 1, + ICU4XTimeLength_Medium = 2, + ICU4XTimeLength_Short = 3, +} ICU4XTimeLength; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XTimeLength_destroy(ICU4XTimeLength* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XTimeLength.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XTimeLength.hpp new file mode 100644 index 000000000000..9eae1892e36e --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XTimeLength.hpp @@ -0,0 +1,28 @@ +#ifndef ICU4XTimeLength_HPP +#define ICU4XTimeLength_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XTimeLength.h" + + + +/** + * + * + * See the [Rust documentation for `Time`](https://docs.rs/icu/latest/icu/datetime/options/length/enum.Time.html) for more information. + */ +enum struct ICU4XTimeLength { + Full = 0, + Long = 1, + Medium = 2, + Short = 3, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XTimeZoneFormatter.h b/third_party/rust/icu_capi/cpp/include/ICU4XTimeZoneFormatter.h new file mode 100644 index 000000000000..c11abf4362cb --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XTimeZoneFormatter.h @@ -0,0 +1,53 @@ +#ifndef ICU4XTimeZoneFormatter_H +#define ICU4XTimeZoneFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XTimeZoneFormatter ICU4XTimeZoneFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError.h" +#include "ICU4XIsoTimeZoneOptions.h" +#include "diplomat_result_void_ICU4XError.h" +#include "ICU4XCustomTimeZone.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError ICU4XTimeZoneFormatter_create_with_localized_gmt_fallback(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError ICU4XTimeZoneFormatter_create_with_iso_8601_fallback(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XIsoTimeZoneOptions options); + +diplomat_result_void_ICU4XError ICU4XTimeZoneFormatter_load_generic_non_location_long(ICU4XTimeZoneFormatter* self, const ICU4XDataProvider* provider); + +diplomat_result_void_ICU4XError ICU4XTimeZoneFormatter_load_generic_non_location_short(ICU4XTimeZoneFormatter* self, const ICU4XDataProvider* provider); + +diplomat_result_void_ICU4XError ICU4XTimeZoneFormatter_load_specific_non_location_long(ICU4XTimeZoneFormatter* self, const ICU4XDataProvider* provider); + +diplomat_result_void_ICU4XError ICU4XTimeZoneFormatter_load_specific_non_location_short(ICU4XTimeZoneFormatter* self, const ICU4XDataProvider* provider); + +diplomat_result_void_ICU4XError ICU4XTimeZoneFormatter_load_generic_location_format(ICU4XTimeZoneFormatter* self, const ICU4XDataProvider* provider); + +diplomat_result_void_ICU4XError ICU4XTimeZoneFormatter_load_localized_gmt_format(ICU4XTimeZoneFormatter* self); + +diplomat_result_void_ICU4XError ICU4XTimeZoneFormatter_load_iso_8601_format(ICU4XTimeZoneFormatter* self, ICU4XIsoTimeZoneOptions options); + +diplomat_result_void_ICU4XError ICU4XTimeZoneFormatter_format_custom_time_zone(const ICU4XTimeZoneFormatter* self, const ICU4XCustomTimeZone* value, DiplomatWriteable* write); +void ICU4XTimeZoneFormatter_destroy(ICU4XTimeZoneFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XTimeZoneFormatter.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XTimeZoneFormatter.hpp new file mode 100644 index 000000000000..13988619bc41 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XTimeZoneFormatter.hpp @@ -0,0 +1,256 @@ +#ifndef ICU4XTimeZoneFormatter_HPP +#define ICU4XTimeZoneFormatter_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XTimeZoneFormatter.h" + +class ICU4XDataProvider; +class ICU4XLocale; +class ICU4XTimeZoneFormatter; +#include "ICU4XError.hpp" +struct ICU4XIsoTimeZoneOptions; +class ICU4XCustomTimeZone; + +/** + * A destruction policy for using ICU4XTimeZoneFormatter with std::unique_ptr. + */ +struct ICU4XTimeZoneFormatterDeleter { + void operator()(capi::ICU4XTimeZoneFormatter* l) const noexcept { + capi::ICU4XTimeZoneFormatter_destroy(l); + } +}; + +/** + * An ICU4X TimeZoneFormatter object capable of formatting an [`ICU4XCustomTimeZone`] 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. + */ +class ICU4XTimeZoneFormatter { + public: + + /** + * Creates a new [`ICU4XTimeZoneFormatter`] from locale data. + * + * Uses localized GMT as the fallback format. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.try_new_unstable) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/time_zone/enum.FallbackFormat.html) + */ + static diplomat::result create_with_localized_gmt_fallback(const ICU4XDataProvider& provider, const ICU4XLocale& locale); + + /** + * Creates a new [`ICU4XTimeZoneFormatter`] from locale data. + * + * Uses ISO-8601 as the fallback format. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.try_new_unstable) for more information. + * + * Additional information: [1](https://docs.rs/icu/latest/icu/datetime/time_zone/enum.FallbackFormat.html) + */ + static diplomat::result create_with_iso_8601_fallback(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XIsoTimeZoneOptions options); + + /** + * Loads generic non-location long format. Example: "Pacific Time" + * + * See the [Rust documentation for `load_generic_non_location_long`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.load_generic_non_location_long) for more information. + */ + diplomat::result load_generic_non_location_long(const ICU4XDataProvider& provider); + + /** + * Loads generic non-location short format. Example: "PT" + * + * See the [Rust documentation for `load_generic_non_location_short`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.load_generic_non_location_short) for more information. + */ + diplomat::result load_generic_non_location_short(const ICU4XDataProvider& provider); + + /** + * Loads specific non-location long format. Example: "Pacific Standard Time" + * + * See the [Rust documentation for `load_specific_non_location_long`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.load_specific_non_location_long) for more information. + */ + diplomat::result load_specific_non_location_long(const ICU4XDataProvider& provider); + + /** + * Loads specific non-location short format. Example: "PST" + * + * See the [Rust documentation for `load_specific_non_location_short`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.load_specific_non_location_short) for more information. + */ + diplomat::result load_specific_non_location_short(const ICU4XDataProvider& provider); + + /** + * Loads generic location format. Example: "Los Angeles Time" + * + * See the [Rust documentation for `load_generic_location_format`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.load_generic_location_format) for more information. + */ + diplomat::result load_generic_location_format(const ICU4XDataProvider& provider); + + /** + * Loads localized GMT format. Example: "GMT-07:00" + * + * See the [Rust documentation for `load_localized_gmt_format`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.load_localized_gmt_format) for more information. + */ + diplomat::result load_localized_gmt_format(); + + /** + * Loads ISO-8601 format. Example: "-07:00" + * + * See the [Rust documentation for `load_iso_8601_format`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.load_iso_8601_format) for more information. + */ + diplomat::result load_iso_8601_format(ICU4XIsoTimeZoneOptions options); + + /** + * Formats a [`ICU4XCustomTimeZone`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.format) for more information. + * + * See the [Rust documentation for `format_to_string`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.format_to_string) for more information. + */ + template diplomat::result format_custom_time_zone_to_writeable(const ICU4XCustomTimeZone& value, W& write) const; + + /** + * Formats a [`ICU4XCustomTimeZone`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.format) for more information. + * + * See the [Rust documentation for `format_to_string`](https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.format_to_string) for more information. + */ + diplomat::result format_custom_time_zone(const ICU4XCustomTimeZone& value) const; + inline const capi::ICU4XTimeZoneFormatter* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XTimeZoneFormatter* AsFFIMut() { return this->inner.get(); } + inline ICU4XTimeZoneFormatter(capi::ICU4XTimeZoneFormatter* i) : inner(i) {} + ICU4XTimeZoneFormatter() = default; + ICU4XTimeZoneFormatter(ICU4XTimeZoneFormatter&&) noexcept = default; + ICU4XTimeZoneFormatter& operator=(ICU4XTimeZoneFormatter&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" +#include "ICU4XIsoTimeZoneOptions.hpp" +#include "ICU4XCustomTimeZone.hpp" + +inline diplomat::result ICU4XTimeZoneFormatter::create_with_localized_gmt_fallback(const ICU4XDataProvider& provider, const ICU4XLocale& locale) { + auto diplomat_result_raw_out_value = capi::ICU4XTimeZoneFormatter_create_with_localized_gmt_fallback(provider.AsFFI(), locale.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XTimeZoneFormatter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XTimeZoneFormatter::create_with_iso_8601_fallback(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XIsoTimeZoneOptions options) { + ICU4XIsoTimeZoneOptions diplomat_wrapped_struct_options = options; + auto diplomat_result_raw_out_value = capi::ICU4XTimeZoneFormatter_create_with_iso_8601_fallback(provider.AsFFI(), locale.AsFFI(), capi::ICU4XIsoTimeZoneOptions{ .format = static_cast(diplomat_wrapped_struct_options.format), .minutes = static_cast(diplomat_wrapped_struct_options.minutes), .seconds = static_cast(diplomat_wrapped_struct_options.seconds) }); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XTimeZoneFormatter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XTimeZoneFormatter::load_generic_non_location_long(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XTimeZoneFormatter_load_generic_non_location_long(this->inner.get(), provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XTimeZoneFormatter::load_generic_non_location_short(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XTimeZoneFormatter_load_generic_non_location_short(this->inner.get(), provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XTimeZoneFormatter::load_specific_non_location_long(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XTimeZoneFormatter_load_specific_non_location_long(this->inner.get(), provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XTimeZoneFormatter::load_specific_non_location_short(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XTimeZoneFormatter_load_specific_non_location_short(this->inner.get(), provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XTimeZoneFormatter::load_generic_location_format(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XTimeZoneFormatter_load_generic_location_format(this->inner.get(), provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XTimeZoneFormatter::load_localized_gmt_format() { + auto diplomat_result_raw_out_value = capi::ICU4XTimeZoneFormatter_load_localized_gmt_format(this->inner.get()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XTimeZoneFormatter::load_iso_8601_format(ICU4XIsoTimeZoneOptions options) { + ICU4XIsoTimeZoneOptions diplomat_wrapped_struct_options = options; + auto diplomat_result_raw_out_value = capi::ICU4XTimeZoneFormatter_load_iso_8601_format(this->inner.get(), capi::ICU4XIsoTimeZoneOptions{ .format = static_cast(diplomat_wrapped_struct_options.format), .minutes = static_cast(diplomat_wrapped_struct_options.minutes), .seconds = static_cast(diplomat_wrapped_struct_options.seconds) }); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +template inline diplomat::result ICU4XTimeZoneFormatter::format_custom_time_zone_to_writeable(const ICU4XCustomTimeZone& value, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XTimeZoneFormatter_format_custom_time_zone(this->inner.get(), value.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XTimeZoneFormatter::format_custom_time_zone(const ICU4XCustomTimeZone& value) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XTimeZoneFormatter_format_custom_time_zone(this->inner.get(), value.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XTransformResult.h b/third_party/rust/icu_capi/cpp/include/ICU4XTransformResult.h new file mode 100644 index 000000000000..66b268e266a7 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XTransformResult.h @@ -0,0 +1,31 @@ +#ifndef ICU4XTransformResult_H +#define ICU4XTransformResult_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XTransformResult { + ICU4XTransformResult_Modified = 0, + ICU4XTransformResult_Unmodified = 1, +} ICU4XTransformResult; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XTransformResult_destroy(ICU4XTransformResult* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XTransformResult.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XTransformResult.hpp new file mode 100644 index 000000000000..106025313b84 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XTransformResult.hpp @@ -0,0 +1,26 @@ +#ifndef ICU4XTransformResult_HPP +#define ICU4XTransformResult_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XTransformResult.h" + + + +/** + * FFI version of `TransformResult`. + * + * See the [Rust documentation for `TransformResult`](https://docs.rs/icu/latest/icu/locid_transform/enum.TransformResult.html) for more information. + */ +enum struct ICU4XTransformResult { + Modified = 0, + Unmodified = 1, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XUnicodeSetData.h b/third_party/rust/icu_capi/cpp/include/ICU4XUnicodeSetData.h new file mode 100644 index 000000000000..3e10e53097e5 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XUnicodeSetData.h @@ -0,0 +1,48 @@ +#ifndef ICU4XUnicodeSetData_H +#define ICU4XUnicodeSetData_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XUnicodeSetData ICU4XUnicodeSetData; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XUnicodeSetData_ICU4XError.h" +#include "ICU4XLocale.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +bool ICU4XUnicodeSetData_contains(const ICU4XUnicodeSetData* self, const char* s_data, size_t s_len); + +bool ICU4XUnicodeSetData_contains_char(const ICU4XUnicodeSetData* self, char32_t cp); + +bool ICU4XUnicodeSetData_contains32(const ICU4XUnicodeSetData* self, uint32_t cp); + +diplomat_result_box_ICU4XUnicodeSetData_ICU4XError ICU4XUnicodeSetData_load_basic_emoji(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XUnicodeSetData_ICU4XError ICU4XUnicodeSetData_load_exemplars_main(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +diplomat_result_box_ICU4XUnicodeSetData_ICU4XError ICU4XUnicodeSetData_load_exemplars_auxiliary(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +diplomat_result_box_ICU4XUnicodeSetData_ICU4XError ICU4XUnicodeSetData_load_exemplars_punctuation(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +diplomat_result_box_ICU4XUnicodeSetData_ICU4XError ICU4XUnicodeSetData_load_exemplars_numbers(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +diplomat_result_box_ICU4XUnicodeSetData_ICU4XError ICU4XUnicodeSetData_load_exemplars_index(const ICU4XDataProvider* provider, const ICU4XLocale* locale); +void ICU4XUnicodeSetData_destroy(ICU4XUnicodeSetData* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XUnicodeSetData.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XUnicodeSetData.hpp new file mode 100644 index 000000000000..9f12caa2e61e --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XUnicodeSetData.hpp @@ -0,0 +1,182 @@ +#ifndef ICU4XUnicodeSetData_HPP +#define ICU4XUnicodeSetData_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XUnicodeSetData.h" + +class ICU4XDataProvider; +class ICU4XUnicodeSetData; +#include "ICU4XError.hpp" +class ICU4XLocale; + +/** + * A destruction policy for using ICU4XUnicodeSetData with std::unique_ptr. + */ +struct ICU4XUnicodeSetDataDeleter { + void operator()(capi::ICU4XUnicodeSetData* l) const noexcept { + capi::ICU4XUnicodeSetData_destroy(l); + } +}; + +/** + * An ICU4X Unicode Set Property object, capable of querying whether a code point is contained in a set based on a Unicode property. + * + * See the [Rust documentation for `properties`](https://docs.rs/icu/latest/icu/properties/index.html) for more information. + * + * See the [Rust documentation for `UnicodeSetData`](https://docs.rs/icu/latest/icu/properties/sets/struct.UnicodeSetData.html) for more information. + * + * See the [Rust documentation for `UnicodeSetDataBorrowed`](https://docs.rs/icu/latest/icu/properties/sets/struct.UnicodeSetDataBorrowed.html) for more information. + */ +class ICU4XUnicodeSetData { + public: + + /** + * Checks whether the string is in the set. + * + * See the [Rust documentation for `contains`](https://docs.rs/icu/latest/icu/properties/sets/struct.UnicodeSetDataBorrowed.html#method.contains) for more information. + */ + bool contains(const std::string_view s) const; + + /** + * Checks whether the code point is in the set. + * + * See the [Rust documentation for `contains_char`](https://docs.rs/icu/latest/icu/properties/sets/struct.UnicodeSetDataBorrowed.html#method.contains_char) for more information. + */ + bool contains_char(char32_t cp) const; + + /** + * Checks whether the code point (specified as a 32 bit integer, in UTF-32) is in the set. + */ + bool contains32(uint32_t cp) const; + + /** + * + * + * See the [Rust documentation for `load_basic_emoji`](https://docs.rs/icu/latest/icu/properties/sets/fn.load_basic_emoji.html) for more information. + */ + static diplomat::result load_basic_emoji(const ICU4XDataProvider& provider); + + /** + * + * + * See the [Rust documentation for `load_exemplars_main`](https://docs.rs/icu/latest/icu/properties/exemplar_chars/fn.load_exemplars_main.html) for more information. + */ + static diplomat::result load_exemplars_main(const ICU4XDataProvider& provider, const ICU4XLocale& locale); + + /** + * + * + * See the [Rust documentation for `load_exemplars_auxiliary`](https://docs.rs/icu/latest/icu/properties/exemplar_chars/fn.load_exemplars_auxiliary.html) for more information. + */ + static diplomat::result load_exemplars_auxiliary(const ICU4XDataProvider& provider, const ICU4XLocale& locale); + + /** + * + * + * See the [Rust documentation for `load_exemplars_punctuation`](https://docs.rs/icu/latest/icu/properties/exemplar_chars/fn.load_exemplars_punctuation.html) for more information. + */ + static diplomat::result load_exemplars_punctuation(const ICU4XDataProvider& provider, const ICU4XLocale& locale); + + /** + * + * + * See the [Rust documentation for `load_exemplars_numbers`](https://docs.rs/icu/latest/icu/properties/exemplar_chars/fn.load_exemplars_numbers.html) for more information. + */ + static diplomat::result load_exemplars_numbers(const ICU4XDataProvider& provider, const ICU4XLocale& locale); + + /** + * + * + * See the [Rust documentation for `load_exemplars_index`](https://docs.rs/icu/latest/icu/properties/exemplar_chars/fn.load_exemplars_index.html) for more information. + */ + static diplomat::result load_exemplars_index(const ICU4XDataProvider& provider, const ICU4XLocale& locale); + inline const capi::ICU4XUnicodeSetData* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XUnicodeSetData* AsFFIMut() { return this->inner.get(); } + inline ICU4XUnicodeSetData(capi::ICU4XUnicodeSetData* i) : inner(i) {} + ICU4XUnicodeSetData() = default; + ICU4XUnicodeSetData(ICU4XUnicodeSetData&&) noexcept = default; + ICU4XUnicodeSetData& operator=(ICU4XUnicodeSetData&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" + +inline bool ICU4XUnicodeSetData::contains(const std::string_view s) const { + return capi::ICU4XUnicodeSetData_contains(this->inner.get(), s.data(), s.size()); +} +inline bool ICU4XUnicodeSetData::contains_char(char32_t cp) const { + return capi::ICU4XUnicodeSetData_contains_char(this->inner.get(), cp); +} +inline bool ICU4XUnicodeSetData::contains32(uint32_t cp) const { + return capi::ICU4XUnicodeSetData_contains32(this->inner.get(), cp); +} +inline diplomat::result ICU4XUnicodeSetData::load_basic_emoji(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XUnicodeSetData_load_basic_emoji(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XUnicodeSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XUnicodeSetData::load_exemplars_main(const ICU4XDataProvider& provider, const ICU4XLocale& locale) { + auto diplomat_result_raw_out_value = capi::ICU4XUnicodeSetData_load_exemplars_main(provider.AsFFI(), locale.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XUnicodeSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XUnicodeSetData::load_exemplars_auxiliary(const ICU4XDataProvider& provider, const ICU4XLocale& locale) { + auto diplomat_result_raw_out_value = capi::ICU4XUnicodeSetData_load_exemplars_auxiliary(provider.AsFFI(), locale.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XUnicodeSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XUnicodeSetData::load_exemplars_punctuation(const ICU4XDataProvider& provider, const ICU4XLocale& locale) { + auto diplomat_result_raw_out_value = capi::ICU4XUnicodeSetData_load_exemplars_punctuation(provider.AsFFI(), locale.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XUnicodeSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XUnicodeSetData::load_exemplars_numbers(const ICU4XDataProvider& provider, const ICU4XLocale& locale) { + auto diplomat_result_raw_out_value = capi::ICU4XUnicodeSetData_load_exemplars_numbers(provider.AsFFI(), locale.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XUnicodeSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XUnicodeSetData::load_exemplars_index(const ICU4XDataProvider& provider, const ICU4XLocale& locale) { + auto diplomat_result_raw_out_value = capi::ICU4XUnicodeSetData_load_exemplars_index(provider.AsFFI(), locale.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XUnicodeSetData(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XWeekCalculator.h b/third_party/rust/icu_capi/cpp/include/ICU4XWeekCalculator.h new file mode 100644 index 000000000000..02a52c6e87be --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XWeekCalculator.h @@ -0,0 +1,39 @@ +#ifndef ICU4XWeekCalculator_H +#define ICU4XWeekCalculator_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XWeekCalculator ICU4XWeekCalculator; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "diplomat_result_box_ICU4XWeekCalculator_ICU4XError.h" +#include "ICU4XIsoWeekday.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XWeekCalculator_ICU4XError ICU4XWeekCalculator_create(const ICU4XDataProvider* provider, const ICU4XLocale* locale); + +ICU4XWeekCalculator* ICU4XWeekCalculator_create_from_first_day_of_week_and_min_week_days(ICU4XIsoWeekday first_weekday, uint8_t min_week_days); + +ICU4XIsoWeekday ICU4XWeekCalculator_first_weekday(const ICU4XWeekCalculator* self); + +uint8_t ICU4XWeekCalculator_min_week_days(const ICU4XWeekCalculator* self); +void ICU4XWeekCalculator_destroy(ICU4XWeekCalculator* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XWeekCalculator.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XWeekCalculator.hpp new file mode 100644 index 000000000000..807fee141e01 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XWeekCalculator.hpp @@ -0,0 +1,97 @@ +#ifndef ICU4XWeekCalculator_HPP +#define ICU4XWeekCalculator_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XWeekCalculator.h" + +class ICU4XDataProvider; +class ICU4XLocale; +class ICU4XWeekCalculator; +#include "ICU4XError.hpp" +#include "ICU4XIsoWeekday.hpp" + +/** + * A destruction policy for using ICU4XWeekCalculator with std::unique_ptr. + */ +struct ICU4XWeekCalculatorDeleter { + void operator()(capi::ICU4XWeekCalculator* l) const noexcept { + capi::ICU4XWeekCalculator_destroy(l); + } +}; + +/** + * 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. + */ +class ICU4XWeekCalculator { + public: + + /** + * Creates a new [`ICU4XWeekCalculator`] from locale data. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/calendar/week/struct.WeekCalculator.html#method.try_new_unstable) for more information. + */ + static diplomat::result create(const ICU4XDataProvider& provider, const ICU4XLocale& locale); + + /** + * + * + * 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) + */ + static ICU4XWeekCalculator create_from_first_day_of_week_and_min_week_days(ICU4XIsoWeekday first_weekday, uint8_t min_week_days); + + /** + * 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. + */ + ICU4XIsoWeekday first_weekday() const; + + /** + * The minimum number of days overlapping a year required for a week to be + * considered part of that year + * + * See the [Rust documentation for `min_week_days`](https://docs.rs/icu/latest/icu/calendar/week/struct.WeekCalculator.html#structfield.min_week_days) for more information. + */ + uint8_t min_week_days() const; + inline const capi::ICU4XWeekCalculator* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XWeekCalculator* AsFFIMut() { return this->inner.get(); } + inline ICU4XWeekCalculator(capi::ICU4XWeekCalculator* i) : inner(i) {} + ICU4XWeekCalculator() = default; + ICU4XWeekCalculator(ICU4XWeekCalculator&&) noexcept = default; + ICU4XWeekCalculator& operator=(ICU4XWeekCalculator&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" + +inline diplomat::result ICU4XWeekCalculator::create(const ICU4XDataProvider& provider, const ICU4XLocale& locale) { + auto diplomat_result_raw_out_value = capi::ICU4XWeekCalculator_create(provider.AsFFI(), locale.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XWeekCalculator(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XWeekCalculator ICU4XWeekCalculator::create_from_first_day_of_week_and_min_week_days(ICU4XIsoWeekday first_weekday, uint8_t min_week_days) { + return ICU4XWeekCalculator(capi::ICU4XWeekCalculator_create_from_first_day_of_week_and_min_week_days(static_cast(first_weekday), min_week_days)); +} +inline ICU4XIsoWeekday ICU4XWeekCalculator::first_weekday() const { + return static_cast(capi::ICU4XWeekCalculator_first_weekday(this->inner.get())); +} +inline uint8_t ICU4XWeekCalculator::min_week_days() const { + return capi::ICU4XWeekCalculator_min_week_days(this->inner.get()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XWeekOf.h b/third_party/rust/icu_capi/cpp/include/ICU4XWeekOf.h new file mode 100644 index 000000000000..5441b943d41f --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XWeekOf.h @@ -0,0 +1,33 @@ +#ifndef ICU4XWeekOf_H +#define ICU4XWeekOf_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XWeekRelativeUnit.h" +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XWeekOf { + uint16_t week; + ICU4XWeekRelativeUnit unit; +} ICU4XWeekOf; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XWeekRelativeUnit.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XWeekOf_destroy(ICU4XWeekOf* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XWeekOf.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XWeekOf.hpp new file mode 100644 index 000000000000..9f76ad73b642 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XWeekOf.hpp @@ -0,0 +1,29 @@ +#ifndef ICU4XWeekOf_HPP +#define ICU4XWeekOf_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XWeekOf.h" + +#include "ICU4XWeekRelativeUnit.hpp" + + +/** + * + * + * See the [Rust documentation for `WeekOf`](https://docs.rs/icu/latest/icu/calendar/week/struct.WeekOf.html) for more information. + */ +struct ICU4XWeekOf { + public: + uint16_t week; + ICU4XWeekRelativeUnit unit; +}; + + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XWeekRelativeUnit.h b/third_party/rust/icu_capi/cpp/include/ICU4XWeekRelativeUnit.h new file mode 100644 index 000000000000..ee6802dc3b37 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XWeekRelativeUnit.h @@ -0,0 +1,32 @@ +#ifndef ICU4XWeekRelativeUnit_H +#define ICU4XWeekRelativeUnit_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef enum ICU4XWeekRelativeUnit { + ICU4XWeekRelativeUnit_Previous = 0, + ICU4XWeekRelativeUnit_Current = 1, + ICU4XWeekRelativeUnit_Next = 2, +} ICU4XWeekRelativeUnit; +#ifdef __cplusplus +} // namespace capi +#endif +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +void ICU4XWeekRelativeUnit_destroy(ICU4XWeekRelativeUnit* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XWeekRelativeUnit.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XWeekRelativeUnit.hpp new file mode 100644 index 000000000000..93ff7504257c --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XWeekRelativeUnit.hpp @@ -0,0 +1,27 @@ +#ifndef ICU4XWeekRelativeUnit_HPP +#define ICU4XWeekRelativeUnit_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XWeekRelativeUnit.h" + + + +/** + * + * + * See the [Rust documentation for `RelativeUnit`](https://docs.rs/icu/latest/icu/calendar/week/enum.RelativeUnit.html) for more information. + */ +enum struct ICU4XWeekRelativeUnit { + Previous = 0, + Current = 1, + Next = 2, +}; + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorLatin1.h b/third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorLatin1.h new file mode 100644 index 000000000000..112025bdf510 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorLatin1.h @@ -0,0 +1,34 @@ +#ifndef ICU4XWordBreakIteratorLatin1_H +#define ICU4XWordBreakIteratorLatin1_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XWordBreakIteratorLatin1 ICU4XWordBreakIteratorLatin1; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XSegmenterWordType.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XWordBreakIteratorLatin1_next(ICU4XWordBreakIteratorLatin1* self); + +ICU4XSegmenterWordType ICU4XWordBreakIteratorLatin1_word_type(const ICU4XWordBreakIteratorLatin1* self); + +bool ICU4XWordBreakIteratorLatin1_is_word_like(const ICU4XWordBreakIteratorLatin1* self); +void ICU4XWordBreakIteratorLatin1_destroy(ICU4XWordBreakIteratorLatin1* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorLatin1.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorLatin1.hpp new file mode 100644 index 000000000000..e4056d8e9fed --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorLatin1.hpp @@ -0,0 +1,74 @@ +#ifndef ICU4XWordBreakIteratorLatin1_HPP +#define ICU4XWordBreakIteratorLatin1_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XWordBreakIteratorLatin1.h" + +#include "ICU4XSegmenterWordType.hpp" + +/** + * A destruction policy for using ICU4XWordBreakIteratorLatin1 with std::unique_ptr. + */ +struct ICU4XWordBreakIteratorLatin1Deleter { + void operator()(capi::ICU4XWordBreakIteratorLatin1* l) const noexcept { + capi::ICU4XWordBreakIteratorLatin1_destroy(l); + } +}; + +/** + * + * + * See the [Rust documentation for `WordBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html) for more information. + */ +class ICU4XWordBreakIteratorLatin1 { + public: + + /** + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + * out of range of a 32-bit signed integer. + * + * See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.next) for more information. + */ + int32_t next(); + + /** + * Return the status value of break boundary. + * + * See the [Rust documentation for `word_type`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.word_type) for more information. + */ + ICU4XSegmenterWordType word_type() const; + + /** + * Return true when break boundary is word-like such as letter/number/CJK + * + * See the [Rust documentation for `is_word_like`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.is_word_like) for more information. + */ + bool is_word_like() const; + inline const capi::ICU4XWordBreakIteratorLatin1* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XWordBreakIteratorLatin1* AsFFIMut() { return this->inner.get(); } + inline ICU4XWordBreakIteratorLatin1(capi::ICU4XWordBreakIteratorLatin1* i) : inner(i) {} + ICU4XWordBreakIteratorLatin1() = default; + ICU4XWordBreakIteratorLatin1(ICU4XWordBreakIteratorLatin1&&) noexcept = default; + ICU4XWordBreakIteratorLatin1& operator=(ICU4XWordBreakIteratorLatin1&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline int32_t ICU4XWordBreakIteratorLatin1::next() { + return capi::ICU4XWordBreakIteratorLatin1_next(this->inner.get()); +} +inline ICU4XSegmenterWordType ICU4XWordBreakIteratorLatin1::word_type() const { + return static_cast(capi::ICU4XWordBreakIteratorLatin1_word_type(this->inner.get())); +} +inline bool ICU4XWordBreakIteratorLatin1::is_word_like() const { + return capi::ICU4XWordBreakIteratorLatin1_is_word_like(this->inner.get()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorUtf16.h b/third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorUtf16.h new file mode 100644 index 000000000000..676aea3cff49 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorUtf16.h @@ -0,0 +1,34 @@ +#ifndef ICU4XWordBreakIteratorUtf16_H +#define ICU4XWordBreakIteratorUtf16_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XWordBreakIteratorUtf16 ICU4XWordBreakIteratorUtf16; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XSegmenterWordType.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XWordBreakIteratorUtf16_next(ICU4XWordBreakIteratorUtf16* self); + +ICU4XSegmenterWordType ICU4XWordBreakIteratorUtf16_word_type(const ICU4XWordBreakIteratorUtf16* self); + +bool ICU4XWordBreakIteratorUtf16_is_word_like(const ICU4XWordBreakIteratorUtf16* self); +void ICU4XWordBreakIteratorUtf16_destroy(ICU4XWordBreakIteratorUtf16* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorUtf16.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorUtf16.hpp new file mode 100644 index 000000000000..b825e1c63689 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorUtf16.hpp @@ -0,0 +1,74 @@ +#ifndef ICU4XWordBreakIteratorUtf16_HPP +#define ICU4XWordBreakIteratorUtf16_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XWordBreakIteratorUtf16.h" + +#include "ICU4XSegmenterWordType.hpp" + +/** + * A destruction policy for using ICU4XWordBreakIteratorUtf16 with std::unique_ptr. + */ +struct ICU4XWordBreakIteratorUtf16Deleter { + void operator()(capi::ICU4XWordBreakIteratorUtf16* l) const noexcept { + capi::ICU4XWordBreakIteratorUtf16_destroy(l); + } +}; + +/** + * + * + * See the [Rust documentation for `WordBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html) for more information. + */ +class ICU4XWordBreakIteratorUtf16 { + public: + + /** + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + * out of range of a 32-bit signed integer. + * + * See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.next) for more information. + */ + int32_t next(); + + /** + * Return the status value of break boundary. + * + * See the [Rust documentation for `word_type`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.word_type) for more information. + */ + ICU4XSegmenterWordType word_type() const; + + /** + * Return true when break boundary is word-like such as letter/number/CJK + * + * See the [Rust documentation for `is_word_like`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.is_word_like) for more information. + */ + bool is_word_like() const; + inline const capi::ICU4XWordBreakIteratorUtf16* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XWordBreakIteratorUtf16* AsFFIMut() { return this->inner.get(); } + inline ICU4XWordBreakIteratorUtf16(capi::ICU4XWordBreakIteratorUtf16* i) : inner(i) {} + ICU4XWordBreakIteratorUtf16() = default; + ICU4XWordBreakIteratorUtf16(ICU4XWordBreakIteratorUtf16&&) noexcept = default; + ICU4XWordBreakIteratorUtf16& operator=(ICU4XWordBreakIteratorUtf16&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline int32_t ICU4XWordBreakIteratorUtf16::next() { + return capi::ICU4XWordBreakIteratorUtf16_next(this->inner.get()); +} +inline ICU4XSegmenterWordType ICU4XWordBreakIteratorUtf16::word_type() const { + return static_cast(capi::ICU4XWordBreakIteratorUtf16_word_type(this->inner.get())); +} +inline bool ICU4XWordBreakIteratorUtf16::is_word_like() const { + return capi::ICU4XWordBreakIteratorUtf16_is_word_like(this->inner.get()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorUtf8.h b/third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorUtf8.h new file mode 100644 index 000000000000..d8e98fb9b19d --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorUtf8.h @@ -0,0 +1,34 @@ +#ifndef ICU4XWordBreakIteratorUtf8_H +#define ICU4XWordBreakIteratorUtf8_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XWordBreakIteratorUtf8 ICU4XWordBreakIteratorUtf8; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XSegmenterWordType.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +int32_t ICU4XWordBreakIteratorUtf8_next(ICU4XWordBreakIteratorUtf8* self); + +ICU4XSegmenterWordType ICU4XWordBreakIteratorUtf8_word_type(const ICU4XWordBreakIteratorUtf8* self); + +bool ICU4XWordBreakIteratorUtf8_is_word_like(const ICU4XWordBreakIteratorUtf8* self); +void ICU4XWordBreakIteratorUtf8_destroy(ICU4XWordBreakIteratorUtf8* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorUtf8.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorUtf8.hpp new file mode 100644 index 000000000000..0c581884ae66 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XWordBreakIteratorUtf8.hpp @@ -0,0 +1,74 @@ +#ifndef ICU4XWordBreakIteratorUtf8_HPP +#define ICU4XWordBreakIteratorUtf8_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XWordBreakIteratorUtf8.h" + +#include "ICU4XSegmenterWordType.hpp" + +/** + * A destruction policy for using ICU4XWordBreakIteratorUtf8 with std::unique_ptr. + */ +struct ICU4XWordBreakIteratorUtf8Deleter { + void operator()(capi::ICU4XWordBreakIteratorUtf8* l) const noexcept { + capi::ICU4XWordBreakIteratorUtf8_destroy(l); + } +}; + +/** + * + * + * See the [Rust documentation for `WordBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html) for more information. + */ +class ICU4XWordBreakIteratorUtf8 { + public: + + /** + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is + * out of range of a 32-bit signed integer. + * + * See the [Rust documentation for `next`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.next) for more information. + */ + int32_t next(); + + /** + * Return the status value of break boundary. + * + * See the [Rust documentation for `word_type`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.word_type) for more information. + */ + ICU4XSegmenterWordType word_type() const; + + /** + * Return true when break boundary is word-like such as letter/number/CJK + * + * See the [Rust documentation for `is_word_like`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.is_word_like) for more information. + */ + bool is_word_like() const; + inline const capi::ICU4XWordBreakIteratorUtf8* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XWordBreakIteratorUtf8* AsFFIMut() { return this->inner.get(); } + inline ICU4XWordBreakIteratorUtf8(capi::ICU4XWordBreakIteratorUtf8* i) : inner(i) {} + ICU4XWordBreakIteratorUtf8() = default; + ICU4XWordBreakIteratorUtf8(ICU4XWordBreakIteratorUtf8&&) noexcept = default; + ICU4XWordBreakIteratorUtf8& operator=(ICU4XWordBreakIteratorUtf8&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + + +inline int32_t ICU4XWordBreakIteratorUtf8::next() { + return capi::ICU4XWordBreakIteratorUtf8_next(this->inner.get()); +} +inline ICU4XSegmenterWordType ICU4XWordBreakIteratorUtf8::word_type() const { + return static_cast(capi::ICU4XWordBreakIteratorUtf8_word_type(this->inner.get())); +} +inline bool ICU4XWordBreakIteratorUtf8::is_word_like() const { + return capi::ICU4XWordBreakIteratorUtf8_is_word_like(this->inner.get()); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XWordSegmenter.h b/third_party/rust/icu_capi/cpp/include/ICU4XWordSegmenter.h new file mode 100644 index 000000000000..5bef9437e092 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XWordSegmenter.h @@ -0,0 +1,44 @@ +#ifndef ICU4XWordSegmenter_H +#define ICU4XWordSegmenter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XWordSegmenter ICU4XWordSegmenter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "diplomat_result_box_ICU4XWordSegmenter_ICU4XError.h" +#include "ICU4XWordBreakIteratorUtf8.h" +#include "ICU4XWordBreakIteratorUtf16.h" +#include "ICU4XWordBreakIteratorLatin1.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XWordSegmenter_ICU4XError ICU4XWordSegmenter_create_auto(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XWordSegmenter_ICU4XError ICU4XWordSegmenter_create_lstm(const ICU4XDataProvider* provider); + +diplomat_result_box_ICU4XWordSegmenter_ICU4XError ICU4XWordSegmenter_create_dictionary(const ICU4XDataProvider* provider); + +ICU4XWordBreakIteratorUtf8* ICU4XWordSegmenter_segment_utf8(const ICU4XWordSegmenter* self, const char* input_data, size_t input_len); + +ICU4XWordBreakIteratorUtf16* ICU4XWordSegmenter_segment_utf16(const ICU4XWordSegmenter* self, const uint16_t* input_data, size_t input_len); + +ICU4XWordBreakIteratorLatin1* ICU4XWordSegmenter_segment_latin1(const ICU4XWordSegmenter* self, const uint8_t* input_data, size_t input_len); +void ICU4XWordSegmenter_destroy(ICU4XWordSegmenter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XWordSegmenter.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XWordSegmenter.hpp new file mode 100644 index 000000000000..d8bbfe923b45 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XWordSegmenter.hpp @@ -0,0 +1,148 @@ +#ifndef ICU4XWordSegmenter_HPP +#define ICU4XWordSegmenter_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XWordSegmenter.h" + +class ICU4XDataProvider; +class ICU4XWordSegmenter; +#include "ICU4XError.hpp" +class ICU4XWordBreakIteratorUtf8; +class ICU4XWordBreakIteratorUtf16; +class ICU4XWordBreakIteratorLatin1; + +/** + * A destruction policy for using ICU4XWordSegmenter with std::unique_ptr. + */ +struct ICU4XWordSegmenterDeleter { + void operator()(capi::ICU4XWordSegmenter* l) const noexcept { + capi::ICU4XWordSegmenter_destroy(l); + } +}; + +/** + * 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. + */ +class ICU4XWordSegmenter { + public: + + /** + * Construct an [`ICU4XWordSegmenter`] with automatically selecting the best available LSTM + * or dictionary payload data. + * + * Note: currently, it uses dictionary for Chinese and Japanese, and LSTM for Burmese, + * Khmer, Lao, and Thai. + * + * See the [Rust documentation for `try_new_auto_unstable`](https://docs.rs/icu/latest/icu/segmenter/struct.WordSegmenter.html#method.try_new_auto_unstable) for more information. + */ + static diplomat::result create_auto(const ICU4XDataProvider& provider); + + /** + * Construct an [`ICU4XWordSegmenter`] with LSTM payload data for Burmese, Khmer, Lao, and + * Thai. + * + * Warning: [`ICU4XWordSegmenter`] created by this function doesn't handle Chinese or + * Japanese. + * + * See the [Rust documentation for `try_new_lstm_unstable`](https://docs.rs/icu/latest/icu/segmenter/struct.WordSegmenter.html#method.try_new_lstm_unstable) for more information. + */ + static diplomat::result create_lstm(const ICU4XDataProvider& provider); + + /** + * Construct an [`ICU4XWordSegmenter`] with dictionary payload data for Chinese, Japanese, + * Burmese, Khmer, Lao, and Thai. + * + * See the [Rust documentation for `try_new_dictionary_unstable`](https://docs.rs/icu/latest/icu/segmenter/struct.WordSegmenter.html#method.try_new_dictionary_unstable) for more information. + */ + static diplomat::result create_dictionary(const ICU4XDataProvider& provider); + + /** + * Segments a (potentially ill-formed) UTF-8 string. + * + * See the [Rust documentation for `segment_utf8`](https://docs.rs/icu/latest/icu/segmenter/struct.WordSegmenter.html#method.segment_utf8) for more information. + * + * Lifetimes: `this`, `input` must live at least as long as the output. + */ + ICU4XWordBreakIteratorUtf8 segment_utf8(const std::string_view input) const; + + /** + * Segments a UTF-16 string. + * + * See the [Rust documentation for `segment_utf16`](https://docs.rs/icu/latest/icu/segmenter/struct.WordSegmenter.html#method.segment_utf16) for more information. + * + * Lifetimes: `this`, `input` must live at least as long as the output. + */ + ICU4XWordBreakIteratorUtf16 segment_utf16(const diplomat::span input) const; + + /** + * Segments a Latin-1 string. + * + * See the [Rust documentation for `segment_latin1`](https://docs.rs/icu/latest/icu/segmenter/struct.WordSegmenter.html#method.segment_latin1) for more information. + * + * Lifetimes: `this`, `input` must live at least as long as the output. + */ + ICU4XWordBreakIteratorLatin1 segment_latin1(const diplomat::span input) const; + inline const capi::ICU4XWordSegmenter* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XWordSegmenter* AsFFIMut() { return this->inner.get(); } + inline ICU4XWordSegmenter(capi::ICU4XWordSegmenter* i) : inner(i) {} + ICU4XWordSegmenter() = default; + ICU4XWordSegmenter(ICU4XWordSegmenter&&) noexcept = default; + ICU4XWordSegmenter& operator=(ICU4XWordSegmenter&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XWordBreakIteratorUtf8.hpp" +#include "ICU4XWordBreakIteratorUtf16.hpp" +#include "ICU4XWordBreakIteratorLatin1.hpp" + +inline diplomat::result ICU4XWordSegmenter::create_auto(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XWordSegmenter_create_auto(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XWordSegmenter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XWordSegmenter::create_lstm(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XWordSegmenter_create_lstm(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XWordSegmenter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XWordSegmenter::create_dictionary(const ICU4XDataProvider& provider) { + auto diplomat_result_raw_out_value = capi::ICU4XWordSegmenter_create_dictionary(provider.AsFFI()); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XWordSegmenter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline ICU4XWordBreakIteratorUtf8 ICU4XWordSegmenter::segment_utf8(const std::string_view input) const { + return ICU4XWordBreakIteratorUtf8(capi::ICU4XWordSegmenter_segment_utf8(this->inner.get(), input.data(), input.size())); +} +inline ICU4XWordBreakIteratorUtf16 ICU4XWordSegmenter::segment_utf16(const diplomat::span input) const { + return ICU4XWordBreakIteratorUtf16(capi::ICU4XWordSegmenter_segment_utf16(this->inner.get(), input.data(), input.size())); +} +inline ICU4XWordBreakIteratorLatin1 ICU4XWordSegmenter::segment_latin1(const diplomat::span input) const { + return ICU4XWordBreakIteratorLatin1(capi::ICU4XWordSegmenter_segment_latin1(this->inner.get(), input.data(), input.size())); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XZonedDateTimeFormatter.h b/third_party/rust/icu_capi/cpp/include/ICU4XZonedDateTimeFormatter.h new file mode 100644 index 000000000000..77b228a5a2cf --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XZonedDateTimeFormatter.h @@ -0,0 +1,45 @@ +#ifndef ICU4XZonedDateTimeFormatter_H +#define ICU4XZonedDateTimeFormatter_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +#endif + +typedef struct ICU4XZonedDateTimeFormatter ICU4XZonedDateTimeFormatter; +#ifdef __cplusplus +} // namespace capi +#endif +#include "ICU4XDataProvider.h" +#include "ICU4XLocale.h" +#include "ICU4XDateLength.h" +#include "ICU4XTimeLength.h" +#include "diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError.h" +#include "ICU4XIsoTimeZoneOptions.h" +#include "ICU4XDateTime.h" +#include "ICU4XCustomTimeZone.h" +#include "diplomat_result_void_ICU4XError.h" +#include "ICU4XIsoDateTime.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError ICU4XZonedDateTimeFormatter_create_with_lengths(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XDateLength date_length, ICU4XTimeLength time_length); + +diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError ICU4XZonedDateTimeFormatter_create_with_lengths_and_iso_8601_time_zone_fallback(const ICU4XDataProvider* provider, const ICU4XLocale* locale, ICU4XDateLength date_length, ICU4XTimeLength time_length, ICU4XIsoTimeZoneOptions zone_options); + +diplomat_result_void_ICU4XError ICU4XZonedDateTimeFormatter_format_datetime_with_custom_time_zone(const ICU4XZonedDateTimeFormatter* self, const ICU4XDateTime* datetime, const ICU4XCustomTimeZone* time_zone, DiplomatWriteable* write); + +diplomat_result_void_ICU4XError ICU4XZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone(const ICU4XZonedDateTimeFormatter* self, const ICU4XIsoDateTime* datetime, const ICU4XCustomTimeZone* time_zone, DiplomatWriteable* write); +void ICU4XZonedDateTimeFormatter_destroy(ICU4XZonedDateTimeFormatter* self); + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/ICU4XZonedDateTimeFormatter.hpp b/third_party/rust/icu_capi/cpp/include/ICU4XZonedDateTimeFormatter.hpp new file mode 100644 index 000000000000..9c2ee8a90a6c --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/ICU4XZonedDateTimeFormatter.hpp @@ -0,0 +1,173 @@ +#ifndef ICU4XZonedDateTimeFormatter_HPP +#define ICU4XZonedDateTimeFormatter_HPP +#include +#include +#include +#include +#include +#include +#include +#include "diplomat_runtime.hpp" + +#include "ICU4XZonedDateTimeFormatter.h" + +class ICU4XDataProvider; +class ICU4XLocale; +#include "ICU4XDateLength.hpp" +#include "ICU4XTimeLength.hpp" +class ICU4XZonedDateTimeFormatter; +#include "ICU4XError.hpp" +struct ICU4XIsoTimeZoneOptions; +class ICU4XDateTime; +class ICU4XCustomTimeZone; +class ICU4XIsoDateTime; + +/** + * A destruction policy for using ICU4XZonedDateTimeFormatter with std::unique_ptr. + */ +struct ICU4XZonedDateTimeFormatterDeleter { + void operator()(capi::ICU4XZonedDateTimeFormatter* l) const noexcept { + capi::ICU4XZonedDateTimeFormatter_destroy(l); + } +}; + +/** + * 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. + */ +class ICU4XZonedDateTimeFormatter { + public: + + /** + * Creates a new [`ICU4XZonedDateTimeFormatter`] from locale data. + * + * This function has `date_length` and `time_length` arguments and uses default options + * for the time zone. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/datetime/struct.ZonedDateTimeFormatter.html#method.try_new_unstable) for more information. + */ + static diplomat::result create_with_lengths(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XDateLength date_length, ICU4XTimeLength time_length); + + /** + * Creates a new [`ICU4XZonedDateTimeFormatter`] from locale data. + * + * This function has `date_length` and `time_length` arguments and uses an ISO-8601 style + * fallback for the time zone with the given configurations. + * + * See the [Rust documentation for `try_new_unstable`](https://docs.rs/icu/latest/icu/datetime/struct.ZonedDateTimeFormatter.html#method.try_new_unstable) for more information. + */ + static diplomat::result create_with_lengths_and_iso_8601_time_zone_fallback(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XDateLength date_length, ICU4XTimeLength time_length, ICU4XIsoTimeZoneOptions zone_options); + + /** + * Formats a [`ICU4XDateTime`] and [`ICU4XCustomTimeZone`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.ZonedDateTimeFormatter.html#method.format) for more information. + */ + template diplomat::result format_datetime_with_custom_time_zone_to_writeable(const ICU4XDateTime& datetime, const ICU4XCustomTimeZone& time_zone, W& write) const; + + /** + * Formats a [`ICU4XDateTime`] and [`ICU4XCustomTimeZone`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.ZonedDateTimeFormatter.html#method.format) for more information. + */ + diplomat::result format_datetime_with_custom_time_zone(const ICU4XDateTime& datetime, const ICU4XCustomTimeZone& time_zone) const; + + /** + * Formats a [`ICU4XIsoDateTime`] and [`ICU4XCustomTimeZone`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.ZonedDateTimeFormatter.html#method.format) for more information. + */ + template diplomat::result format_iso_datetime_with_custom_time_zone_to_writeable(const ICU4XIsoDateTime& datetime, const ICU4XCustomTimeZone& time_zone, W& write) const; + + /** + * Formats a [`ICU4XIsoDateTime`] and [`ICU4XCustomTimeZone`] to a string. + * + * See the [Rust documentation for `format`](https://docs.rs/icu/latest/icu/datetime/struct.ZonedDateTimeFormatter.html#method.format) for more information. + */ + diplomat::result format_iso_datetime_with_custom_time_zone(const ICU4XIsoDateTime& datetime, const ICU4XCustomTimeZone& time_zone) const; + inline const capi::ICU4XZonedDateTimeFormatter* AsFFI() const { return this->inner.get(); } + inline capi::ICU4XZonedDateTimeFormatter* AsFFIMut() { return this->inner.get(); } + inline ICU4XZonedDateTimeFormatter(capi::ICU4XZonedDateTimeFormatter* i) : inner(i) {} + ICU4XZonedDateTimeFormatter() = default; + ICU4XZonedDateTimeFormatter(ICU4XZonedDateTimeFormatter&&) noexcept = default; + ICU4XZonedDateTimeFormatter& operator=(ICU4XZonedDateTimeFormatter&& other) noexcept = default; + private: + std::unique_ptr inner; +}; + +#include "ICU4XDataProvider.hpp" +#include "ICU4XLocale.hpp" +#include "ICU4XIsoTimeZoneOptions.hpp" +#include "ICU4XDateTime.hpp" +#include "ICU4XCustomTimeZone.hpp" +#include "ICU4XIsoDateTime.hpp" + +inline diplomat::result ICU4XZonedDateTimeFormatter::create_with_lengths(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XDateLength date_length, ICU4XTimeLength time_length) { + auto diplomat_result_raw_out_value = capi::ICU4XZonedDateTimeFormatter_create_with_lengths(provider.AsFFI(), locale.AsFFI(), static_cast(date_length), static_cast(time_length)); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XZonedDateTimeFormatter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XZonedDateTimeFormatter::create_with_lengths_and_iso_8601_time_zone_fallback(const ICU4XDataProvider& provider, const ICU4XLocale& locale, ICU4XDateLength date_length, ICU4XTimeLength time_length, ICU4XIsoTimeZoneOptions zone_options) { + ICU4XIsoTimeZoneOptions diplomat_wrapped_struct_zone_options = zone_options; + auto diplomat_result_raw_out_value = capi::ICU4XZonedDateTimeFormatter_create_with_lengths_and_iso_8601_time_zone_fallback(provider.AsFFI(), locale.AsFFI(), static_cast(date_length), static_cast(time_length), capi::ICU4XIsoTimeZoneOptions{ .format = static_cast(diplomat_wrapped_struct_zone_options.format), .minutes = static_cast(diplomat_wrapped_struct_zone_options.minutes), .seconds = static_cast(diplomat_wrapped_struct_zone_options.seconds) }); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::move(ICU4XZonedDateTimeFormatter(diplomat_result_raw_out_value.ok))); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +template inline diplomat::result ICU4XZonedDateTimeFormatter::format_datetime_with_custom_time_zone_to_writeable(const ICU4XDateTime& datetime, const ICU4XCustomTimeZone& time_zone, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XZonedDateTimeFormatter_format_datetime_with_custom_time_zone(this->inner.get(), datetime.AsFFI(), time_zone.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XZonedDateTimeFormatter::format_datetime_with_custom_time_zone(const ICU4XDateTime& datetime, const ICU4XCustomTimeZone& time_zone) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XZonedDateTimeFormatter_format_datetime_with_custom_time_zone(this->inner.get(), datetime.AsFFI(), time_zone.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +template inline diplomat::result ICU4XZonedDateTimeFormatter::format_iso_datetime_with_custom_time_zone_to_writeable(const ICU4XIsoDateTime& datetime, const ICU4XCustomTimeZone& time_zone, W& write) const { + capi::DiplomatWriteable write_writer = diplomat::WriteableTrait::Construct(write); + auto diplomat_result_raw_out_value = capi::ICU4XZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone(this->inner.get(), datetime.AsFFI(), time_zone.AsFFI(), &write_writer); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value; +} +inline diplomat::result ICU4XZonedDateTimeFormatter::format_iso_datetime_with_custom_time_zone(const ICU4XIsoDateTime& datetime, const ICU4XCustomTimeZone& time_zone) const { + std::string diplomat_writeable_string; + capi::DiplomatWriteable diplomat_writeable_out = diplomat::WriteableFromString(diplomat_writeable_string); + auto diplomat_result_raw_out_value = capi::ICU4XZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone(this->inner.get(), datetime.AsFFI(), time_zone.AsFFI(), &diplomat_writeable_out); + diplomat::result diplomat_result_out_value; + if (diplomat_result_raw_out_value.is_ok) { + diplomat_result_out_value = diplomat::Ok(std::monostate()); + } else { + diplomat_result_out_value = diplomat::Err(std::move(static_cast(diplomat_result_raw_out_value.err))); + } + return diplomat_result_out_value.replace_ok(std::move(diplomat_writeable_string)); +} +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_ICU4XAnyCalendarKind_void.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_ICU4XAnyCalendarKind_void.h new file mode 100644 index 000000000000..f67f66ed4db4 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_ICU4XAnyCalendarKind_void.h @@ -0,0 +1,24 @@ +#ifndef diplomat_result_ICU4XAnyCalendarKind_void_H +#define diplomat_result_ICU4XAnyCalendarKind_void_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XAnyCalendarKind.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_ICU4XAnyCalendarKind_void { + union { + ICU4XAnyCalendarKind ok; + }; + bool is_ok; +} diplomat_result_ICU4XAnyCalendarKind_void; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_ICU4XPluralCategory_void.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_ICU4XPluralCategory_void.h new file mode 100644 index 000000000000..b56ef60acb7f --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_ICU4XPluralCategory_void.h @@ -0,0 +1,24 @@ +#ifndef diplomat_result_ICU4XPluralCategory_void_H +#define diplomat_result_ICU4XPluralCategory_void_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XPluralCategory.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_ICU4XPluralCategory_void { + union { + ICU4XPluralCategory ok; + }; + bool is_ok; +} diplomat_result_ICU4XPluralCategory_void; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_ICU4XWeekOf_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_ICU4XWeekOf_ICU4XError.h new file mode 100644 index 000000000000..4dee8f941f70 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_ICU4XWeekOf_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_ICU4XWeekOf_ICU4XError_H +#define diplomat_result_ICU4XWeekOf_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XWeekOf.h" +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_ICU4XWeekOf_ICU4XError { + union { + ICU4XWeekOf ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_ICU4XWeekOf_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_bool_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_bool_ICU4XError.h new file mode 100644 index 000000000000..015930214da6 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_bool_ICU4XError.h @@ -0,0 +1,25 @@ +#ifndef diplomat_result_bool_ICU4XError_H +#define diplomat_result_bool_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_bool_ICU4XError { + union { + bool ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_bool_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XBidi_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XBidi_ICU4XError.h new file mode 100644 index 000000000000..f1cd7ca6a30d --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XBidi_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XBidi_ICU4XError_H +#define diplomat_result_box_ICU4XBidi_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XBidi ICU4XBidi; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XBidi_ICU4XError { + union { + ICU4XBidi* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XBidi_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCalendar_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCalendar_ICU4XError.h new file mode 100644 index 000000000000..bffa22c6b027 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCalendar_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XCalendar_ICU4XError_H +#define diplomat_result_box_ICU4XCalendar_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XCalendar ICU4XCalendar; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XCalendar_ICU4XError { + union { + ICU4XCalendar* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XCalendar_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError.h new file mode 100644 index 000000000000..2c05f7967151 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError_H +#define diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XCanonicalCombiningClassMap ICU4XCanonicalCombiningClassMap; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError { + union { + ICU4XCanonicalCombiningClassMap* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XCanonicalCombiningClassMap_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCanonicalComposition_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCanonicalComposition_ICU4XError.h new file mode 100644 index 000000000000..66d0386ff8b0 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCanonicalComposition_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XCanonicalComposition_ICU4XError_H +#define diplomat_result_box_ICU4XCanonicalComposition_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XCanonicalComposition ICU4XCanonicalComposition; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XCanonicalComposition_ICU4XError { + union { + ICU4XCanonicalComposition* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XCanonicalComposition_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError.h new file mode 100644 index 000000000000..cf02637fef0f --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError_H +#define diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XCanonicalDecomposition ICU4XCanonicalDecomposition; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError { + union { + ICU4XCanonicalDecomposition* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XCanonicalDecomposition_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCodePointMapData16_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCodePointMapData16_ICU4XError.h new file mode 100644 index 000000000000..fbe11daad2e1 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCodePointMapData16_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XCodePointMapData16_ICU4XError_H +#define diplomat_result_box_ICU4XCodePointMapData16_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XCodePointMapData16 ICU4XCodePointMapData16; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XCodePointMapData16_ICU4XError { + union { + ICU4XCodePointMapData16* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XCodePointMapData16_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCodePointMapData8_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCodePointMapData8_ICU4XError.h new file mode 100644 index 000000000000..2e203279e3b8 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCodePointMapData8_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XCodePointMapData8_ICU4XError_H +#define diplomat_result_box_ICU4XCodePointMapData8_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XCodePointMapData8 ICU4XCodePointMapData8; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XCodePointMapData8_ICU4XError { + union { + ICU4XCodePointMapData8* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XCodePointMapData8_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCodePointSetData_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCodePointSetData_ICU4XError.h new file mode 100644 index 000000000000..e70e39ba61dc --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCodePointSetData_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XCodePointSetData_ICU4XError_H +#define diplomat_result_box_ICU4XCodePointSetData_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XCodePointSetData ICU4XCodePointSetData; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XCodePointSetData_ICU4XError { + union { + ICU4XCodePointSetData* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XCodePointSetData_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCollator_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCollator_ICU4XError.h new file mode 100644 index 000000000000..abb5c8a59839 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCollator_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XCollator_ICU4XError_H +#define diplomat_result_box_ICU4XCollator_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XCollator ICU4XCollator; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XCollator_ICU4XError { + union { + ICU4XCollator* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XCollator_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XComposingNormalizer_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XComposingNormalizer_ICU4XError.h new file mode 100644 index 000000000000..d0c381ef039c --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XComposingNormalizer_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XComposingNormalizer_ICU4XError_H +#define diplomat_result_box_ICU4XComposingNormalizer_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XComposingNormalizer ICU4XComposingNormalizer; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XComposingNormalizer_ICU4XError { + union { + ICU4XComposingNormalizer* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XComposingNormalizer_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCustomTimeZone_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCustomTimeZone_ICU4XError.h new file mode 100644 index 000000000000..4709a89871e5 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XCustomTimeZone_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XCustomTimeZone_ICU4XError_H +#define diplomat_result_box_ICU4XCustomTimeZone_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XCustomTimeZone ICU4XCustomTimeZone; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XCustomTimeZone_ICU4XError { + union { + ICU4XCustomTimeZone* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XCustomTimeZone_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDataProvider_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDataProvider_ICU4XError.h new file mode 100644 index 000000000000..a5be84418382 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDataProvider_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XDataProvider_ICU4XError_H +#define diplomat_result_box_ICU4XDataProvider_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XDataProvider ICU4XDataProvider; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XDataProvider_ICU4XError { + union { + ICU4XDataProvider* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XDataProvider_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDataStruct_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDataStruct_ICU4XError.h new file mode 100644 index 000000000000..d8c1d33e2107 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDataStruct_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XDataStruct_ICU4XError_H +#define diplomat_result_box_ICU4XDataStruct_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XDataStruct ICU4XDataStruct; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XDataStruct_ICU4XError { + union { + ICU4XDataStruct* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XDataStruct_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDateFormatter_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDateFormatter_ICU4XError.h new file mode 100644 index 000000000000..b6d9671434c5 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDateFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XDateFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XDateFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XDateFormatter ICU4XDateFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XDateFormatter_ICU4XError { + union { + ICU4XDateFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XDateFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError.h new file mode 100644 index 000000000000..855e74fe6c06 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XDateTimeFormatter ICU4XDateTimeFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError { + union { + ICU4XDateTimeFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XDateTimeFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDateTime_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDateTime_ICU4XError.h new file mode 100644 index 000000000000..2d4cb2fe4840 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDateTime_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XDateTime_ICU4XError_H +#define diplomat_result_box_ICU4XDateTime_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XDateTime ICU4XDateTime; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XDateTime_ICU4XError { + union { + ICU4XDateTime* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XDateTime_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDate_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDate_ICU4XError.h new file mode 100644 index 000000000000..30461b264a65 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDate_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XDate_ICU4XError_H +#define diplomat_result_box_ICU4XDate_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XDate ICU4XDate; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XDate_ICU4XError { + union { + ICU4XDate* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XDate_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError.h new file mode 100644 index 000000000000..c51d9907bc9f --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError_H +#define diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XDecomposingNormalizer ICU4XDecomposingNormalizer; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError { + union { + ICU4XDecomposingNormalizer* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XDecomposingNormalizer_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError.h new file mode 100644 index 000000000000..8ee245a09336 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XFixedDecimalFormatter ICU4XFixedDecimalFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError { + union { + ICU4XFixedDecimalFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XFixedDecimalFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XFixedDecimal_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XFixedDecimal_ICU4XError.h new file mode 100644 index 000000000000..f45cd78fb93b --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XFixedDecimal_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XFixedDecimal_ICU4XError_H +#define diplomat_result_box_ICU4XFixedDecimal_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XFixedDecimal ICU4XFixedDecimal; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XFixedDecimal_ICU4XError { + union { + ICU4XFixedDecimal* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XFixedDecimal_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError.h new file mode 100644 index 000000000000..98ff137a9a3c --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError_H +#define diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XGeneralCategoryNameToMaskMapper ICU4XGeneralCategoryNameToMaskMapper; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError { + union { + ICU4XGeneralCategoryNameToMaskMapper* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XGeneralCategoryNameToMaskMapper_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError.h new file mode 100644 index 000000000000..d560b381a59d --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError_H +#define diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XGraphemeClusterSegmenter ICU4XGraphemeClusterSegmenter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError { + union { + ICU4XGraphemeClusterSegmenter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XGraphemeClusterSegmenter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError.h new file mode 100644 index 000000000000..86b13be9121b --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XGregorianDateFormatter ICU4XGregorianDateFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError { + union { + ICU4XGregorianDateFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XGregorianDateFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError.h new file mode 100644 index 000000000000..4393d9ffb0fb --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XGregorianDateTimeFormatter ICU4XGregorianDateTimeFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError { + union { + ICU4XGregorianDateTimeFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XGregorianDateTimeFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError.h new file mode 100644 index 000000000000..270b38ba94ce --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XGregorianZonedDateTimeFormatter ICU4XGregorianZonedDateTimeFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError { + union { + ICU4XGregorianZonedDateTimeFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XGregorianZonedDateTimeFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XIsoDateTime_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XIsoDateTime_ICU4XError.h new file mode 100644 index 000000000000..8a55b47a68b0 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XIsoDateTime_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XIsoDateTime_ICU4XError_H +#define diplomat_result_box_ICU4XIsoDateTime_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XIsoDateTime ICU4XIsoDateTime; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XIsoDateTime_ICU4XError { + union { + ICU4XIsoDateTime* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XIsoDateTime_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XIsoDate_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XIsoDate_ICU4XError.h new file mode 100644 index 000000000000..8528d73b0721 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XIsoDate_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XIsoDate_ICU4XError_H +#define diplomat_result_box_ICU4XIsoDate_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XIsoDate ICU4XIsoDate; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XIsoDate_ICU4XError { + union { + ICU4XIsoDate* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XIsoDate_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLineSegmenter_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLineSegmenter_ICU4XError.h new file mode 100644 index 000000000000..004d3494ae04 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLineSegmenter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XLineSegmenter_ICU4XError_H +#define diplomat_result_box_ICU4XLineSegmenter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XLineSegmenter ICU4XLineSegmenter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XLineSegmenter_ICU4XError { + union { + ICU4XLineSegmenter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XLineSegmenter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XListFormatter_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XListFormatter_ICU4XError.h new file mode 100644 index 000000000000..df40aa2daed1 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XListFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XListFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XListFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XListFormatter ICU4XListFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XListFormatter_ICU4XError { + union { + ICU4XListFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XListFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError.h new file mode 100644 index 000000000000..a49bb700ca67 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError_H +#define diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XLocaleCanonicalizer ICU4XLocaleCanonicalizer; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError { + union { + ICU4XLocaleCanonicalizer* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XLocaleCanonicalizer_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError.h new file mode 100644 index 000000000000..6b0f09b2a2ff --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XLocaleDisplayNamesFormatter ICU4XLocaleDisplayNamesFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError { + union { + ICU4XLocaleDisplayNamesFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XLocaleDisplayNamesFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleExpander_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleExpander_ICU4XError.h new file mode 100644 index 000000000000..c7275e699c2d --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleExpander_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XLocaleExpander_ICU4XError_H +#define diplomat_result_box_ICU4XLocaleExpander_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XLocaleExpander ICU4XLocaleExpander; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XLocaleExpander_ICU4XError { + union { + ICU4XLocaleExpander* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XLocaleExpander_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError.h new file mode 100644 index 000000000000..0dc002718e8c --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError_H +#define diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XLocaleFallbackerWithConfig ICU4XLocaleFallbackerWithConfig; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError { + union { + ICU4XLocaleFallbackerWithConfig* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XLocaleFallbackerWithConfig_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError.h new file mode 100644 index 000000000000..3427bf3e3a35 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError_H +#define diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XLocaleFallbacker ICU4XLocaleFallbacker; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError { + union { + ICU4XLocaleFallbacker* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XLocaleFallbacker_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocale_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocale_ICU4XError.h new file mode 100644 index 000000000000..f5720b612f3d --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XLocale_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XLocale_ICU4XError_H +#define diplomat_result_box_ICU4XLocale_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XLocale ICU4XLocale; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XLocale_ICU4XError { + union { + ICU4XLocale* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XLocale_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError.h new file mode 100644 index 000000000000..ebd519e0b5b4 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError_H +#define diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XMetazoneCalculator ICU4XMetazoneCalculator; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError { + union { + ICU4XMetazoneCalculator* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XMetazoneCalculator_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XPluralOperands_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XPluralOperands_ICU4XError.h new file mode 100644 index 000000000000..7c068ba4b801 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XPluralOperands_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XPluralOperands_ICU4XError_H +#define diplomat_result_box_ICU4XPluralOperands_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XPluralOperands ICU4XPluralOperands; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XPluralOperands_ICU4XError { + union { + ICU4XPluralOperands* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XPluralOperands_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XPluralRules_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XPluralRules_ICU4XError.h new file mode 100644 index 000000000000..4fa522b8508f --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XPluralRules_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XPluralRules_ICU4XError_H +#define diplomat_result_box_ICU4XPluralRules_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XPluralRules ICU4XPluralRules; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XPluralRules_ICU4XError { + union { + ICU4XPluralRules* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XPluralRules_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError.h new file mode 100644 index 000000000000..047ef959b040 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError_H +#define diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XPropertyValueNameToEnumMapper ICU4XPropertyValueNameToEnumMapper; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError { + union { + ICU4XPropertyValueNameToEnumMapper* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XPropertyValueNameToEnumMapper_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError.h new file mode 100644 index 000000000000..fcf7e88a232a --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError_H +#define diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XRegionDisplayNames ICU4XRegionDisplayNames; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError { + union { + ICU4XRegionDisplayNames* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XRegionDisplayNames_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError.h new file mode 100644 index 000000000000..bffd6161aa8d --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError_H +#define diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XScriptWithExtensions ICU4XScriptWithExtensions; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError { + union { + ICU4XScriptWithExtensions* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XScriptWithExtensions_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError.h new file mode 100644 index 000000000000..a8ab968fa946 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError_H +#define diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XSentenceSegmenter ICU4XSentenceSegmenter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError { + union { + ICU4XSentenceSegmenter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XSentenceSegmenter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XTimeFormatter_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XTimeFormatter_ICU4XError.h new file mode 100644 index 000000000000..0e63cbbc2a80 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XTimeFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XTimeFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XTimeFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XTimeFormatter ICU4XTimeFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XTimeFormatter_ICU4XError { + union { + ICU4XTimeFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XTimeFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError.h new file mode 100644 index 000000000000..5f4851051e9a --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XTimeZoneFormatter ICU4XTimeZoneFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError { + union { + ICU4XTimeZoneFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XTimeZoneFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XTime_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XTime_ICU4XError.h new file mode 100644 index 000000000000..3e58b1e4daa6 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XTime_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XTime_ICU4XError_H +#define diplomat_result_box_ICU4XTime_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XTime ICU4XTime; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XTime_ICU4XError { + union { + ICU4XTime* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XTime_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XUnicodeSetData_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XUnicodeSetData_ICU4XError.h new file mode 100644 index 000000000000..6dd14e82b64d --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XUnicodeSetData_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XUnicodeSetData_ICU4XError_H +#define diplomat_result_box_ICU4XUnicodeSetData_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XUnicodeSetData ICU4XUnicodeSetData; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XUnicodeSetData_ICU4XError { + union { + ICU4XUnicodeSetData* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XUnicodeSetData_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XWeekCalculator_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XWeekCalculator_ICU4XError.h new file mode 100644 index 000000000000..1f547fd383c3 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XWeekCalculator_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XWeekCalculator_ICU4XError_H +#define diplomat_result_box_ICU4XWeekCalculator_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XWeekCalculator ICU4XWeekCalculator; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XWeekCalculator_ICU4XError { + union { + ICU4XWeekCalculator* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XWeekCalculator_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XWordSegmenter_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XWordSegmenter_ICU4XError.h new file mode 100644 index 000000000000..e41c59b661e1 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XWordSegmenter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XWordSegmenter_ICU4XError_H +#define diplomat_result_box_ICU4XWordSegmenter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XWordSegmenter ICU4XWordSegmenter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XWordSegmenter_ICU4XError { + union { + ICU4XWordSegmenter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XWordSegmenter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError.h new file mode 100644 index 000000000000..52a0ab446213 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError.h @@ -0,0 +1,26 @@ +#ifndef diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError_H +#define diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +typedef struct ICU4XZonedDateTimeFormatter ICU4XZonedDateTimeFormatter; +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError { + union { + ICU4XZonedDateTimeFormatter* ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_box_ICU4XZonedDateTimeFormatter_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_int32_t_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_int32_t_ICU4XError.h new file mode 100644 index 000000000000..adbe148dd153 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_int32_t_ICU4XError.h @@ -0,0 +1,25 @@ +#ifndef diplomat_result_int32_t_ICU4XError_H +#define diplomat_result_int32_t_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_int32_t_ICU4XError { + union { + int32_t ok; + ICU4XError err; + }; + bool is_ok; +} diplomat_result_int32_t_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_uint16_t_void.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_uint16_t_void.h new file mode 100644 index 000000000000..3adeb5f36de3 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_uint16_t_void.h @@ -0,0 +1,23 @@ +#ifndef diplomat_result_uint16_t_void_H +#define diplomat_result_uint16_t_void_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_uint16_t_void { + union { + uint16_t ok; + }; + bool is_ok; +} diplomat_result_uint16_t_void; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_void_ICU4XError.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_void_ICU4XError.h new file mode 100644 index 000000000000..f092491e3404 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_void_ICU4XError.h @@ -0,0 +1,24 @@ +#ifndef diplomat_result_void_ICU4XError_H +#define diplomat_result_void_ICU4XError_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#include "ICU4XError.h" +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_void_ICU4XError { + union { + ICU4XError err; + }; + bool is_ok; +} diplomat_result_void_ICU4XError; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_result_void_void.h b/third_party/rust/icu_capi/cpp/include/diplomat_result_void_void.h new file mode 100644 index 000000000000..2d5cc704e526 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_result_void_void.h @@ -0,0 +1,20 @@ +#ifndef diplomat_result_void_void_H +#define diplomat_result_void_void_H +#include +#include +#include +#include +#include "diplomat_runtime.h" + +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif +typedef struct diplomat_result_void_void { + bool is_ok; +} diplomat_result_void_void; +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_runtime.h b/third_party/rust/icu_capi/cpp/include/diplomat_runtime.h new file mode 100644 index 000000000000..de0f9c76fee3 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_runtime.h @@ -0,0 +1,70 @@ +#ifndef DIPLOMAT_RUNTIME_C_H +#define DIPLOMAT_RUNTIME_C_H + +#include +#include +#include +#include + +// uchar.h doesn't always exist, but char32_t is always available +// in C++ anyway +#ifndef __cplusplus +#ifdef __APPLE__ +#include +typedef uint16_t char16_t; +typedef uint32_t char32_t; +#else +#include +#endif +#endif + + +#ifdef __cplusplus +namespace capi { +extern "C" { +#endif + +typedef struct DiplomatWriteable { + void* context; + char* buf; + size_t len; + size_t cap; + void (*flush)(struct DiplomatWriteable*); + bool (*grow)(struct DiplomatWriteable*, size_t); +} DiplomatWriteable; + +DiplomatWriteable diplomat_simple_writeable(char* buf, size_t buf_size); + +typedef struct DiplomatStringView { + const char* data; + size_t len; +} DiplomatStringView; + +#define MAKE_SLICE_VIEW(name, c_ty) \ + typedef struct Diplomat##name##View { \ + const c_ty* data; \ + size_t len; \ + } Diplomat##name##View; + +MAKE_SLICE_VIEW(I8, int8_t) +MAKE_SLICE_VIEW(U8, uint8_t) +MAKE_SLICE_VIEW(I16, int16_t) +MAKE_SLICE_VIEW(U16, uint16_t) +MAKE_SLICE_VIEW(I32, int32_t) +MAKE_SLICE_VIEW(U32, uint32_t) +MAKE_SLICE_VIEW(I64, int64_t) +MAKE_SLICE_VIEW(U64, uint64_t) +MAKE_SLICE_VIEW(Isize, intptr_t) +MAKE_SLICE_VIEW(Usize, size_t) +MAKE_SLICE_VIEW(F32, float) +MAKE_SLICE_VIEW(F64, double) +MAKE_SLICE_VIEW(Bool, bool) +MAKE_SLICE_VIEW(Char, char32_t) + + +#ifdef __cplusplus +} // extern "C" +} // namespace capi +#endif + +#endif diff --git a/third_party/rust/icu_capi/cpp/include/diplomat_runtime.hpp b/third_party/rust/icu_capi/cpp/include/diplomat_runtime.hpp new file mode 100644 index 000000000000..19d76044a710 --- /dev/null +++ b/third_party/rust/icu_capi/cpp/include/diplomat_runtime.hpp @@ -0,0 +1,160 @@ +#ifndef DIPLOMAT_RUNTIME_CPP_H +#define DIPLOMAT_RUNTIME_CPP_H + +#include +#include +#include +#include + +#if __cplusplus >= 202002L +#include +#else +#include +#endif + +#include "diplomat_runtime.h" + +namespace diplomat { + +extern "C" inline void Flush(capi::DiplomatWriteable* w) { + std::string* string = reinterpret_cast(w->context); + string->resize(w->len); +}; + +extern "C" inline bool Grow(capi::DiplomatWriteable* w, uintptr_t requested) { + std::string* string = reinterpret_cast(w->context); + string->resize(requested); + w->cap = string->length(); + w->buf = &(*string)[0]; + return true; +}; + +inline capi::DiplomatWriteable WriteableFromString(std::string& string) { + capi::DiplomatWriteable w; + w.context = &string; + w.buf = &string[0]; + w.len = string.length(); + // Same as length, since C++ strings are not supposed + // to be written to past their len; you resize *first* + w.cap = string.length(); + w.flush = Flush; + w.grow = Grow; + return w; +}; + +template struct WriteableTrait { + // static inline capi::DiplomatWriteable Construct(T& t); +}; + + +template<> struct WriteableTrait { + static inline capi::DiplomatWriteable Construct(std::string& t) { + return diplomat::WriteableFromString(t); + } +}; + +template struct Ok { + T inner; + Ok(T&& i): inner(std::move(i)) {} + Ok() = default; + Ok(Ok&&) noexcept = default; + Ok(const Ok &) = default; + Ok& operator=(const Ok&) = default; + Ok& operator=(Ok&&) noexcept = default; +}; + +template struct Err { + T inner; + Err(T&& i): inner(std::move(i)) {} + Err() = default; + Err(Err&&) noexcept = default; + Err(const Err &) = default; + Err& operator=(const Err&) = default; + Err& operator=(Err&&) noexcept = default; +}; + +template +class result { +private: + std::variant, Err> val; +public: + result(Ok&& v): val(std::move(v)) {} + result(Err&& v): val(std::move(v)) {} + result() = default; + result(const result &) = default; + result& operator=(const result&) = default; + result& operator=(result&&) noexcept = default; + result(result &&) noexcept = default; + ~result() = default; + bool is_ok() const { + return std::holds_alternative>(this->val); + }; + bool is_err() const { + return std::holds_alternative>(this->val); + }; + + std::optional ok() && { + if (!this->is_ok()) { + return std::nullopt; + } + return std::make_optional(std::move(std::get>(std::move(this->val)).inner)); + }; + std::optional err() && { + if (!this->is_err()) { + return std::nullopt; + } + return std::make_optional(std::move(std::get>(std::move(this->val)).inner)); + } + + void set_ok(T&& t) { + this->val = Ok(std::move(t)); + } + + void set_err(E&& e) { + this->val = Err(std::move(e)); + } + + template + result replace_ok(T2&& t) { + if (this->is_err()) { + return result(Err(std::get>(std::move(this->val)))); + } else { + return result(Ok(std::move(t))); + } + } +}; + + +// Use custom std::span on C++17, otherwise use std::span +#if __cplusplus >= 202002L + +template using span = std::span; + +#else // __cplusplus >= 202002L + +// C++-17-compatible std::span +template +class span { + +public: + constexpr span(T* data, size_t size) + : data_(data), size_(size) {} + template + constexpr span(std::array::type, N>& arr) + : data_(const_cast(arr.data())), size_(N) {} + constexpr T* data() const noexcept { + return this->data_; + } + constexpr size_t size() const noexcept { + return this->size_; + } +private: + T* data_; + size_t size_; +}; + +#endif // __cplusplus >= 202002L + +} + +#endif diff --git a/third_party/rust/icu_capi/js/README.md b/third_party/rust/icu_capi/js/README.md new file mode 100644 index 000000000000..7bc93e47d763 --- /dev/null +++ b/third_party/rust/icu_capi/js/README.md @@ -0,0 +1,18 @@ +# JavaScript/TypeScript FFI for ICU4X + +This folder contains the JavaScript/TypeScript FFI for ICU4X. To re-generate the bindings run: + +```sh +cargo make diplomat-install +cargo make diplomat-gen-js +``` + +Or re-generate all of the bindings: + +```sh +cargo make diplomat-gen +``` + +## More Information + +For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x). diff --git a/third_party/rust/icu_capi/js/examples/tinywasm/README.md b/third_party/rust/icu_capi/js/examples/tinywasm/README.md new file mode 100644 index 000000000000..708e6b5d5a06 --- /dev/null +++ b/third_party/rust/icu_capi/js/examples/tinywasm/README.md @@ -0,0 +1 @@ +This is a example of how to build a size-optimized WASM library file using ICU4X. diff --git a/third_party/rust/icu_capi/js/include/CodePointRangeIterator.d.ts b/third_party/rust/icu_capi/js/include/CodePointRangeIterator.d.ts new file mode 100644 index 000000000000..25d3076bc893 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/CodePointRangeIterator.d.ts @@ -0,0 +1,16 @@ +import { CodePointRangeIteratorResult } from "./CodePointRangeIteratorResult"; + +/** + + * An iterator over code point ranges, produced by `ICU4XCodePointSetData` or one of the `ICU4XCodePointMapData` types + */ +export class CodePointRangeIterator { + + /** + + * Advance the iterator by one and return the next range. + + * If the iterator is out of items, `done` will be true + */ + next(): CodePointRangeIteratorResult; +} diff --git a/third_party/rust/icu_capi/js/include/CodePointRangeIterator.js b/third_party/rust/icu_capi/js/include/CodePointRangeIterator.js new file mode 100644 index 000000000000..7fe654a93d8c --- /dev/null +++ b/third_party/rust/icu_capi/js/include/CodePointRangeIterator.js @@ -0,0 +1,28 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { CodePointRangeIteratorResult } from "./CodePointRangeIteratorResult.js" + +const CodePointRangeIterator_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.CodePointRangeIterator_destroy(underlying); +}); + +export class CodePointRangeIterator { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + CodePointRangeIterator_box_destroy_registry.register(this, underlying); + } + } + + next() { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(9, 4); + wasm.CodePointRangeIterator_next(diplomat_receive_buffer, this.underlying); + const out = new CodePointRangeIteratorResult(diplomat_receive_buffer); + wasm.diplomat_free(diplomat_receive_buffer, 9, 4); + return out; + })(); + } +} diff --git a/third_party/rust/icu_capi/js/include/CodePointRangeIteratorResult.d.ts b/third_party/rust/icu_capi/js/include/CodePointRangeIteratorResult.d.ts new file mode 100644 index 000000000000..bcc72a65a618 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/CodePointRangeIteratorResult.d.ts @@ -0,0 +1,13 @@ +import { u32 } from "./diplomat-runtime" + +/** + + * Result of a single iteration of {@link CodePointRangeIterator `CodePointRangeIterator`}. Logically can be considered to be an `Option>`, + + * `start` and `end` represent an inclusive range of code points start, end, and `done` will be true if the iterator has already finished. The last contentful iteration will NOT produce a range done=true, in other words `start` and `end` are useful values if and only if `done=false`. + */ +export class CodePointRangeIteratorResult { + start: u32; + end: u32; + done: boolean; +} diff --git a/third_party/rust/icu_capi/js/include/CodePointRangeIteratorResult.js b/third_party/rust/icu_capi/js/include/CodePointRangeIteratorResult.js new file mode 100644 index 000000000000..f544e085fa6d --- /dev/null +++ b/third_party/rust/icu_capi/js/include/CodePointRangeIteratorResult.js @@ -0,0 +1,10 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export class CodePointRangeIteratorResult { + constructor(underlying) { + this.start = (new Uint32Array(wasm.memory.buffer, underlying, 1))[0]; + this.end = (new Uint32Array(wasm.memory.buffer, underlying + 4, 1))[0]; + this.done = (new Uint8Array(wasm.memory.buffer, underlying + 8, 1))[0] == 1; + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XAnyCalendarKind.d.ts b/third_party/rust/icu_capi/js/include/ICU4XAnyCalendarKind.d.ts new file mode 100644 index 000000000000..a8be0b443c6d --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XAnyCalendarKind.d.ts @@ -0,0 +1,57 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XError } from "./ICU4XError"; +import { ICU4XLocale } from "./ICU4XLocale"; + +/** + + * The various calendar types currently supported by {@link ICU4XCalendar `ICU4XCalendar`} + + * See the {@link https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendarKind.html Rust documentation for `AnyCalendarKind`} for more information. + */ +export enum ICU4XAnyCalendarKind { + /** + + * The kind of an Iso calendar + */ + Iso = 'Iso', + /** + + * The kind of a Gregorian calendar + */ + Gregorian = 'Gregorian', + /** + + * The kind of a Buddhist calendar + */ + Buddhist = 'Buddhist', + /** + + * The kind of a Japanese calendar with modern eras + */ + Japanese = 'Japanese', + /** + + * The kind of a Japanese calendar with modern and historic eras + */ + JapaneseExtended = 'JapaneseExtended', + /** + + * The kind of an Ethiopian calendar, with Amete Mihret era + */ + Ethiopian = 'Ethiopian', + /** + + * The kind of an Ethiopian calendar, with Amete Alem era + */ + EthiopianAmeteAlem = 'EthiopianAmeteAlem', + /** + + * The kind of a Indian calendar + */ + Indian = 'Indian', + /** + + * The kind of a Coptic calendar + */ + Coptic = 'Coptic', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XAnyCalendarKind.js b/third_party/rust/icu_capi/js/include/ICU4XAnyCalendarKind.js new file mode 100644 index 000000000000..188a144eb780 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XAnyCalendarKind.js @@ -0,0 +1,39 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +export const ICU4XAnyCalendarKind_js_to_rust = { + "Iso": 0, + "Gregorian": 1, + "Buddhist": 2, + "Japanese": 3, + "JapaneseExtended": 4, + "Ethiopian": 5, + "EthiopianAmeteAlem": 6, + "Indian": 7, + "Coptic": 8, +}; + +export const ICU4XAnyCalendarKind_rust_to_js = { + [0]: "Iso", + [1]: "Gregorian", + [2]: "Buddhist", + [3]: "Japanese", + [4]: "JapaneseExtended", + [5]: "Ethiopian", + [6]: "EthiopianAmeteAlem", + [7]: "Indian", + [8]: "Coptic", +}; + +export const ICU4XAnyCalendarKind = { + "Iso": "Iso", + "Gregorian": "Gregorian", + "Buddhist": "Buddhist", + "Japanese": "Japanese", + "JapaneseExtended": "JapaneseExtended", + "Ethiopian": "Ethiopian", + "EthiopianAmeteAlem": "EthiopianAmeteAlem", + "Indian": "Indian", + "Coptic": "Coptic", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XBidi.d.ts b/third_party/rust/icu_capi/js/include/ICU4XBidi.d.ts new file mode 100644 index 000000000000..96806c7479e2 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XBidi.d.ts @@ -0,0 +1,82 @@ +import { u8 } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { ICU4XBidiInfo } from "./ICU4XBidiInfo"; +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XReorderedIndexMap } from "./ICU4XReorderedIndexMap"; + +/** + + * An ICU4X Bidi object, containing loaded bidi data + + * See the {@link https://docs.rs/icu/latest/icu/properties/bidi/struct.BidiClassAdapter.html Rust documentation for `BidiClassAdapter`} for more information. + */ +export class ICU4XBidi { + + /** + + * Creates a new {@link ICU4XBidi `ICU4XBidi`} from locale data. + + * See the {@link https://docs.rs/icu/latest/icu/properties/bidi/struct.BidiClassAdapter.html#method.new Rust documentation for `new`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create(provider: ICU4XDataProvider): ICU4XBidi | never; + + /** + + * Use the data loaded in this object to process a string and calculate bidi information + + * Takes in a Level for the default level, if it is an invalid value it will default to LTR + + * See the {@link https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.BidiInfo.html#method.new_with_data_source Rust documentation for `new_with_data_source`} for more information. + */ + for_text(text: string, default_level: u8): ICU4XBidiInfo; + + /** + + * Utility function for producing reorderings given a list of levels + + * Produces a map saying which visual index maps to which source index. + + * The levels array must not have values greater than 126 (this is the Bidi maximum explicit depth plus one). Failure to follow this invariant may lead to incorrect results, but is still safe. + + * See the {@link https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.BidiInfo.html#method.reorder_visual Rust documentation for `reorder_visual`} for more information. + */ + reorder_visual(levels: Uint8Array): ICU4XReorderedIndexMap; + + /** + + * Check if a Level returned by level_at is an RTL level. + + * Invalid levels (numbers greater than 125) will be assumed LTR + + * See the {@link https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Level.html#method.is_rtl Rust documentation for `is_rtl`} for more information. + */ + static level_is_rtl(level: u8): boolean; + + /** + + * Check if a Level returned by level_at is an LTR level. + + * Invalid levels (numbers greater than 125) will be assumed LTR + + * See the {@link https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Level.html#method.is_ltr Rust documentation for `is_ltr`} for more information. + */ + static level_is_ltr(level: u8): boolean; + + /** + + * Get a basic RTL Level value + + * See the {@link https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Level.html#method.rtl Rust documentation for `rtl`} for more information. + */ + static level_rtl(): u8; + + /** + + * Get a simple LTR Level value + + * See the {@link https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Level.html#method.ltr Rust documentation for `ltr`} for more information. + */ + static level_ltr(): u8; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XBidi.js b/third_party/rust/icu_capi/js/include/ICU4XBidi.js new file mode 100644 index 000000000000..18676b88740c --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XBidi.js @@ -0,0 +1,65 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XBidiInfo } from "./ICU4XBidiInfo.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XReorderedIndexMap } from "./ICU4XReorderedIndexMap.js" + +const ICU4XBidi_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XBidi_destroy(underlying); +}); + +export class ICU4XBidi { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XBidi_box_destroy_registry.register(this, underlying); + } + } + + static create(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XBidi_create(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XBidi(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + for_text(arg_text, arg_default_level) { + const buf_arg_text = diplomatRuntime.DiplomatBuf.str(wasm, arg_text); + return new ICU4XBidiInfo(wasm.ICU4XBidi_for_text(this.underlying, buf_arg_text.ptr, buf_arg_text.size, arg_default_level), true, [buf_arg_text]); + } + + reorder_visual(arg_levels) { + const buf_arg_levels = diplomatRuntime.DiplomatBuf.slice(wasm, arg_levels, 1); + const diplomat_out = new ICU4XReorderedIndexMap(wasm.ICU4XBidi_reorder_visual(this.underlying, buf_arg_levels.ptr, buf_arg_levels.size), true, []); + buf_arg_levels.free(); + return diplomat_out; + } + + static level_is_rtl(arg_level) { + return wasm.ICU4XBidi_level_is_rtl(arg_level); + } + + static level_is_ltr(arg_level) { + return wasm.ICU4XBidi_level_is_ltr(arg_level); + } + + static level_rtl() { + return wasm.ICU4XBidi_level_rtl(); + } + + static level_ltr() { + return wasm.ICU4XBidi_level_ltr(); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XBidiDirection.d.ts b/third_party/rust/icu_capi/js/include/ICU4XBidiDirection.d.ts new file mode 100644 index 000000000000..2c406601d6e4 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XBidiDirection.d.ts @@ -0,0 +1,14 @@ + +/** + */ +export enum ICU4XBidiDirection { + /** + */ + Ltr = 'Ltr', + /** + */ + Rtl = 'Rtl', + /** + */ + Mixed = 'Mixed', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XBidiDirection.js b/third_party/rust/icu_capi/js/include/ICU4XBidiDirection.js new file mode 100644 index 000000000000..6e68a915987b --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XBidiDirection.js @@ -0,0 +1,20 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XBidiDirection_js_to_rust = { + "Ltr": 0, + "Rtl": 1, + "Mixed": 2, +}; + +export const ICU4XBidiDirection_rust_to_js = { + [0]: "Ltr", + [1]: "Rtl", + [2]: "Mixed", +}; + +export const ICU4XBidiDirection = { + "Ltr": "Ltr", + "Rtl": "Rtl", + "Mixed": "Mixed", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XBidiInfo.d.ts b/third_party/rust/icu_capi/js/include/ICU4XBidiInfo.d.ts new file mode 100644 index 000000000000..12d1d24d35b7 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XBidiInfo.d.ts @@ -0,0 +1,37 @@ +import { u8, usize } from "./diplomat-runtime" +import { ICU4XBidiParagraph } from "./ICU4XBidiParagraph"; + +/** + + * An object containing bidi information for a given string, produced by `for_text()` on `ICU4XBidi` + + * See the {@link https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.BidiInfo.html Rust documentation for `BidiInfo`} for more information. + */ +export class ICU4XBidiInfo { + + /** + + * The number of paragraphs contained here + */ + paragraph_count(): usize; + + /** + + * Get the nth paragraph, returning None if out of bounds + */ + paragraph_at(n: usize): ICU4XBidiParagraph | undefined; + + /** + + * The number of bytes in this full text + */ + size(): usize; + + /** + + * Get the BIDI level at a particular byte index in the full text. This integer is conceptually a `unicode_bidi::Level`, and can be further inspected using the static methods on ICU4XBidi. + + * Returns 0 (equivalent to `Level::ltr()`) on error + */ + level_at(pos: usize): u8; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XBidiInfo.js b/third_party/rust/icu_capi/js/include/ICU4XBidiInfo.js new file mode 100644 index 000000000000..dcdc78390ff6 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XBidiInfo.js @@ -0,0 +1,37 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XBidiParagraph } from "./ICU4XBidiParagraph.js" + +const ICU4XBidiInfo_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XBidiInfo_destroy(underlying); +}); + +export class ICU4XBidiInfo { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XBidiInfo_box_destroy_registry.register(this, underlying); + } + } + + paragraph_count() { + return wasm.ICU4XBidiInfo_paragraph_count(this.underlying); + } + + paragraph_at(arg_n) { + return (() => { + const option_ptr = wasm.ICU4XBidiInfo_paragraph_at(this.underlying, arg_n); + return (option_ptr == 0) ? null : new ICU4XBidiParagraph(option_ptr, true, [this]); + })(); + } + + size() { + return wasm.ICU4XBidiInfo_size(this.underlying); + } + + level_at(arg_pos) { + return wasm.ICU4XBidiInfo_level_at(this.underlying, arg_pos); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XBidiParagraph.d.ts b/third_party/rust/icu_capi/js/include/ICU4XBidiParagraph.d.ts new file mode 100644 index 000000000000..94d29baa42f6 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XBidiParagraph.d.ts @@ -0,0 +1,67 @@ +import { u8, usize } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { ICU4XBidiDirection } from "./ICU4XBidiDirection"; +import { ICU4XError } from "./ICU4XError"; + +/** + + * Bidi information for a single processed paragraph + */ +export class ICU4XBidiParagraph { + + /** + + * Given a paragraph index `n` within the surrounding text, this sets this object to the paragraph at that index. Returns `ICU4XError::OutOfBoundsError` when out of bounds. + + * This is equivalent to calling `paragraph_at()` on `ICU4XBidiInfo` but doesn't create a new object + * @throws {@link FFIError}<{@link ICU4XError}> + */ + set_paragraph_in_text(n: usize): void | never; + + /** + + * The primary direction of this paragraph + + * See the {@link https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Paragraph.html#method.level_at Rust documentation for `level_at`} for more information. + */ + direction(): ICU4XBidiDirection; + + /** + + * The number of bytes in this paragraph + + * See the {@link https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.ParagraphInfo.html#method.len Rust documentation for `len`} for more information. + */ + size(): usize; + + /** + + * The start index of this paragraph within the source text + */ + range_start(): usize; + + /** + + * The end index of this paragraph within the source text + */ + range_end(): usize; + + /** + + * Reorder a line based on display order. The ranges are specified relative to the source text and must be contained within this paragraph's range. + + * See the {@link https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Paragraph.html#method.level_at Rust documentation for `level_at`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + reorder_line(range_start: usize, range_end: usize): string | never; + + /** + + * Get the BIDI level at a particular byte index in this paragraph. This integer is conceptually a `unicode_bidi::Level`, and can be further inspected using the static methods on ICU4XBidi. + + * Returns 0 (equivalent to `Level::ltr()`) on error + + * See the {@link https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.Paragraph.html#method.level_at Rust documentation for `level_at`} for more information. + */ + level_at(pos: usize): u8; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XBidiParagraph.js b/third_party/rust/icu_capi/js/include/ICU4XBidiParagraph.js new file mode 100644 index 000000000000..2037650134c3 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XBidiParagraph.js @@ -0,0 +1,75 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XBidiDirection_js_to_rust, ICU4XBidiDirection_rust_to_js } from "./ICU4XBidiDirection.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XBidiParagraph_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XBidiParagraph_destroy(underlying); +}); + +export class ICU4XBidiParagraph { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XBidiParagraph_box_destroy_registry.register(this, underlying); + } + } + + set_paragraph_in_text(arg_n) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XBidiParagraph_set_paragraph_in_text(diplomat_receive_buffer, this.underlying, arg_n); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + direction() { + return ICU4XBidiDirection_rust_to_js[wasm.ICU4XBidiParagraph_direction(this.underlying)]; + } + + size() { + return wasm.ICU4XBidiParagraph_size(this.underlying); + } + + range_start() { + return wasm.ICU4XBidiParagraph_range_start(this.underlying); + } + + range_end() { + return wasm.ICU4XBidiParagraph_range_end(this.underlying); + } + + reorder_line(arg_range_start, arg_range_end) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XBidiParagraph_reorder_line(diplomat_receive_buffer, this.underlying, arg_range_start, arg_range_end, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + level_at(arg_pos) { + return wasm.ICU4XBidiParagraph_level_at(this.underlying, arg_pos); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCalendar.d.ts b/third_party/rust/icu_capi/js/include/ICU4XCalendar.d.ts new file mode 100644 index 000000000000..5656d71d789d --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCalendar.d.ts @@ -0,0 +1,38 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XAnyCalendarKind } from "./ICU4XAnyCalendarKind"; +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XLocale } from "./ICU4XLocale"; + +/** + + * See the {@link https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendar.html Rust documentation for `AnyCalendar`} for more information. + */ +export class ICU4XCalendar { + + /** + + * Creates a new {@link ICU4XCalendar `ICU4XCalendar`} from the specified date and time. + + * See the {@link https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendar.html#method.try_new_for_locale_unstable Rust documentation for `try_new_for_locale_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_for_locale(provider: ICU4XDataProvider, locale: ICU4XLocale): ICU4XCalendar | never; + + /** + + * Creates a new {@link ICU4XCalendar `ICU4XCalendar`} from the specified date and time. + + * See the {@link https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendar.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_for_kind(provider: ICU4XDataProvider, kind: ICU4XAnyCalendarKind): ICU4XCalendar | never; + + /** + + * Returns the kind of this calendar + + * See the {@link https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendar.html#method.kind Rust documentation for `kind`} for more information. + */ + kind(): ICU4XAnyCalendarKind; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCalendar.js b/third_party/rust/icu_capi/js/include/ICU4XCalendar.js new file mode 100644 index 000000000000..03c5f882b8a7 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCalendar.js @@ -0,0 +1,57 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XAnyCalendarKind_js_to_rust, ICU4XAnyCalendarKind_rust_to_js } from "./ICU4XAnyCalendarKind.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XCalendar_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XCalendar_destroy(underlying); +}); + +export class ICU4XCalendar { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XCalendar_box_destroy_registry.register(this, underlying); + } + } + + static create_for_locale(arg_provider, arg_locale) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCalendar_create_for_locale(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCalendar(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_for_kind(arg_provider, arg_kind) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCalendar_create_for_kind(diplomat_receive_buffer, arg_provider.underlying, ICU4XAnyCalendarKind_js_to_rust[arg_kind]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCalendar(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + kind() { + return ICU4XAnyCalendarKind_rust_to_js[wasm.ICU4XCalendar_kind(this.underlying)]; + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCanonicalCombiningClassMap.d.ts b/third_party/rust/icu_capi/js/include/ICU4XCanonicalCombiningClassMap.d.ts new file mode 100644 index 000000000000..0a4bfcf96e42 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCanonicalCombiningClassMap.d.ts @@ -0,0 +1,38 @@ +import { u8, u32, char } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; + +/** + + * Lookup of the Canonical_Combining_Class Unicode property + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalCombiningClassMap.html Rust documentation for `CanonicalCombiningClassMap`} for more information. + */ +export class ICU4XCanonicalCombiningClassMap { + + /** + + * Construct a new ICU4XCanonicalCombiningClassMap instance for NFC + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalCombiningClassMap.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create(provider: ICU4XDataProvider): ICU4XCanonicalCombiningClassMap | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalCombiningClassMap.html#method.get Rust documentation for `get`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/properties/properties/struct.CanonicalCombiningClass.html 1} + */ + get(ch: char): u8; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalCombiningClassMap.html#method.get32 Rust documentation for `get32`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/properties/properties/struct.CanonicalCombiningClass.html 1} + */ + get32(ch: u32): u8; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCanonicalCombiningClassMap.js b/third_party/rust/icu_capi/js/include/ICU4XCanonicalCombiningClassMap.js new file mode 100644 index 000000000000..9bdb959134dd --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCanonicalCombiningClassMap.js @@ -0,0 +1,43 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XCanonicalCombiningClassMap_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XCanonicalCombiningClassMap_destroy(underlying); +}); + +export class ICU4XCanonicalCombiningClassMap { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XCanonicalCombiningClassMap_box_destroy_registry.register(this, underlying); + } + } + + static create(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCanonicalCombiningClassMap_create(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCanonicalCombiningClassMap(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + get(arg_ch) { + return wasm.ICU4XCanonicalCombiningClassMap_get(this.underlying, diplomatRuntime.extractCodePoint(arg_ch, 'arg_ch')); + } + + get32(arg_ch) { + return wasm.ICU4XCanonicalCombiningClassMap_get32(this.underlying, arg_ch); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCanonicalComposition.d.ts b/third_party/rust/icu_capi/js/include/ICU4XCanonicalComposition.d.ts new file mode 100644 index 000000000000..744e99947f30 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCanonicalComposition.d.ts @@ -0,0 +1,32 @@ +import { char } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; + +/** + + * The raw canonical composition operation. + + * Callers should generally use ICU4XComposingNormalizer unless they specifically need raw composition operations + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalComposition.html Rust documentation for `CanonicalComposition`} for more information. + */ +export class ICU4XCanonicalComposition { + + /** + + * Construct a new ICU4XCanonicalComposition instance for NFC + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalComposition.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create(provider: ICU4XDataProvider): ICU4XCanonicalComposition | never; + + /** + + * Performs canonical composition (including Hangul) on a pair of characters or returns NUL if these characters don’t compose. Composition exclusions are taken into account. + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalComposition.html#method.compose Rust documentation for `compose`} for more information. + */ + compose(starter: char, second: char): char; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCanonicalComposition.js b/third_party/rust/icu_capi/js/include/ICU4XCanonicalComposition.js new file mode 100644 index 000000000000..ae217cafe9bd --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCanonicalComposition.js @@ -0,0 +1,39 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XCanonicalComposition_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XCanonicalComposition_destroy(underlying); +}); + +export class ICU4XCanonicalComposition { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XCanonicalComposition_box_destroy_registry.register(this, underlying); + } + } + + static create(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCanonicalComposition_create(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCanonicalComposition(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + compose(arg_starter, arg_second) { + return wasm.ICU4XCanonicalComposition_compose(this.underlying, diplomatRuntime.extractCodePoint(arg_starter, 'arg_starter'), diplomatRuntime.extractCodePoint(arg_second, 'arg_second')); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCanonicalDecomposition.d.ts b/third_party/rust/icu_capi/js/include/ICU4XCanonicalDecomposition.d.ts new file mode 100644 index 000000000000..3e3d782a5a7b --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCanonicalDecomposition.d.ts @@ -0,0 +1,33 @@ +import { char } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XDecomposed } from "./ICU4XDecomposed"; +import { ICU4XError } from "./ICU4XError"; + +/** + + * The raw (non-recursive) canonical decomposition operation. + + * Callers should generally use ICU4XDecomposingNormalizer unless they specifically need raw composition operations + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalDecomposition.html Rust documentation for `CanonicalDecomposition`} for more information. + */ +export class ICU4XCanonicalDecomposition { + + /** + + * Construct a new ICU4XCanonicalDecomposition instance for NFC + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalDecomposition.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create(provider: ICU4XDataProvider): ICU4XCanonicalDecomposition | never; + + /** + + * Performs non-recursive canonical decomposition (including for Hangul). + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/properties/struct.CanonicalDecomposition.html#method.decompose Rust documentation for `decompose`} for more information. + */ + decompose(c: char): ICU4XDecomposed; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCanonicalDecomposition.js b/third_party/rust/icu_capi/js/include/ICU4XCanonicalDecomposition.js new file mode 100644 index 000000000000..249a09d54071 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCanonicalDecomposition.js @@ -0,0 +1,46 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XDecomposed } from "./ICU4XDecomposed.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XCanonicalDecomposition_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XCanonicalDecomposition_destroy(underlying); +}); + +export class ICU4XCanonicalDecomposition { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XCanonicalDecomposition_box_destroy_registry.register(this, underlying); + } + } + + static create(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCanonicalDecomposition_create(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCanonicalDecomposition(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + decompose(arg_c) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(8, 4); + wasm.ICU4XCanonicalDecomposition_decompose(diplomat_receive_buffer, this.underlying, diplomatRuntime.extractCodePoint(arg_c, 'arg_c')); + const out = new ICU4XDecomposed(diplomat_receive_buffer); + wasm.diplomat_free(diplomat_receive_buffer, 8, 4); + return out; + })(); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCodePointMapData16.d.ts b/third_party/rust/icu_capi/js/include/ICU4XCodePointMapData16.d.ts new file mode 100644 index 000000000000..dc8a2a4fc1a4 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCodePointMapData16.d.ts @@ -0,0 +1,66 @@ +import { u16, u32, char } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { CodePointRangeIterator } from "./CodePointRangeIterator"; +import { ICU4XCodePointSetData } from "./ICU4XCodePointSetData"; +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; + +/** + + * An ICU4X Unicode Map Property object, capable of querying whether a code point (key) to obtain the Unicode property value, for a specific Unicode property. + + * For properties whose values fit into 16 bits. + + * See the {@link https://docs.rs/icu/latest/icu/properties/index.html Rust documentation for `properties`} for more information. + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapData.html Rust documentation for `CodePointMapData`} for more information. + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html Rust documentation for `CodePointMapDataBorrowed`} for more information. + */ +export class ICU4XCodePointMapData16 { + + /** + + * Gets the value for a code point. + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.get Rust documentation for `get`} for more information. + */ + get(cp: char): u16; + + /** + + * Gets the value for a code point (specified as a 32 bit integer, in UTF-32) + */ + get32(cp: u32): u16; + + /** + + * Produces an iterator over ranges of code points that map to `value` + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.iter_ranges_for_value Rust documentation for `iter_ranges_for_value`} for more information. + */ + iter_ranges_for_value(value: u16): CodePointRangeIterator; + + /** + + * Produces an iterator over ranges of code points that do not map to `value` + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.iter_ranges_for_value_complemented Rust documentation for `iter_ranges_for_value_complemented`} for more information. + */ + iter_ranges_for_value_complemented(value: u16): CodePointRangeIterator; + + /** + + * Gets a {@link ICU4XCodePointSetData `ICU4XCodePointSetData`} representing all entries in this map that map to the given value + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.get_set_for_value Rust documentation for `get_set_for_value`} for more information. + */ + get_set_for_value(value: u16): ICU4XCodePointSetData; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/fn.load_script.html Rust documentation for `load_script`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_script(provider: ICU4XDataProvider): ICU4XCodePointMapData16 | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCodePointMapData16.js b/third_party/rust/icu_capi/js/include/ICU4XCodePointMapData16.js new file mode 100644 index 000000000000..cbdb61da4598 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCodePointMapData16.js @@ -0,0 +1,57 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { CodePointRangeIterator } from "./CodePointRangeIterator.js" +import { ICU4XCodePointSetData } from "./ICU4XCodePointSetData.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XCodePointMapData16_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XCodePointMapData16_destroy(underlying); +}); + +export class ICU4XCodePointMapData16 { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XCodePointMapData16_box_destroy_registry.register(this, underlying); + } + } + + get(arg_cp) { + return wasm.ICU4XCodePointMapData16_get(this.underlying, diplomatRuntime.extractCodePoint(arg_cp, 'arg_cp')); + } + + get32(arg_cp) { + return wasm.ICU4XCodePointMapData16_get32(this.underlying, arg_cp); + } + + iter_ranges_for_value(arg_value) { + return new CodePointRangeIterator(wasm.ICU4XCodePointMapData16_iter_ranges_for_value(this.underlying, arg_value), true, [this]); + } + + iter_ranges_for_value_complemented(arg_value) { + return new CodePointRangeIterator(wasm.ICU4XCodePointMapData16_iter_ranges_for_value_complemented(this.underlying, arg_value), true, [this]); + } + + get_set_for_value(arg_value) { + return new ICU4XCodePointSetData(wasm.ICU4XCodePointMapData16_get_set_for_value(this.underlying, arg_value), true, []); + } + + static load_script(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointMapData16_load_script(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointMapData16(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCodePointMapData8.d.ts b/third_party/rust/icu_capi/js/include/ICU4XCodePointMapData8.d.ts new file mode 100644 index 000000000000..d6616eb35cb8 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCodePointMapData8.d.ts @@ -0,0 +1,130 @@ +import { u8, u32, char } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { CodePointRangeIterator } from "./CodePointRangeIterator"; +import { ICU4XCodePointSetData } from "./ICU4XCodePointSetData"; +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; + +/** + + * An ICU4X Unicode Map Property object, capable of querying whether a code point (key) to obtain the Unicode property value, for a specific Unicode property. + + * For properties whose values fit into 8 bits. + + * See the {@link https://docs.rs/icu/latest/icu/properties/index.html Rust documentation for `properties`} for more information. + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapData.html Rust documentation for `CodePointMapData`} for more information. + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html Rust documentation for `CodePointMapDataBorrowed`} for more information. + */ +export class ICU4XCodePointMapData8 { + + /** + + * Gets the value for a code point. + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.get Rust documentation for `get`} for more information. + */ + get(cp: char): u8; + + /** + + * Gets the value for a code point (specified as a 32 bit integer, in UTF-32) + */ + get32(cp: u32): u8; + + /** + + * Converts a general category to its corresponding mask value + + * Nonexistant general categories will map to the empty mask + + * See the {@link https://docs.rs/icu/latest/icu/properties/struct.GeneralCategoryGroup.html Rust documentation for `GeneralCategoryGroup`} for more information. + */ + static general_category_to_mask(gc: u8): u32; + + /** + + * Produces an iterator over ranges of code points that map to `value` + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.iter_ranges_for_value Rust documentation for `iter_ranges_for_value`} for more information. + */ + iter_ranges_for_value(value: u8): CodePointRangeIterator; + + /** + + * Produces an iterator over ranges of code points that do not map to `value` + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.iter_ranges_for_value_complemented Rust documentation for `iter_ranges_for_value_complemented`} for more information. + */ + iter_ranges_for_value_complemented(value: u8): CodePointRangeIterator; + + /** + + * Given a mask value (the nth bit marks property value = n), produce an iterator over ranges of code points whose property values are contained in the mask. + + * The main mask property supported is that for General_Category, which can be obtained via `general_category_to_mask()` or by using `ICU4XGeneralCategoryNameToMaskMapper` + + * Should only be used on maps for properties with values less than 32 (like Generak_Category), other maps will have unpredictable results + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.iter_ranges_for_group Rust documentation for `iter_ranges_for_group`} for more information. + */ + iter_ranges_for_mask(mask: u32): CodePointRangeIterator; + + /** + + * Gets a {@link ICU4XCodePointSetData `ICU4XCodePointSetData`} representing all entries in this map that map to the given value + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/struct.CodePointMapDataBorrowed.html#method.get_set_for_value Rust documentation for `get_set_for_value`} for more information. + */ + get_set_for_value(value: u8): ICU4XCodePointSetData; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/fn.load_general_category.html Rust documentation for `load_general_category`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_general_category(provider: ICU4XDataProvider): ICU4XCodePointMapData8 | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/fn.load_bidi_class.html Rust documentation for `load_bidi_class`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_bidi_class(provider: ICU4XDataProvider): ICU4XCodePointMapData8 | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/fn.load_east_asian_width.html Rust documentation for `load_east_asian_width`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_east_asian_width(provider: ICU4XDataProvider): ICU4XCodePointMapData8 | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/fn.load_line_break.html Rust documentation for `load_line_break`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_line_break(provider: ICU4XDataProvider): ICU4XCodePointMapData8 | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/fn.load_grapheme_cluster_break.html Rust documentation for `load_grapheme_cluster_break`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static try_grapheme_cluster_break(provider: ICU4XDataProvider): ICU4XCodePointMapData8 | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/fn.load_word_break.html Rust documentation for `load_word_break`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_word_break(provider: ICU4XDataProvider): ICU4XCodePointMapData8 | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/maps/fn.load_sentence_break.html Rust documentation for `load_sentence_break`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_sentence_break(provider: ICU4XDataProvider): ICU4XCodePointMapData8 | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCodePointMapData8.js b/third_party/rust/icu_capi/js/include/ICU4XCodePointMapData8.js new file mode 100644 index 000000000000..3fc2d65d61fd --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCodePointMapData8.js @@ -0,0 +1,167 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { CodePointRangeIterator } from "./CodePointRangeIterator.js" +import { ICU4XCodePointSetData } from "./ICU4XCodePointSetData.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XCodePointMapData8_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XCodePointMapData8_destroy(underlying); +}); + +export class ICU4XCodePointMapData8 { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XCodePointMapData8_box_destroy_registry.register(this, underlying); + } + } + + get(arg_cp) { + return wasm.ICU4XCodePointMapData8_get(this.underlying, diplomatRuntime.extractCodePoint(arg_cp, 'arg_cp')); + } + + get32(arg_cp) { + return wasm.ICU4XCodePointMapData8_get32(this.underlying, arg_cp); + } + + static general_category_to_mask(arg_gc) { + return wasm.ICU4XCodePointMapData8_general_category_to_mask(arg_gc); + } + + iter_ranges_for_value(arg_value) { + return new CodePointRangeIterator(wasm.ICU4XCodePointMapData8_iter_ranges_for_value(this.underlying, arg_value), true, [this]); + } + + iter_ranges_for_value_complemented(arg_value) { + return new CodePointRangeIterator(wasm.ICU4XCodePointMapData8_iter_ranges_for_value_complemented(this.underlying, arg_value), true, [this]); + } + + iter_ranges_for_mask(arg_mask) { + return new CodePointRangeIterator(wasm.ICU4XCodePointMapData8_iter_ranges_for_mask(this.underlying, arg_mask), true, [this]); + } + + get_set_for_value(arg_value) { + return new ICU4XCodePointSetData(wasm.ICU4XCodePointMapData8_get_set_for_value(this.underlying, arg_value), true, []); + } + + static load_general_category(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointMapData8_load_general_category(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointMapData8(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_bidi_class(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointMapData8_load_bidi_class(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointMapData8(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_east_asian_width(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointMapData8_load_east_asian_width(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointMapData8(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_line_break(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointMapData8_load_line_break(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointMapData8(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static try_grapheme_cluster_break(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointMapData8_try_grapheme_cluster_break(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointMapData8(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_word_break(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointMapData8_load_word_break(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointMapData8(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_sentence_break(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointMapData8_load_sentence_break(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointMapData8(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCodePointSetData.d.ts b/third_party/rust/icu_capi/js/include/ICU4XCodePointSetData.d.ts new file mode 100644 index 000000000000..6120ed1b5a29 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCodePointSetData.d.ts @@ -0,0 +1,523 @@ +import { u32, char } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { CodePointRangeIterator } from "./CodePointRangeIterator"; +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; + +/** + + * An ICU4X Unicode Set Property object, capable of querying whether a code point is contained in a set based on a Unicode property. + + * See the {@link https://docs.rs/icu/latest/icu/properties/index.html Rust documentation for `properties`} for more information. + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/struct.CodePointSetData.html Rust documentation for `CodePointSetData`} for more information. + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/struct.CodePointSetDataBorrowed.html Rust documentation for `CodePointSetDataBorrowed`} for more information. + */ +export class ICU4XCodePointSetData { + + /** + + * Checks whether the code point is in the set. + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/struct.CodePointSetDataBorrowed.html#method.contains Rust documentation for `contains`} for more information. + */ + contains(cp: char): boolean; + + /** + + * Checks whether the code point (specified as a 32 bit integer, in UTF-32) is in the set. + */ + contains32(cp: u32): boolean; + + /** + + * Produces an iterator over ranges of code points contained in this set + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/struct.CodePointSetDataBorrowed.html#method.iter_ranges Rust documentation for `iter_ranges`} for more information. + */ + iter_ranges(): CodePointRangeIterator; + + /** + + * Produces an iterator over ranges of code points not contained in this set + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/struct.CodePointSetDataBorrowed.html#method.iter_ranges_complemented Rust documentation for `iter_ranges_complemented`} for more information. + */ + iter_ranges_complemented(): CodePointRangeIterator; + + /** + + * which is a mask with the same format as the `U_GC_XX_MASK` mask in ICU4C + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_for_general_category_group.html Rust documentation for `load_for_general_category_group`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_for_general_category_group(provider: ICU4XDataProvider, group: u32): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_ascii_hex_digit.html Rust documentation for `load_ascii_hex_digit`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_ascii_hex_digit(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_alnum.html Rust documentation for `load_alnum`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_alnum(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_alphabetic.html Rust documentation for `load_alphabetic`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_alphabetic(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_bidi_control.html Rust documentation for `load_bidi_control`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_bidi_control(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_bidi_mirrored.html Rust documentation for `load_bidi_mirrored`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_bidi_mirrored(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_blank.html Rust documentation for `load_blank`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_blank(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_cased.html Rust documentation for `load_cased`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_cased(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_case_ignorable.html Rust documentation for `load_case_ignorable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_case_ignorable(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_full_composition_exclusion.html Rust documentation for `load_full_composition_exclusion`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_full_composition_exclusion(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_changes_when_casefolded.html Rust documentation for `load_changes_when_casefolded`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_changes_when_casefolded(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_changes_when_casemapped.html Rust documentation for `load_changes_when_casemapped`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_changes_when_casemapped(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_changes_when_nfkc_casefolded.html Rust documentation for `load_changes_when_nfkc_casefolded`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_changes_when_nfkc_casefolded(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_changes_when_lowercased.html Rust documentation for `load_changes_when_lowercased`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_changes_when_lowercased(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_changes_when_titlecased.html Rust documentation for `load_changes_when_titlecased`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_changes_when_titlecased(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_changes_when_uppercased.html Rust documentation for `load_changes_when_uppercased`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_changes_when_uppercased(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_dash.html Rust documentation for `load_dash`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_dash(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_deprecated.html Rust documentation for `load_deprecated`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_deprecated(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_default_ignorable_code_point.html Rust documentation for `load_default_ignorable_code_point`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_default_ignorable_code_point(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_diacritic.html Rust documentation for `load_diacritic`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_diacritic(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_emoji_modifier_base.html Rust documentation for `load_emoji_modifier_base`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_emoji_modifier_base(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_emoji_component.html Rust documentation for `load_emoji_component`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_emoji_component(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_emoji_modifier.html Rust documentation for `load_emoji_modifier`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_emoji_modifier(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_emoji.html Rust documentation for `load_emoji`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_emoji(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_emoji_presentation.html Rust documentation for `load_emoji_presentation`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_emoji_presentation(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_extender.html Rust documentation for `load_extender`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_extender(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_extended_pictographic.html Rust documentation for `load_extended_pictographic`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_extended_pictographic(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_graph.html Rust documentation for `load_graph`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_graph(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_grapheme_base.html Rust documentation for `load_grapheme_base`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_grapheme_base(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_grapheme_extend.html Rust documentation for `load_grapheme_extend`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_grapheme_extend(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_grapheme_link.html Rust documentation for `load_grapheme_link`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_grapheme_link(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_hex_digit.html Rust documentation for `load_hex_digit`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_hex_digit(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_hyphen.html Rust documentation for `load_hyphen`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_hyphen(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_id_continue.html Rust documentation for `load_id_continue`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_id_continue(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_ideographic.html Rust documentation for `load_ideographic`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_ideographic(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_id_start.html Rust documentation for `load_id_start`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_id_start(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_ids_binary_operator.html Rust documentation for `load_ids_binary_operator`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_ids_binary_operator(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_ids_trinary_operator.html Rust documentation for `load_ids_trinary_operator`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_ids_trinary_operator(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_join_control.html Rust documentation for `load_join_control`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_join_control(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_logical_order_exception.html Rust documentation for `load_logical_order_exception`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_logical_order_exception(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_lowercase.html Rust documentation for `load_lowercase`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_lowercase(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_math.html Rust documentation for `load_math`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_math(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_noncharacter_code_point.html Rust documentation for `load_noncharacter_code_point`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_noncharacter_code_point(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_nfc_inert.html Rust documentation for `load_nfc_inert`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_nfc_inert(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_nfd_inert.html Rust documentation for `load_nfd_inert`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_nfd_inert(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_nfkc_inert.html Rust documentation for `load_nfkc_inert`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_nfkc_inert(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_nfkd_inert.html Rust documentation for `load_nfkd_inert`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_nfkd_inert(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_pattern_syntax.html Rust documentation for `load_pattern_syntax`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_pattern_syntax(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_pattern_white_space.html Rust documentation for `load_pattern_white_space`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_pattern_white_space(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_prepended_concatenation_mark.html Rust documentation for `load_prepended_concatenation_mark`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_prepended_concatenation_mark(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_print.html Rust documentation for `load_print`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_print(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_quotation_mark.html Rust documentation for `load_quotation_mark`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_quotation_mark(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_radical.html Rust documentation for `load_radical`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_radical(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_regional_indicator.html Rust documentation for `load_regional_indicator`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_regional_indicator(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_soft_dotted.html Rust documentation for `load_soft_dotted`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_soft_dotted(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_segment_starter.html Rust documentation for `load_segment_starter`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_segment_starter(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_case_sensitive.html Rust documentation for `load_case_sensitive`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_case_sensitive(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_sentence_terminal.html Rust documentation for `load_sentence_terminal`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_sentence_terminal(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_terminal_punctuation.html Rust documentation for `load_terminal_punctuation`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_terminal_punctuation(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_unified_ideograph.html Rust documentation for `load_unified_ideograph`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_unified_ideograph(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_uppercase.html Rust documentation for `load_uppercase`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_uppercase(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_variation_selector.html Rust documentation for `load_variation_selector`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_variation_selector(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_white_space.html Rust documentation for `load_white_space`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_white_space(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_xdigit.html Rust documentation for `load_xdigit`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_xdigit(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_xid_continue.html Rust documentation for `load_xid_continue`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_xid_continue(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_xid_start.html Rust documentation for `load_xid_start`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_xid_start(provider: ICU4XDataProvider): ICU4XCodePointSetData | never; + + /** + + * Loads data for a property specified as a string as long as it is one of the {@link https://tc39.es/ecma262/#table-binary-unicode-properties ECMA-262 binary properties} (not including Any, ASCII, and Assigned pseudoproperties). + + * Returns `ICU4XError::PropertyUnexpectedPropertyNameError` in case the string does not match any property in the list + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_for_ecma262_unstable.html Rust documentation for `load_for_ecma262_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_for_ecma262(provider: ICU4XDataProvider, property_name: string): ICU4XCodePointSetData | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCodePointSetData.js b/third_party/rust/icu_capi/js/include/ICU4XCodePointSetData.js new file mode 100644 index 000000000000..55a1605d4e6f --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCodePointSetData.js @@ -0,0 +1,1177 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { CodePointRangeIterator } from "./CodePointRangeIterator.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XCodePointSetData_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XCodePointSetData_destroy(underlying); +}); + +export class ICU4XCodePointSetData { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XCodePointSetData_box_destroy_registry.register(this, underlying); + } + } + + contains(arg_cp) { + return wasm.ICU4XCodePointSetData_contains(this.underlying, diplomatRuntime.extractCodePoint(arg_cp, 'arg_cp')); + } + + contains32(arg_cp) { + return wasm.ICU4XCodePointSetData_contains32(this.underlying, arg_cp); + } + + iter_ranges() { + return new CodePointRangeIterator(wasm.ICU4XCodePointSetData_iter_ranges(this.underlying), true, [this]); + } + + iter_ranges_complemented() { + return new CodePointRangeIterator(wasm.ICU4XCodePointSetData_iter_ranges_complemented(this.underlying), true, [this]); + } + + static load_for_general_category_group(arg_provider, arg_group) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_for_general_category_group(diplomat_receive_buffer, arg_provider.underlying, arg_group); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_ascii_hex_digit(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_ascii_hex_digit(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_alnum(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_alnum(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_alphabetic(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_alphabetic(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_bidi_control(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_bidi_control(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_bidi_mirrored(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_bidi_mirrored(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_blank(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_blank(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_cased(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_cased(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_case_ignorable(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_case_ignorable(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_full_composition_exclusion(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_full_composition_exclusion(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_changes_when_casefolded(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_changes_when_casefolded(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_changes_when_casemapped(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_changes_when_casemapped(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_changes_when_nfkc_casefolded(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_changes_when_nfkc_casefolded(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_changes_when_lowercased(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_changes_when_lowercased(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_changes_when_titlecased(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_changes_when_titlecased(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_changes_when_uppercased(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_changes_when_uppercased(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_dash(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_dash(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_deprecated(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_deprecated(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_default_ignorable_code_point(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_default_ignorable_code_point(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_diacritic(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_diacritic(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_emoji_modifier_base(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_emoji_modifier_base(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_emoji_component(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_emoji_component(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_emoji_modifier(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_emoji_modifier(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_emoji(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_emoji(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_emoji_presentation(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_emoji_presentation(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_extender(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_extender(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_extended_pictographic(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_extended_pictographic(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_graph(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_graph(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_grapheme_base(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_grapheme_base(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_grapheme_extend(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_grapheme_extend(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_grapheme_link(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_grapheme_link(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_hex_digit(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_hex_digit(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_hyphen(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_hyphen(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_id_continue(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_id_continue(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_ideographic(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_ideographic(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_id_start(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_id_start(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_ids_binary_operator(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_ids_binary_operator(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_ids_trinary_operator(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_ids_trinary_operator(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_join_control(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_join_control(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_logical_order_exception(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_logical_order_exception(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_lowercase(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_lowercase(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_math(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_math(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_noncharacter_code_point(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_noncharacter_code_point(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_nfc_inert(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_nfc_inert(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_nfd_inert(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_nfd_inert(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_nfkc_inert(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_nfkc_inert(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_nfkd_inert(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_nfkd_inert(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_pattern_syntax(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_pattern_syntax(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_pattern_white_space(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_pattern_white_space(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_prepended_concatenation_mark(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_prepended_concatenation_mark(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_print(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_print(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_quotation_mark(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_quotation_mark(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_radical(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_radical(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_regional_indicator(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_regional_indicator(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_soft_dotted(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_soft_dotted(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_segment_starter(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_segment_starter(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_case_sensitive(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_case_sensitive(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_sentence_terminal(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_sentence_terminal(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_terminal_punctuation(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_terminal_punctuation(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_unified_ideograph(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_unified_ideograph(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_uppercase(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_uppercase(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_variation_selector(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_variation_selector(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_white_space(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_white_space(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_xdigit(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_xdigit(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_xid_continue(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_xid_continue(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_xid_start(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_xid_start(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_for_ecma262(arg_provider, arg_property_name) { + const buf_arg_property_name = diplomatRuntime.DiplomatBuf.str(wasm, arg_property_name); + const diplomat_out = (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCodePointSetData_load_for_ecma262(diplomat_receive_buffer, arg_provider.underlying, buf_arg_property_name.ptr, buf_arg_property_name.size); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCodePointSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + buf_arg_property_name.free(); + return diplomat_out; + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCollator.d.ts b/third_party/rust/icu_capi/js/include/ICU4XCollator.d.ts new file mode 100644 index 000000000000..7b74de0ca41f --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCollator.d.ts @@ -0,0 +1,50 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XCollatorOptionsV1 } from "./ICU4XCollatorOptionsV1"; +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XLocale } from "./ICU4XLocale"; +import { ICU4XOrdering } from "./ICU4XOrdering"; + +/** + + * See the {@link https://docs.rs/icu/latest/icu/collator/struct.Collator.html Rust documentation for `Collator`} for more information. + */ +export class ICU4XCollator { + + /** + + * Construct a new Collator instance. + + * See the {@link https://docs.rs/icu/latest/icu/collator/struct.Collator.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_v1(provider: ICU4XDataProvider, locale: ICU4XLocale, options: ICU4XCollatorOptionsV1): ICU4XCollator | never; + + /** + + * Compare potentially ill-formed UTF-8 strings. + + * Ill-formed input is compared as if errors had been replaced with REPLACEMENT CHARACTERs according to the WHATWG Encoding Standard. + + * See the {@link https://docs.rs/icu/latest/icu/collator/struct.Collator.html#method.compare_utf8 Rust documentation for `compare_utf8`} for more information. + */ + compare(left: string, right: string): ICU4XOrdering; + + /** + + * Compare guaranteed well-formed UTF-8 strings. + + * Note: In C++, passing ill-formed UTF-8 strings is undefined behavior (and may be memory-unsafe to do so, too). + + * See the {@link https://docs.rs/icu/latest/icu/collator/struct.Collator.html#method.compare Rust documentation for `compare`} for more information. + */ + compare_valid_utf8(left: string, right: string): ICU4XOrdering; + + /** + + * Compare potentially ill-formed UTF-16 strings, with unpaired surrogates compared as REPLACEMENT CHARACTER. + + * See the {@link https://docs.rs/icu/latest/icu/collator/struct.Collator.html#method.compare_utf16 Rust documentation for `compare_utf16`} for more information. + */ + compare_utf16(left: Uint16Array, right: Uint16Array): ICU4XOrdering; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCollator.js b/third_party/rust/icu_capi/js/include/ICU4XCollator.js new file mode 100644 index 000000000000..5fc796cbd24b --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCollator.js @@ -0,0 +1,77 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XCollatorAlternateHandling_js_to_rust, ICU4XCollatorAlternateHandling_rust_to_js } from "./ICU4XCollatorAlternateHandling.js" +import { ICU4XCollatorBackwardSecondLevel_js_to_rust, ICU4XCollatorBackwardSecondLevel_rust_to_js } from "./ICU4XCollatorBackwardSecondLevel.js" +import { ICU4XCollatorCaseFirst_js_to_rust, ICU4XCollatorCaseFirst_rust_to_js } from "./ICU4XCollatorCaseFirst.js" +import { ICU4XCollatorCaseLevel_js_to_rust, ICU4XCollatorCaseLevel_rust_to_js } from "./ICU4XCollatorCaseLevel.js" +import { ICU4XCollatorMaxVariable_js_to_rust, ICU4XCollatorMaxVariable_rust_to_js } from "./ICU4XCollatorMaxVariable.js" +import { ICU4XCollatorNumeric_js_to_rust, ICU4XCollatorNumeric_rust_to_js } from "./ICU4XCollatorNumeric.js" +import { ICU4XCollatorStrength_js_to_rust, ICU4XCollatorStrength_rust_to_js } from "./ICU4XCollatorStrength.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XOrdering_js_to_rust, ICU4XOrdering_rust_to_js } from "./ICU4XOrdering.js" + +const ICU4XCollator_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XCollator_destroy(underlying); +}); + +export class ICU4XCollator { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XCollator_box_destroy_registry.register(this, underlying); + } + } + + static create_v1(arg_provider, arg_locale, arg_options) { + const field_strength_arg_options = arg_options["strength"]; + const field_alternate_handling_arg_options = arg_options["alternate_handling"]; + const field_case_first_arg_options = arg_options["case_first"]; + const field_max_variable_arg_options = arg_options["max_variable"]; + const field_case_level_arg_options = arg_options["case_level"]; + const field_numeric_arg_options = arg_options["numeric"]; + const field_backward_second_level_arg_options = arg_options["backward_second_level"]; + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCollator_create_v1(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying, ICU4XCollatorStrength_js_to_rust[field_strength_arg_options], ICU4XCollatorAlternateHandling_js_to_rust[field_alternate_handling_arg_options], ICU4XCollatorCaseFirst_js_to_rust[field_case_first_arg_options], ICU4XCollatorMaxVariable_js_to_rust[field_max_variable_arg_options], ICU4XCollatorCaseLevel_js_to_rust[field_case_level_arg_options], ICU4XCollatorNumeric_js_to_rust[field_numeric_arg_options], ICU4XCollatorBackwardSecondLevel_js_to_rust[field_backward_second_level_arg_options]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCollator(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + compare(arg_left, arg_right) { + const buf_arg_left = diplomatRuntime.DiplomatBuf.str(wasm, arg_left); + const buf_arg_right = diplomatRuntime.DiplomatBuf.str(wasm, arg_right); + const diplomat_out = ICU4XOrdering_rust_to_js[wasm.ICU4XCollator_compare(this.underlying, buf_arg_left.ptr, buf_arg_left.size, buf_arg_right.ptr, buf_arg_right.size)]; + buf_arg_left.free(); + buf_arg_right.free(); + return diplomat_out; + } + + compare_valid_utf8(arg_left, arg_right) { + const buf_arg_left = diplomatRuntime.DiplomatBuf.str(wasm, arg_left); + const buf_arg_right = diplomatRuntime.DiplomatBuf.str(wasm, arg_right); + const diplomat_out = ICU4XOrdering_rust_to_js[wasm.ICU4XCollator_compare_valid_utf8(this.underlying, buf_arg_left.ptr, buf_arg_left.size, buf_arg_right.ptr, buf_arg_right.size)]; + buf_arg_left.free(); + buf_arg_right.free(); + return diplomat_out; + } + + compare_utf16(arg_left, arg_right) { + const buf_arg_left = diplomatRuntime.DiplomatBuf.slice(wasm, arg_left, 2); + const buf_arg_right = diplomatRuntime.DiplomatBuf.slice(wasm, arg_right, 2); + const diplomat_out = ICU4XOrdering_rust_to_js[wasm.ICU4XCollator_compare_utf16(this.underlying, buf_arg_left.ptr, buf_arg_left.size, buf_arg_right.ptr, buf_arg_right.size)]; + buf_arg_left.free(); + buf_arg_right.free(); + return diplomat_out; + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCollatorAlternateHandling.d.ts b/third_party/rust/icu_capi/js/include/ICU4XCollatorAlternateHandling.d.ts new file mode 100644 index 000000000000..9e84343353dd --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCollatorAlternateHandling.d.ts @@ -0,0 +1,16 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/collator/enum.AlternateHandling.html Rust documentation for `AlternateHandling`} for more information. + */ +export enum ICU4XCollatorAlternateHandling { + /** + */ + Auto = 'Auto', + /** + */ + NonIgnorable = 'NonIgnorable', + /** + */ + Shifted = 'Shifted', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XCollatorAlternateHandling.js b/third_party/rust/icu_capi/js/include/ICU4XCollatorAlternateHandling.js new file mode 100644 index 000000000000..50467508156e --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCollatorAlternateHandling.js @@ -0,0 +1,20 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XCollatorAlternateHandling_js_to_rust = { + "Auto": 0, + "NonIgnorable": 1, + "Shifted": 2, +}; + +export const ICU4XCollatorAlternateHandling_rust_to_js = { + [0]: "Auto", + [1]: "NonIgnorable", + [2]: "Shifted", +}; + +export const ICU4XCollatorAlternateHandling = { + "Auto": "Auto", + "NonIgnorable": "NonIgnorable", + "Shifted": "Shifted", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XCollatorBackwardSecondLevel.d.ts b/third_party/rust/icu_capi/js/include/ICU4XCollatorBackwardSecondLevel.d.ts new file mode 100644 index 000000000000..6dc06e7e2a7c --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCollatorBackwardSecondLevel.d.ts @@ -0,0 +1,16 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/collator/enum.BackwardSecondLevel.html Rust documentation for `BackwardSecondLevel`} for more information. + */ +export enum ICU4XCollatorBackwardSecondLevel { + /** + */ + Auto = 'Auto', + /** + */ + Off = 'Off', + /** + */ + On = 'On', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XCollatorBackwardSecondLevel.js b/third_party/rust/icu_capi/js/include/ICU4XCollatorBackwardSecondLevel.js new file mode 100644 index 000000000000..825b3d200c82 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCollatorBackwardSecondLevel.js @@ -0,0 +1,20 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XCollatorBackwardSecondLevel_js_to_rust = { + "Auto": 0, + "Off": 1, + "On": 2, +}; + +export const ICU4XCollatorBackwardSecondLevel_rust_to_js = { + [0]: "Auto", + [1]: "Off", + [2]: "On", +}; + +export const ICU4XCollatorBackwardSecondLevel = { + "Auto": "Auto", + "Off": "Off", + "On": "On", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XCollatorCaseFirst.d.ts b/third_party/rust/icu_capi/js/include/ICU4XCollatorCaseFirst.d.ts new file mode 100644 index 000000000000..f72b75cfeceb --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCollatorCaseFirst.d.ts @@ -0,0 +1,19 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/collator/enum.CaseFirst.html Rust documentation for `CaseFirst`} for more information. + */ +export enum ICU4XCollatorCaseFirst { + /** + */ + Auto = 'Auto', + /** + */ + Off = 'Off', + /** + */ + LowerFirst = 'LowerFirst', + /** + */ + UpperFirst = 'UpperFirst', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XCollatorCaseFirst.js b/third_party/rust/icu_capi/js/include/ICU4XCollatorCaseFirst.js new file mode 100644 index 000000000000..b5c11fb4e8e7 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCollatorCaseFirst.js @@ -0,0 +1,23 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XCollatorCaseFirst_js_to_rust = { + "Auto": 0, + "Off": 1, + "LowerFirst": 2, + "UpperFirst": 3, +}; + +export const ICU4XCollatorCaseFirst_rust_to_js = { + [0]: "Auto", + [1]: "Off", + [2]: "LowerFirst", + [3]: "UpperFirst", +}; + +export const ICU4XCollatorCaseFirst = { + "Auto": "Auto", + "Off": "Off", + "LowerFirst": "LowerFirst", + "UpperFirst": "UpperFirst", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XCollatorCaseLevel.d.ts b/third_party/rust/icu_capi/js/include/ICU4XCollatorCaseLevel.d.ts new file mode 100644 index 000000000000..3825eaeae0f0 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCollatorCaseLevel.d.ts @@ -0,0 +1,16 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/collator/enum.CaseLevel.html Rust documentation for `CaseLevel`} for more information. + */ +export enum ICU4XCollatorCaseLevel { + /** + */ + Auto = 'Auto', + /** + */ + Off = 'Off', + /** + */ + On = 'On', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XCollatorCaseLevel.js b/third_party/rust/icu_capi/js/include/ICU4XCollatorCaseLevel.js new file mode 100644 index 000000000000..aa0f74738968 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCollatorCaseLevel.js @@ -0,0 +1,20 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XCollatorCaseLevel_js_to_rust = { + "Auto": 0, + "Off": 1, + "On": 2, +}; + +export const ICU4XCollatorCaseLevel_rust_to_js = { + [0]: "Auto", + [1]: "Off", + [2]: "On", +}; + +export const ICU4XCollatorCaseLevel = { + "Auto": "Auto", + "Off": "Off", + "On": "On", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XCollatorMaxVariable.d.ts b/third_party/rust/icu_capi/js/include/ICU4XCollatorMaxVariable.d.ts new file mode 100644 index 000000000000..2605bbc45001 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCollatorMaxVariable.d.ts @@ -0,0 +1,22 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/collator/enum.MaxVariable.html Rust documentation for `MaxVariable`} for more information. + */ +export enum ICU4XCollatorMaxVariable { + /** + */ + Auto = 'Auto', + /** + */ + Space = 'Space', + /** + */ + Punctuation = 'Punctuation', + /** + */ + Symbol = 'Symbol', + /** + */ + Currency = 'Currency', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XCollatorMaxVariable.js b/third_party/rust/icu_capi/js/include/ICU4XCollatorMaxVariable.js new file mode 100644 index 000000000000..6964c4812d34 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCollatorMaxVariable.js @@ -0,0 +1,26 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XCollatorMaxVariable_js_to_rust = { + "Auto": 0, + "Space": 1, + "Punctuation": 2, + "Symbol": 3, + "Currency": 4, +}; + +export const ICU4XCollatorMaxVariable_rust_to_js = { + [0]: "Auto", + [1]: "Space", + [2]: "Punctuation", + [3]: "Symbol", + [4]: "Currency", +}; + +export const ICU4XCollatorMaxVariable = { + "Auto": "Auto", + "Space": "Space", + "Punctuation": "Punctuation", + "Symbol": "Symbol", + "Currency": "Currency", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XCollatorNumeric.d.ts b/third_party/rust/icu_capi/js/include/ICU4XCollatorNumeric.d.ts new file mode 100644 index 000000000000..884c71d62b2f --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCollatorNumeric.d.ts @@ -0,0 +1,16 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/collator/enum.Numeric.html Rust documentation for `Numeric`} for more information. + */ +export enum ICU4XCollatorNumeric { + /** + */ + Auto = 'Auto', + /** + */ + Off = 'Off', + /** + */ + On = 'On', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XCollatorNumeric.js b/third_party/rust/icu_capi/js/include/ICU4XCollatorNumeric.js new file mode 100644 index 000000000000..8a5e5e1f5805 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCollatorNumeric.js @@ -0,0 +1,20 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XCollatorNumeric_js_to_rust = { + "Auto": 0, + "Off": 1, + "On": 2, +}; + +export const ICU4XCollatorNumeric_rust_to_js = { + [0]: "Auto", + [1]: "Off", + [2]: "On", +}; + +export const ICU4XCollatorNumeric = { + "Auto": "Auto", + "Off": "Off", + "On": "On", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XCollatorOptionsV1.d.ts b/third_party/rust/icu_capi/js/include/ICU4XCollatorOptionsV1.d.ts new file mode 100644 index 000000000000..3306764cd459 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCollatorOptionsV1.d.ts @@ -0,0 +1,21 @@ +import { ICU4XCollatorAlternateHandling } from "./ICU4XCollatorAlternateHandling"; +import { ICU4XCollatorBackwardSecondLevel } from "./ICU4XCollatorBackwardSecondLevel"; +import { ICU4XCollatorCaseFirst } from "./ICU4XCollatorCaseFirst"; +import { ICU4XCollatorCaseLevel } from "./ICU4XCollatorCaseLevel"; +import { ICU4XCollatorMaxVariable } from "./ICU4XCollatorMaxVariable"; +import { ICU4XCollatorNumeric } from "./ICU4XCollatorNumeric"; +import { ICU4XCollatorStrength } from "./ICU4XCollatorStrength"; + +/** + + * See the {@link https://docs.rs/icu/latest/icu/collator/struct.CollatorOptions.html Rust documentation for `CollatorOptions`} for more information. + */ +export class ICU4XCollatorOptionsV1 { + strength: ICU4XCollatorStrength; + alternate_handling: ICU4XCollatorAlternateHandling; + case_first: ICU4XCollatorCaseFirst; + max_variable: ICU4XCollatorMaxVariable; + case_level: ICU4XCollatorCaseLevel; + numeric: ICU4XCollatorNumeric; + backward_second_level: ICU4XCollatorBackwardSecondLevel; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCollatorOptionsV1.js b/third_party/rust/icu_capi/js/include/ICU4XCollatorOptionsV1.js new file mode 100644 index 000000000000..5be95f595533 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCollatorOptionsV1.js @@ -0,0 +1,21 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XCollatorAlternateHandling_js_to_rust, ICU4XCollatorAlternateHandling_rust_to_js } from "./ICU4XCollatorAlternateHandling.js" +import { ICU4XCollatorBackwardSecondLevel_js_to_rust, ICU4XCollatorBackwardSecondLevel_rust_to_js } from "./ICU4XCollatorBackwardSecondLevel.js" +import { ICU4XCollatorCaseFirst_js_to_rust, ICU4XCollatorCaseFirst_rust_to_js } from "./ICU4XCollatorCaseFirst.js" +import { ICU4XCollatorCaseLevel_js_to_rust, ICU4XCollatorCaseLevel_rust_to_js } from "./ICU4XCollatorCaseLevel.js" +import { ICU4XCollatorMaxVariable_js_to_rust, ICU4XCollatorMaxVariable_rust_to_js } from "./ICU4XCollatorMaxVariable.js" +import { ICU4XCollatorNumeric_js_to_rust, ICU4XCollatorNumeric_rust_to_js } from "./ICU4XCollatorNumeric.js" +import { ICU4XCollatorStrength_js_to_rust, ICU4XCollatorStrength_rust_to_js } from "./ICU4XCollatorStrength.js" + +export class ICU4XCollatorOptionsV1 { + constructor(underlying) { + this.strength = ICU4XCollatorStrength_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, underlying)]; + this.alternate_handling = ICU4XCollatorAlternateHandling_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, underlying + 4)]; + this.case_first = ICU4XCollatorCaseFirst_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, underlying + 8)]; + this.max_variable = ICU4XCollatorMaxVariable_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, underlying + 12)]; + this.case_level = ICU4XCollatorCaseLevel_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, underlying + 16)]; + this.numeric = ICU4XCollatorNumeric_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, underlying + 20)]; + this.backward_second_level = ICU4XCollatorBackwardSecondLevel_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, underlying + 24)]; + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCollatorStrength.d.ts b/third_party/rust/icu_capi/js/include/ICU4XCollatorStrength.d.ts new file mode 100644 index 000000000000..2f1ff28a60aa --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCollatorStrength.d.ts @@ -0,0 +1,25 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/collator/enum.Strength.html Rust documentation for `Strength`} for more information. + */ +export enum ICU4XCollatorStrength { + /** + */ + Auto = 'Auto', + /** + */ + Primary = 'Primary', + /** + */ + Secondary = 'Secondary', + /** + */ + Tertiary = 'Tertiary', + /** + */ + Quaternary = 'Quaternary', + /** + */ + Identical = 'Identical', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XCollatorStrength.js b/third_party/rust/icu_capi/js/include/ICU4XCollatorStrength.js new file mode 100644 index 000000000000..4a8ca99fd2d2 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCollatorStrength.js @@ -0,0 +1,29 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XCollatorStrength_js_to_rust = { + "Auto": 0, + "Primary": 1, + "Secondary": 2, + "Tertiary": 3, + "Quaternary": 4, + "Identical": 5, +}; + +export const ICU4XCollatorStrength_rust_to_js = { + [0]: "Auto", + [1]: "Primary", + [2]: "Secondary", + [3]: "Tertiary", + [4]: "Quaternary", + [5]: "Identical", +}; + +export const ICU4XCollatorStrength = { + "Auto": "Auto", + "Primary": "Primary", + "Secondary": "Secondary", + "Tertiary": "Tertiary", + "Quaternary": "Quaternary", + "Identical": "Identical", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XComposingNormalizer.d.ts b/third_party/rust/icu_capi/js/include/ICU4XComposingNormalizer.d.ts new file mode 100644 index 000000000000..9e07d0da3aa1 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XComposingNormalizer.d.ts @@ -0,0 +1,49 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; + +/** + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html Rust documentation for `ComposingNormalizer`} for more information. + */ +export class ICU4XComposingNormalizer { + + /** + + * Construct a new ICU4XComposingNormalizer instance for NFC + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html#method.try_new_nfc_unstable Rust documentation for `try_new_nfc_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_nfc(provider: ICU4XDataProvider): ICU4XComposingNormalizer | never; + + /** + + * Construct a new ICU4XComposingNormalizer instance for NFKC + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html#method.try_new_nfkc_unstable Rust documentation for `try_new_nfkc_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_nfkc(provider: ICU4XDataProvider): ICU4XComposingNormalizer | never; + + /** + + * Normalize a (potentially ill-formed) UTF8 string + + * Errors are mapped to REPLACEMENT CHARACTER + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html#method.normalize_utf8 Rust documentation for `normalize_utf8`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + normalize(s: string): string | never; + + /** + + * Check if a (potentially ill-formed) UTF8 string is normalized + + * Errors are mapped to REPLACEMENT CHARACTER + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/struct.ComposingNormalizer.html#method.is_normalized_utf8 Rust documentation for `is_normalized_utf8`} for more information. + */ + is_normalized(s: string): boolean; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XComposingNormalizer.js b/third_party/rust/icu_capi/js/include/ICU4XComposingNormalizer.js new file mode 100644 index 000000000000..8793316b7ac1 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XComposingNormalizer.js @@ -0,0 +1,81 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XComposingNormalizer_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XComposingNormalizer_destroy(underlying); +}); + +export class ICU4XComposingNormalizer { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XComposingNormalizer_box_destroy_registry.register(this, underlying); + } + } + + static create_nfc(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XComposingNormalizer_create_nfc(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XComposingNormalizer(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_nfkc(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XComposingNormalizer_create_nfkc(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XComposingNormalizer(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + normalize(arg_s) { + const buf_arg_s = diplomatRuntime.DiplomatBuf.str(wasm, arg_s); + const diplomat_out = diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XComposingNormalizer_normalize(diplomat_receive_buffer, this.underlying, buf_arg_s.ptr, buf_arg_s.size, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + buf_arg_s.free(); + return diplomat_out; + } + + is_normalized(arg_s) { + const buf_arg_s = diplomatRuntime.DiplomatBuf.str(wasm, arg_s); + const diplomat_out = wasm.ICU4XComposingNormalizer_is_normalized(this.underlying, buf_arg_s.ptr, buf_arg_s.size); + buf_arg_s.free(); + return diplomat_out; + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCustomTimeZone.d.ts b/third_party/rust/icu_capi/js/include/ICU4XCustomTimeZone.d.ts new file mode 100644 index 000000000000..a5f78f49ed86 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCustomTimeZone.d.ts @@ -0,0 +1,281 @@ +import { i32 } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { ICU4XError } from "./ICU4XError"; +import { ICU4XIsoDateTime } from "./ICU4XIsoDateTime"; +import { ICU4XMetazoneCalculator } from "./ICU4XMetazoneCalculator"; + +/** + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html Rust documentation for `CustomTimeZone`} for more information. + */ +export class ICU4XCustomTimeZone { + + /** + + * Creates a time zone from an offset string. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.from_str Rust documentation for `from_str`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_from_string(s: string): ICU4XCustomTimeZone | never; + + /** + + * Creates a time zone with no information. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.new_empty Rust documentation for `new_empty`} for more information. + */ + static create_empty(): ICU4XCustomTimeZone; + + /** + + * Creates a time zone for UTC. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.utc Rust documentation for `utc`} for more information. + */ + static create_utc(): ICU4XCustomTimeZone; + + /** + + * Sets the `gmt_offset` field from offset seconds. + + * Errors if the offset seconds are out of range. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.try_from_offset_seconds Rust documentation for `try_from_offset_seconds`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html 1} + * @throws {@link FFIError}<{@link ICU4XError}> + */ + try_set_gmt_offset_seconds(offset_seconds: i32): void | never; + + /** + + * Clears the `gmt_offset` field. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.offset_seconds Rust documentation for `offset_seconds`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html 1} + */ + clear_gmt_offset(): void; + + /** + + * Returns the value of the `gmt_offset` field as offset seconds. + + * Errors if the `gmt_offset` field is empty. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.offset_seconds Rust documentation for `offset_seconds`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html 1} + * @throws {@link FFIError}<{@link ICU4XError}> + */ + gmt_offset_seconds(): i32 | never; + + /** + + * Returns whether the `gmt_offset` field is positive. + + * Errors if the `gmt_offset` field is empty. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.is_positive Rust documentation for `is_positive`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + is_gmt_offset_positive(): boolean | never; + + /** + + * Returns whether the `gmt_offset` field is zero. + + * Errors if the `gmt_offset` field is empty (which is not the same as zero). + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.is_zero Rust documentation for `is_zero`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + is_gmt_offset_zero(): boolean | never; + + /** + + * Returns whether the `gmt_offset` field has nonzero minutes. + + * Errors if the `gmt_offset` field is empty. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.has_minutes Rust documentation for `has_minutes`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + gmt_offset_has_minutes(): boolean | never; + + /** + + * Returns whether the `gmt_offset` field has nonzero seconds. + + * Errors if the `gmt_offset` field is empty. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.GmtOffset.html#method.has_seconds Rust documentation for `has_seconds`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + gmt_offset_has_seconds(): boolean | never; + + /** + + * Sets the `time_zone_id` field from a string. + + * Errors if the string is not a valid BCP-47 time zone ID. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.time_zone_id Rust documentation for `time_zone_id`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneBcp47Id.html 1} + * @throws {@link FFIError}<{@link ICU4XError}> + */ + try_set_time_zone_id(id: string): void | never; + + /** + + * Clears the `time_zone_id` field. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.time_zone_id Rust documentation for `time_zone_id`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneBcp47Id.html 1} + */ + clear_time_zone_id(): void; + + /** + + * Writes the value of the `time_zone_id` field as a string. + + * Errors if the `time_zone_id` field is empty. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.time_zone_id Rust documentation for `time_zone_id`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/timezone/struct.TimeZoneBcp47Id.html 1} + * @throws {@link FFIError}<{@link ICU4XError}> + */ + time_zone_id(): string | never; + + /** + + * Sets the `metazone_id` field from a string. + + * Errors if the string is not a valid BCP-47 metazone ID. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.metazone_id Rust documentation for `metazone_id`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/timezone/struct.MetazoneId.html 1} + * @throws {@link FFIError}<{@link ICU4XError}> + */ + try_set_metazone_id(id: string): void | never; + + /** + + * Clears the `metazone_id` field. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.metazone_id Rust documentation for `metazone_id`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/timezone/struct.MetazoneId.html 1} + */ + clear_metazone_id(): void; + + /** + + * Writes the value of the `metazone_id` field as a string. + + * Errors if the `metazone_id` field is empty. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.metazone_id Rust documentation for `metazone_id`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/timezone/struct.MetazoneId.html 1} + * @throws {@link FFIError}<{@link ICU4XError}> + */ + metazone_id(): string | never; + + /** + + * Sets the `zone_variant` field from a string. + + * Errors if the string is not a valid zone variant. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant Rust documentation for `zone_variant`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html 1} + * @throws {@link FFIError}<{@link ICU4XError}> + */ + try_set_zone_variant(id: string): void | never; + + /** + + * Clears the `zone_variant` field. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant Rust documentation for `zone_variant`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html 1} + */ + clear_zone_variant(): void; + + /** + + * Writes the value of the `zone_variant` field as a string. + + * Errors if the `zone_variant` field is empty. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant Rust documentation for `zone_variant`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html 1} + * @throws {@link FFIError}<{@link ICU4XError}> + */ + zone_variant(): string | never; + + /** + + * Sets the `zone_variant` field to standard time. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.standard Rust documentation for `standard`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant 1} + */ + set_standard_time(): void; + + /** + + * Sets the `zone_variant` field to daylight time. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.daylight Rust documentation for `daylight`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant 1} + */ + set_daylight_time(): void; + + /** + + * Returns whether the `zone_variant` field is standard time. + + * Errors if the `zone_variant` field is empty. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.standard Rust documentation for `standard`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant 1} + * @throws {@link FFIError}<{@link ICU4XError}> + */ + is_standard_time(): boolean | never; + + /** + + * Returns whether the `zone_variant` field is daylight time. + + * Errors if the `zone_variant` field is empty. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.ZoneVariant.html#method.daylight Rust documentation for `daylight`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#structfield.zone_variant 1} + * @throws {@link FFIError}<{@link ICU4XError}> + */ + is_daylight_time(): boolean | never; + + /** + + * Sets the metazone based on the time zone and the local timestamp. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.CustomTimeZone.html#method.maybe_calculate_metazone Rust documentation for `maybe_calculate_metazone`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/timezone/struct.MetazoneCalculator.html#method.compute_metazone_from_time_zone 1} + */ + maybe_calculate_metazone(metazone_calculator: ICU4XMetazoneCalculator, local_datetime: ICU4XIsoDateTime): void; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XCustomTimeZone.js b/third_party/rust/icu_capi/js/include/ICU4XCustomTimeZone.js new file mode 100644 index 000000000000..5e0b3ab6c87b --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XCustomTimeZone.js @@ -0,0 +1,327 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XCustomTimeZone_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XCustomTimeZone_destroy(underlying); +}); + +export class ICU4XCustomTimeZone { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XCustomTimeZone_box_destroy_registry.register(this, underlying); + } + } + + static create_from_string(arg_s) { + const buf_arg_s = diplomatRuntime.DiplomatBuf.str(wasm, arg_s); + const diplomat_out = (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCustomTimeZone_create_from_string(diplomat_receive_buffer, buf_arg_s.ptr, buf_arg_s.size); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XCustomTimeZone(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + buf_arg_s.free(); + return diplomat_out; + } + + static create_empty() { + return new ICU4XCustomTimeZone(wasm.ICU4XCustomTimeZone_create_empty(), true, []); + } + + static create_utc() { + return new ICU4XCustomTimeZone(wasm.ICU4XCustomTimeZone_create_utc(), true, []); + } + + try_set_gmt_offset_seconds(arg_offset_seconds) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCustomTimeZone_try_set_gmt_offset_seconds(diplomat_receive_buffer, this.underlying, arg_offset_seconds); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + clear_gmt_offset() { + wasm.ICU4XCustomTimeZone_clear_gmt_offset(this.underlying); + } + + gmt_offset_seconds() { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCustomTimeZone_gmt_offset_seconds(diplomat_receive_buffer, this.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = (new Int32Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + is_gmt_offset_positive() { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCustomTimeZone_is_gmt_offset_positive(diplomat_receive_buffer, this.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0] == 1; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + is_gmt_offset_zero() { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCustomTimeZone_is_gmt_offset_zero(diplomat_receive_buffer, this.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0] == 1; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + gmt_offset_has_minutes() { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCustomTimeZone_gmt_offset_has_minutes(diplomat_receive_buffer, this.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0] == 1; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + gmt_offset_has_seconds() { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCustomTimeZone_gmt_offset_has_seconds(diplomat_receive_buffer, this.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0] == 1; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + try_set_time_zone_id(arg_id) { + const buf_arg_id = diplomatRuntime.DiplomatBuf.str(wasm, arg_id); + const diplomat_out = (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCustomTimeZone_try_set_time_zone_id(diplomat_receive_buffer, this.underlying, buf_arg_id.ptr, buf_arg_id.size); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + buf_arg_id.free(); + return diplomat_out; + } + + clear_time_zone_id() { + wasm.ICU4XCustomTimeZone_clear_time_zone_id(this.underlying); + } + + time_zone_id() { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCustomTimeZone_time_zone_id(diplomat_receive_buffer, this.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + try_set_metazone_id(arg_id) { + const buf_arg_id = diplomatRuntime.DiplomatBuf.str(wasm, arg_id); + const diplomat_out = (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCustomTimeZone_try_set_metazone_id(diplomat_receive_buffer, this.underlying, buf_arg_id.ptr, buf_arg_id.size); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + buf_arg_id.free(); + return diplomat_out; + } + + clear_metazone_id() { + wasm.ICU4XCustomTimeZone_clear_metazone_id(this.underlying); + } + + metazone_id() { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCustomTimeZone_metazone_id(diplomat_receive_buffer, this.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + try_set_zone_variant(arg_id) { + const buf_arg_id = diplomatRuntime.DiplomatBuf.str(wasm, arg_id); + const diplomat_out = (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCustomTimeZone_try_set_zone_variant(diplomat_receive_buffer, this.underlying, buf_arg_id.ptr, buf_arg_id.size); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + buf_arg_id.free(); + return diplomat_out; + } + + clear_zone_variant() { + wasm.ICU4XCustomTimeZone_clear_zone_variant(this.underlying); + } + + zone_variant() { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCustomTimeZone_zone_variant(diplomat_receive_buffer, this.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + set_standard_time() { + wasm.ICU4XCustomTimeZone_set_standard_time(this.underlying); + } + + set_daylight_time() { + wasm.ICU4XCustomTimeZone_set_daylight_time(this.underlying); + } + + is_standard_time() { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCustomTimeZone_is_standard_time(diplomat_receive_buffer, this.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0] == 1; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + is_daylight_time() { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XCustomTimeZone_is_daylight_time(diplomat_receive_buffer, this.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = (new Uint8Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0] == 1; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + maybe_calculate_metazone(arg_metazone_calculator, arg_local_datetime) { + wasm.ICU4XCustomTimeZone_maybe_calculate_metazone(this.underlying, arg_metazone_calculator.underlying, arg_local_datetime.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDataProvider.d.ts b/third_party/rust/icu_capi/js/include/ICU4XDataProvider.d.ts new file mode 100644 index 000000000000..7ca2760d9738 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDataProvider.d.ts @@ -0,0 +1,90 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XError } from "./ICU4XError"; +import { ICU4XLocaleFallbacker } from "./ICU4XLocaleFallbacker"; + +/** + + * An ICU4X data provider, capable of loading ICU4X data keys from some source. + + * See the {@link https://docs.rs/icu_provider/latest/icu_provider/index.html Rust documentation for `icu_provider`} for more information. + */ +export class ICU4XDataProvider { + + /** + + * Constructs an `FsDataProvider` and returns it as an {@link ICU4XDataProvider `ICU4XDataProvider`}. Requires the `provider_fs` Cargo feature. Not supported in WASM. + + * See the {@link https://docs.rs/icu_provider_fs/latest/icu_provider_fs/struct.FsDataProvider.html Rust documentation for `FsDataProvider`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_fs(path: string): ICU4XDataProvider | never; + + /** + + * Constructs a testdata provider and returns it as an {@link ICU4XDataProvider `ICU4XDataProvider`}. Requires the `provider_test` and one of `any_provider` or `buffer_provider` Cargo features. + + * See the {@link https://docs.rs/icu_testdata/latest/icu_testdata/index.html Rust documentation for `icu_testdata`} for more information. + */ + static create_test(): ICU4XDataProvider; + + /** + + * Constructs a `BlobDataProvider` and returns it as an {@link ICU4XDataProvider `ICU4XDataProvider`}. + + * See the {@link https://docs.rs/icu_provider_blob/latest/icu_provider_blob/struct.BlobDataProvider.html Rust documentation for `BlobDataProvider`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_from_byte_slice(blob: Uint8Array): ICU4XDataProvider | never; + + /** + + * Constructs an empty {@link ICU4XDataProvider `ICU4XDataProvider`}. + + * See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/empty/struct.EmptyDataProvider.html Rust documentation for `EmptyDataProvider`} for more information. + */ + static create_empty(): ICU4XDataProvider; + + /** + + * Creates a provider that tries the current provider and then, if the current provider doesn't support the data key, another provider `other`. + + * This takes ownership of the `other` provider, leaving an empty provider in its place. + + * The providers must be the same type (Any or Buffer). This condition is satisfied if both providers originate from the same constructor, such as `create_from_byte_slice` or `create_fs`. If the condition is not upheld, a runtime error occurs. + + * See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fork/type.ForkByKeyProvider.html Rust documentation for `ForkByKeyProvider`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + fork_by_key(other: ICU4XDataProvider): void | never; + + /** + + * Same as `fork_by_key` but forks by locale instead of key. + + * See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fork/predicates/struct.MissingLocalePredicate.html Rust documentation for `MissingLocalePredicate`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + fork_by_locale(other: ICU4XDataProvider): void | never; + + /** + + * Enables locale fallbacking for data requests made to this provider. + + * Note that the test provider (from `create_test`) already has fallbacking enabled. + + * See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + + * Additional information: {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html 1} + * @throws {@link FFIError}<{@link ICU4XError}> + */ + enable_locale_fallback(): void | never; + + /** + + * See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html#method.new_with_fallbacker Rust documentation for `new_with_fallbacker`} for more information. + + * Additional information: {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackProvider.html 1} + * @throws {@link FFIError}<{@link ICU4XError}> + */ + enable_locale_fallback_with(fallbacker: ICU4XLocaleFallbacker): void | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDataProvider.js b/third_party/rust/icu_capi/js/include/ICU4XDataProvider.js new file mode 100644 index 000000000000..3b1354f8248d --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDataProvider.js @@ -0,0 +1,134 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XDataProvider_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XDataProvider_destroy(underlying); +}); + +export class ICU4XDataProvider { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XDataProvider_box_destroy_registry.register(this, underlying); + } + } + + static create_fs(arg_path) { + const buf_arg_path = diplomatRuntime.DiplomatBuf.str(wasm, arg_path); + const diplomat_out = (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDataProvider_create_fs(diplomat_receive_buffer, buf_arg_path.ptr, buf_arg_path.size); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XDataProvider(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + buf_arg_path.free(); + return diplomat_out; + } + + static create_test() { + return new ICU4XDataProvider(wasm.ICU4XDataProvider_create_test(), true, []); + } + + static create_from_byte_slice(arg_blob) { + const buf_arg_blob = diplomatRuntime.DiplomatBuf.slice(wasm, arg_blob, 1); + const diplomat_out = (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDataProvider_create_from_byte_slice(diplomat_receive_buffer, buf_arg_blob.ptr, buf_arg_blob.size); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XDataProvider(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + buf_arg_blob.leak(); + return diplomat_out; + } + + static create_empty() { + return new ICU4XDataProvider(wasm.ICU4XDataProvider_create_empty(), true, []); + } + + fork_by_key(arg_other) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDataProvider_fork_by_key(diplomat_receive_buffer, this.underlying, arg_other.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + fork_by_locale(arg_other) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDataProvider_fork_by_locale(diplomat_receive_buffer, this.underlying, arg_other.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + enable_locale_fallback() { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDataProvider_enable_locale_fallback(diplomat_receive_buffer, this.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + enable_locale_fallback_with(arg_fallbacker) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDataProvider_enable_locale_fallback_with(diplomat_receive_buffer, this.underlying, arg_fallbacker.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDataStruct.d.ts b/third_party/rust/icu_capi/js/include/ICU4XDataStruct.d.ts new file mode 100644 index 000000000000..8d2464f40ed5 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDataStruct.d.ts @@ -0,0 +1,23 @@ +import { u8 } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { ICU4XError } from "./ICU4XError"; + +/** + + * A generic data struct to be used by ICU4X + + * This can be used to construct a StructDataProvider. + */ +export class ICU4XDataStruct { + + /** + + * Construct a new DecimalSymbolsV1 data struct. + + * C++ users: All string arguments must be valid UTF8 + + * See the {@link https://docs.rs/icu/latest/icu/decimal/provider/struct.DecimalSymbolsV1.html Rust documentation for `DecimalSymbolsV1`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_decimal_symbols_v1(plus_sign_prefix: string, plus_sign_suffix: string, minus_sign_prefix: string, minus_sign_suffix: string, decimal_separator: string, grouping_separator: string, primary_group_size: u8, secondary_group_size: u8, min_group_size: u8, digits: Uint32Array): ICU4XDataStruct | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDataStruct.js b/third_party/rust/icu_capi/js/include/ICU4XDataStruct.js new file mode 100644 index 000000000000..22bc10d69b23 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDataStruct.js @@ -0,0 +1,50 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XDataStruct_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XDataStruct_destroy(underlying); +}); + +export class ICU4XDataStruct { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XDataStruct_box_destroy_registry.register(this, underlying); + } + } + + static create_decimal_symbols_v1(arg_plus_sign_prefix, arg_plus_sign_suffix, arg_minus_sign_prefix, arg_minus_sign_suffix, arg_decimal_separator, arg_grouping_separator, arg_primary_group_size, arg_secondary_group_size, arg_min_group_size, arg_digits) { + const buf_arg_plus_sign_prefix = diplomatRuntime.DiplomatBuf.str(wasm, arg_plus_sign_prefix); + const buf_arg_plus_sign_suffix = diplomatRuntime.DiplomatBuf.str(wasm, arg_plus_sign_suffix); + const buf_arg_minus_sign_prefix = diplomatRuntime.DiplomatBuf.str(wasm, arg_minus_sign_prefix); + const buf_arg_minus_sign_suffix = diplomatRuntime.DiplomatBuf.str(wasm, arg_minus_sign_suffix); + const buf_arg_decimal_separator = diplomatRuntime.DiplomatBuf.str(wasm, arg_decimal_separator); + const buf_arg_grouping_separator = diplomatRuntime.DiplomatBuf.str(wasm, arg_grouping_separator); + const buf_arg_digits = diplomatRuntime.DiplomatBuf.slice(wasm, arg_digits, 4); + const diplomat_out = (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDataStruct_create_decimal_symbols_v1(diplomat_receive_buffer, buf_arg_plus_sign_prefix.ptr, buf_arg_plus_sign_prefix.size, buf_arg_plus_sign_suffix.ptr, buf_arg_plus_sign_suffix.size, buf_arg_minus_sign_prefix.ptr, buf_arg_minus_sign_prefix.size, buf_arg_minus_sign_suffix.ptr, buf_arg_minus_sign_suffix.size, buf_arg_decimal_separator.ptr, buf_arg_decimal_separator.size, buf_arg_grouping_separator.ptr, buf_arg_grouping_separator.size, arg_primary_group_size, arg_secondary_group_size, arg_min_group_size, buf_arg_digits.ptr, buf_arg_digits.size); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XDataStruct(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + buf_arg_plus_sign_prefix.free(); + buf_arg_plus_sign_suffix.free(); + buf_arg_minus_sign_prefix.free(); + buf_arg_minus_sign_suffix.free(); + buf_arg_decimal_separator.free(); + buf_arg_grouping_separator.free(); + buf_arg_digits.free(); + return diplomat_out; + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDate.d.ts b/third_party/rust/icu_capi/js/include/ICU4XDate.d.ts new file mode 100644 index 000000000000..7ff938aa2a16 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDate.d.ts @@ -0,0 +1,156 @@ +import { u8, i32, u32 } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { ICU4XCalendar } from "./ICU4XCalendar"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XIsoDate } from "./ICU4XIsoDate"; +import { ICU4XIsoWeekday } from "./ICU4XIsoWeekday"; +import { ICU4XWeekCalculator } from "./ICU4XWeekCalculator"; +import { ICU4XWeekOf } from "./ICU4XWeekOf"; + +/** + + * An ICU4X Date object capable of containing a date and time for any calendar. + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html Rust documentation for `Date`} for more information. + */ +export class ICU4XDate { + + /** + + * Creates a new {@link ICU4XDate `ICU4XDate`} representing the ISO date and time given but in a given calendar + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.new_from_iso Rust documentation for `new_from_iso`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_from_iso_in_calendar(year: i32, month: u8, day: u8, calendar: ICU4XCalendar): ICU4XDate | never; + + /** + + * Creates a new {@link ICU4XDate `ICU4XDate`} from the given codes, which are interpreted in the given calendar system + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.try_new_from_codes Rust documentation for `try_new_from_codes`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_from_codes_in_calendar(era_code: string, year: i32, month_code: string, day: u8, calendar: ICU4XCalendar): ICU4XDate | never; + + /** + + * Convert this date to one in a different calendar + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.to_calendar Rust documentation for `to_calendar`} for more information. + */ + to_calendar(calendar: ICU4XCalendar): ICU4XDate; + + /** + + * Converts this date to ISO + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.to_iso Rust documentation for `to_iso`} for more information. + */ + to_iso(): ICU4XIsoDate; + + /** + + * Returns the 1-indexed day in the month for this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_month Rust documentation for `day_of_month`} for more information. + */ + day_of_month(): u32; + + /** + + * Returns the day in the week for this day + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_week Rust documentation for `day_of_week`} for more information. + */ + day_of_week(): ICU4XIsoWeekday; + + /** + + * Returns the week number in this month, 1-indexed, based on what is considered the first day of the week (often a locale preference). + + * `first_weekday` can be obtained via `first_weekday()` on {@link ICU4XWeekCalculator `ICU4XWeekCalculator`} + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_month Rust documentation for `week_of_month`} for more information. + */ + week_of_month(first_weekday: ICU4XIsoWeekday): u32; + + /** + + * Returns the week number in this year, using week data + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_year Rust documentation for `week_of_year`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + week_of_year(calculator: ICU4XWeekCalculator): ICU4XWeekOf | never; + + /** + + * Returns 1-indexed number of the month of this date in its year + + * Note that for lunar calendars this may not lead to the same month having the same ordinal month across years; use month_code if you care about month identity. + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month Rust documentation for `month`} for more information. + */ + ordinal_month(): u32; + + /** + + * Returns the month code for this date. Typically something like "M01", "M02", but can be more complicated for lunar calendars. + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month Rust documentation for `month`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + month_code(): string | never; + + /** + + * Returns the year number in the current era for this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year Rust documentation for `year`} for more information. + */ + year_in_era(): i32; + + /** + + * Returns the era for this date, + + * See the {@link https://docs.rs/icu/latest/icu/struct.Date.html#method.year Rust documentation for `year`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/types/struct.Era.html 1} + * @throws {@link FFIError}<{@link ICU4XError}> + */ + era(): string | never; + + /** + + * Returns the number of months in the year represented by this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.months_in_year Rust documentation for `months_in_year`} for more information. + */ + months_in_year(): u8; + + /** + + * Returns the number of days in the month represented by this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_month Rust documentation for `days_in_month`} for more information. + */ + days_in_month(): u8; + + /** + + * Returns the number of days in the year represented by this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_year Rust documentation for `days_in_year`} for more information. + */ + days_in_year(): u32; + + /** + + * Returns the {@link ICU4XCalendar `ICU4XCalendar`} object backing this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.calendar Rust documentation for `calendar`} for more information. + */ + calendar(): ICU4XCalendar; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDate.js b/third_party/rust/icu_capi/js/include/ICU4XDate.js new file mode 100644 index 000000000000..de7b646eb066 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDate.js @@ -0,0 +1,161 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XCalendar } from "./ICU4XCalendar.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XIsoDate } from "./ICU4XIsoDate.js" +import { ICU4XIsoWeekday_js_to_rust, ICU4XIsoWeekday_rust_to_js } from "./ICU4XIsoWeekday.js" +import { ICU4XWeekOf } from "./ICU4XWeekOf.js" +import { ICU4XWeekRelativeUnit_js_to_rust, ICU4XWeekRelativeUnit_rust_to_js } from "./ICU4XWeekRelativeUnit.js" + +const ICU4XDate_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XDate_destroy(underlying); +}); + +export class ICU4XDate { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XDate_box_destroy_registry.register(this, underlying); + } + } + + static create_from_iso_in_calendar(arg_year, arg_month, arg_day, arg_calendar) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDate_create_from_iso_in_calendar(diplomat_receive_buffer, arg_year, arg_month, arg_day, arg_calendar.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XDate(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_from_codes_in_calendar(arg_era_code, arg_year, arg_month_code, arg_day, arg_calendar) { + const buf_arg_era_code = diplomatRuntime.DiplomatBuf.str(wasm, arg_era_code); + const buf_arg_month_code = diplomatRuntime.DiplomatBuf.str(wasm, arg_month_code); + const diplomat_out = (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDate_create_from_codes_in_calendar(diplomat_receive_buffer, buf_arg_era_code.ptr, buf_arg_era_code.size, arg_year, buf_arg_month_code.ptr, buf_arg_month_code.size, arg_day, arg_calendar.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XDate(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + buf_arg_era_code.free(); + buf_arg_month_code.free(); + return diplomat_out; + } + + to_calendar(arg_calendar) { + return new ICU4XDate(wasm.ICU4XDate_to_calendar(this.underlying, arg_calendar.underlying), true, []); + } + + to_iso() { + return new ICU4XIsoDate(wasm.ICU4XDate_to_iso(this.underlying), true, []); + } + + day_of_month() { + return wasm.ICU4XDate_day_of_month(this.underlying); + } + + day_of_week() { + return ICU4XIsoWeekday_rust_to_js[wasm.ICU4XDate_day_of_week(this.underlying)]; + } + + week_of_month(arg_first_weekday) { + return wasm.ICU4XDate_week_of_month(this.underlying, ICU4XIsoWeekday_js_to_rust[arg_first_weekday]); + } + + week_of_year(arg_calculator) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(9, 4); + wasm.ICU4XDate_week_of_year(diplomat_receive_buffer, this.underlying, arg_calculator.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 8); + if (is_ok) { + const ok_value = new ICU4XWeekOf(diplomat_receive_buffer); + wasm.diplomat_free(diplomat_receive_buffer, 9, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 9, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + ordinal_month() { + return wasm.ICU4XDate_ordinal_month(this.underlying); + } + + month_code() { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDate_month_code(diplomat_receive_buffer, this.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + year_in_era() { + return wasm.ICU4XDate_year_in_era(this.underlying); + } + + era() { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDate_era(diplomat_receive_buffer, this.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + months_in_year() { + return wasm.ICU4XDate_months_in_year(this.underlying); + } + + days_in_month() { + return wasm.ICU4XDate_days_in_month(this.underlying); + } + + days_in_year() { + return wasm.ICU4XDate_days_in_year(this.underlying); + } + + calendar() { + return new ICU4XCalendar(wasm.ICU4XDate_calendar(this.underlying), true, []); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDateFormatter.d.ts b/third_party/rust/icu_capi/js/include/ICU4XDateFormatter.d.ts new file mode 100644 index 000000000000..461fc78cd4e2 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDateFormatter.d.ts @@ -0,0 +1,67 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XDate } from "./ICU4XDate"; +import { ICU4XDateLength } from "./ICU4XDateLength"; +import { ICU4XDateTime } from "./ICU4XDateTime"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XIsoDate } from "./ICU4XIsoDate"; +import { ICU4XIsoDateTime } from "./ICU4XIsoDateTime"; +import { ICU4XLocale } from "./ICU4XLocale"; + +/** + + * An ICU4X DateFormatter object capable of formatting a {@link ICU4XDate `ICU4XDate`} as a string, using some calendar specified at runtime in the locale. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html Rust documentation for `DateFormatter`} for more information. + */ +export class ICU4XDateFormatter { + + /** + + * Creates a new {@link ICU4XDateFormatter `ICU4XDateFormatter`} from locale data. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.try_new_with_length_unstable Rust documentation for `try_new_with_length_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_with_length(provider: ICU4XDataProvider, locale: ICU4XLocale, date_length: ICU4XDateLength): ICU4XDateFormatter | never; + + /** + + * Formats a {@link ICU4XDate `ICU4XDate`} to a string. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.format Rust documentation for `format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + format_date(value: ICU4XDate): string | never; + + /** + + * Formats a {@link ICU4XIsoDate `ICU4XIsoDate`} to a string. + + * Will convert to this formatter's calendar first + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.format Rust documentation for `format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + format_iso_date(value: ICU4XIsoDate): string | never; + + /** + + * Formats a {@link ICU4XDateTime `ICU4XDateTime`} to a string. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.format Rust documentation for `format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + format_datetime(value: ICU4XDateTime): string | never; + + /** + + * Formats a {@link ICU4XIsoDateTime `ICU4XIsoDateTime`} to a string. + + * Will convert to this formatter's calendar first + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.DateFormatter.html#method.format Rust documentation for `format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + format_iso_datetime(value: ICU4XIsoDateTime): string | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDateFormatter.js b/third_party/rust/icu_capi/js/include/ICU4XDateFormatter.js new file mode 100644 index 000000000000..d48003362d15 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDateFormatter.js @@ -0,0 +1,112 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XDateLength_js_to_rust, ICU4XDateLength_rust_to_js } from "./ICU4XDateLength.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XDateFormatter_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XDateFormatter_destroy(underlying); +}); + +export class ICU4XDateFormatter { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XDateFormatter_box_destroy_registry.register(this, underlying); + } + } + + static create_with_length(arg_provider, arg_locale, arg_date_length) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDateFormatter_create_with_length(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying, ICU4XDateLength_js_to_rust[arg_date_length]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XDateFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + format_date(arg_value) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDateFormatter_format_date(diplomat_receive_buffer, this.underlying, arg_value.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + format_iso_date(arg_value) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDateFormatter_format_iso_date(diplomat_receive_buffer, this.underlying, arg_value.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + format_datetime(arg_value) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDateFormatter_format_datetime(diplomat_receive_buffer, this.underlying, arg_value.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + format_iso_datetime(arg_value) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDateFormatter_format_iso_datetime(diplomat_receive_buffer, this.underlying, arg_value.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDateLength.d.ts b/third_party/rust/icu_capi/js/include/ICU4XDateLength.d.ts new file mode 100644 index 000000000000..1229c2ce096a --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDateLength.d.ts @@ -0,0 +1,19 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/datetime/options/length/enum.Date.html Rust documentation for `Date`} for more information. + */ +export enum ICU4XDateLength { + /** + */ + Full = 'Full', + /** + */ + Long = 'Long', + /** + */ + Medium = 'Medium', + /** + */ + Short = 'Short', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XDateLength.js b/third_party/rust/icu_capi/js/include/ICU4XDateLength.js new file mode 100644 index 000000000000..bca6c2d8b895 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDateLength.js @@ -0,0 +1,23 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XDateLength_js_to_rust = { + "Full": 0, + "Long": 1, + "Medium": 2, + "Short": 3, +}; + +export const ICU4XDateLength_rust_to_js = { + [0]: "Full", + [1]: "Long", + [2]: "Medium", + [3]: "Short", +}; + +export const ICU4XDateLength = { + "Full": "Full", + "Long": "Long", + "Medium": "Medium", + "Short": "Short", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XDateTime.d.ts b/third_party/rust/icu_capi/js/include/ICU4XDateTime.d.ts new file mode 100644 index 000000000000..d0c6f1f1f1d6 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDateTime.d.ts @@ -0,0 +1,212 @@ +import { u8, i32, u32 } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { ICU4XCalendar } from "./ICU4XCalendar"; +import { ICU4XDate } from "./ICU4XDate"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XIsoDateTime } from "./ICU4XIsoDateTime"; +import { ICU4XIsoWeekday } from "./ICU4XIsoWeekday"; +import { ICU4XTime } from "./ICU4XTime"; +import { ICU4XWeekCalculator } from "./ICU4XWeekCalculator"; +import { ICU4XWeekOf } from "./ICU4XWeekOf"; + +/** + + * An ICU4X DateTime object capable of containing a date and time for any calendar. + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html Rust documentation for `DateTime`} for more information. + */ +export class ICU4XDateTime { + + /** + + * Creates a new {@link ICU4XDateTime `ICU4XDateTime`} representing the ISO date and time given but in a given calendar + + * See the {@link https://docs.rs/icu/latest/icu/struct.DateTime.html#method.new_from_iso Rust documentation for `new_from_iso`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_from_iso_in_calendar(year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, nanosecond: u32, calendar: ICU4XCalendar): ICU4XDateTime | never; + + /** + + * Creates a new {@link ICU4XDateTime `ICU4XDateTime`} from the given codes, which are interpreted in the given calendar system + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.try_new_from_codes Rust documentation for `try_new_from_codes`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_from_codes_in_calendar(era_code: string, year: i32, month_code: string, day: u8, hour: u8, minute: u8, second: u8, nanosecond: u32, calendar: ICU4XCalendar): ICU4XDateTime | never; + + /** + + * Creates a new {@link ICU4XDateTime `ICU4XDateTime`} from an {@link ICU4XDate `ICU4XDate`} and {@link ICU4XTime `ICU4XTime`} object + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.new Rust documentation for `new`} for more information. + */ + static create_from_date_and_time(date: ICU4XDate, time: ICU4XTime): ICU4XDateTime; + + /** + + * Gets a copy of the date contained in this object + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#structfield.date Rust documentation for `date`} for more information. + */ + date(): ICU4XDate; + + /** + + * Gets the time contained in this object + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#structfield.time Rust documentation for `time`} for more information. + */ + time(): ICU4XTime; + + /** + + * Converts this date to ISO + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.to_iso Rust documentation for `to_iso`} for more information. + */ + to_iso(): ICU4XIsoDateTime; + + /** + + * Convert this datetime to one in a different calendar + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.to_calendar Rust documentation for `to_calendar`} for more information. + */ + to_calendar(calendar: ICU4XCalendar): ICU4XDateTime; + + /** + + * Returns the hour in this time + + * See the {@link https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.hour Rust documentation for `hour`} for more information. + */ + hour(): u8; + + /** + + * Returns the minute in this time + + * See the {@link https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.minute Rust documentation for `minute`} for more information. + */ + minute(): u8; + + /** + + * Returns the second in this time + + * See the {@link https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.second Rust documentation for `second`} for more information. + */ + second(): u8; + + /** + + * Returns the nanosecond in this time + + * See the {@link https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.nanosecond Rust documentation for `nanosecond`} for more information. + */ + nanosecond(): u32; + + /** + + * Returns the 1-indexed day in the month for this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_month Rust documentation for `day_of_month`} for more information. + */ + day_of_month(): u32; + + /** + + * Returns the day in the week for this day + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_week Rust documentation for `day_of_week`} for more information. + */ + day_of_week(): ICU4XIsoWeekday; + + /** + + * Returns the week number in this month, 1-indexed, based on what is considered the first day of the week (often a locale preference). + + * `first_weekday` can be obtained via `first_weekday()` on {@link ICU4XWeekCalculator `ICU4XWeekCalculator`} + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_month Rust documentation for `week_of_month`} for more information. + */ + week_of_month(first_weekday: ICU4XIsoWeekday): u32; + + /** + + * Returns the week number in this year, using week data + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_year Rust documentation for `week_of_year`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + week_of_year(calculator: ICU4XWeekCalculator): ICU4XWeekOf | never; + + /** + + * Returns 1-indexed number of the month of this date in its year + + * Note that for lunar calendars this may not lead to the same month having the same ordinal month across years; use month_code if you care about month identity. + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month Rust documentation for `month`} for more information. + */ + ordinal_month(): u32; + + /** + + * Returns the month code for this date. Typically something like "M01", "M02", but can be more complicated for lunar calendars. + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month Rust documentation for `month`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + month_code(): string | never; + + /** + + * Returns the year number in the current era for this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year Rust documentation for `year`} for more information. + */ + year_in_era(): i32; + + /** + + * Returns the era for this date, + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year Rust documentation for `year`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + era(): string | never; + + /** + + * Returns the number of months in the year represented by this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.months_in_year Rust documentation for `months_in_year`} for more information. + */ + months_in_year(): u8; + + /** + + * Returns the number of days in the month represented by this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_month Rust documentation for `days_in_month`} for more information. + */ + days_in_month(): u8; + + /** + + * Returns the number of days in the year represented by this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_year Rust documentation for `days_in_year`} for more information. + */ + days_in_year(): u32; + + /** + + * Returns the {@link ICU4XCalendar `ICU4XCalendar`} object backing this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.calendar Rust documentation for `calendar`} for more information. + */ + calendar(): ICU4XCalendar; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDateTime.js b/third_party/rust/icu_capi/js/include/ICU4XDateTime.js new file mode 100644 index 000000000000..3d0d3d910fd3 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDateTime.js @@ -0,0 +1,191 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XCalendar } from "./ICU4XCalendar.js" +import { ICU4XDate } from "./ICU4XDate.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XIsoDateTime } from "./ICU4XIsoDateTime.js" +import { ICU4XIsoWeekday_js_to_rust, ICU4XIsoWeekday_rust_to_js } from "./ICU4XIsoWeekday.js" +import { ICU4XTime } from "./ICU4XTime.js" +import { ICU4XWeekOf } from "./ICU4XWeekOf.js" +import { ICU4XWeekRelativeUnit_js_to_rust, ICU4XWeekRelativeUnit_rust_to_js } from "./ICU4XWeekRelativeUnit.js" + +const ICU4XDateTime_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XDateTime_destroy(underlying); +}); + +export class ICU4XDateTime { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XDateTime_box_destroy_registry.register(this, underlying); + } + } + + static create_from_iso_in_calendar(arg_year, arg_month, arg_day, arg_hour, arg_minute, arg_second, arg_nanosecond, arg_calendar) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDateTime_create_from_iso_in_calendar(diplomat_receive_buffer, arg_year, arg_month, arg_day, arg_hour, arg_minute, arg_second, arg_nanosecond, arg_calendar.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XDateTime(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_from_codes_in_calendar(arg_era_code, arg_year, arg_month_code, arg_day, arg_hour, arg_minute, arg_second, arg_nanosecond, arg_calendar) { + const buf_arg_era_code = diplomatRuntime.DiplomatBuf.str(wasm, arg_era_code); + const buf_arg_month_code = diplomatRuntime.DiplomatBuf.str(wasm, arg_month_code); + const diplomat_out = (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDateTime_create_from_codes_in_calendar(diplomat_receive_buffer, buf_arg_era_code.ptr, buf_arg_era_code.size, arg_year, buf_arg_month_code.ptr, buf_arg_month_code.size, arg_day, arg_hour, arg_minute, arg_second, arg_nanosecond, arg_calendar.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XDateTime(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + buf_arg_era_code.free(); + buf_arg_month_code.free(); + return diplomat_out; + } + + static create_from_date_and_time(arg_date, arg_time) { + return new ICU4XDateTime(wasm.ICU4XDateTime_create_from_date_and_time(arg_date.underlying, arg_time.underlying), true, []); + } + + date() { + return new ICU4XDate(wasm.ICU4XDateTime_date(this.underlying), true, []); + } + + time() { + return new ICU4XTime(wasm.ICU4XDateTime_time(this.underlying), true, []); + } + + to_iso() { + return new ICU4XIsoDateTime(wasm.ICU4XDateTime_to_iso(this.underlying), true, []); + } + + to_calendar(arg_calendar) { + return new ICU4XDateTime(wasm.ICU4XDateTime_to_calendar(this.underlying, arg_calendar.underlying), true, []); + } + + hour() { + return wasm.ICU4XDateTime_hour(this.underlying); + } + + minute() { + return wasm.ICU4XDateTime_minute(this.underlying); + } + + second() { + return wasm.ICU4XDateTime_second(this.underlying); + } + + nanosecond() { + return wasm.ICU4XDateTime_nanosecond(this.underlying); + } + + day_of_month() { + return wasm.ICU4XDateTime_day_of_month(this.underlying); + } + + day_of_week() { + return ICU4XIsoWeekday_rust_to_js[wasm.ICU4XDateTime_day_of_week(this.underlying)]; + } + + week_of_month(arg_first_weekday) { + return wasm.ICU4XDateTime_week_of_month(this.underlying, ICU4XIsoWeekday_js_to_rust[arg_first_weekday]); + } + + week_of_year(arg_calculator) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(9, 4); + wasm.ICU4XDateTime_week_of_year(diplomat_receive_buffer, this.underlying, arg_calculator.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 8); + if (is_ok) { + const ok_value = new ICU4XWeekOf(diplomat_receive_buffer); + wasm.diplomat_free(diplomat_receive_buffer, 9, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 9, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + ordinal_month() { + return wasm.ICU4XDateTime_ordinal_month(this.underlying); + } + + month_code() { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDateTime_month_code(diplomat_receive_buffer, this.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + year_in_era() { + return wasm.ICU4XDateTime_year_in_era(this.underlying); + } + + era() { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDateTime_era(diplomat_receive_buffer, this.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + months_in_year() { + return wasm.ICU4XDateTime_months_in_year(this.underlying); + } + + days_in_month() { + return wasm.ICU4XDateTime_days_in_month(this.underlying); + } + + days_in_year() { + return wasm.ICU4XDateTime_days_in_year(this.underlying); + } + + calendar() { + return new ICU4XCalendar(wasm.ICU4XDateTime_calendar(this.underlying), true, []); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDateTimeFormatter.d.ts b/third_party/rust/icu_capi/js/include/ICU4XDateTimeFormatter.d.ts new file mode 100644 index 000000000000..ee956df0ce9a --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDateTimeFormatter.d.ts @@ -0,0 +1,46 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XDateLength } from "./ICU4XDateLength"; +import { ICU4XDateTime } from "./ICU4XDateTime"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XIsoDateTime } from "./ICU4XIsoDateTime"; +import { ICU4XLocale } from "./ICU4XLocale"; +import { ICU4XTimeLength } from "./ICU4XTimeLength"; + +/** + + * An ICU4X DateFormatter object capable of formatting a {@link ICU4XDateTime `ICU4XDateTime`} as a string, using some calendar specified at runtime in the locale. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html Rust documentation for `DateTimeFormatter`} for more information. + */ +export class ICU4XDateTimeFormatter { + + /** + + * Creates a new {@link ICU4XDateTimeFormatter `ICU4XDateTimeFormatter`} from locale data. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_with_lengths(provider: ICU4XDataProvider, locale: ICU4XLocale, date_length: ICU4XDateLength, time_length: ICU4XTimeLength): ICU4XDateTimeFormatter | never; + + /** + + * Formats a {@link ICU4XDateTime `ICU4XDateTime`} to a string. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.format Rust documentation for `format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + format_datetime(value: ICU4XDateTime): string | never; + + /** + + * Formats a {@link ICU4XIsoDateTime `ICU4XIsoDateTime`} to a string. + + * Will convert to this formatter's calendar first + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.DateTimeFormatter.html#method.format Rust documentation for `format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + format_iso_datetime(value: ICU4XIsoDateTime): string | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDateTimeFormatter.js b/third_party/rust/icu_capi/js/include/ICU4XDateTimeFormatter.js new file mode 100644 index 000000000000..83bbbae72f90 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDateTimeFormatter.js @@ -0,0 +1,75 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XDateLength_js_to_rust, ICU4XDateLength_rust_to_js } from "./ICU4XDateLength.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XTimeLength_js_to_rust, ICU4XTimeLength_rust_to_js } from "./ICU4XTimeLength.js" + +const ICU4XDateTimeFormatter_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XDateTimeFormatter_destroy(underlying); +}); + +export class ICU4XDateTimeFormatter { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XDateTimeFormatter_box_destroy_registry.register(this, underlying); + } + } + + static create_with_lengths(arg_provider, arg_locale, arg_date_length, arg_time_length) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDateTimeFormatter_create_with_lengths(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying, ICU4XDateLength_js_to_rust[arg_date_length], ICU4XTimeLength_js_to_rust[arg_time_length]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XDateTimeFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + format_datetime(arg_value) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDateTimeFormatter_format_datetime(diplomat_receive_buffer, this.underlying, arg_value.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + format_iso_datetime(arg_value) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDateTimeFormatter_format_iso_datetime(diplomat_receive_buffer, this.underlying, arg_value.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDecomposed.d.ts b/third_party/rust/icu_capi/js/include/ICU4XDecomposed.d.ts new file mode 100644 index 000000000000..a95e7cbde82f --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDecomposed.d.ts @@ -0,0 +1,12 @@ +import { char } from "./diplomat-runtime" + +/** + + * The outcome of non-recursive canonical decomposition of a character. `second` will be NUL when the decomposition expands to a single character (which may or may not be the original one) + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/properties/enum.Decomposed.html Rust documentation for `Decomposed`} for more information. + */ +export class ICU4XDecomposed { + first: char; + second: char; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDecomposed.js b/third_party/rust/icu_capi/js/include/ICU4XDecomposed.js new file mode 100644 index 000000000000..8f5e80f5e43b --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDecomposed.js @@ -0,0 +1,9 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export class ICU4XDecomposed { + constructor(underlying) { + this.first = String.fromCharCode((new Uint32Array(wasm.memory.buffer, underlying, 1))[0]); + this.second = String.fromCharCode((new Uint32Array(wasm.memory.buffer, underlying + 4, 1))[0]); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDecomposingNormalizer.d.ts b/third_party/rust/icu_capi/js/include/ICU4XDecomposingNormalizer.d.ts new file mode 100644 index 000000000000..d4e6498ed19e --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDecomposingNormalizer.d.ts @@ -0,0 +1,49 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; + +/** + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/struct.DecomposingNormalizer.html Rust documentation for `DecomposingNormalizer`} for more information. + */ +export class ICU4XDecomposingNormalizer { + + /** + + * Construct a new ICU4XDecomposingNormalizer instance for NFC + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/struct.DecomposingNormalizer.html#method.try_new_nfd_unstable Rust documentation for `try_new_nfd_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_nfd(provider: ICU4XDataProvider): ICU4XDecomposingNormalizer | never; + + /** + + * Construct a new ICU4XDecomposingNormalizer instance for NFKC + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/struct.DecomposingNormalizer.html#method.try_new_nfkd_unstable Rust documentation for `try_new_nfkd_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_nfkd(provider: ICU4XDataProvider): ICU4XDecomposingNormalizer | never; + + /** + + * Normalize a (potentially ill-formed) UTF8 string + + * Errors are mapped to REPLACEMENT CHARACTER + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/struct.DecomposingNormalizer.html#method.normalize_utf8 Rust documentation for `normalize_utf8`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + normalize(s: string): string | never; + + /** + + * Check if a (potentially ill-formed) UTF8 string is normalized + + * Errors are mapped to REPLACEMENT CHARACTER + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/struct.DecomposingNormalizer.html#method.is_normalized_utf8 Rust documentation for `is_normalized_utf8`} for more information. + */ + is_normalized(s: string): boolean; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDecomposingNormalizer.js b/third_party/rust/icu_capi/js/include/ICU4XDecomposingNormalizer.js new file mode 100644 index 000000000000..e1357dbb2a34 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDecomposingNormalizer.js @@ -0,0 +1,81 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XDecomposingNormalizer_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XDecomposingNormalizer_destroy(underlying); +}); + +export class ICU4XDecomposingNormalizer { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XDecomposingNormalizer_box_destroy_registry.register(this, underlying); + } + } + + static create_nfd(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDecomposingNormalizer_create_nfd(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XDecomposingNormalizer(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_nfkd(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDecomposingNormalizer_create_nfkd(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XDecomposingNormalizer(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + normalize(arg_s) { + const buf_arg_s = diplomatRuntime.DiplomatBuf.str(wasm, arg_s); + const diplomat_out = diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XDecomposingNormalizer_normalize(diplomat_receive_buffer, this.underlying, buf_arg_s.ptr, buf_arg_s.size, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + buf_arg_s.free(); + return diplomat_out; + } + + is_normalized(arg_s) { + const buf_arg_s = diplomatRuntime.DiplomatBuf.str(wasm, arg_s); + const diplomat_out = wasm.ICU4XDecomposingNormalizer_is_normalized(this.underlying, buf_arg_s.ptr, buf_arg_s.size); + buf_arg_s.free(); + return diplomat_out; + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDisplayNamesFallback.d.ts b/third_party/rust/icu_capi/js/include/ICU4XDisplayNamesFallback.d.ts new file mode 100644 index 000000000000..46f8452fb1ee --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDisplayNamesFallback.d.ts @@ -0,0 +1,13 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/displaynames/options/enum.Fallback.html Rust documentation for `Fallback`} for more information. + */ +export enum ICU4XDisplayNamesFallback { + /** + */ + Code = 'Code', + /** + */ + None = 'None', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XDisplayNamesFallback.js b/third_party/rust/icu_capi/js/include/ICU4XDisplayNamesFallback.js new file mode 100644 index 000000000000..aa7dc2d43fdd --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDisplayNamesFallback.js @@ -0,0 +1,17 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XDisplayNamesFallback_js_to_rust = { + "Code": 0, + "None": 1, +}; + +export const ICU4XDisplayNamesFallback_rust_to_js = { + [0]: "Code", + [1]: "None", +}; + +export const ICU4XDisplayNamesFallback = { + "Code": "Code", + "None": "None", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XDisplayNamesOptionsV1.d.ts b/third_party/rust/icu_capi/js/include/ICU4XDisplayNamesOptionsV1.d.ts new file mode 100644 index 000000000000..2f964d343977 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDisplayNamesOptionsV1.d.ts @@ -0,0 +1,13 @@ +import { ICU4XDisplayNamesFallback } from "./ICU4XDisplayNamesFallback"; +import { ICU4XDisplayNamesStyle } from "./ICU4XDisplayNamesStyle"; +import { ICU4XLanguageDisplay } from "./ICU4XLanguageDisplay"; + +/** + + * See the {@link https://docs.rs/icu/latest/icu/displaynames/options/struct.DisplayNamesOptions.html Rust documentation for `DisplayNamesOptions`} for more information. + */ +export class ICU4XDisplayNamesOptionsV1 { + style: ICU4XDisplayNamesStyle; + fallback: ICU4XDisplayNamesFallback; + language_display: ICU4XLanguageDisplay; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDisplayNamesOptionsV1.js b/third_party/rust/icu_capi/js/include/ICU4XDisplayNamesOptionsV1.js new file mode 100644 index 000000000000..eeaa0100b35a --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDisplayNamesOptionsV1.js @@ -0,0 +1,13 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XDisplayNamesFallback_js_to_rust, ICU4XDisplayNamesFallback_rust_to_js } from "./ICU4XDisplayNamesFallback.js" +import { ICU4XDisplayNamesStyle_js_to_rust, ICU4XDisplayNamesStyle_rust_to_js } from "./ICU4XDisplayNamesStyle.js" +import { ICU4XLanguageDisplay_js_to_rust, ICU4XLanguageDisplay_rust_to_js } from "./ICU4XLanguageDisplay.js" + +export class ICU4XDisplayNamesOptionsV1 { + constructor(underlying) { + this.style = ICU4XDisplayNamesStyle_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, underlying)]; + this.fallback = ICU4XDisplayNamesFallback_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, underlying + 4)]; + this.language_display = ICU4XLanguageDisplay_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, underlying + 8)]; + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XDisplayNamesStyle.d.ts b/third_party/rust/icu_capi/js/include/ICU4XDisplayNamesStyle.d.ts new file mode 100644 index 000000000000..5f92c6e96142 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDisplayNamesStyle.d.ts @@ -0,0 +1,22 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/displaynames/options/enum.Style.html Rust documentation for `Style`} for more information. + */ +export enum ICU4XDisplayNamesStyle { + /** + */ + Auto = 'Auto', + /** + */ + Narrow = 'Narrow', + /** + */ + Short = 'Short', + /** + */ + Long = 'Long', + /** + */ + Menu = 'Menu', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XDisplayNamesStyle.js b/third_party/rust/icu_capi/js/include/ICU4XDisplayNamesStyle.js new file mode 100644 index 000000000000..9bb346422941 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XDisplayNamesStyle.js @@ -0,0 +1,26 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XDisplayNamesStyle_js_to_rust = { + "Auto": 0, + "Narrow": 1, + "Short": 2, + "Long": 3, + "Menu": 4, +}; + +export const ICU4XDisplayNamesStyle_rust_to_js = { + [0]: "Auto", + [1]: "Narrow", + [2]: "Short", + [3]: "Long", + [4]: "Menu", +}; + +export const ICU4XDisplayNamesStyle = { + "Auto": "Auto", + "Narrow": "Narrow", + "Short": "Short", + "Long": "Long", + "Menu": "Menu", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XError.d.ts b/third_party/rust/icu_capi/js/include/ICU4XError.d.ts new file mode 100644 index 000000000000..ef00127f3660 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XError.d.ts @@ -0,0 +1,183 @@ + +/** + + * A common enum for errors that ICU4X may return, organized by API + + * The error names are stable and can be checked against as strings in the JS API + + * Additional information: {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.Error.html 1}, {@link https://docs.rs/icu/latest/icu/calendar/enum.CalendarError.html 2}, {@link https://docs.rs/icu/latest/icu/collator/enum.CollatorError.html 3}, {@link https://docs.rs/icu/latest/icu/datetime/enum.DateTimeError.html 4}, {@link https://docs.rs/icu/latest/icu/decimal/enum.DecimalError.html 5}, {@link https://docs.rs/icu/latest/icu/list/enum.ListError.html 6}, {@link https://docs.rs/icu/latest/icu/locid/enum.ParserError.html 7}, {@link https://docs.rs/icu/latest/icu/locid_transform/enum.LocaleTransformError.html 8}, {@link https://docs.rs/icu/latest/icu/normalizer/enum.NormalizerError.html 9}, {@link https://docs.rs/icu/latest/icu/plurals/enum.PluralsError.html 10}, {@link https://docs.rs/icu/latest/icu/properties/enum.PropertiesError.html 11}, {@link https://docs.rs/icu/latest/icu/provider/struct.DataError.html 12}, {@link https://docs.rs/icu/latest/icu/provider/enum.DataErrorKind.html 13}, {@link https://docs.rs/icu/latest/icu/segmenter/enum.SegmenterError.html 14}, {@link https://docs.rs/icu/latest/icu/timezone/enum.TimeZoneError.html 15} + */ +export enum ICU4XError { + /** + + * The error is not currently categorized as ICU4XError. Please file a bug + */ + UnknownError = 'UnknownError', + /** + + * An error arising from writing to a string Typically found when not enough space is allocated Most APIs that return a string may return this error + */ + WriteableError = 'WriteableError', + /** + */ + OutOfBoundsError = 'OutOfBoundsError', + /** + */ + DataMissingDataKeyError = 'DataMissingDataKeyError', + /** + */ + DataMissingVariantError = 'DataMissingVariantError', + /** + */ + DataMissingLocaleError = 'DataMissingLocaleError', + /** + */ + DataNeedsVariantError = 'DataNeedsVariantError', + /** + */ + DataNeedsLocaleError = 'DataNeedsLocaleError', + /** + */ + DataExtraneousLocaleError = 'DataExtraneousLocaleError', + /** + */ + DataFilteredResourceError = 'DataFilteredResourceError', + /** + */ + DataMismatchedTypeError = 'DataMismatchedTypeError', + /** + */ + DataMissingPayloadError = 'DataMissingPayloadError', + /** + */ + DataInvalidStateError = 'DataInvalidStateError', + /** + */ + DataCustomError = 'DataCustomError', + /** + */ + DataIoError = 'DataIoError', + /** + */ + DataUnavailableBufferFormatError = 'DataUnavailableBufferFormatError', + /** + */ + DataMismatchedAnyBufferError = 'DataMismatchedAnyBufferError', + /** + + * The subtag being requested was not set + */ + LocaleUndefinedSubtagError = 'LocaleUndefinedSubtagError', + /** + + * The locale or subtag string failed to parse + */ + LocaleParserLanguageError = 'LocaleParserLanguageError', + /** + */ + LocaleParserSubtagError = 'LocaleParserSubtagError', + /** + */ + LocaleParserExtensionError = 'LocaleParserExtensionError', + /** + + * Attempted to construct an invalid data struct + */ + DataStructValidityError = 'DataStructValidityError', + /** + */ + PropertyUnknownScriptIdError = 'PropertyUnknownScriptIdError', + /** + */ + PropertyUnknownGeneralCategoryGroupError = 'PropertyUnknownGeneralCategoryGroupError', + /** + */ + PropertyUnexpectedPropertyNameError = 'PropertyUnexpectedPropertyNameError', + /** + */ + FixedDecimalLimitError = 'FixedDecimalLimitError', + /** + */ + FixedDecimalSyntaxError = 'FixedDecimalSyntaxError', + /** + */ + PluralsParserError = 'PluralsParserError', + /** + */ + CalendarParseError = 'CalendarParseError', + /** + */ + CalendarOverflowError = 'CalendarOverflowError', + /** + */ + CalendarUnderflowError = 'CalendarUnderflowError', + /** + */ + CalendarOutOfRangeError = 'CalendarOutOfRangeError', + /** + */ + CalendarUnknownEraError = 'CalendarUnknownEraError', + /** + */ + CalendarUnknownMonthCodeError = 'CalendarUnknownMonthCodeError', + /** + */ + CalendarMissingInputError = 'CalendarMissingInputError', + /** + */ + CalendarUnknownKindError = 'CalendarUnknownKindError', + /** + */ + CalendarMissingError = 'CalendarMissingError', + /** + */ + DateTimePatternError = 'DateTimePatternError', + /** + */ + DateTimeMissingInputFieldError = 'DateTimeMissingInputFieldError', + /** + */ + DateTimeSkeletonError = 'DateTimeSkeletonError', + /** + */ + DateTimeUnsupportedFieldError = 'DateTimeUnsupportedFieldError', + /** + */ + DateTimeUnsupportedOptionsError = 'DateTimeUnsupportedOptionsError', + /** + */ + DateTimeMissingWeekdaySymbolError = 'DateTimeMissingWeekdaySymbolError', + /** + */ + DateTimeMissingMonthSymbolError = 'DateTimeMissingMonthSymbolError', + /** + */ + DateTimeFixedDecimalError = 'DateTimeFixedDecimalError', + /** + */ + DateTimeMismatchedCalendarError = 'DateTimeMismatchedCalendarError', + /** + */ + TinyStrTooLargeError = 'TinyStrTooLargeError', + /** + */ + TinyStrContainsNullError = 'TinyStrContainsNullError', + /** + */ + TinyStrNonAsciiError = 'TinyStrNonAsciiError', + /** + */ + TimeZoneOffsetOutOfBoundsError = 'TimeZoneOffsetOutOfBoundsError', + /** + */ + TimeZoneInvalidOffsetError = 'TimeZoneInvalidOffsetError', + /** + */ + TimeZoneMissingInputError = 'TimeZoneMissingInputError', + /** + */ + NormalizerFutureExtensionError = 'NormalizerFutureExtensionError', + /** + */ + NormalizerValidationError = 'NormalizerValidationError', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XError.js b/third_party/rust/icu_capi/js/include/ICU4XError.js new file mode 100644 index 000000000000..d64c46208f6e --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XError.js @@ -0,0 +1,173 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XError_js_to_rust = { + "UnknownError": 0, + "WriteableError": 1, + "OutOfBoundsError": 2, + "DataMissingDataKeyError": 256, + "DataMissingVariantError": 257, + "DataMissingLocaleError": 258, + "DataNeedsVariantError": 259, + "DataNeedsLocaleError": 260, + "DataExtraneousLocaleError": 261, + "DataFilteredResourceError": 262, + "DataMismatchedTypeError": 263, + "DataMissingPayloadError": 264, + "DataInvalidStateError": 265, + "DataCustomError": 266, + "DataIoError": 267, + "DataUnavailableBufferFormatError": 268, + "DataMismatchedAnyBufferError": 269, + "LocaleUndefinedSubtagError": 512, + "LocaleParserLanguageError": 513, + "LocaleParserSubtagError": 514, + "LocaleParserExtensionError": 515, + "DataStructValidityError": 768, + "PropertyUnknownScriptIdError": 1024, + "PropertyUnknownGeneralCategoryGroupError": 1025, + "PropertyUnexpectedPropertyNameError": 1026, + "FixedDecimalLimitError": 1280, + "FixedDecimalSyntaxError": 1281, + "PluralsParserError": 1536, + "CalendarParseError": 1792, + "CalendarOverflowError": 1793, + "CalendarUnderflowError": 1794, + "CalendarOutOfRangeError": 1795, + "CalendarUnknownEraError": 1796, + "CalendarUnknownMonthCodeError": 1797, + "CalendarMissingInputError": 1798, + "CalendarUnknownKindError": 1799, + "CalendarMissingError": 1800, + "DateTimePatternError": 2048, + "DateTimeMissingInputFieldError": 2049, + "DateTimeSkeletonError": 2050, + "DateTimeUnsupportedFieldError": 2051, + "DateTimeUnsupportedOptionsError": 2052, + "DateTimeMissingWeekdaySymbolError": 2053, + "DateTimeMissingMonthSymbolError": 2054, + "DateTimeFixedDecimalError": 2055, + "DateTimeMismatchedCalendarError": 2056, + "TinyStrTooLargeError": 2304, + "TinyStrContainsNullError": 2305, + "TinyStrNonAsciiError": 2306, + "TimeZoneOffsetOutOfBoundsError": 2560, + "TimeZoneInvalidOffsetError": 2561, + "TimeZoneMissingInputError": 2562, + "NormalizerFutureExtensionError": 2816, + "NormalizerValidationError": 2817, +}; + +export const ICU4XError_rust_to_js = { + [0]: "UnknownError", + [1]: "WriteableError", + [2]: "OutOfBoundsError", + [256]: "DataMissingDataKeyError", + [257]: "DataMissingVariantError", + [258]: "DataMissingLocaleError", + [259]: "DataNeedsVariantError", + [260]: "DataNeedsLocaleError", + [261]: "DataExtraneousLocaleError", + [262]: "DataFilteredResourceError", + [263]: "DataMismatchedTypeError", + [264]: "DataMissingPayloadError", + [265]: "DataInvalidStateError", + [266]: "DataCustomError", + [267]: "DataIoError", + [268]: "DataUnavailableBufferFormatError", + [269]: "DataMismatchedAnyBufferError", + [512]: "LocaleUndefinedSubtagError", + [513]: "LocaleParserLanguageError", + [514]: "LocaleParserSubtagError", + [515]: "LocaleParserExtensionError", + [768]: "DataStructValidityError", + [1024]: "PropertyUnknownScriptIdError", + [1025]: "PropertyUnknownGeneralCategoryGroupError", + [1026]: "PropertyUnexpectedPropertyNameError", + [1280]: "FixedDecimalLimitError", + [1281]: "FixedDecimalSyntaxError", + [1536]: "PluralsParserError", + [1792]: "CalendarParseError", + [1793]: "CalendarOverflowError", + [1794]: "CalendarUnderflowError", + [1795]: "CalendarOutOfRangeError", + [1796]: "CalendarUnknownEraError", + [1797]: "CalendarUnknownMonthCodeError", + [1798]: "CalendarMissingInputError", + [1799]: "CalendarUnknownKindError", + [1800]: "CalendarMissingError", + [2048]: "DateTimePatternError", + [2049]: "DateTimeMissingInputFieldError", + [2050]: "DateTimeSkeletonError", + [2051]: "DateTimeUnsupportedFieldError", + [2052]: "DateTimeUnsupportedOptionsError", + [2053]: "DateTimeMissingWeekdaySymbolError", + [2054]: "DateTimeMissingMonthSymbolError", + [2055]: "DateTimeFixedDecimalError", + [2056]: "DateTimeMismatchedCalendarError", + [2304]: "TinyStrTooLargeError", + [2305]: "TinyStrContainsNullError", + [2306]: "TinyStrNonAsciiError", + [2560]: "TimeZoneOffsetOutOfBoundsError", + [2561]: "TimeZoneInvalidOffsetError", + [2562]: "TimeZoneMissingInputError", + [2816]: "NormalizerFutureExtensionError", + [2817]: "NormalizerValidationError", +}; + +export const ICU4XError = { + "UnknownError": "UnknownError", + "WriteableError": "WriteableError", + "OutOfBoundsError": "OutOfBoundsError", + "DataMissingDataKeyError": "DataMissingDataKeyError", + "DataMissingVariantError": "DataMissingVariantError", + "DataMissingLocaleError": "DataMissingLocaleError", + "DataNeedsVariantError": "DataNeedsVariantError", + "DataNeedsLocaleError": "DataNeedsLocaleError", + "DataExtraneousLocaleError": "DataExtraneousLocaleError", + "DataFilteredResourceError": "DataFilteredResourceError", + "DataMismatchedTypeError": "DataMismatchedTypeError", + "DataMissingPayloadError": "DataMissingPayloadError", + "DataInvalidStateError": "DataInvalidStateError", + "DataCustomError": "DataCustomError", + "DataIoError": "DataIoError", + "DataUnavailableBufferFormatError": "DataUnavailableBufferFormatError", + "DataMismatchedAnyBufferError": "DataMismatchedAnyBufferError", + "LocaleUndefinedSubtagError": "LocaleUndefinedSubtagError", + "LocaleParserLanguageError": "LocaleParserLanguageError", + "LocaleParserSubtagError": "LocaleParserSubtagError", + "LocaleParserExtensionError": "LocaleParserExtensionError", + "DataStructValidityError": "DataStructValidityError", + "PropertyUnknownScriptIdError": "PropertyUnknownScriptIdError", + "PropertyUnknownGeneralCategoryGroupError": "PropertyUnknownGeneralCategoryGroupError", + "PropertyUnexpectedPropertyNameError": "PropertyUnexpectedPropertyNameError", + "FixedDecimalLimitError": "FixedDecimalLimitError", + "FixedDecimalSyntaxError": "FixedDecimalSyntaxError", + "PluralsParserError": "PluralsParserError", + "CalendarParseError": "CalendarParseError", + "CalendarOverflowError": "CalendarOverflowError", + "CalendarUnderflowError": "CalendarUnderflowError", + "CalendarOutOfRangeError": "CalendarOutOfRangeError", + "CalendarUnknownEraError": "CalendarUnknownEraError", + "CalendarUnknownMonthCodeError": "CalendarUnknownMonthCodeError", + "CalendarMissingInputError": "CalendarMissingInputError", + "CalendarUnknownKindError": "CalendarUnknownKindError", + "CalendarMissingError": "CalendarMissingError", + "DateTimePatternError": "DateTimePatternError", + "DateTimeMissingInputFieldError": "DateTimeMissingInputFieldError", + "DateTimeSkeletonError": "DateTimeSkeletonError", + "DateTimeUnsupportedFieldError": "DateTimeUnsupportedFieldError", + "DateTimeUnsupportedOptionsError": "DateTimeUnsupportedOptionsError", + "DateTimeMissingWeekdaySymbolError": "DateTimeMissingWeekdaySymbolError", + "DateTimeMissingMonthSymbolError": "DateTimeMissingMonthSymbolError", + "DateTimeFixedDecimalError": "DateTimeFixedDecimalError", + "DateTimeMismatchedCalendarError": "DateTimeMismatchedCalendarError", + "TinyStrTooLargeError": "TinyStrTooLargeError", + "TinyStrContainsNullError": "TinyStrContainsNullError", + "TinyStrNonAsciiError": "TinyStrNonAsciiError", + "TimeZoneOffsetOutOfBoundsError": "TimeZoneOffsetOutOfBoundsError", + "TimeZoneInvalidOffsetError": "TimeZoneInvalidOffsetError", + "TimeZoneMissingInputError": "TimeZoneMissingInputError", + "NormalizerFutureExtensionError": "NormalizerFutureExtensionError", + "NormalizerValidationError": "NormalizerValidationError", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XFixedDecimal.d.ts b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimal.d.ts new file mode 100644 index 000000000000..cf524c2601c7 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimal.d.ts @@ -0,0 +1,272 @@ +import { u8, i16, i32, u32, i64, u64, f64 } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { ICU4XError } from "./ICU4XError"; +import { ICU4XFixedDecimalSign } from "./ICU4XFixedDecimalSign"; +import { ICU4XFixedDecimalSignDisplay } from "./ICU4XFixedDecimalSignDisplay"; + +/** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html Rust documentation for `FixedDecimal`} for more information. + */ +export class ICU4XFixedDecimal { + + /** + + * Construct an {@link ICU4XFixedDecimal `ICU4XFixedDecimal`} from an integer. + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html Rust documentation for `FixedDecimal`} for more information. + */ + static create_from_i32(v: i32): ICU4XFixedDecimal; + + /** + + * Construct an {@link ICU4XFixedDecimal `ICU4XFixedDecimal`} from an integer. + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html Rust documentation for `FixedDecimal`} for more information. + */ + static create_from_u32(v: u32): ICU4XFixedDecimal; + + /** + + * Construct an {@link ICU4XFixedDecimal `ICU4XFixedDecimal`} from an integer. + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html Rust documentation for `FixedDecimal`} for more information. + */ + static create_from_i64(v: i64): ICU4XFixedDecimal; + + /** + + * Construct an {@link ICU4XFixedDecimal `ICU4XFixedDecimal`} from an integer. + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html Rust documentation for `FixedDecimal`} for more information. + */ + static create_from_u64(v: u64): ICU4XFixedDecimal; + + /** + + * Construct an {@link ICU4XFixedDecimal `ICU4XFixedDecimal`} from an integer-valued float + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.try_from_f64 Rust documentation for `try_from_f64`} for more information. + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.DoublePrecision.html Rust documentation for `DoublePrecision`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_from_f64_with_integer_precision(f: f64): ICU4XFixedDecimal | never; + + /** + + * Construct an {@link ICU4XFixedDecimal `ICU4XFixedDecimal`} from an float, with a given power of 10 for the lower magnitude + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.try_from_f64 Rust documentation for `try_from_f64`} for more information. + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.DoublePrecision.html Rust documentation for `DoublePrecision`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_from_f64_with_lower_magnitude(f: f64, magnitude: i16): ICU4XFixedDecimal | never; + + /** + + * Construct an {@link ICU4XFixedDecimal `ICU4XFixedDecimal`} from an float, for a given number of significant digits + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.try_from_f64 Rust documentation for `try_from_f64`} for more information. + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.DoublePrecision.html Rust documentation for `DoublePrecision`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_from_f64_with_significant_digits(f: f64, digits: u8): ICU4XFixedDecimal | never; + + /** + + * Construct an {@link ICU4XFixedDecimal `ICU4XFixedDecimal`} from an float, with enough digits to recover the original floating point in IEEE 754 without needing trailing zeros + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.try_from_f64 Rust documentation for `try_from_f64`} for more information. + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.DoublePrecision.html Rust documentation for `DoublePrecision`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_from_f64_with_floating_precision(f: f64): ICU4XFixedDecimal | never; + + /** + + * Construct an {@link ICU4XFixedDecimal `ICU4XFixedDecimal`} from a string. + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.from_str Rust documentation for `from_str`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_from_string(v: string): ICU4XFixedDecimal | never; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.digit_at Rust documentation for `digit_at`} for more information. + */ + digit_at(magnitude: i16): u8; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.magnitude_range Rust documentation for `magnitude_range`} for more information. + */ + magnitude_start(): i16; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.magnitude_range Rust documentation for `magnitude_range`} for more information. + */ + magnitude_end(): i16; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.nonzero_magnitude_start Rust documentation for `nonzero_magnitude_start`} for more information. + */ + nonzero_magnitude_start(): i16; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.nonzero_magnitude_end Rust documentation for `nonzero_magnitude_end`} for more information. + */ + nonzero_magnitude_end(): i16; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.is_zero Rust documentation for `is_zero`} for more information. + */ + is_zero(): boolean; + + /** + + * Multiply the {@link ICU4XFixedDecimal `ICU4XFixedDecimal`} by a given power of ten. + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.multiply_pow10 Rust documentation for `multiply_pow10`} for more information. + */ + multiply_pow10(power: i16): void; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.sign Rust documentation for `sign`} for more information. + */ + sign(): ICU4XFixedDecimalSign; + + /** + + * Set the sign of the {@link ICU4XFixedDecimal `ICU4XFixedDecimal`}. + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.set_sign Rust documentation for `set_sign`} for more information. + */ + set_sign(sign: ICU4XFixedDecimalSign): void; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.apply_sign_display Rust documentation for `apply_sign_display`} for more information. + */ + apply_sign_display(sign_display: ICU4XFixedDecimalSignDisplay): void; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.trim_start Rust documentation for `trim_start`} for more information. + */ + trim_start(): void; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.trim_end Rust documentation for `trim_end`} for more information. + */ + trim_end(): void; + + /** + + * Zero-pad the {@link ICU4XFixedDecimal `ICU4XFixedDecimal`} on the left to a particular position + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.pad_start Rust documentation for `pad_start`} for more information. + */ + pad_start(position: i16): void; + + /** + + * Zero-pad the {@link ICU4XFixedDecimal `ICU4XFixedDecimal`} on the right to a particular position + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.pad_end Rust documentation for `pad_end`} for more information. + */ + pad_end(position: i16): void; + + /** + + * Truncate the {@link ICU4XFixedDecimal `ICU4XFixedDecimal`} on the left to a particular position, deleting digits if necessary. This is useful for, e.g. abbreviating years ("2022" -> "22") + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.set_max_position Rust documentation for `set_max_position`} for more information. + */ + set_max_position(position: i16): void; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.trunc Rust documentation for `trunc`} for more information. + */ + trunc(position: i16): void; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_trunc Rust documentation for `half_trunc`} for more information. + */ + half_trunc(position: i16): void; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.expand Rust documentation for `expand`} for more information. + */ + expand(position: i16): void; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_expand Rust documentation for `half_expand`} for more information. + */ + half_expand(position: i16): void; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.ceil Rust documentation for `ceil`} for more information. + */ + ceil(position: i16): void; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_ceil Rust documentation for `half_ceil`} for more information. + */ + half_ceil(position: i16): void; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.floor Rust documentation for `floor`} for more information. + */ + floor(position: i16): void; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_floor Rust documentation for `half_floor`} for more information. + */ + half_floor(position: i16): void; + + /** + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.half_even Rust documentation for `half_even`} for more information. + */ + half_even(position: i16): void; + + /** + + * Concatenates `other` to the end of `self`. + + * If successful, `other` will be set to 0 and a successful status is returned. + + * If not successful, `other` will be unchanged and an error is returned. + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.concatenate_end Rust documentation for `concatenate_end`} for more information. + * @throws {@link FFIError} + */ + concatenate_end(other: ICU4XFixedDecimal): void | never; + + /** + + * Format the {@link ICU4XFixedDecimal `ICU4XFixedDecimal`} as a string. + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/struct.FixedDecimal.html#method.write_to Rust documentation for `write_to`} for more information. + */ + to_string(): string; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XFixedDecimal.js b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimal.js new file mode 100644 index 000000000000..e517bc9f48cb --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimal.js @@ -0,0 +1,235 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XFixedDecimalSign_js_to_rust, ICU4XFixedDecimalSign_rust_to_js } from "./ICU4XFixedDecimalSign.js" +import { ICU4XFixedDecimalSignDisplay_js_to_rust, ICU4XFixedDecimalSignDisplay_rust_to_js } from "./ICU4XFixedDecimalSignDisplay.js" + +const ICU4XFixedDecimal_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XFixedDecimal_destroy(underlying); +}); + +export class ICU4XFixedDecimal { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XFixedDecimal_box_destroy_registry.register(this, underlying); + } + } + + static create_from_i32(arg_v) { + return new ICU4XFixedDecimal(wasm.ICU4XFixedDecimal_create_from_i32(arg_v), true, []); + } + + static create_from_u32(arg_v) { + return new ICU4XFixedDecimal(wasm.ICU4XFixedDecimal_create_from_u32(arg_v), true, []); + } + + static create_from_i64(arg_v) { + return new ICU4XFixedDecimal(wasm.ICU4XFixedDecimal_create_from_i64(arg_v), true, []); + } + + static create_from_u64(arg_v) { + return new ICU4XFixedDecimal(wasm.ICU4XFixedDecimal_create_from_u64(arg_v), true, []); + } + + static create_from_f64_with_integer_precision(arg_f) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XFixedDecimal_create_from_f64_with_integer_precision(diplomat_receive_buffer, arg_f); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XFixedDecimal(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_from_f64_with_lower_magnitude(arg_f, arg_magnitude) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XFixedDecimal_create_from_f64_with_lower_magnitude(diplomat_receive_buffer, arg_f, arg_magnitude); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XFixedDecimal(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_from_f64_with_significant_digits(arg_f, arg_digits) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XFixedDecimal_create_from_f64_with_significant_digits(diplomat_receive_buffer, arg_f, arg_digits); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XFixedDecimal(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_from_f64_with_floating_precision(arg_f) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XFixedDecimal_create_from_f64_with_floating_precision(diplomat_receive_buffer, arg_f); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XFixedDecimal(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_from_string(arg_v) { + const buf_arg_v = diplomatRuntime.DiplomatBuf.str(wasm, arg_v); + const diplomat_out = (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XFixedDecimal_create_from_string(diplomat_receive_buffer, buf_arg_v.ptr, buf_arg_v.size); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XFixedDecimal(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + buf_arg_v.free(); + return diplomat_out; + } + + digit_at(arg_magnitude) { + return wasm.ICU4XFixedDecimal_digit_at(this.underlying, arg_magnitude); + } + + magnitude_start() { + return wasm.ICU4XFixedDecimal_magnitude_start(this.underlying); + } + + magnitude_end() { + return wasm.ICU4XFixedDecimal_magnitude_end(this.underlying); + } + + nonzero_magnitude_start() { + return wasm.ICU4XFixedDecimal_nonzero_magnitude_start(this.underlying); + } + + nonzero_magnitude_end() { + return wasm.ICU4XFixedDecimal_nonzero_magnitude_end(this.underlying); + } + + is_zero() { + return wasm.ICU4XFixedDecimal_is_zero(this.underlying); + } + + multiply_pow10(arg_power) { + wasm.ICU4XFixedDecimal_multiply_pow10(this.underlying, arg_power); + } + + sign() { + return ICU4XFixedDecimalSign_rust_to_js[wasm.ICU4XFixedDecimal_sign(this.underlying)]; + } + + set_sign(arg_sign) { + wasm.ICU4XFixedDecimal_set_sign(this.underlying, ICU4XFixedDecimalSign_js_to_rust[arg_sign]); + } + + apply_sign_display(arg_sign_display) { + wasm.ICU4XFixedDecimal_apply_sign_display(this.underlying, ICU4XFixedDecimalSignDisplay_js_to_rust[arg_sign_display]); + } + + trim_start() { + wasm.ICU4XFixedDecimal_trim_start(this.underlying); + } + + trim_end() { + wasm.ICU4XFixedDecimal_trim_end(this.underlying); + } + + pad_start(arg_position) { + wasm.ICU4XFixedDecimal_pad_start(this.underlying, arg_position); + } + + pad_end(arg_position) { + wasm.ICU4XFixedDecimal_pad_end(this.underlying, arg_position); + } + + set_max_position(arg_position) { + wasm.ICU4XFixedDecimal_set_max_position(this.underlying, arg_position); + } + + trunc(arg_position) { + wasm.ICU4XFixedDecimal_trunc(this.underlying, arg_position); + } + + half_trunc(arg_position) { + wasm.ICU4XFixedDecimal_half_trunc(this.underlying, arg_position); + } + + expand(arg_position) { + wasm.ICU4XFixedDecimal_expand(this.underlying, arg_position); + } + + half_expand(arg_position) { + wasm.ICU4XFixedDecimal_half_expand(this.underlying, arg_position); + } + + ceil(arg_position) { + wasm.ICU4XFixedDecimal_ceil(this.underlying, arg_position); + } + + half_ceil(arg_position) { + wasm.ICU4XFixedDecimal_half_ceil(this.underlying, arg_position); + } + + floor(arg_position) { + wasm.ICU4XFixedDecimal_floor(this.underlying, arg_position); + } + + half_floor(arg_position) { + wasm.ICU4XFixedDecimal_half_floor(this.underlying, arg_position); + } + + half_even(arg_position) { + wasm.ICU4XFixedDecimal_half_even(this.underlying, arg_position); + } + + concatenate_end(arg_other) { + return (() => { + const is_ok = wasm.ICU4XFixedDecimal_concatenate_end(this.underlying, arg_other.underlying) == 1; + if (!is_ok) { + throw new diplomatRuntime.FFIError(undefined); + } + })(); + } + + to_string() { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return wasm.ICU4XFixedDecimal_to_string(this.underlying, writeable); + }); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalFormatter.d.ts b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalFormatter.d.ts new file mode 100644 index 000000000000..6c78c7f66d4c --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalFormatter.d.ts @@ -0,0 +1,43 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XDataStruct } from "./ICU4XDataStruct"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XFixedDecimal } from "./ICU4XFixedDecimal"; +import { ICU4XFixedDecimalGroupingStrategy } from "./ICU4XFixedDecimalGroupingStrategy"; +import { ICU4XLocale } from "./ICU4XLocale"; + +/** + + * An ICU4X Fixed Decimal Format object, capable of formatting a {@link ICU4XFixedDecimal `ICU4XFixedDecimal`} as a string. + + * See the {@link https://docs.rs/icu/latest/icu/decimal/struct.FixedDecimalFormatter.html Rust documentation for `FixedDecimalFormatter`} for more information. + */ +export class ICU4XFixedDecimalFormatter { + + /** + + * Creates a new {@link ICU4XFixedDecimalFormatter `ICU4XFixedDecimalFormatter`} from locale data. + + * See the {@link https://docs.rs/icu/latest/icu/decimal/struct.FixedDecimalFormatter.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_with_grouping_strategy(provider: ICU4XDataProvider, locale: ICU4XLocale, grouping_strategy: ICU4XFixedDecimalGroupingStrategy): ICU4XFixedDecimalFormatter | never; + + /** + + * Creates a new {@link ICU4XFixedDecimalFormatter `ICU4XFixedDecimalFormatter`} from preconstructed locale data in the form of an {@link ICU4XDataStruct `ICU4XDataStruct`} constructed from `ICU4XDataStruct::create_decimal_symbols()`. + + * The contents of the data struct will be consumed: if you wish to use the struct again it will have to be reconstructed. Passing a consumed struct to this method will return an error. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_with_decimal_symbols_v1(data_struct: ICU4XDataStruct, grouping_strategy: ICU4XFixedDecimalGroupingStrategy): ICU4XFixedDecimalFormatter | never; + + /** + + * Formats a {@link ICU4XFixedDecimal `ICU4XFixedDecimal`} to a string. + + * See the {@link https://docs.rs/icu/latest/icu/decimal/struct.FixedDecimalFormatter.html#method.format Rust documentation for `format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + format(value: ICU4XFixedDecimal): string | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalFormatter.js b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalFormatter.js new file mode 100644 index 000000000000..03cff035b1e4 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalFormatter.js @@ -0,0 +1,72 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XFixedDecimalGroupingStrategy_js_to_rust, ICU4XFixedDecimalGroupingStrategy_rust_to_js } from "./ICU4XFixedDecimalGroupingStrategy.js" + +const ICU4XFixedDecimalFormatter_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XFixedDecimalFormatter_destroy(underlying); +}); + +export class ICU4XFixedDecimalFormatter { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XFixedDecimalFormatter_box_destroy_registry.register(this, underlying); + } + } + + static create_with_grouping_strategy(arg_provider, arg_locale, arg_grouping_strategy) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XFixedDecimalFormatter_create_with_grouping_strategy(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying, ICU4XFixedDecimalGroupingStrategy_js_to_rust[arg_grouping_strategy]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XFixedDecimalFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_with_decimal_symbols_v1(arg_data_struct, arg_grouping_strategy) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XFixedDecimalFormatter_create_with_decimal_symbols_v1(diplomat_receive_buffer, arg_data_struct.underlying, ICU4XFixedDecimalGroupingStrategy_js_to_rust[arg_grouping_strategy]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XFixedDecimalFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + format(arg_value) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XFixedDecimalFormatter_format(diplomat_receive_buffer, this.underlying, arg_value.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalGroupingStrategy.d.ts b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalGroupingStrategy.d.ts new file mode 100644 index 000000000000..6a615f93a527 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalGroupingStrategy.d.ts @@ -0,0 +1,19 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/decimal/options/enum.GroupingStrategy.html Rust documentation for `GroupingStrategy`} for more information. + */ +export enum ICU4XFixedDecimalGroupingStrategy { + /** + */ + Auto = 'Auto', + /** + */ + Never = 'Never', + /** + */ + Always = 'Always', + /** + */ + Min2 = 'Min2', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalGroupingStrategy.js b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalGroupingStrategy.js new file mode 100644 index 000000000000..8272ee599d63 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalGroupingStrategy.js @@ -0,0 +1,23 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XFixedDecimalGroupingStrategy_js_to_rust = { + "Auto": 0, + "Never": 1, + "Always": 2, + "Min2": 3, +}; + +export const ICU4XFixedDecimalGroupingStrategy_rust_to_js = { + [0]: "Auto", + [1]: "Never", + [2]: "Always", + [3]: "Min2", +}; + +export const ICU4XFixedDecimalGroupingStrategy = { + "Auto": "Auto", + "Never": "Never", + "Always": "Always", + "Min2": "Min2", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalSign.d.ts b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalSign.d.ts new file mode 100644 index 000000000000..ec777aa3ebaf --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalSign.d.ts @@ -0,0 +1,24 @@ + +/** + + * The sign of a FixedDecimal, as shown in formatting. + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.Sign.html Rust documentation for `Sign`} for more information. + */ +export enum ICU4XFixedDecimalSign { + /** + + * No sign (implicitly positive, e.g., 1729). + */ + None = 'None', + /** + + * A negative sign, e.g., -1729. + */ + Negative = 'Negative', + /** + + * An explicit positive sign, e.g., +1729. + */ + Positive = 'Positive', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalSign.js b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalSign.js new file mode 100644 index 000000000000..407cf14d3397 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalSign.js @@ -0,0 +1,20 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XFixedDecimalSign_js_to_rust = { + "None": 0, + "Negative": 1, + "Positive": 2, +}; + +export const ICU4XFixedDecimalSign_rust_to_js = { + [0]: "None", + [1]: "Negative", + [2]: "Positive", +}; + +export const ICU4XFixedDecimalSign = { + "None": "None", + "Negative": "Negative", + "Positive": "Positive", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalSignDisplay.d.ts b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalSignDisplay.d.ts new file mode 100644 index 000000000000..d3302911a170 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalSignDisplay.d.ts @@ -0,0 +1,24 @@ + +/** + + * ECMA-402 compatible sign display preference. + + * See the {@link https://docs.rs/fixed_decimal/latest/fixed_decimal/enum.SignDisplay.html Rust documentation for `SignDisplay`} for more information. + */ +export enum ICU4XFixedDecimalSignDisplay { + /** + */ + Auto = 'Auto', + /** + */ + Never = 'Never', + /** + */ + Always = 'Always', + /** + */ + ExceptZero = 'ExceptZero', + /** + */ + Negative = 'Negative', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalSignDisplay.js b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalSignDisplay.js new file mode 100644 index 000000000000..21bd180800b4 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XFixedDecimalSignDisplay.js @@ -0,0 +1,26 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XFixedDecimalSignDisplay_js_to_rust = { + "Auto": 0, + "Never": 1, + "Always": 2, + "ExceptZero": 3, + "Negative": 4, +}; + +export const ICU4XFixedDecimalSignDisplay_rust_to_js = { + [0]: "Auto", + [1]: "Never", + [2]: "Always", + [3]: "ExceptZero", + [4]: "Negative", +}; + +export const ICU4XFixedDecimalSignDisplay = { + "Auto": "Auto", + "Never": "Never", + "Always": "Always", + "ExceptZero": "ExceptZero", + "Negative": "Negative", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XGeneralCategoryNameToMaskMapper.d.ts b/third_party/rust/icu_capi/js/include/ICU4XGeneralCategoryNameToMaskMapper.d.ts new file mode 100644 index 000000000000..b5cfef9cab95 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XGeneralCategoryNameToMaskMapper.d.ts @@ -0,0 +1,38 @@ +import { u32 } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; + +/** + + * A type capable of looking up General Category mask values from a string name. + + * See the {@link https://docs.rs/icu/latest/icu/properties/struct.GeneralCategoryGroup.html#method.get_name_to_enum_mapper Rust documentation for `get_name_to_enum_mapper`} for more information. + + * See the {@link https://docs.rs/icu/latest/icu/properties/names/struct.PropertyValueNameToEnumMapper.html Rust documentation for `PropertyValueNameToEnumMapper`} for more information. + */ +export class ICU4XGeneralCategoryNameToMaskMapper { + + /** + + * Get the mask value matching the given name, using strict matching + + * Returns 0 if the name is unknown for this property + */ + get_strict(name: string): u32; + + /** + + * Get the mask value matching the given name, using loose matching + + * Returns 0 if the name is unknown for this property + */ + get_loose(name: string): u32; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/struct.GeneralCategoryGroup.html#method.get_name_to_enum_mapper Rust documentation for `get_name_to_enum_mapper`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load(provider: ICU4XDataProvider): ICU4XGeneralCategoryNameToMaskMapper | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XGeneralCategoryNameToMaskMapper.js b/third_party/rust/icu_capi/js/include/ICU4XGeneralCategoryNameToMaskMapper.js new file mode 100644 index 000000000000..4f3319123a9c --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XGeneralCategoryNameToMaskMapper.js @@ -0,0 +1,49 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XGeneralCategoryNameToMaskMapper_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XGeneralCategoryNameToMaskMapper_destroy(underlying); +}); + +export class ICU4XGeneralCategoryNameToMaskMapper { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XGeneralCategoryNameToMaskMapper_box_destroy_registry.register(this, underlying); + } + } + + get_strict(arg_name) { + const buf_arg_name = diplomatRuntime.DiplomatBuf.str(wasm, arg_name); + const diplomat_out = wasm.ICU4XGeneralCategoryNameToMaskMapper_get_strict(this.underlying, buf_arg_name.ptr, buf_arg_name.size); + buf_arg_name.free(); + return diplomat_out; + } + + get_loose(arg_name) { + const buf_arg_name = diplomatRuntime.DiplomatBuf.str(wasm, arg_name); + const diplomat_out = wasm.ICU4XGeneralCategoryNameToMaskMapper_get_loose(this.underlying, buf_arg_name.ptr, buf_arg_name.size); + buf_arg_name.free(); + return diplomat_out; + } + + static load(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XGeneralCategoryNameToMaskMapper_load(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XGeneralCategoryNameToMaskMapper(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorLatin1.d.ts b/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorLatin1.d.ts new file mode 100644 index 000000000000..5022d4baa70f --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorLatin1.d.ts @@ -0,0 +1,16 @@ +import { i32 } from "./diplomat-runtime" + +/** + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterBreakIterator.html Rust documentation for `GraphemeClusterBreakIterator`} for more information. + */ +export class ICU4XGraphemeClusterBreakIteratorLatin1 { + + /** + + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is out of range of a 32-bit signed integer. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterBreakIterator.html#method.next Rust documentation for `next`} for more information. + */ + next(): i32; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorLatin1.js b/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorLatin1.js new file mode 100644 index 000000000000..a50df59feb44 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorLatin1.js @@ -0,0 +1,21 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +const ICU4XGraphemeClusterBreakIteratorLatin1_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XGraphemeClusterBreakIteratorLatin1_destroy(underlying); +}); + +export class ICU4XGraphemeClusterBreakIteratorLatin1 { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XGraphemeClusterBreakIteratorLatin1_box_destroy_registry.register(this, underlying); + } + } + + next() { + return wasm.ICU4XGraphemeClusterBreakIteratorLatin1_next(this.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorUtf16.d.ts b/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorUtf16.d.ts new file mode 100644 index 000000000000..95d21da695c9 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorUtf16.d.ts @@ -0,0 +1,16 @@ +import { i32 } from "./diplomat-runtime" + +/** + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterBreakIterator.html Rust documentation for `GraphemeClusterBreakIterator`} for more information. + */ +export class ICU4XGraphemeClusterBreakIteratorUtf16 { + + /** + + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is out of range of a 32-bit signed integer. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterBreakIterator.html#method.next Rust documentation for `next`} for more information. + */ + next(): i32; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorUtf16.js b/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorUtf16.js new file mode 100644 index 000000000000..cc997daa057e --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorUtf16.js @@ -0,0 +1,21 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +const ICU4XGraphemeClusterBreakIteratorUtf16_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XGraphemeClusterBreakIteratorUtf16_destroy(underlying); +}); + +export class ICU4XGraphemeClusterBreakIteratorUtf16 { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XGraphemeClusterBreakIteratorUtf16_box_destroy_registry.register(this, underlying); + } + } + + next() { + return wasm.ICU4XGraphemeClusterBreakIteratorUtf16_next(this.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorUtf8.d.ts b/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorUtf8.d.ts new file mode 100644 index 000000000000..cb78596153eb --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorUtf8.d.ts @@ -0,0 +1,16 @@ +import { i32 } from "./diplomat-runtime" + +/** + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterBreakIterator.html Rust documentation for `GraphemeClusterBreakIterator`} for more information. + */ +export class ICU4XGraphemeClusterBreakIteratorUtf8 { + + /** + + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is out of range of a 32-bit signed integer. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterBreakIterator.html#method.next Rust documentation for `next`} for more information. + */ + next(): i32; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorUtf8.js b/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorUtf8.js new file mode 100644 index 000000000000..2a16170dfe0c --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterBreakIteratorUtf8.js @@ -0,0 +1,21 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +const ICU4XGraphemeClusterBreakIteratorUtf8_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XGraphemeClusterBreakIteratorUtf8_destroy(underlying); +}); + +export class ICU4XGraphemeClusterBreakIteratorUtf8 { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XGraphemeClusterBreakIteratorUtf8_box_destroy_registry.register(this, underlying); + } + } + + next() { + return wasm.ICU4XGraphemeClusterBreakIteratorUtf8_next(this.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterSegmenter.d.ts b/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterSegmenter.d.ts new file mode 100644 index 000000000000..173955f4e41e --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterSegmenter.d.ts @@ -0,0 +1,48 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XGraphemeClusterBreakIteratorLatin1 } from "./ICU4XGraphemeClusterBreakIteratorLatin1"; +import { ICU4XGraphemeClusterBreakIteratorUtf16 } from "./ICU4XGraphemeClusterBreakIteratorUtf16"; +import { ICU4XGraphemeClusterBreakIteratorUtf8 } from "./ICU4XGraphemeClusterBreakIteratorUtf8"; + +/** + + * An ICU4X grapheme-cluster-break segmenter, capable of finding grapheme cluster breakpoints in strings. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterSegmenter.html Rust documentation for `GraphemeClusterSegmenter`} for more information. + */ +export class ICU4XGraphemeClusterSegmenter { + + /** + + * Construct an {@link ICU4XGraphemeClusterSegmenter `ICU4XGraphemeClusterSegmenter`}. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterSegmenter.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create(provider: ICU4XDataProvider): ICU4XGraphemeClusterSegmenter | never; + + /** + + * Segments a (potentially ill-formed) UTF-8 string. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterSegmenter.html#method.segment_utf8 Rust documentation for `segment_utf8`} for more information. + */ + segment_utf8(input: string): ICU4XGraphemeClusterBreakIteratorUtf8; + + /** + + * Segments a UTF-16 string. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterSegmenter.html#method.segment_utf16 Rust documentation for `segment_utf16`} for more information. + */ + segment_utf16(input: Uint16Array): ICU4XGraphemeClusterBreakIteratorUtf16; + + /** + + * Segments a Latin-1 string. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.GraphemeClusterSegmenter.html#method.segment_latin1 Rust documentation for `segment_latin1`} for more information. + */ + segment_latin1(input: Uint8Array): ICU4XGraphemeClusterBreakIteratorLatin1; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterSegmenter.js b/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterSegmenter.js new file mode 100644 index 000000000000..91dfea1ba51a --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XGraphemeClusterSegmenter.js @@ -0,0 +1,53 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XGraphemeClusterBreakIteratorLatin1 } from "./ICU4XGraphemeClusterBreakIteratorLatin1.js" +import { ICU4XGraphemeClusterBreakIteratorUtf16 } from "./ICU4XGraphemeClusterBreakIteratorUtf16.js" +import { ICU4XGraphemeClusterBreakIteratorUtf8 } from "./ICU4XGraphemeClusterBreakIteratorUtf8.js" + +const ICU4XGraphemeClusterSegmenter_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XGraphemeClusterSegmenter_destroy(underlying); +}); + +export class ICU4XGraphemeClusterSegmenter { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XGraphemeClusterSegmenter_box_destroy_registry.register(this, underlying); + } + } + + static create(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XGraphemeClusterSegmenter_create(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XGraphemeClusterSegmenter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + segment_utf8(arg_input) { + const buf_arg_input = diplomatRuntime.DiplomatBuf.str(wasm, arg_input); + return new ICU4XGraphemeClusterBreakIteratorUtf8(wasm.ICU4XGraphemeClusterSegmenter_segment_utf8(this.underlying, buf_arg_input.ptr, buf_arg_input.size), true, [this, buf_arg_input]); + } + + segment_utf16(arg_input) { + const buf_arg_input = diplomatRuntime.DiplomatBuf.slice(wasm, arg_input, 2); + return new ICU4XGraphemeClusterBreakIteratorUtf16(wasm.ICU4XGraphemeClusterSegmenter_segment_utf16(this.underlying, buf_arg_input.ptr, buf_arg_input.size), true, [this, buf_arg_input]); + } + + segment_latin1(arg_input) { + const buf_arg_input = diplomatRuntime.DiplomatBuf.slice(wasm, arg_input, 1); + return new ICU4XGraphemeClusterBreakIteratorLatin1(wasm.ICU4XGraphemeClusterSegmenter_segment_latin1(this.underlying, buf_arg_input.ptr, buf_arg_input.size), true, [this, buf_arg_input]); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XGregorianDateFormatter.d.ts b/third_party/rust/icu_capi/js/include/ICU4XGregorianDateFormatter.d.ts new file mode 100644 index 000000000000..c5f205761413 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XGregorianDateFormatter.d.ts @@ -0,0 +1,43 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XDateLength } from "./ICU4XDateLength"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XIsoDate } from "./ICU4XIsoDate"; +import { ICU4XIsoDateTime } from "./ICU4XIsoDateTime"; +import { ICU4XLocale } from "./ICU4XLocale"; + +/** + + * An ICU4X TypedDateFormatter object capable of formatting a {@link ICU4XIsoDateTime `ICU4XIsoDateTime`} as a string, using the Gregorian Calendar. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.TypedDateFormatter.html Rust documentation for `TypedDateFormatter`} for more information. + */ +export class ICU4XGregorianDateFormatter { + + /** + + * Creates a new {@link ICU4XGregorianDateFormatter `ICU4XGregorianDateFormatter`} from locale data. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.TypedDateFormatter.html#method.try_new_with_length_unstable Rust documentation for `try_new_with_length_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_with_length(provider: ICU4XDataProvider, locale: ICU4XLocale, length: ICU4XDateLength): ICU4XGregorianDateFormatter | never; + + /** + + * Formats a {@link ICU4XIsoDate `ICU4XIsoDate`} to a string. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.TypedDateFormatter.html#method.format Rust documentation for `format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + format_iso_date(value: ICU4XIsoDate): string | never; + + /** + + * Formats a {@link ICU4XIsoDateTime `ICU4XIsoDateTime`} to a string. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.TypedDateFormatter.html#method.format Rust documentation for `format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + format_iso_datetime(value: ICU4XIsoDateTime): string | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XGregorianDateFormatter.js b/third_party/rust/icu_capi/js/include/ICU4XGregorianDateFormatter.js new file mode 100644 index 000000000000..c9bb1b329f4e --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XGregorianDateFormatter.js @@ -0,0 +1,74 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XDateLength_js_to_rust, ICU4XDateLength_rust_to_js } from "./ICU4XDateLength.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XGregorianDateFormatter_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XGregorianDateFormatter_destroy(underlying); +}); + +export class ICU4XGregorianDateFormatter { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XGregorianDateFormatter_box_destroy_registry.register(this, underlying); + } + } + + static create_with_length(arg_provider, arg_locale, arg_length) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XGregorianDateFormatter_create_with_length(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying, ICU4XDateLength_js_to_rust[arg_length]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XGregorianDateFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + format_iso_date(arg_value) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XGregorianDateFormatter_format_iso_date(diplomat_receive_buffer, this.underlying, arg_value.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + format_iso_datetime(arg_value) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XGregorianDateFormatter_format_iso_datetime(diplomat_receive_buffer, this.underlying, arg_value.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XGregorianDateTimeFormatter.d.ts b/third_party/rust/icu_capi/js/include/ICU4XGregorianDateTimeFormatter.d.ts new file mode 100644 index 000000000000..e7952ff06072 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XGregorianDateTimeFormatter.d.ts @@ -0,0 +1,34 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XDateLength } from "./ICU4XDateLength"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XIsoDateTime } from "./ICU4XIsoDateTime"; +import { ICU4XLocale } from "./ICU4XLocale"; +import { ICU4XTimeLength } from "./ICU4XTimeLength"; + +/** + + * An ICU4X TypedDateTimeFormatter object capable of formatting a {@link ICU4XIsoDateTime `ICU4XIsoDateTime`} as a string, using the Gregorian Calendar. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.TypedDateTimeFormatter.html Rust documentation for `TypedDateTimeFormatter`} for more information. + */ +export class ICU4XGregorianDateTimeFormatter { + + /** + + * Creates a new {@link ICU4XGregorianDateFormatter `ICU4XGregorianDateFormatter`} from locale data. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.TypedDateTimeFormatter.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_with_lengths(provider: ICU4XDataProvider, locale: ICU4XLocale, date_length: ICU4XDateLength, time_length: ICU4XTimeLength): ICU4XGregorianDateTimeFormatter | never; + + /** + + * Formats a {@link ICU4XIsoDateTime `ICU4XIsoDateTime`} to a string. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.TypedDateTimeFormatter.html#method.format Rust documentation for `format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + format_iso_datetime(value: ICU4XIsoDateTime): string | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XGregorianDateTimeFormatter.js b/third_party/rust/icu_capi/js/include/ICU4XGregorianDateTimeFormatter.js new file mode 100644 index 000000000000..5315ad4c145d --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XGregorianDateTimeFormatter.js @@ -0,0 +1,56 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XDateLength_js_to_rust, ICU4XDateLength_rust_to_js } from "./ICU4XDateLength.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XTimeLength_js_to_rust, ICU4XTimeLength_rust_to_js } from "./ICU4XTimeLength.js" + +const ICU4XGregorianDateTimeFormatter_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XGregorianDateTimeFormatter_destroy(underlying); +}); + +export class ICU4XGregorianDateTimeFormatter { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XGregorianDateTimeFormatter_box_destroy_registry.register(this, underlying); + } + } + + static create_with_lengths(arg_provider, arg_locale, arg_date_length, arg_time_length) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XGregorianDateTimeFormatter_create_with_lengths(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying, ICU4XDateLength_js_to_rust[arg_date_length], ICU4XTimeLength_js_to_rust[arg_time_length]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XGregorianDateTimeFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + format_iso_datetime(arg_value) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XGregorianDateTimeFormatter_format_iso_datetime(diplomat_receive_buffer, this.underlying, arg_value.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XGregorianZonedDateTimeFormatter.d.ts b/third_party/rust/icu_capi/js/include/ICU4XGregorianZonedDateTimeFormatter.d.ts new file mode 100644 index 000000000000..93c2a42eddc5 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XGregorianZonedDateTimeFormatter.d.ts @@ -0,0 +1,49 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XCustomTimeZone } from "./ICU4XCustomTimeZone"; +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XDateLength } from "./ICU4XDateLength"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XIsoDateTime } from "./ICU4XIsoDateTime"; +import { ICU4XIsoTimeZoneOptions } from "./ICU4XIsoTimeZoneOptions"; +import { ICU4XLocale } from "./ICU4XLocale"; +import { ICU4XTimeLength } from "./ICU4XTimeLength"; + +/** + + * An object capable of formatting a date time with time zone to a string. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.TypedZonedDateTimeFormatter.html Rust documentation for `TypedZonedDateTimeFormatter`} for more information. + */ +export class ICU4XGregorianZonedDateTimeFormatter { + + /** + + * Creates a new {@link ICU4XGregorianZonedDateTimeFormatter `ICU4XGregorianZonedDateTimeFormatter`} from locale data. + + * This function has `date_length` and `time_length` arguments and uses default options for the time zone. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.TypedZonedDateTimeFormatter.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_with_lengths(provider: ICU4XDataProvider, locale: ICU4XLocale, date_length: ICU4XDateLength, time_length: ICU4XTimeLength): ICU4XGregorianZonedDateTimeFormatter | never; + + /** + + * Creates a new {@link ICU4XGregorianZonedDateTimeFormatter `ICU4XGregorianZonedDateTimeFormatter`} from locale data. + + * This function has `date_length` and `time_length` arguments and uses an ISO-8601 style fallback for the time zone with the given configurations. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.TypedZonedDateTimeFormatter.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_with_lengths_and_iso_8601_time_zone_fallback(provider: ICU4XDataProvider, locale: ICU4XLocale, date_length: ICU4XDateLength, time_length: ICU4XTimeLength, zone_options: ICU4XIsoTimeZoneOptions): ICU4XGregorianZonedDateTimeFormatter | never; + + /** + + * Formats a {@link ICU4XIsoDateTime `ICU4XIsoDateTime`} and {@link ICU4XCustomTimeZone `ICU4XCustomTimeZone`} to a string. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.TypedZonedDateTimeFormatter.html#method.format Rust documentation for `format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + format_iso_datetime_with_custom_time_zone(datetime: ICU4XIsoDateTime, time_zone: ICU4XCustomTimeZone): string | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XGregorianZonedDateTimeFormatter.js b/third_party/rust/icu_capi/js/include/ICU4XGregorianZonedDateTimeFormatter.js new file mode 100644 index 000000000000..3e5fa8007ba7 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XGregorianZonedDateTimeFormatter.js @@ -0,0 +1,79 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XDateLength_js_to_rust, ICU4XDateLength_rust_to_js } from "./ICU4XDateLength.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XIsoTimeZoneFormat_js_to_rust, ICU4XIsoTimeZoneFormat_rust_to_js } from "./ICU4XIsoTimeZoneFormat.js" +import { ICU4XIsoTimeZoneMinuteDisplay_js_to_rust, ICU4XIsoTimeZoneMinuteDisplay_rust_to_js } from "./ICU4XIsoTimeZoneMinuteDisplay.js" +import { ICU4XIsoTimeZoneSecondDisplay_js_to_rust, ICU4XIsoTimeZoneSecondDisplay_rust_to_js } from "./ICU4XIsoTimeZoneSecondDisplay.js" +import { ICU4XTimeLength_js_to_rust, ICU4XTimeLength_rust_to_js } from "./ICU4XTimeLength.js" + +const ICU4XGregorianZonedDateTimeFormatter_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XGregorianZonedDateTimeFormatter_destroy(underlying); +}); + +export class ICU4XGregorianZonedDateTimeFormatter { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XGregorianZonedDateTimeFormatter_box_destroy_registry.register(this, underlying); + } + } + + static create_with_lengths(arg_provider, arg_locale, arg_date_length, arg_time_length) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XGregorianZonedDateTimeFormatter_create_with_lengths(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying, ICU4XDateLength_js_to_rust[arg_date_length], ICU4XTimeLength_js_to_rust[arg_time_length]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XGregorianZonedDateTimeFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_with_lengths_and_iso_8601_time_zone_fallback(arg_provider, arg_locale, arg_date_length, arg_time_length, arg_zone_options) { + const field_format_arg_zone_options = arg_zone_options["format"]; + const field_minutes_arg_zone_options = arg_zone_options["minutes"]; + const field_seconds_arg_zone_options = arg_zone_options["seconds"]; + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XGregorianZonedDateTimeFormatter_create_with_lengths_and_iso_8601_time_zone_fallback(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying, ICU4XDateLength_js_to_rust[arg_date_length], ICU4XTimeLength_js_to_rust[arg_time_length], ICU4XIsoTimeZoneFormat_js_to_rust[field_format_arg_zone_options], ICU4XIsoTimeZoneMinuteDisplay_js_to_rust[field_minutes_arg_zone_options], ICU4XIsoTimeZoneSecondDisplay_js_to_rust[field_seconds_arg_zone_options]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XGregorianZonedDateTimeFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + format_iso_datetime_with_custom_time_zone(arg_datetime, arg_time_zone) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XGregorianZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone(diplomat_receive_buffer, this.underlying, arg_datetime.underlying, arg_time_zone.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XIsoDate.d.ts b/third_party/rust/icu_capi/js/include/ICU4XIsoDate.d.ts new file mode 100644 index 000000000000..a9ce0c2e04ae --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XIsoDate.d.ts @@ -0,0 +1,115 @@ +import { u8, i32, u32 } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { ICU4XCalendar } from "./ICU4XCalendar"; +import { ICU4XDate } from "./ICU4XDate"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XIsoWeekday } from "./ICU4XIsoWeekday"; +import { ICU4XWeekCalculator } from "./ICU4XWeekCalculator"; +import { ICU4XWeekOf } from "./ICU4XWeekOf"; + +/** + + * An ICU4X Date object capable of containing a ISO-8601 date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html Rust documentation for `Date`} for more information. + */ +export class ICU4XIsoDate { + + /** + + * Creates a new {@link ICU4XIsoDate `ICU4XIsoDate`} from the specified date and time. + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.try_new_iso_date Rust documentation for `try_new_iso_date`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create(year: i32, month: u8, day: u8): ICU4XIsoDate | never; + + /** + + * Convert this date to one in a different calendar + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.to_calendar Rust documentation for `to_calendar`} for more information. + */ + to_calendar(calendar: ICU4XCalendar): ICU4XDate; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.to_any Rust documentation for `to_any`} for more information. + */ + to_any(): ICU4XDate; + + /** + + * Returns the 1-indexed day in the month for this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_month Rust documentation for `day_of_month`} for more information. + */ + day_of_month(): u32; + + /** + + * Returns the day in the week for this day + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_week Rust documentation for `day_of_week`} for more information. + */ + day_of_week(): ICU4XIsoWeekday; + + /** + + * Returns the week number in this month, 1-indexed, based on what is considered the first day of the week (often a locale preference). + + * `first_weekday` can be obtained via `first_weekday()` on {@link ICU4XWeekCalculator `ICU4XWeekCalculator`} + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_month Rust documentation for `week_of_month`} for more information. + */ + week_of_month(first_weekday: ICU4XIsoWeekday): u32; + + /** + + * Returns the week number in this year, using week data + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_year Rust documentation for `week_of_year`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + week_of_year(calculator: ICU4XWeekCalculator): ICU4XWeekOf | never; + + /** + + * Returns 1-indexed number of the month of this date in its year + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month Rust documentation for `month`} for more information. + */ + month(): u32; + + /** + + * Returns the year number for this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year Rust documentation for `year`} for more information. + */ + year(): i32; + + /** + + * Returns the number of months in the year represented by this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.months_in_year Rust documentation for `months_in_year`} for more information. + */ + months_in_year(): u8; + + /** + + * Returns the number of days in the month represented by this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_month Rust documentation for `days_in_month`} for more information. + */ + days_in_month(): u8; + + /** + + * Returns the number of days in the year represented by this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_year Rust documentation for `days_in_year`} for more information. + */ + days_in_year(): u32; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XIsoDate.js b/third_party/rust/icu_capi/js/include/ICU4XIsoDate.js new file mode 100644 index 000000000000..e2f4a7df662b --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XIsoDate.js @@ -0,0 +1,96 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XDate } from "./ICU4XDate.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XIsoWeekday_js_to_rust, ICU4XIsoWeekday_rust_to_js } from "./ICU4XIsoWeekday.js" +import { ICU4XWeekOf } from "./ICU4XWeekOf.js" +import { ICU4XWeekRelativeUnit_js_to_rust, ICU4XWeekRelativeUnit_rust_to_js } from "./ICU4XWeekRelativeUnit.js" + +const ICU4XIsoDate_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XIsoDate_destroy(underlying); +}); + +export class ICU4XIsoDate { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XIsoDate_box_destroy_registry.register(this, underlying); + } + } + + static create(arg_year, arg_month, arg_day) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XIsoDate_create(diplomat_receive_buffer, arg_year, arg_month, arg_day); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XIsoDate(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + to_calendar(arg_calendar) { + return new ICU4XDate(wasm.ICU4XIsoDate_to_calendar(this.underlying, arg_calendar.underlying), true, []); + } + + to_any() { + return new ICU4XDate(wasm.ICU4XIsoDate_to_any(this.underlying), true, []); + } + + day_of_month() { + return wasm.ICU4XIsoDate_day_of_month(this.underlying); + } + + day_of_week() { + return ICU4XIsoWeekday_rust_to_js[wasm.ICU4XIsoDate_day_of_week(this.underlying)]; + } + + week_of_month(arg_first_weekday) { + return wasm.ICU4XIsoDate_week_of_month(this.underlying, ICU4XIsoWeekday_js_to_rust[arg_first_weekday]); + } + + week_of_year(arg_calculator) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(9, 4); + wasm.ICU4XIsoDate_week_of_year(diplomat_receive_buffer, this.underlying, arg_calculator.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 8); + if (is_ok) { + const ok_value = new ICU4XWeekOf(diplomat_receive_buffer); + wasm.diplomat_free(diplomat_receive_buffer, 9, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 9, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + month() { + return wasm.ICU4XIsoDate_month(this.underlying); + } + + year() { + return wasm.ICU4XIsoDate_year(this.underlying); + } + + months_in_year() { + return wasm.ICU4XIsoDate_months_in_year(this.underlying); + } + + days_in_month() { + return wasm.ICU4XIsoDate_days_in_month(this.underlying); + } + + days_in_year() { + return wasm.ICU4XIsoDate_days_in_year(this.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XIsoDateTime.d.ts b/third_party/rust/icu_capi/js/include/ICU4XIsoDateTime.d.ts new file mode 100644 index 000000000000..6140631bba77 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XIsoDateTime.d.ts @@ -0,0 +1,191 @@ +import { u8, i32, u32 } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { ICU4XCalendar } from "./ICU4XCalendar"; +import { ICU4XDateTime } from "./ICU4XDateTime"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XIsoDate } from "./ICU4XIsoDate"; +import { ICU4XIsoWeekday } from "./ICU4XIsoWeekday"; +import { ICU4XTime } from "./ICU4XTime"; +import { ICU4XWeekCalculator } from "./ICU4XWeekCalculator"; +import { ICU4XWeekOf } from "./ICU4XWeekOf"; + +/** + + * An ICU4X DateTime object capable of containing a ISO-8601 date and time. + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html Rust documentation for `DateTime`} for more information. + */ +export class ICU4XIsoDateTime { + + /** + + * Creates a new {@link ICU4XIsoDateTime `ICU4XIsoDateTime`} from the specified date and time. + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.try_new_iso_datetime Rust documentation for `try_new_iso_datetime`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create(year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8, nanosecond: u32): ICU4XIsoDateTime | never; + + /** + + * Creates a new {@link ICU4XIsoDateTime `ICU4XIsoDateTime`} from an {@link ICU4XIsoDate `ICU4XIsoDate`} and {@link ICU4XTime `ICU4XTime`} object + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.new Rust documentation for `new`} for more information. + */ + static crate_from_date_and_time(date: ICU4XIsoDate, time: ICU4XTime): ICU4XIsoDateTime; + + /** + + * Construct from the minutes since the local unix epoch for this date (Jan 1 1970, 00:00) + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.from_minutes_since_local_unix_epoch Rust documentation for `from_minutes_since_local_unix_epoch`} for more information. + */ + static create_from_minutes_since_local_unix_epoch(minutes: i32): ICU4XIsoDateTime; + + /** + + * Gets the date contained in this object + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#structfield.date Rust documentation for `date`} for more information. + */ + date(): ICU4XIsoDate; + + /** + + * Gets the time contained in this object + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#structfield.time Rust documentation for `time`} for more information. + */ + time(): ICU4XTime; + + /** + + * Converts this to an {@link ICU4XDateTime `ICU4XDateTime`} capable of being mixed with dates of other calendars + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.to_any Rust documentation for `to_any`} for more information. + */ + to_any(): ICU4XDateTime; + + /** + + * Gets the minutes since the local unix epoch for this date (Jan 1 1970, 00:00) + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.minutes_since_local_unix_epoch Rust documentation for `minutes_since_local_unix_epoch`} for more information. + */ + minutes_since_local_unix_epoch(): i32; + + /** + + * Convert this datetime to one in a different calendar + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.DateTime.html#method.to_calendar Rust documentation for `to_calendar`} for more information. + */ + to_calendar(calendar: ICU4XCalendar): ICU4XDateTime; + + /** + + * Returns the hour in this time + + * See the {@link https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.hour Rust documentation for `hour`} for more information. + */ + hour(): u8; + + /** + + * Returns the minute in this time + + * See the {@link https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.minute Rust documentation for `minute`} for more information. + */ + minute(): u8; + + /** + + * Returns the second in this time + + * See the {@link https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.second Rust documentation for `second`} for more information. + */ + second(): u8; + + /** + + * Returns the nanosecond in this time + + * See the {@link https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.nanosecond Rust documentation for `nanosecond`} for more information. + */ + nanosecond(): u32; + + /** + + * Returns the 1-indexed day in the month for this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_month Rust documentation for `day_of_month`} for more information. + */ + day_of_month(): u32; + + /** + + * Returns the day in the week for this day + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.day_of_week Rust documentation for `day_of_week`} for more information. + */ + day_of_week(): ICU4XIsoWeekday; + + /** + + * Returns the week number in this month, 1-indexed, based on what is considered the first day of the week (often a locale preference). + + * `first_weekday` can be obtained via `first_weekday()` on {@link ICU4XWeekCalculator `ICU4XWeekCalculator`} + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_month Rust documentation for `week_of_month`} for more information. + */ + week_of_month(first_weekday: ICU4XIsoWeekday): u32; + + /** + + * Returns the week number in this year, using week data + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.week_of_year Rust documentation for `week_of_year`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + week_of_year(calculator: ICU4XWeekCalculator): ICU4XWeekOf | never; + + /** + + * Returns 1-indexed number of the month of this date in its year + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.month Rust documentation for `month`} for more information. + */ + month(): u32; + + /** + + * Returns the year number for this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.year Rust documentation for `year`} for more information. + */ + year(): i32; + + /** + + * Returns the number of months in the year represented by this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.months_in_year Rust documentation for `months_in_year`} for more information. + */ + months_in_year(): u8; + + /** + + * Returns the number of days in the month represented by this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_month Rust documentation for `days_in_month`} for more information. + */ + days_in_month(): u8; + + /** + + * Returns the number of days in the year represented by this date + + * See the {@link https://docs.rs/icu/latest/icu/calendar/struct.Date.html#method.days_in_year Rust documentation for `days_in_year`} for more information. + */ + days_in_year(): u32; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XIsoDateTime.js b/third_party/rust/icu_capi/js/include/ICU4XIsoDateTime.js new file mode 100644 index 000000000000..f188bb4f2b51 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XIsoDateTime.js @@ -0,0 +1,134 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XDateTime } from "./ICU4XDateTime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XIsoDate } from "./ICU4XIsoDate.js" +import { ICU4XIsoWeekday_js_to_rust, ICU4XIsoWeekday_rust_to_js } from "./ICU4XIsoWeekday.js" +import { ICU4XTime } from "./ICU4XTime.js" +import { ICU4XWeekOf } from "./ICU4XWeekOf.js" +import { ICU4XWeekRelativeUnit_js_to_rust, ICU4XWeekRelativeUnit_rust_to_js } from "./ICU4XWeekRelativeUnit.js" + +const ICU4XIsoDateTime_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XIsoDateTime_destroy(underlying); +}); + +export class ICU4XIsoDateTime { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XIsoDateTime_box_destroy_registry.register(this, underlying); + } + } + + static create(arg_year, arg_month, arg_day, arg_hour, arg_minute, arg_second, arg_nanosecond) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XIsoDateTime_create(diplomat_receive_buffer, arg_year, arg_month, arg_day, arg_hour, arg_minute, arg_second, arg_nanosecond); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XIsoDateTime(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static crate_from_date_and_time(arg_date, arg_time) { + return new ICU4XIsoDateTime(wasm.ICU4XIsoDateTime_crate_from_date_and_time(arg_date.underlying, arg_time.underlying), true, []); + } + + static create_from_minutes_since_local_unix_epoch(arg_minutes) { + return new ICU4XIsoDateTime(wasm.ICU4XIsoDateTime_create_from_minutes_since_local_unix_epoch(arg_minutes), true, []); + } + + date() { + return new ICU4XIsoDate(wasm.ICU4XIsoDateTime_date(this.underlying), true, []); + } + + time() { + return new ICU4XTime(wasm.ICU4XIsoDateTime_time(this.underlying), true, []); + } + + to_any() { + return new ICU4XDateTime(wasm.ICU4XIsoDateTime_to_any(this.underlying), true, []); + } + + minutes_since_local_unix_epoch() { + return wasm.ICU4XIsoDateTime_minutes_since_local_unix_epoch(this.underlying); + } + + to_calendar(arg_calendar) { + return new ICU4XDateTime(wasm.ICU4XIsoDateTime_to_calendar(this.underlying, arg_calendar.underlying), true, []); + } + + hour() { + return wasm.ICU4XIsoDateTime_hour(this.underlying); + } + + minute() { + return wasm.ICU4XIsoDateTime_minute(this.underlying); + } + + second() { + return wasm.ICU4XIsoDateTime_second(this.underlying); + } + + nanosecond() { + return wasm.ICU4XIsoDateTime_nanosecond(this.underlying); + } + + day_of_month() { + return wasm.ICU4XIsoDateTime_day_of_month(this.underlying); + } + + day_of_week() { + return ICU4XIsoWeekday_rust_to_js[wasm.ICU4XIsoDateTime_day_of_week(this.underlying)]; + } + + week_of_month(arg_first_weekday) { + return wasm.ICU4XIsoDateTime_week_of_month(this.underlying, ICU4XIsoWeekday_js_to_rust[arg_first_weekday]); + } + + week_of_year(arg_calculator) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(9, 4); + wasm.ICU4XIsoDateTime_week_of_year(diplomat_receive_buffer, this.underlying, arg_calculator.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 8); + if (is_ok) { + const ok_value = new ICU4XWeekOf(diplomat_receive_buffer); + wasm.diplomat_free(diplomat_receive_buffer, 9, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 9, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + month() { + return wasm.ICU4XIsoDateTime_month(this.underlying); + } + + year() { + return wasm.ICU4XIsoDateTime_year(this.underlying); + } + + months_in_year() { + return wasm.ICU4XIsoDateTime_months_in_year(this.underlying); + } + + days_in_month() { + return wasm.ICU4XIsoDateTime_days_in_month(this.underlying); + } + + days_in_year() { + return wasm.ICU4XIsoDateTime_days_in_year(this.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneFormat.d.ts b/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneFormat.d.ts new file mode 100644 index 000000000000..8889318a02c5 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneFormat.d.ts @@ -0,0 +1,19 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/datetime/time_zone/enum.IsoFormat.html Rust documentation for `IsoFormat`} for more information. + */ +export enum ICU4XIsoTimeZoneFormat { + /** + */ + Basic = 'Basic', + /** + */ + Extended = 'Extended', + /** + */ + UtcBasic = 'UtcBasic', + /** + */ + UtcExtended = 'UtcExtended', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneFormat.js b/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneFormat.js new file mode 100644 index 000000000000..aae553da7766 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneFormat.js @@ -0,0 +1,23 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XIsoTimeZoneFormat_js_to_rust = { + "Basic": 0, + "Extended": 1, + "UtcBasic": 2, + "UtcExtended": 3, +}; + +export const ICU4XIsoTimeZoneFormat_rust_to_js = { + [0]: "Basic", + [1]: "Extended", + [2]: "UtcBasic", + [3]: "UtcExtended", +}; + +export const ICU4XIsoTimeZoneFormat = { + "Basic": "Basic", + "Extended": "Extended", + "UtcBasic": "UtcBasic", + "UtcExtended": "UtcExtended", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneMinuteDisplay.d.ts b/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneMinuteDisplay.d.ts new file mode 100644 index 000000000000..07ed133c1858 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneMinuteDisplay.d.ts @@ -0,0 +1,13 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/datetime/time_zone/enum.IsoMinutes.html Rust documentation for `IsoMinutes`} for more information. + */ +export enum ICU4XIsoTimeZoneMinuteDisplay { + /** + */ + Required = 'Required', + /** + */ + Optional = 'Optional', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneMinuteDisplay.js b/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneMinuteDisplay.js new file mode 100644 index 000000000000..f6daf3ef46c0 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneMinuteDisplay.js @@ -0,0 +1,17 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XIsoTimeZoneMinuteDisplay_js_to_rust = { + "Required": 0, + "Optional": 1, +}; + +export const ICU4XIsoTimeZoneMinuteDisplay_rust_to_js = { + [0]: "Required", + [1]: "Optional", +}; + +export const ICU4XIsoTimeZoneMinuteDisplay = { + "Required": "Required", + "Optional": "Optional", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneOptions.d.ts b/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneOptions.d.ts new file mode 100644 index 000000000000..d150b2d2e586 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneOptions.d.ts @@ -0,0 +1,11 @@ +import { ICU4XIsoTimeZoneFormat } from "./ICU4XIsoTimeZoneFormat"; +import { ICU4XIsoTimeZoneMinuteDisplay } from "./ICU4XIsoTimeZoneMinuteDisplay"; +import { ICU4XIsoTimeZoneSecondDisplay } from "./ICU4XIsoTimeZoneSecondDisplay"; + +/** + */ +export class ICU4XIsoTimeZoneOptions { + format: ICU4XIsoTimeZoneFormat; + minutes: ICU4XIsoTimeZoneMinuteDisplay; + seconds: ICU4XIsoTimeZoneSecondDisplay; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneOptions.js b/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneOptions.js new file mode 100644 index 000000000000..5e9e8f16a799 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneOptions.js @@ -0,0 +1,13 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XIsoTimeZoneFormat_js_to_rust, ICU4XIsoTimeZoneFormat_rust_to_js } from "./ICU4XIsoTimeZoneFormat.js" +import { ICU4XIsoTimeZoneMinuteDisplay_js_to_rust, ICU4XIsoTimeZoneMinuteDisplay_rust_to_js } from "./ICU4XIsoTimeZoneMinuteDisplay.js" +import { ICU4XIsoTimeZoneSecondDisplay_js_to_rust, ICU4XIsoTimeZoneSecondDisplay_rust_to_js } from "./ICU4XIsoTimeZoneSecondDisplay.js" + +export class ICU4XIsoTimeZoneOptions { + constructor(underlying) { + this.format = ICU4XIsoTimeZoneFormat_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, underlying)]; + this.minutes = ICU4XIsoTimeZoneMinuteDisplay_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, underlying + 4)]; + this.seconds = ICU4XIsoTimeZoneSecondDisplay_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, underlying + 8)]; + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneSecondDisplay.d.ts b/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneSecondDisplay.d.ts new file mode 100644 index 000000000000..77f1c9e8b761 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneSecondDisplay.d.ts @@ -0,0 +1,13 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/datetime/time_zone/enum.IsoSeconds.html Rust documentation for `IsoSeconds`} for more information. + */ +export enum ICU4XIsoTimeZoneSecondDisplay { + /** + */ + Optional = 'Optional', + /** + */ + Never = 'Never', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneSecondDisplay.js b/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneSecondDisplay.js new file mode 100644 index 000000000000..d57b7139e17a --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XIsoTimeZoneSecondDisplay.js @@ -0,0 +1,17 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XIsoTimeZoneSecondDisplay_js_to_rust = { + "Optional": 0, + "Never": 1, +}; + +export const ICU4XIsoTimeZoneSecondDisplay_rust_to_js = { + [0]: "Optional", + [1]: "Never", +}; + +export const ICU4XIsoTimeZoneSecondDisplay = { + "Optional": "Optional", + "Never": "Never", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XIsoWeekday.d.ts b/third_party/rust/icu_capi/js/include/ICU4XIsoWeekday.d.ts new file mode 100644 index 000000000000..873f20a55f86 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XIsoWeekday.d.ts @@ -0,0 +1,26 @@ + +/** + */ +export enum ICU4XIsoWeekday { + /** + */ + Monday = 'Monday', + /** + */ + Tuesday = 'Tuesday', + /** + */ + Wednesday = 'Wednesday', + /** + */ + Thursday = 'Thursday', + /** + */ + Friday = 'Friday', + /** + */ + Saturday = 'Saturday', + /** + */ + Sunday = 'Sunday', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XIsoWeekday.js b/third_party/rust/icu_capi/js/include/ICU4XIsoWeekday.js new file mode 100644 index 000000000000..71912bd0e36c --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XIsoWeekday.js @@ -0,0 +1,32 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XIsoWeekday_js_to_rust = { + "Monday": 1, + "Tuesday": 2, + "Wednesday": 3, + "Thursday": 4, + "Friday": 5, + "Saturday": 6, + "Sunday": 7, +}; + +export const ICU4XIsoWeekday_rust_to_js = { + [1]: "Monday", + [2]: "Tuesday", + [3]: "Wednesday", + [4]: "Thursday", + [5]: "Friday", + [6]: "Saturday", + [7]: "Sunday", +}; + +export const ICU4XIsoWeekday = { + "Monday": "Monday", + "Tuesday": "Tuesday", + "Wednesday": "Wednesday", + "Thursday": "Thursday", + "Friday": "Friday", + "Saturday": "Saturday", + "Sunday": "Sunday", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XLanguageDisplay.d.ts b/third_party/rust/icu_capi/js/include/ICU4XLanguageDisplay.d.ts new file mode 100644 index 000000000000..8c391e8ebb3f --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLanguageDisplay.d.ts @@ -0,0 +1,13 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/displaynames/options/enum.LanguageDisplay.html Rust documentation for `LanguageDisplay`} for more information. + */ +export enum ICU4XLanguageDisplay { + /** + */ + Dialect = 'Dialect', + /** + */ + Standard = 'Standard', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XLanguageDisplay.js b/third_party/rust/icu_capi/js/include/ICU4XLanguageDisplay.js new file mode 100644 index 000000000000..abac8082e076 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLanguageDisplay.js @@ -0,0 +1,17 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XLanguageDisplay_js_to_rust = { + "Dialect": 0, + "Standard": 1, +}; + +export const ICU4XLanguageDisplay_rust_to_js = { + [0]: "Dialect", + [1]: "Standard", +}; + +export const ICU4XLanguageDisplay = { + "Dialect": "Dialect", + "Standard": "Standard", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorLatin1.d.ts b/third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorLatin1.d.ts new file mode 100644 index 000000000000..e8dfe70b589c --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorLatin1.d.ts @@ -0,0 +1,18 @@ +import { i32 } from "./diplomat-runtime" + +/** + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakIterator.html Rust documentation for `LineBreakIterator`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/segmenter/type.LineBreakIteratorLatin1.html 1} + */ +export class ICU4XLineBreakIteratorLatin1 { + + /** + + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is out of range of a 32-bit signed integer. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakIterator.html#method.next Rust documentation for `next`} for more information. + */ + next(): i32; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorLatin1.js b/third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorLatin1.js new file mode 100644 index 000000000000..7bd8f131538c --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorLatin1.js @@ -0,0 +1,21 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +const ICU4XLineBreakIteratorLatin1_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XLineBreakIteratorLatin1_destroy(underlying); +}); + +export class ICU4XLineBreakIteratorLatin1 { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XLineBreakIteratorLatin1_box_destroy_registry.register(this, underlying); + } + } + + next() { + return wasm.ICU4XLineBreakIteratorLatin1_next(this.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorUtf16.d.ts b/third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorUtf16.d.ts new file mode 100644 index 000000000000..4a1b41ba9d3c --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorUtf16.d.ts @@ -0,0 +1,18 @@ +import { i32 } from "./diplomat-runtime" + +/** + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakIterator.html Rust documentation for `LineBreakIterator`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/segmenter/type.LineBreakIteratorUtf16.html 1} + */ +export class ICU4XLineBreakIteratorUtf16 { + + /** + + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is out of range of a 32-bit signed integer. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakIterator.html#method.next Rust documentation for `next`} for more information. + */ + next(): i32; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorUtf16.js b/third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorUtf16.js new file mode 100644 index 000000000000..3ac2f871ace5 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorUtf16.js @@ -0,0 +1,21 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +const ICU4XLineBreakIteratorUtf16_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XLineBreakIteratorUtf16_destroy(underlying); +}); + +export class ICU4XLineBreakIteratorUtf16 { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XLineBreakIteratorUtf16_box_destroy_registry.register(this, underlying); + } + } + + next() { + return wasm.ICU4XLineBreakIteratorUtf16_next(this.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorUtf8.d.ts b/third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorUtf8.d.ts new file mode 100644 index 000000000000..9a576f122442 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorUtf8.d.ts @@ -0,0 +1,18 @@ +import { i32 } from "./diplomat-runtime" + +/** + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakIterator.html Rust documentation for `LineBreakIterator`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/segmenter/type.LineBreakIteratorPotentiallyIllFormedUtf8.html 1} + */ +export class ICU4XLineBreakIteratorUtf8 { + + /** + + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is out of range of a 32-bit signed integer. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakIterator.html#method.next Rust documentation for `next`} for more information. + */ + next(): i32; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorUtf8.js b/third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorUtf8.js new file mode 100644 index 000000000000..a9802d00332f --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLineBreakIteratorUtf8.js @@ -0,0 +1,21 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +const ICU4XLineBreakIteratorUtf8_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XLineBreakIteratorUtf8_destroy(underlying); +}); + +export class ICU4XLineBreakIteratorUtf8 { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XLineBreakIteratorUtf8_box_destroy_registry.register(this, underlying); + } + } + + next() { + return wasm.ICU4XLineBreakIteratorUtf8_next(this.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLineBreakOptionsV1.d.ts b/third_party/rust/icu_capi/js/include/ICU4XLineBreakOptionsV1.d.ts new file mode 100644 index 000000000000..9dd3f2e841ec --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLineBreakOptionsV1.d.ts @@ -0,0 +1,12 @@ +import { ICU4XLineBreakStrictness } from "./ICU4XLineBreakStrictness"; +import { ICU4XLineBreakWordOption } from "./ICU4XLineBreakWordOption"; + +/** + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.LineBreakOptions.html Rust documentation for `LineBreakOptions`} for more information. + */ +export class ICU4XLineBreakOptionsV1 { + strictness: ICU4XLineBreakStrictness; + word_option: ICU4XLineBreakWordOption; + ja_zh: boolean; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLineBreakOptionsV1.js b/third_party/rust/icu_capi/js/include/ICU4XLineBreakOptionsV1.js new file mode 100644 index 000000000000..ee3a48175fa5 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLineBreakOptionsV1.js @@ -0,0 +1,12 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XLineBreakStrictness_js_to_rust, ICU4XLineBreakStrictness_rust_to_js } from "./ICU4XLineBreakStrictness.js" +import { ICU4XLineBreakWordOption_js_to_rust, ICU4XLineBreakWordOption_rust_to_js } from "./ICU4XLineBreakWordOption.js" + +export class ICU4XLineBreakOptionsV1 { + constructor(underlying) { + this.strictness = ICU4XLineBreakStrictness_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, underlying)]; + this.word_option = ICU4XLineBreakWordOption_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, underlying + 4)]; + this.ja_zh = (new Uint8Array(wasm.memory.buffer, underlying + 8, 1))[0] == 1; + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLineBreakStrictness.d.ts b/third_party/rust/icu_capi/js/include/ICU4XLineBreakStrictness.d.ts new file mode 100644 index 000000000000..f92e35a751c4 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLineBreakStrictness.d.ts @@ -0,0 +1,19 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/enum.LineBreakStrictness.html Rust documentation for `LineBreakStrictness`} for more information. + */ +export enum ICU4XLineBreakStrictness { + /** + */ + Loose = 'Loose', + /** + */ + Normal = 'Normal', + /** + */ + Strict = 'Strict', + /** + */ + Anywhere = 'Anywhere', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XLineBreakStrictness.js b/third_party/rust/icu_capi/js/include/ICU4XLineBreakStrictness.js new file mode 100644 index 000000000000..c52030b79fc9 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLineBreakStrictness.js @@ -0,0 +1,23 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XLineBreakStrictness_js_to_rust = { + "Loose": 0, + "Normal": 1, + "Strict": 2, + "Anywhere": 3, +}; + +export const ICU4XLineBreakStrictness_rust_to_js = { + [0]: "Loose", + [1]: "Normal", + [2]: "Strict", + [3]: "Anywhere", +}; + +export const ICU4XLineBreakStrictness = { + "Loose": "Loose", + "Normal": "Normal", + "Strict": "Strict", + "Anywhere": "Anywhere", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XLineBreakWordOption.d.ts b/third_party/rust/icu_capi/js/include/ICU4XLineBreakWordOption.d.ts new file mode 100644 index 000000000000..256ddb0e08dd --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLineBreakWordOption.d.ts @@ -0,0 +1,16 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/enum.LineBreakWordOption.html Rust documentation for `LineBreakWordOption`} for more information. + */ +export enum ICU4XLineBreakWordOption { + /** + */ + Normal = 'Normal', + /** + */ + BreakAll = 'BreakAll', + /** + */ + KeepAll = 'KeepAll', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XLineBreakWordOption.js b/third_party/rust/icu_capi/js/include/ICU4XLineBreakWordOption.js new file mode 100644 index 000000000000..60094fdafde1 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLineBreakWordOption.js @@ -0,0 +1,20 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XLineBreakWordOption_js_to_rust = { + "Normal": 0, + "BreakAll": 1, + "KeepAll": 2, +}; + +export const ICU4XLineBreakWordOption_rust_to_js = { + [0]: "Normal", + [1]: "BreakAll", + [2]: "KeepAll", +}; + +export const ICU4XLineBreakWordOption = { + "Normal": "Normal", + "BreakAll": "BreakAll", + "KeepAll": "KeepAll", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XLineSegmenter.d.ts b/third_party/rust/icu_capi/js/include/ICU4XLineSegmenter.d.ts new file mode 100644 index 000000000000..aac2412ae63b --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLineSegmenter.d.ts @@ -0,0 +1,94 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XLineBreakIteratorLatin1 } from "./ICU4XLineBreakIteratorLatin1"; +import { ICU4XLineBreakIteratorUtf16 } from "./ICU4XLineBreakIteratorUtf16"; +import { ICU4XLineBreakIteratorUtf8 } from "./ICU4XLineBreakIteratorUtf8"; +import { ICU4XLineBreakOptionsV1 } from "./ICU4XLineBreakOptionsV1"; + +/** + + * An ICU4X line-break segmenter, capable of finding breakpoints in strings. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html Rust documentation for `LineSegmenter`} for more information. + */ +export class ICU4XLineSegmenter { + + /** + + * Construct a {@link ICU4XLineSegmenter `ICU4XLineSegmenter`} with default options. It automatically loads the best available payload data for Burmese, Khmer, Lao, and Thai. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.try_new_auto_unstable Rust documentation for `try_new_auto_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_auto(provider: ICU4XDataProvider): ICU4XLineSegmenter | never; + + /** + + * Construct a {@link ICU4XLineSegmenter `ICU4XLineSegmenter`} with default options and LSTM payload data for Burmese, Khmer, Lao, and Thai. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.try_new_lstm_unstable Rust documentation for `try_new_lstm_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_lstm(provider: ICU4XDataProvider): ICU4XLineSegmenter | never; + + /** + + * Construct a {@link ICU4XLineSegmenter `ICU4XLineSegmenter`} with default options and dictionary payload data for Burmese, Khmer, Lao, and Thai.. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.try_new_dictionary_unstable Rust documentation for `try_new_dictionary_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_dictionary(provider: ICU4XDataProvider): ICU4XLineSegmenter | never; + + /** + + * Construct a {@link ICU4XLineSegmenter `ICU4XLineSegmenter`} with custom options. It automatically loads the best available payload data for Burmese, Khmer, Lao, and Thai. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.try_new_auto_with_options_unstable Rust documentation for `try_new_auto_with_options_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_auto_with_options_v1(provider: ICU4XDataProvider, options: ICU4XLineBreakOptionsV1): ICU4XLineSegmenter | never; + + /** + + * Construct a {@link ICU4XLineSegmenter `ICU4XLineSegmenter`} with custom options and LSTM payload data for Burmese, Khmer, Lao, and Thai. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.try_new_lstm_with_options_unstable Rust documentation for `try_new_lstm_with_options_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_lstm_with_options_v1(provider: ICU4XDataProvider, options: ICU4XLineBreakOptionsV1): ICU4XLineSegmenter | never; + + /** + + * Construct a {@link ICU4XLineSegmenter `ICU4XLineSegmenter`} with custom options and dictionary payload data for Burmese, Khmer, Lao, and Thai. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.try_new_dictionary_with_options_unstable Rust documentation for `try_new_dictionary_with_options_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_dictionary_with_options_v1(provider: ICU4XDataProvider, options: ICU4XLineBreakOptionsV1): ICU4XLineSegmenter | never; + + /** + + * Segments a (potentially ill-formed) UTF-8 string. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.segment_utf8 Rust documentation for `segment_utf8`} for more information. + */ + segment_utf8(input: string): ICU4XLineBreakIteratorUtf8; + + /** + + * Segments a UTF-16 string. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.segment_utf16 Rust documentation for `segment_utf16`} for more information. + */ + segment_utf16(input: Uint16Array): ICU4XLineBreakIteratorUtf16; + + /** + + * Segments a Latin-1 string. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.LineSegmenter.html#method.segment_latin1 Rust documentation for `segment_latin1`} for more information. + */ + segment_latin1(input: Uint8Array): ICU4XLineBreakIteratorLatin1; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLineSegmenter.js b/third_party/rust/icu_capi/js/include/ICU4XLineSegmenter.js new file mode 100644 index 000000000000..eabb317515c8 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLineSegmenter.js @@ -0,0 +1,149 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XLineBreakIteratorLatin1 } from "./ICU4XLineBreakIteratorLatin1.js" +import { ICU4XLineBreakIteratorUtf16 } from "./ICU4XLineBreakIteratorUtf16.js" +import { ICU4XLineBreakIteratorUtf8 } from "./ICU4XLineBreakIteratorUtf8.js" +import { ICU4XLineBreakStrictness_js_to_rust, ICU4XLineBreakStrictness_rust_to_js } from "./ICU4XLineBreakStrictness.js" +import { ICU4XLineBreakWordOption_js_to_rust, ICU4XLineBreakWordOption_rust_to_js } from "./ICU4XLineBreakWordOption.js" + +const ICU4XLineSegmenter_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XLineSegmenter_destroy(underlying); +}); + +export class ICU4XLineSegmenter { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XLineSegmenter_box_destroy_registry.register(this, underlying); + } + } + + static create_auto(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLineSegmenter_create_auto(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XLineSegmenter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_lstm(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLineSegmenter_create_lstm(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XLineSegmenter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_dictionary(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLineSegmenter_create_dictionary(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XLineSegmenter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_auto_with_options_v1(arg_provider, arg_options) { + const field_strictness_arg_options = arg_options["strictness"]; + const field_word_option_arg_options = arg_options["word_option"]; + const field_ja_zh_arg_options = arg_options["ja_zh"]; + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLineSegmenter_create_auto_with_options_v1(diplomat_receive_buffer, arg_provider.underlying, ICU4XLineBreakStrictness_js_to_rust[field_strictness_arg_options], ICU4XLineBreakWordOption_js_to_rust[field_word_option_arg_options], field_ja_zh_arg_options); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XLineSegmenter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_lstm_with_options_v1(arg_provider, arg_options) { + const field_strictness_arg_options = arg_options["strictness"]; + const field_word_option_arg_options = arg_options["word_option"]; + const field_ja_zh_arg_options = arg_options["ja_zh"]; + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLineSegmenter_create_lstm_with_options_v1(diplomat_receive_buffer, arg_provider.underlying, ICU4XLineBreakStrictness_js_to_rust[field_strictness_arg_options], ICU4XLineBreakWordOption_js_to_rust[field_word_option_arg_options], field_ja_zh_arg_options); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XLineSegmenter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_dictionary_with_options_v1(arg_provider, arg_options) { + const field_strictness_arg_options = arg_options["strictness"]; + const field_word_option_arg_options = arg_options["word_option"]; + const field_ja_zh_arg_options = arg_options["ja_zh"]; + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLineSegmenter_create_dictionary_with_options_v1(diplomat_receive_buffer, arg_provider.underlying, ICU4XLineBreakStrictness_js_to_rust[field_strictness_arg_options], ICU4XLineBreakWordOption_js_to_rust[field_word_option_arg_options], field_ja_zh_arg_options); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XLineSegmenter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + segment_utf8(arg_input) { + const buf_arg_input = diplomatRuntime.DiplomatBuf.str(wasm, arg_input); + return new ICU4XLineBreakIteratorUtf8(wasm.ICU4XLineSegmenter_segment_utf8(this.underlying, buf_arg_input.ptr, buf_arg_input.size), true, [this, buf_arg_input]); + } + + segment_utf16(arg_input) { + const buf_arg_input = diplomatRuntime.DiplomatBuf.slice(wasm, arg_input, 2); + return new ICU4XLineBreakIteratorUtf16(wasm.ICU4XLineSegmenter_segment_utf16(this.underlying, buf_arg_input.ptr, buf_arg_input.size), true, [this, buf_arg_input]); + } + + segment_latin1(arg_input) { + const buf_arg_input = diplomatRuntime.DiplomatBuf.slice(wasm, arg_input, 1); + return new ICU4XLineBreakIteratorLatin1(wasm.ICU4XLineSegmenter_segment_latin1(this.underlying, buf_arg_input.ptr, buf_arg_input.size), true, [this, buf_arg_input]); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XList.d.ts b/third_party/rust/icu_capi/js/include/ICU4XList.d.ts new file mode 100644 index 000000000000..facf54a8cb41 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XList.d.ts @@ -0,0 +1,34 @@ +import { usize } from "./diplomat-runtime" + +/** + + * A list of strings + */ +export class ICU4XList { + + /** + + * Create a new list of strings + */ + static create(): ICU4XList; + + /** + + * Create a new list of strings with preallocated space to hold at least `capacity` elements + */ + static create_with_capacity(capacity: usize): ICU4XList; + + /** + + * Push a string to the list + + * For C++ users, potentially invalid UTF8 will be handled via REPLACEMENT CHARACTERs + */ + push(val: string): void; + + /** + + * The number of elements in this list + */ + len(): usize; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XList.js b/third_party/rust/icu_capi/js/include/ICU4XList.js new file mode 100644 index 000000000000..55475df4dba5 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XList.js @@ -0,0 +1,35 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +const ICU4XList_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XList_destroy(underlying); +}); + +export class ICU4XList { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XList_box_destroy_registry.register(this, underlying); + } + } + + static create() { + return new ICU4XList(wasm.ICU4XList_create(), true, []); + } + + static create_with_capacity(arg_capacity) { + return new ICU4XList(wasm.ICU4XList_create_with_capacity(arg_capacity), true, []); + } + + push(arg_val) { + const buf_arg_val = diplomatRuntime.DiplomatBuf.str(wasm, arg_val); + wasm.ICU4XList_push(this.underlying, buf_arg_val.ptr, buf_arg_val.size); + buf_arg_val.free(); + } + + len() { + return wasm.ICU4XList_len(this.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XListFormatter.d.ts b/third_party/rust/icu_capi/js/include/ICU4XListFormatter.d.ts new file mode 100644 index 000000000000..744527bfe43f --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XListFormatter.d.ts @@ -0,0 +1,47 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XList } from "./ICU4XList"; +import { ICU4XListLength } from "./ICU4XListLength"; +import { ICU4XLocale } from "./ICU4XLocale"; + +/** + + * See the {@link https://docs.rs/icu/latest/icu/list/struct.ListFormatter.html Rust documentation for `ListFormatter`} for more information. + */ +export class ICU4XListFormatter { + + /** + + * Construct a new ICU4XListFormatter instance for And patterns + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/struct.ListFormatter.html#method.try_new_and_with_length_unstable Rust documentation for `try_new_and_with_length_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_and_with_length(provider: ICU4XDataProvider, locale: ICU4XLocale, length: ICU4XListLength): ICU4XListFormatter | never; + + /** + + * Construct a new ICU4XListFormatter instance for And patterns + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/struct.ListFormatter.html#method.try_new_or_with_length_unstable Rust documentation for `try_new_or_with_length_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_or_with_length(provider: ICU4XDataProvider, locale: ICU4XLocale, length: ICU4XListLength): ICU4XListFormatter | never; + + /** + + * Construct a new ICU4XListFormatter instance for And patterns + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/struct.ListFormatter.html#method.try_new_unit_with_length_unstable Rust documentation for `try_new_unit_with_length_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_unit_with_length(provider: ICU4XDataProvider, locale: ICU4XLocale, length: ICU4XListLength): ICU4XListFormatter | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/normalizer/struct.ListFormatter.html#method.format Rust documentation for `format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + format(list: ICU4XList): string | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XListFormatter.js b/third_party/rust/icu_capi/js/include/ICU4XListFormatter.js new file mode 100644 index 000000000000..63ef80b23fba --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XListFormatter.js @@ -0,0 +1,89 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XListLength_js_to_rust, ICU4XListLength_rust_to_js } from "./ICU4XListLength.js" + +const ICU4XListFormatter_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XListFormatter_destroy(underlying); +}); + +export class ICU4XListFormatter { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XListFormatter_box_destroy_registry.register(this, underlying); + } + } + + static create_and_with_length(arg_provider, arg_locale, arg_length) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XListFormatter_create_and_with_length(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying, ICU4XListLength_js_to_rust[arg_length]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XListFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_or_with_length(arg_provider, arg_locale, arg_length) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XListFormatter_create_or_with_length(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying, ICU4XListLength_js_to_rust[arg_length]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XListFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_unit_with_length(arg_provider, arg_locale, arg_length) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XListFormatter_create_unit_with_length(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying, ICU4XListLength_js_to_rust[arg_length]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XListFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + format(arg_list) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XListFormatter_format(diplomat_receive_buffer, this.underlying, arg_list.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XListLength.d.ts b/third_party/rust/icu_capi/js/include/ICU4XListLength.d.ts new file mode 100644 index 000000000000..4aa3e3b4d5ec --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XListLength.d.ts @@ -0,0 +1,16 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/list/enum.ListLength.html Rust documentation for `ListLength`} for more information. + */ +export enum ICU4XListLength { + /** + */ + Wide = 'Wide', + /** + */ + Short = 'Short', + /** + */ + Narrow = 'Narrow', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XListLength.js b/third_party/rust/icu_capi/js/include/ICU4XListLength.js new file mode 100644 index 000000000000..171e851b4d98 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XListLength.js @@ -0,0 +1,20 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XListLength_js_to_rust = { + "Wide": 0, + "Short": 1, + "Narrow": 2, +}; + +export const ICU4XListLength_rust_to_js = { + [0]: "Wide", + [1]: "Short", + [2]: "Narrow", +}; + +export const ICU4XListLength = { + "Wide": "Wide", + "Short": "Short", + "Narrow": "Narrow", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XLocale.d.ts b/third_party/rust/icu_capi/js/include/ICU4XLocale.d.ts new file mode 100644 index 000000000000..935d45961f72 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLocale.d.ts @@ -0,0 +1,159 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XError } from "./ICU4XError"; +import { ICU4XOrdering } from "./ICU4XOrdering"; + +/** + + * An ICU4X Locale, capable of representing strings like `"en-US"`. + + * See the {@link https://docs.rs/icu/latest/icu/locid/struct.Locale.html Rust documentation for `Locale`} for more information. + */ +export class ICU4XLocale { + + /** + + * Construct an {@link ICU4XLocale `ICU4XLocale`} from an locale identifier. + + * This will run the complete locale parsing algorithm. If code size and performance are critical and the locale is of a known shape (such as `aa-BB`) use `create_und`, `set_language`, `set_script`, and `set_region`. + + * See the {@link https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.try_from_bytes Rust documentation for `try_from_bytes`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_from_string(name: string): ICU4XLocale | never; + + /** + + * Construct a default undefined {@link ICU4XLocale `ICU4XLocale`} "und". + + * See the {@link https://docs.rs/icu/latest/icu/locid/struct.Locale.html#associatedconstant.UND Rust documentation for `UND`} for more information. + */ + static create_und(): ICU4XLocale; + + /** + + * Clones the {@link ICU4XLocale `ICU4XLocale`}. + + * See the {@link https://docs.rs/icu/latest/icu/locid/struct.Locale.html Rust documentation for `Locale`} for more information. + */ + clone(): ICU4XLocale; + + /** + + * Write a string representation of the `LanguageIdentifier` part of {@link ICU4XLocale `ICU4XLocale`} to `write`. + + * See the {@link https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.id Rust documentation for `id`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + basename(): string | never; + + /** + + * Write a string representation of the unicode extension to `write` + + * See the {@link https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.extensions Rust documentation for `extensions`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + get_unicode_extension(bytes: string): string | never; + + /** + + * Write a string representation of {@link ICU4XLocale `ICU4XLocale`} language to `write` + + * See the {@link https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.id Rust documentation for `id`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + language(): string | never; + + /** + + * Set the language part of the {@link ICU4XLocale `ICU4XLocale`}. + + * See the {@link https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.try_from_bytes Rust documentation for `try_from_bytes`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + set_language(bytes: string): void | never; + + /** + + * Write a string representation of {@link ICU4XLocale `ICU4XLocale`} region to `write` + + * See the {@link https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.id Rust documentation for `id`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + region(): string | never; + + /** + + * Set the region part of the {@link ICU4XLocale `ICU4XLocale`}. + + * See the {@link https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.try_from_bytes Rust documentation for `try_from_bytes`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + set_region(bytes: string): void | never; + + /** + + * Write a string representation of {@link ICU4XLocale `ICU4XLocale`} script to `write` + + * See the {@link https://docs.rs/icu/latest/icu/locid/struct.Locale.html#structfield.id Rust documentation for `id`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + script(): string | never; + + /** + + * Set the script part of the {@link ICU4XLocale `ICU4XLocale`}. Pass an empty string to remove the script. + + * See the {@link https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.try_from_bytes Rust documentation for `try_from_bytes`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + set_script(bytes: string): void | never; + + /** + + * Best effort locale canonicalizer that doesn't need any data + + * Use ICU4XLocaleCanonicalizer for better control and functionality + + * See the {@link https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.canonicalize Rust documentation for `canonicalize`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static canonicalize(bytes: string): string | never; + + /** + + * Write a string representation of {@link ICU4XLocale `ICU4XLocale`} to `write` + + * See the {@link https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.write_to Rust documentation for `write_to`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + to_string(): string | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.normalizing_eq Rust documentation for `normalizing_eq`} for more information. + */ + normalizing_eq(other: string): boolean; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/locid/struct.Locale.html#method.strict_cmp Rust documentation for `strict_cmp`} for more information. + */ + strict_cmp(other: string): ICU4XOrdering; + + /** + + * Construct an {@link ICU4XLocale `ICU4XLocale`} for the English language. + + * This convenience constructor is intended for testing only and requires the `provider_test` feature. + */ + static create_en(): ICU4XLocale; + + /** + + * Construct an {@link ICU4XLocale `ICU4XLocale`} for the Bangla language. + + * This convenience constructor is intended for testing only and requires the `provider_test` feature. + */ + static create_bn(): ICU4XLocale; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLocale.js b/third_party/rust/icu_capi/js/include/ICU4XLocale.js new file mode 100644 index 000000000000..b3cb1398424f --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLocale.js @@ -0,0 +1,268 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XOrdering_js_to_rust, ICU4XOrdering_rust_to_js } from "./ICU4XOrdering.js" + +const ICU4XLocale_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XLocale_destroy(underlying); +}); + +export class ICU4XLocale { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XLocale_box_destroy_registry.register(this, underlying); + } + } + + static create_from_string(arg_name) { + const buf_arg_name = diplomatRuntime.DiplomatBuf.str(wasm, arg_name); + const diplomat_out = (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocale_create_from_string(diplomat_receive_buffer, buf_arg_name.ptr, buf_arg_name.size); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XLocale(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + buf_arg_name.free(); + return diplomat_out; + } + + static create_und() { + return new ICU4XLocale(wasm.ICU4XLocale_create_und(), true, []); + } + + clone() { + return new ICU4XLocale(wasm.ICU4XLocale_clone(this.underlying), true, []); + } + + basename() { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocale_basename(diplomat_receive_buffer, this.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + get_unicode_extension(arg_bytes) { + const buf_arg_bytes = diplomatRuntime.DiplomatBuf.str(wasm, arg_bytes); + const diplomat_out = diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocale_get_unicode_extension(diplomat_receive_buffer, this.underlying, buf_arg_bytes.ptr, buf_arg_bytes.size, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + buf_arg_bytes.free(); + return diplomat_out; + } + + language() { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocale_language(diplomat_receive_buffer, this.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + set_language(arg_bytes) { + const buf_arg_bytes = diplomatRuntime.DiplomatBuf.str(wasm, arg_bytes); + const diplomat_out = (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocale_set_language(diplomat_receive_buffer, this.underlying, buf_arg_bytes.ptr, buf_arg_bytes.size); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + buf_arg_bytes.free(); + return diplomat_out; + } + + region() { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocale_region(diplomat_receive_buffer, this.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + set_region(arg_bytes) { + const buf_arg_bytes = diplomatRuntime.DiplomatBuf.str(wasm, arg_bytes); + const diplomat_out = (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocale_set_region(diplomat_receive_buffer, this.underlying, buf_arg_bytes.ptr, buf_arg_bytes.size); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + buf_arg_bytes.free(); + return diplomat_out; + } + + script() { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocale_script(diplomat_receive_buffer, this.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + set_script(arg_bytes) { + const buf_arg_bytes = diplomatRuntime.DiplomatBuf.str(wasm, arg_bytes); + const diplomat_out = (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocale_set_script(diplomat_receive_buffer, this.underlying, buf_arg_bytes.ptr, buf_arg_bytes.size); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + buf_arg_bytes.free(); + return diplomat_out; + } + + static canonicalize(arg_bytes) { + const buf_arg_bytes = diplomatRuntime.DiplomatBuf.str(wasm, arg_bytes); + const diplomat_out = diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocale_canonicalize(diplomat_receive_buffer, buf_arg_bytes.ptr, buf_arg_bytes.size, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + buf_arg_bytes.free(); + return diplomat_out; + } + + to_string() { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocale_to_string(diplomat_receive_buffer, this.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + normalizing_eq(arg_other) { + const buf_arg_other = diplomatRuntime.DiplomatBuf.str(wasm, arg_other); + const diplomat_out = wasm.ICU4XLocale_normalizing_eq(this.underlying, buf_arg_other.ptr, buf_arg_other.size); + buf_arg_other.free(); + return diplomat_out; + } + + strict_cmp(arg_other) { + const buf_arg_other = diplomatRuntime.DiplomatBuf.str(wasm, arg_other); + const diplomat_out = ICU4XOrdering_rust_to_js[wasm.ICU4XLocale_strict_cmp(this.underlying, buf_arg_other.ptr, buf_arg_other.size)]; + buf_arg_other.free(); + return diplomat_out; + } + + static create_en() { + return new ICU4XLocale(wasm.ICU4XLocale_create_en(), true, []); + } + + static create_bn() { + return new ICU4XLocale(wasm.ICU4XLocale_create_bn(), true, []); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLocaleCanonicalizer.d.ts b/third_party/rust/icu_capi/js/include/ICU4XLocaleCanonicalizer.d.ts new file mode 100644 index 000000000000..120053d9993c --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLocaleCanonicalizer.d.ts @@ -0,0 +1,40 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XLocale } from "./ICU4XLocale"; +import { ICU4XTransformResult } from "./ICU4XTransformResult"; + +/** + + * A locale canonicalizer. + + * See the {@link https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleCanonicalizer.html Rust documentation for `LocaleCanonicalizer`} for more information. + */ +export class ICU4XLocaleCanonicalizer { + + /** + + * Create a new {@link ICU4XLocaleCanonicalizer `ICU4XLocaleCanonicalizer`}. + + * See the {@link https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleCanonicalizer.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create(provider: ICU4XDataProvider): ICU4XLocaleCanonicalizer | never; + + /** + + * Create a new {@link ICU4XLocaleCanonicalizer `ICU4XLocaleCanonicalizer`} with extended data. + + * See the {@link https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleCanonicalizer.html#method.try_new_with_expander_unstable Rust documentation for `try_new_with_expander_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_extended(provider: ICU4XDataProvider): ICU4XLocaleCanonicalizer | never; + + /** + + * FFI version of `LocaleCanonicalizer::canonicalize()`. + + * See the {@link https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleCanonicalizer.html#method.canonicalize Rust documentation for `canonicalize`} for more information. + */ + canonicalize(locale: ICU4XLocale): ICU4XTransformResult; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLocaleCanonicalizer.js b/third_party/rust/icu_capi/js/include/ICU4XLocaleCanonicalizer.js new file mode 100644 index 000000000000..8a5a98da83cb --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLocaleCanonicalizer.js @@ -0,0 +1,57 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XTransformResult_js_to_rust, ICU4XTransformResult_rust_to_js } from "./ICU4XTransformResult.js" + +const ICU4XLocaleCanonicalizer_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XLocaleCanonicalizer_destroy(underlying); +}); + +export class ICU4XLocaleCanonicalizer { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XLocaleCanonicalizer_box_destroy_registry.register(this, underlying); + } + } + + static create(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocaleCanonicalizer_create(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XLocaleCanonicalizer(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_extended(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocaleCanonicalizer_create_extended(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XLocaleCanonicalizer(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + canonicalize(arg_locale) { + return ICU4XTransformResult_rust_to_js[wasm.ICU4XLocaleCanonicalizer_canonicalize(this.underlying, arg_locale.underlying)]; + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLocaleDisplayNamesFormatter.d.ts b/third_party/rust/icu_capi/js/include/ICU4XLocaleDisplayNamesFormatter.d.ts new file mode 100644 index 000000000000..8b0f9584cbb3 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLocaleDisplayNamesFormatter.d.ts @@ -0,0 +1,30 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XDisplayNamesOptionsV1 } from "./ICU4XDisplayNamesOptionsV1"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XLocale } from "./ICU4XLocale"; + +/** + + * See the {@link https://docs.rs/icu/latest/icu/displaynames/struct.LocaleDisplayNamesFormatter.html Rust documentation for `LocaleDisplayNamesFormatter`} for more information. + */ +export class ICU4XLocaleDisplayNamesFormatter { + + /** + + * Creates a new `LocaleDisplayNamesFormatter` from locale data and an options bag. + + * See the {@link https://docs.rs/icu/latest/icu/displaynames/struct.LocaleDisplayNamesFormatter.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static try_new_unstable(provider: ICU4XDataProvider, locale: ICU4XLocale, options: ICU4XDisplayNamesOptionsV1): ICU4XLocaleDisplayNamesFormatter | never; + + /** + + * Returns the locale-specific display name of a locale. + + * See the {@link https://docs.rs/icu/latest/icu/displaynames/struct.LocaleDisplayNamesFormatter.html#method.of Rust documentation for `of`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + of(locale: ICU4XLocale): string | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLocaleDisplayNamesFormatter.js b/third_party/rust/icu_capi/js/include/ICU4XLocaleDisplayNamesFormatter.js new file mode 100644 index 000000000000..f7d87ac0b621 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLocaleDisplayNamesFormatter.js @@ -0,0 +1,60 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XDisplayNamesFallback_js_to_rust, ICU4XDisplayNamesFallback_rust_to_js } from "./ICU4XDisplayNamesFallback.js" +import { ICU4XDisplayNamesStyle_js_to_rust, ICU4XDisplayNamesStyle_rust_to_js } from "./ICU4XDisplayNamesStyle.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XLanguageDisplay_js_to_rust, ICU4XLanguageDisplay_rust_to_js } from "./ICU4XLanguageDisplay.js" + +const ICU4XLocaleDisplayNamesFormatter_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XLocaleDisplayNamesFormatter_destroy(underlying); +}); + +export class ICU4XLocaleDisplayNamesFormatter { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XLocaleDisplayNamesFormatter_box_destroy_registry.register(this, underlying); + } + } + + static try_new_unstable(arg_provider, arg_locale, arg_options) { + const field_style_arg_options = arg_options["style"]; + const field_fallback_arg_options = arg_options["fallback"]; + const field_language_display_arg_options = arg_options["language_display"]; + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocaleDisplayNamesFormatter_try_new_unstable(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying, ICU4XDisplayNamesStyle_js_to_rust[field_style_arg_options], ICU4XDisplayNamesFallback_js_to_rust[field_fallback_arg_options], ICU4XLanguageDisplay_js_to_rust[field_language_display_arg_options]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XLocaleDisplayNamesFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + of(arg_locale) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocaleDisplayNamesFormatter_of(diplomat_receive_buffer, this.underlying, arg_locale.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLocaleExpander.d.ts b/third_party/rust/icu_capi/js/include/ICU4XLocaleExpander.d.ts new file mode 100644 index 000000000000..8ac04e9bbd0b --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLocaleExpander.d.ts @@ -0,0 +1,48 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XLocale } from "./ICU4XLocale"; +import { ICU4XTransformResult } from "./ICU4XTransformResult"; + +/** + + * A locale expander. + + * See the {@link https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html Rust documentation for `LocaleExpander`} for more information. + */ +export class ICU4XLocaleExpander { + + /** + + * Create a new {@link ICU4XLocaleExpander `ICU4XLocaleExpander`}. + + * See the {@link https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create(provider: ICU4XDataProvider): ICU4XLocaleExpander | never; + + /** + + * Create a new {@link ICU4XLocaleExpander `ICU4XLocaleExpander`} with extended data. + + * See the {@link https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html#method.try_new_extended_unstable Rust documentation for `try_new_extended_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_extended(provider: ICU4XDataProvider): ICU4XLocaleExpander | never; + + /** + + * FFI version of `LocaleExpander::maximize()`. + + * See the {@link https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html#method.maximize Rust documentation for `maximize`} for more information. + */ + maximize(locale: ICU4XLocale): ICU4XTransformResult; + + /** + + * FFI version of `LocaleExpander::minimize()`. + + * See the {@link https://docs.rs/icu/latest/icu/locid_transform/struct.LocaleExpander.html#method.minimize Rust documentation for `minimize`} for more information. + */ + minimize(locale: ICU4XLocale): ICU4XTransformResult; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLocaleExpander.js b/third_party/rust/icu_capi/js/include/ICU4XLocaleExpander.js new file mode 100644 index 000000000000..439698b27e59 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLocaleExpander.js @@ -0,0 +1,61 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XTransformResult_js_to_rust, ICU4XTransformResult_rust_to_js } from "./ICU4XTransformResult.js" + +const ICU4XLocaleExpander_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XLocaleExpander_destroy(underlying); +}); + +export class ICU4XLocaleExpander { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XLocaleExpander_box_destroy_registry.register(this, underlying); + } + } + + static create(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocaleExpander_create(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XLocaleExpander(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_extended(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocaleExpander_create_extended(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XLocaleExpander(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + maximize(arg_locale) { + return ICU4XTransformResult_rust_to_js[wasm.ICU4XLocaleExpander_maximize(this.underlying, arg_locale.underlying)]; + } + + minimize(arg_locale) { + return ICU4XTransformResult_rust_to_js[wasm.ICU4XLocaleExpander_minimize(this.underlying, arg_locale.underlying)]; + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackConfig.d.ts b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackConfig.d.ts new file mode 100644 index 000000000000..a49ad3c74030 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackConfig.d.ts @@ -0,0 +1,12 @@ +import { ICU4XLocaleFallbackPriority } from "./ICU4XLocaleFallbackPriority"; + +/** + + * Collection of configurations for the ICU4X fallback algorithm. + + * See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackConfig.html Rust documentation for `LocaleFallbackConfig`} for more information. + */ +export class ICU4XLocaleFallbackConfig { + priority: ICU4XLocaleFallbackPriority; + extension_key: string; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackConfig.js b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackConfig.js new file mode 100644 index 000000000000..56e883cdaea8 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackConfig.js @@ -0,0 +1,13 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XLocaleFallbackPriority_js_to_rust, ICU4XLocaleFallbackPriority_rust_to_js } from "./ICU4XLocaleFallbackPriority.js" + +export class ICU4XLocaleFallbackConfig { + constructor(underlying, edges_a) { + this.priority = ICU4XLocaleFallbackPriority_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, underlying)]; + this.extension_key = (() => { + const [ptr, size] = new Uint32Array(wasm.memory.buffer, underlying + 4, 2); + return diplomatRuntime.readString(wasm, ptr, size); + })(); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackIterator.d.ts b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackIterator.d.ts new file mode 100644 index 000000000000..6f35f029823c --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackIterator.d.ts @@ -0,0 +1,26 @@ +import { ICU4XLocale } from "./ICU4XLocale"; + +/** + + * An iterator over the locale under fallback. + + * See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackIterator.html Rust documentation for `LocaleFallbackIterator`} for more information. + */ +export class ICU4XLocaleFallbackIterator { + + /** + + * Gets a snapshot of the current state of the locale. + + * See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackIterator.html#method.get Rust documentation for `get`} for more information. + */ + get(): ICU4XLocale; + + /** + + * Performs one step of the fallback algorithm, mutating the locale. + + * See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackIterator.html#method.step Rust documentation for `step`} for more information. + */ + step(): void; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackIterator.js b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackIterator.js new file mode 100644 index 000000000000..4540e3d7db26 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackIterator.js @@ -0,0 +1,26 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XLocale } from "./ICU4XLocale.js" + +const ICU4XLocaleFallbackIterator_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XLocaleFallbackIterator_destroy(underlying); +}); + +export class ICU4XLocaleFallbackIterator { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XLocaleFallbackIterator_box_destroy_registry.register(this, underlying); + } + } + + get() { + return new ICU4XLocale(wasm.ICU4XLocaleFallbackIterator_get(this.underlying), true, []); + } + + step() { + wasm.ICU4XLocaleFallbackIterator_step(this.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackPriority.d.ts b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackPriority.d.ts new file mode 100644 index 000000000000..2867901f143a --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackPriority.d.ts @@ -0,0 +1,18 @@ + +/** + + * Priority mode for the ICU4X fallback algorithm. + + * See the {@link https://docs.rs/icu_provider/latest/icu_provider/enum.FallbackPriority.html Rust documentation for `FallbackPriority`} for more information. + */ +export enum ICU4XLocaleFallbackPriority { + /** + */ + Language = 'Language', + /** + */ + Region = 'Region', + /** + */ + Collation = 'Collation', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackPriority.js b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackPriority.js new file mode 100644 index 000000000000..421e73fb71c8 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackPriority.js @@ -0,0 +1,20 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XLocaleFallbackPriority_js_to_rust = { + "Language": 0, + "Region": 1, + "Collation": 2, +}; + +export const ICU4XLocaleFallbackPriority_rust_to_js = { + [0]: "Language", + [1]: "Region", + [2]: "Collation", +}; + +export const ICU4XLocaleFallbackPriority = { + "Language": "Language", + "Region": "Region", + "Collation": "Collation", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbacker.d.ts b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbacker.d.ts new file mode 100644 index 000000000000..145863834ebd --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbacker.d.ts @@ -0,0 +1,40 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XLocaleFallbackConfig } from "./ICU4XLocaleFallbackConfig"; +import { ICU4XLocaleFallbackerWithConfig } from "./ICU4XLocaleFallbackerWithConfig"; + +/** + + * An object that runs the ICU4X locale fallback algorithm. + + * See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbacker.html Rust documentation for `LocaleFallbacker`} for more information. + */ +export class ICU4XLocaleFallbacker { + + /** + + * Creates a new `ICU4XLocaleFallbacker` from a data provider. + + * See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbacker.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create(provider: ICU4XDataProvider): ICU4XLocaleFallbacker | never; + + /** + + * Creates a new `ICU4XLocaleFallbacker` without data for limited functionality. + + * See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbacker.html#method.new_without_data Rust documentation for `new_without_data`} for more information. + */ + static create_without_data(): ICU4XLocaleFallbacker; + + /** + + * Associates this `ICU4XLocaleFallbacker` with configuration options. + + * See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbacker.html#method.for_config Rust documentation for `for_config`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + for_config(config: ICU4XLocaleFallbackConfig): ICU4XLocaleFallbackerWithConfig | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbacker.js b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbacker.js new file mode 100644 index 000000000000..0ec01f33f309 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbacker.js @@ -0,0 +1,63 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XLocaleFallbackPriority_js_to_rust, ICU4XLocaleFallbackPriority_rust_to_js } from "./ICU4XLocaleFallbackPriority.js" +import { ICU4XLocaleFallbackerWithConfig } from "./ICU4XLocaleFallbackerWithConfig.js" + +const ICU4XLocaleFallbacker_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XLocaleFallbacker_destroy(underlying); +}); + +export class ICU4XLocaleFallbacker { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XLocaleFallbacker_box_destroy_registry.register(this, underlying); + } + } + + static create(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocaleFallbacker_create(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XLocaleFallbacker(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_without_data() { + return new ICU4XLocaleFallbacker(wasm.ICU4XLocaleFallbacker_create_without_data(), true, []); + } + + for_config(arg_config) { + const field_priority_arg_config = arg_config["priority"]; + const field_extension_key_arg_config = arg_config["extension_key"]; + const buf_field_extension_key_arg_config = diplomatRuntime.DiplomatBuf.str(wasm, field_extension_key_arg_config); + const diplomat_out = (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XLocaleFallbacker_for_config(diplomat_receive_buffer, this.underlying, ICU4XLocaleFallbackPriority_js_to_rust[field_priority_arg_config], buf_field_extension_key_arg_config.ptr, buf_field_extension_key_arg_config.size); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XLocaleFallbackerWithConfig(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, [this]); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + buf_field_extension_key_arg_config.free(); + return diplomat_out; + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackerWithConfig.d.ts b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackerWithConfig.d.ts new file mode 100644 index 000000000000..f3d220238f6c --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackerWithConfig.d.ts @@ -0,0 +1,19 @@ +import { ICU4XLocale } from "./ICU4XLocale"; +import { ICU4XLocaleFallbackIterator } from "./ICU4XLocaleFallbackIterator"; + +/** + + * An object that runs the ICU4X locale fallback algorithm with specific configurations. + + * See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackerWithConfig.html Rust documentation for `LocaleFallbackerWithConfig`} for more information. + */ +export class ICU4XLocaleFallbackerWithConfig { + + /** + + * Creates an iterator from a locale with each step of fallback. + + * See the {@link https://docs.rs/icu_provider_adapters/latest/icu_provider_adapters/fallback/struct.LocaleFallbackerWithConfig.html#method.fallback_for Rust documentation for `fallback_for`} for more information. + */ + fallback_for_locale(locale: ICU4XLocale): ICU4XLocaleFallbackIterator; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackerWithConfig.js b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackerWithConfig.js new file mode 100644 index 000000000000..632654df03b0 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLocaleFallbackerWithConfig.js @@ -0,0 +1,22 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XLocaleFallbackIterator } from "./ICU4XLocaleFallbackIterator.js" + +const ICU4XLocaleFallbackerWithConfig_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XLocaleFallbackerWithConfig_destroy(underlying); +}); + +export class ICU4XLocaleFallbackerWithConfig { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XLocaleFallbackerWithConfig_box_destroy_registry.register(this, underlying); + } + } + + fallback_for_locale(arg_locale) { + return new ICU4XLocaleFallbackIterator(wasm.ICU4XLocaleFallbackerWithConfig_fallback_for_locale(this.underlying, arg_locale.underlying), true, [this]); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLogger.d.ts b/third_party/rust/icu_capi/js/include/ICU4XLogger.d.ts new file mode 100644 index 000000000000..2b33c03234b6 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLogger.d.ts @@ -0,0 +1,13 @@ + +/** + + * An object allowing control over the logging used + */ +export class ICU4XLogger { + + /** + + * Initialize the logger from the `simple_logger` crate, which simply logs to stdout. Returns `false` if there was already a logger set, or if logging has not been compiled into the platform + */ + static init_simple_logger(): boolean; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XLogger.js b/third_party/rust/icu_capi/js/include/ICU4XLogger.js new file mode 100644 index 000000000000..03aaae2d3075 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XLogger.js @@ -0,0 +1,21 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +const ICU4XLogger_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XLogger_destroy(underlying); +}); + +export class ICU4XLogger { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XLogger_box_destroy_registry.register(this, underlying); + } + } + + static init_simple_logger() { + return wasm.ICU4XLogger_init_simple_logger(); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XMetazoneCalculator.d.ts b/third_party/rust/icu_capi/js/include/ICU4XMetazoneCalculator.d.ts new file mode 100644 index 000000000000..988f756e798a --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XMetazoneCalculator.d.ts @@ -0,0 +1,21 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; + +/** + + * An object capable of computing the metazone from a timezone. + + * This can be used via `maybe_calculate_metazone()` on {@link crate::timezone::ffi::ICU4XCustomTimeZone; `ICU4XCustomTimeZone`}. + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.MetazoneCalculator.html Rust documentation for `MetazoneCalculator`} for more information. + */ +export class ICU4XMetazoneCalculator { + + /** + + * See the {@link https://docs.rs/icu/latest/icu/timezone/struct.MetazoneCalculator.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create(provider: ICU4XDataProvider): ICU4XMetazoneCalculator | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XMetazoneCalculator.js b/third_party/rust/icu_capi/js/include/ICU4XMetazoneCalculator.js new file mode 100644 index 000000000000..a72b56af0c23 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XMetazoneCalculator.js @@ -0,0 +1,35 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XMetazoneCalculator_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XMetazoneCalculator_destroy(underlying); +}); + +export class ICU4XMetazoneCalculator { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XMetazoneCalculator_box_destroy_registry.register(this, underlying); + } + } + + static create(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XMetazoneCalculator_create(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XMetazoneCalculator(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XOrdering.d.ts b/third_party/rust/icu_capi/js/include/ICU4XOrdering.d.ts new file mode 100644 index 000000000000..1567229a9b34 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XOrdering.d.ts @@ -0,0 +1,16 @@ + +/** + + * See the {@link https://docs.rs/core/latest/core/cmp/enum.Ordering.html Rust documentation for `Ordering`} for more information. + */ +export enum ICU4XOrdering { + /** + */ + Less = 'Less', + /** + */ + Equal = 'Equal', + /** + */ + Greater = 'Greater', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XOrdering.js b/third_party/rust/icu_capi/js/include/ICU4XOrdering.js new file mode 100644 index 000000000000..fb86968e7032 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XOrdering.js @@ -0,0 +1,20 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XOrdering_js_to_rust = { + "Less": -1, + "Equal": 0, + "Greater": 1, +}; + +export const ICU4XOrdering_rust_to_js = { + [-1]: "Less", + [0]: "Equal", + [1]: "Greater", +}; + +export const ICU4XOrdering = { + "Less": "Less", + "Equal": "Equal", + "Greater": "Greater", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XPluralCategories.d.ts b/third_party/rust/icu_capi/js/include/ICU4XPluralCategories.d.ts new file mode 100644 index 000000000000..f74b1f4f935f --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XPluralCategories.d.ts @@ -0,0 +1,13 @@ + +/** + + * FFI version of `PluralRules::categories()` data. + */ +export class ICU4XPluralCategories { + zero: boolean; + one: boolean; + two: boolean; + few: boolean; + many: boolean; + other: boolean; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XPluralCategories.js b/third_party/rust/icu_capi/js/include/ICU4XPluralCategories.js new file mode 100644 index 000000000000..84e8fcf1ce17 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XPluralCategories.js @@ -0,0 +1,13 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export class ICU4XPluralCategories { + constructor(underlying) { + this.zero = (new Uint8Array(wasm.memory.buffer, underlying, 1))[0] == 1; + this.one = (new Uint8Array(wasm.memory.buffer, underlying + 1, 1))[0] == 1; + this.two = (new Uint8Array(wasm.memory.buffer, underlying + 2, 1))[0] == 1; + this.few = (new Uint8Array(wasm.memory.buffer, underlying + 3, 1))[0] == 1; + this.many = (new Uint8Array(wasm.memory.buffer, underlying + 4, 1))[0] == 1; + this.other = (new Uint8Array(wasm.memory.buffer, underlying + 5, 1))[0] == 1; + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XPluralCategory.d.ts b/third_party/rust/icu_capi/js/include/ICU4XPluralCategory.d.ts new file mode 100644 index 000000000000..7b1a9831c098 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XPluralCategory.d.ts @@ -0,0 +1,28 @@ +import { FFIError } from "./diplomat-runtime" + +/** + + * FFI version of `PluralCategory`. + + * See the {@link https://docs.rs/icu/latest/icu/plurals/enum.PluralCategory.html Rust documentation for `PluralCategory`} for more information. + */ +export enum ICU4XPluralCategory { + /** + */ + Zero = 'Zero', + /** + */ + One = 'One', + /** + */ + Two = 'Two', + /** + */ + Few = 'Few', + /** + */ + Many = 'Many', + /** + */ + Other = 'Other', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XPluralCategory.js b/third_party/rust/icu_capi/js/include/ICU4XPluralCategory.js new file mode 100644 index 000000000000..299abbb4b0d7 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XPluralCategory.js @@ -0,0 +1,29 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XPluralCategory_js_to_rust = { + "Zero": 0, + "One": 1, + "Two": 2, + "Few": 3, + "Many": 4, + "Other": 5, +}; + +export const ICU4XPluralCategory_rust_to_js = { + [0]: "Zero", + [1]: "One", + [2]: "Two", + [3]: "Few", + [4]: "Many", + [5]: "Other", +}; + +export const ICU4XPluralCategory = { + "Zero": "Zero", + "One": "One", + "Two": "Two", + "Few": "Few", + "Many": "Many", + "Other": "Other", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XPluralOperands.d.ts b/third_party/rust/icu_capi/js/include/ICU4XPluralOperands.d.ts new file mode 100644 index 000000000000..a521100d17a8 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XPluralOperands.d.ts @@ -0,0 +1,20 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XError } from "./ICU4XError"; + +/** + + * FFI version of `PluralOperands`. + + * See the {@link https://docs.rs/icu/latest/icu/plurals/struct.PluralOperands.html Rust documentation for `PluralOperands`} for more information. + */ +export class ICU4XPluralOperands { + + /** + + * Construct for a given string representing a number + + * See the {@link https://docs.rs/icu/latest/icu/plurals/struct.PluralOperands.html#method.from_str Rust documentation for `from_str`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_from_string(s: string): ICU4XPluralOperands | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XPluralOperands.js b/third_party/rust/icu_capi/js/include/ICU4XPluralOperands.js new file mode 100644 index 000000000000..6fdffaef2adb --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XPluralOperands.js @@ -0,0 +1,38 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XPluralOperands_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XPluralOperands_destroy(underlying); +}); + +export class ICU4XPluralOperands { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XPluralOperands_box_destroy_registry.register(this, underlying); + } + } + + static create_from_string(arg_s) { + const buf_arg_s = diplomatRuntime.DiplomatBuf.str(wasm, arg_s); + const diplomat_out = (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XPluralOperands_create_from_string(diplomat_receive_buffer, buf_arg_s.ptr, buf_arg_s.size); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XPluralOperands(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + buf_arg_s.free(); + return diplomat_out; + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XPluralRules.d.ts b/third_party/rust/icu_capi/js/include/ICU4XPluralRules.d.ts new file mode 100644 index 000000000000..0d250e7beb6d --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XPluralRules.d.ts @@ -0,0 +1,50 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XLocale } from "./ICU4XLocale"; +import { ICU4XPluralCategories } from "./ICU4XPluralCategories"; +import { ICU4XPluralCategory } from "./ICU4XPluralCategory"; +import { ICU4XPluralOperands } from "./ICU4XPluralOperands"; + +/** + + * FFI version of `PluralRules`. + + * See the {@link https://docs.rs/icu/latest/icu/plurals/struct.PluralRules.html Rust documentation for `PluralRules`} for more information. + */ +export class ICU4XPluralRules { + + /** + + * Construct an {@link ICU4XPluralRules `ICU4XPluralRules`} for the given locale, for cardinal numbers + + * See the {@link https://docs.rs/icu/latest/icu/plurals/struct.PluralRules.html#method.try_new_cardinal_unstable Rust documentation for `try_new_cardinal_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_cardinal(provider: ICU4XDataProvider, locale: ICU4XLocale): ICU4XPluralRules | never; + + /** + + * Construct an {@link ICU4XPluralRules `ICU4XPluralRules`} for the given locale, for ordinal numbers + + * See the {@link https://docs.rs/icu/latest/icu/plurals/struct.PluralRules.html#method.try_new_ordinal_unstable Rust documentation for `try_new_ordinal_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_ordinal(provider: ICU4XDataProvider, locale: ICU4XLocale): ICU4XPluralRules | never; + + /** + + * Get the category for a given number represented as operands + + * See the {@link https://docs.rs/icu/latest/icu/plurals/struct.PluralRules.html#method.category_for Rust documentation for `category_for`} for more information. + */ + category_for(op: ICU4XPluralOperands): ICU4XPluralCategory; + + /** + + * Get all of the categories needed in the current locale + + * See the {@link https://docs.rs/icu/latest/icu/plurals/struct.PluralRules.html#method.categories Rust documentation for `categories`} for more information. + */ + categories(): ICU4XPluralCategories; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XPluralRules.js b/third_party/rust/icu_capi/js/include/ICU4XPluralRules.js new file mode 100644 index 000000000000..bb78fd8ab51f --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XPluralRules.js @@ -0,0 +1,68 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XPluralCategories } from "./ICU4XPluralCategories.js" +import { ICU4XPluralCategory_js_to_rust, ICU4XPluralCategory_rust_to_js } from "./ICU4XPluralCategory.js" + +const ICU4XPluralRules_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XPluralRules_destroy(underlying); +}); + +export class ICU4XPluralRules { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XPluralRules_box_destroy_registry.register(this, underlying); + } + } + + static create_cardinal(arg_provider, arg_locale) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XPluralRules_create_cardinal(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XPluralRules(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_ordinal(arg_provider, arg_locale) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XPluralRules_create_ordinal(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XPluralRules(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + category_for(arg_op) { + return ICU4XPluralCategory_rust_to_js[wasm.ICU4XPluralRules_category_for(this.underlying, arg_op.underlying)]; + } + + categories() { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(6, 1); + wasm.ICU4XPluralRules_categories(diplomat_receive_buffer, this.underlying); + const out = new ICU4XPluralCategories(diplomat_receive_buffer); + wasm.diplomat_free(diplomat_receive_buffer, 6, 1); + return out; + })(); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XPropertyValueNameToEnumMapper.d.ts b/third_party/rust/icu_capi/js/include/ICU4XPropertyValueNameToEnumMapper.d.ts new file mode 100644 index 000000000000..fbb101a54b4c --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XPropertyValueNameToEnumMapper.d.ts @@ -0,0 +1,91 @@ +import { i16 } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; + +/** + + * A type capable of looking up a property value from a string name. + + * See the {@link https://docs.rs/icu/latest/icu/properties/names/struct.PropertyValueNameToEnumMapper.html Rust documentation for `PropertyValueNameToEnumMapper`} for more information. + + * See the {@link https://docs.rs/icu/latest/icu/properties/names/struct.PropertyValueNameToEnumMapperBorrowed.html Rust documentation for `PropertyValueNameToEnumMapperBorrowed`} for more information. + */ +export class ICU4XPropertyValueNameToEnumMapper { + + /** + + * Get the property value matching the given name, using strict matching + + * Returns -1 if the name is unknown for this property + + * See the {@link https://docs.rs/icu/latest/icu/properties/names/struct.PropertyValueNameToEnumMapperBorrowed.html#method.get_strict Rust documentation for `get_strict`} for more information. + */ + get_strict(name: string): i16; + + /** + + * Get the property value matching the given name, using loose matching + + * Returns -1 if the name is unknown for this property + + * See the {@link https://docs.rs/icu/latest/icu/properties/names/struct.PropertyValueNameToEnumMapperBorrowed.html#method.get_loose Rust documentation for `get_loose`} for more information. + */ + get_loose(name: string): i16; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/struct.GeneralCategory.html#method.get_name_to_enum_mapper Rust documentation for `get_name_to_enum_mapper`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_general_category(provider: ICU4XDataProvider): ICU4XPropertyValueNameToEnumMapper | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/struct.BidiClass.html#method.get_name_to_enum_mapper Rust documentation for `get_name_to_enum_mapper`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_bidi_class(provider: ICU4XDataProvider): ICU4XPropertyValueNameToEnumMapper | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/struct.EastAsianWidth.html#method.get_name_to_enum_mapper Rust documentation for `get_name_to_enum_mapper`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_east_asian_width(provider: ICU4XDataProvider): ICU4XPropertyValueNameToEnumMapper | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/struct.LineBreak.html#method.get_name_to_enum_mapper Rust documentation for `get_name_to_enum_mapper`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_line_break(provider: ICU4XDataProvider): ICU4XPropertyValueNameToEnumMapper | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/struct.GraphemeClusterBreak.html#method.get_name_to_enum_mapper Rust documentation for `get_name_to_enum_mapper`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_grapheme_cluster_break(provider: ICU4XDataProvider): ICU4XPropertyValueNameToEnumMapper | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/struct.WordBreak.html#method.get_name_to_enum_mapper Rust documentation for `get_name_to_enum_mapper`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_word_break(provider: ICU4XDataProvider): ICU4XPropertyValueNameToEnumMapper | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/struct.SentenceBreak.html#method.get_name_to_enum_mapper Rust documentation for `get_name_to_enum_mapper`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_sentence_break(provider: ICU4XDataProvider): ICU4XPropertyValueNameToEnumMapper | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/struct.Script.html#method.get_name_to_enum_mapper Rust documentation for `get_name_to_enum_mapper`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_script(provider: ICU4XDataProvider): ICU4XPropertyValueNameToEnumMapper | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XPropertyValueNameToEnumMapper.js b/third_party/rust/icu_capi/js/include/ICU4XPropertyValueNameToEnumMapper.js new file mode 100644 index 000000000000..2029aab5085a --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XPropertyValueNameToEnumMapper.js @@ -0,0 +1,168 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XPropertyValueNameToEnumMapper_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XPropertyValueNameToEnumMapper_destroy(underlying); +}); + +export class ICU4XPropertyValueNameToEnumMapper { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XPropertyValueNameToEnumMapper_box_destroy_registry.register(this, underlying); + } + } + + get_strict(arg_name) { + const buf_arg_name = diplomatRuntime.DiplomatBuf.str(wasm, arg_name); + const diplomat_out = wasm.ICU4XPropertyValueNameToEnumMapper_get_strict(this.underlying, buf_arg_name.ptr, buf_arg_name.size); + buf_arg_name.free(); + return diplomat_out; + } + + get_loose(arg_name) { + const buf_arg_name = diplomatRuntime.DiplomatBuf.str(wasm, arg_name); + const diplomat_out = wasm.ICU4XPropertyValueNameToEnumMapper_get_loose(this.underlying, buf_arg_name.ptr, buf_arg_name.size); + buf_arg_name.free(); + return diplomat_out; + } + + static load_general_category(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XPropertyValueNameToEnumMapper_load_general_category(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XPropertyValueNameToEnumMapper(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_bidi_class(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XPropertyValueNameToEnumMapper_load_bidi_class(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XPropertyValueNameToEnumMapper(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_east_asian_width(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XPropertyValueNameToEnumMapper_load_east_asian_width(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XPropertyValueNameToEnumMapper(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_line_break(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XPropertyValueNameToEnumMapper_load_line_break(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XPropertyValueNameToEnumMapper(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_grapheme_cluster_break(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XPropertyValueNameToEnumMapper_load_grapheme_cluster_break(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XPropertyValueNameToEnumMapper(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_word_break(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XPropertyValueNameToEnumMapper_load_word_break(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XPropertyValueNameToEnumMapper(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_sentence_break(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XPropertyValueNameToEnumMapper_load_sentence_break(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XPropertyValueNameToEnumMapper(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_script(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XPropertyValueNameToEnumMapper_load_script(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XPropertyValueNameToEnumMapper(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XRegionDisplayNames.d.ts b/third_party/rust/icu_capi/js/include/ICU4XRegionDisplayNames.d.ts new file mode 100644 index 000000000000..3bb733b416e4 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XRegionDisplayNames.d.ts @@ -0,0 +1,29 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XLocale } from "./ICU4XLocale"; + +/** + + * See the {@link https://docs.rs/icu/latest/icu/displaynames/struct.RegionDisplayNames.html Rust documentation for `RegionDisplayNames`} for more information. + */ +export class ICU4XRegionDisplayNames { + + /** + + * Creates a new `RegionDisplayNames` from locale data and an options bag. + + * See the {@link https://docs.rs/icu/latest/icu/displaynames/struct.RegionDisplayNames.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static try_new_unstable(provider: ICU4XDataProvider, locale: ICU4XLocale): ICU4XRegionDisplayNames | never; + + /** + + * Returns the locale specific display name of a region. Note that the funtion returns an empty string in case the display name for a given region code is not found. + + * See the {@link https://docs.rs/icu/latest/icu/displaynames/struct.RegionDisplayNames.html#method.of Rust documentation for `of`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + of(region: string): string | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XRegionDisplayNames.js b/third_party/rust/icu_capi/js/include/ICU4XRegionDisplayNames.js new file mode 100644 index 000000000000..76277a20a067 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XRegionDisplayNames.js @@ -0,0 +1,57 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XRegionDisplayNames_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XRegionDisplayNames_destroy(underlying); +}); + +export class ICU4XRegionDisplayNames { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XRegionDisplayNames_box_destroy_registry.register(this, underlying); + } + } + + static try_new_unstable(arg_provider, arg_locale) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XRegionDisplayNames_try_new_unstable(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XRegionDisplayNames(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + of(arg_region) { + const buf_arg_region = diplomatRuntime.DiplomatBuf.str(wasm, arg_region); + const diplomat_out = diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XRegionDisplayNames_of(diplomat_receive_buffer, this.underlying, buf_arg_region.ptr, buf_arg_region.size, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + buf_arg_region.free(); + return diplomat_out; + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XReorderedIndexMap.d.ts b/third_party/rust/icu_capi/js/include/ICU4XReorderedIndexMap.d.ts new file mode 100644 index 000000000000..ef6889f2ae61 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XReorderedIndexMap.d.ts @@ -0,0 +1,30 @@ +import { usize } from "./diplomat-runtime" + +/** + + * Thin wrapper around a vector that maps visual indices to source indices + + * `map[visualIndex] = sourceIndex` + + * Produced by `reorder_visual()` on {@link ICU4XBidi `ICU4XBidi`}. + */ +export class ICU4XReorderedIndexMap { + + /** + + * Get this as a slice/array of indices + */ + as_slice(): Uint32Array; + + /** + + * The length of this map + */ + len(): usize; + + /** + + * Get element at `index`. Returns 0 when out of bounds (note that 0 is also a valid in-bounds value, please use `len()` to avoid out-of-bounds) + */ + get(index: usize): usize; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XReorderedIndexMap.js b/third_party/rust/icu_capi/js/include/ICU4XReorderedIndexMap.js new file mode 100644 index 000000000000..46ad3060c1a9 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XReorderedIndexMap.js @@ -0,0 +1,35 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +const ICU4XReorderedIndexMap_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XReorderedIndexMap_destroy(underlying); +}); + +export class ICU4XReorderedIndexMap { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XReorderedIndexMap_box_destroy_registry.register(this, underlying); + } + } + + as_slice() { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(8, 4); + wasm.ICU4XReorderedIndexMap_as_slice(diplomat_receive_buffer, this.underlying); + const [ptr, size] = new Uint32Array(wasm.memory.buffer, diplomat_receive_buffer, 2); + wasm.diplomat_free(diplomat_receive_buffer, 8, 4); + return new Uint32Array(wasm.memory.buffer, ptr, size); + })(); + } + + len() { + return wasm.ICU4XReorderedIndexMap_len(this.underlying); + } + + get(arg_index) { + return wasm.ICU4XReorderedIndexMap_get(this.underlying, arg_index); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XScriptExtensionsSet.d.ts b/third_party/rust/icu_capi/js/include/ICU4XScriptExtensionsSet.d.ts new file mode 100644 index 000000000000..dcef951fcb94 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XScriptExtensionsSet.d.ts @@ -0,0 +1,36 @@ +import { u16, usize } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" + +/** + + * An object that represents the Script_Extensions property for a single character + + * See the {@link https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html Rust documentation for `ScriptExtensionsSet`} for more information. + */ +export class ICU4XScriptExtensionsSet { + + /** + + * Check if the Script_Extensions property of the given code point covers the given script + + * See the {@link https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html#method.contains Rust documentation for `contains`} for more information. + */ + contains(script: u16): boolean; + + /** + + * Get the number of scripts contained in here + + * See the {@link https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html#method.iter Rust documentation for `iter`} for more information. + */ + count(): usize; + + /** + + * Get script at index, returning an error if out of bounds + + * See the {@link https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html#method.iter Rust documentation for `iter`} for more information. + * @throws {@link FFIError} + */ + script_at(index: usize): u16 | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XScriptExtensionsSet.js b/third_party/rust/icu_capi/js/include/ICU4XScriptExtensionsSet.js new file mode 100644 index 000000000000..c0a95a662b09 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XScriptExtensionsSet.js @@ -0,0 +1,42 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +const ICU4XScriptExtensionsSet_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XScriptExtensionsSet_destroy(underlying); +}); + +export class ICU4XScriptExtensionsSet { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XScriptExtensionsSet_box_destroy_registry.register(this, underlying); + } + } + + contains(arg_script) { + return wasm.ICU4XScriptExtensionsSet_contains(this.underlying, arg_script); + } + + count() { + return wasm.ICU4XScriptExtensionsSet_count(this.underlying); + } + + script_at(arg_index) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(3, 2); + wasm.ICU4XScriptExtensionsSet_script_at(diplomat_receive_buffer, this.underlying, arg_index); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 2); + if (is_ok) { + const ok_value = (new Uint16Array(wasm.memory.buffer, diplomat_receive_buffer, 1))[0]; + wasm.diplomat_free(diplomat_receive_buffer, 3, 2); + return ok_value; + } else { + const throw_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 3, 2); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XScriptWithExtensions.d.ts b/third_party/rust/icu_capi/js/include/ICU4XScriptWithExtensions.d.ts new file mode 100644 index 000000000000..4b7dbe45f1bb --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XScriptWithExtensions.d.ts @@ -0,0 +1,54 @@ +import { u16, u32 } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { CodePointRangeIterator } from "./CodePointRangeIterator"; +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XScriptWithExtensionsBorrowed } from "./ICU4XScriptWithExtensionsBorrowed"; + +/** + + * An ICU4X ScriptWithExtensions map object, capable of holding a map of codepoints to scriptextensions values + + * See the {@link https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensions.html Rust documentation for `ScriptWithExtensions`} for more information. + */ +export class ICU4XScriptWithExtensions { + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/script/fn.load_script_with_extensions_unstable.html Rust documentation for `load_script_with_extensions_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create(provider: ICU4XDataProvider): ICU4XScriptWithExtensions | never; + + /** + + * Get the Script property value for a code point + + * See the {@link https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.get_script_val Rust documentation for `get_script_val`} for more information. + */ + get_script_val(code_point: u32): u16; + + /** + + * Check if the Script_Extensions property of the given code point covers the given script + + * See the {@link https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.has_script Rust documentation for `has_script`} for more information. + */ + has_script(code_point: u32, script: u16): boolean; + + /** + + * Borrow this object for a slightly faster variant with more operations + + * See the {@link https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensions.html#method.as_borrowed Rust documentation for `as_borrowed`} for more information. + */ + as_borrowed(): ICU4XScriptWithExtensionsBorrowed; + + /** + + * Get a list of ranges of code points that contain this script in their Script_Extensions values + + * See the {@link https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.get_script_extensions_ranges Rust documentation for `get_script_extensions_ranges`} for more information. + */ + iter_ranges_for_script(script: u16): CodePointRangeIterator; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XScriptWithExtensions.js b/third_party/rust/icu_capi/js/include/ICU4XScriptWithExtensions.js new file mode 100644 index 000000000000..fc5be89c8726 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XScriptWithExtensions.js @@ -0,0 +1,53 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { CodePointRangeIterator } from "./CodePointRangeIterator.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XScriptWithExtensionsBorrowed } from "./ICU4XScriptWithExtensionsBorrowed.js" + +const ICU4XScriptWithExtensions_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XScriptWithExtensions_destroy(underlying); +}); + +export class ICU4XScriptWithExtensions { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XScriptWithExtensions_box_destroy_registry.register(this, underlying); + } + } + + static create(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XScriptWithExtensions_create(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XScriptWithExtensions(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + get_script_val(arg_code_point) { + return wasm.ICU4XScriptWithExtensions_get_script_val(this.underlying, arg_code_point); + } + + has_script(arg_code_point, arg_script) { + return wasm.ICU4XScriptWithExtensions_has_script(this.underlying, arg_code_point, arg_script); + } + + as_borrowed() { + return new ICU4XScriptWithExtensionsBorrowed(wasm.ICU4XScriptWithExtensions_as_borrowed(this.underlying), true, [this]); + } + + iter_ranges_for_script(arg_script) { + return new CodePointRangeIterator(wasm.ICU4XScriptWithExtensions_iter_ranges_for_script(this.underlying, arg_script), true, [this]); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XScriptWithExtensionsBorrowed.d.ts b/third_party/rust/icu_capi/js/include/ICU4XScriptWithExtensionsBorrowed.d.ts new file mode 100644 index 000000000000..81d6f132f8c1 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XScriptWithExtensionsBorrowed.d.ts @@ -0,0 +1,35 @@ +import { u16, u32 } from "./diplomat-runtime" +import { ICU4XScriptExtensionsSet } from "./ICU4XScriptExtensionsSet"; + +/** + + * A slightly faster ICU4XScriptWithExtensions object + + * See the {@link https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html Rust documentation for `ScriptWithExtensionsBorrowed`} for more information. + */ +export class ICU4XScriptWithExtensionsBorrowed { + + /** + + * Get the Script property value for a code point + + * See the {@link https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.get_script_val Rust documentation for `get_script_val`} for more information. + */ + get_script_val(code_point: u32): u16; + + /** + + * Get the Script property value for a code point + + * See the {@link https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.get_script_extensions_val Rust documentation for `get_script_extensions_val`} for more information. + */ + get_script_extensions_val(code_point: u32): ICU4XScriptExtensionsSet; + + /** + + * Check if the Script_Extensions property of the given code point covers the given script + + * See the {@link https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.has_script Rust documentation for `has_script`} for more information. + */ + has_script(code_point: u32, script: u16): boolean; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XScriptWithExtensionsBorrowed.js b/third_party/rust/icu_capi/js/include/ICU4XScriptWithExtensionsBorrowed.js new file mode 100644 index 000000000000..235d387d8a4b --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XScriptWithExtensionsBorrowed.js @@ -0,0 +1,30 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XScriptExtensionsSet } from "./ICU4XScriptExtensionsSet.js" + +const ICU4XScriptWithExtensionsBorrowed_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XScriptWithExtensionsBorrowed_destroy(underlying); +}); + +export class ICU4XScriptWithExtensionsBorrowed { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XScriptWithExtensionsBorrowed_box_destroy_registry.register(this, underlying); + } + } + + get_script_val(arg_code_point) { + return wasm.ICU4XScriptWithExtensionsBorrowed_get_script_val(this.underlying, arg_code_point); + } + + get_script_extensions_val(arg_code_point) { + return new ICU4XScriptExtensionsSet(wasm.ICU4XScriptWithExtensionsBorrowed_get_script_extensions_val(this.underlying, arg_code_point), true, [this]); + } + + has_script(arg_code_point, arg_script) { + return wasm.ICU4XScriptWithExtensionsBorrowed_has_script(this.underlying, arg_code_point, arg_script); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XSegmenterWordType.d.ts b/third_party/rust/icu_capi/js/include/ICU4XSegmenterWordType.d.ts new file mode 100644 index 000000000000..35eae4becf08 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XSegmenterWordType.d.ts @@ -0,0 +1,16 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/enum.WordType.html Rust documentation for `WordType`} for more information. + */ +export enum ICU4XSegmenterWordType { + /** + */ + None = 'None', + /** + */ + Number = 'Number', + /** + */ + Letter = 'Letter', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XSegmenterWordType.js b/third_party/rust/icu_capi/js/include/ICU4XSegmenterWordType.js new file mode 100644 index 000000000000..390fdb45ca42 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XSegmenterWordType.js @@ -0,0 +1,20 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XSegmenterWordType_js_to_rust = { + "None": 0, + "Number": 1, + "Letter": 2, +}; + +export const ICU4XSegmenterWordType_rust_to_js = { + [0]: "None", + [1]: "Number", + [2]: "Letter", +}; + +export const ICU4XSegmenterWordType = { + "None": "None", + "Number": "Number", + "Letter": "Letter", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorLatin1.d.ts b/third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorLatin1.d.ts new file mode 100644 index 000000000000..1601ae83ba05 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorLatin1.d.ts @@ -0,0 +1,16 @@ +import { i32 } from "./diplomat-runtime" + +/** + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.SentenceBreakIterator.html Rust documentation for `SentenceBreakIterator`} for more information. + */ +export class ICU4XSentenceBreakIteratorLatin1 { + + /** + + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is out of range of a 32-bit signed integer. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.SentenceBreakIterator.html#method.next Rust documentation for `next`} for more information. + */ + next(): i32; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorLatin1.js b/third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorLatin1.js new file mode 100644 index 000000000000..674e015a7d06 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorLatin1.js @@ -0,0 +1,21 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +const ICU4XSentenceBreakIteratorLatin1_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XSentenceBreakIteratorLatin1_destroy(underlying); +}); + +export class ICU4XSentenceBreakIteratorLatin1 { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XSentenceBreakIteratorLatin1_box_destroy_registry.register(this, underlying); + } + } + + next() { + return wasm.ICU4XSentenceBreakIteratorLatin1_next(this.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorUtf16.d.ts b/third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorUtf16.d.ts new file mode 100644 index 000000000000..76b4e04d328c --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorUtf16.d.ts @@ -0,0 +1,16 @@ +import { i32 } from "./diplomat-runtime" + +/** + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.SentenceBreakIterator.html Rust documentation for `SentenceBreakIterator`} for more information. + */ +export class ICU4XSentenceBreakIteratorUtf16 { + + /** + + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is out of range of a 32-bit signed integer. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.SentenceBreakIterator.html#method.next Rust documentation for `next`} for more information. + */ + next(): i32; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorUtf16.js b/third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorUtf16.js new file mode 100644 index 000000000000..8a69b6907ea0 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorUtf16.js @@ -0,0 +1,21 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +const ICU4XSentenceBreakIteratorUtf16_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XSentenceBreakIteratorUtf16_destroy(underlying); +}); + +export class ICU4XSentenceBreakIteratorUtf16 { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XSentenceBreakIteratorUtf16_box_destroy_registry.register(this, underlying); + } + } + + next() { + return wasm.ICU4XSentenceBreakIteratorUtf16_next(this.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorUtf8.d.ts b/third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorUtf8.d.ts new file mode 100644 index 000000000000..b4080e2112a6 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorUtf8.d.ts @@ -0,0 +1,16 @@ +import { i32 } from "./diplomat-runtime" + +/** + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.SentenceBreakIterator.html Rust documentation for `SentenceBreakIterator`} for more information. + */ +export class ICU4XSentenceBreakIteratorUtf8 { + + /** + + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is out of range of a 32-bit signed integer. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.SentenceBreakIterator.html#method.next Rust documentation for `next`} for more information. + */ + next(): i32; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorUtf8.js b/third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorUtf8.js new file mode 100644 index 000000000000..cd140f513bc6 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XSentenceBreakIteratorUtf8.js @@ -0,0 +1,21 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +const ICU4XSentenceBreakIteratorUtf8_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XSentenceBreakIteratorUtf8_destroy(underlying); +}); + +export class ICU4XSentenceBreakIteratorUtf8 { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XSentenceBreakIteratorUtf8_box_destroy_registry.register(this, underlying); + } + } + + next() { + return wasm.ICU4XSentenceBreakIteratorUtf8_next(this.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XSentenceSegmenter.d.ts b/third_party/rust/icu_capi/js/include/ICU4XSentenceSegmenter.d.ts new file mode 100644 index 000000000000..fb513c90e8c9 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XSentenceSegmenter.d.ts @@ -0,0 +1,48 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XSentenceBreakIteratorLatin1 } from "./ICU4XSentenceBreakIteratorLatin1"; +import { ICU4XSentenceBreakIteratorUtf16 } from "./ICU4XSentenceBreakIteratorUtf16"; +import { ICU4XSentenceBreakIteratorUtf8 } from "./ICU4XSentenceBreakIteratorUtf8"; + +/** + + * An ICU4X sentence-break segmenter, capable of finding sentence breakpoints in strings. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.SentenceSegmenter.html Rust documentation for `SentenceSegmenter`} for more information. + */ +export class ICU4XSentenceSegmenter { + + /** + + * Construct an {@link ICU4XSentenceSegmenter `ICU4XSentenceSegmenter`}. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.SentenceSegmenter.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create(provider: ICU4XDataProvider): ICU4XSentenceSegmenter | never; + + /** + + * Segments a (potentially ill-formed) UTF-8 string. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.SentenceSegmenter.html#method.segment_utf8 Rust documentation for `segment_utf8`} for more information. + */ + segment_utf8(input: string): ICU4XSentenceBreakIteratorUtf8; + + /** + + * Segments a UTF-16 string. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.SentenceSegmenter.html#method.segment_utf16 Rust documentation for `segment_utf16`} for more information. + */ + segment_utf16(input: Uint16Array): ICU4XSentenceBreakIteratorUtf16; + + /** + + * Segments a Latin-1 string. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.SentenceSegmenter.html#method.segment_latin1 Rust documentation for `segment_latin1`} for more information. + */ + segment_latin1(input: Uint8Array): ICU4XSentenceBreakIteratorLatin1; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XSentenceSegmenter.js b/third_party/rust/icu_capi/js/include/ICU4XSentenceSegmenter.js new file mode 100644 index 000000000000..de617070a29f --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XSentenceSegmenter.js @@ -0,0 +1,53 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XSentenceBreakIteratorLatin1 } from "./ICU4XSentenceBreakIteratorLatin1.js" +import { ICU4XSentenceBreakIteratorUtf16 } from "./ICU4XSentenceBreakIteratorUtf16.js" +import { ICU4XSentenceBreakIteratorUtf8 } from "./ICU4XSentenceBreakIteratorUtf8.js" + +const ICU4XSentenceSegmenter_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XSentenceSegmenter_destroy(underlying); +}); + +export class ICU4XSentenceSegmenter { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XSentenceSegmenter_box_destroy_registry.register(this, underlying); + } + } + + static create(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XSentenceSegmenter_create(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XSentenceSegmenter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + segment_utf8(arg_input) { + const buf_arg_input = diplomatRuntime.DiplomatBuf.str(wasm, arg_input); + return new ICU4XSentenceBreakIteratorUtf8(wasm.ICU4XSentenceSegmenter_segment_utf8(this.underlying, buf_arg_input.ptr, buf_arg_input.size), true, [this, buf_arg_input]); + } + + segment_utf16(arg_input) { + const buf_arg_input = diplomatRuntime.DiplomatBuf.slice(wasm, arg_input, 2); + return new ICU4XSentenceBreakIteratorUtf16(wasm.ICU4XSentenceSegmenter_segment_utf16(this.underlying, buf_arg_input.ptr, buf_arg_input.size), true, [this, buf_arg_input]); + } + + segment_latin1(arg_input) { + const buf_arg_input = diplomatRuntime.DiplomatBuf.slice(wasm, arg_input, 1); + return new ICU4XSentenceBreakIteratorLatin1(wasm.ICU4XSentenceSegmenter_segment_latin1(this.underlying, buf_arg_input.ptr, buf_arg_input.size), true, [this, buf_arg_input]); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XTime.d.ts b/third_party/rust/icu_capi/js/include/ICU4XTime.d.ts new file mode 100644 index 000000000000..1578d6c65aba --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XTime.d.ts @@ -0,0 +1,53 @@ +import { u8, u32 } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { ICU4XError } from "./ICU4XError"; + +/** + + * An ICU4X Time object representing a time in terms of hour, minute, second, nanosecond + + * See the {@link https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html Rust documentation for `Time`} for more information. + */ +export class ICU4XTime { + + /** + + * Creates a new {@link ICU4XTime `ICU4XTime`} given field values + + * See the {@link https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html Rust documentation for `Time`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create(hour: u8, minute: u8, second: u8, nanosecond: u32): ICU4XTime | never; + + /** + + * Returns the hour in this time + + * See the {@link https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.hour Rust documentation for `hour`} for more information. + */ + hour(): u8; + + /** + + * Returns the minute in this time + + * See the {@link https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.minute Rust documentation for `minute`} for more information. + */ + minute(): u8; + + /** + + * Returns the second in this time + + * See the {@link https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.second Rust documentation for `second`} for more information. + */ + second(): u8; + + /** + + * Returns the nanosecond in this time + + * See the {@link https://docs.rs/icu/latest/icu/calendar/types/struct.Time.html#structfield.nanosecond Rust documentation for `nanosecond`} for more information. + */ + nanosecond(): u32; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XTime.js b/third_party/rust/icu_capi/js/include/ICU4XTime.js new file mode 100644 index 000000000000..9f9de19ab58c --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XTime.js @@ -0,0 +1,51 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XTime_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XTime_destroy(underlying); +}); + +export class ICU4XTime { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XTime_box_destroy_registry.register(this, underlying); + } + } + + static create(arg_hour, arg_minute, arg_second, arg_nanosecond) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XTime_create(diplomat_receive_buffer, arg_hour, arg_minute, arg_second, arg_nanosecond); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XTime(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + hour() { + return wasm.ICU4XTime_hour(this.underlying); + } + + minute() { + return wasm.ICU4XTime_minute(this.underlying); + } + + second() { + return wasm.ICU4XTime_second(this.underlying); + } + + nanosecond() { + return wasm.ICU4XTime_nanosecond(this.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XTimeFormatter.d.ts b/third_party/rust/icu_capi/js/include/ICU4XTimeFormatter.d.ts new file mode 100644 index 000000000000..03f172fafc70 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XTimeFormatter.d.ts @@ -0,0 +1,53 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XDateTime } from "./ICU4XDateTime"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XIsoDateTime } from "./ICU4XIsoDateTime"; +import { ICU4XLocale } from "./ICU4XLocale"; +import { ICU4XTime } from "./ICU4XTime"; +import { ICU4XTimeLength } from "./ICU4XTimeLength"; + +/** + + * An ICU4X TimeFormatter object capable of formatting an {@link ICU4XTime `ICU4XTime`} type (and others) as a string + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.TimeFormatter.html Rust documentation for `TimeFormatter`} for more information. + */ +export class ICU4XTimeFormatter { + + /** + + * Creates a new {@link ICU4XTimeFormatter `ICU4XTimeFormatter`} from locale data. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.TimeFormatter.html#method.try_new_with_length_unstable Rust documentation for `try_new_with_length_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_with_length(provider: ICU4XDataProvider, locale: ICU4XLocale, length: ICU4XTimeLength): ICU4XTimeFormatter | never; + + /** + + * Formats a {@link ICU4XTime `ICU4XTime`} to a string. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.TimeFormatter.html#method.format Rust documentation for `format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + format_time(value: ICU4XTime): string | never; + + /** + + * Formats a {@link ICU4XDateTime `ICU4XDateTime`} to a string. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.TimeFormatter.html#method.format Rust documentation for `format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + format_datetime(value: ICU4XDateTime): string | never; + + /** + + * Formats a {@link ICU4XIsoDateTime `ICU4XIsoDateTime`} to a string. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.TimeFormatter.html#method.format Rust documentation for `format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + format_iso_datetime(value: ICU4XIsoDateTime): string | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XTimeFormatter.js b/third_party/rust/icu_capi/js/include/ICU4XTimeFormatter.js new file mode 100644 index 000000000000..9b7fb7e1a886 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XTimeFormatter.js @@ -0,0 +1,93 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XTimeLength_js_to_rust, ICU4XTimeLength_rust_to_js } from "./ICU4XTimeLength.js" + +const ICU4XTimeFormatter_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XTimeFormatter_destroy(underlying); +}); + +export class ICU4XTimeFormatter { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XTimeFormatter_box_destroy_registry.register(this, underlying); + } + } + + static create_with_length(arg_provider, arg_locale, arg_length) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XTimeFormatter_create_with_length(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying, ICU4XTimeLength_js_to_rust[arg_length]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XTimeFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + format_time(arg_value) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XTimeFormatter_format_time(diplomat_receive_buffer, this.underlying, arg_value.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + format_datetime(arg_value) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XTimeFormatter_format_datetime(diplomat_receive_buffer, this.underlying, arg_value.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + format_iso_datetime(arg_value) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XTimeFormatter_format_iso_datetime(diplomat_receive_buffer, this.underlying, arg_value.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XTimeLength.d.ts b/third_party/rust/icu_capi/js/include/ICU4XTimeLength.d.ts new file mode 100644 index 000000000000..ac90d6175beb --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XTimeLength.d.ts @@ -0,0 +1,19 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/datetime/options/length/enum.Time.html Rust documentation for `Time`} for more information. + */ +export enum ICU4XTimeLength { + /** + */ + Full = 'Full', + /** + */ + Long = 'Long', + /** + */ + Medium = 'Medium', + /** + */ + Short = 'Short', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XTimeLength.js b/third_party/rust/icu_capi/js/include/ICU4XTimeLength.js new file mode 100644 index 000000000000..f8a9c7e5f0b1 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XTimeLength.js @@ -0,0 +1,23 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XTimeLength_js_to_rust = { + "Full": 0, + "Long": 1, + "Medium": 2, + "Short": 3, +}; + +export const ICU4XTimeLength_rust_to_js = { + [0]: "Full", + [1]: "Long", + [2]: "Medium", + [3]: "Short", +}; + +export const ICU4XTimeLength = { + "Full": "Full", + "Long": "Long", + "Medium": "Medium", + "Short": "Short", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XTimeZoneFormatter.d.ts b/third_party/rust/icu_capi/js/include/ICU4XTimeZoneFormatter.d.ts new file mode 100644 index 000000000000..076c135f0237 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XTimeZoneFormatter.d.ts @@ -0,0 +1,115 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XCustomTimeZone } from "./ICU4XCustomTimeZone"; +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XIsoTimeZoneOptions } from "./ICU4XIsoTimeZoneOptions"; +import { ICU4XLocale } from "./ICU4XLocale"; + +/** + + * An ICU4X TimeZoneFormatter object capable of formatting an {@link ICU4XCustomTimeZone `ICU4XCustomTimeZone`} type (and others) as a string + + * See the {@link https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html Rust documentation for `TimeZoneFormatter`} for more information. + */ +export class ICU4XTimeZoneFormatter { + + /** + + * Creates a new {@link ICU4XTimeZoneFormatter `ICU4XTimeZoneFormatter`} from locale data. + + * Uses localized GMT as the fallback format. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/datetime/time_zone/enum.FallbackFormat.html 1} + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_with_localized_gmt_fallback(provider: ICU4XDataProvider, locale: ICU4XLocale): ICU4XTimeZoneFormatter | never; + + /** + + * Creates a new {@link ICU4XTimeZoneFormatter `ICU4XTimeZoneFormatter`} from locale data. + + * Uses ISO-8601 as the fallback format. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + + * Additional information: {@link https://docs.rs/icu/latest/icu/datetime/time_zone/enum.FallbackFormat.html 1} + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_with_iso_8601_fallback(provider: ICU4XDataProvider, locale: ICU4XLocale, options: ICU4XIsoTimeZoneOptions): ICU4XTimeZoneFormatter | never; + + /** + + * Loads generic non-location long format. Example: "Pacific Time" + + * See the {@link https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.load_generic_non_location_long Rust documentation for `load_generic_non_location_long`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + load_generic_non_location_long(provider: ICU4XDataProvider): void | never; + + /** + + * Loads generic non-location short format. Example: "PT" + + * See the {@link https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.load_generic_non_location_short Rust documentation for `load_generic_non_location_short`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + load_generic_non_location_short(provider: ICU4XDataProvider): void | never; + + /** + + * Loads specific non-location long format. Example: "Pacific Standard Time" + + * See the {@link https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.load_specific_non_location_long Rust documentation for `load_specific_non_location_long`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + load_specific_non_location_long(provider: ICU4XDataProvider): void | never; + + /** + + * Loads specific non-location short format. Example: "PST" + + * See the {@link https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.load_specific_non_location_short Rust documentation for `load_specific_non_location_short`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + load_specific_non_location_short(provider: ICU4XDataProvider): void | never; + + /** + + * Loads generic location format. Example: "Los Angeles Time" + + * See the {@link https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.load_generic_location_format Rust documentation for `load_generic_location_format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + load_generic_location_format(provider: ICU4XDataProvider): void | never; + + /** + + * Loads localized GMT format. Example: "GMT-07:00" + + * See the {@link https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.load_localized_gmt_format Rust documentation for `load_localized_gmt_format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + load_localized_gmt_format(): void | never; + + /** + + * Loads ISO-8601 format. Example: "-07:00" + + * See the {@link https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.load_iso_8601_format Rust documentation for `load_iso_8601_format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + load_iso_8601_format(options: ICU4XIsoTimeZoneOptions): void | never; + + /** + + * Formats a {@link ICU4XCustomTimeZone `ICU4XCustomTimeZone`} to a string. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.format Rust documentation for `format`} for more information. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/time_zone/struct.TimeZoneFormatter.html#method.format_to_string Rust documentation for `format_to_string`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + format_custom_time_zone(value: ICU4XCustomTimeZone): string | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XTimeZoneFormatter.js b/third_party/rust/icu_capi/js/include/ICU4XTimeZoneFormatter.js new file mode 100644 index 000000000000..90bd4288d1d7 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XTimeZoneFormatter.js @@ -0,0 +1,199 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XIsoTimeZoneFormat_js_to_rust, ICU4XIsoTimeZoneFormat_rust_to_js } from "./ICU4XIsoTimeZoneFormat.js" +import { ICU4XIsoTimeZoneMinuteDisplay_js_to_rust, ICU4XIsoTimeZoneMinuteDisplay_rust_to_js } from "./ICU4XIsoTimeZoneMinuteDisplay.js" +import { ICU4XIsoTimeZoneSecondDisplay_js_to_rust, ICU4XIsoTimeZoneSecondDisplay_rust_to_js } from "./ICU4XIsoTimeZoneSecondDisplay.js" + +const ICU4XTimeZoneFormatter_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XTimeZoneFormatter_destroy(underlying); +}); + +export class ICU4XTimeZoneFormatter { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XTimeZoneFormatter_box_destroy_registry.register(this, underlying); + } + } + + static create_with_localized_gmt_fallback(arg_provider, arg_locale) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XTimeZoneFormatter_create_with_localized_gmt_fallback(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XTimeZoneFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_with_iso_8601_fallback(arg_provider, arg_locale, arg_options) { + const field_format_arg_options = arg_options["format"]; + const field_minutes_arg_options = arg_options["minutes"]; + const field_seconds_arg_options = arg_options["seconds"]; + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XTimeZoneFormatter_create_with_iso_8601_fallback(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying, ICU4XIsoTimeZoneFormat_js_to_rust[field_format_arg_options], ICU4XIsoTimeZoneMinuteDisplay_js_to_rust[field_minutes_arg_options], ICU4XIsoTimeZoneSecondDisplay_js_to_rust[field_seconds_arg_options]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XTimeZoneFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + load_generic_non_location_long(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XTimeZoneFormatter_load_generic_non_location_long(diplomat_receive_buffer, this.underlying, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + load_generic_non_location_short(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XTimeZoneFormatter_load_generic_non_location_short(diplomat_receive_buffer, this.underlying, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + load_specific_non_location_long(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XTimeZoneFormatter_load_specific_non_location_long(diplomat_receive_buffer, this.underlying, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + load_specific_non_location_short(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XTimeZoneFormatter_load_specific_non_location_short(diplomat_receive_buffer, this.underlying, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + load_generic_location_format(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XTimeZoneFormatter_load_generic_location_format(diplomat_receive_buffer, this.underlying, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + load_localized_gmt_format() { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XTimeZoneFormatter_load_localized_gmt_format(diplomat_receive_buffer, this.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + load_iso_8601_format(arg_options) { + const field_format_arg_options = arg_options["format"]; + const field_minutes_arg_options = arg_options["minutes"]; + const field_seconds_arg_options = arg_options["seconds"]; + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XTimeZoneFormatter_load_iso_8601_format(diplomat_receive_buffer, this.underlying, ICU4XIsoTimeZoneFormat_js_to_rust[field_format_arg_options], ICU4XIsoTimeZoneMinuteDisplay_js_to_rust[field_minutes_arg_options], ICU4XIsoTimeZoneSecondDisplay_js_to_rust[field_seconds_arg_options]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + format_custom_time_zone(arg_value) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XTimeZoneFormatter_format_custom_time_zone(diplomat_receive_buffer, this.underlying, arg_value.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XTransformResult.d.ts b/third_party/rust/icu_capi/js/include/ICU4XTransformResult.d.ts new file mode 100644 index 000000000000..e741659ea926 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XTransformResult.d.ts @@ -0,0 +1,15 @@ + +/** + + * FFI version of `TransformResult`. + + * See the {@link https://docs.rs/icu/latest/icu/locid_transform/enum.TransformResult.html Rust documentation for `TransformResult`} for more information. + */ +export enum ICU4XTransformResult { + /** + */ + Modified = 'Modified', + /** + */ + Unmodified = 'Unmodified', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XTransformResult.js b/third_party/rust/icu_capi/js/include/ICU4XTransformResult.js new file mode 100644 index 000000000000..db68a34f0fe5 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XTransformResult.js @@ -0,0 +1,17 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XTransformResult_js_to_rust = { + "Modified": 0, + "Unmodified": 1, +}; + +export const ICU4XTransformResult_rust_to_js = { + [0]: "Modified", + [1]: "Unmodified", +}; + +export const ICU4XTransformResult = { + "Modified": "Modified", + "Unmodified": "Unmodified", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XUnicodeSetData.d.ts b/third_party/rust/icu_capi/js/include/ICU4XUnicodeSetData.d.ts new file mode 100644 index 000000000000..b1fb3dfd6c8c --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XUnicodeSetData.d.ts @@ -0,0 +1,82 @@ +import { u32, char } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XLocale } from "./ICU4XLocale"; + +/** + + * An ICU4X Unicode Set Property object, capable of querying whether a code point is contained in a set based on a Unicode property. + + * See the {@link https://docs.rs/icu/latest/icu/properties/index.html Rust documentation for `properties`} for more information. + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/struct.UnicodeSetData.html Rust documentation for `UnicodeSetData`} for more information. + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/struct.UnicodeSetDataBorrowed.html Rust documentation for `UnicodeSetDataBorrowed`} for more information. + */ +export class ICU4XUnicodeSetData { + + /** + + * Checks whether the string is in the set. + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/struct.UnicodeSetDataBorrowed.html#method.contains Rust documentation for `contains`} for more information. + */ + contains(s: string): boolean; + + /** + + * Checks whether the code point is in the set. + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/struct.UnicodeSetDataBorrowed.html#method.contains_char Rust documentation for `contains_char`} for more information. + */ + contains_char(cp: char): boolean; + + /** + + * Checks whether the code point (specified as a 32 bit integer, in UTF-32) is in the set. + */ + contains32(cp: u32): boolean; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/sets/fn.load_basic_emoji.html Rust documentation for `load_basic_emoji`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_basic_emoji(provider: ICU4XDataProvider): ICU4XUnicodeSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/exemplar_chars/fn.load_exemplars_main.html Rust documentation for `load_exemplars_main`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_exemplars_main(provider: ICU4XDataProvider, locale: ICU4XLocale): ICU4XUnicodeSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/exemplar_chars/fn.load_exemplars_auxiliary.html Rust documentation for `load_exemplars_auxiliary`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_exemplars_auxiliary(provider: ICU4XDataProvider, locale: ICU4XLocale): ICU4XUnicodeSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/exemplar_chars/fn.load_exemplars_punctuation.html Rust documentation for `load_exemplars_punctuation`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_exemplars_punctuation(provider: ICU4XDataProvider, locale: ICU4XLocale): ICU4XUnicodeSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/exemplar_chars/fn.load_exemplars_numbers.html Rust documentation for `load_exemplars_numbers`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_exemplars_numbers(provider: ICU4XDataProvider, locale: ICU4XLocale): ICU4XUnicodeSetData | never; + + /** + + * See the {@link https://docs.rs/icu/latest/icu/properties/exemplar_chars/fn.load_exemplars_index.html Rust documentation for `load_exemplars_index`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static load_exemplars_index(provider: ICU4XDataProvider, locale: ICU4XLocale): ICU4XUnicodeSetData | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XUnicodeSetData.js b/third_party/rust/icu_capi/js/include/ICU4XUnicodeSetData.js new file mode 100644 index 000000000000..b345a101237e --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XUnicodeSetData.js @@ -0,0 +1,135 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" + +const ICU4XUnicodeSetData_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XUnicodeSetData_destroy(underlying); +}); + +export class ICU4XUnicodeSetData { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XUnicodeSetData_box_destroy_registry.register(this, underlying); + } + } + + contains(arg_s) { + const buf_arg_s = diplomatRuntime.DiplomatBuf.str(wasm, arg_s); + const diplomat_out = wasm.ICU4XUnicodeSetData_contains(this.underlying, buf_arg_s.ptr, buf_arg_s.size); + buf_arg_s.free(); + return diplomat_out; + } + + contains_char(arg_cp) { + return wasm.ICU4XUnicodeSetData_contains_char(this.underlying, diplomatRuntime.extractCodePoint(arg_cp, 'arg_cp')); + } + + contains32(arg_cp) { + return wasm.ICU4XUnicodeSetData_contains32(this.underlying, arg_cp); + } + + static load_basic_emoji(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XUnicodeSetData_load_basic_emoji(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XUnicodeSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_exemplars_main(arg_provider, arg_locale) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XUnicodeSetData_load_exemplars_main(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XUnicodeSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_exemplars_auxiliary(arg_provider, arg_locale) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XUnicodeSetData_load_exemplars_auxiliary(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XUnicodeSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_exemplars_punctuation(arg_provider, arg_locale) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XUnicodeSetData_load_exemplars_punctuation(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XUnicodeSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_exemplars_numbers(arg_provider, arg_locale) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XUnicodeSetData_load_exemplars_numbers(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XUnicodeSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static load_exemplars_index(arg_provider, arg_locale) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XUnicodeSetData_load_exemplars_index(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XUnicodeSetData(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XWeekCalculator.d.ts b/third_party/rust/icu_capi/js/include/ICU4XWeekCalculator.d.ts new file mode 100644 index 000000000000..bf69f94d056d --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XWeekCalculator.d.ts @@ -0,0 +1,46 @@ +import { u8 } from "./diplomat-runtime" +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XIsoWeekday } from "./ICU4XIsoWeekday"; +import { ICU4XLocale } from "./ICU4XLocale"; + +/** + + * A Week calculator, useful to be passed in to `week_of_year()` on Date and DateTime types + + * See the {@link https://docs.rs/icu/latest/icu/calendar/week/struct.WeekCalculator.html Rust documentation for `WeekCalculator`} for more information. + */ +export class ICU4XWeekCalculator { + + /** + + * Creates a new {@link ICU4XWeekCalculator `ICU4XWeekCalculator`} from locale data. + + * See the {@link https://docs.rs/icu/latest/icu/calendar/week/struct.WeekCalculator.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create(provider: ICU4XDataProvider, locale: ICU4XLocale): ICU4XWeekCalculator | never; + + /** + + * Additional information: {@link https://docs.rs/icu/latest/icu/calendar/week/struct.WeekCalculator.html#structfield.first_weekday 1}, {@link https://docs.rs/icu/latest/icu/calendar/week/struct.WeekCalculator.html#structfield.min_week_days 2} + */ + static create_from_first_day_of_week_and_min_week_days(first_weekday: ICU4XIsoWeekday, min_week_days: u8): ICU4XWeekCalculator; + + /** + + * Returns the weekday that starts the week for this object's locale + + * See the {@link https://docs.rs/icu/latest/icu/calendar/week/struct.WeekCalculator.html#structfield.first_weekday Rust documentation for `first_weekday`} for more information. + */ + first_weekday(): ICU4XIsoWeekday; + + /** + + * The minimum number of days overlapping a year required for a week to be considered part of that year + + * See the {@link https://docs.rs/icu/latest/icu/calendar/week/struct.WeekCalculator.html#structfield.min_week_days Rust documentation for `min_week_days`} for more information. + */ + min_week_days(): u8; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XWeekCalculator.js b/third_party/rust/icu_capi/js/include/ICU4XWeekCalculator.js new file mode 100644 index 000000000000..7b3110538de2 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XWeekCalculator.js @@ -0,0 +1,48 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XIsoWeekday_js_to_rust, ICU4XIsoWeekday_rust_to_js } from "./ICU4XIsoWeekday.js" + +const ICU4XWeekCalculator_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XWeekCalculator_destroy(underlying); +}); + +export class ICU4XWeekCalculator { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XWeekCalculator_box_destroy_registry.register(this, underlying); + } + } + + static create(arg_provider, arg_locale) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XWeekCalculator_create(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XWeekCalculator(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_from_first_day_of_week_and_min_week_days(arg_first_weekday, arg_min_week_days) { + return new ICU4XWeekCalculator(wasm.ICU4XWeekCalculator_create_from_first_day_of_week_and_min_week_days(ICU4XIsoWeekday_js_to_rust[arg_first_weekday], arg_min_week_days), true, []); + } + + first_weekday() { + return ICU4XIsoWeekday_rust_to_js[wasm.ICU4XWeekCalculator_first_weekday(this.underlying)]; + } + + min_week_days() { + return wasm.ICU4XWeekCalculator_min_week_days(this.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XWeekOf.d.ts b/third_party/rust/icu_capi/js/include/ICU4XWeekOf.d.ts new file mode 100644 index 000000000000..dfcf1eb97fbc --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XWeekOf.d.ts @@ -0,0 +1,11 @@ +import { u16 } from "./diplomat-runtime" +import { ICU4XWeekRelativeUnit } from "./ICU4XWeekRelativeUnit"; + +/** + + * See the {@link https://docs.rs/icu/latest/icu/calendar/week/struct.WeekOf.html Rust documentation for `WeekOf`} for more information. + */ +export class ICU4XWeekOf { + week: u16; + unit: ICU4XWeekRelativeUnit; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XWeekOf.js b/third_party/rust/icu_capi/js/include/ICU4XWeekOf.js new file mode 100644 index 000000000000..5f74b5d1a5ab --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XWeekOf.js @@ -0,0 +1,10 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XWeekRelativeUnit_js_to_rust, ICU4XWeekRelativeUnit_rust_to_js } from "./ICU4XWeekRelativeUnit.js" + +export class ICU4XWeekOf { + constructor(underlying) { + this.week = (new Uint16Array(wasm.memory.buffer, underlying, 1))[0]; + this.unit = ICU4XWeekRelativeUnit_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, underlying + 4)]; + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XWeekRelativeUnit.d.ts b/third_party/rust/icu_capi/js/include/ICU4XWeekRelativeUnit.d.ts new file mode 100644 index 000000000000..60a12eddb5f6 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XWeekRelativeUnit.d.ts @@ -0,0 +1,16 @@ + +/** + + * See the {@link https://docs.rs/icu/latest/icu/calendar/week/enum.RelativeUnit.html Rust documentation for `RelativeUnit`} for more information. + */ +export enum ICU4XWeekRelativeUnit { + /** + */ + Previous = 'Previous', + /** + */ + Current = 'Current', + /** + */ + Next = 'Next', +} \ No newline at end of file diff --git a/third_party/rust/icu_capi/js/include/ICU4XWeekRelativeUnit.js b/third_party/rust/icu_capi/js/include/ICU4XWeekRelativeUnit.js new file mode 100644 index 000000000000..685a296b2087 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XWeekRelativeUnit.js @@ -0,0 +1,20 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" + +export const ICU4XWeekRelativeUnit_js_to_rust = { + "Previous": 0, + "Current": 1, + "Next": 2, +}; + +export const ICU4XWeekRelativeUnit_rust_to_js = { + [0]: "Previous", + [1]: "Current", + [2]: "Next", +}; + +export const ICU4XWeekRelativeUnit = { + "Previous": "Previous", + "Current": "Current", + "Next": "Next", +}; diff --git a/third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorLatin1.d.ts b/third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorLatin1.d.ts new file mode 100644 index 000000000000..3bd6da522491 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorLatin1.d.ts @@ -0,0 +1,33 @@ +import { i32 } from "./diplomat-runtime" +import { ICU4XSegmenterWordType } from "./ICU4XSegmenterWordType"; + +/** + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html Rust documentation for `WordBreakIterator`} for more information. + */ +export class ICU4XWordBreakIteratorLatin1 { + + /** + + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is out of range of a 32-bit signed integer. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.next Rust documentation for `next`} for more information. + */ + next(): i32; + + /** + + * Return the status value of break boundary. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.word_type Rust documentation for `word_type`} for more information. + */ + word_type(): ICU4XSegmenterWordType; + + /** + + * Return true when break boundary is word-like such as letter/number/CJK + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.is_word_like Rust documentation for `is_word_like`} for more information. + */ + is_word_like(): boolean; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorLatin1.js b/third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorLatin1.js new file mode 100644 index 000000000000..bdeac9ae7167 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorLatin1.js @@ -0,0 +1,30 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XSegmenterWordType_js_to_rust, ICU4XSegmenterWordType_rust_to_js } from "./ICU4XSegmenterWordType.js" + +const ICU4XWordBreakIteratorLatin1_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XWordBreakIteratorLatin1_destroy(underlying); +}); + +export class ICU4XWordBreakIteratorLatin1 { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XWordBreakIteratorLatin1_box_destroy_registry.register(this, underlying); + } + } + + next() { + return wasm.ICU4XWordBreakIteratorLatin1_next(this.underlying); + } + + word_type() { + return ICU4XSegmenterWordType_rust_to_js[wasm.ICU4XWordBreakIteratorLatin1_word_type(this.underlying)]; + } + + is_word_like() { + return wasm.ICU4XWordBreakIteratorLatin1_is_word_like(this.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorUtf16.d.ts b/third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorUtf16.d.ts new file mode 100644 index 000000000000..d0f67acd2df7 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorUtf16.d.ts @@ -0,0 +1,33 @@ +import { i32 } from "./diplomat-runtime" +import { ICU4XSegmenterWordType } from "./ICU4XSegmenterWordType"; + +/** + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html Rust documentation for `WordBreakIterator`} for more information. + */ +export class ICU4XWordBreakIteratorUtf16 { + + /** + + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is out of range of a 32-bit signed integer. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.next Rust documentation for `next`} for more information. + */ + next(): i32; + + /** + + * Return the status value of break boundary. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.word_type Rust documentation for `word_type`} for more information. + */ + word_type(): ICU4XSegmenterWordType; + + /** + + * Return true when break boundary is word-like such as letter/number/CJK + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.is_word_like Rust documentation for `is_word_like`} for more information. + */ + is_word_like(): boolean; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorUtf16.js b/third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorUtf16.js new file mode 100644 index 000000000000..7dd16d4ef07b --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorUtf16.js @@ -0,0 +1,30 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XSegmenterWordType_js_to_rust, ICU4XSegmenterWordType_rust_to_js } from "./ICU4XSegmenterWordType.js" + +const ICU4XWordBreakIteratorUtf16_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XWordBreakIteratorUtf16_destroy(underlying); +}); + +export class ICU4XWordBreakIteratorUtf16 { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XWordBreakIteratorUtf16_box_destroy_registry.register(this, underlying); + } + } + + next() { + return wasm.ICU4XWordBreakIteratorUtf16_next(this.underlying); + } + + word_type() { + return ICU4XSegmenterWordType_rust_to_js[wasm.ICU4XWordBreakIteratorUtf16_word_type(this.underlying)]; + } + + is_word_like() { + return wasm.ICU4XWordBreakIteratorUtf16_is_word_like(this.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorUtf8.d.ts b/third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorUtf8.d.ts new file mode 100644 index 000000000000..1a74af6d889d --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorUtf8.d.ts @@ -0,0 +1,33 @@ +import { i32 } from "./diplomat-runtime" +import { ICU4XSegmenterWordType } from "./ICU4XSegmenterWordType"; + +/** + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html Rust documentation for `WordBreakIterator`} for more information. + */ +export class ICU4XWordBreakIteratorUtf8 { + + /** + + * Finds the next breakpoint. Returns -1 if at the end of the string or if the index is out of range of a 32-bit signed integer. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.next Rust documentation for `next`} for more information. + */ + next(): i32; + + /** + + * Return the status value of break boundary. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.word_type Rust documentation for `word_type`} for more information. + */ + word_type(): ICU4XSegmenterWordType; + + /** + + * Return true when break boundary is word-like such as letter/number/CJK + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html#method.is_word_like Rust documentation for `is_word_like`} for more information. + */ + is_word_like(): boolean; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorUtf8.js b/third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorUtf8.js new file mode 100644 index 000000000000..f4517683d205 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XWordBreakIteratorUtf8.js @@ -0,0 +1,30 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XSegmenterWordType_js_to_rust, ICU4XSegmenterWordType_rust_to_js } from "./ICU4XSegmenterWordType.js" + +const ICU4XWordBreakIteratorUtf8_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XWordBreakIteratorUtf8_destroy(underlying); +}); + +export class ICU4XWordBreakIteratorUtf8 { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XWordBreakIteratorUtf8_box_destroy_registry.register(this, underlying); + } + } + + next() { + return wasm.ICU4XWordBreakIteratorUtf8_next(this.underlying); + } + + word_type() { + return ICU4XSegmenterWordType_rust_to_js[wasm.ICU4XWordBreakIteratorUtf8_word_type(this.underlying)]; + } + + is_word_like() { + return wasm.ICU4XWordBreakIteratorUtf8_is_word_like(this.underlying); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XWordSegmenter.d.ts b/third_party/rust/icu_capi/js/include/ICU4XWordSegmenter.d.ts new file mode 100644 index 000000000000..4c63e2df1732 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XWordSegmenter.d.ts @@ -0,0 +1,70 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XWordBreakIteratorLatin1 } from "./ICU4XWordBreakIteratorLatin1"; +import { ICU4XWordBreakIteratorUtf16 } from "./ICU4XWordBreakIteratorUtf16"; +import { ICU4XWordBreakIteratorUtf8 } from "./ICU4XWordBreakIteratorUtf8"; + +/** + + * An ICU4X word-break segmenter, capable of finding word breakpoints in strings. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordSegmenter.html Rust documentation for `WordSegmenter`} for more information. + */ +export class ICU4XWordSegmenter { + + /** + + * Construct an {@link ICU4XWordSegmenter `ICU4XWordSegmenter`} with automatically selecting the best available LSTM or dictionary payload data. + + * Note: currently, it uses dictionary for Chinese and Japanese, and LSTM for Burmese, Khmer, Lao, and Thai. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordSegmenter.html#method.try_new_auto_unstable Rust documentation for `try_new_auto_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_auto(provider: ICU4XDataProvider): ICU4XWordSegmenter | never; + + /** + + * Construct an {@link ICU4XWordSegmenter `ICU4XWordSegmenter`} with LSTM payload data for Burmese, Khmer, Lao, and Thai. + + * Warning: {@link ICU4XWordSegmenter `ICU4XWordSegmenter`} created by this function doesn't handle Chinese or Japanese. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordSegmenter.html#method.try_new_lstm_unstable Rust documentation for `try_new_lstm_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_lstm(provider: ICU4XDataProvider): ICU4XWordSegmenter | never; + + /** + + * Construct an {@link ICU4XWordSegmenter `ICU4XWordSegmenter`} with dictionary payload data for Chinese, Japanese, Burmese, Khmer, Lao, and Thai. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordSegmenter.html#method.try_new_dictionary_unstable Rust documentation for `try_new_dictionary_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_dictionary(provider: ICU4XDataProvider): ICU4XWordSegmenter | never; + + /** + + * Segments a (potentially ill-formed) UTF-8 string. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordSegmenter.html#method.segment_utf8 Rust documentation for `segment_utf8`} for more information. + */ + segment_utf8(input: string): ICU4XWordBreakIteratorUtf8; + + /** + + * Segments a UTF-16 string. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordSegmenter.html#method.segment_utf16 Rust documentation for `segment_utf16`} for more information. + */ + segment_utf16(input: Uint16Array): ICU4XWordBreakIteratorUtf16; + + /** + + * Segments a Latin-1 string. + + * See the {@link https://docs.rs/icu/latest/icu/segmenter/struct.WordSegmenter.html#method.segment_latin1 Rust documentation for `segment_latin1`} for more information. + */ + segment_latin1(input: Uint8Array): ICU4XWordBreakIteratorLatin1; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XWordSegmenter.js b/third_party/rust/icu_capi/js/include/ICU4XWordSegmenter.js new file mode 100644 index 000000000000..f1a1b263ee38 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XWordSegmenter.js @@ -0,0 +1,87 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XWordBreakIteratorLatin1 } from "./ICU4XWordBreakIteratorLatin1.js" +import { ICU4XWordBreakIteratorUtf16 } from "./ICU4XWordBreakIteratorUtf16.js" +import { ICU4XWordBreakIteratorUtf8 } from "./ICU4XWordBreakIteratorUtf8.js" + +const ICU4XWordSegmenter_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XWordSegmenter_destroy(underlying); +}); + +export class ICU4XWordSegmenter { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XWordSegmenter_box_destroy_registry.register(this, underlying); + } + } + + static create_auto(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XWordSegmenter_create_auto(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XWordSegmenter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_lstm(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XWordSegmenter_create_lstm(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XWordSegmenter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_dictionary(arg_provider) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XWordSegmenter_create_dictionary(diplomat_receive_buffer, arg_provider.underlying); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XWordSegmenter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + segment_utf8(arg_input) { + const buf_arg_input = diplomatRuntime.DiplomatBuf.str(wasm, arg_input); + return new ICU4XWordBreakIteratorUtf8(wasm.ICU4XWordSegmenter_segment_utf8(this.underlying, buf_arg_input.ptr, buf_arg_input.size), true, [this, buf_arg_input]); + } + + segment_utf16(arg_input) { + const buf_arg_input = diplomatRuntime.DiplomatBuf.slice(wasm, arg_input, 2); + return new ICU4XWordBreakIteratorUtf16(wasm.ICU4XWordSegmenter_segment_utf16(this.underlying, buf_arg_input.ptr, buf_arg_input.size), true, [this, buf_arg_input]); + } + + segment_latin1(arg_input) { + const buf_arg_input = diplomatRuntime.DiplomatBuf.slice(wasm, arg_input, 1); + return new ICU4XWordBreakIteratorLatin1(wasm.ICU4XWordSegmenter_segment_latin1(this.underlying, buf_arg_input.ptr, buf_arg_input.size), true, [this, buf_arg_input]); + } +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XZonedDateTimeFormatter.d.ts b/third_party/rust/icu_capi/js/include/ICU4XZonedDateTimeFormatter.d.ts new file mode 100644 index 000000000000..f9c8fab16cb7 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XZonedDateTimeFormatter.d.ts @@ -0,0 +1,59 @@ +import { FFIError } from "./diplomat-runtime" +import { ICU4XCustomTimeZone } from "./ICU4XCustomTimeZone"; +import { ICU4XDataProvider } from "./ICU4XDataProvider"; +import { ICU4XDateLength } from "./ICU4XDateLength"; +import { ICU4XDateTime } from "./ICU4XDateTime"; +import { ICU4XError } from "./ICU4XError"; +import { ICU4XIsoDateTime } from "./ICU4XIsoDateTime"; +import { ICU4XIsoTimeZoneOptions } from "./ICU4XIsoTimeZoneOptions"; +import { ICU4XLocale } from "./ICU4XLocale"; +import { ICU4XTimeLength } from "./ICU4XTimeLength"; + +/** + + * An object capable of formatting a date time with time zone to a string. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.ZonedDateTimeFormatter.html Rust documentation for `ZonedDateTimeFormatter`} for more information. + */ +export class ICU4XZonedDateTimeFormatter { + + /** + + * Creates a new {@link ICU4XZonedDateTimeFormatter `ICU4XZonedDateTimeFormatter`} from locale data. + + * This function has `date_length` and `time_length` arguments and uses default options for the time zone. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.ZonedDateTimeFormatter.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_with_lengths(provider: ICU4XDataProvider, locale: ICU4XLocale, date_length: ICU4XDateLength, time_length: ICU4XTimeLength): ICU4XZonedDateTimeFormatter | never; + + /** + + * Creates a new {@link ICU4XZonedDateTimeFormatter `ICU4XZonedDateTimeFormatter`} from locale data. + + * This function has `date_length` and `time_length` arguments and uses an ISO-8601 style fallback for the time zone with the given configurations. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.ZonedDateTimeFormatter.html#method.try_new_unstable Rust documentation for `try_new_unstable`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + static create_with_lengths_and_iso_8601_time_zone_fallback(provider: ICU4XDataProvider, locale: ICU4XLocale, date_length: ICU4XDateLength, time_length: ICU4XTimeLength, zone_options: ICU4XIsoTimeZoneOptions): ICU4XZonedDateTimeFormatter | never; + + /** + + * Formats a {@link ICU4XDateTime `ICU4XDateTime`} and {@link ICU4XCustomTimeZone `ICU4XCustomTimeZone`} to a string. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.ZonedDateTimeFormatter.html#method.format Rust documentation for `format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + format_datetime_with_custom_time_zone(datetime: ICU4XDateTime, time_zone: ICU4XCustomTimeZone): string | never; + + /** + + * Formats a {@link ICU4XIsoDateTime `ICU4XIsoDateTime`} and {@link ICU4XCustomTimeZone `ICU4XCustomTimeZone`} to a string. + + * See the {@link https://docs.rs/icu/latest/icu/datetime/struct.ZonedDateTimeFormatter.html#method.format Rust documentation for `format`} for more information. + * @throws {@link FFIError}<{@link ICU4XError}> + */ + format_iso_datetime_with_custom_time_zone(datetime: ICU4XIsoDateTime, time_zone: ICU4XCustomTimeZone): string | never; +} diff --git a/third_party/rust/icu_capi/js/include/ICU4XZonedDateTimeFormatter.js b/third_party/rust/icu_capi/js/include/ICU4XZonedDateTimeFormatter.js new file mode 100644 index 000000000000..3dab1732019d --- /dev/null +++ b/third_party/rust/icu_capi/js/include/ICU4XZonedDateTimeFormatter.js @@ -0,0 +1,98 @@ +import wasm from "./diplomat-wasm.mjs" +import * as diplomatRuntime from "./diplomat-runtime.js" +import { ICU4XDateLength_js_to_rust, ICU4XDateLength_rust_to_js } from "./ICU4XDateLength.js" +import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.js" +import { ICU4XIsoTimeZoneFormat_js_to_rust, ICU4XIsoTimeZoneFormat_rust_to_js } from "./ICU4XIsoTimeZoneFormat.js" +import { ICU4XIsoTimeZoneMinuteDisplay_js_to_rust, ICU4XIsoTimeZoneMinuteDisplay_rust_to_js } from "./ICU4XIsoTimeZoneMinuteDisplay.js" +import { ICU4XIsoTimeZoneSecondDisplay_js_to_rust, ICU4XIsoTimeZoneSecondDisplay_rust_to_js } from "./ICU4XIsoTimeZoneSecondDisplay.js" +import { ICU4XTimeLength_js_to_rust, ICU4XTimeLength_rust_to_js } from "./ICU4XTimeLength.js" + +const ICU4XZonedDateTimeFormatter_box_destroy_registry = new FinalizationRegistry(underlying => { + wasm.ICU4XZonedDateTimeFormatter_destroy(underlying); +}); + +export class ICU4XZonedDateTimeFormatter { + #lifetimeEdges = []; + constructor(underlying, owned, edges) { + this.underlying = underlying; + this.#lifetimeEdges.push(...edges); + if (owned) { + ICU4XZonedDateTimeFormatter_box_destroy_registry.register(this, underlying); + } + } + + static create_with_lengths(arg_provider, arg_locale, arg_date_length, arg_time_length) { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XZonedDateTimeFormatter_create_with_lengths(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying, ICU4XDateLength_js_to_rust[arg_date_length], ICU4XTimeLength_js_to_rust[arg_time_length]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XZonedDateTimeFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + static create_with_lengths_and_iso_8601_time_zone_fallback(arg_provider, arg_locale, arg_date_length, arg_time_length, arg_zone_options) { + const field_format_arg_zone_options = arg_zone_options["format"]; + const field_minutes_arg_zone_options = arg_zone_options["minutes"]; + const field_seconds_arg_zone_options = arg_zone_options["seconds"]; + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XZonedDateTimeFormatter_create_with_lengths_and_iso_8601_time_zone_fallback(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying, ICU4XDateLength_js_to_rust[arg_date_length], ICU4XTimeLength_js_to_rust[arg_time_length], ICU4XIsoTimeZoneFormat_js_to_rust[field_format_arg_zone_options], ICU4XIsoTimeZoneMinuteDisplay_js_to_rust[field_minutes_arg_zone_options], ICU4XIsoTimeZoneSecondDisplay_js_to_rust[field_seconds_arg_zone_options]); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = new ICU4XZonedDateTimeFormatter(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []); + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + } + + format_datetime_with_custom_time_zone(arg_datetime, arg_time_zone) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XZonedDateTimeFormatter_format_datetime_with_custom_time_zone(diplomat_receive_buffer, this.underlying, arg_datetime.underlying, arg_time_zone.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } + + format_iso_datetime_with_custom_time_zone(arg_datetime, arg_time_zone) { + return diplomatRuntime.withWriteable(wasm, (writeable) => { + return (() => { + const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4); + wasm.ICU4XZonedDateTimeFormatter_format_iso_datetime_with_custom_time_zone(diplomat_receive_buffer, this.underlying, arg_datetime.underlying, arg_time_zone.underlying, writeable); + const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4); + if (is_ok) { + const ok_value = {}; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + return ok_value; + } else { + const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)]; + wasm.diplomat_free(diplomat_receive_buffer, 5, 4); + throw new diplomatRuntime.FFIError(throw_value); + } + })(); + }); + } +} diff --git a/third_party/rust/icu_capi/js/include/diplomat-runtime.d.ts b/third_party/rust/icu_capi/js/include/diplomat-runtime.d.ts new file mode 100644 index 000000000000..8a8748b6a410 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/diplomat-runtime.d.ts @@ -0,0 +1,20 @@ +/** + * An error that occurred in Rust. + */ +export class FFIError extends Error { + error_value: E; +} + +export type u8 = number; +export type i8 = number; +export type u16 = number; +export type i16 = number; +export type u32 = number; +export type i32 = number; +export type u64 = bigint; +export type i64 = bigint; +export type usize = number; +export type isize = number; +export type f32 = number; +export type f64 = number; +export type char = string; diff --git a/third_party/rust/icu_capi/js/include/diplomat-runtime.js b/third_party/rust/icu_capi/js/include/diplomat-runtime.js new file mode 100644 index 000000000000..75317d4a7463 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/diplomat-runtime.js @@ -0,0 +1,121 @@ +export function readString(wasm, ptr, len) { + const buf = new Uint8Array(wasm.memory.buffer, ptr, len); + return (new TextDecoder("utf-8")).decode(buf) +} + +export function withWriteable(wasm, callback) { + const writeable = wasm.diplomat_buffer_writeable_create(0); + try { + callback(writeable); + const outStringPtr = wasm.diplomat_buffer_writeable_get_bytes(writeable); + const outStringLen = wasm.diplomat_buffer_writeable_len(writeable); + return readString(wasm, outStringPtr, outStringLen); + } finally { + wasm.diplomat_buffer_writeable_destroy(writeable); + } +} + +export class FFIError extends Error { + constructor(error_value) { + super("Error over FFI"); + this.error_value = error_value; // (2) + } +} + +export function extractCodePoint(str, param) { + const cp = str.codePointAt?.(0); + if ((!cp && cp !== 0) || [...str]?.length != 1) { + throw new TypeError(`Expected single-character string for char parameter ${param}, found ${str}`); + } + return cp; +} + +// Get the pointer returned by an FFI function +// +// It's tempting to call `(new Uint32Array(wasm.memory.buffer, FFI_func(), 1))[0]`. +// However, there's a chance that `wasm.memory.buffer` will be resized between +// the time it's accessed and the time it's used, invalidating the view. +// This function ensures that the view into wasm memory is fresh. +// +// This is used for methods that return multiple types into a wasm buffer, where +// one of those types is another ptr. Call this method to get access to the returned +// ptr, so the return buffer can be freed. +export function ptrRead(wasm, ptr) { + return (new Uint32Array(wasm.memory.buffer, ptr, 1))[0]; +} + +// Get the flag of a result type. +export function resultFlag(wasm, ptr, offset) { + return (new Uint8Array(wasm.memory.buffer, ptr + offset, 1))[0]; +} + +// Get the discriminant of a Rust enum. +export function enumDiscriminant(wasm, ptr) { + return (new Int32Array(wasm.memory.buffer, ptr, 1))[0] +} + +// A wrapper around a slice of WASM memory that can be freed manually or +// automatically by the garbage collector. +// +// This type is necessary for Rust functions that take a `&str` or `&[T]`, since +// they can create an edge to this object if they borrow from the str/slice, +// or we can manually free the WASM memory if they don't. +export class DiplomatBuf { + static str = (wasm, string) => { + var utf8_len = 0; + for (const codepoint_string of string) { + let codepoint = codepoint_string.codePointAt(0); + if (codepoint < 0x80) { + utf8_len += 1 + } else if (codepoint < 0x800) { + utf8_len += 2 + } else if (codepoint < 0x10000) { + utf8_len += 3 + } else { + utf8_len += 4 + } + } + return new DiplomatBuf(wasm, utf8_len, 1, buf => { + const result = (new TextEncoder()).encodeInto(string, buf); + console.assert(string.length == result.read && utf8_len == result.written, "UTF-8 write error"); + }) +} + + static slice = (wasm, slice, align) => { + // If the slice is not a Uint8Array, we have to convert to one, as that's the only + // thing we can write into the wasm buffer. + const bytes = slice.constructor.name == "Uint8Array" ? slice : new Uint8Array(slice); + return new DiplomatBuf(wasm, bytes.length, align, buf => buf.set(bytes)); + } + + constructor(wasm, size, align, encodeCallback) { + const ptr = wasm.diplomat_alloc(size, align); + encodeCallback(new Uint8Array(wasm.memory.buffer, ptr, size)); + + this.ptr = ptr; + this.size = size; + this.free = () => { + const successfully_unregistered = DiplomatBuf_finalizer.unregister(this); + if (successfully_unregistered) { + wasm.diplomat_free(this.ptr, this.size, align); + } else { + console.error(`Failed to unregister DiplomatBuf at ${ptr}, this is a bug. Either it was never registered (leak), it was already unregistered (failed attempt to double free), or the unregister token was unrecognized (fallback to GC).`); + } + } + + DiplomatBuf_finalizer.register(this, { wasm, ptr, size, align }, this); + } + + leak = () => { + const successfully_unregistered = DiplomatBuf_finalizer.unregister(this); + if (successfully_unregistered) { + // leak + } else { + console.error(`Failed to unregister DiplomatBuf at ${this.ptr}, this is a bug. Either it was never registered (leak), it was already unregistered (failed attempt to double free), or the unregister token was unrecognized (fallback to GC).`); + } + } +} + +const DiplomatBuf_finalizer = new FinalizationRegistry(({ wasm, ptr, size, align }) => { + wasm.diplomat_free(ptr, size, align); +}); diff --git a/third_party/rust/icu_capi/js/include/diplomat-wasm.mjs b/third_party/rust/icu_capi/js/include/diplomat-wasm.mjs new file mode 100644 index 000000000000..26eb32af4a8a --- /dev/null +++ b/third_party/rust/icu_capi/js/include/diplomat-wasm.mjs @@ -0,0 +1,35 @@ +import cfg from '../diplomat.config.js'; +import {readString} from './diplomat-runtime.js' + +let wasm; + +const imports = { + env: { + log_js(ptr, len) { + console.log(readString(wasm, ptr, len)); + }, + warn_js(ptr, len) { + console.warn(readString(wasm, ptr, len)); + }, + trace_js(ptr, len) { + throw new Error(readString(wasm, ptr, len)); + } + } +} + +if (typeof fetch === 'undefined') { // Node + const fs = await import("fs"); + const wasmFile = new Uint8Array(fs.readFileSync(cfg['wasm_path'])); + const loadedWasm = await WebAssembly.instantiate(wasmFile, imports); + wasm = loadedWasm.instance.exports; +} else { // Browser + const loadedWasm = await WebAssembly.instantiateStreaming(fetch(cfg['wasm_path']), imports); + wasm = loadedWasm.instance.exports; +} + +wasm.diplomat_init(); +if (cfg['init'] !== undefined) { + cfg['init'](wasm); +} + +export default wasm; diff --git a/third_party/rust/icu_capi/js/include/index.d.ts b/third_party/rust/icu_capi/js/include/index.d.ts new file mode 100644 index 000000000000..3515d5fe666e --- /dev/null +++ b/third_party/rust/icu_capi/js/include/index.d.ts @@ -0,0 +1,111 @@ +export { FFIError, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, char } from './diplomat-runtime.js'; +export { CodePointRangeIterator } from './CodePointRangeIterator.js'; +export { CodePointRangeIteratorResult } from './CodePointRangeIteratorResult.js'; +export { ICU4XAnyCalendarKind } from './ICU4XAnyCalendarKind.js'; +export { ICU4XBidi } from './ICU4XBidi.js'; +export { ICU4XBidiDirection } from './ICU4XBidiDirection.js'; +export { ICU4XBidiInfo } from './ICU4XBidiInfo.js'; +export { ICU4XBidiParagraph } from './ICU4XBidiParagraph.js'; +export { ICU4XCalendar } from './ICU4XCalendar.js'; +export { ICU4XCanonicalCombiningClassMap } from './ICU4XCanonicalCombiningClassMap.js'; +export { ICU4XCanonicalComposition } from './ICU4XCanonicalComposition.js'; +export { ICU4XCanonicalDecomposition } from './ICU4XCanonicalDecomposition.js'; +export { ICU4XCodePointMapData16 } from './ICU4XCodePointMapData16.js'; +export { ICU4XCodePointMapData8 } from './ICU4XCodePointMapData8.js'; +export { ICU4XCodePointSetData } from './ICU4XCodePointSetData.js'; +export { ICU4XCollator } from './ICU4XCollator.js'; +export { ICU4XCollatorAlternateHandling } from './ICU4XCollatorAlternateHandling.js'; +export { ICU4XCollatorBackwardSecondLevel } from './ICU4XCollatorBackwardSecondLevel.js'; +export { ICU4XCollatorCaseFirst } from './ICU4XCollatorCaseFirst.js'; +export { ICU4XCollatorCaseLevel } from './ICU4XCollatorCaseLevel.js'; +export { ICU4XCollatorMaxVariable } from './ICU4XCollatorMaxVariable.js'; +export { ICU4XCollatorNumeric } from './ICU4XCollatorNumeric.js'; +export { ICU4XCollatorOptionsV1 } from './ICU4XCollatorOptionsV1.js'; +export { ICU4XCollatorStrength } from './ICU4XCollatorStrength.js'; +export { ICU4XComposingNormalizer } from './ICU4XComposingNormalizer.js'; +export { ICU4XCustomTimeZone } from './ICU4XCustomTimeZone.js'; +export { ICU4XDataProvider } from './ICU4XDataProvider.js'; +export { ICU4XDataStruct } from './ICU4XDataStruct.js'; +export { ICU4XDate } from './ICU4XDate.js'; +export { ICU4XDateFormatter } from './ICU4XDateFormatter.js'; +export { ICU4XDateLength } from './ICU4XDateLength.js'; +export { ICU4XDateTime } from './ICU4XDateTime.js'; +export { ICU4XDateTimeFormatter } from './ICU4XDateTimeFormatter.js'; +export { ICU4XDecomposed } from './ICU4XDecomposed.js'; +export { ICU4XDecomposingNormalizer } from './ICU4XDecomposingNormalizer.js'; +export { ICU4XDisplayNamesFallback } from './ICU4XDisplayNamesFallback.js'; +export { ICU4XDisplayNamesOptionsV1 } from './ICU4XDisplayNamesOptionsV1.js'; +export { ICU4XDisplayNamesStyle } from './ICU4XDisplayNamesStyle.js'; +export { ICU4XError } from './ICU4XError.js'; +export { ICU4XFixedDecimal } from './ICU4XFixedDecimal.js'; +export { ICU4XFixedDecimalFormatter } from './ICU4XFixedDecimalFormatter.js'; +export { ICU4XFixedDecimalGroupingStrategy } from './ICU4XFixedDecimalGroupingStrategy.js'; +export { ICU4XFixedDecimalSign } from './ICU4XFixedDecimalSign.js'; +export { ICU4XFixedDecimalSignDisplay } from './ICU4XFixedDecimalSignDisplay.js'; +export { ICU4XGeneralCategoryNameToMaskMapper } from './ICU4XGeneralCategoryNameToMaskMapper.js'; +export { ICU4XGraphemeClusterBreakIteratorLatin1 } from './ICU4XGraphemeClusterBreakIteratorLatin1.js'; +export { ICU4XGraphemeClusterBreakIteratorUtf16 } from './ICU4XGraphemeClusterBreakIteratorUtf16.js'; +export { ICU4XGraphemeClusterBreakIteratorUtf8 } from './ICU4XGraphemeClusterBreakIteratorUtf8.js'; +export { ICU4XGraphemeClusterSegmenter } from './ICU4XGraphemeClusterSegmenter.js'; +export { ICU4XGregorianDateFormatter } from './ICU4XGregorianDateFormatter.js'; +export { ICU4XGregorianDateTimeFormatter } from './ICU4XGregorianDateTimeFormatter.js'; +export { ICU4XGregorianZonedDateTimeFormatter } from './ICU4XGregorianZonedDateTimeFormatter.js'; +export { ICU4XIsoDate } from './ICU4XIsoDate.js'; +export { ICU4XIsoDateTime } from './ICU4XIsoDateTime.js'; +export { ICU4XIsoTimeZoneFormat } from './ICU4XIsoTimeZoneFormat.js'; +export { ICU4XIsoTimeZoneMinuteDisplay } from './ICU4XIsoTimeZoneMinuteDisplay.js'; +export { ICU4XIsoTimeZoneOptions } from './ICU4XIsoTimeZoneOptions.js'; +export { ICU4XIsoTimeZoneSecondDisplay } from './ICU4XIsoTimeZoneSecondDisplay.js'; +export { ICU4XIsoWeekday } from './ICU4XIsoWeekday.js'; +export { ICU4XLanguageDisplay } from './ICU4XLanguageDisplay.js'; +export { ICU4XLineBreakIteratorLatin1 } from './ICU4XLineBreakIteratorLatin1.js'; +export { ICU4XLineBreakIteratorUtf16 } from './ICU4XLineBreakIteratorUtf16.js'; +export { ICU4XLineBreakIteratorUtf8 } from './ICU4XLineBreakIteratorUtf8.js'; +export { ICU4XLineBreakOptionsV1 } from './ICU4XLineBreakOptionsV1.js'; +export { ICU4XLineBreakStrictness } from './ICU4XLineBreakStrictness.js'; +export { ICU4XLineBreakWordOption } from './ICU4XLineBreakWordOption.js'; +export { ICU4XLineSegmenter } from './ICU4XLineSegmenter.js'; +export { ICU4XList } from './ICU4XList.js'; +export { ICU4XListFormatter } from './ICU4XListFormatter.js'; +export { ICU4XListLength } from './ICU4XListLength.js'; +export { ICU4XLocale } from './ICU4XLocale.js'; +export { ICU4XLocaleCanonicalizer } from './ICU4XLocaleCanonicalizer.js'; +export { ICU4XLocaleDisplayNamesFormatter } from './ICU4XLocaleDisplayNamesFormatter.js'; +export { ICU4XLocaleExpander } from './ICU4XLocaleExpander.js'; +export { ICU4XLocaleFallbackConfig } from './ICU4XLocaleFallbackConfig.js'; +export { ICU4XLocaleFallbackIterator } from './ICU4XLocaleFallbackIterator.js'; +export { ICU4XLocaleFallbackPriority } from './ICU4XLocaleFallbackPriority.js'; +export { ICU4XLocaleFallbacker } from './ICU4XLocaleFallbacker.js'; +export { ICU4XLocaleFallbackerWithConfig } from './ICU4XLocaleFallbackerWithConfig.js'; +export { ICU4XLogger } from './ICU4XLogger.js'; +export { ICU4XMetazoneCalculator } from './ICU4XMetazoneCalculator.js'; +export { ICU4XOrdering } from './ICU4XOrdering.js'; +export { ICU4XPluralCategories } from './ICU4XPluralCategories.js'; +export { ICU4XPluralCategory } from './ICU4XPluralCategory.js'; +export { ICU4XPluralOperands } from './ICU4XPluralOperands.js'; +export { ICU4XPluralRules } from './ICU4XPluralRules.js'; +export { ICU4XPropertyValueNameToEnumMapper } from './ICU4XPropertyValueNameToEnumMapper.js'; +export { ICU4XRegionDisplayNames } from './ICU4XRegionDisplayNames.js'; +export { ICU4XReorderedIndexMap } from './ICU4XReorderedIndexMap.js'; +export { ICU4XScriptExtensionsSet } from './ICU4XScriptExtensionsSet.js'; +export { ICU4XScriptWithExtensions } from './ICU4XScriptWithExtensions.js'; +export { ICU4XScriptWithExtensionsBorrowed } from './ICU4XScriptWithExtensionsBorrowed.js'; +export { ICU4XSegmenterWordType } from './ICU4XSegmenterWordType.js'; +export { ICU4XSentenceBreakIteratorLatin1 } from './ICU4XSentenceBreakIteratorLatin1.js'; +export { ICU4XSentenceBreakIteratorUtf16 } from './ICU4XSentenceBreakIteratorUtf16.js'; +export { ICU4XSentenceBreakIteratorUtf8 } from './ICU4XSentenceBreakIteratorUtf8.js'; +export { ICU4XSentenceSegmenter } from './ICU4XSentenceSegmenter.js'; +export { ICU4XTime } from './ICU4XTime.js'; +export { ICU4XTimeFormatter } from './ICU4XTimeFormatter.js'; +export { ICU4XTimeLength } from './ICU4XTimeLength.js'; +export { ICU4XTimeZoneFormatter } from './ICU4XTimeZoneFormatter.js'; +export { ICU4XTransformResult } from './ICU4XTransformResult.js'; +export { ICU4XUnicodeSetData } from './ICU4XUnicodeSetData.js'; +export { ICU4XWeekCalculator } from './ICU4XWeekCalculator.js'; +export { ICU4XWeekOf } from './ICU4XWeekOf.js'; +export { ICU4XWeekRelativeUnit } from './ICU4XWeekRelativeUnit.js'; +export { ICU4XWordBreakIteratorLatin1 } from './ICU4XWordBreakIteratorLatin1.js'; +export { ICU4XWordBreakIteratorUtf16 } from './ICU4XWordBreakIteratorUtf16.js'; +export { ICU4XWordBreakIteratorUtf8 } from './ICU4XWordBreakIteratorUtf8.js'; +export { ICU4XWordSegmenter } from './ICU4XWordSegmenter.js'; +export { ICU4XZonedDateTimeFormatter } from './ICU4XZonedDateTimeFormatter.js'; diff --git a/third_party/rust/icu_capi/js/include/index.js b/third_party/rust/icu_capi/js/include/index.js new file mode 100644 index 000000000000..ba954b2d4011 --- /dev/null +++ b/third_party/rust/icu_capi/js/include/index.js @@ -0,0 +1,111 @@ +export { FFIError } from './diplomat-runtime.js'; +export { CodePointRangeIterator } from './CodePointRangeIterator.js'; +export { CodePointRangeIteratorResult } from './CodePointRangeIteratorResult.js'; +export { ICU4XAnyCalendarKind } from './ICU4XAnyCalendarKind.js'; +export { ICU4XBidi } from './ICU4XBidi.js'; +export { ICU4XBidiDirection } from './ICU4XBidiDirection.js'; +export { ICU4XBidiInfo } from './ICU4XBidiInfo.js'; +export { ICU4XBidiParagraph } from './ICU4XBidiParagraph.js'; +export { ICU4XCalendar } from './ICU4XCalendar.js'; +export { ICU4XCanonicalCombiningClassMap } from './ICU4XCanonicalCombiningClassMap.js'; +export { ICU4XCanonicalComposition } from './ICU4XCanonicalComposition.js'; +export { ICU4XCanonicalDecomposition } from './ICU4XCanonicalDecomposition.js'; +export { ICU4XCodePointMapData16 } from './ICU4XCodePointMapData16.js'; +export { ICU4XCodePointMapData8 } from './ICU4XCodePointMapData8.js'; +export { ICU4XCodePointSetData } from './ICU4XCodePointSetData.js'; +export { ICU4XCollator } from './ICU4XCollator.js'; +export { ICU4XCollatorAlternateHandling } from './ICU4XCollatorAlternateHandling.js'; +export { ICU4XCollatorBackwardSecondLevel } from './ICU4XCollatorBackwardSecondLevel.js'; +export { ICU4XCollatorCaseFirst } from './ICU4XCollatorCaseFirst.js'; +export { ICU4XCollatorCaseLevel } from './ICU4XCollatorCaseLevel.js'; +export { ICU4XCollatorMaxVariable } from './ICU4XCollatorMaxVariable.js'; +export { ICU4XCollatorNumeric } from './ICU4XCollatorNumeric.js'; +export { ICU4XCollatorOptionsV1 } from './ICU4XCollatorOptionsV1.js'; +export { ICU4XCollatorStrength } from './ICU4XCollatorStrength.js'; +export { ICU4XComposingNormalizer } from './ICU4XComposingNormalizer.js'; +export { ICU4XCustomTimeZone } from './ICU4XCustomTimeZone.js'; +export { ICU4XDataProvider } from './ICU4XDataProvider.js'; +export { ICU4XDataStruct } from './ICU4XDataStruct.js'; +export { ICU4XDate } from './ICU4XDate.js'; +export { ICU4XDateFormatter } from './ICU4XDateFormatter.js'; +export { ICU4XDateLength } from './ICU4XDateLength.js'; +export { ICU4XDateTime } from './ICU4XDateTime.js'; +export { ICU4XDateTimeFormatter } from './ICU4XDateTimeFormatter.js'; +export { ICU4XDecomposed } from './ICU4XDecomposed.js'; +export { ICU4XDecomposingNormalizer } from './ICU4XDecomposingNormalizer.js'; +export { ICU4XDisplayNamesFallback } from './ICU4XDisplayNamesFallback.js'; +export { ICU4XDisplayNamesOptionsV1 } from './ICU4XDisplayNamesOptionsV1.js'; +export { ICU4XDisplayNamesStyle } from './ICU4XDisplayNamesStyle.js'; +export { ICU4XError } from './ICU4XError.js'; +export { ICU4XFixedDecimal } from './ICU4XFixedDecimal.js'; +export { ICU4XFixedDecimalFormatter } from './ICU4XFixedDecimalFormatter.js'; +export { ICU4XFixedDecimalGroupingStrategy } from './ICU4XFixedDecimalGroupingStrategy.js'; +export { ICU4XFixedDecimalSign } from './ICU4XFixedDecimalSign.js'; +export { ICU4XFixedDecimalSignDisplay } from './ICU4XFixedDecimalSignDisplay.js'; +export { ICU4XGeneralCategoryNameToMaskMapper } from './ICU4XGeneralCategoryNameToMaskMapper.js'; +export { ICU4XGraphemeClusterBreakIteratorLatin1 } from './ICU4XGraphemeClusterBreakIteratorLatin1.js'; +export { ICU4XGraphemeClusterBreakIteratorUtf16 } from './ICU4XGraphemeClusterBreakIteratorUtf16.js'; +export { ICU4XGraphemeClusterBreakIteratorUtf8 } from './ICU4XGraphemeClusterBreakIteratorUtf8.js'; +export { ICU4XGraphemeClusterSegmenter } from './ICU4XGraphemeClusterSegmenter.js'; +export { ICU4XGregorianDateFormatter } from './ICU4XGregorianDateFormatter.js'; +export { ICU4XGregorianDateTimeFormatter } from './ICU4XGregorianDateTimeFormatter.js'; +export { ICU4XGregorianZonedDateTimeFormatter } from './ICU4XGregorianZonedDateTimeFormatter.js'; +export { ICU4XIsoDate } from './ICU4XIsoDate.js'; +export { ICU4XIsoDateTime } from './ICU4XIsoDateTime.js'; +export { ICU4XIsoTimeZoneFormat } from './ICU4XIsoTimeZoneFormat.js'; +export { ICU4XIsoTimeZoneMinuteDisplay } from './ICU4XIsoTimeZoneMinuteDisplay.js'; +export { ICU4XIsoTimeZoneOptions } from './ICU4XIsoTimeZoneOptions.js'; +export { ICU4XIsoTimeZoneSecondDisplay } from './ICU4XIsoTimeZoneSecondDisplay.js'; +export { ICU4XIsoWeekday } from './ICU4XIsoWeekday.js'; +export { ICU4XLanguageDisplay } from './ICU4XLanguageDisplay.js'; +export { ICU4XLineBreakIteratorLatin1 } from './ICU4XLineBreakIteratorLatin1.js'; +export { ICU4XLineBreakIteratorUtf16 } from './ICU4XLineBreakIteratorUtf16.js'; +export { ICU4XLineBreakIteratorUtf8 } from './ICU4XLineBreakIteratorUtf8.js'; +export { ICU4XLineBreakOptionsV1 } from './ICU4XLineBreakOptionsV1.js'; +export { ICU4XLineBreakStrictness } from './ICU4XLineBreakStrictness.js'; +export { ICU4XLineBreakWordOption } from './ICU4XLineBreakWordOption.js'; +export { ICU4XLineSegmenter } from './ICU4XLineSegmenter.js'; +export { ICU4XList } from './ICU4XList.js'; +export { ICU4XListFormatter } from './ICU4XListFormatter.js'; +export { ICU4XListLength } from './ICU4XListLength.js'; +export { ICU4XLocale } from './ICU4XLocale.js'; +export { ICU4XLocaleCanonicalizer } from './ICU4XLocaleCanonicalizer.js'; +export { ICU4XLocaleDisplayNamesFormatter } from './ICU4XLocaleDisplayNamesFormatter.js'; +export { ICU4XLocaleExpander } from './ICU4XLocaleExpander.js'; +export { ICU4XLocaleFallbackConfig } from './ICU4XLocaleFallbackConfig.js'; +export { ICU4XLocaleFallbackIterator } from './ICU4XLocaleFallbackIterator.js'; +export { ICU4XLocaleFallbackPriority } from './ICU4XLocaleFallbackPriority.js'; +export { ICU4XLocaleFallbacker } from './ICU4XLocaleFallbacker.js'; +export { ICU4XLocaleFallbackerWithConfig } from './ICU4XLocaleFallbackerWithConfig.js'; +export { ICU4XLogger } from './ICU4XLogger.js'; +export { ICU4XMetazoneCalculator } from './ICU4XMetazoneCalculator.js'; +export { ICU4XOrdering } from './ICU4XOrdering.js'; +export { ICU4XPluralCategories } from './ICU4XPluralCategories.js'; +export { ICU4XPluralCategory } from './ICU4XPluralCategory.js'; +export { ICU4XPluralOperands } from './ICU4XPluralOperands.js'; +export { ICU4XPluralRules } from './ICU4XPluralRules.js'; +export { ICU4XPropertyValueNameToEnumMapper } from './ICU4XPropertyValueNameToEnumMapper.js'; +export { ICU4XRegionDisplayNames } from './ICU4XRegionDisplayNames.js'; +export { ICU4XReorderedIndexMap } from './ICU4XReorderedIndexMap.js'; +export { ICU4XScriptExtensionsSet } from './ICU4XScriptExtensionsSet.js'; +export { ICU4XScriptWithExtensions } from './ICU4XScriptWithExtensions.js'; +export { ICU4XScriptWithExtensionsBorrowed } from './ICU4XScriptWithExtensionsBorrowed.js'; +export { ICU4XSegmenterWordType } from './ICU4XSegmenterWordType.js'; +export { ICU4XSentenceBreakIteratorLatin1 } from './ICU4XSentenceBreakIteratorLatin1.js'; +export { ICU4XSentenceBreakIteratorUtf16 } from './ICU4XSentenceBreakIteratorUtf16.js'; +export { ICU4XSentenceBreakIteratorUtf8 } from './ICU4XSentenceBreakIteratorUtf8.js'; +export { ICU4XSentenceSegmenter } from './ICU4XSentenceSegmenter.js'; +export { ICU4XTime } from './ICU4XTime.js'; +export { ICU4XTimeFormatter } from './ICU4XTimeFormatter.js'; +export { ICU4XTimeLength } from './ICU4XTimeLength.js'; +export { ICU4XTimeZoneFormatter } from './ICU4XTimeZoneFormatter.js'; +export { ICU4XTransformResult } from './ICU4XTransformResult.js'; +export { ICU4XUnicodeSetData } from './ICU4XUnicodeSetData.js'; +export { ICU4XWeekCalculator } from './ICU4XWeekCalculator.js'; +export { ICU4XWeekOf } from './ICU4XWeekOf.js'; +export { ICU4XWeekRelativeUnit } from './ICU4XWeekRelativeUnit.js'; +export { ICU4XWordBreakIteratorLatin1 } from './ICU4XWordBreakIteratorLatin1.js'; +export { ICU4XWordBreakIteratorUtf16 } from './ICU4XWordBreakIteratorUtf16.js'; +export { ICU4XWordBreakIteratorUtf8 } from './ICU4XWordBreakIteratorUtf8.js'; +export { ICU4XWordSegmenter } from './ICU4XWordSegmenter.js'; +export { ICU4XZonedDateTimeFormatter } from './ICU4XZonedDateTimeFormatter.js'; diff --git a/third_party/rust/icu_capi/src/bidi.rs b/third_party/rust/icu_capi/src/bidi.rs new file mode 100644 index 000000000000..c5b3d0fe0047 --- /dev/null +++ b/third_party/rust/icu_capi/src/bidi.rs @@ -0,0 +1,262 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +#[diplomat::bridge] +pub mod ffi { + use alloc::boxed::Box; + use alloc::vec::Vec; + use diplomat_runtime::DiplomatWriteable; + + use core::fmt::Write; + use icu_properties::bidi::BidiClassAdapter; + use icu_properties::maps; + use icu_properties::BidiClass; + use unicode_bidi::BidiInfo; + use unicode_bidi::Level; + use unicode_bidi::Paragraph; + + use crate::errors::ffi::ICU4XError; + use crate::provider::ffi::ICU4XDataProvider; + + pub enum ICU4XBidiDirection { + Ltr, + Rtl, + Mixed, + } + + #[diplomat::opaque] + /// An ICU4X Bidi object, containing loaded bidi data + #[diplomat::rust_link(icu::properties::bidi::BidiClassAdapter, Struct)] + // #[diplomat::rust_link(icu::properties::maps::load_bidi_class, Struct)] + pub struct ICU4XBidi(pub maps::CodePointMapData); + + impl ICU4XBidi { + /// Creates a new [`ICU4XBidi`] from locale data. + #[diplomat::rust_link(icu::properties::bidi::BidiClassAdapter::new, FnInStruct)] + pub fn create(provider: &ICU4XDataProvider) -> Result, ICU4XError> { + Ok(Box::new(ICU4XBidi(maps::load_bidi_class(&provider.0)?))) + } + + /// Use the data loaded in this object to process a string and calculate bidi information + /// + /// Takes in a Level for the default level, if it is an invalid value it will default to LTR + #[diplomat::rust_link(unicode_bidi::BidiInfo::new_with_data_source, FnInStruct)] + #[diplomat::rust_link( + icu::properties::bidi::BidiClassAdapter::bidi_class, + FnInStruct, + hidden + )] + pub fn for_text<'text>( + &self, + text: &'text str, + default_level: u8, + ) -> Box> { + let data = self.0.as_borrowed(); + let adapter = BidiClassAdapter::new(data); + + Box::new(ICU4XBidiInfo(BidiInfo::new_with_data_source( + &adapter, + text, + Level::new(default_level).ok(), + ))) + } + /// Utility function for producing reorderings given a list of levels + /// + /// Produces a map saying which visual index maps to which source index. + /// + /// The levels array must not have values greater than 126 (this is the + /// Bidi maximum explicit depth plus one). + /// Failure to follow this invariant may lead to incorrect results, + /// but is still safe. + #[diplomat::rust_link(unicode_bidi::BidiInfo::reorder_visual, FnInStruct)] + pub fn reorder_visual(&self, levels: &[u8]) -> Box { + let levels = Level::from_slice_unchecked(levels); + Box::new(ICU4XReorderedIndexMap(BidiInfo::reorder_visual(levels))) + } + + /// Check if a Level returned by level_at is an RTL level. + /// + /// Invalid levels (numbers greater than 125) will be assumed LTR + #[diplomat::rust_link(unicode_bidi::Level::is_rtl, FnInStruct)] + pub fn level_is_rtl(level: u8) -> bool { + Level::new(level).unwrap_or_else(|_| Level::ltr()).is_rtl() + } + + /// Check if a Level returned by level_at is an LTR level. + /// + /// Invalid levels (numbers greater than 125) will be assumed LTR + #[diplomat::rust_link(unicode_bidi::Level::is_ltr, FnInStruct)] + pub fn level_is_ltr(level: u8) -> bool { + Level::new(level).unwrap_or_else(|_| Level::ltr()).is_ltr() + } + + /// Get a basic RTL Level value + #[diplomat::rust_link(unicode_bidi::Level::rtl, FnInStruct)] + pub fn level_rtl() -> u8 { + Level::rtl().number() + } + + /// Get a simple LTR Level value + #[diplomat::rust_link(unicode_bidi::Level::ltr, FnInStruct)] + pub fn level_ltr() -> u8 { + Level::ltr().number() + } + } + + /// Thin wrapper around a vector that maps visual indices to source indices + /// + /// `map[visualIndex] = sourceIndex` + /// + /// Produced by `reorder_visual()` on [`ICU4XBidi`]. + #[diplomat::opaque] + pub struct ICU4XReorderedIndexMap(pub Vec); + + impl ICU4XReorderedIndexMap { + /// Get this as a slice/array of indices + pub fn as_slice<'a>(&'a self) -> &'a [usize] { + &self.0 + } + + /// The length of this map + #[allow(clippy::len_without_is_empty)] + pub fn len(&self) -> usize { + self.0.len() + } + + /// Get element at `index`. Returns 0 when out of bounds + /// (note that 0 is also a valid in-bounds value, please use `len()` + /// to avoid out-of-bounds) + pub fn get(&self, index: usize) -> usize { + self.0.get(index).copied().unwrap_or(0) + } + } + + /// An object containing bidi information for a given string, produced by `for_text()` on `ICU4XBidi` + #[diplomat::rust_link(unicode_bidi::BidiInfo, Struct)] + #[diplomat::opaque] + pub struct ICU4XBidiInfo<'text>(pub BidiInfo<'text>); + + impl<'text> ICU4XBidiInfo<'text> { + /// The number of paragraphs contained here + pub fn paragraph_count(&self) -> usize { + self.0.paragraphs.len() + } + + /// Get the nth paragraph, returning None if out of bounds + pub fn paragraph_at(&'text self, n: usize) -> Option>> { + self.0 + .paragraphs + .get(n) + .map(|p| Box::new(ICU4XBidiParagraph(Paragraph::new(&self.0, p)))) + } + + /// The number of bytes in this full text + pub fn size(&self) -> usize { + self.0.levels.len() + } + + /// Get the BIDI level at a particular byte index in the full text. + /// This integer is conceptually a `unicode_bidi::Level`, + /// and can be further inspected using the static methods on ICU4XBidi. + /// + /// Returns 0 (equivalent to `Level::ltr()`) on error + pub fn level_at(&self, pos: usize) -> u8 { + if let Some(l) = self.0.levels.get(pos) { + l.number() + } else { + 0 + } + } + } + + /// Bidi information for a single processed paragraph + #[diplomat::opaque] + pub struct ICU4XBidiParagraph<'info>(pub Paragraph<'info, 'info>); + + impl<'info> ICU4XBidiParagraph<'info> { + /// Given a paragraph index `n` within the surrounding text, this sets this + /// object to the paragraph at that index. Returns `ICU4XError::OutOfBoundsError` when out of bounds. + /// + /// This is equivalent to calling `paragraph_at()` on `ICU4XBidiInfo` but doesn't + /// create a new object + pub fn set_paragraph_in_text(&mut self, n: usize) -> Result<(), ICU4XError> { + let para = self + .0 + .info + .paragraphs + .get(n) + .ok_or(ICU4XError::OutOfBoundsError)?; + self.0 = Paragraph::new(self.0.info, para); + Ok(()) + } + #[diplomat::rust_link(unicode_bidi::Paragraph::level_at, FnInStruct)] + /// The primary direction of this paragraph + pub fn direction(&self) -> ICU4XBidiDirection { + self.0.direction().into() + } + + /// The number of bytes in this paragraph + #[diplomat::rust_link(unicode_bidi::ParagraphInfo::len, FnInStruct)] + pub fn size(&self) -> usize { + self.0.para.len() + } + + /// The start index of this paragraph within the source text + pub fn range_start(&self) -> usize { + self.0.para.range.start + } + + /// The end index of this paragraph within the source text + pub fn range_end(&self) -> usize { + self.0.para.range.end + } + + /// Reorder a line based on display order. The ranges are specified relative to the source text and must be contained + /// within this paragraph's range. + #[diplomat::rust_link(unicode_bidi::Paragraph::level_at, FnInStruct)] + pub fn reorder_line( + &self, + range_start: usize, + range_end: usize, + out: &mut DiplomatWriteable, + ) -> Result<(), ICU4XError> { + if range_start < self.range_start() || range_end > self.range_end() { + return Err(ICU4XError::OutOfBoundsError); + } + + let info = self.0.info; + let para = self.0.para; + + let reordered = info.reorder_line(para, range_start..range_end); + + Ok(out.write_str(&reordered)?) + } + + /// Get the BIDI level at a particular byte index in this paragraph. + /// This integer is conceptually a `unicode_bidi::Level`, + /// and can be further inspected using the static methods on ICU4XBidi. + /// + /// Returns 0 (equivalent to `Level::ltr()`) on error + #[diplomat::rust_link(unicode_bidi::Paragraph::level_at, FnInStruct)] + pub fn level_at(&self, pos: usize) -> u8 { + if pos >= self.size() { + return 0; + } + + self.0.level_at(pos).number() + } + } +} + +use unicode_bidi::Direction; + +impl From for ffi::ICU4XBidiDirection { + fn from(other: Direction) -> Self { + match other { + Direction::Ltr => Self::Ltr, + Direction::Rtl => Self::Rtl, + Direction::Mixed => Self::Mixed, + } + } +} diff --git a/third_party/rust/icu_capi/src/calendar.rs b/third_party/rust/icu_capi/src/calendar.rs new file mode 100644 index 000000000000..659dc6f63747 --- /dev/null +++ b/third_party/rust/icu_capi/src/calendar.rs @@ -0,0 +1,122 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +#[diplomat::bridge] +pub mod ffi { + use alloc::boxed::Box; + use alloc::sync::Arc; + + use core::fmt::Write; + use icu_calendar::{AnyCalendar, AnyCalendarKind}; + + use crate::errors::ffi::ICU4XError; + use crate::locale::ffi::ICU4XLocale; + use crate::provider::ffi::ICU4XDataProvider; + + /// The various calendar types currently supported by [`ICU4XCalendar`] + #[diplomat::enum_convert(AnyCalendarKind, needs_wildcard)] + #[diplomat::rust_link(icu::calendar::AnyCalendarKind, Enum)] + pub enum ICU4XAnyCalendarKind { + /// The kind of an Iso calendar + Iso = 0, + /// The kind of a Gregorian calendar + Gregorian = 1, + /// The kind of a Buddhist calendar + Buddhist = 2, + /// The kind of a Japanese calendar with modern eras + Japanese = 3, + /// The kind of a Japanese calendar with modern and historic eras + JapaneseExtended = 4, + /// The kind of an Ethiopian calendar, with Amete Mihret era + Ethiopian = 5, + /// The kind of an Ethiopian calendar, with Amete Alem era + EthiopianAmeteAlem = 6, + /// The kind of a Indian calendar + Indian = 7, + /// The kind of a Coptic calendar + Coptic = 8, + } + + impl ICU4XAnyCalendarKind { + /// Read the calendar type off of the -u-ca- extension on a locale. + /// + /// Errors if there is no calendar on the locale or if the locale's calendar + /// is not known or supported. + #[diplomat::rust_link(icu::calendar::AnyCalendarKind::get_for_locale, FnInEnum)] + pub fn get_for_locale(locale: &ICU4XLocale) -> Result { + AnyCalendarKind::get_for_locale(&locale.0) + .map(Into::into) + .ok_or(()) + } + + /// Obtain the calendar type given a BCP-47 -u-ca- extension string. + /// + /// Errors if the calendar is not known or supported. + #[diplomat::rust_link(icu::calendar::AnyCalendarKind::get_for_bcp47_value, FnInEnum)] + #[diplomat::rust_link( + icu::calendar::AnyCalendarKind::get_for_bcp47_string, + FnInEnum, + hidden + )] + #[diplomat::rust_link( + icu::calendar::AnyCalendarKind::get_for_bcp47_bytes, + FnInEnum, + hidden + )] + pub fn get_for_bcp47(s: &str) -> Result { + let s = s.as_bytes(); // #2520 + AnyCalendarKind::get_for_bcp47_bytes(s) + .map(Into::into) + .ok_or(()) + } + + /// Obtain the string suitable for use in the -u-ca- extension in a BCP47 locale. + #[diplomat::rust_link(icu::calendar::AnyCalendarKind::as_bcp47_string, FnInEnum)] + #[diplomat::rust_link(icu::calendar::AnyCalendarKind::as_bcp47_value, FnInEnum, hidden)] + pub fn bcp47( + self, + write: &mut diplomat_runtime::DiplomatWriteable, + ) -> Result<(), ICU4XError> { + let kind = AnyCalendarKind::from(self); + Ok(write.write_str(kind.as_bcp47_string())?) + } + } + + #[diplomat::opaque] + #[diplomat::transparent_convert] + #[diplomat::rust_link(icu::calendar::AnyCalendar, Enum)] + pub struct ICU4XCalendar(pub Arc); + + impl ICU4XCalendar { + /// Creates a new [`ICU4XCalendar`] from the specified date and time. + #[diplomat::rust_link(icu::calendar::AnyCalendar::try_new_for_locale_unstable, FnInEnum)] + pub fn create_for_locale( + provider: &ICU4XDataProvider, + locale: &ICU4XLocale, + ) -> Result, ICU4XError> { + let locale = locale.to_datalocale(); + + Ok(Box::new(ICU4XCalendar(Arc::new( + AnyCalendar::try_new_for_locale_unstable(&provider.0, &locale)?, + )))) + } + + /// Creates a new [`ICU4XCalendar`] from the specified date and time. + #[diplomat::rust_link(icu::calendar::AnyCalendar::try_new_unstable, FnInEnum)] + pub fn create_for_kind( + provider: &ICU4XDataProvider, + kind: ICU4XAnyCalendarKind, + ) -> Result, ICU4XError> { + Ok(Box::new(ICU4XCalendar(Arc::new( + AnyCalendar::try_new_unstable(&provider.0, kind.into())?, + )))) + } + + /// Returns the kind of this calendar + #[diplomat::rust_link(icu::calendar::AnyCalendar::kind, FnInEnum)] + pub fn kind(&self) -> ICU4XAnyCalendarKind { + self.0.kind().into() + } + } +} diff --git a/third_party/rust/icu_capi/src/collator.rs b/third_party/rust/icu_capi/src/collator.rs new file mode 100644 index 000000000000..ae42d30f83f7 --- /dev/null +++ b/third_party/rust/icu_capi/src/collator.rs @@ -0,0 +1,232 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +#[diplomat::bridge] +pub mod ffi { + use alloc::boxed::Box; + use icu_collator::{Collator, CollatorOptions}; + + use crate::{ + common::ffi::ICU4XOrdering, errors::ffi::ICU4XError, locale::ffi::ICU4XLocale, + provider::ffi::ICU4XDataProvider, + }; + + #[diplomat::opaque] + #[diplomat::rust_link(icu::collator::Collator, Struct)] + pub struct ICU4XCollator(pub Collator); + + #[diplomat::rust_link(icu::collator::CollatorOptions, Struct)] + #[diplomat::rust_link(icu::collator::CollatorOptions::new, FnInStruct, hidden)] + pub struct ICU4XCollatorOptionsV1 { + pub strength: ICU4XCollatorStrength, + pub alternate_handling: ICU4XCollatorAlternateHandling, + pub case_first: ICU4XCollatorCaseFirst, + pub max_variable: ICU4XCollatorMaxVariable, + pub case_level: ICU4XCollatorCaseLevel, + pub numeric: ICU4XCollatorNumeric, + pub backward_second_level: ICU4XCollatorBackwardSecondLevel, + } + + #[diplomat::rust_link(icu::collator::Strength, Enum)] + pub enum ICU4XCollatorStrength { + Auto = 0, + Primary = 1, + Secondary = 2, + Tertiary = 3, + Quaternary = 4, + Identical = 5, + } + + #[diplomat::rust_link(icu::collator::AlternateHandling, Enum)] + pub enum ICU4XCollatorAlternateHandling { + Auto = 0, + NonIgnorable = 1, + Shifted = 2, + } + + #[diplomat::rust_link(icu::collator::CaseFirst, Enum)] + pub enum ICU4XCollatorCaseFirst { + Auto = 0, + Off = 1, + LowerFirst = 2, + UpperFirst = 3, + } + + #[diplomat::rust_link(icu::collator::MaxVariable, Enum)] + pub enum ICU4XCollatorMaxVariable { + Auto = 0, + Space = 1, + Punctuation = 2, + Symbol = 3, + Currency = 4, + } + + #[diplomat::rust_link(icu::collator::CaseLevel, Enum)] + pub enum ICU4XCollatorCaseLevel { + Auto = 0, + Off = 1, + On = 2, + } + + #[diplomat::rust_link(icu::collator::Numeric, Enum)] + pub enum ICU4XCollatorNumeric { + Auto = 0, + Off = 1, + On = 2, + } + + #[diplomat::rust_link(icu::collator::BackwardSecondLevel, Enum)] + pub enum ICU4XCollatorBackwardSecondLevel { + Auto = 0, + Off = 1, + On = 2, + } + + impl ICU4XCollator { + /// Construct a new Collator instance. + #[diplomat::rust_link(icu::collator::Collator::try_new_unstable, FnInStruct)] + pub fn create_v1( + provider: &ICU4XDataProvider, + locale: &ICU4XLocale, + options: ICU4XCollatorOptionsV1, + ) -> Result, ICU4XError> { + let locale = locale.to_datalocale(); + let options = CollatorOptions::from(options); + + Ok(Box::new(ICU4XCollator(Collator::try_new_unstable( + &provider.0, + &locale, + options, + )?))) + } + + /// Compare potentially ill-formed UTF-8 strings. + /// + /// Ill-formed input is compared + /// as if errors had been replaced with REPLACEMENT CHARACTERs according + /// to the WHATWG Encoding Standard. + #[diplomat::rust_link(icu::collator::Collator::compare_utf8, FnInStruct)] + pub fn compare(&self, left: &str, right: &str) -> ICU4XOrdering { + let left = left.as_bytes(); // #2520 + let right = right.as_bytes(); // #2520 + self.0.compare_utf8(left, right).into() + } + + /// Compare guaranteed well-formed UTF-8 strings. + /// + /// Note: In C++, passing ill-formed UTF-8 strings is undefined behavior + /// (and may be memory-unsafe to do so, too). + #[diplomat::rust_link(icu::collator::Collator::compare, FnInStruct)] + pub fn compare_valid_utf8(&self, left: &str, right: &str) -> ICU4XOrdering { + self.0.compare(left, right).into() + } + + /// Compare potentially ill-formed UTF-16 strings, with unpaired surrogates + /// compared as REPLACEMENT CHARACTER. + #[diplomat::rust_link(icu::collator::Collator::compare_utf16, FnInStruct)] + pub fn compare_utf16(&self, left: &[u16], right: &[u16]) -> ICU4XOrdering { + self.0.compare_utf16(left, right).into() + } + } +} + +use icu_collator::{ + AlternateHandling, BackwardSecondLevel, CaseFirst, CaseLevel, CollatorOptions, MaxVariable, + Numeric, Strength, +}; + +impl From for Option { + fn from(strength: ffi::ICU4XCollatorStrength) -> Option { + match strength { + ffi::ICU4XCollatorStrength::Auto => None, + ffi::ICU4XCollatorStrength::Primary => Some(Strength::Primary), + ffi::ICU4XCollatorStrength::Secondary => Some(Strength::Secondary), + ffi::ICU4XCollatorStrength::Tertiary => Some(Strength::Tertiary), + ffi::ICU4XCollatorStrength::Quaternary => Some(Strength::Quaternary), + ffi::ICU4XCollatorStrength::Identical => Some(Strength::Identical), + } + } +} + +impl From for Option { + fn from(alternate_handling: ffi::ICU4XCollatorAlternateHandling) -> Option { + match alternate_handling { + ffi::ICU4XCollatorAlternateHandling::Auto => None, + ffi::ICU4XCollatorAlternateHandling::NonIgnorable => { + Some(AlternateHandling::NonIgnorable) + } + ffi::ICU4XCollatorAlternateHandling::Shifted => Some(AlternateHandling::Shifted), + } + } +} + +impl From for Option { + fn from(case_first: ffi::ICU4XCollatorCaseFirst) -> Option { + match case_first { + ffi::ICU4XCollatorCaseFirst::Auto => None, + ffi::ICU4XCollatorCaseFirst::Off => Some(CaseFirst::Off), + ffi::ICU4XCollatorCaseFirst::LowerFirst => Some(CaseFirst::LowerFirst), + ffi::ICU4XCollatorCaseFirst::UpperFirst => Some(CaseFirst::UpperFirst), + } + } +} + +impl From for Option { + fn from(max_variable: ffi::ICU4XCollatorMaxVariable) -> Option { + match max_variable { + ffi::ICU4XCollatorMaxVariable::Auto => None, + ffi::ICU4XCollatorMaxVariable::Space => Some(MaxVariable::Space), + ffi::ICU4XCollatorMaxVariable::Punctuation => Some(MaxVariable::Punctuation), + ffi::ICU4XCollatorMaxVariable::Symbol => Some(MaxVariable::Symbol), + ffi::ICU4XCollatorMaxVariable::Currency => Some(MaxVariable::Currency), + } + } +} + +impl From for Option { + fn from(case_level: ffi::ICU4XCollatorCaseLevel) -> Option { + match case_level { + ffi::ICU4XCollatorCaseLevel::Auto => None, + ffi::ICU4XCollatorCaseLevel::Off => Some(CaseLevel::Off), + ffi::ICU4XCollatorCaseLevel::On => Some(CaseLevel::On), + } + } +} + +impl From for Option { + fn from(numeric: ffi::ICU4XCollatorNumeric) -> Option { + match numeric { + ffi::ICU4XCollatorNumeric::Auto => None, + ffi::ICU4XCollatorNumeric::Off => Some(Numeric::Off), + ffi::ICU4XCollatorNumeric::On => Some(Numeric::On), + } + } +} + +impl From for Option { + fn from( + backward_second_level: ffi::ICU4XCollatorBackwardSecondLevel, + ) -> Option { + match backward_second_level { + ffi::ICU4XCollatorBackwardSecondLevel::Auto => None, + ffi::ICU4XCollatorBackwardSecondLevel::Off => Some(BackwardSecondLevel::Off), + ffi::ICU4XCollatorBackwardSecondLevel::On => Some(BackwardSecondLevel::On), + } + } +} + +impl From for CollatorOptions { + fn from(options: ffi::ICU4XCollatorOptionsV1) -> CollatorOptions { + let mut result = CollatorOptions::new(); + result.strength = options.strength.into(); + result.alternate_handling = options.alternate_handling.into(); + result.case_first = options.case_first.into(); + result.max_variable = options.max_variable.into(); + result.case_level = options.case_level.into(); + result.numeric = options.numeric.into(); + result.backward_second_level = options.backward_second_level.into(); + + result + } +} diff --git a/third_party/rust/icu_capi/src/common.rs b/third_party/rust/icu_capi/src/common.rs new file mode 100644 index 000000000000..d11ca260440a --- /dev/null +++ b/third_party/rust/icu_capi/src/common.rs @@ -0,0 +1,16 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +#[diplomat::bridge] +pub mod ffi { + use alloc::boxed::Box; + + #[diplomat::enum_convert(core::cmp::Ordering)] + #[diplomat::rust_link(core::cmp::Ordering, Enum)] + pub enum ICU4XOrdering { + Less = -1, + Equal = 0, + Greater = 1, + } +} diff --git a/third_party/rust/icu_capi/src/data_struct.rs b/third_party/rust/icu_capi/src/data_struct.rs new file mode 100644 index 000000000000..b2213209cf4e --- /dev/null +++ b/third_party/rust/icu_capi/src/data_struct.rs @@ -0,0 +1,87 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +#[cfg(feature = "icu_decimal")] +use alloc::borrow::{Cow, ToOwned}; + +#[diplomat::bridge] +pub mod ffi { + + #[cfg(feature = "icu_decimal")] + use crate::errors::ffi::ICU4XError; + use alloc::boxed::Box; + use icu_provider::{AnyPayload, DataPayload}; + + #[diplomat::opaque] + /// A generic data struct to be used by ICU4X + /// + /// This can be used to construct a StructDataProvider. + pub struct ICU4XDataStruct(pub(crate) AnyPayload); + + impl ICU4XDataStruct { + /// Construct a new DecimalSymbolsV1 data struct. + /// + /// C++ users: All string arguments must be valid UTF8 + #[diplomat::rust_link(icu::decimal::provider::DecimalSymbolsV1, Struct)] + #[allow(clippy::too_many_arguments)] + #[cfg(feature = "icu_decimal")] + pub fn create_decimal_symbols_v1( + plus_sign_prefix: &str, + plus_sign_suffix: &str, + minus_sign_prefix: &str, + minus_sign_suffix: &str, + decimal_separator: &str, + grouping_separator: &str, + primary_group_size: u8, + secondary_group_size: u8, + min_group_size: u8, + digits: &[char], + ) -> Result, ICU4XError> { + use super::str_to_cow; + use icu_decimal::provider::{ + AffixesV1, DecimalSymbolsV1, DecimalSymbolsV1Marker, GroupingSizesV1, + }; + let digits = if digits.len() == 10 { + let mut new_digits = ['\0'; 10]; + new_digits.copy_from_slice(digits); + new_digits + } else { + return Err(ICU4XError::DataStructValidityError); + }; + let plus_sign_affixes = AffixesV1 { + prefix: str_to_cow(plus_sign_prefix), + suffix: str_to_cow(plus_sign_suffix), + }; + let minus_sign_affixes = AffixesV1 { + prefix: str_to_cow(minus_sign_prefix), + suffix: str_to_cow(minus_sign_suffix), + }; + let grouping_sizes = GroupingSizesV1 { + primary: primary_group_size, + secondary: secondary_group_size, + min_grouping: min_group_size, + }; + + let symbols = DecimalSymbolsV1 { + plus_sign_affixes, + minus_sign_affixes, + decimal_separator: str_to_cow(decimal_separator), + grouping_separator: str_to_cow(grouping_separator), + grouping_sizes, + digits, + }; + + let payload: DataPayload = DataPayload::from_owned(symbols); + Ok(Box::new(ICU4XDataStruct(payload.wrap_into_any_payload()))) + } + } +} +#[cfg(feature = "icu_decimal")] +fn str_to_cow(s: &str) -> Cow<'static, str> { + if s.is_empty() { + Cow::default() + } else { + Cow::from(s.to_owned()) + } +} diff --git a/third_party/rust/icu_capi/src/date.rs b/third_party/rust/icu_capi/src/date.rs new file mode 100644 index 000000000000..87a6810b7b36 --- /dev/null +++ b/third_party/rust/icu_capi/src/date.rs @@ -0,0 +1,288 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +#[diplomat::bridge] +pub mod ffi { + use alloc::boxed::Box; + use alloc::sync::Arc; + use core::fmt::Write; + use icu_calendar::types::IsoWeekday; + use icu_calendar::AnyCalendar; + use icu_calendar::{Date, Iso}; + use tinystr::TinyAsciiStr; + + use crate::calendar::ffi::ICU4XCalendar; + use crate::errors::ffi::ICU4XError; + + #[cfg(feature = "icu_calendar")] + use crate::week::ffi::ICU4XWeekCalculator; + + #[diplomat::enum_convert(IsoWeekday)] + pub enum ICU4XIsoWeekday { + Monday = 1, + Tuesday, + Wednesday, + Thursday, + Friday, + Saturday, + Sunday, + } + #[diplomat::opaque] + #[diplomat::transparent_convert] + /// An ICU4X Date object capable of containing a ISO-8601 date + #[diplomat::rust_link(icu::calendar::Date, Struct)] + pub struct ICU4XIsoDate(pub Date); + + impl ICU4XIsoDate { + /// Creates a new [`ICU4XIsoDate`] from the specified date and time. + #[diplomat::rust_link(icu::calendar::Date::try_new_iso_date, FnInStruct)] + pub fn create(year: i32, month: u8, day: u8) -> Result, ICU4XError> { + Ok(Box::new(ICU4XIsoDate(Date::try_new_iso_date( + year, month, day, + )?))) + } + + /// Convert this date to one in a different calendar + #[diplomat::rust_link(icu::calendar::Date::to_calendar, FnInStruct)] + pub fn to_calendar(&self, calendar: &ICU4XCalendar) -> Box { + Box::new(ICU4XDate(self.0.to_calendar(calendar.0.clone()))) + } + + #[diplomat::rust_link(icu::calendar::Date::to_any, FnInStruct)] + pub fn to_any(&self) -> Box { + Box::new(ICU4XDate(self.0.to_any().wrap_calendar_in_arc())) + } + + /// Returns the 1-indexed day in the month for this date + #[diplomat::rust_link(icu::calendar::Date::day_of_month, FnInStruct)] + pub fn day_of_month(&self) -> u32 { + self.0.day_of_month().0 + } + + /// Returns the day in the week for this day + #[diplomat::rust_link(icu::calendar::Date::day_of_week, FnInStruct)] + pub fn day_of_week(&self) -> ICU4XIsoWeekday { + self.0.day_of_week().into() + } + + /// Returns the week number in this month, 1-indexed, based on what + /// is considered the first day of the week (often a locale preference). + /// + /// `first_weekday` can be obtained via `first_weekday()` on [`ICU4XWeekCalculator`] + #[diplomat::rust_link(icu::calendar::Date::week_of_month, FnInStruct)] + #[diplomat::rust_link( + icu::calendar::week::WeekCalculator::week_of_month, + FnInStruct, + hidden + )] + pub fn week_of_month(&self, first_weekday: ICU4XIsoWeekday) -> u32 { + self.0.week_of_month(first_weekday.into()).0 + } + + /// Returns the week number in this year, using week data + #[diplomat::rust_link(icu::calendar::Date::week_of_year, FnInStruct)] + #[diplomat::rust_link( + icu::calendar::week::WeekCalculator::week_of_year, + FnInStruct, + hidden + )] + #[cfg(feature = "icu_calendar")] + pub fn week_of_year( + &self, + calculator: &ICU4XWeekCalculator, + ) -> Result { + Ok(self.0.week_of_year(&calculator.0)?.into()) + } + + /// Returns 1-indexed number of the month of this date in its year + #[diplomat::rust_link(icu::calendar::Date::month, FnInStruct)] + pub fn month(&self) -> u32 { + self.0.month().ordinal + } + + /// Returns the year number for this date + #[diplomat::rust_link(icu::calendar::Date::year, FnInStruct)] + pub fn year(&self) -> i32 { + self.0.year().number + } + + /// Returns the number of months in the year represented by this date + #[diplomat::rust_link(icu::calendar::Date::months_in_year, FnInStruct)] + pub fn months_in_year(&self) -> u8 { + self.0.months_in_year() + } + + /// Returns the number of days in the month represented by this date + #[diplomat::rust_link(icu::calendar::Date::days_in_month, FnInStruct)] + pub fn days_in_month(&self) -> u8 { + self.0.days_in_month() + } + + /// Returns the number of days in the year represented by this date + #[diplomat::rust_link(icu::calendar::Date::days_in_year, FnInStruct)] + pub fn days_in_year(&self) -> u32 { + self.0.days_in_year() + } + } + + #[diplomat::opaque] + #[diplomat::transparent_convert] + /// An ICU4X Date object capable of containing a date and time for any calendar. + #[diplomat::rust_link(icu::calendar::Date, Struct)] + pub struct ICU4XDate(pub Date>); + + impl ICU4XDate { + /// Creates a new [`ICU4XDate`] representing the ISO date and time + /// given but in a given calendar + #[diplomat::rust_link(icu::calendar::Date::new_from_iso, FnInStruct)] + pub fn create_from_iso_in_calendar( + year: i32, + month: u8, + day: u8, + calendar: &ICU4XCalendar, + ) -> Result, ICU4XError> { + let cal = calendar.0.clone(); + Ok(Box::new(ICU4XDate( + Date::try_new_iso_date(year, month, day)?.to_calendar(cal), + ))) + } + + /// Creates a new [`ICU4XDate`] from the given codes, which are interpreted in the given calendar system + #[diplomat::rust_link(icu::calendar::Date::try_new_from_codes, FnInStruct)] + pub fn create_from_codes_in_calendar( + era_code: &str, + year: i32, + month_code: &str, + day: u8, + calendar: &ICU4XCalendar, + ) -> Result, ICU4XError> { + let era_code = era_code.as_bytes(); // #2520 + let month_code = month_code.as_bytes(); // #2520 + let era = TinyAsciiStr::from_bytes(era_code)?.into(); + let month = TinyAsciiStr::from_bytes(month_code)?.into(); + let cal = calendar.0.clone(); + Ok(Box::new(ICU4XDate(Date::try_new_from_codes( + era, year, month, day, cal, + )?))) + } + + /// Convert this date to one in a different calendar + #[diplomat::rust_link(icu::calendar::Date::to_calendar, FnInStruct)] + pub fn to_calendar(&self, calendar: &ICU4XCalendar) -> Box { + Box::new(ICU4XDate(self.0.to_calendar(calendar.0.clone()))) + } + + /// Converts this date to ISO + #[diplomat::rust_link(icu::calendar::Date::to_iso, FnInStruct)] + pub fn to_iso(&self) -> Box { + Box::new(ICU4XIsoDate(self.0.to_iso())) + } + + /// Returns the 1-indexed day in the month for this date + #[diplomat::rust_link(icu::calendar::Date::day_of_month, FnInStruct)] + pub fn day_of_month(&self) -> u32 { + self.0.day_of_month().0 + } + + /// Returns the day in the week for this day + #[diplomat::rust_link(icu::calendar::Date::day_of_week, FnInStruct)] + pub fn day_of_week(&self) -> ICU4XIsoWeekday { + self.0.day_of_week().into() + } + + /// Returns the week number in this month, 1-indexed, based on what + /// is considered the first day of the week (often a locale preference). + /// + /// `first_weekday` can be obtained via `first_weekday()` on [`ICU4XWeekCalculator`] + #[diplomat::rust_link(icu::calendar::Date::week_of_month, FnInStruct)] + #[diplomat::rust_link( + icu::calendar::week::WeekCalculator::week_of_month, + FnInStruct, + hidden + )] + pub fn week_of_month(&self, first_weekday: ICU4XIsoWeekday) -> u32 { + self.0.week_of_month(first_weekday.into()).0 + } + + /// Returns the week number in this year, using week data + #[diplomat::rust_link(icu::calendar::Date::week_of_year, FnInStruct)] + #[diplomat::rust_link( + icu::calendar::week::WeekCalculator::week_of_year, + FnInStruct, + hidden + )] + #[cfg(feature = "icu_calendar")] + pub fn week_of_year( + &self, + calculator: &ICU4XWeekCalculator, + ) -> Result { + Ok(self.0.week_of_year(&calculator.0)?.into()) + } + + /// Returns 1-indexed number of the month of this date in its year + /// + /// Note that for lunar calendars this may not lead to the same month + /// having the same ordinal month across years; use month_code if you care + /// about month identity. + #[diplomat::rust_link(icu::calendar::Date::month, FnInStruct)] + pub fn ordinal_month(&self) -> u32 { + self.0.month().ordinal + } + + /// Returns the month code for this date. Typically something + /// like "M01", "M02", but can be more complicated for lunar calendars. + #[diplomat::rust_link(icu::calendar::Date::month, FnInStruct)] + pub fn month_code( + &self, + write: &mut diplomat_runtime::DiplomatWriteable, + ) -> Result<(), ICU4XError> { + let code = self.0.month().code; + write.write_str(&code.0)?; + Ok(()) + } + + /// Returns the year number in the current era for this date + #[diplomat::rust_link(icu::calendar::Date::year, FnInStruct)] + pub fn year_in_era(&self) -> i32 { + self.0.year().number + } + + /// Returns the era for this date, + #[diplomat::rust_link(icu::Date::year, FnInStruct)] + #[diplomat::rust_link(icu::types::Era, Struct, compact)] + pub fn era( + &self, + write: &mut diplomat_runtime::DiplomatWriteable, + ) -> Result<(), ICU4XError> { + let era = self.0.year().era; + write.write_str(&era.0)?; + Ok(()) + } + + /// Returns the number of months in the year represented by this date + #[diplomat::rust_link(icu::calendar::Date::months_in_year, FnInStruct)] + pub fn months_in_year(&self) -> u8 { + self.0.months_in_year() + } + + /// Returns the number of days in the month represented by this date + #[diplomat::rust_link(icu::calendar::Date::days_in_month, FnInStruct)] + pub fn days_in_month(&self) -> u8 { + self.0.days_in_month() + } + + /// Returns the number of days in the year represented by this date + #[diplomat::rust_link(icu::calendar::Date::days_in_year, FnInStruct)] + pub fn days_in_year(&self) -> u32 { + self.0.days_in_year() + } + + /// Returns the [`ICU4XCalendar`] object backing this date + #[diplomat::rust_link(icu::calendar::Date::calendar, FnInStruct)] + #[diplomat::rust_link(icu::calendar::Date::calendar_wrapper, FnInStruct, hidden)] + pub fn calendar(&self) -> Box { + Box::new(ICU4XCalendar(self.0.calendar_wrapper().clone())) + } + } +} diff --git a/third_party/rust/icu_capi/src/datetime.rs b/third_party/rust/icu_capi/src/datetime.rs new file mode 100644 index 000000000000..768d7c968f35 --- /dev/null +++ b/third_party/rust/icu_capi/src/datetime.rs @@ -0,0 +1,408 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +#[diplomat::bridge] +pub mod ffi { + use alloc::boxed::Box; + use alloc::sync::Arc; + use core::convert::TryInto; + use core::fmt::Write; + + use icu_calendar::types::Time; + use icu_calendar::AnyCalendar; + use icu_calendar::{DateTime, Iso}; + use tinystr::TinyAsciiStr; + + use crate::calendar::ffi::ICU4XCalendar; + use crate::date::ffi::{ICU4XDate, ICU4XIsoDate, ICU4XIsoWeekday}; + use crate::errors::ffi::ICU4XError; + use crate::time::ffi::ICU4XTime; + + #[cfg(feature = "icu_calendar")] + use crate::week::ffi::ICU4XWeekCalculator; + + #[diplomat::opaque] + /// An ICU4X DateTime object capable of containing a ISO-8601 date and time. + #[diplomat::rust_link(icu::calendar::DateTime, Struct)] + pub struct ICU4XIsoDateTime(pub DateTime); + + impl ICU4XIsoDateTime { + /// Creates a new [`ICU4XIsoDateTime`] from the specified date and time. + #[diplomat::rust_link(icu::calendar::DateTime::try_new_iso_datetime, FnInStruct)] + pub fn create( + year: i32, + month: u8, + day: u8, + hour: u8, + minute: u8, + second: u8, + nanosecond: u32, + ) -> Result, ICU4XError> { + let mut dt = DateTime::try_new_iso_datetime(year, month, day, hour, minute, second)?; + dt.time.nanosecond = nanosecond.try_into()?; + Ok(Box::new(ICU4XIsoDateTime(dt))) + } + + /// Creates a new [`ICU4XIsoDateTime`] from an [`ICU4XIsoDate`] and [`ICU4XTime`] object + #[diplomat::rust_link(icu::calendar::DateTime::new, FnInStruct)] + pub fn crate_from_date_and_time( + date: &ICU4XIsoDate, + time: &ICU4XTime, + ) -> Box { + let dt = DateTime::new(date.0, time.0); + Box::new(ICU4XIsoDateTime(dt)) + } + + /// Construct from the minutes since the local unix epoch for this date (Jan 1 1970, 00:00) + #[diplomat::rust_link( + icu::calendar::DateTime::from_minutes_since_local_unix_epoch, + FnInStruct + )] + pub fn create_from_minutes_since_local_unix_epoch(minutes: i32) -> Box { + Box::new(ICU4XIsoDateTime( + DateTime::from_minutes_since_local_unix_epoch(minutes), + )) + } + + /// Gets the date contained in this object + #[diplomat::rust_link(icu::calendar::DateTime::date, StructField)] + pub fn date(&self) -> Box { + Box::new(ICU4XIsoDate(self.0.date)) + } + + /// Gets the time contained in this object + #[diplomat::rust_link(icu::calendar::DateTime::time, StructField)] + pub fn time(&self) -> Box { + Box::new(ICU4XTime(self.0.time)) + } + + /// Converts this to an [`ICU4XDateTime`] capable of being mixed with dates of + /// other calendars + #[diplomat::rust_link(icu::calendar::DateTime::to_any, FnInStruct)] + #[diplomat::rust_link(icu::calendar::DateTime::new_from_iso, FnInStruct, hidden)] + pub fn to_any(&self) -> Box { + Box::new(ICU4XDateTime(self.0.to_any().wrap_calendar_in_arc())) + } + + /// Gets the minutes since the local unix epoch for this date (Jan 1 1970, 00:00) + #[diplomat::rust_link(icu::calendar::DateTime::minutes_since_local_unix_epoch, FnInStruct)] + pub fn minutes_since_local_unix_epoch(&self) -> i32 { + self.0.minutes_since_local_unix_epoch() + } + + /// Convert this datetime to one in a different calendar + #[diplomat::rust_link(icu::calendar::DateTime::to_calendar, FnInStruct)] + pub fn to_calendar(&self, calendar: &ICU4XCalendar) -> Box { + Box::new(ICU4XDateTime(self.0.to_calendar(calendar.0.clone()))) + } + + /// Returns the hour in this time + #[diplomat::rust_link(icu::calendar::types::Time::hour, StructField)] + pub fn hour(&self) -> u8 { + self.0.time.hour.into() + } + /// Returns the minute in this time + #[diplomat::rust_link(icu::calendar::types::Time::minute, StructField)] + pub fn minute(&self) -> u8 { + self.0.time.minute.into() + } + /// Returns the second in this time + #[diplomat::rust_link(icu::calendar::types::Time::second, StructField)] + pub fn second(&self) -> u8 { + self.0.time.second.into() + } + /// Returns the nanosecond in this time + #[diplomat::rust_link(icu::calendar::types::Time::nanosecond, StructField)] + pub fn nanosecond(&self) -> u32 { + self.0.time.nanosecond.into() + } + + /// Returns the 1-indexed day in the month for this date + #[diplomat::rust_link(icu::calendar::Date::day_of_month, FnInStruct)] + pub fn day_of_month(&self) -> u32 { + self.0.date.day_of_month().0 + } + + /// Returns the day in the week for this day + #[diplomat::rust_link(icu::calendar::Date::day_of_week, FnInStruct)] + pub fn day_of_week(&self) -> ICU4XIsoWeekday { + self.0.date.day_of_week().into() + } + + /// Returns the week number in this month, 1-indexed, based on what + /// is considered the first day of the week (often a locale preference). + /// + /// `first_weekday` can be obtained via `first_weekday()` on [`ICU4XWeekCalculator`] + #[diplomat::rust_link(icu::calendar::Date::week_of_month, FnInStruct)] + #[diplomat::rust_link( + icu::calendar::week::WeekCalculator::week_of_month, + FnInStruct, + hidden + )] + pub fn week_of_month(&self, first_weekday: ICU4XIsoWeekday) -> u32 { + self.0.date.week_of_month(first_weekday.into()).0 + } + + /// Returns the week number in this year, using week data + #[diplomat::rust_link(icu::calendar::Date::week_of_year, FnInStruct)] + #[diplomat::rust_link( + icu::calendar::week::WeekCalculator::week_of_year, + FnInStruct, + hidden + )] + #[cfg(feature = "icu_calendar")] + pub fn week_of_year( + &self, + calculator: &ICU4XWeekCalculator, + ) -> Result { + Ok(self.0.date.week_of_year(&calculator.0)?.into()) + } + + /// Returns 1-indexed number of the month of this date in its year + #[diplomat::rust_link(icu::calendar::Date::month, FnInStruct)] + pub fn month(&self) -> u32 { + self.0.date.month().ordinal + } + + /// Returns the year number for this date + #[diplomat::rust_link(icu::calendar::Date::year, FnInStruct)] + pub fn year(&self) -> i32 { + self.0.date.year().number + } + + /// Returns the number of months in the year represented by this date + #[diplomat::rust_link(icu::calendar::Date::months_in_year, FnInStruct)] + pub fn months_in_year(&self) -> u8 { + self.0.date.months_in_year() + } + + /// Returns the number of days in the month represented by this date + #[diplomat::rust_link(icu::calendar::Date::days_in_month, FnInStruct)] + pub fn days_in_month(&self) -> u8 { + self.0.date.days_in_month() + } + + /// Returns the number of days in the year represented by this date + #[diplomat::rust_link(icu::calendar::Date::days_in_year, FnInStruct)] + pub fn days_in_year(&self) -> u32 { + self.0.date.days_in_year() + } + } + + #[diplomat::opaque] + /// An ICU4X DateTime object capable of containing a date and time for any calendar. + #[diplomat::rust_link(icu::calendar::DateTime, Struct)] + pub struct ICU4XDateTime(pub DateTime>); + + impl ICU4XDateTime { + /// Creates a new [`ICU4XDateTime`] representing the ISO date and time + /// given but in a given calendar + #[diplomat::rust_link(icu::DateTime::new_from_iso, FnInStruct)] + #[allow(clippy::too_many_arguments)] + pub fn create_from_iso_in_calendar( + year: i32, + month: u8, + day: u8, + hour: u8, + minute: u8, + second: u8, + nanosecond: u32, + calendar: &ICU4XCalendar, + ) -> Result, ICU4XError> { + let cal = calendar.0.clone(); + let mut dt = DateTime::try_new_iso_datetime(year, month, day, hour, minute, second)?; + dt.time.nanosecond = nanosecond.try_into()?; + Ok(Box::new(ICU4XDateTime(dt.to_calendar(cal)))) + } + /// Creates a new [`ICU4XDateTime`] from the given codes, which are interpreted in the given calendar system + #[diplomat::rust_link(icu::calendar::DateTime::try_new_from_codes, FnInStruct)] + #[allow(clippy::too_many_arguments)] + pub fn create_from_codes_in_calendar( + era_code: &str, + year: i32, + month_code: &str, + day: u8, + hour: u8, + minute: u8, + second: u8, + nanosecond: u32, + calendar: &ICU4XCalendar, + ) -> Result, ICU4XError> { + let era_code = era_code.as_bytes(); // #2520 + let month_code = month_code.as_bytes(); // #2520 + let era = TinyAsciiStr::from_bytes(era_code)?.into(); + let month = TinyAsciiStr::from_bytes(month_code)?.into(); + let cal = calendar.0.clone(); + let hour = hour.try_into()?; + let minute = minute.try_into()?; + let second = second.try_into()?; + let nanosecond = nanosecond.try_into()?; + let time = Time { + hour, + minute, + second, + nanosecond, + }; + Ok(Box::new(ICU4XDateTime(DateTime::try_new_from_codes( + era, year, month, day, time, cal, + )?))) + } + /// Creates a new [`ICU4XDateTime`] from an [`ICU4XDate`] and [`ICU4XTime`] object + #[diplomat::rust_link(icu::calendar::DateTime::new, FnInStruct)] + pub fn create_from_date_and_time(date: &ICU4XDate, time: &ICU4XTime) -> Box { + let dt = DateTime::new(date.0.clone(), time.0); + Box::new(ICU4XDateTime(dt)) + } + + /// Gets a copy of the date contained in this object + #[diplomat::rust_link(icu::calendar::DateTime::date, StructField)] + pub fn date(&self) -> Box { + Box::new(ICU4XDate(self.0.date.clone())) + } + + /// Gets the time contained in this object + #[diplomat::rust_link(icu::calendar::DateTime::time, StructField)] + pub fn time(&self) -> Box { + Box::new(ICU4XTime(self.0.time)) + } + + /// Converts this date to ISO + #[diplomat::rust_link(icu::calendar::DateTime::to_iso, FnInStruct)] + pub fn to_iso(&self) -> Box { + Box::new(ICU4XIsoDateTime(self.0.to_iso())) + } + + /// Convert this datetime to one in a different calendar + #[diplomat::rust_link(icu::calendar::DateTime::to_calendar, FnInStruct)] + pub fn to_calendar(&self, calendar: &ICU4XCalendar) -> Box { + Box::new(ICU4XDateTime(self.0.to_calendar(calendar.0.clone()))) + } + + /// Returns the hour in this time + #[diplomat::rust_link(icu::calendar::types::Time::hour, StructField)] + pub fn hour(&self) -> u8 { + self.0.time.hour.into() + } + /// Returns the minute in this time + #[diplomat::rust_link(icu::calendar::types::Time::minute, StructField)] + pub fn minute(&self) -> u8 { + self.0.time.minute.into() + } + /// Returns the second in this time + #[diplomat::rust_link(icu::calendar::types::Time::second, StructField)] + pub fn second(&self) -> u8 { + self.0.time.second.into() + } + /// Returns the nanosecond in this time + #[diplomat::rust_link(icu::calendar::types::Time::nanosecond, StructField)] + pub fn nanosecond(&self) -> u32 { + self.0.time.nanosecond.into() + } + + /// Returns the 1-indexed day in the month for this date + #[diplomat::rust_link(icu::calendar::Date::day_of_month, FnInStruct)] + pub fn day_of_month(&self) -> u32 { + self.0.date.day_of_month().0 + } + + /// Returns the day in the week for this day + #[diplomat::rust_link(icu::calendar::Date::day_of_week, FnInStruct)] + pub fn day_of_week(&self) -> ICU4XIsoWeekday { + self.0.date.day_of_week().into() + } + + /// Returns the week number in this month, 1-indexed, based on what + /// is considered the first day of the week (often a locale preference). + /// + /// `first_weekday` can be obtained via `first_weekday()` on [`ICU4XWeekCalculator`] + #[diplomat::rust_link(icu::calendar::Date::week_of_month, FnInStruct)] + #[diplomat::rust_link( + icu::calendar::week::WeekCalculator::week_of_month, + FnInStruct, + hidden + )] + pub fn week_of_month(&self, first_weekday: ICU4XIsoWeekday) -> u32 { + self.0.date.week_of_month(first_weekday.into()).0 + } + + /// Returns the week number in this year, using week data + #[diplomat::rust_link(icu::calendar::Date::week_of_year, FnInStruct)] + #[diplomat::rust_link( + icu::calendar::week::WeekCalculator::week_of_year, + FnInStruct, + hidden + )] + #[cfg(feature = "icu_calendar")] + pub fn week_of_year( + &self, + calculator: &ICU4XWeekCalculator, + ) -> Result { + Ok(self.0.date.week_of_year(&calculator.0)?.into()) + } + + /// Returns 1-indexed number of the month of this date in its year + /// + /// Note that for lunar calendars this may not lead to the same month + /// having the same ordinal month across years; use month_code if you care + /// about month identity. + #[diplomat::rust_link(icu::calendar::Date::month, FnInStruct)] + pub fn ordinal_month(&self) -> u32 { + self.0.date.month().ordinal + } + + /// Returns the month code for this date. Typically something + /// like "M01", "M02", but can be more complicated for lunar calendars. + #[diplomat::rust_link(icu::calendar::Date::month, FnInStruct)] + pub fn month_code( + &self, + write: &mut diplomat_runtime::DiplomatWriteable, + ) -> Result<(), ICU4XError> { + let code = self.0.date.month().code; + write.write_str(&code.0)?; + Ok(()) + } + + /// Returns the year number in the current era for this date + #[diplomat::rust_link(icu::calendar::Date::year, FnInStruct)] + pub fn year_in_era(&self) -> i32 { + self.0.date.year().number + } + + /// Returns the era for this date, + #[diplomat::rust_link(icu::calendar::Date::year, FnInStruct)] + pub fn era( + &self, + write: &mut diplomat_runtime::DiplomatWriteable, + ) -> Result<(), ICU4XError> { + let era = self.0.date.year().era; + write.write_str(&era.0)?; + Ok(()) + } + + /// Returns the number of months in the year represented by this date + #[diplomat::rust_link(icu::calendar::Date::months_in_year, FnInStruct)] + pub fn months_in_year(&self) -> u8 { + self.0.date.months_in_year() + } + + /// Returns the number of days in the month represented by this date + #[diplomat::rust_link(icu::calendar::Date::days_in_month, FnInStruct)] + pub fn days_in_month(&self) -> u8 { + self.0.date.days_in_month() + } + + /// Returns the number of days in the year represented by this date + #[diplomat::rust_link(icu::calendar::Date::days_in_year, FnInStruct)] + pub fn days_in_year(&self) -> u32 { + self.0.date.days_in_year() + } + + /// Returns the [`ICU4XCalendar`] object backing this date + #[diplomat::rust_link(icu::calendar::Date::calendar, FnInStruct)] + #[diplomat::rust_link(icu::calendar::Date::calendar_wrapper, FnInStruct, hidden)] + pub fn calendar(&self) -> Box { + Box::new(ICU4XCalendar(self.0.date.calendar_wrapper().clone())) + } + } +} diff --git a/third_party/rust/icu_capi/src/datetime_formatter.rs b/third_party/rust/icu_capi/src/datetime_formatter.rs new file mode 100644 index 000000000000..7b65ee12c317 --- /dev/null +++ b/third_party/rust/icu_capi/src/datetime_formatter.rs @@ -0,0 +1,350 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +#[diplomat::bridge] +pub mod ffi { + use alloc::boxed::Box; + use icu_calendar::{Date, DateTime, Gregorian}; + use icu_datetime::{ + options::length, DateFormatter, DateTimeFormatter, TimeFormatter, TypedDateFormatter, + TypedDateTimeFormatter, + }; + + use crate::{ + date::ffi::{ICU4XDate, ICU4XIsoDate}, + datetime::ffi::ICU4XDateTime, + datetime::ffi::ICU4XIsoDateTime, + errors::ffi::ICU4XError, + locale::ffi::ICU4XLocale, + provider::ffi::ICU4XDataProvider, + time::ffi::ICU4XTime, + }; + use writeable::Writeable; + + #[diplomat::opaque] + /// An ICU4X TimeFormatter object capable of formatting an [`ICU4XTime`] type (and others) as a string + #[diplomat::rust_link(icu::datetime::TimeFormatter, Struct)] + // TODO(#2153) - Rename to ICU4XTimeFormatter when we remove the dependency on calendar + // from TimeFormatter. + pub struct ICU4XTimeFormatter(pub TimeFormatter); + + #[diplomat::enum_convert(length::Time, needs_wildcard)] + #[diplomat::rust_link(icu::datetime::options::length::Time, Enum)] + pub enum ICU4XTimeLength { + Full, + Long, + Medium, + Short, + } + + impl ICU4XTimeFormatter { + /// Creates a new [`ICU4XTimeFormatter`] from locale data. + #[diplomat::rust_link( + icu::datetime::TimeFormatter::try_new_with_length_unstable, + FnInStruct + )] + pub fn create_with_length( + provider: &ICU4XDataProvider, + locale: &ICU4XLocale, + length: ICU4XTimeLength, + ) -> Result, ICU4XError> { + let locale = locale.to_datalocale(); + + Ok(Box::new(ICU4XTimeFormatter( + TimeFormatter::try_new_with_length_unstable(&provider.0, &locale, length.into())?, + ))) + } + + /// Formats a [`ICU4XTime`] to a string. + #[diplomat::rust_link(icu::datetime::TimeFormatter::format, FnInStruct)] + #[diplomat::rust_link(icu::datetime::TimeFormatter::format_to_string, FnInStruct, hidden)] + pub fn format_time( + &self, + value: &ICU4XTime, + write: &mut diplomat_runtime::DiplomatWriteable, + ) -> Result<(), ICU4XError> { + self.0.format(&value.0).write_to(write)?; + Ok(()) + } + + /// Formats a [`ICU4XDateTime`] to a string. + #[diplomat::rust_link(icu::datetime::TimeFormatter::format, FnInStruct)] + #[diplomat::rust_link(icu::datetime::TimeFormatter::format_to_string, FnInStruct, hidden)] + pub fn format_datetime( + &self, + value: &ICU4XDateTime, + write: &mut diplomat_runtime::DiplomatWriteable, + ) -> Result<(), ICU4XError> { + self.0.format(&value.0).write_to(write)?; + Ok(()) + } + + /// Formats a [`ICU4XIsoDateTime`] to a string. + #[diplomat::rust_link(icu::datetime::TimeFormatter::format, FnInStruct)] + #[diplomat::rust_link(icu::datetime::TimeFormatter::format_to_string, FnInStruct, hidden)] + pub fn format_iso_datetime( + &self, + value: &ICU4XIsoDateTime, + write: &mut diplomat_runtime::DiplomatWriteable, + ) -> Result<(), ICU4XError> { + self.0.format(&value.0).write_to(write)?; + Ok(()) + } + } + + #[diplomat::opaque] + /// An ICU4X TypedDateFormatter object capable of formatting a [`ICU4XIsoDateTime`] as a string, + /// using the Gregorian Calendar. + #[diplomat::rust_link(icu::datetime::TypedDateFormatter, Struct)] + pub struct ICU4XGregorianDateFormatter(pub TypedDateFormatter); + + #[diplomat::enum_convert(length::Date, needs_wildcard)] + #[diplomat::rust_link(icu::datetime::options::length::Date, Enum)] + pub enum ICU4XDateLength { + Full, + Long, + Medium, + Short, + } + + impl ICU4XGregorianDateFormatter { + /// Creates a new [`ICU4XGregorianDateFormatter`] from locale data. + #[diplomat::rust_link( + icu::datetime::TypedDateFormatter::try_new_with_length_unstable, + FnInStruct + )] + pub fn create_with_length( + provider: &ICU4XDataProvider, + locale: &ICU4XLocale, + length: ICU4XDateLength, + ) -> Result, ICU4XError> { + let locale = locale.to_datalocale(); + + Ok(Box::new(ICU4XGregorianDateFormatter( + TypedDateFormatter::try_new_with_length_unstable( + &provider.0, + &locale, + length.into(), + )?, + ))) + } + + /// Formats a [`ICU4XIsoDate`] to a string. + #[diplomat::rust_link(icu::datetime::TypedDateFormatter::format, FnInStruct)] + #[diplomat::rust_link( + icu::datetime::TypedDateFormatter::format_to_string, + FnInStruct, + hidden + )] + pub fn format_iso_date( + &self, + value: &ICU4XIsoDate, + write: &mut diplomat_runtime::DiplomatWriteable, + ) -> Result<(), ICU4XError> { + let greg = Date::new_from_iso(value.0, Gregorian); + self.0.format(&greg).write_to(write)?; + Ok(()) + } + /// Formats a [`ICU4XIsoDateTime`] to a string. + #[diplomat::rust_link(icu::datetime::TypedDateFormatter::format, FnInStruct)] + #[diplomat::rust_link( + icu::datetime::TypedDateFormatter::format_to_string, + FnInStruct, + hidden + )] + pub fn format_iso_datetime( + &self, + value: &ICU4XIsoDateTime, + write: &mut diplomat_runtime::DiplomatWriteable, + ) -> Result<(), ICU4XError> { + let greg = DateTime::new_from_iso(value.0, Gregorian); + self.0.format(&greg).write_to(write)?; + Ok(()) + } + } + + #[diplomat::opaque] + /// An ICU4X TypedDateTimeFormatter object capable of formatting a [`ICU4XIsoDateTime`] as a string, + /// using the Gregorian Calendar. + #[diplomat::rust_link(icu::datetime::TypedDateTimeFormatter, Struct)] + pub struct ICU4XGregorianDateTimeFormatter(pub TypedDateTimeFormatter); + + impl ICU4XGregorianDateTimeFormatter { + /// Creates a new [`ICU4XGregorianDateFormatter`] from locale data. + #[diplomat::rust_link(icu::datetime::TypedDateTimeFormatter::try_new_unstable, FnInStruct)] + pub fn create_with_lengths( + provider: &ICU4XDataProvider, + locale: &ICU4XLocale, + date_length: ICU4XDateLength, + time_length: ICU4XTimeLength, + ) -> Result, ICU4XError> { + let locale = locale.to_datalocale(); + + let options = length::Bag::from_date_time_style(date_length.into(), time_length.into()); + + Ok(Box::new(ICU4XGregorianDateTimeFormatter( + TypedDateTimeFormatter::try_new_unstable(&provider.0, &locale, options.into())?, + ))) + } + + /// Formats a [`ICU4XIsoDateTime`] to a string. + #[diplomat::rust_link(icu::datetime::TypedDateTimeFormatter::format, FnInStruct)] + #[diplomat::rust_link( + icu::datetime::TypedDateTimeFormatter::format_to_string, + FnInStruct, + hidden + )] + pub fn format_iso_datetime( + &self, + value: &ICU4XIsoDateTime, + write: &mut diplomat_runtime::DiplomatWriteable, + ) -> Result<(), ICU4XError> { + let greg = DateTime::new_from_iso(value.0, Gregorian); + self.0.format(&greg).write_to(write)?; + Ok(()) + } + } + + #[diplomat::opaque] + /// An ICU4X DateFormatter object capable of formatting a [`ICU4XDate`] as a string, + /// using some calendar specified at runtime in the locale. + #[diplomat::rust_link(icu::datetime::DateFormatter, Struct)] + pub struct ICU4XDateFormatter(pub DateFormatter); + + impl ICU4XDateFormatter { + /// Creates a new [`ICU4XDateFormatter`] from locale data. + #[diplomat::rust_link( + icu::datetime::DateFormatter::try_new_with_length_unstable, + FnInStruct + )] + pub fn create_with_length( + provider: &ICU4XDataProvider, + locale: &ICU4XLocale, + date_length: ICU4XDateLength, + ) -> Result, ICU4XError> { + let locale = locale.to_datalocale(); + + Ok(Box::new(ICU4XDateFormatter( + DateFormatter::try_new_with_length_unstable( + &provider.0, + &locale, + date_length.into(), + )?, + ))) + } + + /// Formats a [`ICU4XDate`] to a string. + #[diplomat::rust_link(icu::datetime::DateFormatter::format, FnInStruct)] + #[diplomat::rust_link(icu::datetime::DateFormatter::format_to_string, FnInStruct, hidden)] + pub fn format_date( + &self, + value: &ICU4XDate, + write: &mut diplomat_runtime::DiplomatWriteable, + ) -> Result<(), ICU4XError> { + self.0.format(&value.0)?.write_to(write)?; + Ok(()) + } + + /// Formats a [`ICU4XIsoDate`] to a string. + /// + /// Will convert to this formatter's calendar first + #[diplomat::rust_link(icu::datetime::DateFormatter::format, FnInStruct)] + #[diplomat::rust_link(icu::datetime::DateFormatter::format_to_string, FnInStruct, hidden)] + pub fn format_iso_date( + &self, + value: &ICU4XIsoDate, + write: &mut diplomat_runtime::DiplomatWriteable, + ) -> Result<(), ICU4XError> { + let any = value.0.to_any(); + self.0.format(&any)?.write_to(write)?; + Ok(()) + } + + /// Formats a [`ICU4XDateTime`] to a string. + #[diplomat::rust_link(icu::datetime::DateFormatter::format, FnInStruct)] + #[diplomat::rust_link(icu::datetime::DateFormatter::format_to_string, FnInStruct, hidden)] + pub fn format_datetime( + &self, + value: &ICU4XDateTime, + write: &mut diplomat_runtime::DiplomatWriteable, + ) -> Result<(), ICU4XError> { + self.0.format(&value.0)?.write_to(write)?; + Ok(()) + } + + /// Formats a [`ICU4XIsoDateTime`] to a string. + /// + /// Will convert to this formatter's calendar first + #[diplomat::rust_link(icu::datetime::DateFormatter::format, FnInStruct)] + #[diplomat::rust_link(icu::datetime::DateFormatter::format_to_string, FnInStruct, hidden)] + pub fn format_iso_datetime( + &self, + value: &ICU4XIsoDateTime, + write: &mut diplomat_runtime::DiplomatWriteable, + ) -> Result<(), ICU4XError> { + let any = value.0.to_any(); + self.0.format(&any)?.write_to(write)?; + Ok(()) + } + } + + #[diplomat::opaque] + /// An ICU4X DateFormatter object capable of formatting a [`ICU4XDateTime`] as a string, + /// using some calendar specified at runtime in the locale. + #[diplomat::rust_link(icu::datetime::DateTimeFormatter, Struct)] + pub struct ICU4XDateTimeFormatter(pub DateTimeFormatter); + + impl ICU4XDateTimeFormatter { + /// Creates a new [`ICU4XDateTimeFormatter`] from locale data. + #[diplomat::rust_link(icu::datetime::DateTimeFormatter::try_new_unstable, FnInStruct)] + pub fn create_with_lengths( + provider: &ICU4XDataProvider, + locale: &ICU4XLocale, + date_length: ICU4XDateLength, + time_length: ICU4XTimeLength, + ) -> Result, ICU4XError> { + let locale = locale.to_datalocale(); + let options = length::Bag::from_date_time_style(date_length.into(), time_length.into()); + + Ok(Box::new(ICU4XDateTimeFormatter( + DateTimeFormatter::try_new_unstable(&provider.0, &locale, options.into())?, + ))) + } + + /// Formats a [`ICU4XDateTime`] to a string. + #[diplomat::rust_link(icu::datetime::DateTimeFormatter::format, FnInStruct)] + #[diplomat::rust_link( + icu::datetime::DateTimeFormatter::format_to_string, + FnInStruct, + hidden + )] + pub fn format_datetime( + &self, + value: &ICU4XDateTime, + write: &mut diplomat_runtime::DiplomatWriteable, + ) -> Result<(), ICU4XError> { + self.0.format(&value.0)?.write_to(write)?; + Ok(()) + } + + /// Formats a [`ICU4XIsoDateTime`] to a string. + /// + /// Will convert to this formatter's calendar first + #[diplomat::rust_link(icu::datetime::DateTimeFormatter::format, FnInStruct)] + #[diplomat::rust_link( + icu::datetime::DateTimeFormatter::format_to_string, + FnInStruct, + hidden + )] + pub fn format_iso_datetime( + &self, + value: &ICU4XIsoDateTime, + write: &mut diplomat_runtime::DiplomatWriteable, + ) -> Result<(), ICU4XError> { + let any = value.0.to_any(); + self.0.format(&any)?.write_to(write)?; + Ok(()) + } + } +} diff --git a/third_party/rust/icu_capi/src/decimal.rs b/third_party/rust/icu_capi/src/decimal.rs new file mode 100644 index 000000000000..7a55ad91629b --- /dev/null +++ b/third_party/rust/icu_capi/src/decimal.rs @@ -0,0 +1,108 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +#[diplomat::bridge] +pub mod ffi { + use alloc::boxed::Box; + use icu_decimal::{ + options::{FixedDecimalFormatterOptions, GroupingStrategy}, + provider::DecimalSymbolsV1Marker, + FixedDecimalFormatter, + }; + use icu_locid::Locale; + use icu_provider::DataProvider; + use icu_provider_adapters::any_payload::AnyPayloadProvider; + use writeable::Writeable; + + use crate::{ + data_struct::ffi::ICU4XDataStruct, errors::ffi::ICU4XError, + fixed_decimal::ffi::ICU4XFixedDecimal, locale::ffi::ICU4XLocale, + provider::ffi::ICU4XDataProvider, + }; + + #[diplomat::opaque] + /// An ICU4X Fixed Decimal Format object, capable of formatting a [`ICU4XFixedDecimal`] as a string. + #[diplomat::rust_link(icu::decimal::FixedDecimalFormatter, Struct)] + pub struct ICU4XFixedDecimalFormatter(pub FixedDecimalFormatter); + + #[diplomat::rust_link(icu::decimal::options::GroupingStrategy, Enum)] + pub enum ICU4XFixedDecimalGroupingStrategy { + Auto, + Never, + Always, + Min2, + } + + impl ICU4XFixedDecimalFormatter { + /// Creates a new [`ICU4XFixedDecimalFormatter`] from locale data. + #[diplomat::rust_link(icu::decimal::FixedDecimalFormatter::try_new_unstable, FnInStruct)] + pub fn create_with_grouping_strategy( + provider: &ICU4XDataProvider, + locale: &ICU4XLocale, + grouping_strategy: ICU4XFixedDecimalGroupingStrategy, + ) -> Result, ICU4XError> { + Self::try_new_impl(&provider.0, locale, grouping_strategy) + } + + /// Creates a new [`ICU4XFixedDecimalFormatter`] from preconstructed locale data in the form of an [`ICU4XDataStruct`] + /// constructed from `ICU4XDataStruct::create_decimal_symbols()`. + /// + /// The contents of the data struct will be consumed: if you wish to use the struct again it will have to be reconstructed. + /// Passing a consumed struct to this method will return an error. + pub fn create_with_decimal_symbols_v1( + data_struct: &ICU4XDataStruct, + grouping_strategy: ICU4XFixedDecimalGroupingStrategy, + ) -> Result, ICU4XError> { + use icu_provider::AsDowncastingAnyProvider; + let provider = AnyPayloadProvider::from_any_payload::( + // Note: This clone is free, since cloning AnyPayload is free. + data_struct.0.clone(), + ); + Self::try_new_impl( + &provider.as_downcasting(), + &ICU4XLocale(Locale::UND), + grouping_strategy, + ) + } + + fn try_new_impl( + provider: &D, + locale: &ICU4XLocale, + grouping_strategy: ICU4XFixedDecimalGroupingStrategy, + ) -> Result, ICU4XError> + where + D: DataProvider + ?Sized, + { + let locale = locale.to_datalocale(); + + let grouping_strategy = match grouping_strategy { + ICU4XFixedDecimalGroupingStrategy::Auto => GroupingStrategy::Auto, + ICU4XFixedDecimalGroupingStrategy::Never => GroupingStrategy::Never, + ICU4XFixedDecimalGroupingStrategy::Always => GroupingStrategy::Always, + ICU4XFixedDecimalGroupingStrategy::Min2 => GroupingStrategy::Min2, + }; + let mut options = FixedDecimalFormatterOptions::default(); + options.grouping_strategy = grouping_strategy; + Ok(Box::new(ICU4XFixedDecimalFormatter( + FixedDecimalFormatter::try_new_unstable(provider, &locale, options)?, + ))) + } + + /// Formats a [`ICU4XFixedDecimal`] to a string. + #[diplomat::rust_link(icu::decimal::FixedDecimalFormatter::format, FnInStruct)] + #[diplomat::rust_link( + icu::decimal::FixedDecimalFormatter::format_to_string, + FnInStruct, + hidden + )] + pub fn format( + &self, + value: &ICU4XFixedDecimal, + write: &mut diplomat_runtime::DiplomatWriteable, + ) -> Result<(), ICU4XError> { + self.0.format(&value.0).write_to(write)?; + Ok(()) + } + } +} diff --git a/third_party/rust/icu_capi/src/displaynames.rs b/third_party/rust/icu_capi/src/displaynames.rs new file mode 100644 index 000000000000..be320fbf0a9c --- /dev/null +++ b/third_party/rust/icu_capi/src/displaynames.rs @@ -0,0 +1,147 @@ +// This file is part of ICU4X. For terms of use, please see the file +// called LICENSE at the top level of the ICU4X source tree +// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). + +#[diplomat::bridge] +pub mod ffi { + use crate::errors::ffi::ICU4XError; + use crate::locale::ffi::ICU4XLocale; + use crate::provider::ffi::ICU4XDataProvider; + use alloc::boxed::Box; + use diplomat_runtime::DiplomatWriteable; + #[allow(unused_imports)] // feature-specific + use icu_displaynames::{DisplayNamesOptions, Fallback, LanguageDisplay}; + use icu_displaynames::{LocaleDisplayNamesFormatter, RegionDisplayNames}; + use icu_locid::subtags::Region; + use writeable::Writeable; + + // FFI version of `LocaleDisplayNamesFormatter`. + #[diplomat::opaque] + #[diplomat::rust_link(icu::displaynames::LocaleDisplayNamesFormatter, Struct)] + pub struct ICU4XLocaleDisplayNamesFormatter(pub LocaleDisplayNamesFormatter); + + // FFI version of `RegionDisplayNames`. + #[diplomat::opaque] + #[diplomat::rust_link(icu::displaynames::RegionDisplayNames, Struct)] + pub struct ICU4XRegionDisplayNames(pub RegionDisplayNames); + + // FFI version of `DisplayNamesOptions`. + #[diplomat::rust_link(icu::displaynames::options::DisplayNamesOptions, Struct)] + pub struct ICU4XDisplayNamesOptionsV1 { + /// The optional formatting style to use for display name. + pub style: ICU4XDisplayNamesStyle, + /// The fallback return when the system does not have the + /// requested display name, defaults to "code". + pub fallback: ICU4XDisplayNamesFallback, + /// The language display kind, defaults to "dialect". + pub language_display: ICU4XLanguageDisplay, + } + + // FFI version of `Style` option for the display names. + #[diplomat::rust_link(icu::displaynames::options::Style, Enum)] + pub enum ICU4XDisplayNamesStyle { + Auto, + Narrow, + Short, + Long, + Menu, + } + + // FFI version of `Fallback` option for the display names. + #[diplomat::rust_link(icu::displaynames::options::Fallback, Enum)] + #[diplomat::enum_convert(Fallback, needs_wildcard)] + pub enum ICU4XDisplayNamesFallback { + Code, + None, + } + + // FFI version of `LanguageDisplay`. + #[diplomat::rust_link(icu::displaynames::options::LanguageDisplay, Enum)] + #[diplomat::enum_convert(LanguageDisplay, needs_wildcard)] + pub enum ICU4XLanguageDisplay { + Dialect, + Standard, + } + + impl ICU4XLocaleDisplayNamesFormatter { + /// Creates a new `LocaleDisplayNamesFormatter` from locale data and an options bag. + #[diplomat::rust_link( + icu::displaynames::LocaleDisplayNamesFormatter::try_new_unstable, + FnInStruct + )] + pub fn try_new_unstable( + provider: &ICU4XDataProvider, + locale: &ICU4XLocale, + options: ICU4XDisplayNamesOptionsV1, + ) -> Result, ICU4XError> { + let locale = locale.to_datalocale(); + let options = DisplayNamesOptions::from(options); + + Ok(Box::new(ICU4XLocaleDisplayNamesFormatter( + LocaleDisplayNamesFormatter::try_new_unstable(&provider.0, &locale, options)?, + ))) + } + + /// Returns the locale-specific display name of a locale. + #[diplomat::rust_link(icu::displaynames::LocaleDisplayNamesFormatter::of, FnInStruct)] + pub fn of( + &self, + locale: &ICU4XLocale, + write: &mut DiplomatWriteable, + ) -> Result<(), ICU4XError> { + self.0.of(&locale.0).write_to(write)?; + Ok(()) + } + } + + impl ICU4XRegionDisplayNames { + /// Creates a new `RegionDisplayNames` from locale data and an options bag. + #[diplomat::rust_link(icu::displaynames::RegionDisplayNames::try_new_unstable, FnInStruct)] + pub fn try_new_unstable( + provider: &ICU4XDataProvider, + locale: &ICU4XLocale, + ) -> Result, ICU4XError> { + let locale = locale.to_datalocale(); + Ok(Box::new(ICU4XRegionDisplayNames( + RegionDisplayNames::try_new_unstable(&provider.0, &locale, Default::default())?, + ))) + } + + /// Returns the locale specific display name of a region. + /// Note that the funtion returns an empty string in case the display name for a given + /// region code is not found. + #[diplomat::rust_link(icu::displaynames::RegionDisplayNames::of, FnInStruct)] + pub fn of(&self, region: &str, write: &mut DiplomatWriteable) -> Result<(), ICU4XError> { + self.0 + .of(region.parse::()?) + .unwrap_or("") + .write_to(write)?; + Ok(()) + } + } +} + +#[allow(unused_imports)] // feature-specific +use icu_displaynames::{DisplayNamesOptions, Fallback, LanguageDisplay, Style}; + +impl From for Option