VerticalOrientation.mjs (5989B)
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 `VerticalOrientation`](https://docs.rs/icu/latest/icu/properties/props/struct.VerticalOrientation.html) for more information. 8 */ 9 10 11 export class VerticalOrientation { 12 #value = undefined; 13 14 static #values = new Map([ 15 ["Rotated", 0], 16 ["TransformedRotated", 1], 17 ["TransformedUpright", 2], 18 ["Upright", 3] 19 ]); 20 21 static getAllEntries() { 22 return VerticalOrientation.#values.entries(); 23 } 24 25 #internalConstructor(value) { 26 if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) { 27 // We pass in two internalConstructor arguments to create *new* 28 // instances of this type, otherwise the enums are treated as singletons. 29 if (arguments[1] === diplomatRuntime.internalConstructor ) { 30 this.#value = arguments[2]; 31 return this; 32 } 33 return VerticalOrientation.#objectValues[arguments[1]]; 34 } 35 36 if (value instanceof VerticalOrientation) { 37 return value; 38 } 39 40 let intVal = VerticalOrientation.#values.get(value); 41 42 // Nullish check, checks for null or undefined 43 if (intVal != null) { 44 return VerticalOrientation.#objectValues[intVal]; 45 } 46 47 throw TypeError(value + " is not a VerticalOrientation and does not correspond to any of its enumerator values."); 48 } 49 50 static fromValue(value) { 51 return new VerticalOrientation(value); 52 } 53 54 get value(){ 55 return [...VerticalOrientation.#values.keys()][this.#value]; 56 } 57 58 get ffiValue(){ 59 return this.#value; 60 } 61 static #objectValues = [ 62 new VerticalOrientation(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0), 63 new VerticalOrientation(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1), 64 new VerticalOrientation(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2), 65 new VerticalOrientation(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3), 66 ]; 67 68 static Rotated = VerticalOrientation.#objectValues[0]; 69 static TransformedRotated = VerticalOrientation.#objectValues[1]; 70 static TransformedUpright = VerticalOrientation.#objectValues[2]; 71 static Upright = VerticalOrientation.#objectValues[3]; 72 73 74 /** 75 * See the [Rust documentation for `for_char`](https://docs.rs/icu/latest/icu/properties/props/trait.EnumeratedProperty.html#tymethod.for_char) for more information. 76 */ 77 static forChar(ch) { 78 79 const result = wasm.icu4x_VerticalOrientation_for_char_mv1(ch); 80 81 try { 82 return new VerticalOrientation(diplomatRuntime.internalConstructor, result); 83 } 84 85 finally { 86 } 87 } 88 89 /** 90 * Get the "long" name of this property value (returns empty if property value is unknown) 91 * 92 * See the [Rust documentation for `get`](https://docs.rs/icu/latest/icu/properties/struct.PropertyNamesLongBorrowed.html#method.get) for more information. 93 */ 94 longName() { 95 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true); 96 97 98 const result = wasm.icu4x_VerticalOrientation_long_name_mv1(diplomatReceive.buffer, this.ffiValue); 99 100 try { 101 if (!diplomatReceive.resultFlag) { 102 return null; 103 } 104 return new diplomatRuntime.DiplomatSliceStr(wasm, diplomatReceive.buffer, "string8", []).getValue(); 105 } 106 107 finally { 108 diplomatReceive.free(); 109 } 110 } 111 112 /** 113 * Get the "short" name of this property value (returns empty if property value is unknown) 114 * 115 * See the [Rust documentation for `get`](https://docs.rs/icu/latest/icu/properties/struct.PropertyNamesShortBorrowed.html#method.get) for more information. 116 */ 117 shortName() { 118 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true); 119 120 121 const result = wasm.icu4x_VerticalOrientation_short_name_mv1(diplomatReceive.buffer, this.ffiValue); 122 123 try { 124 if (!diplomatReceive.resultFlag) { 125 return null; 126 } 127 return new diplomatRuntime.DiplomatSliceStr(wasm, diplomatReceive.buffer, "string8", []).getValue(); 128 } 129 130 finally { 131 diplomatReceive.free(); 132 } 133 } 134 135 /** 136 * Convert to an integer value usable with ICU4C and CodePointMapData 137 * 138 * See the [Rust documentation for `to_icu4c_value`](https://docs.rs/icu/latest/icu/properties/props/struct.VerticalOrientation.html#method.to_icu4c_value) for more information. 139 */ 140 toIntegerValue() { 141 142 const result = wasm.icu4x_VerticalOrientation_to_integer_value_mv1(this.ffiValue); 143 144 try { 145 return result; 146 } 147 148 finally { 149 } 150 } 151 152 /** 153 * Convert from an integer value from ICU4C or CodePointMapData 154 * 155 * See the [Rust documentation for `from_icu4c_value`](https://docs.rs/icu/latest/icu/properties/props/struct.VerticalOrientation.html#method.from_icu4c_value) for more information. 156 */ 157 static fromIntegerValue(other) { 158 const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true); 159 160 161 const result = wasm.icu4x_VerticalOrientation_from_integer_value_mv1(diplomatReceive.buffer, other); 162 163 try { 164 if (!diplomatReceive.resultFlag) { 165 return null; 166 } 167 return new VerticalOrientation(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer)); 168 } 169 170 finally { 171 diplomatReceive.free(); 172 } 173 } 174 175 constructor(value) { 176 return this.#internalConstructor(...arguments) 177 } 178 }