• 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/** See the [Rust documentation for `HangulSyllableType`](https://docs.rs/icu/latest/icu/properties/props/struct.HangulSyllableType.html) for more information.
7*/
8
9
10export class HangulSyllableType {
11
12    #value = undefined;
13
14    static #values = new Map([
15        ["NotApplicable", 0],
16        ["LeadingJamo", 1],
17        ["VowelJamo", 2],
18        ["TrailingJamo", 3],
19        ["LeadingVowelSyllable", 4],
20        ["LeadingVowelTrailingSyllable", 5]
21    ]);
22
23    static getAllEntries() {
24        return HangulSyllableType.#values.entries();
25    }
26
27    #internalConstructor(value) {
28        if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) {
29            // We pass in two internalConstructor arguments to create *new*
30            // instances of this type, otherwise the enums are treated as singletons.
31            if (arguments[1] === diplomatRuntime.internalConstructor ) {
32                this.#value = arguments[2];
33                return this;
34            }
35            return HangulSyllableType.#objectValues[arguments[1]];
36        }
37
38        if (value instanceof HangulSyllableType) {
39            return value;
40        }
41
42        let intVal = HangulSyllableType.#values.get(value);
43
44        // Nullish check, checks for null or undefined
45        if (intVal != null) {
46            return HangulSyllableType.#objectValues[intVal];
47        }
48
49        throw TypeError(value + " is not a HangulSyllableType and does not correspond to any of its enumerator values.");
50    }
51
52    static fromValue(value) {
53        return new HangulSyllableType(value);
54    }
55
56    get value() {
57        return [...HangulSyllableType.#values.keys()][this.#value];
58    }
59
60    get ffiValue() {
61        return this.#value;
62    }
63    static #objectValues = [
64        new HangulSyllableType(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
65        new HangulSyllableType(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
66        new HangulSyllableType(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
67        new HangulSyllableType(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
68        new HangulSyllableType(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4),
69        new HangulSyllableType(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5),
70    ];
71
72    static NotApplicable = HangulSyllableType.#objectValues[0];
73    static LeadingJamo = HangulSyllableType.#objectValues[1];
74    static VowelJamo = HangulSyllableType.#objectValues[2];
75    static TrailingJamo = HangulSyllableType.#objectValues[3];
76    static LeadingVowelSyllable = HangulSyllableType.#objectValues[4];
77    static LeadingVowelTrailingSyllable = HangulSyllableType.#objectValues[5];
78
79    static forChar(ch) {
80        const result = wasm.icu4x_HangulSyllableType_for_char_mv1(ch);
81
82        try {
83            return new HangulSyllableType(diplomatRuntime.internalConstructor, result);
84        }
85
86        finally {}
87    }
88
89    toIntegerValue() {
90        const result = wasm.icu4x_HangulSyllableType_to_integer_value_mv1(this.ffiValue);
91
92        try {
93            return result;
94        }
95
96        finally {}
97    }
98
99    static fromIntegerValue(other) {
100        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
101
102        const result = wasm.icu4x_HangulSyllableType_from_integer_value_mv1(diplomatReceive.buffer, other);
103
104        try {
105            if (!diplomatReceive.resultFlag) {
106                return null;
107            }
108            return new HangulSyllableType(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
109        }
110
111        finally {
112            diplomatReceive.free();
113        }
114    }
115
116    constructor(value) {
117        return this.#internalConstructor(...arguments)
118    }
119}