• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// generated by diplomat-tool
2import wasm from "./diplomat-wasm.mjs";
3import * as diplomatRuntime from "./diplomat-runtime.mjs";
4
5
6/** An object that represents the Script_Extensions property for a single character
7*
8*See the [Rust documentation for `ScriptExtensionsSet`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptExtensionsSet.html) for more information.
9*/
10const ScriptExtensionsSet_box_destroy_registry = new FinalizationRegistry((ptr) => {
11    wasm.icu4x_ScriptExtensionsSet_destroy_mv1(ptr);
12});
13
14export class ScriptExtensionsSet {
15
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
30
31        this.#aEdge = aEdge;
32
33        this.#ptr = ptr;
34        this.#selfEdge = selfEdge;
35
36        // Are we being borrowed? If not, we can register.
37        if (this.#selfEdge.length === 0) {
38            ScriptExtensionsSet_box_destroy_registry.register(this, this.#ptr);
39        }
40
41        return this;
42    }
43    get ffiValue() {
44        return this.#ptr;
45    }
46
47    contains(script) {
48        const result = wasm.icu4x_ScriptExtensionsSet_contains_mv1(this.ffiValue, script);
49
50        try {
51            return result;
52        }
53
54        finally {}
55    }
56
57    get count() {
58        const result = wasm.icu4x_ScriptExtensionsSet_count_mv1(this.ffiValue);
59
60        try {
61            return result;
62        }
63
64        finally {}
65    }
66
67    scriptAt(index) {
68        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 3, 2, true);
69
70        const result = wasm.icu4x_ScriptExtensionsSet_script_at_mv1(diplomatReceive.buffer, this.ffiValue, index);
71
72        try {
73            if (!diplomatReceive.resultFlag) {
74                return null;
75            }
76            return (new Uint16Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
77        }
78
79        finally {
80            diplomatReceive.free();
81        }
82    }
83
84    constructor(symbol, ptr, selfEdge, aEdge) {
85        return this.#internalConstructor(...arguments)
86    }
87}