Debian Codegraph @

intl/icu_capi/bindings/js/ICU4XComposingNormalizer.mjs

raw
1 import wasm from "./diplomat-wasm.mjs"
2 import * as diplomatRuntime from "./diplomat-runtime.mjs"
3 import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.mjs"
4
5 const ICU4XComposingNormalizer_box_destroy_registry = new FinalizationRegistry(underlying => {
6 wasm.ICU4XComposingNormalizer_destroy(underlying);
7 });
8
9 export class ICU4XComposingNormalizer {
10 #lifetimeEdges = [];
11 constructor(underlying, owned, edges) {
12 this.underlying = underlying;
13 this.#lifetimeEdges.push(...edges);
14 if (owned) {
15 ICU4XComposingNormalizer_box_destroy_registry.register(this, underlying);
16 }
17 }
18
19 static create_nfc(arg_provider) {
20 return (() => {
21 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
22 wasm.ICU4XComposingNormalizer_create_nfc(diplomat_receive_buffer, arg_provider.underlying);
23 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
24 if (is_ok) {
25 const ok_value = new ICU4XComposingNormalizer(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []);
26 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
27 return ok_value;
28 } else {
29 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
30 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
31 throw new diplomatRuntime.FFIError(throw_value);
32 }
33 })();
34 }
35
36 static create_nfkc(arg_provider) {
37 return (() => {
38 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
39 wasm.ICU4XComposingNormalizer_create_nfkc(diplomat_receive_buffer, arg_provider.underlying);
40 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
41 if (is_ok) {
42 const ok_value = new ICU4XComposingNormalizer(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []);
43 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
44 return ok_value;
45 } else {
46 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
47 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
48 throw new diplomatRuntime.FFIError(throw_value);
49 }
50 })();
51 }
52
53 normalize(arg_s) {
54 const buf_arg_s = diplomatRuntime.DiplomatBuf.str8(wasm, arg_s);
55 const diplomat_out = diplomatRuntime.withWriteable(wasm, (writeable) => {
56 return (() => {
57 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
58 wasm.ICU4XComposingNormalizer_normalize(diplomat_receive_buffer, this.underlying, buf_arg_s.ptr, buf_arg_s.size, writeable);
59 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
60 if (is_ok) {
61 const ok_value = {};
62 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
63 return ok_value;
64 } else {
65 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
66 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
67 throw new diplomatRuntime.FFIError(throw_value);
68 }
69 })();
70 });
71 buf_arg_s.free();
72 return diplomat_out;
73 }
74
75 is_normalized(arg_s) {
76 const buf_arg_s = diplomatRuntime.DiplomatBuf.str8(wasm, arg_s);
77 const diplomat_out = wasm.ICU4XComposingNormalizer_is_normalized(this.underlying, buf_arg_s.ptr, buf_arg_s.size);
78 buf_arg_s.free();
79 return diplomat_out;
80 }
81 }