// generated by diplomat-tool import wasm from "./diplomat-wasm.mjs"; import * as diplomatRuntime from "./diplomat-runtime.mjs"; // Base enumerator definition /** See the [Rust documentation for `GeneralCategory`](https://docs.rs/icu/latest/icu/properties/props/struct.GeneralCategory.html) for more information. */ export class GeneralCategory { #value = undefined; static #values = new Map([ ["Unassigned", 0], ["UppercaseLetter", 1], ["LowercaseLetter", 2], ["TitlecaseLetter", 3], ["ModifierLetter", 4], ["OtherLetter", 5], ["NonspacingMark", 6], ["SpacingMark", 8], ["EnclosingMark", 7], ["DecimalNumber", 9], ["LetterNumber", 10], ["OtherNumber", 11], ["SpaceSeparator", 12], ["LineSeparator", 13], ["ParagraphSeparator", 14], ["Control", 15], ["Format", 16], ["PrivateUse", 17], ["Surrogate", 18], ["DashPunctuation", 19], ["OpenPunctuation", 20], ["ClosePunctuation", 21], ["ConnectorPunctuation", 22], ["InitialPunctuation", 28], ["FinalPunctuation", 29], ["OtherPunctuation", 23], ["MathSymbol", 24], ["CurrencySymbol", 25], ["ModifierSymbol", 26], ["OtherSymbol", 27] ]); static getAllEntries() { return GeneralCategory.#values.entries(); } constructor(value) { if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { // We pass in two internalConstructor arguments to create *new* // instances of this type, otherwise the enums are treated as singletons. if (arguments[1] === diplomatRuntime.internalConstructor ) { this.#value = arguments[2]; return; } return GeneralCategory.#objectValues[arguments[1]]; } if (value instanceof GeneralCategory) { return value; } let intVal = GeneralCategory.#values.get(value); // Nullish check, checks for null or undefined if (intVal == null) { return GeneralCategory.#objectValues[intVal]; } throw TypeError(value + " is not a GeneralCategory and does not correspond to any of its enumerator values."); } get value() { for (let entry of GeneralCategory.#values) { if (entry[1] == this.#value) { return entry[0]; } } } get ffiValue() { return this.#value; } static #objectValues = { [0]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0), [1]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1), [2]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2), [3]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3), [4]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4), [5]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5), [6]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 6), [8]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 8), [7]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 7), [9]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 9), [10]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 10), [11]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 11), [12]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 12), [13]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 13), [14]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 14), [15]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 15), [16]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 16), [17]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 17), [18]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 18), [19]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 19), [20]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 20), [21]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 21), [22]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 22), [28]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 28), [29]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 29), [23]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 23), [24]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 24), [25]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 25), [26]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 26), [27]: new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 27), }; static Unassigned = GeneralCategory.#objectValues[0]; static UppercaseLetter = GeneralCategory.#objectValues[1]; static LowercaseLetter = GeneralCategory.#objectValues[2]; static TitlecaseLetter = GeneralCategory.#objectValues[3]; static ModifierLetter = GeneralCategory.#objectValues[4]; static OtherLetter = GeneralCategory.#objectValues[5]; static NonspacingMark = GeneralCategory.#objectValues[6]; static SpacingMark = GeneralCategory.#objectValues[8]; static EnclosingMark = GeneralCategory.#objectValues[7]; static DecimalNumber = GeneralCategory.#objectValues[9]; static LetterNumber = GeneralCategory.#objectValues[10]; static OtherNumber = GeneralCategory.#objectValues[11]; static SpaceSeparator = GeneralCategory.#objectValues[12]; static LineSeparator = GeneralCategory.#objectValues[13]; static ParagraphSeparator = GeneralCategory.#objectValues[14]; static Control = GeneralCategory.#objectValues[15]; static Format = GeneralCategory.#objectValues[16]; static PrivateUse = GeneralCategory.#objectValues[17]; static Surrogate = GeneralCategory.#objectValues[18]; static DashPunctuation = GeneralCategory.#objectValues[19]; static OpenPunctuation = GeneralCategory.#objectValues[20]; static ClosePunctuation = GeneralCategory.#objectValues[21]; static ConnectorPunctuation = GeneralCategory.#objectValues[22]; static InitialPunctuation = GeneralCategory.#objectValues[28]; static FinalPunctuation = GeneralCategory.#objectValues[29]; static OtherPunctuation = GeneralCategory.#objectValues[23]; static MathSymbol = GeneralCategory.#objectValues[24]; static CurrencySymbol = GeneralCategory.#objectValues[25]; static ModifierSymbol = GeneralCategory.#objectValues[26]; static OtherSymbol = GeneralCategory.#objectValues[27]; toInteger() { const result = wasm.icu4x_GeneralCategory_to_integer_mv1(this.ffiValue); try { return result; } finally {} } static fromInteger(other) { const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); const result = wasm.icu4x_GeneralCategory_from_integer_mv1(diplomatReceive.buffer, other); try { if (!diplomatReceive.resultFlag) { return null; } return new GeneralCategory(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); } finally { diplomatReceive.free(); } } }