Source code

Revision control

Copy as Markdown

Other Tools

// generated by diplomat-tool
import wasm from "./diplomat-wasm.mjs";
import * as diplomatRuntime from "./diplomat-runtime.mjs";
/**
*/
export class CalendarError {
#value = undefined;
static #values = new Map([
["Unknown", 0],
["OutOfRange", 1],
["UnknownEra", 2],
["UnknownMonthCode", 3]
]);
static getAllEntries() {
return CalendarError.#values.entries();
}
#internalConstructor(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 this;
}
return CalendarError.#objectValues[arguments[1]];
}
if (value instanceof CalendarError) {
return value;
}
let intVal = CalendarError.#values.get(value);
// Nullish check, checks for null or undefined
if (intVal != null) {
return CalendarError.#objectValues[intVal];
}
throw TypeError(value + " is not a CalendarError and does not correspond to any of its enumerator values.");
}
static fromValue(value) {
return new CalendarError(value);
}
get value(){
return [...CalendarError.#values.keys()][this.#value];
}
get ffiValue(){
return this.#value;
}
static #objectValues = [
new CalendarError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
new CalendarError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
new CalendarError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
new CalendarError(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
];
static Unknown = CalendarError.#objectValues[0];
static OutOfRange = CalendarError.#objectValues[1];
static UnknownEra = CalendarError.#objectValues[2];
static UnknownMonthCode = CalendarError.#objectValues[3];
constructor(value) {
return this.#internalConstructor(...arguments)
}
}