1// generated by diplomat-tool 2import { Locale } from "./Locale.mjs" 3import wasm from "./diplomat-wasm.mjs"; 4import * as diplomatRuntime from "./diplomat-runtime.mjs"; 5 6 7/** An iterator over the locale under fallback. 8* 9*See the [Rust documentation for `LocaleFallbackIterator`](https://docs.rs/icu/latest/icu/locale/fallback/struct.LocaleFallbackIterator.html) for more information. 10*/ 11const LocaleFallbackIterator_box_destroy_registry = new FinalizationRegistry((ptr) => { 12 wasm.icu4x_LocaleFallbackIterator_destroy_mv1(ptr); 13}); 14 15export class LocaleFallbackIterator { 16 17 // Internal ptr reference: 18 #ptr = null; 19 20 // Lifetimes are only to keep dependencies alive. 21 // Since JS won't garbage collect until there are no incoming edges. 22 #selfEdge = []; 23 #aEdge = []; 24 25 #internalConstructor(symbol, ptr, selfEdge, aEdge) { 26 if (symbol !== diplomatRuntime.internalConstructor) { 27 console.error("LocaleFallbackIterator is an Opaque type. You cannot call its constructor."); 28 return; 29 } 30 31 32 this.#aEdge = aEdge; 33 34 this.#ptr = ptr; 35 this.#selfEdge = selfEdge; 36 37 // Are we being borrowed? If not, we can register. 38 if (this.#selfEdge.length === 0) { 39 LocaleFallbackIterator_box_destroy_registry.register(this, this.#ptr); 40 } 41 42 return this; 43 } 44 get ffiValue() { 45 return this.#ptr; 46 } 47 48 #iteratorNext() { 49 const result = wasm.icu4x_LocaleFallbackIterator_next_mv1(this.ffiValue); 50 51 try { 52 return result === 0 ? null : new Locale(diplomatRuntime.internalConstructor, result, []); 53 } 54 55 finally {} 56 } 57 58 next() { 59 const out = this.#iteratorNext(); 60 61 return { 62 value: out, 63 done: out === null, 64 }; 65 } 66 67 constructor(symbol, ptr, selfEdge, aEdge) { 68 return this.#internalConstructor(...arguments) 69 } 70}