• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// generated by diplomat-tool
2import { DataError } from "./DataError.mjs"
3import { DataProvider } from "./DataProvider.mjs"
4import wasm from "./diplomat-wasm.mjs";
5import * as diplomatRuntime from "./diplomat-runtime.mjs";
6
7
8/** A type capable of looking up a property value from a string name.
9*
10*See the [Rust documentation for `PropertyParser`](https://docs.rs/icu/latest/icu/properties/struct.PropertyParser.html) for more information.
11*
12*See the [Rust documentation for `PropertyParserBorrowed`](https://docs.rs/icu/latest/icu/properties/struct.PropertyParserBorrowed.html) for more information.
13*
14*See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/properties/struct.PropertyParser.html#method.new) for more information.
15*/
16const PropertyValueNameToEnumMapper_box_destroy_registry = new FinalizationRegistry((ptr) => {
17    wasm.icu4x_PropertyValueNameToEnumMapper_destroy_mv1(ptr);
18});
19
20export class PropertyValueNameToEnumMapper {
21
22    // Internal ptr reference:
23    #ptr = null;
24
25    // Lifetimes are only to keep dependencies alive.
26    // Since JS won't garbage collect until there are no incoming edges.
27    #selfEdge = [];
28
29    #internalConstructor(symbol, ptr, selfEdge) {
30        if (symbol !== diplomatRuntime.internalConstructor) {
31            console.error("PropertyValueNameToEnumMapper is an Opaque type. You cannot call its constructor.");
32            return;
33        }
34
35        this.#ptr = ptr;
36        this.#selfEdge = selfEdge;
37
38        // Are we being borrowed? If not, we can register.
39        if (this.#selfEdge.length === 0) {
40            PropertyValueNameToEnumMapper_box_destroy_registry.register(this, this.#ptr);
41        }
42
43        return this;
44    }
45    get ffiValue() {
46        return this.#ptr;
47    }
48
49    getStrict(name) {
50        let functionCleanupArena = new diplomatRuntime.CleanupArena();
51
52        const nameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, name));
53
54        const result = wasm.icu4x_PropertyValueNameToEnumMapper_get_strict_mv1(this.ffiValue, ...nameSlice.splat());
55
56        try {
57            return result;
58        }
59
60        finally {
61            functionCleanupArena.free();
62        }
63    }
64
65    getLoose(name) {
66        let functionCleanupArena = new diplomatRuntime.CleanupArena();
67
68        const nameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, name));
69
70        const result = wasm.icu4x_PropertyValueNameToEnumMapper_get_loose_mv1(this.ffiValue, ...nameSlice.splat());
71
72        try {
73            return result;
74        }
75
76        finally {
77            functionCleanupArena.free();
78        }
79    }
80
81    static createGeneralCategory() {
82        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_general_category_mv1();
83
84        try {
85            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
86        }
87
88        finally {}
89    }
90
91    static createGeneralCategoryWithProvider(provider) {
92        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
93
94        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_general_category_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
95
96        try {
97            if (!diplomatReceive.resultFlag) {
98                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
99                throw new globalThis.Error('DataError: ' + cause.value, { cause });
100            }
101            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
102        }
103
104        finally {
105            diplomatReceive.free();
106        }
107    }
108
109    static createHangulSyllableType() {
110        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_hangul_syllable_type_mv1();
111
112        try {
113            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
114        }
115
116        finally {}
117    }
118
119    static createHangulSyllableTypeWithProvider(provider) {
120        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
121
122        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_hangul_syllable_type_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
123
124        try {
125            if (!diplomatReceive.resultFlag) {
126                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
127                throw new globalThis.Error('DataError: ' + cause.value, { cause });
128            }
129            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
130        }
131
132        finally {
133            diplomatReceive.free();
134        }
135    }
136
137    static createEastAsianWidth() {
138        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_east_asian_width_mv1();
139
140        try {
141            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
142        }
143
144        finally {}
145    }
146
147    static createEastAsianWidthWithProvider(provider) {
148        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
149
150        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_east_asian_width_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
151
152        try {
153            if (!diplomatReceive.resultFlag) {
154                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
155                throw new globalThis.Error('DataError: ' + cause.value, { cause });
156            }
157            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
158        }
159
160        finally {
161            diplomatReceive.free();
162        }
163    }
164
165    static createBidiClass() {
166        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_bidi_class_mv1();
167
168        try {
169            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
170        }
171
172        finally {}
173    }
174
175    static createBidiClassWithProvider(provider) {
176        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
177
178        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_bidi_class_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
179
180        try {
181            if (!diplomatReceive.resultFlag) {
182                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
183                throw new globalThis.Error('DataError: ' + cause.value, { cause });
184            }
185            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
186        }
187
188        finally {
189            diplomatReceive.free();
190        }
191    }
192
193    static createIndicSyllabicCategory() {
194        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_indic_syllabic_category_mv1();
195
196        try {
197            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
198        }
199
200        finally {}
201    }
202
203    static createIndicSyllabicCategoryWithProvider(provider) {
204        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
205
206        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_indic_syllabic_category_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
207
208        try {
209            if (!diplomatReceive.resultFlag) {
210                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
211                throw new globalThis.Error('DataError: ' + cause.value, { cause });
212            }
213            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
214        }
215
216        finally {
217            diplomatReceive.free();
218        }
219    }
220
221    static createLineBreak() {
222        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_line_break_mv1();
223
224        try {
225            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
226        }
227
228        finally {}
229    }
230
231    static createLineBreakWithProvider(provider) {
232        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
233
234        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_line_break_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
235
236        try {
237            if (!diplomatReceive.resultFlag) {
238                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
239                throw new globalThis.Error('DataError: ' + cause.value, { cause });
240            }
241            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
242        }
243
244        finally {
245            diplomatReceive.free();
246        }
247    }
248
249    static createGraphemeClusterBreak() {
250        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_grapheme_cluster_break_mv1();
251
252        try {
253            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
254        }
255
256        finally {}
257    }
258
259    static createGraphemeClusterBreakWithProvider(provider) {
260        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
261
262        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_grapheme_cluster_break_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
263
264        try {
265            if (!diplomatReceive.resultFlag) {
266                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
267                throw new globalThis.Error('DataError: ' + cause.value, { cause });
268            }
269            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
270        }
271
272        finally {
273            diplomatReceive.free();
274        }
275    }
276
277    static createWordBreak() {
278        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_word_break_mv1();
279
280        try {
281            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
282        }
283
284        finally {}
285    }
286
287    static createWordBreakWithProvider(provider) {
288        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
289
290        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_word_break_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
291
292        try {
293            if (!diplomatReceive.resultFlag) {
294                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
295                throw new globalThis.Error('DataError: ' + cause.value, { cause });
296            }
297            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
298        }
299
300        finally {
301            diplomatReceive.free();
302        }
303    }
304
305    static createSentenceBreak() {
306        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_sentence_break_mv1();
307
308        try {
309            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
310        }
311
312        finally {}
313    }
314
315    static createSentenceBreakWithProvider(provider) {
316        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
317
318        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_sentence_break_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
319
320        try {
321            if (!diplomatReceive.resultFlag) {
322                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
323                throw new globalThis.Error('DataError: ' + cause.value, { cause });
324            }
325            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
326        }
327
328        finally {
329            diplomatReceive.free();
330        }
331    }
332
333    static createScript() {
334        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_script_mv1();
335
336        try {
337            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
338        }
339
340        finally {}
341    }
342
343    static createScriptWithProvider(provider) {
344        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
345
346        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_script_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
347
348        try {
349            if (!diplomatReceive.resultFlag) {
350                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
351                throw new globalThis.Error('DataError: ' + cause.value, { cause });
352            }
353            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
354        }
355
356        finally {
357            diplomatReceive.free();
358        }
359    }
360
361    constructor(symbol, ptr, selfEdge) {
362        return this.#internalConstructor(...arguments)
363    }
364}