1// generated by diplomat-tool 2import wasm from "./diplomat-wasm.mjs"; 3import * as diplomatRuntime from "./diplomat-runtime.mjs"; 4 5 6/** Thin wrapper around a vector that maps visual indices to source indices 7* 8*`map[visualIndex] = sourceIndex` 9* 10*Produced by `reorder_visual()` on [`Bidi`]. 11*/ 12const ReorderedIndexMap_box_destroy_registry = new FinalizationRegistry((ptr) => { 13 wasm.icu4x_ReorderedIndexMap_destroy_mv1(ptr); 14}); 15 16export class ReorderedIndexMap { 17 18 // Internal ptr reference: 19 #ptr = null; 20 21 // Lifetimes are only to keep dependencies alive. 22 // Since JS won't garbage collect until there are no incoming edges. 23 #selfEdge = []; 24 25 #internalConstructor(symbol, ptr, selfEdge) { 26 if (symbol !== diplomatRuntime.internalConstructor) { 27 console.error("ReorderedIndexMap is an Opaque type. You cannot call its constructor."); 28 return; 29 } 30 31 this.#ptr = ptr; 32 this.#selfEdge = selfEdge; 33 34 // Are we being borrowed? If not, we can register. 35 if (this.#selfEdge.length === 0) { 36 ReorderedIndexMap_box_destroy_registry.register(this, this.#ptr); 37 } 38 39 return this; 40 } 41 get ffiValue() { 42 return this.#ptr; 43 } 44 45 get asSlice() { 46 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 8, 4, false); 47 48 // This lifetime edge depends on lifetimes 'a 49 let aEdges = [this]; 50 51 const result = wasm.icu4x_ReorderedIndexMap_as_slice_mv1(diplomatReceive.buffer, this.ffiValue); 52 53 try { 54 return Array.from(new diplomatRuntime.DiplomatSlicePrimitive(wasm, diplomatReceive.buffer, "u32", aEdges).getValue()); 55 } 56 57 finally { 58 diplomatReceive.free(); 59 } 60 } 61 62 get length() { 63 const result = wasm.icu4x_ReorderedIndexMap_len_mv1(this.ffiValue); 64 65 try { 66 return result; 67 } 68 69 finally {} 70 } 71 72 get isEmpty() { 73 const result = wasm.icu4x_ReorderedIndexMap_is_empty_mv1(this.ffiValue); 74 75 try { 76 return result; 77 } 78 79 finally {} 80 } 81 82 get(index) { 83 const result = wasm.icu4x_ReorderedIndexMap_get_mv1(this.ffiValue, index); 84 85 try { 86 return result; 87 } 88 89 finally {} 90 } 91 92 constructor(symbol, ptr, selfEdge) { 93 return this.#internalConstructor(...arguments) 94 } 95}