1// generated by diplomat-tool 2import { BidiDirection } from "./BidiDirection.mjs" 3import wasm from "./diplomat-wasm.mjs"; 4import * as diplomatRuntime from "./diplomat-runtime.mjs"; 5 6 7/** Bidi information for a single processed paragraph 8*/ 9const BidiParagraph_box_destroy_registry = new FinalizationRegistry((ptr) => { 10 wasm.icu4x_BidiParagraph_destroy_mv1(ptr); 11}); 12 13export class BidiParagraph { 14 15 // Internal ptr reference: 16 #ptr = null; 17 18 // Lifetimes are only to keep dependencies alive. 19 // Since JS won't garbage collect until there are no incoming edges. 20 #selfEdge = []; 21 #infoEdge = []; 22 23 #internalConstructor(symbol, ptr, selfEdge, infoEdge) { 24 if (symbol !== diplomatRuntime.internalConstructor) { 25 console.error("BidiParagraph is an Opaque type. You cannot call its constructor."); 26 return; 27 } 28 29 30 this.#infoEdge = infoEdge; 31 32 this.#ptr = ptr; 33 this.#selfEdge = selfEdge; 34 35 // Are we being borrowed? If not, we can register. 36 if (this.#selfEdge.length === 0) { 37 BidiParagraph_box_destroy_registry.register(this, this.#ptr); 38 } 39 40 return this; 41 } 42 get ffiValue() { 43 return this.#ptr; 44 } 45 46 setParagraphInText(n) { 47 const result = wasm.icu4x_BidiParagraph_set_paragraph_in_text_mv1(this.ffiValue, n); 48 49 try { 50 return result; 51 } 52 53 finally {} 54 } 55 56 get direction() { 57 const result = wasm.icu4x_BidiParagraph_direction_mv1(this.ffiValue); 58 59 try { 60 return new BidiDirection(diplomatRuntime.internalConstructor, result); 61 } 62 63 finally {} 64 } 65 66 get size() { 67 const result = wasm.icu4x_BidiParagraph_size_mv1(this.ffiValue); 68 69 try { 70 return result; 71 } 72 73 finally {} 74 } 75 76 get rangeStart() { 77 const result = wasm.icu4x_BidiParagraph_range_start_mv1(this.ffiValue); 78 79 try { 80 return result; 81 } 82 83 finally {} 84 } 85 86 get rangeEnd() { 87 const result = wasm.icu4x_BidiParagraph_range_end_mv1(this.ffiValue); 88 89 try { 90 return result; 91 } 92 93 finally {} 94 } 95 96 reorderLine(rangeStart, rangeEnd) { 97 const write = new diplomatRuntime.DiplomatWriteBuf(wasm); 98 99 const result = wasm.icu4x_BidiParagraph_reorder_line_mv1(this.ffiValue, rangeStart, rangeEnd, write.buffer); 100 101 try { 102 return result === 0 ? null : write.readString8(); 103 } 104 105 finally { 106 write.free(); 107 } 108 } 109 110 levelAt(pos) { 111 const result = wasm.icu4x_BidiParagraph_level_at_mv1(this.ffiValue, pos); 112 113 try { 114 return result; 115 } 116 117 finally {} 118 } 119 120 constructor(symbol, ptr, selfEdge, infoEdge) { 121 return this.#internalConstructor(...arguments) 122 } 123}