• 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 `GraphemeClusterBreak`](https://docs.rs/icu/latest/icu/properties/props/struct.GraphemeClusterBreak.html) for more information.
7*/
8
9
10export class GraphemeClusterBreak {
11
12    #value = undefined;
13
14    static #values = new Map([
15        ["Other", 0],
16        ["Control", 1],
17        ["Cr", 2],
18        ["Extend", 3],
19        ["L", 4],
20        ["Lf", 5],
21        ["Lv", 6],
22        ["Lvt", 7],
23        ["T", 8],
24        ["V", 9],
25        ["SpacingMark", 10],
26        ["Prepend", 11],
27        ["RegionalIndicator", 12],
28        ["EBase", 13],
29        ["EBaseGaz", 14],
30        ["EModifier", 15],
31        ["GlueAfterZwj", 16],
32        ["Zwj", 17]
33    ]);
34
35    static getAllEntries() {
36        return GraphemeClusterBreak.#values.entries();
37    }
38
39    #internalConstructor(value) {
40        if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) {
41            // We pass in two internalConstructor arguments to create *new*
42            // instances of this type, otherwise the enums are treated as singletons.
43            if (arguments[1] === diplomatRuntime.internalConstructor ) {
44                this.#value = arguments[2];
45                return this;
46            }
47            return GraphemeClusterBreak.#objectValues[arguments[1]];
48        }
49
50        if (value instanceof GraphemeClusterBreak) {
51            return value;
52        }
53
54        let intVal = GraphemeClusterBreak.#values.get(value);
55
56        // Nullish check, checks for null or undefined
57        if (intVal != null) {
58            return GraphemeClusterBreak.#objectValues[intVal];
59        }
60
61        throw TypeError(value + " is not a GraphemeClusterBreak and does not correspond to any of its enumerator values.");
62    }
63
64    static fromValue(value) {
65        return new GraphemeClusterBreak(value);
66    }
67
68    get value() {
69        return [...GraphemeClusterBreak.#values.keys()][this.#value];
70    }
71
72    get ffiValue() {
73        return this.#value;
74    }
75    static #objectValues = [
76        new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
77        new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
78        new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
79        new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
80        new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4),
81        new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5),
82        new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 6),
83        new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 7),
84        new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 8),
85        new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 9),
86        new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 10),
87        new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 11),
88        new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 12),
89        new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 13),
90        new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 14),
91        new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 15),
92        new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 16),
93        new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 17),
94    ];
95
96    static Other = GraphemeClusterBreak.#objectValues[0];
97    static Control = GraphemeClusterBreak.#objectValues[1];
98    static Cr = GraphemeClusterBreak.#objectValues[2];
99    static Extend = GraphemeClusterBreak.#objectValues[3];
100    static L = GraphemeClusterBreak.#objectValues[4];
101    static Lf = GraphemeClusterBreak.#objectValues[5];
102    static Lv = GraphemeClusterBreak.#objectValues[6];
103    static Lvt = GraphemeClusterBreak.#objectValues[7];
104    static T = GraphemeClusterBreak.#objectValues[8];
105    static V = GraphemeClusterBreak.#objectValues[9];
106    static SpacingMark = GraphemeClusterBreak.#objectValues[10];
107    static Prepend = GraphemeClusterBreak.#objectValues[11];
108    static RegionalIndicator = GraphemeClusterBreak.#objectValues[12];
109    static EBase = GraphemeClusterBreak.#objectValues[13];
110    static EBaseGaz = GraphemeClusterBreak.#objectValues[14];
111    static EModifier = GraphemeClusterBreak.#objectValues[15];
112    static GlueAfterZwj = GraphemeClusterBreak.#objectValues[16];
113    static Zwj = GraphemeClusterBreak.#objectValues[17];
114
115    static forChar(ch) {
116        const result = wasm.icu4x_GraphemeClusterBreak_for_char_mv1(ch);
117
118        try {
119            return new GraphemeClusterBreak(diplomatRuntime.internalConstructor, result);
120        }
121
122        finally {}
123    }
124
125    toIntegerValue() {
126        const result = wasm.icu4x_GraphemeClusterBreak_to_integer_value_mv1(this.ffiValue);
127
128        try {
129            return result;
130        }
131
132        finally {}
133    }
134
135    static fromIntegerValue(other) {
136        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
137
138        const result = wasm.icu4x_GraphemeClusterBreak_from_integer_value_mv1(diplomatReceive.buffer, other);
139
140        try {
141            if (!diplomatReceive.resultFlag) {
142                return null;
143            }
144            return new GraphemeClusterBreak(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
145        }
146
147        finally {
148            diplomatReceive.free();
149        }
150    }
151
152    constructor(value) {
153        return this.#internalConstructor(...arguments)
154    }
155}