tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

BidiDirection.mjs (2113B)


      1 // generated by diplomat-tool
      2 import wasm from "./diplomat-wasm.mjs";
      3 import * as diplomatRuntime from "./diplomat-runtime.mjs";
      4 
      5 
      6 
      7 export class BidiDirection {
      8    #value = undefined;
      9 
     10    static #values = new Map([
     11        ["Ltr", 0],
     12        ["Rtl", 1],
     13        ["Mixed", 2]
     14    ]);
     15 
     16    static getAllEntries() {
     17        return BidiDirection.#values.entries();
     18    }
     19 
     20    #internalConstructor(value) {
     21        if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) {
     22            // We pass in two internalConstructor arguments to create *new*
     23            // instances of this type, otherwise the enums are treated as singletons.
     24            if (arguments[1] === diplomatRuntime.internalConstructor ) {
     25                this.#value = arguments[2];
     26                return this;
     27            }
     28            return BidiDirection.#objectValues[arguments[1]];
     29        }
     30 
     31        if (value instanceof BidiDirection) {
     32            return value;
     33        }
     34 
     35        let intVal = BidiDirection.#values.get(value);
     36 
     37        // Nullish check, checks for null or undefined
     38        if (intVal != null) {
     39            return BidiDirection.#objectValues[intVal];
     40        }
     41 
     42        throw TypeError(value + " is not a BidiDirection and does not correspond to any of its enumerator values.");
     43    }
     44 
     45    static fromValue(value) {
     46        return new BidiDirection(value);
     47    }
     48 
     49    get value(){
     50        return [...BidiDirection.#values.keys()][this.#value];
     51    }
     52 
     53    get ffiValue(){
     54        return this.#value;
     55    }
     56    static #objectValues = [
     57        new BidiDirection(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
     58        new BidiDirection(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
     59        new BidiDirection(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
     60    ];
     61 
     62    static Ltr = BidiDirection.#objectValues[0];
     63    static Rtl = BidiDirection.#objectValues[1];
     64    static Mixed = BidiDirection.#objectValues[2];
     65 
     66 
     67    constructor(value) {
     68        return this.#internalConstructor(...arguments)
     69    }
     70 }