Debian Codegraph @

intl/icu_capi/bindings/js/ICU4XCanonicalDecomposition.mjs

raw
1 import wasm from "./diplomat-wasm.mjs"
2 import * as diplomatRuntime from "./diplomat-runtime.mjs"
3 import { ICU4XDecomposed } from "./ICU4XDecomposed.mjs"
4 import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.mjs"
5
6 const ICU4XCanonicalDecomposition_box_destroy_registry = new FinalizationRegistry(underlying => {
7 wasm.ICU4XCanonicalDecomposition_destroy(underlying);
8 });
9
10 export class ICU4XCanonicalDecomposition {
11 #lifetimeEdges = [];
12 constructor(underlying, owned, edges) {
13 this.underlying = underlying;
14 this.#lifetimeEdges.push(...edges);
15 if (owned) {
16 ICU4XCanonicalDecomposition_box_destroy_registry.register(this, underlying);
17 }
18 }
19
20 static create(arg_provider) {
21 return (() => {
22 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
23 wasm.ICU4XCanonicalDecomposition_create(diplomat_receive_buffer, arg_provider.underlying);
24 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
25 if (is_ok) {
26 const ok_value = new ICU4XCanonicalDecomposition(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []);
27 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
28 return ok_value;
29 } else {
30 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
31 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
32 throw new diplomatRuntime.FFIError(throw_value);
33 }
34 })();
35 }
36
37 decompose(arg_c) {
38 return (() => {
39 const diplomat_receive_buffer = wasm.diplomat_alloc(8, 4);
40 wasm.ICU4XCanonicalDecomposition_decompose(diplomat_receive_buffer, this.underlying, diplomatRuntime.extractCodePoint(arg_c, 'arg_c'));
41 const out = new ICU4XDecomposed(diplomat_receive_buffer);
42 wasm.diplomat_free(diplomat_receive_buffer, 8, 4);
43 return out;
44 })();
45 }
46 }