Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 41x 1787x 1787x 1787x 41x 41x 2920x 2920x 41x 41x 41x 41x 5858x 5858x 41x 41x 41x 41x 384x 384x 41x 41x 388x 388x 41x 41x 15x 15x 41x 41x 352x 352x 41x 41x 12x 12x 41x 41x 41x 384x 384x 384x 384x 384x 384x 384x 1784x 1784x 1784x 1784x 1784x 384x 384x 1784x 1784x 1784x 1784x 1784x 1400x 1400x 1784x 384x 384x 384x 384x 445x 443x 445x 2x 2x 384x 384x 384x 394x 384x 384x 384x 30x 11x 11x 11x 11x 384x 384x 384x 27x 384x 384x 384x 384x 384x 384x 9906x 9906x 3x 3x 9906x 384x 384x 384x 384x 384x 384x 384x 384x 384x 384x 384x 384x 384x | // Copyright (c) ZeroC, Inc. // Declared here to avoid circular dependencies when importing OptionalFormat enum. const OptionalFormat_Size = {}; Object.defineProperty(OptionalFormat_Size, "value", { value: 4 }); // // Ice.EnumBase // class EnumBase { constructor(name, value) { this._name = name; this._value = value; } toString() { return this._name; } get name() { return this._name; } get value() { return this._value; } } class EnumHelper { constructor(enumType) { this._enumType = enumType; } write(os, v) { this._enumType._write(os, v); } writeOptional(os, tag, v) { this._enumType._writeOpt(os, tag, v); } read(is) { return this._enumType._read(is); } readOptional(is, tag) { return this._enumType._readOpt(is, tag); } } export function defineEnum(enumerators) { const type = class extends EnumBase {}; const enums = []; let maxValue = 0; let firstEnum = null; for (const idx in enumerators) { const e = enumerators[idx][0]; const value = enumerators[idx][1]; const enumerator = new type(e, value); enums[value] = enumerator; if (!firstEnum) { firstEnum = enumerator; } Object.defineProperty(type, e, { enumerable: true, value: enumerator, }); if (value > maxValue) { maxValue = value; } } Object.defineProperty(type, "minWireSize", { get: () => 1 }); type._write = function (os, v) { if (v) { os.writeEnum(v); } else { os.writeEnum(firstEnum); } }; type._read = function (is) { return is.readEnum(type); }; type._writeOpt = function (os, tag, v) { if (v !== undefined && v !== null) { if (os.writeOptional(tag, OptionalFormat_Size)) { type._write(os, v); } } }; type._readOpt = function (is, tag) { return is.readOptionalEnum(tag, type); }; type._helper = new EnumHelper(type); Object.defineProperty(type, "valueOf", { value: function (v) { let enumerator = enums[v]; if (enumerator === undefined) { enumerator = new type(`${v}`, v); } return enumerator; }, }); Object.defineProperty(type, "maxValue", { value: maxValue, }); Object.defineProperty(type.prototype, "maxValue", { value: maxValue, }); return type; } |