tor-browser

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

PropertyValueNameToEnumMapper.mjs (21878B)


      1 // generated by diplomat-tool
      2 import { DataError } from "./DataError.mjs"
      3 import { DataProvider } from "./DataProvider.mjs"
      4 import wasm from "./diplomat-wasm.mjs";
      5 import * as diplomatRuntime from "./diplomat-runtime.mjs";
      6 
      7 
      8 /**
      9 * A type capable of looking up a property value from a string name.
     10 *
     11 * See the [Rust documentation for `PropertyParser`](https://docs.rs/icu/latest/icu/properties/struct.PropertyParser.html) for more information.
     12 *
     13 * See the [Rust documentation for `PropertyParserBorrowed`](https://docs.rs/icu/latest/icu/properties/struct.PropertyParserBorrowed.html) for more information.
     14 *
     15 * See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/properties/struct.PropertyParser.html#method.new) for more information.
     16 */
     17 const PropertyValueNameToEnumMapper_box_destroy_registry = new FinalizationRegistry((ptr) => {
     18    wasm.icu4x_PropertyValueNameToEnumMapper_destroy_mv1(ptr);
     19 });
     20 
     21 export class PropertyValueNameToEnumMapper {
     22    // Internal ptr reference:
     23    #ptr = null;
     24 
     25    // Lifetimes are only to keep dependencies alive.
     26    // Since JS won't garbage collect until there are no incoming edges.
     27    #selfEdge = [];
     28 
     29    #internalConstructor(symbol, ptr, selfEdge) {
     30        if (symbol !== diplomatRuntime.internalConstructor) {
     31            console.error("PropertyValueNameToEnumMapper is an Opaque type. You cannot call its constructor.");
     32            return;
     33        }
     34        this.#ptr = ptr;
     35        this.#selfEdge = selfEdge;
     36 
     37        // Are we being borrowed? If not, we can register.
     38        if (this.#selfEdge.length === 0) {
     39            PropertyValueNameToEnumMapper_box_destroy_registry.register(this, this.#ptr);
     40        }
     41 
     42        return this;
     43    }
     44    get ffiValue() {
     45        return this.#ptr;
     46    }
     47 
     48 
     49    /**
     50     * Get the property value matching the given name, using strict matching
     51     *
     52     * Returns -1 if the name is unknown for this property
     53     *
     54     * See the [Rust documentation for `get_strict`](https://docs.rs/icu/latest/icu/properties/struct.PropertyParserBorrowed.html#method.get_strict) for more information.
     55     */
     56    getStrict(name) {
     57        let functionCleanupArena = new diplomatRuntime.CleanupArena();
     58 
     59        const nameSlice = diplomatRuntime.DiplomatBuf.str8(wasm, name);
     60 
     61        const result = wasm.icu4x_PropertyValueNameToEnumMapper_get_strict_mv1(this.ffiValue, ...nameSlice.splat());
     62 
     63        try {
     64            return result;
     65        }
     66 
     67        finally {
     68            functionCleanupArena.free();
     69 
     70        }
     71    }
     72 
     73    /**
     74     * Get the property value matching the given name, using loose matching
     75     *
     76     * Returns -1 if the name is unknown for this property
     77     *
     78     * See the [Rust documentation for `get_loose`](https://docs.rs/icu/latest/icu/properties/struct.PropertyParserBorrowed.html#method.get_loose) for more information.
     79     */
     80    getLoose(name) {
     81        let functionCleanupArena = new diplomatRuntime.CleanupArena();
     82 
     83        const nameSlice = diplomatRuntime.DiplomatBuf.str8(wasm, name);
     84 
     85        const result = wasm.icu4x_PropertyValueNameToEnumMapper_get_loose_mv1(this.ffiValue, ...nameSlice.splat());
     86 
     87        try {
     88            return result;
     89        }
     90 
     91        finally {
     92            functionCleanupArena.free();
     93 
     94        }
     95    }
     96 
     97    /**
     98     * Create a name-to-enum mapper for the `General_Category` property, using compiled data.
     99     *
    100     * See the [Rust documentation for `GeneralCategory`](https://docs.rs/icu/latest/icu/properties/props/enum.GeneralCategory.html) for more information.
    101     */
    102    static createGeneralCategory() {
    103 
    104        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_general_category_mv1();
    105 
    106        try {
    107            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
    108        }
    109 
    110        finally {
    111        }
    112    }
    113 
    114    /**
    115     * Create a name-to-enum mapper for the `General_Category` property, using a particular data source.
    116     *
    117     * See the [Rust documentation for `GeneralCategory`](https://docs.rs/icu/latest/icu/properties/props/enum.GeneralCategory.html) for more information.
    118     */
    119    static createGeneralCategoryWithProvider(provider) {
    120        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
    121 
    122 
    123        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_general_category_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
    124 
    125        try {
    126            if (!diplomatReceive.resultFlag) {
    127                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
    128                throw new globalThis.Error('DataError: ' + cause.value, { cause });
    129            }
    130            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
    131        }
    132 
    133        finally {
    134            diplomatReceive.free();
    135        }
    136    }
    137 
    138    /**
    139     * Create a name-to-enum mapper for the `Hangul_Syllable_Type` property, using compiled data.
    140     *
    141     * See the [Rust documentation for `HangulSyllableType`](https://docs.rs/icu/latest/icu/properties/props/struct.HangulSyllableType.html) for more information.
    142     */
    143    static createHangulSyllableType() {
    144 
    145        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_hangul_syllable_type_mv1();
    146 
    147        try {
    148            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
    149        }
    150 
    151        finally {
    152        }
    153    }
    154 
    155    /**
    156     * Create a name-to-enum mapper for the `Hangul_Syllable_Type` property, using a particular data source.
    157     *
    158     * See the [Rust documentation for `HangulSyllableType`](https://docs.rs/icu/latest/icu/properties/props/struct.HangulSyllableType.html) for more information.
    159     */
    160    static createHangulSyllableTypeWithProvider(provider) {
    161        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
    162 
    163 
    164        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_hangul_syllable_type_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
    165 
    166        try {
    167            if (!diplomatReceive.resultFlag) {
    168                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
    169                throw new globalThis.Error('DataError: ' + cause.value, { cause });
    170            }
    171            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
    172        }
    173 
    174        finally {
    175            diplomatReceive.free();
    176        }
    177    }
    178 
    179    /**
    180     * Create a name-to-enum mapper for the `East_Asian_Width` property, using compiled data.
    181     *
    182     * See the [Rust documentation for `EastAsianWidth`](https://docs.rs/icu/latest/icu/properties/props/struct.EastAsianWidth.html) for more information.
    183     */
    184    static createEastAsianWidth() {
    185 
    186        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_east_asian_width_mv1();
    187 
    188        try {
    189            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
    190        }
    191 
    192        finally {
    193        }
    194    }
    195 
    196    /**
    197     * Create a name-to-enum mapper for the `East_Asian_Width` property, using a particular data source.
    198     *
    199     * See the [Rust documentation for `EastAsianWidth`](https://docs.rs/icu/latest/icu/properties/props/struct.EastAsianWidth.html) for more information.
    200     */
    201    static createEastAsianWidthWithProvider(provider) {
    202        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
    203 
    204 
    205        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_east_asian_width_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
    206 
    207        try {
    208            if (!diplomatReceive.resultFlag) {
    209                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
    210                throw new globalThis.Error('DataError: ' + cause.value, { cause });
    211            }
    212            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
    213        }
    214 
    215        finally {
    216            diplomatReceive.free();
    217        }
    218    }
    219 
    220    /**
    221     * Create a name-to-enum mapper for the `Bidi_Class` property, using compiled data.
    222     *
    223     * See the [Rust documentation for `BidiClass`](https://docs.rs/icu/latest/icu/properties/props/struct.BidiClass.html) for more information.
    224     */
    225    static createBidiClass() {
    226 
    227        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_bidi_class_mv1();
    228 
    229        try {
    230            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
    231        }
    232 
    233        finally {
    234        }
    235    }
    236 
    237    /**
    238     * Create a name-to-enum mapper for the `Bidi_Class` property, using a particular data source.
    239     *
    240     * See the [Rust documentation for `BidiClass`](https://docs.rs/icu/latest/icu/properties/props/struct.BidiClass.html) for more information.
    241     */
    242    static createBidiClassWithProvider(provider) {
    243        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
    244 
    245 
    246        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_bidi_class_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
    247 
    248        try {
    249            if (!diplomatReceive.resultFlag) {
    250                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
    251                throw new globalThis.Error('DataError: ' + cause.value, { cause });
    252            }
    253            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
    254        }
    255 
    256        finally {
    257            diplomatReceive.free();
    258        }
    259    }
    260 
    261    /**
    262     * Create a name-to-enum mapper for the `Indic_Syllabic_Category` property, using compiled data.
    263     *
    264     * See the [Rust documentation for `IndicSyllabicCategory`](https://docs.rs/icu/latest/icu/properties/props/struct.IndicSyllabicCategory.html) for more information.
    265     */
    266    static createIndicSyllabicCategory() {
    267 
    268        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_indic_syllabic_category_mv1();
    269 
    270        try {
    271            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
    272        }
    273 
    274        finally {
    275        }
    276    }
    277 
    278    /**
    279     * Create a name-to-enum mapper for the `Indic_Syllabic_Category` property, using a particular data source.
    280     *
    281     * See the [Rust documentation for `IndicSyllabicCategory`](https://docs.rs/icu/latest/icu/properties/props/struct.IndicSyllabicCategory.html) for more information.
    282     */
    283    static createIndicSyllabicCategoryWithProvider(provider) {
    284        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
    285 
    286 
    287        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_indic_syllabic_category_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
    288 
    289        try {
    290            if (!diplomatReceive.resultFlag) {
    291                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
    292                throw new globalThis.Error('DataError: ' + cause.value, { cause });
    293            }
    294            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
    295        }
    296 
    297        finally {
    298            diplomatReceive.free();
    299        }
    300    }
    301 
    302    /**
    303     * Create a name-to-enum mapper for the `Line_Break` property, using compiled data.
    304     *
    305     * See the [Rust documentation for `LineBreak`](https://docs.rs/icu/latest/icu/properties/props/struct.LineBreak.html) for more information.
    306     */
    307    static createLineBreak() {
    308 
    309        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_line_break_mv1();
    310 
    311        try {
    312            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
    313        }
    314 
    315        finally {
    316        }
    317    }
    318 
    319    /**
    320     * Create a name-to-enum mapper for the `Line_Break` property, using a particular data source.
    321     *
    322     * See the [Rust documentation for `LineBreak`](https://docs.rs/icu/latest/icu/properties/props/struct.LineBreak.html) for more information.
    323     */
    324    static createLineBreakWithProvider(provider) {
    325        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
    326 
    327 
    328        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_line_break_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
    329 
    330        try {
    331            if (!diplomatReceive.resultFlag) {
    332                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
    333                throw new globalThis.Error('DataError: ' + cause.value, { cause });
    334            }
    335            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
    336        }
    337 
    338        finally {
    339            diplomatReceive.free();
    340        }
    341    }
    342 
    343    /**
    344     * Create a name-to-enum mapper for the `Grapheme_Cluster_Break` property, using compiled data.
    345     *
    346     * See the [Rust documentation for `GraphemeClusterBreak`](https://docs.rs/icu/latest/icu/properties/props/struct.GraphemeClusterBreak.html) for more information.
    347     */
    348    static createGraphemeClusterBreak() {
    349 
    350        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_grapheme_cluster_break_mv1();
    351 
    352        try {
    353            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
    354        }
    355 
    356        finally {
    357        }
    358    }
    359 
    360    /**
    361     * Create a name-to-enum mapper for the `Grapheme_Cluster_Break` property, using a particular data source.
    362     *
    363     * See the [Rust documentation for `GraphemeClusterBreak`](https://docs.rs/icu/latest/icu/properties/props/struct.GraphemeClusterBreak.html) for more information.
    364     */
    365    static createGraphemeClusterBreakWithProvider(provider) {
    366        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
    367 
    368 
    369        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_grapheme_cluster_break_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
    370 
    371        try {
    372            if (!diplomatReceive.resultFlag) {
    373                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
    374                throw new globalThis.Error('DataError: ' + cause.value, { cause });
    375            }
    376            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
    377        }
    378 
    379        finally {
    380            diplomatReceive.free();
    381        }
    382    }
    383 
    384    /**
    385     * Create a name-to-enum mapper for the `Word_Break` property, using compiled data.
    386     *
    387     * See the [Rust documentation for `WordBreak`](https://docs.rs/icu/latest/icu/properties/props/struct.WordBreak.html) for more information.
    388     */
    389    static createWordBreak() {
    390 
    391        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_word_break_mv1();
    392 
    393        try {
    394            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
    395        }
    396 
    397        finally {
    398        }
    399    }
    400 
    401    /**
    402     * Create a name-to-enum mapper for the `Word_Break` property, using a particular data source.
    403     *
    404     * See the [Rust documentation for `WordBreak`](https://docs.rs/icu/latest/icu/properties/props/struct.WordBreak.html) for more information.
    405     */
    406    static createWordBreakWithProvider(provider) {
    407        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
    408 
    409 
    410        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_word_break_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
    411 
    412        try {
    413            if (!diplomatReceive.resultFlag) {
    414                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
    415                throw new globalThis.Error('DataError: ' + cause.value, { cause });
    416            }
    417            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
    418        }
    419 
    420        finally {
    421            diplomatReceive.free();
    422        }
    423    }
    424 
    425    /**
    426     * Create a name-to-enum mapper for the `Sentence_Break` property, using compiled data.
    427     *
    428     * See the [Rust documentation for `SentenceBreak`](https://docs.rs/icu/latest/icu/properties/props/struct.SentenceBreak.html) for more information.
    429     */
    430    static createSentenceBreak() {
    431 
    432        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_sentence_break_mv1();
    433 
    434        try {
    435            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
    436        }
    437 
    438        finally {
    439        }
    440    }
    441 
    442    /**
    443     * Create a name-to-enum mapper for the `Sentence_Break` property, using a particular data source.
    444     *
    445     * See the [Rust documentation for `SentenceBreak`](https://docs.rs/icu/latest/icu/properties/props/struct.SentenceBreak.html) for more information.
    446     */
    447    static createSentenceBreakWithProvider(provider) {
    448        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
    449 
    450 
    451        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_sentence_break_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
    452 
    453        try {
    454            if (!diplomatReceive.resultFlag) {
    455                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
    456                throw new globalThis.Error('DataError: ' + cause.value, { cause });
    457            }
    458            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
    459        }
    460 
    461        finally {
    462            diplomatReceive.free();
    463        }
    464    }
    465 
    466    /**
    467     * Create a name-to-enum mapper for the `Script` property, using compiled data.
    468     *
    469     * See the [Rust documentation for `Script`](https://docs.rs/icu/latest/icu/properties/props/struct.Script.html) for more information.
    470     */
    471    static createScript() {
    472 
    473        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_script_mv1();
    474 
    475        try {
    476            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
    477        }
    478 
    479        finally {
    480        }
    481    }
    482 
    483    /**
    484     * Create a name-to-enum mapper for the `Script` property, using a particular data source.
    485     *
    486     * See the [Rust documentation for `Script`](https://docs.rs/icu/latest/icu/properties/props/struct.Script.html) for more information.
    487     */
    488    static createScriptWithProvider(provider) {
    489        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
    490 
    491 
    492        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_script_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
    493 
    494        try {
    495            if (!diplomatReceive.resultFlag) {
    496                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
    497                throw new globalThis.Error('DataError: ' + cause.value, { cause });
    498            }
    499            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
    500        }
    501 
    502        finally {
    503            diplomatReceive.free();
    504        }
    505    }
    506 
    507    /**
    508     * Create a name-to-enum mapper for the `Vertical_Orientation` property, using compiled data.
    509     *
    510     * See the [Rust documentation for `VerticalOrientation`](https://docs.rs/icu/latest/icu/properties/props/struct.VerticalOrientation.html) for more information.
    511     */
    512    static createVerticalOrientation() {
    513 
    514        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_vertical_orientation_mv1();
    515 
    516        try {
    517            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, result, []);
    518        }
    519 
    520        finally {
    521        }
    522    }
    523 
    524    /**
    525     * Create a name-to-enum mapper for the `Vertical_Orientation` property, using a particular data source.
    526     *
    527     * See the [Rust documentation for `VerticalOrientation`](https://docs.rs/icu/latest/icu/properties/props/struct.VerticalOrientation.html) for more information.
    528     */
    529    static createVerticalOrientationWithProvider(provider) {
    530        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
    531 
    532 
    533        const result = wasm.icu4x_PropertyValueNameToEnumMapper_create_vertical_orientation_with_provider_mv1(diplomatReceive.buffer, provider.ffiValue);
    534 
    535        try {
    536            if (!diplomatReceive.resultFlag) {
    537                const cause = new DataError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
    538                throw new globalThis.Error('DataError: ' + cause.value, { cause });
    539            }
    540            return new PropertyValueNameToEnumMapper(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
    541        }
    542 
    543        finally {
    544            diplomatReceive.free();
    545        }
    546    }
    547 
    548    constructor(symbol, ptr, selfEdge) {
    549        return this.#internalConstructor(...arguments)
    550    }
    551 }