ScriptExtensionsSet.mjs (3138B)
1 // generated by diplomat-tool 2 import wasm from "./diplomat-wasm.mjs"; 3 import * as diplomatRuntime from "./diplomat-runtime.mjs"; 4 5 6 /** 7 * An object that represents the Script_Extensions property for a single character 8 * 9 * See the [Rust documentation for `ScriptExtensionsSet`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html) for more information. 10 */ 11 const ScriptExtensionsSet_box_destroy_registry = new FinalizationRegistry((ptr) => { 12 wasm.icu4x_ScriptExtensionsSet_destroy_mv1(ptr); 13 }); 14 15 export class ScriptExtensionsSet { 16 // Internal ptr reference: 17 #ptr = null; 18 19 // Lifetimes are only to keep dependencies alive. 20 // Since JS won't garbage collect until there are no incoming edges. 21 #selfEdge = []; 22 #aEdge = []; 23 24 #internalConstructor(symbol, ptr, selfEdge, aEdge) { 25 if (symbol !== diplomatRuntime.internalConstructor) { 26 console.error("ScriptExtensionsSet is an Opaque type. You cannot call its constructor."); 27 return; 28 } 29 this.#aEdge = aEdge; 30 this.#ptr = ptr; 31 this.#selfEdge = selfEdge; 32 33 // Are we being borrowed? If not, we can register. 34 if (this.#selfEdge.length === 0) { 35 ScriptExtensionsSet_box_destroy_registry.register(this, this.#ptr); 36 } 37 38 return this; 39 } 40 get ffiValue() { 41 return this.#ptr; 42 } 43 44 45 /** 46 * Check if the Script_Extensions property of the given code point covers the given script 47 * 48 * See the [Rust documentation for `contains`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html#method.contains) for more information. 49 */ 50 contains(script) { 51 52 const result = wasm.icu4x_ScriptExtensionsSet_contains_mv1(this.ffiValue, script); 53 54 try { 55 return result; 56 } 57 58 finally { 59 } 60 } 61 62 /** 63 * Get the number of scripts contained in here 64 * 65 * See the [Rust documentation for `iter`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html#method.iter) for more information. 66 */ 67 get count() { 68 69 const result = wasm.icu4x_ScriptExtensionsSet_count_mv1(this.ffiValue); 70 71 try { 72 return result; 73 } 74 75 finally { 76 } 77 } 78 79 /** 80 * Get script at index 81 * 82 * See the [Rust documentation for `iter`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html#method.iter) for more information. 83 */ 84 scriptAt(index) { 85 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 3, 2, true); 86 87 88 const result = wasm.icu4x_ScriptExtensionsSet_script_at_mv1(diplomatReceive.buffer, this.ffiValue, index); 89 90 try { 91 if (!diplomatReceive.resultFlag) { 92 return null; 93 } 94 return (new Uint16Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0]; 95 } 96 97 finally { 98 diplomatReceive.free(); 99 } 100 } 101 102 constructor(symbol, ptr, selfEdge, aEdge) { 103 return this.#internalConstructor(...arguments) 104 } 105 }