• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// generated by diplomat-tool
2import { SegmenterWordType } from "./SegmenterWordType.mjs"
3import wasm from "./diplomat-wasm.mjs";
4import * as diplomatRuntime from "./diplomat-runtime.mjs";
5
6
7/** See the [Rust documentation for `WordBreakIterator`](https://docs.rs/icu/latest/icu/segmenter/struct.WordBreakIterator.html) for more information.
8*/
9const WordBreakIteratorLatin1_box_destroy_registry = new FinalizationRegistry((ptr) => {
10    wasm.icu4x_WordBreakIteratorLatin1_destroy_mv1(ptr);
11});
12
13export class WordBreakIteratorLatin1 {
14
15    // Internal ptr reference:
16    #ptr = null;
17
18    // Lifetimes are only to keep dependencies alive.
19    // Since JS won't garbage collect until there are no incoming edges.
20    #selfEdge = [];
21    #aEdge = [];
22
23    #internalConstructor(symbol, ptr, selfEdge, aEdge) {
24        if (symbol !== diplomatRuntime.internalConstructor) {
25            console.error("WordBreakIteratorLatin1 is an Opaque type. You cannot call its constructor.");
26            return;
27        }
28
29
30        this.#aEdge = aEdge;
31
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            WordBreakIteratorLatin1_box_destroy_registry.register(this, this.#ptr);
38        }
39
40        return this;
41    }
42    get ffiValue() {
43        return this.#ptr;
44    }
45
46    next() {
47        const result = wasm.icu4x_WordBreakIteratorLatin1_next_mv1(this.ffiValue);
48
49        try {
50            return result;
51        }
52
53        finally {}
54    }
55
56    get wordType() {
57        const result = wasm.icu4x_WordBreakIteratorLatin1_word_type_mv1(this.ffiValue);
58
59        try {
60            return new SegmenterWordType(diplomatRuntime.internalConstructor, result);
61        }
62
63        finally {}
64    }
65
66    get isWordLike() {
67        const result = wasm.icu4x_WordBreakIteratorLatin1_is_word_like_mv1(this.ffiValue);
68
69        try {
70            return result;
71        }
72
73        finally {}
74    }
75
76    constructor(symbol, ptr, selfEdge, aEdge) {
77        return this.#internalConstructor(...arguments)
78    }
79}