// generated by diplomat-tool import { CodePointRangeIterator } from "./CodePointRangeIterator.mjs" import { CodePointSetData } from "./CodePointSetData.mjs" import { DataError } from "./DataError.mjs" import { DataProvider } from "./DataProvider.mjs" import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; /** 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/struct.CodePointMapData.html) for more information. * *See the [Rust documentation for `CodePointMapDataBorrowed`](https://docs.rs/icu/latest/icu/properties/struct.CodePointMapDataBorrowed.html) for more information. */ const CodePointMapData8_box_destroy_registry = new FinalizationRegistry((ptr) => { wasm.icu4x_CodePointMapData8_destroy_mv1(ptr); }); export class CodePointMapData8 { // 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 = []; constructor(symbol, ptr, selfEdge) { if (symbol !== diplomatRuntime.internalConstructor) { console.error("CodePointMapData8 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) { CodePointMapData8_box_destroy_registry.register(this, this.#ptr); } } get ffiValue() { return this.#ptr; } get(cp) { const result = wasm.icu4x_CodePointMapData8_get_mv1(this.ffiValue, cp); try { return result; } finally {} } static generalCategoryToMask(gc) { const result = wasm.icu4x_CodePointMapData8_general_category_to_mask_mv1(gc); try { return result; } finally {} } iterRangesForValue(value) { // This lifetime edge depends on lifetimes 'a let aEdges = [this]; const result = wasm.icu4x_CodePointMapData8_iter_ranges_for_value_mv1(this.ffiValue, value); try { return new CodePointRangeIterator(diplomatRuntime.internalConstructor, result, [], aEdges); } finally {} } iterRangesForValueComplemented(value) { // This lifetime edge depends on lifetimes 'a let aEdges = [this]; const result = wasm.icu4x_CodePointMapData8_iter_ranges_for_value_complemented_mv1(this.ffiValue, value); try { return new CodePointRangeIterator(diplomatRuntime.internalConstructor, result, [], aEdges); } finally {} } iterRangesForMask(mask) { // This lifetime edge depends on lifetimes 'a let aEdges = [this]; const result = wasm.icu4x_CodePointMapData8_iter_ranges_for_mask_mv1(this.ffiValue, mask); try { return new CodePointRangeIterator(diplomatRuntime.internalConstructor, result, [], aEdges); } finally {} } getSetForValue(value) { const result = wasm.icu4x_CodePointMapData8_get_set_for_value_mv1(this.ffiValue, value); try { return new CodePointSetData(diplomatRuntime.internalConstructor, result, []); } finally {} } static loadGeneralCategory(provider) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); const result = wasm.icu4x_CodePointMapData8_load_general_category_mv1(diplomatReceive.buffer, provider.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 CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); } finally { diplomatReceive.free(); } } static loadBidiClass(provider) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); const result = wasm.icu4x_CodePointMapData8_load_bidi_class_mv1(diplomatReceive.buffer, provider.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 CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); } finally { diplomatReceive.free(); } } static loadEastAsianWidth(provider) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); const result = wasm.icu4x_CodePointMapData8_load_east_asian_width_mv1(diplomatReceive.buffer, provider.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 CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); } finally { diplomatReceive.free(); } } static loadHangulSyllableType(provider) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); const result = wasm.icu4x_CodePointMapData8_load_hangul_syllable_type_mv1(diplomatReceive.buffer, provider.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 CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); } finally { diplomatReceive.free(); } } static loadIndicSyllabicCategory(provider) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); const result = wasm.icu4x_CodePointMapData8_load_indic_syllabic_category_mv1(diplomatReceive.buffer, provider.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 CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); } finally { diplomatReceive.free(); } } static loadLineBreak(provider) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); const result = wasm.icu4x_CodePointMapData8_load_line_break_mv1(diplomatReceive.buffer, provider.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 CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); } finally { diplomatReceive.free(); } } static tryGraphemeClusterBreak(provider) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); const result = wasm.icu4x_CodePointMapData8_try_grapheme_cluster_break_mv1(diplomatReceive.buffer, provider.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 CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); } finally { diplomatReceive.free(); } } static loadWordBreak(provider) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); const result = wasm.icu4x_CodePointMapData8_load_word_break_mv1(diplomatReceive.buffer, provider.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 CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); } finally { diplomatReceive.free(); } } static loadSentenceBreak(provider) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); const result = wasm.icu4x_CodePointMapData8_load_sentence_break_mv1(diplomatReceive.buffer, provider.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 CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); } finally { diplomatReceive.free(); } } static loadJoiningType(provider) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); const result = wasm.icu4x_CodePointMapData8_load_joining_type_mv1(diplomatReceive.buffer, provider.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 CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); } finally { diplomatReceive.free(); } } static loadCanonicalCombiningClass(provider) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); const result = wasm.icu4x_CodePointMapData8_load_canonical_combining_class_mv1(diplomatReceive.buffer, provider.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 CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []); } finally { diplomatReceive.free(); } } }