BidiClass.mjs (9405B)
1 // generated by diplomat-tool 2 import wasm from "./diplomat-wasm.mjs"; 3 import * as diplomatRuntime from "./diplomat-runtime.mjs"; 4 5 6 /** 7 * See the [Rust documentation for `BidiClass`](https://docs.rs/icu/latest/icu/properties/props/struct.BidiClass.html) for more information. 8 */ 9 10 11 export class BidiClass { 12 #value = undefined; 13 14 static #values = new Map([ 15 ["LeftToRight", 0], 16 ["RightToLeft", 1], 17 ["EuropeanNumber", 2], 18 ["EuropeanSeparator", 3], 19 ["EuropeanTerminator", 4], 20 ["ArabicNumber", 5], 21 ["CommonSeparator", 6], 22 ["ParagraphSeparator", 7], 23 ["SegmentSeparator", 8], 24 ["WhiteSpace", 9], 25 ["OtherNeutral", 10], 26 ["LeftToRightEmbedding", 11], 27 ["LeftToRightOverride", 12], 28 ["ArabicLetter", 13], 29 ["RightToLeftEmbedding", 14], 30 ["RightToLeftOverride", 15], 31 ["PopDirectionalFormat", 16], 32 ["NonspacingMark", 17], 33 ["BoundaryNeutral", 18], 34 ["FirstStrongIsolate", 19], 35 ["LeftToRightIsolate", 20], 36 ["RightToLeftIsolate", 21], 37 ["PopDirectionalIsolate", 22] 38 ]); 39 40 static getAllEntries() { 41 return BidiClass.#values.entries(); 42 } 43 44 #internalConstructor(value) { 45 if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { 46 // We pass in two internalConstructor arguments to create *new* 47 // instances of this type, otherwise the enums are treated as singletons. 48 if (arguments[1] === diplomatRuntime.internalConstructor ) { 49 this.#value = arguments[2]; 50 return this; 51 } 52 return BidiClass.#objectValues[arguments[1]]; 53 } 54 55 if (value instanceof BidiClass) { 56 return value; 57 } 58 59 let intVal = BidiClass.#values.get(value); 60 61 // Nullish check, checks for null or undefined 62 if (intVal != null) { 63 return BidiClass.#objectValues[intVal]; 64 } 65 66 throw TypeError(value + " is not a BidiClass and does not correspond to any of its enumerator values."); 67 } 68 69 static fromValue(value) { 70 return new BidiClass(value); 71 } 72 73 get value(){ 74 return [...BidiClass.#values.keys()][this.#value]; 75 } 76 77 get ffiValue(){ 78 return this.#value; 79 } 80 static #objectValues = [ 81 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0), 82 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1), 83 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2), 84 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3), 85 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4), 86 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5), 87 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 6), 88 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 7), 89 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 8), 90 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 9), 91 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 10), 92 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 11), 93 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 12), 94 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 13), 95 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 14), 96 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 15), 97 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 16), 98 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 17), 99 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 18), 100 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 19), 101 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 20), 102 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 21), 103 new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 22), 104 ]; 105 106 static LeftToRight = BidiClass.#objectValues[0]; 107 static RightToLeft = BidiClass.#objectValues[1]; 108 static EuropeanNumber = BidiClass.#objectValues[2]; 109 static EuropeanSeparator = BidiClass.#objectValues[3]; 110 static EuropeanTerminator = BidiClass.#objectValues[4]; 111 static ArabicNumber = BidiClass.#objectValues[5]; 112 static CommonSeparator = BidiClass.#objectValues[6]; 113 static ParagraphSeparator = BidiClass.#objectValues[7]; 114 static SegmentSeparator = BidiClass.#objectValues[8]; 115 static WhiteSpace = BidiClass.#objectValues[9]; 116 static OtherNeutral = BidiClass.#objectValues[10]; 117 static LeftToRightEmbedding = BidiClass.#objectValues[11]; 118 static LeftToRightOverride = BidiClass.#objectValues[12]; 119 static ArabicLetter = BidiClass.#objectValues[13]; 120 static RightToLeftEmbedding = BidiClass.#objectValues[14]; 121 static RightToLeftOverride = BidiClass.#objectValues[15]; 122 static PopDirectionalFormat = BidiClass.#objectValues[16]; 123 static NonspacingMark = BidiClass.#objectValues[17]; 124 static BoundaryNeutral = BidiClass.#objectValues[18]; 125 static FirstStrongIsolate = BidiClass.#objectValues[19]; 126 static LeftToRightIsolate = BidiClass.#objectValues[20]; 127 static RightToLeftIsolate = BidiClass.#objectValues[21]; 128 static PopDirectionalIsolate = BidiClass.#objectValues[22]; 129 130 131 /** 132 * See the [Rust documentation for `for_char`](https://docs.rs/icu/latest/icu/properties/props/trait.EnumeratedProperty.html#tymethod.for_char) for more information. 133 */ 134 static forChar(ch) { 135 136 const result = wasm.icu4x_BidiClass_for_char_mv1(ch); 137 138 try { 139 return new BidiClass(diplomatRuntime.internalConstructor, result); 140 } 141 142 finally { 143 } 144 } 145 146 /** 147 * Get the "long" name of this property value (returns empty if property value is unknown) 148 * 149 * See the [Rust documentation for `get`](https://docs.rs/icu/latest/icu/properties/struct.PropertyNamesLongBorrowed.html#method.get) for more information. 150 */ 151 longName() { 152 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true); 153 154 155 const result = wasm.icu4x_BidiClass_long_name_mv1(diplomatReceive.buffer, this.ffiValue); 156 157 try { 158 if (!diplomatReceive.resultFlag) { 159 return null; 160 } 161 return new diplomatRuntime.DiplomatSliceStr(wasm, diplomatReceive.buffer, "string8", []).getValue(); 162 } 163 164 finally { 165 diplomatReceive.free(); 166 } 167 } 168 169 /** 170 * Get the "short" name of this property value (returns empty if property value is unknown) 171 * 172 * See the [Rust documentation for `get`](https://docs.rs/icu/latest/icu/properties/struct.PropertyNamesShortBorrowed.html#method.get) for more information. 173 */ 174 shortName() { 175 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true); 176 177 178 const result = wasm.icu4x_BidiClass_short_name_mv1(diplomatReceive.buffer, this.ffiValue); 179 180 try { 181 if (!diplomatReceive.resultFlag) { 182 return null; 183 } 184 return new diplomatRuntime.DiplomatSliceStr(wasm, diplomatReceive.buffer, "string8", []).getValue(); 185 } 186 187 finally { 188 diplomatReceive.free(); 189 } 190 } 191 192 /** 193 * Convert to an integer value usable with ICU4C and CodePointMapData 194 * 195 * See the [Rust documentation for `to_icu4c_value`](https://docs.rs/icu/latest/icu/properties/props/struct.BidiClass.html#method.to_icu4c_value) for more information. 196 */ 197 toIntegerValue() { 198 199 const result = wasm.icu4x_BidiClass_to_integer_value_mv1(this.ffiValue); 200 201 try { 202 return result; 203 } 204 205 finally { 206 } 207 } 208 209 /** 210 * Convert from an integer value from ICU4C or CodePointMapData 211 * 212 * See the [Rust documentation for `from_icu4c_value`](https://docs.rs/icu/latest/icu/properties/props/struct.BidiClass.html#method.from_icu4c_value) for more information. 213 */ 214 static fromIntegerValue(other) { 215 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 216 217 218 const result = wasm.icu4x_BidiClass_from_integer_value_mv1(diplomatReceive.buffer, other); 219 220 try { 221 if (!diplomatReceive.resultFlag) { 222 return null; 223 } 224 return new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 225 } 226 227 finally { 228 diplomatReceive.free(); 229 } 230 } 231 232 constructor(value) { 233 return this.#internalConstructor(...arguments) 234 } 235 }