| // generated by diplomat-tool |
| import { DataError } from "./DataError.mjs" |
| import { DataProvider } from "./DataProvider.mjs" |
| import { Locale } from "./Locale.mjs" |
| import wasm from "./diplomat-wasm.mjs"; |
| import * as diplomatRuntime from "./diplomat-runtime.mjs"; |
| |
| |
| /** A set of "exemplar characters" for a given locale. |
| * |
| *See the [Rust documentation for `locale`](https://docs.rs/icu/latest/icu/locale/index.html) for more information. |
| * |
| *See the [Rust documentation for `ExemplarCharacters`](https://docs.rs/icu/latest/icu/locale/exemplar_chars/struct.ExemplarCharacters.html) for more information. |
| * |
| *See the [Rust documentation for `ExemplarCharactersBorrowed`](https://docs.rs/icu/latest/icu/locale/exemplar_chars/struct.ExemplarCharactersBorrowed.html) for more information. |
| */ |
| const ExemplarCharacters_box_destroy_registry = new FinalizationRegistry((ptr) => { |
| wasm.icu4x_ExemplarCharacters_destroy_mv1(ptr); |
| }); |
| |
| export class ExemplarCharacters { |
| |
| // Internal ptr reference: |
| #ptr = null; |
| |
| // Lifetimes are only to keep dependencies alive. |
| // Since JS won't garbage collect until there are no incoming edges. |
| #selfEdge = []; |
| |
| #internalConstructor(symbol, ptr, selfEdge) { |
| if (symbol !== diplomatRuntime.internalConstructor) { |
| console.error("ExemplarCharacters is an Opaque type. You cannot call its constructor."); |
| return; |
| } |
| |
| this.#ptr = ptr; |
| this.#selfEdge = selfEdge; |
| |
| // Are we being borrowed? If not, we can register. |
| if (this.#selfEdge.length === 0) { |
| ExemplarCharacters_box_destroy_registry.register(this, this.#ptr); |
| } |
| |
| return this; |
| } |
| get ffiValue() { |
| return this.#ptr; |
| } |
| |
| containsStr(s) { |
| let functionCleanupArena = new diplomatRuntime.CleanupArena(); |
| |
| const sSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, s)); |
| |
| const result = wasm.icu4x_ExemplarCharacters_contains_str_mv1(this.ffiValue, ...sSlice.splat()); |
| |
| try { |
| return result; |
| } |
| |
| finally { |
| functionCleanupArena.free(); |
| } |
| } |
| |
| contains(cp) { |
| const result = wasm.icu4x_ExemplarCharacters_contains_mv1(this.ffiValue, cp); |
| |
| try { |
| return result; |
| } |
| |
| finally {} |
| } |
| |
| static createMain(locale) { |
| const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); |
| |
| const result = wasm.icu4x_ExemplarCharacters_create_main_mv1(diplomatReceive.buffer, locale.ffiValue); |
| |
| try { |
| if (!diplomatReceive.resultFlag) { |
| const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); |
| throw new globalThis.Error('DataError: ' + cause.value, { cause }); |
| } |
| return new ExemplarCharacters(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); |
| } |
| |
| finally { |
| diplomatReceive.free(); |
| } |
| } |
| |
| static createMainWithProvider(provider, locale) { |
| const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); |
| |
| const result = wasm.icu4x_ExemplarCharacters_create_main_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue, locale.ffiValue); |
| |
| try { |
| if (!diplomatReceive.resultFlag) { |
| const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); |
| throw new globalThis.Error('DataError: ' + cause.value, { cause }); |
| } |
| return new ExemplarCharacters(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); |
| } |
| |
| finally { |
| diplomatReceive.free(); |
| } |
| } |
| |
| static createAuxiliary(locale) { |
| const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); |
| |
| const result = wasm.icu4x_ExemplarCharacters_create_auxiliary_mv1(diplomatReceive.buffer, locale.ffiValue); |
| |
| try { |
| if (!diplomatReceive.resultFlag) { |
| const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); |
| throw new globalThis.Error('DataError: ' + cause.value, { cause }); |
| } |
| return new ExemplarCharacters(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); |
| } |
| |
| finally { |
| diplomatReceive.free(); |
| } |
| } |
| |
| static createAuxiliaryWithProvider(provider, locale) { |
| const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); |
| |
| const result = wasm.icu4x_ExemplarCharacters_create_auxiliary_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue, locale.ffiValue); |
| |
| try { |
| if (!diplomatReceive.resultFlag) { |
| const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); |
| throw new globalThis.Error('DataError: ' + cause.value, { cause }); |
| } |
| return new ExemplarCharacters(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); |
| } |
| |
| finally { |
| diplomatReceive.free(); |
| } |
| } |
| |
| static createPunctuation(locale) { |
| const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); |
| |
| const result = wasm.icu4x_ExemplarCharacters_create_punctuation_mv1(diplomatReceive.buffer, locale.ffiValue); |
| |
| try { |
| if (!diplomatReceive.resultFlag) { |
| const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); |
| throw new globalThis.Error('DataError: ' + cause.value, { cause }); |
| } |
| return new ExemplarCharacters(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); |
| } |
| |
| finally { |
| diplomatReceive.free(); |
| } |
| } |
| |
| static createPunctuationWithProvider(provider, locale) { |
| const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); |
| |
| const result = wasm.icu4x_ExemplarCharacters_create_punctuation_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue, locale.ffiValue); |
| |
| try { |
| if (!diplomatReceive.resultFlag) { |
| const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); |
| throw new globalThis.Error('DataError: ' + cause.value, { cause }); |
| } |
| return new ExemplarCharacters(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); |
| } |
| |
| finally { |
| diplomatReceive.free(); |
| } |
| } |
| |
| static createNumbers(locale) { |
| const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); |
| |
| const result = wasm.icu4x_ExemplarCharacters_create_numbers_mv1(diplomatReceive.buffer, locale.ffiValue); |
| |
| try { |
| if (!diplomatReceive.resultFlag) { |
| const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); |
| throw new globalThis.Error('DataError: ' + cause.value, { cause }); |
| } |
| return new ExemplarCharacters(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); |
| } |
| |
| finally { |
| diplomatReceive.free(); |
| } |
| } |
| |
| static createNumbersWithProvider(provider, locale) { |
| const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); |
| |
| const result = wasm.icu4x_ExemplarCharacters_create_numbers_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue, locale.ffiValue); |
| |
| try { |
| if (!diplomatReceive.resultFlag) { |
| const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); |
| throw new globalThis.Error('DataError: ' + cause.value, { cause }); |
| } |
| return new ExemplarCharacters(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); |
| } |
| |
| finally { |
| diplomatReceive.free(); |
| } |
| } |
| |
| static createIndex(locale) { |
| const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); |
| |
| const result = wasm.icu4x_ExemplarCharacters_create_index_mv1(diplomatReceive.buffer, locale.ffiValue); |
| |
| try { |
| if (!diplomatReceive.resultFlag) { |
| const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); |
| throw new globalThis.Error('DataError: ' + cause.value, { cause }); |
| } |
| return new ExemplarCharacters(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); |
| } |
| |
| finally { |
| diplomatReceive.free(); |
| } |
| } |
| |
| static createIndexWithProvider(provider, locale) { |
| const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); |
| |
| const result = wasm.icu4x_ExemplarCharacters_create_index_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue, locale.ffiValue); |
| |
| try { |
| if (!diplomatReceive.resultFlag) { |
| const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); |
| throw new globalThis.Error('DataError: ' + cause.value, { cause }); |
| } |
| return new ExemplarCharacters(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); |
| } |
| |
| finally { |
| diplomatReceive.free(); |
| } |
| } |
| |
| constructor(symbol, ptr, selfEdge) { |
| return this.#internalConstructor(...arguments) |
| } |
| } |