Debian Codegraph @

intl/icu_capi/bindings/js/ICU4XLocaleDirectionality.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 import { ICU4XLocaleDirection_js_to_rust, ICU4XLocaleDirection_rust_to_js } from "./ICU4XLocaleDirection.mjs"
5
6 const ICU4XLocaleDirectionality_box_destroy_registry = new FinalizationRegistry(underlying => {
7 wasm.ICU4XLocaleDirectionality_destroy(underlying);
8 });
9
10 export class ICU4XLocaleDirectionality {
11 #lifetimeEdges = [];
12 constructor(underlying, owned, edges) {
13 this.underlying = underlying;
14 this.#lifetimeEdges.push(...edges);
15 if (owned) {
16 ICU4XLocaleDirectionality_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.ICU4XLocaleDirectionality_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 ICU4XLocaleDirectionality(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 static create_with_expander(arg_provider, arg_expander) {
38 return (() => {
39 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
40 wasm.ICU4XLocaleDirectionality_create_with_expander(diplomat_receive_buffer, arg_provider.underlying, arg_expander.underlying);
41 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
42 if (is_ok) {
43 const ok_value = new ICU4XLocaleDirectionality(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []);
44 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
45 return ok_value;
46 } else {
47 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
48 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
49 throw new diplomatRuntime.FFIError(throw_value);
50 }
51 })();
52 }
53
54 get(arg_locale) {
55 return ICU4XLocaleDirection_rust_to_js[wasm.ICU4XLocaleDirectionality_get(this.underlying, arg_locale.underlying)];
56 }
57
58 is_left_to_right(arg_locale) {
59 return wasm.ICU4XLocaleDirectionality_is_left_to_right(this.underlying, arg_locale.underlying);
60 }
61
62 is_right_to_left(arg_locale) {
63 return wasm.ICU4XLocaleDirectionality_is_right_to_left(this.underlying, arg_locale.underlying);
64 }
65 }