LineBreak.mjs (13657B)
1 // generated by diplomat-tool 2 import wasm from "./diplomat-wasm.mjs"; 3 import * as diplomatRuntime from "./diplomat-runtime.mjs"; 4 5 6 /** 7 * See the [Rust documentation for `LineBreak`](https://docs.rs/icu/latest/icu/properties/props/struct.LineBreak.html) for more information. 8 */ 9 10 11 export class LineBreak { 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 206 /** 207 * See the [Rust documentation for `for_char`](https://docs.rs/icu/latest/icu/properties/props/trait.EnumeratedProperty.html#tymethod.for_char) for more information. 208 */ 209 static forChar(ch) { 210 211 const result = wasm.icu4x_LineBreak_for_char_mv1(ch); 212 213 try { 214 return new LineBreak(diplomatRuntime.internalConstructor, result); 215 } 216 217 finally { 218 } 219 } 220 221 /** 222 * Get the "long" name of this property value (returns empty if property value is unknown) 223 * 224 * See the [Rust documentation for `get`](https://docs.rs/icu/latest/icu/properties/struct.PropertyNamesLongBorrowed.html#method.get) for more information. 225 */ 226 longName() { 227 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true); 228 229 230 const result = wasm.icu4x_LineBreak_long_name_mv1(diplomatReceive.buffer, this.ffiValue); 231 232 try { 233 if (!diplomatReceive.resultFlag) { 234 return null; 235 } 236 return new diplomatRuntime.DiplomatSliceStr(wasm, diplomatReceive.buffer, "string8", []).getValue(); 237 } 238 239 finally { 240 diplomatReceive.free(); 241 } 242 } 243 244 /** 245 * Get the "short" name of this property value (returns empty if property value is unknown) 246 * 247 * See the [Rust documentation for `get`](https://docs.rs/icu/latest/icu/properties/struct.PropertyNamesShortBorrowed.html#method.get) for more information. 248 */ 249 shortName() { 250 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true); 251 252 253 const result = wasm.icu4x_LineBreak_short_name_mv1(diplomatReceive.buffer, this.ffiValue); 254 255 try { 256 if (!diplomatReceive.resultFlag) { 257 return null; 258 } 259 return new diplomatRuntime.DiplomatSliceStr(wasm, diplomatReceive.buffer, "string8", []).getValue(); 260 } 261 262 finally { 263 diplomatReceive.free(); 264 } 265 } 266 267 /** 268 * Convert to an integer value usable with ICU4C and CodePointMapData 269 * 270 * See the [Rust documentation for `to_icu4c_value`](https://docs.rs/icu/latest/icu/properties/props/struct.LineBreak.html#method.to_icu4c_value) for more information. 271 */ 272 toIntegerValue() { 273 274 const result = wasm.icu4x_LineBreak_to_integer_value_mv1(this.ffiValue); 275 276 try { 277 return result; 278 } 279 280 finally { 281 } 282 } 283 284 /** 285 * Convert from an integer value from ICU4C or CodePointMapData 286 * 287 * See the [Rust documentation for `from_icu4c_value`](https://docs.rs/icu/latest/icu/properties/props/struct.LineBreak.html#method.from_icu4c_value) for more information. 288 */ 289 static fromIntegerValue(other) { 290 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 291 292 293 const result = wasm.icu4x_LineBreak_from_integer_value_mv1(diplomatReceive.buffer, other); 294 295 try { 296 if (!diplomatReceive.resultFlag) { 297 return null; 298 } 299 return new LineBreak(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 300 } 301 302 finally { 303 diplomatReceive.free(); 304 } 305 } 306 307 constructor(value) { 308 return this.#internalConstructor(...arguments) 309 } 310 }