• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// generated by diplomat-tool
2import { CodePointRangeIterator } from "./CodePointRangeIterator.mjs"
3import { CodePointSetData } from "./CodePointSetData.mjs"
4import { DataError } from "./DataError.mjs"
5import { DataProvider } from "./DataProvider.mjs"
6import { GeneralCategoryGroup } from "./GeneralCategoryGroup.mjs"
7import wasm from "./diplomat-wasm.mjs";
8import * as diplomatRuntime from "./diplomat-runtime.mjs";
9
10
11/** 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.
12*
13*For properties whose values fit into 8 bits.
14*
15*See the [Rust documentation for `properties`](https://docs.rs/icu/latest/icu/properties/index.html) for more information.
16*
17*See the [Rust documentation for `CodePointMapData`](https://docs.rs/icu/latest/icu/properties/struct.CodePointMapData.html) for more information.
18*
19*See the [Rust documentation for `CodePointMapDataBorrowed`](https://docs.rs/icu/latest/icu/properties/struct.CodePointMapDataBorrowed.html) for more information.
20*/
21const CodePointMapData8_box_destroy_registry = new FinalizationRegistry((ptr) => {
22    wasm.icu4x_CodePointMapData8_destroy_mv1(ptr);
23});
24
25export class CodePointMapData8 {
26
27    // Internal ptr reference:
28    #ptr = null;
29
30    // Lifetimes are only to keep dependencies alive.
31    // Since JS won't garbage collect until there are no incoming edges.
32    #selfEdge = [];
33
34    #internalConstructor(symbol, ptr, selfEdge) {
35        if (symbol !== diplomatRuntime.internalConstructor) {
36            console.error("CodePointMapData8 is an Opaque type. You cannot call its constructor.");
37            return;
38        }
39
40        this.#ptr = ptr;
41        this.#selfEdge = selfEdge;
42
43        // Are we being borrowed? If not, we can register.
44        if (this.#selfEdge.length === 0) {
45            CodePointMapData8_box_destroy_registry.register(this, this.#ptr);
46        }
47
48        return this;
49    }
50    get ffiValue() {
51        return this.#ptr;
52    }
53
54    get(cp) {
55        const result = wasm.icu4x_CodePointMapData8_get_mv1(this.ffiValue, cp);
56
57        try {
58            return result;
59        }
60
61        finally {}
62    }
63
64    iterRangesForValue(value) {
65        // This lifetime edge depends on lifetimes 'a
66        let aEdges = [this];
67
68        const result = wasm.icu4x_CodePointMapData8_iter_ranges_for_value_mv1(this.ffiValue, value);
69
70        try {
71            return new CodePointRangeIterator(diplomatRuntime.internalConstructor, result, [], aEdges);
72        }
73
74        finally {}
75    }
76
77    iterRangesForValueComplemented(value) {
78        // This lifetime edge depends on lifetimes 'a
79        let aEdges = [this];
80
81        const result = wasm.icu4x_CodePointMapData8_iter_ranges_for_value_complemented_mv1(this.ffiValue, value);
82
83        try {
84            return new CodePointRangeIterator(diplomatRuntime.internalConstructor, result, [], aEdges);
85        }
86
87        finally {}
88    }
89
90    iterRangesForGroup(group) {
91        let functionCleanupArena = new diplomatRuntime.CleanupArena();
92
93        // This lifetime edge depends on lifetimes 'a
94        let aEdges = [this];
95
96        const result = wasm.icu4x_CodePointMapData8_iter_ranges_for_group_mv1(this.ffiValue, ...GeneralCategoryGroup._fromSuppliedValue(diplomatRuntime.internalConstructor, group)._intoFFI(functionCleanupArena, {}));
97
98        try {
99            return new CodePointRangeIterator(diplomatRuntime.internalConstructor, result, [], aEdges);
100        }
101
102        finally {
103            functionCleanupArena.free();
104        }
105    }
106
107    getSetForValue(value) {
108        const result = wasm.icu4x_CodePointMapData8_get_set_for_value_mv1(this.ffiValue, value);
109
110        try {
111            return new CodePointSetData(diplomatRuntime.internalConstructor, result, []);
112        }
113
114        finally {}
115    }
116
117    static createGeneralCategory() {
118        const result = wasm.icu4x_CodePointMapData8_create_general_category_mv1();
119
120        try {
121            return new CodePointMapData8(diplomatRuntime.internalConstructor, result, []);
122        }
123
124        finally {}
125    }
126
127    static createGeneralCategoryWithProvider(provider) {
128        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
129
130        const result = wasm.icu4x_CodePointMapData8_create_general_category_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
131
132        try {
133            if (!diplomatReceive.resultFlag) {
134                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
135                throw new globalThis.Error('DataError: ' + cause.value, { cause });
136            }
137            return new CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
138        }
139
140        finally {
141            diplomatReceive.free();
142        }
143    }
144
145    static createBidiClass() {
146        const result = wasm.icu4x_CodePointMapData8_create_bidi_class_mv1();
147
148        try {
149            return new CodePointMapData8(diplomatRuntime.internalConstructor, result, []);
150        }
151
152        finally {}
153    }
154
155    static createBidiClassWithProvider(provider) {
156        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
157
158        const result = wasm.icu4x_CodePointMapData8_create_bidi_class_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
159
160        try {
161            if (!diplomatReceive.resultFlag) {
162                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
163                throw new globalThis.Error('DataError: ' + cause.value, { cause });
164            }
165            return new CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
166        }
167
168        finally {
169            diplomatReceive.free();
170        }
171    }
172
173    static createEastAsianWidth() {
174        const result = wasm.icu4x_CodePointMapData8_create_east_asian_width_mv1();
175
176        try {
177            return new CodePointMapData8(diplomatRuntime.internalConstructor, result, []);
178        }
179
180        finally {}
181    }
182
183    static createEastAsianWidthWithProvider(provider) {
184        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
185
186        const result = wasm.icu4x_CodePointMapData8_create_east_asian_width_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
187
188        try {
189            if (!diplomatReceive.resultFlag) {
190                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
191                throw new globalThis.Error('DataError: ' + cause.value, { cause });
192            }
193            return new CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
194        }
195
196        finally {
197            diplomatReceive.free();
198        }
199    }
200
201    static createHangulSyllableType() {
202        const result = wasm.icu4x_CodePointMapData8_create_hangul_syllable_type_mv1();
203
204        try {
205            return new CodePointMapData8(diplomatRuntime.internalConstructor, result, []);
206        }
207
208        finally {}
209    }
210
211    static createHangulSyllableTypeWithProvider(provider) {
212        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
213
214        const result = wasm.icu4x_CodePointMapData8_create_hangul_syllable_type_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
215
216        try {
217            if (!diplomatReceive.resultFlag) {
218                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
219                throw new globalThis.Error('DataError: ' + cause.value, { cause });
220            }
221            return new CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
222        }
223
224        finally {
225            diplomatReceive.free();
226        }
227    }
228
229    static createIndicSyllabicCategory() {
230        const result = wasm.icu4x_CodePointMapData8_create_indic_syllabic_category_mv1();
231
232        try {
233            return new CodePointMapData8(diplomatRuntime.internalConstructor, result, []);
234        }
235
236        finally {}
237    }
238
239    static createIndicSyllabicCategoryWithProvider(provider) {
240        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
241
242        const result = wasm.icu4x_CodePointMapData8_create_indic_syllabic_category_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
243
244        try {
245            if (!diplomatReceive.resultFlag) {
246                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
247                throw new globalThis.Error('DataError: ' + cause.value, { cause });
248            }
249            return new CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
250        }
251
252        finally {
253            diplomatReceive.free();
254        }
255    }
256
257    static createLineBreak() {
258        const result = wasm.icu4x_CodePointMapData8_create_line_break_mv1();
259
260        try {
261            return new CodePointMapData8(diplomatRuntime.internalConstructor, result, []);
262        }
263
264        finally {}
265    }
266
267    static createLineBreakWithProvider(provider) {
268        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
269
270        const result = wasm.icu4x_CodePointMapData8_create_line_break_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
271
272        try {
273            if (!diplomatReceive.resultFlag) {
274                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
275                throw new globalThis.Error('DataError: ' + cause.value, { cause });
276            }
277            return new CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
278        }
279
280        finally {
281            diplomatReceive.free();
282        }
283    }
284
285    static createGraphemeClusterBreak() {
286        const result = wasm.icu4x_CodePointMapData8_create_grapheme_cluster_break_mv1();
287
288        try {
289            return new CodePointMapData8(diplomatRuntime.internalConstructor, result, []);
290        }
291
292        finally {}
293    }
294
295    static createGraphemeClusterBreakWithProvider(provider) {
296        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
297
298        const result = wasm.icu4x_CodePointMapData8_create_grapheme_cluster_break_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
299
300        try {
301            if (!diplomatReceive.resultFlag) {
302                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
303                throw new globalThis.Error('DataError: ' + cause.value, { cause });
304            }
305            return new CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
306        }
307
308        finally {
309            diplomatReceive.free();
310        }
311    }
312
313    static createWordBreak() {
314        const result = wasm.icu4x_CodePointMapData8_create_word_break_mv1();
315
316        try {
317            return new CodePointMapData8(diplomatRuntime.internalConstructor, result, []);
318        }
319
320        finally {}
321    }
322
323    static createWordBreakWithProvider(provider) {
324        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
325
326        const result = wasm.icu4x_CodePointMapData8_create_word_break_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
327
328        try {
329            if (!diplomatReceive.resultFlag) {
330                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
331                throw new globalThis.Error('DataError: ' + cause.value, { cause });
332            }
333            return new CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
334        }
335
336        finally {
337            diplomatReceive.free();
338        }
339    }
340
341    static createSentenceBreak() {
342        const result = wasm.icu4x_CodePointMapData8_create_sentence_break_mv1();
343
344        try {
345            return new CodePointMapData8(diplomatRuntime.internalConstructor, result, []);
346        }
347
348        finally {}
349    }
350
351    static createSentenceBreakWithProvider(provider) {
352        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
353
354        const result = wasm.icu4x_CodePointMapData8_create_sentence_break_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
355
356        try {
357            if (!diplomatReceive.resultFlag) {
358                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
359                throw new globalThis.Error('DataError: ' + cause.value, { cause });
360            }
361            return new CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
362        }
363
364        finally {
365            diplomatReceive.free();
366        }
367    }
368
369    static createJoiningType() {
370        const result = wasm.icu4x_CodePointMapData8_create_joining_type_mv1();
371
372        try {
373            return new CodePointMapData8(diplomatRuntime.internalConstructor, result, []);
374        }
375
376        finally {}
377    }
378
379    static createJoiningTypeWithProvider(provider) {
380        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
381
382        const result = wasm.icu4x_CodePointMapData8_create_joining_type_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
383
384        try {
385            if (!diplomatReceive.resultFlag) {
386                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
387                throw new globalThis.Error('DataError: ' + cause.value, { cause });
388            }
389            return new CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
390        }
391
392        finally {
393            diplomatReceive.free();
394        }
395    }
396
397    static createCanonicalCombiningClass() {
398        const result = wasm.icu4x_CodePointMapData8_create_canonical_combining_class_mv1();
399
400        try {
401            return new CodePointMapData8(diplomatRuntime.internalConstructor, result, []);
402        }
403
404        finally {}
405    }
406
407    static createCanonicalCombiningClassWithProvider(provider) {
408        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
409
410        const result = wasm.icu4x_CodePointMapData8_create_canonical_combining_class_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
411
412        try {
413            if (!diplomatReceive.resultFlag) {
414                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
415                throw new globalThis.Error('DataError: ' + cause.value, { cause });
416            }
417            return new CodePointMapData8(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
418        }
419
420        finally {
421            diplomatReceive.free();
422        }
423    }
424
425    constructor(symbol, ptr, selfEdge) {
426        return this.#internalConstructor(...arguments)
427    }
428}