Debian Codegraph @

intl/icu_capi/bindings/js/ICU4XBidiParagraph.mjs

raw
1 import wasm from "./diplomat-wasm.mjs"
2 import * as diplomatRuntime from "./diplomat-runtime.mjs"
3 import { ICU4XBidiDirection_js_to_rust, ICU4XBidiDirection_rust_to_js } from "./ICU4XBidiDirection.mjs"
4 import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.mjs"
5
6 const ICU4XBidiParagraph_box_destroy_registry = new FinalizationRegistry(underlying => {
7 wasm.ICU4XBidiParagraph_destroy(underlying);
8 });
9
10 export class ICU4XBidiParagraph {
11 #lifetimeEdges = [];
12 constructor(underlying, owned, edges) {
13 this.underlying = underlying;
14 this.#lifetimeEdges.push(...edges);
15 if (owned) {
16 ICU4XBidiParagraph_box_destroy_registry.register(this, underlying);
17 }
18 }
19
20 set_paragraph_in_text(arg_n) {
21 return (() => {
22 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
23 wasm.ICU4XBidiParagraph_set_paragraph_in_text(diplomat_receive_buffer, this.underlying, arg_n);
24 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
25 if (is_ok) {
26 const ok_value = {};
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 direction() {
38 return ICU4XBidiDirection_rust_to_js[wasm.ICU4XBidiParagraph_direction(this.underlying)];
39 }
40
41 size() {
42 return wasm.ICU4XBidiParagraph_size(this.underlying);
43 }
44
45 range_start() {
46 return wasm.ICU4XBidiParagraph_range_start(this.underlying);
47 }
48
49 range_end() {
50 return wasm.ICU4XBidiParagraph_range_end(this.underlying);
51 }
52
53 reorder_line(arg_range_start, arg_range_end) {
54 return diplomatRuntime.withWriteable(wasm, (writeable) => {
55 return (() => {
56 const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
57 wasm.ICU4XBidiParagraph_reorder_line(diplomat_receive_buffer, this.underlying, arg_range_start, arg_range_end, writeable);
58 const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
59 if (is_ok) {
60 const ok_value = {};
61 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
62 return ok_value;
63 } else {
64 const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
65 wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
66 throw new diplomatRuntime.FFIError(throw_value);
67 }
68 })();
69 });
70 }
71
72 level_at(arg_pos) {
73 return wasm.ICU4XBidiParagraph_level_at(this.underlying, arg_pos);
74 }
75 }