• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// generated by diplomat-tool
2import { CodePointSetData } from "./CodePointSetData.mjs"
3import { ScriptExtensionsSet } from "./ScriptExtensionsSet.mjs"
4import wasm from "./diplomat-wasm.mjs";
5import * as diplomatRuntime from "./diplomat-runtime.mjs";
6
7
8/** A slightly faster ScriptWithExtensions object
9*
10*See the [Rust documentation for `ScriptWithExtensionsBorrowed`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html) for more information.
11*/
12const ScriptWithExtensionsBorrowed_box_destroy_registry = new FinalizationRegistry((ptr) => {
13    wasm.icu4x_ScriptWithExtensionsBorrowed_destroy_mv1(ptr);
14});
15
16export class ScriptWithExtensionsBorrowed {
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    #aEdge = [];
25
26    #internalConstructor(symbol, ptr, selfEdge, aEdge) {
27        if (symbol !== diplomatRuntime.internalConstructor) {
28            console.error("ScriptWithExtensionsBorrowed is an Opaque type. You cannot call its constructor.");
29            return;
30        }
31
32
33        this.#aEdge = aEdge;
34
35        this.#ptr = ptr;
36        this.#selfEdge = selfEdge;
37
38        // Are we being borrowed? If not, we can register.
39        if (this.#selfEdge.length === 0) {
40            ScriptWithExtensionsBorrowed_box_destroy_registry.register(this, this.#ptr);
41        }
42
43        return this;
44    }
45    get ffiValue() {
46        return this.#ptr;
47    }
48
49    getScriptVal(ch) {
50        const result = wasm.icu4x_ScriptWithExtensionsBorrowed_get_script_val_mv1(this.ffiValue, ch);
51
52        try {
53            return result;
54        }
55
56        finally {}
57    }
58
59    getScriptExtensionsVal(ch) {
60        // This lifetime edge depends on lifetimes 'a
61        let aEdges = [this];
62
63        const result = wasm.icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_val_mv1(this.ffiValue, ch);
64
65        try {
66            return new ScriptExtensionsSet(diplomatRuntime.internalConstructor, result, [], aEdges);
67        }
68
69        finally {}
70    }
71
72    hasScript(ch, script) {
73        const result = wasm.icu4x_ScriptWithExtensionsBorrowed_has_script_mv1(this.ffiValue, ch, script);
74
75        try {
76            return result;
77        }
78
79        finally {}
80    }
81
82    getScriptExtensionsSet(script) {
83        const result = wasm.icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_set_mv1(this.ffiValue, script);
84
85        try {
86            return new CodePointSetData(diplomatRuntime.internalConstructor, result, []);
87        }
88
89        finally {}
90    }
91
92    constructor(symbol, ptr, selfEdge, aEdge) {
93        return this.#internalConstructor(...arguments)
94    }
95}