tor-browser

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

ScriptWithExtensionsBorrowed.mjs (4072B)


      1 // generated by diplomat-tool
      2 import { CodePointSetData } from "./CodePointSetData.mjs"
      3 import { ScriptExtensionsSet } from "./ScriptExtensionsSet.mjs"
      4 import wasm from "./diplomat-wasm.mjs";
      5 import * as diplomatRuntime from "./diplomat-runtime.mjs";
      6 
      7 
      8 /**
      9 * A slightly faster ScriptWithExtensions object
     10 *
     11 * See the [Rust documentation for `ScriptWithExtensionsBorrowed`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html) for more information.
     12 */
     13 const ScriptWithExtensionsBorrowed_box_destroy_registry = new FinalizationRegistry((ptr) => {
     14    wasm.icu4x_ScriptWithExtensionsBorrowed_destroy_mv1(ptr);
     15 });
     16 
     17 export class ScriptWithExtensionsBorrowed {
     18    // Internal ptr reference:
     19    #ptr = null;
     20 
     21    // Lifetimes are only to keep dependencies alive.
     22    // Since JS won't garbage collect until there are no incoming edges.
     23    #selfEdge = [];
     24    #aEdge = [];
     25 
     26    #internalConstructor(symbol, ptr, selfEdge, aEdge) {
     27        if (symbol !== diplomatRuntime.internalConstructor) {
     28            console.error("ScriptWithExtensionsBorrowed is an Opaque type. You cannot call its constructor.");
     29            return;
     30        }
     31        this.#aEdge = aEdge;
     32        this.#ptr = ptr;
     33        this.#selfEdge = selfEdge;
     34 
     35        // Are we being borrowed? If not, we can register.
     36        if (this.#selfEdge.length === 0) {
     37            ScriptWithExtensionsBorrowed_box_destroy_registry.register(this, this.#ptr);
     38        }
     39 
     40        return this;
     41    }
     42    get ffiValue() {
     43        return this.#ptr;
     44    }
     45 
     46 
     47    /**
     48     * Get the Script property value for a code point
     49     * Get the Script property value for a code point
     50     *
     51     * See the [Rust documentation for `get_script_val`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.get_script_val) for more information.
     52     */
     53    getScriptVal(ch) {
     54 
     55        const result = wasm.icu4x_ScriptWithExtensionsBorrowed_get_script_val_mv1(this.ffiValue, ch);
     56 
     57        try {
     58            return result;
     59        }
     60 
     61        finally {
     62        }
     63    }
     64 
     65    /**
     66     * Get the Script property value for a code point
     67     *
     68     * See the [Rust documentation for `get_script_extensions_val`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.get_script_extensions_val) for more information.
     69     */
     70    getScriptExtensionsVal(ch) {
     71        // This lifetime edge depends on lifetimes 'a
     72        let aEdges = [this];
     73 
     74 
     75        const result = wasm.icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_val_mv1(this.ffiValue, ch);
     76 
     77        try {
     78            return new ScriptExtensionsSet(diplomatRuntime.internalConstructor, result, [], aEdges);
     79        }
     80 
     81        finally {
     82        }
     83    }
     84 
     85    /**
     86     * Check if the Script_Extensions property of the given code point covers the given script
     87     *
     88     * See the [Rust documentation for `has_script`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.has_script) for more information.
     89     */
     90    hasScript(ch, script) {
     91 
     92        const result = wasm.icu4x_ScriptWithExtensionsBorrowed_has_script_mv1(this.ffiValue, ch, script);
     93 
     94        try {
     95            return result;
     96        }
     97 
     98        finally {
     99        }
    100    }
    101 
    102    /**
    103     * Build the CodePointSetData corresponding to a codepoints matching a particular script
    104     * in their Script_Extensions
    105     *
    106     * See the [Rust documentation for `get_script_extensions_set`](https://docs.rs/icu/latest/icu/properties/script/struct.ScriptWithExtensionsBorrowed.html#method.get_script_extensions_set) for more information.
    107     */
    108    getScriptExtensionsSet(script) {
    109 
    110        const result = wasm.icu4x_ScriptWithExtensionsBorrowed_get_script_extensions_set_mv1(this.ffiValue, script);
    111 
    112        try {
    113            return new CodePointSetData(diplomatRuntime.internalConstructor, result, []);
    114        }
    115 
    116        finally {
    117        }
    118    }
    119 
    120    constructor(symbol, ptr, selfEdge, aEdge) {
    121        return this.#internalConstructor(...arguments)
    122    }
    123 }