• 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 `LineBreak`](https://docs.rs/icu/latest/icu/properties/props/struct.LineBreak.html) for more information.
7*/
8
9
10export class LineBreak {
11
12    #value = undefined;
13
14    static #values = new Map([
15        ["Unknown", 0],
16        ["Ambiguous", 1],
17        ["Alphabetic", 2],
18        ["BreakBoth", 3],
19        ["BreakAfter", 4],
20        ["BreakBefore", 5],
21        ["MandatoryBreak", 6],
22        ["ContingentBreak", 7],
23        ["ClosePunctuation", 8],
24        ["CombiningMark", 9],
25        ["CarriageReturn", 10],
26        ["Exclamation", 11],
27        ["Glue", 12],
28        ["Hyphen", 13],
29        ["Ideographic", 14],
30        ["Inseparable", 15],
31        ["InfixNumeric", 16],
32        ["LineFeed", 17],
33        ["Nonstarter", 18],
34        ["Numeric", 19],
35        ["OpenPunctuation", 20],
36        ["PostfixNumeric", 21],
37        ["PrefixNumeric", 22],
38        ["Quotation", 23],
39        ["ComplexContext", 24],
40        ["Surrogate", 25],
41        ["Space", 26],
42        ["BreakSymbols", 27],
43        ["ZwSpace", 28],
44        ["NextLine", 29],
45        ["WordJoiner", 30],
46        ["H2", 31],
47        ["H3", 32],
48        ["Jl", 33],
49        ["Jt", 34],
50        ["Jv", 35],
51        ["CloseParenthesis", 36],
52        ["ConditionalJapaneseStarter", 37],
53        ["HebrewLetter", 38],
54        ["RegionalIndicator", 39],
55        ["EBase", 40],
56        ["EModifier", 41],
57        ["Zwj", 42],
58        ["Aksara", 43],
59        ["AksaraPrebase", 44],
60        ["AksaraStart", 45],
61        ["ViramaFinal", 46],
62        ["Virama", 47]
63    ]);
64
65    static getAllEntries() {
66        return LineBreak.#values.entries();
67    }
68
69    #internalConstructor(value) {
70        if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) {
71            // We pass in two internalConstructor arguments to create *new*
72            // instances of this type, otherwise the enums are treated as singletons.
73            if (arguments[1] === diplomatRuntime.internalConstructor ) {
74                this.#value = arguments[2];
75                return this;
76            }
77            return LineBreak.#objectValues[arguments[1]];
78        }
79
80        if (value instanceof LineBreak) {
81            return value;
82        }
83
84        let intVal = LineBreak.#values.get(value);
85
86        // Nullish check, checks for null or undefined
87        if (intVal != null) {
88            return LineBreak.#objectValues[intVal];
89        }
90
91        throw TypeError(value + " is not a LineBreak and does not correspond to any of its enumerator values.");
92    }
93
94    static fromValue(value) {
95        return new LineBreak(value);
96    }
97
98    get value() {
99        return [...LineBreak.#values.keys()][this.#value];
100    }
101
102    get ffiValue() {
103        return this.#value;
104    }
105    static #objectValues = [
106        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
107        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
108        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
109        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
110        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4),
111        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5),
112        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 6),
113        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 7),
114        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 8),
115        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 9),
116        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 10),
117        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 11),
118        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 12),
119        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 13),
120        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 14),
121        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 15),
122        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 16),
123        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 17),
124        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 18),
125        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 19),
126        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 20),
127        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 21),
128        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 22),
129        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 23),
130        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 24),
131        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 25),
132        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 26),
133        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 27),
134        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 28),
135        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 29),
136        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 30),
137        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 31),
138        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 32),
139        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 33),
140        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 34),
141        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 35),
142        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 36),
143        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 37),
144        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 38),
145        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 39),
146        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 40),
147        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 41),
148        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 42),
149        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 43),
150        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 44),
151        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 45),
152        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 46),
153        new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 47),
154    ];
155
156    static Unknown = LineBreak.#objectValues[0];
157    static Ambiguous = LineBreak.#objectValues[1];
158    static Alphabetic = LineBreak.#objectValues[2];
159    static BreakBoth = LineBreak.#objectValues[3];
160    static BreakAfter = LineBreak.#objectValues[4];
161    static BreakBefore = LineBreak.#objectValues[5];
162    static MandatoryBreak = LineBreak.#objectValues[6];
163    static ContingentBreak = LineBreak.#objectValues[7];
164    static ClosePunctuation = LineBreak.#objectValues[8];
165    static CombiningMark = LineBreak.#objectValues[9];
166    static CarriageReturn = LineBreak.#objectValues[10];
167    static Exclamation = LineBreak.#objectValues[11];
168    static Glue = LineBreak.#objectValues[12];
169    static Hyphen = LineBreak.#objectValues[13];
170    static Ideographic = LineBreak.#objectValues[14];
171    static Inseparable = LineBreak.#objectValues[15];
172    static InfixNumeric = LineBreak.#objectValues[16];
173    static LineFeed = LineBreak.#objectValues[17];
174    static Nonstarter = LineBreak.#objectValues[18];
175    static Numeric = LineBreak.#objectValues[19];
176    static OpenPunctuation = LineBreak.#objectValues[20];
177    static PostfixNumeric = LineBreak.#objectValues[21];
178    static PrefixNumeric = LineBreak.#objectValues[22];
179    static Quotation = LineBreak.#objectValues[23];
180    static ComplexContext = LineBreak.#objectValues[24];
181    static Surrogate = LineBreak.#objectValues[25];
182    static Space = LineBreak.#objectValues[26];
183    static BreakSymbols = LineBreak.#objectValues[27];
184    static ZwSpace = LineBreak.#objectValues[28];
185    static NextLine = LineBreak.#objectValues[29];
186    static WordJoiner = LineBreak.#objectValues[30];
187    static H2 = LineBreak.#objectValues[31];
188    static H3 = LineBreak.#objectValues[32];
189    static Jl = LineBreak.#objectValues[33];
190    static Jt = LineBreak.#objectValues[34];
191    static Jv = LineBreak.#objectValues[35];
192    static CloseParenthesis = LineBreak.#objectValues[36];
193    static ConditionalJapaneseStarter = LineBreak.#objectValues[37];
194    static HebrewLetter = LineBreak.#objectValues[38];
195    static RegionalIndicator = LineBreak.#objectValues[39];
196    static EBase = LineBreak.#objectValues[40];
197    static EModifier = LineBreak.#objectValues[41];
198    static Zwj = LineBreak.#objectValues[42];
199    static Aksara = LineBreak.#objectValues[43];
200    static AksaraPrebase = LineBreak.#objectValues[44];
201    static AksaraStart = LineBreak.#objectValues[45];
202    static ViramaFinal = LineBreak.#objectValues[46];
203    static Virama = LineBreak.#objectValues[47];
204
205    static forChar(ch) {
206        const result = wasm.icu4x_LineBreak_for_char_mv1(ch);
207
208        try {
209            return new LineBreak(diplomatRuntime.internalConstructor, result);
210        }
211
212        finally {}
213    }
214
215    longName() {
216        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true);
217
218        const result = wasm.icu4x_LineBreak_long_name_mv1(diplomatReceive.buffer, this.ffiValue);
219
220        try {
221            if (!diplomatReceive.resultFlag) {
222                return null;
223            }
224            return new diplomatRuntime.DiplomatSliceStr(wasm, diplomatReceive.buffer,  "string8", []).getValue();
225        }
226
227        finally {
228            diplomatReceive.free();
229        }
230    }
231
232    shortName() {
233        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true);
234
235        const result = wasm.icu4x_LineBreak_short_name_mv1(diplomatReceive.buffer, this.ffiValue);
236
237        try {
238            if (!diplomatReceive.resultFlag) {
239                return null;
240            }
241            return new diplomatRuntime.DiplomatSliceStr(wasm, diplomatReceive.buffer,  "string8", []).getValue();
242        }
243
244        finally {
245            diplomatReceive.free();
246        }
247    }
248
249    toIntegerValue() {
250        const result = wasm.icu4x_LineBreak_to_integer_value_mv1(this.ffiValue);
251
252        try {
253            return result;
254        }
255
256        finally {}
257    }
258
259    static fromIntegerValue(other) {
260        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
261
262        const result = wasm.icu4x_LineBreak_from_integer_value_mv1(diplomatReceive.buffer, other);
263
264        try {
265            if (!diplomatReceive.resultFlag) {
266                return null;
267            }
268            return new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
269        }
270
271        finally {
272            diplomatReceive.free();
273        }
274    }
275
276    constructor(value) {
277        return this.#internalConstructor(...arguments)
278    }
279}