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  CollatorOptions.mjs   Sprache: unbekannt

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

// generated by diplomat-tool
import { CollatorAlternateHandling } from "./CollatorAlternateHandling.mjs"
import { CollatorCaseLevel } from "./CollatorCaseLevel.mjs"
import { CollatorMaxVariable } from "./CollatorMaxVariable.mjs"
import { CollatorStrength } from "./CollatorStrength.mjs"
import wasm from "./diplomat-wasm.mjs";
import * as diplomatRuntime from "./diplomat-runtime.mjs";



/**
 * See the [Rust documentation for `CollatorOptions`](https://docs.rs/icu/2.1.1/icu/collator/options/struct.CollatorOptions.html) for more information.
 */
export class CollatorOptions {
    #strength;
    get strength() {
        return this.#strength;
    }
    set strength(value){
        this.#strength = value;
    }
    #alternateHandling;
    get alternateHandling() {
        return this.#alternateHandling;
    }
    set alternateHandling(value){
        this.#alternateHandling = value;
    }
    #maxVariable;
    get maxVariable() {
        return this.#maxVariable;
    }
    set maxVariable(value){
        this.#maxVariable = value;
    }
    #caseLevel;
    get caseLevel() {
        return this.#caseLevel;
    }
    set caseLevel(value){
        this.#caseLevel = value;
    }
    /** @internal */
    static fromFields(structObj) {
        return new CollatorOptions(structObj);
    }

    #internalConstructor(structObj) {
        if (typeof structObj !== "object") {
            throw new Error("CollatorOptions's constructor takes an object of CollatorOptions's fields.");
        }

        if ("strength" in structObj) {
            this.#strength = structObj.strength;
        } else {
            this.#strength = null;
        }

        if ("alternateHandling" in structObj) {
            this.#alternateHandling = structObj.alternateHandling;
        } else {
            this.#alternateHandling = null;
        }

        if ("maxVariable" in structObj) {
            this.#maxVariable = structObj.maxVariable;
        } else {
            this.#maxVariable = null;
        }

        if ("caseLevel" in structObj) {
            this.#caseLevel = structObj.caseLevel;
        } else {
            this.#caseLevel = null;
        }

        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, 324);

        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 CollatorOptions) {
            return obj;
        }

        return CollatorOptions.fromFields(obj);
    }

    _writeToArrayBuffer(
        arrayBuffer,
        offset,
        functionCleanupArena,
        appendArrayMap
    ) {
        diplomatRuntime.writeOptionToArrayBuffer(arrayBuffer, offset + 0, this.#strength, 44, (arrayBuffer, offset, jsValue) => diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array));
        diplomatRuntime.writeOptionToArrayBuffer(arrayBuffer, offset + 8, this.#alternateHandling, 44, (arrayBuffer, offset, jsValue) => diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array));
        diplomatRuntime.writeOptionToArrayBuffer(arrayBuffer, offset + 16, this.#maxVariable44, (arrayBuffer, offset, jsValue) => diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array));
        diplomatRuntime.writeOptionToArrayBuffer(arrayBuffer, offset + 24, this.#caseLevel, 44, (arrayBuffer, offset, jsValue) => diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, jsValue.ffiValue, Int32Array));
    }

    // 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("CollatorOptions._fromFFI is not meant to be called externally. Please use the default constructor.");
        }
        let structObj = {};
        const strengthDeref = ptr;
        structObj.strength = diplomatRuntime.readOption(wasm, strengthDeref, 4, (wasm, offset) => { const deref = diplomatRuntime.enumDiscriminant(wasm, offset); return new CollatorStrength(diplomatRuntime.internalConstructor, deref) });
        const alternateHandlingDeref = ptr + 8;
        structObj.alternateHandling = diplomatRuntime.readOption(wasm, alternateHandlingDeref, 4, (wasm, offset) => { const deref = diplomatRuntime.enumDiscriminant(wasm, offset); return new CollatorAlternateHandling(diplomatRuntime.internalConstructor, deref) });
        const maxVariableDeref = ptr + 16;
        structObj.maxVariable = diplomatRuntime.readOption(wasm, maxVariableDeref, 4, (wasm, offset) => { const deref = diplomatRuntime.enumDiscriminant(wasm, offset); return new CollatorMaxVariable(diplomatRuntime.internalConstructor, deref) });
        const caseLevelDeref = ptr + 24;
        structObj.caseLevel = diplomatRuntime.readOption(wasm, caseLevelDeref, 4, (wasm, offset) => { const deref = diplomatRuntime.enumDiscriminant(wasm, offset); return new CollatorCaseLevel(diplomatRuntime.internalConstructor, deref) });

        return new CollatorOptions(structObj);
    }


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

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