Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/intl/icu_capi/bindings/js/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 5 kB image not shown  

Quelle  PluralCategories.mjs   Sprache: unbekannt

 
Spracherkennung für: .mjs vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

// generated by diplomat-tool
import wasm from "./diplomat-wasm.mjs";
import * as diplomatRuntime from "./diplomat-runtime.mjs";



/**
 * See the [Rust documentation for `categories`](https://docs.rs/icu/2.1.1/icu/plurals/struct.PluralRules.html#method.categories) for more information.
 */
export class PluralCategories {
    #zero;
    get zero() {
        return this.#zero;
    }
    #one;
    get one() {
        return this.#one;
    }
    #two;
    get two() {
        return this.#two;
    }
    #few;
    get few() {
        return this.#few;
    }
    #many;
    get many() {
        return this.#many;
    }
    #other;
    get other() {
        return this.#other;
    }
    #internalConstructor(structObj, internalConstructor) {
        if (typeof structObj !== "object") {
            throw new Error("PluralCategories's constructor takes an object of PluralCategories's fields.");
        }

        if (internalConstructor !== diplomatRuntime.internalConstructor) {
            throw new Error("PluralCategories is an out struct and can only be created internally.");
        }
        if ("zero" in structObj) {
            this.#zero = structObj.zero;
        } else {
            throw new Error("Missing required field zero.");
        }

        if ("one" in structObj) {
            this.#one = structObj.one;
        } else {
            throw new Error("Missing required field one.");
        }

        if ("two" in structObj) {
            this.#two = structObj.two;
        } else {
            throw new Error("Missing required field two.");
        }

        if ("few" in structObj) {
            this.#few = structObj.few;
        } else {
            throw new Error("Missing required field few.");
        }

        if ("many" in structObj) {
            this.#many = structObj.many;
        } else {
            throw new Error("Missing required field many.");
        }

        if ("other" in structObj) {
            this.#other = structObj.other;
        } else {
            throw new Error("Missing required field other.");
        }

        return this;
    }

    // Return this struct in FFI function friendly format.
    // Returns an array that can be expanded with spread syntax (...)
    _intoFFI(
        functionCleanupArena,
        appendArrayMap
    ) {
        let buffer = diplomatRuntime.DiplomatBuf.struct(wasm, 61);

        this._writeToArrayBuffer(wasm.memory.buffer, buffer.ptr, functionCleanupArena, appendArrayMap);

        functionCleanupArena.alloc(buffer);

        return buffer.ptr;
    }

    static _fromSuppliedValue(internalConstructor, obj) {
        if (internalConstructor !== diplomatRuntime.internalConstructor) {
            throw new Error("_fromSuppliedValue cannot be called externally.");
        }

        if (obj instanceof PluralCategories) {
            return obj;
        }

        return PluralCategories.fromFields(obj);
    }

    _writeToArrayBuffer(
        arrayBuffer,
        offset,
        functionCleanupArena,
        appendArrayMap
    ) {
        diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, this.#zero, Uint8Array);
        diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 1, this.#one, Uint8Array);
        diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 2, this.#two, Uint8Array);
        diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 3, this.#few, Uint8Array);
        diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 4, this.#many, Uint8Array);
        diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 5, this.#other, Uint8Array);
    }

    // This struct contains borrowed fields, so this takes in a list of
    // "edges" corresponding to where each lifetime's data may have been borrowed from
    // and passes it down to individual fields containing the borrow.
    // This method does not attempt to handle any dependencies between lifetimes, the caller
    // should handle this when constructing edge arrays.
    static _fromFFI(internalConstructor, ptr) {
        if (internalConstructor !== diplomatRuntime.internalConstructor) {
            throw new Error("PluralCategories._fromFFI is not meant to be called externally. Please use the default constructor.");
        }
        let structObj = {};
        const zeroDeref = (new Uint8Array(wasm.memory.buffer, ptr, 1))[0] === 1;
        structObj.zero = zeroDeref;
        const oneDeref = (new Uint8Array(wasm.memory.buffer, ptr + 11))[0] === 1;
        structObj.one = oneDeref;
        const twoDeref = (new Uint8Array(wasm.memory.buffer, ptr + 21))[0] === 1;
        structObj.two = twoDeref;
        const fewDeref = (new Uint8Array(wasm.memory.buffer, ptr + 31))[0] === 1;
        structObj.few = fewDeref;
        const manyDeref = (new Uint8Array(wasm.memory.buffer, ptr + 41))[0] === 1;
        structObj.many = manyDeref;
        const otherDeref = (new Uint8Array(wasm.memory.buffer, ptr + 51))[0] === 1;
        structObj.other = otherDeref;

        return new PluralCategories(structObj, internalConstructor);
    }


    constructor(structObj, internalConstructor) {
        return this.#internalConstructor(...arguments)
    }
}

[Dauer der Verarbeitung: 0.21 Sekunden, vorverarbeitet 2026-08-25]