• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// generated by diplomat-tool
2import { CodePointSetData } from "./CodePointSetData.mjs"
3import wasm from "./diplomat-wasm.mjs";
4import * as diplomatRuntime from "./diplomat-runtime.mjs";
5
6
7/** See the [Rust documentation for `CodePointInversionListBuilder`](https://docs.rs/icu/latest/icu/collections/codepointinvlist/struct.CodePointInversionListBuilder.html) for more information.
8*/
9const CodePointSetBuilder_box_destroy_registry = new FinalizationRegistry((ptr) => {
10    wasm.icu4x_CodePointSetBuilder_destroy_mv1(ptr);
11});
12
13export class CodePointSetBuilder {
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
22    #internalConstructor(symbol, ptr, selfEdge) {
23        if (symbol !== diplomatRuntime.internalConstructor) {
24            console.error("CodePointSetBuilder is an Opaque type. You cannot call its constructor.");
25            return;
26        }
27
28        this.#ptr = ptr;
29        this.#selfEdge = selfEdge;
30
31        // Are we being borrowed? If not, we can register.
32        if (this.#selfEdge.length === 0) {
33            CodePointSetBuilder_box_destroy_registry.register(this, this.#ptr);
34        }
35
36        return this;
37    }
38    get ffiValue() {
39        return this.#ptr;
40    }
41
42    #defaultConstructor() {
43        const result = wasm.icu4x_CodePointSetBuilder_create_mv1();
44
45        try {
46            return new CodePointSetBuilder(diplomatRuntime.internalConstructor, result, []);
47        }
48
49        finally {}
50    }
51
52    build() {
53        const result = wasm.icu4x_CodePointSetBuilder_build_mv1(this.ffiValue);
54
55        try {
56            return new CodePointSetData(diplomatRuntime.internalConstructor, result, []);
57        }
58
59        finally {}
60    }
61
62    complement() {wasm.icu4x_CodePointSetBuilder_complement_mv1(this.ffiValue);
63
64        try {}
65
66        finally {}
67    }
68
69    get isEmpty() {
70        const result = wasm.icu4x_CodePointSetBuilder_is_empty_mv1(this.ffiValue);
71
72        try {
73            return result;
74        }
75
76        finally {}
77    }
78
79    addChar(ch) {wasm.icu4x_CodePointSetBuilder_add_char_mv1(this.ffiValue, ch);
80
81        try {}
82
83        finally {}
84    }
85
86    addInclusiveRange(start, end) {wasm.icu4x_CodePointSetBuilder_add_inclusive_range_mv1(this.ffiValue, start, end);
87
88        try {}
89
90        finally {}
91    }
92
93    addSet(data) {wasm.icu4x_CodePointSetBuilder_add_set_mv1(this.ffiValue, data.ffiValue);
94
95        try {}
96
97        finally {}
98    }
99
100    removeChar(ch) {wasm.icu4x_CodePointSetBuilder_remove_char_mv1(this.ffiValue, ch);
101
102        try {}
103
104        finally {}
105    }
106
107    removeInclusiveRange(start, end) {wasm.icu4x_CodePointSetBuilder_remove_inclusive_range_mv1(this.ffiValue, start, end);
108
109        try {}
110
111        finally {}
112    }
113
114    removeSet(data) {wasm.icu4x_CodePointSetBuilder_remove_set_mv1(this.ffiValue, data.ffiValue);
115
116        try {}
117
118        finally {}
119    }
120
121    retainChar(ch) {wasm.icu4x_CodePointSetBuilder_retain_char_mv1(this.ffiValue, ch);
122
123        try {}
124
125        finally {}
126    }
127
128    retainInclusiveRange(start, end) {wasm.icu4x_CodePointSetBuilder_retain_inclusive_range_mv1(this.ffiValue, start, end);
129
130        try {}
131
132        finally {}
133    }
134
135    retainSet(data) {wasm.icu4x_CodePointSetBuilder_retain_set_mv1(this.ffiValue, data.ffiValue);
136
137        try {}
138
139        finally {}
140    }
141
142    complementChar(ch) {wasm.icu4x_CodePointSetBuilder_complement_char_mv1(this.ffiValue, ch);
143
144        try {}
145
146        finally {}
147    }
148
149    complementInclusiveRange(start, end) {wasm.icu4x_CodePointSetBuilder_complement_inclusive_range_mv1(this.ffiValue, start, end);
150
151        try {}
152
153        finally {}
154    }
155
156    complementSet(data) {wasm.icu4x_CodePointSetBuilder_complement_set_mv1(this.ffiValue, data.ffiValue);
157
158        try {}
159
160        finally {}
161    }
162
163    constructor() {
164        if (arguments[0] === diplomatRuntime.exposeConstructor) {
165            return this.#internalConstructor(...Array.prototype.slice.call(arguments, 1));
166        } else if (arguments[0] === diplomatRuntime.internalConstructor) {
167            return this.#internalConstructor(...arguments);
168        } else {
169            return this.#defaultConstructor(...arguments);
170        }
171    }
172}