Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/intl/icu_capi/bindings/js/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 5 kB image not shown  

Quelle  ICU4XCollator.mjs   Sprache: unbekannt

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

import wasm from "./diplomat-wasm.mjs"
import * as diplomatRuntime from "./diplomat-runtime.mjs"
import { ICU4XCollatorAlternateHandling_js_to_rust, ICU4XCollatorAlternateHandling_rust_to_js } from "./ICU4XCollatorAlternateHandling.mjs"
import { ICU4XCollatorBackwardSecondLevel_js_to_rust, ICU4XCollatorBackwardSecondLevel_rust_to_js } from "./ICU4XCollatorBackwardSecondLevel.mjs"
import { ICU4XCollatorCaseFirst_js_to_rust, ICU4XCollatorCaseFirst_rust_to_js } from "./ICU4XCollatorCaseFirst.mjs"
import { ICU4XCollatorCaseLevel_js_to_rust, ICU4XCollatorCaseLevel_rust_to_js } from "./ICU4XCollatorCaseLevel.mjs"
import { ICU4XCollatorMaxVariable_js_to_rust, ICU4XCollatorMaxVariable_rust_to_js } from "./ICU4XCollatorMaxVariable.mjs"
import { ICU4XCollatorNumeric_js_to_rust, ICU4XCollatorNumeric_rust_to_js } from "./ICU4XCollatorNumeric.mjs"
import { ICU4XCollatorResolvedOptionsV1 } from "./ICU4XCollatorResolvedOptionsV1.mjs"
import { ICU4XCollatorStrength_js_to_rust, ICU4XCollatorStrength_rust_to_js } from "./ICU4XCollatorStrength.mjs"
import { ICU4XError_js_to_rust, ICU4XError_rust_to_js } from "./ICU4XError.mjs"
import { ICU4XOrdering_js_to_rust, ICU4XOrdering_rust_to_js } from "./ICU4XOrdering.mjs"

const ICU4XCollator_box_destroy_registry = new FinalizationRegistry(underlying => {
  wasm.ICU4XCollator_destroy(underlying);
});

export class ICU4XCollator {
  #lifetimeEdges = [];
  constructor(underlying, owned, edges) {
    this.underlying = underlying;
    this.#lifetimeEdges.push(...edges);
    if (owned) {
      ICU4XCollator_box_destroy_registry.register(this, underlying);
    }
  }

  static create_v1(arg_provider, arg_locale, arg_options) {
    const field_strength_arg_options = arg_options["strength"];
    const field_alternate_handling_arg_options = arg_options["alternate_handling"];
    const field_case_first_arg_options = arg_options["case_first"];
    const field_max_variable_arg_options = arg_options["max_variable"];
    const field_case_level_arg_options = arg_options["case_level"];
    const field_numeric_arg_options = arg_options["numeric"];
    const field_backward_second_level_arg_options = arg_options["backward_second_level"];
    return (() => {
      const diplomat_receive_buffer = wasm.diplomat_alloc(5, 4);
      wasm.ICU4XCollator_create_v1(diplomat_receive_buffer, arg_provider.underlying, arg_locale.underlying, ICU4XCollatorStrength_js_to_rust[field_strength_arg_options], ICU4XCollatorAlternateHandling_js_to_rust[field_alternate_handling_arg_options], ICU4XCollatorCaseFirst_js_to_rust[field_case_first_arg_options], ICU4XCollatorMaxVariable_js_to_rust[field_max_variable_arg_options], ICU4XCollatorCaseLevel_js_to_rust[field_case_level_arg_options], ICU4XCollatorNumeric_js_to_rust[field_numeric_arg_options], ICU4XCollatorBackwardSecondLevel_js_to_rust[field_backward_second_level_arg_options]);
      const is_ok = diplomatRuntime.resultFlag(wasm, diplomat_receive_buffer, 4);
      if (is_ok) {
        const ok_value = new ICU4XCollator(diplomatRuntime.ptrRead(wasm, diplomat_receive_buffer), true, []);
        wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
        return ok_value;
      } else {
        const throw_value = ICU4XError_rust_to_js[diplomatRuntime.enumDiscriminant(wasm, diplomat_receive_buffer)];
        wasm.diplomat_free(diplomat_receive_buffer, 5, 4);
        throw new diplomatRuntime.FFIError(throw_value);
      }
    })();
  }

  compare(arg_left, arg_right) {
    const buf_arg_left = diplomatRuntime.DiplomatBuf.str8(wasm, arg_left);
    const buf_arg_right = diplomatRuntime.DiplomatBuf.str8(wasm, arg_right);
    const diplomat_out = ICU4XOrdering_rust_to_js[wasm.ICU4XCollator_compare(this.underlying, buf_arg_left.ptr, buf_arg_left.size, buf_arg_right.ptr, buf_arg_right.size)];
    buf_arg_left.free();
    buf_arg_right.free();
    return diplomat_out;
  }

  compare_valid_utf8(arg_left, arg_right) {
    const buf_arg_left = diplomatRuntime.DiplomatBuf.str8(wasm, arg_left);
    const buf_arg_right = diplomatRuntime.DiplomatBuf.str8(wasm, arg_right);
    const diplomat_out = ICU4XOrdering_rust_to_js[wasm.ICU4XCollator_compare_valid_utf8(this.underlying, buf_arg_left.ptr, buf_arg_left.size, buf_arg_right.ptr, buf_arg_right.size)];
    buf_arg_left.free();
    buf_arg_right.free();
    return diplomat_out;
  }

  compare_utf16(arg_left, arg_right) {
    const buf_arg_left = diplomatRuntime.DiplomatBuf.str16(wasm, arg_left);
    const buf_arg_right = diplomatRuntime.DiplomatBuf.str16(wasm, arg_right);
    const diplomat_out = ICU4XOrdering_rust_to_js[wasm.ICU4XCollator_compare_utf16(this.underlying, buf_arg_left.ptr, buf_arg_left.size, buf_arg_right.ptr, buf_arg_right.size)];
    buf_arg_left.free();
    buf_arg_right.free();
    return diplomat_out;
  }

  resolved_options() {
    return (() => {
      const diplomat_receive_buffer = wasm.diplomat_alloc(28, 4);
      wasm.ICU4XCollator_resolved_options(diplomat_receive_buffer, this.underlying);
      const out = new ICU4XCollatorResolvedOptionsV1(diplomat_receive_buffer);
      wasm.diplomat_free(diplomat_receive_buffer, 28, 4);
      return out;
    })();
  }
}

[ Dauer der Verarbeitung: 0.35 Sekunden  ]