Debian Codegraph @

intl/icu_capi/bindings/js/ICU4XScriptWithExtensions.mjs

raw
1 import wasm from "./diplomat-wasm.mjs"
2 import * as diplomatRuntime from "./diplomat-runtime.mjs"
3 import { CodePointRangeIterator } from "./CodePointRangeIterator.mjs"
4 import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.mjs"
5 import { ICU4XScriptWithExtensionsBorrowed } from "./ICU4XScriptWithExtensionsBorrowed.mjs"
6
7 const ICU4XScriptWithExtensions_box_destroy_registry = new FinalizationRegistry(underlying => {
8 wasm.ICU4XScriptWithExtensions_destroy(underlying);
9 });
10
11 export class ICU4XScriptWithExtensions {
12 #lifetimeEdges = [];
13 constructor(underlying, owned, edges) {
14 this.underlying = underlying;
15 this.#lifetimeEdges.push(...edges);
16 if (owned) {
17 ICU4XScriptWithExtensions_box_destroy_registry.register(this, underlying);
18 }
19 }
20
21 static create(arg_provider) {
22 return (() => {
23 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
24 wasm.ICU4XScriptWithExtensions_create(diplomat_receive_buffer, arg_provider.underlying);
25 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
26 if (is_ok) {
27 const ok_value = new ICU4XScriptWithExtensions(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []);
28 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
29 return ok_value;
30 } else {
31 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
32 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
33 throw new diplomatRuntime.FFIError(throw_value);
34 }
35 })();
36 }
37
38 get_script_val(arg_code_point) {
39 return wasm.ICU4XScriptWithExtensions_get_script_val(this.underlying, arg_code_point);
40 }
41
42 has_script(arg_code_point, arg_script) {
43 return wasm.ICU4XScriptWithExtensions_has_script(this.underlying, arg_code_point, arg_script);
44 }
45
46 as_borrowed() {
47 return new ICU4XScriptWithExtensionsBorrowed(wasm.ICU4XScriptWithExtensions_as_borrowed(this.underlying), true, [this]);
48 }
49
50 iter_ranges_for_script(arg_script) {
51 return new CodePointRangeIterator(wasm.ICU4XScriptWithExtensions_iter_ranges_for_script(this.underlying, arg_script), true, [this]);
52 }
53 }