• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// generated by diplomat-tool
2import { DataError } from "./DataError.mjs"
3import { DataProvider } from "./DataProvider.mjs"
4import wasm from "./diplomat-wasm.mjs";
5import * as diplomatRuntime from "./diplomat-runtime.mjs";
6
7
8/** An ICU4X Unicode Set Property object, capable of querying whether a code point is contained in a set based on a Unicode property.
9*
10*See the [Rust documentation for `properties`](https://docs.rs/icu/latest/icu/properties/index.html) for more information.
11*
12*See the [Rust documentation for `EmojiSetData`](https://docs.rs/icu/latest/icu/properties/struct.EmojiSetData.html) for more information.
13*
14*See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/properties/struct.EmojiSetData.html#method.new) for more information.
15*
16*See the [Rust documentation for `EmojiSetDataBorrowed`](https://docs.rs/icu/latest/icu/properties/struct.EmojiSetDataBorrowed.html) for more information.
17*/
18const EmojiSetData_box_destroy_registry = new FinalizationRegistry((ptr) => {
19    wasm.icu4x_EmojiSetData_destroy_mv1(ptr);
20});
21
22export class EmojiSetData {
23
24    // Internal ptr reference:
25    #ptr = null;
26
27    // Lifetimes are only to keep dependencies alive.
28    // Since JS won't garbage collect until there are no incoming edges.
29    #selfEdge = [];
30
31    #internalConstructor(symbol, ptr, selfEdge) {
32        if (symbol !== diplomatRuntime.internalConstructor) {
33            console.error("EmojiSetData is an Opaque type. You cannot call its constructor.");
34            return;
35        }
36
37        this.#ptr = ptr;
38        this.#selfEdge = selfEdge;
39
40        // Are we being borrowed? If not, we can register.
41        if (this.#selfEdge.length === 0) {
42            EmojiSetData_box_destroy_registry.register(this, this.#ptr);
43        }
44
45        return this;
46    }
47    get ffiValue() {
48        return this.#ptr;
49    }
50
51    containsStr(s) {
52        let functionCleanupArena = new diplomatRuntime.CleanupArena();
53
54        const sSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.str8(wasm, s));
55
56        const result = wasm.icu4x_EmojiSetData_contains_str_mv1(this.ffiValue, ...sSlice.splat());
57
58        try {
59            return result;
60        }
61
62        finally {
63            functionCleanupArena.free();
64        }
65    }
66
67    contains(cp) {
68        const result = wasm.icu4x_EmojiSetData_contains_mv1(this.ffiValue, cp);
69
70        try {
71            return result;
72        }
73
74        finally {}
75    }
76
77    static createBasic() {
78        const result = wasm.icu4x_EmojiSetData_create_basic_mv1();
79
80        try {
81            return new EmojiSetData(diplomatRuntime.internalConstructor, result, []);
82        }
83
84        finally {}
85    }
86
87    static createBasicWithProvider(provider) {
88        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
89
90        const result = wasm.icu4x_EmojiSetData_create_basic_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
91
92        try {
93            if (!diplomatReceive.resultFlag) {
94                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
95                throw new globalThis.Error('DataError: ' + cause.value, { cause });
96            }
97            return new EmojiSetData(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
98        }
99
100        finally {
101            diplomatReceive.free();
102        }
103    }
104
105    constructor(symbol, ptr, selfEdge) {
106        return this.#internalConstructor(...arguments)
107    }
108}