@omnibuf/node 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/conformance.d.ts +4 -0
- package/dist/conformance.d.ts.map +1 -1
- package/dist/conformance.js +492 -32
- package/dist/conformance.js.map +1 -1
- package/dist/gen/conformance_omnibuf.pb.d.ts +171 -0
- package/dist/gen/conformance_omnibuf.pb.d.ts.map +1 -0
- package/dist/gen/conformance_omnibuf.pb.js +1915 -0
- package/dist/gen/conformance_omnibuf.pb.js.map +1 -0
- package/dist/gen/peer_omnibuf.pb.d.ts.map +1 -1
- package/dist/gen/peer_omnibuf.pb.js +41 -27
- package/dist/gen/peer_omnibuf.pb.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,1915 @@
|
|
|
1
|
+
// Code generated by protoc-gen-omnibuf-es. DO NOT EDIT.
|
|
2
|
+
// source: conformance.proto
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
|
+
import { Encoder, MaxNestingDepth, appendStringArrBody, appendUint32ArrBody, countSubMsgArrElems, decodeSchemaMeta, decodeUTF8, decodeVarintAuto, decodeVarintBigInt, decodeZigZag, decodeZigZagAuto, defineMessage, encodeField0SchemaMeta, float32FromBits, parseArrayHeader, readBool, readBytes, readFixed32, readFixed64Auto, readFloat32, readFloat64, readFloat64At, readInt, readIntAuto, readLenSlice, readString, readStringArr, readSubMsgArrDecoded, readSubMsgMerged, readTypedMap, readUint, readUint32Arr, readUintAuto, roundFloat32Shortest, spliceFields, validateMapTypes, validateValue, writeField0SchemaMeta, } from '@omnibuf/core';
|
|
5
|
+
export const AllTypesSubMsgSchema = defineMessage('omnibuf.conformance.AllTypesSubMsg', {
|
|
6
|
+
id: { fieldNum: 1, type: 'uint32' },
|
|
7
|
+
label: { fieldNum: 2, type: 'string' },
|
|
8
|
+
flag: { fieldNum: 3, type: 'bool' },
|
|
9
|
+
score: { fieldNum: 4, type: 'sint64' },
|
|
10
|
+
});
|
|
11
|
+
class AllTypesSubMsgMsg {
|
|
12
|
+
id = 0;
|
|
13
|
+
label = '';
|
|
14
|
+
flag = false;
|
|
15
|
+
score = 0;
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(AllTypesSubMsgMsg.prototype, '$typeName', {
|
|
18
|
+
value: 'omnibuf.conformance.AllTypesSubMsg',
|
|
19
|
+
enumerable: false,
|
|
20
|
+
writable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
});
|
|
23
|
+
export function createAllTypesSubMsg(init) {
|
|
24
|
+
if (init === undefined)
|
|
25
|
+
return new AllTypesSubMsgMsg();
|
|
26
|
+
return AllTypesSubMsgSchema.create(init);
|
|
27
|
+
}
|
|
28
|
+
export function encodeAllTypesSubMsg(enc, msg, options) {
|
|
29
|
+
enc.writeUint(1, Number(msg.id ?? 0) >>> 0);
|
|
30
|
+
enc.writeString(2, msg.label ?? '');
|
|
31
|
+
enc.writeBool(3, Boolean(msg.flag));
|
|
32
|
+
enc.writeInt(4, msg.score ?? 0);
|
|
33
|
+
if (options?.writeUnknownFields && Array.isArray(msg.$unknown)) {
|
|
34
|
+
for (const uf of msg.$unknown) {
|
|
35
|
+
enc.writeTag(uf.no, uf.wireType);
|
|
36
|
+
enc.writeRaw(uf.data);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export function marshalAllTypesSubMsgOmniBuf(msg, options) {
|
|
41
|
+
const enc = new Encoder(256);
|
|
42
|
+
if (options?.selfDescribing) {
|
|
43
|
+
writeField0SchemaMeta(enc, AllTypesSubMsgSchema.getSchemaMeta(0, msg), Boolean(options.deterministic));
|
|
44
|
+
}
|
|
45
|
+
encodeAllTypesSubMsg(enc, msg, options);
|
|
46
|
+
return enc.finish();
|
|
47
|
+
}
|
|
48
|
+
export function decodeAllTypesSubMsg(buf, target, depth = 0, options, startPos = 0, endPos = buf.length) {
|
|
49
|
+
const maxDepth = options?.recursionLimit ?? MaxNestingDepth;
|
|
50
|
+
const readUnknown = options?.readUnknownFields ?? true;
|
|
51
|
+
if (depth > maxDepth) {
|
|
52
|
+
throw new Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
|
|
53
|
+
}
|
|
54
|
+
const out = target ?? new AllTypesSubMsgMsg();
|
|
55
|
+
if (target !== undefined && !options?.merge) {
|
|
56
|
+
Object.assign(out, new AllTypesSubMsgMsg());
|
|
57
|
+
delete out.$unknown;
|
|
58
|
+
}
|
|
59
|
+
const n = endPos;
|
|
60
|
+
let pos = startPos;
|
|
61
|
+
let seenMask = 0;
|
|
62
|
+
let unknownFields = Array.isArray(out.$unknown)
|
|
63
|
+
? out.$unknown
|
|
64
|
+
: null;
|
|
65
|
+
while (pos < n) {
|
|
66
|
+
let tag = 0;
|
|
67
|
+
const b0 = buf[pos];
|
|
68
|
+
if ((b0 & 1) !== 0) {
|
|
69
|
+
tag = b0 >>> 1;
|
|
70
|
+
pos += 1;
|
|
71
|
+
}
|
|
72
|
+
else if ((b0 & 2) !== 0) {
|
|
73
|
+
if (pos + 2 > n)
|
|
74
|
+
throw new Error('omnibuf: truncated tag');
|
|
75
|
+
tag = ((b0 | (buf[pos + 1] << 8)) >>> 2) >>> 0;
|
|
76
|
+
pos += 2;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const [t64, tn] = decodeVarintBigInt(buf, pos, n);
|
|
80
|
+
if (tn === 0 || t64 >> 4n > 536870911n)
|
|
81
|
+
throw new Error('omnibuf: invalid tag');
|
|
82
|
+
tag = Number(t64);
|
|
83
|
+
pos += tn;
|
|
84
|
+
}
|
|
85
|
+
const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : Math.floor(tag / 16);
|
|
86
|
+
const wt = tag & 0x0f;
|
|
87
|
+
if (fieldNum === 0) {
|
|
88
|
+
if (wt !== 12)
|
|
89
|
+
throw new Error('omnibuf: invalid Field #0 wire type');
|
|
90
|
+
const [meta, nextPos] = readLenSlice(buf, pos, 0, n);
|
|
91
|
+
decodeSchemaMeta(meta, depth + 1, maxDepth);
|
|
92
|
+
pos = nextPos;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const bit = fieldNum <= 30 ? 1 << fieldNum : 0;
|
|
96
|
+
const alreadySeen = (seenMask & bit) !== 0 || Boolean(options?.merge);
|
|
97
|
+
switch (fieldNum) {
|
|
98
|
+
case 1: {
|
|
99
|
+
if (!(wt === 0)) {
|
|
100
|
+
const valStart = pos;
|
|
101
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
102
|
+
if (readUnknown) {
|
|
103
|
+
if (!unknownFields)
|
|
104
|
+
unknownFields = [];
|
|
105
|
+
unknownFields.push({
|
|
106
|
+
no: fieldNum,
|
|
107
|
+
wireType: wt,
|
|
108
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
seenMask |= bit;
|
|
114
|
+
if (pos >= n)
|
|
115
|
+
throw new Error('omnibuf: truncated uint32');
|
|
116
|
+
const vb = buf[pos];
|
|
117
|
+
let u32Val = 0;
|
|
118
|
+
if ((vb & 1) !== 0) {
|
|
119
|
+
u32Val = vb >>> 1;
|
|
120
|
+
pos += 1;
|
|
121
|
+
}
|
|
122
|
+
else if ((vb & 2) !== 0) {
|
|
123
|
+
if (pos + 2 > n)
|
|
124
|
+
throw new Error('omnibuf: truncated uint32');
|
|
125
|
+
u32Val = (vb | (buf[pos + 1] << 8)) >>> 2;
|
|
126
|
+
pos += 2;
|
|
127
|
+
}
|
|
128
|
+
else if ((vb & 4) !== 0) {
|
|
129
|
+
if (pos + 4 > n)
|
|
130
|
+
throw new Error('omnibuf: truncated uint32');
|
|
131
|
+
u32Val =
|
|
132
|
+
((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
|
|
133
|
+
0;
|
|
134
|
+
pos += 4;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
if (vb !== 0 || pos + 9 > n)
|
|
138
|
+
throw new Error('omnibuf: truncated uint32');
|
|
139
|
+
u32Val =
|
|
140
|
+
(buf[pos + 1] |
|
|
141
|
+
(buf[pos + 2] << 8) |
|
|
142
|
+
(buf[pos + 3] << 16) |
|
|
143
|
+
(buf[pos + 4] << 24)) >>>
|
|
144
|
+
0;
|
|
145
|
+
pos += 9;
|
|
146
|
+
}
|
|
147
|
+
out.id = u32Val;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
case 2: {
|
|
151
|
+
if (!(wt === 10)) {
|
|
152
|
+
const valStart = pos;
|
|
153
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
154
|
+
if (readUnknown) {
|
|
155
|
+
if (!unknownFields)
|
|
156
|
+
unknownFields = [];
|
|
157
|
+
unknownFields.push({
|
|
158
|
+
no: fieldNum,
|
|
159
|
+
wireType: wt,
|
|
160
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
seenMask |= bit;
|
|
166
|
+
if (pos >= n)
|
|
167
|
+
throw new Error('omnibuf: truncated string');
|
|
168
|
+
const sb = buf[pos];
|
|
169
|
+
if ((sb & 1) !== 0) {
|
|
170
|
+
const sLen = sb >>> 1;
|
|
171
|
+
pos += 1;
|
|
172
|
+
if (pos + sLen > n)
|
|
173
|
+
throw new Error('omnibuf: truncated string');
|
|
174
|
+
out.label = decodeUTF8(buf, pos, pos + sLen);
|
|
175
|
+
pos += sLen;
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
const [s, nextPos] = readLenSlice(buf, pos, 0, n);
|
|
179
|
+
out.label = decodeUTF8(s);
|
|
180
|
+
pos = nextPos;
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
case 3: {
|
|
185
|
+
if (!(wt === 2 || wt === 3)) {
|
|
186
|
+
const valStart = pos;
|
|
187
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
188
|
+
if (readUnknown) {
|
|
189
|
+
if (!unknownFields)
|
|
190
|
+
unknownFields = [];
|
|
191
|
+
unknownFields.push({
|
|
192
|
+
no: fieldNum,
|
|
193
|
+
wireType: wt,
|
|
194
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
seenMask |= bit;
|
|
200
|
+
out.flag = wt === 3;
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
case 4: {
|
|
204
|
+
if (!(wt === 1)) {
|
|
205
|
+
const valStart = pos;
|
|
206
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
207
|
+
if (readUnknown) {
|
|
208
|
+
if (!unknownFields)
|
|
209
|
+
unknownFields = [];
|
|
210
|
+
unknownFields.push({
|
|
211
|
+
no: fieldNum,
|
|
212
|
+
wireType: wt,
|
|
213
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
seenMask |= bit;
|
|
219
|
+
const [v, vn] = decodeVarintBigInt(buf, pos, n);
|
|
220
|
+
if (vn === 0)
|
|
221
|
+
throw new Error('omnibuf: truncated int64');
|
|
222
|
+
out.score = decodeZigZagAuto(v);
|
|
223
|
+
pos += vn;
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
default: {
|
|
227
|
+
const valStart = pos;
|
|
228
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
229
|
+
if (readUnknown) {
|
|
230
|
+
if (!unknownFields)
|
|
231
|
+
unknownFields = [];
|
|
232
|
+
unknownFields.push({
|
|
233
|
+
no: fieldNum,
|
|
234
|
+
wireType: wt,
|
|
235
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (unknownFields && unknownFields.length > 0 && !('$unknown' in out)) {
|
|
243
|
+
Object.defineProperty(out, '$unknown', {
|
|
244
|
+
value: unknownFields,
|
|
245
|
+
enumerable: false,
|
|
246
|
+
writable: true,
|
|
247
|
+
configurable: true,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
return out;
|
|
251
|
+
}
|
|
252
|
+
export function unmarshalAllTypesSubMsgOmniBuf(buf, options) {
|
|
253
|
+
return decodeAllTypesSubMsg(buf, undefined, 0, options);
|
|
254
|
+
}
|
|
255
|
+
AllTypesSubMsgSchema.setGeneratedCodec({
|
|
256
|
+
create: () => new AllTypesSubMsgMsg(),
|
|
257
|
+
encode: encodeAllTypesSubMsg,
|
|
258
|
+
decode: decodeAllTypesSubMsg,
|
|
259
|
+
});
|
|
260
|
+
export class OpaqueAllTypesSubMsg {
|
|
261
|
+
_raw;
|
|
262
|
+
_dirtyMask = 0;
|
|
263
|
+
_id;
|
|
264
|
+
_label;
|
|
265
|
+
_flag;
|
|
266
|
+
_score;
|
|
267
|
+
constructor(raw) {
|
|
268
|
+
this._raw = raw;
|
|
269
|
+
}
|
|
270
|
+
raw() {
|
|
271
|
+
return this._raw;
|
|
272
|
+
}
|
|
273
|
+
getId() {
|
|
274
|
+
if ((this._dirtyMask & (1 << 1)) !== 0) {
|
|
275
|
+
return this._id;
|
|
276
|
+
}
|
|
277
|
+
return readUint(this._raw, 1)[0];
|
|
278
|
+
}
|
|
279
|
+
id() {
|
|
280
|
+
return this.getId();
|
|
281
|
+
}
|
|
282
|
+
setId(val) {
|
|
283
|
+
this._id = val;
|
|
284
|
+
this._dirtyMask |= 1 << 1;
|
|
285
|
+
}
|
|
286
|
+
getLabel() {
|
|
287
|
+
if ((this._dirtyMask & (1 << 2)) !== 0) {
|
|
288
|
+
return this._label;
|
|
289
|
+
}
|
|
290
|
+
return readString(this._raw, 2)[0];
|
|
291
|
+
}
|
|
292
|
+
label() {
|
|
293
|
+
return this.getLabel();
|
|
294
|
+
}
|
|
295
|
+
setLabel(val) {
|
|
296
|
+
this._label = val;
|
|
297
|
+
this._dirtyMask |= 1 << 2;
|
|
298
|
+
}
|
|
299
|
+
getFlag() {
|
|
300
|
+
if ((this._dirtyMask & (1 << 3)) !== 0) {
|
|
301
|
+
return this._flag;
|
|
302
|
+
}
|
|
303
|
+
return readBool(this._raw, 3)[0];
|
|
304
|
+
}
|
|
305
|
+
flag() {
|
|
306
|
+
return this.getFlag();
|
|
307
|
+
}
|
|
308
|
+
setFlag(val) {
|
|
309
|
+
this._flag = val;
|
|
310
|
+
this._dirtyMask |= 1 << 3;
|
|
311
|
+
}
|
|
312
|
+
getScore() {
|
|
313
|
+
if ((this._dirtyMask & (1 << 4)) !== 0) {
|
|
314
|
+
return this._score;
|
|
315
|
+
}
|
|
316
|
+
return readIntAuto(this._raw, 4)[0];
|
|
317
|
+
}
|
|
318
|
+
score() {
|
|
319
|
+
return this.getScore();
|
|
320
|
+
}
|
|
321
|
+
setScore(val) {
|
|
322
|
+
this._score = val;
|
|
323
|
+
this._dirtyMask |= 1 << 4;
|
|
324
|
+
}
|
|
325
|
+
marshal(options) {
|
|
326
|
+
if (this._dirtyMask !== 0) {
|
|
327
|
+
this._raw = spliceFields(this._raw, this._dirtyMask, 4, (enc, fnum) => {
|
|
328
|
+
switch (fnum) {
|
|
329
|
+
case 1: {
|
|
330
|
+
const msg = { id: this._id };
|
|
331
|
+
enc.writeUint(1, Number(msg.id ?? 0) >>> 0);
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
case 2: {
|
|
335
|
+
const msg = { label: this._label };
|
|
336
|
+
enc.writeString(2, msg.label ?? '');
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
case 3: {
|
|
340
|
+
const msg = { flag: this._flag };
|
|
341
|
+
enc.writeBool(3, Boolean(msg.flag));
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
case 4: {
|
|
345
|
+
const msg = { score: this._score };
|
|
346
|
+
enc.writeInt(4, msg.score ?? 0);
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
this._dirtyMask = 0;
|
|
352
|
+
}
|
|
353
|
+
if (options?.selfDescribing && (this._raw.length === 0 || this._raw[0] !== 0x19)) {
|
|
354
|
+
const f0 = encodeField0SchemaMeta(AllTypesSubMsgSchema.getSchemaMeta(0), Boolean(options.deterministic));
|
|
355
|
+
const out = new Uint8Array(f0.length + this._raw.length);
|
|
356
|
+
out.set(f0, 0);
|
|
357
|
+
out.set(this._raw, f0.length);
|
|
358
|
+
return out;
|
|
359
|
+
}
|
|
360
|
+
return this._raw;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
export const TestAllTypesSchema = defineMessage('omnibuf.conformance.TestAllTypes', {
|
|
364
|
+
f1Uint32: { fieldNum: 1, name: 'f1_uint32', type: 'uint32' },
|
|
365
|
+
f2Uint64: { fieldNum: 2, name: 'f2_uint64', type: 'uint64' },
|
|
366
|
+
f3Sint32: { fieldNum: 3, name: 'f3_sint32', type: 'sint32' },
|
|
367
|
+
f4Sint64: { fieldNum: 4, name: 'f4_sint64', type: 'sint64' },
|
|
368
|
+
f5Bool: { fieldNum: 5, name: 'f5_bool', type: 'bool' },
|
|
369
|
+
f6String: { fieldNum: 6, name: 'f6_string', type: 'string' },
|
|
370
|
+
f7Bytes: { fieldNum: 7, name: 'f7_bytes', type: 'bytes' },
|
|
371
|
+
f8SubMsg: {
|
|
372
|
+
fieldNum: 8,
|
|
373
|
+
name: 'f8_sub_msg',
|
|
374
|
+
type: 'submsg',
|
|
375
|
+
subSchema: () => AllTypesSubMsgSchema,
|
|
376
|
+
},
|
|
377
|
+
f9StringArr: { fieldNum: 9, name: 'f9_string_arr', type: 'string[]' },
|
|
378
|
+
f10Uint32Arr: { fieldNum: 10, name: 'f10_uint32_arr', type: 'uint32[]' },
|
|
379
|
+
f11SubMsgArr: {
|
|
380
|
+
fieldNum: 11,
|
|
381
|
+
name: 'f11_sub_msg_arr',
|
|
382
|
+
type: 'submsg[]',
|
|
383
|
+
subSchema: () => AllTypesSubMsgSchema,
|
|
384
|
+
},
|
|
385
|
+
f12MapStrUint: {
|
|
386
|
+
fieldNum: 12,
|
|
387
|
+
name: 'f12_map_str_uint',
|
|
388
|
+
type: 'map',
|
|
389
|
+
mapKey: 'string',
|
|
390
|
+
mapVal: 'uint64',
|
|
391
|
+
},
|
|
392
|
+
f13Float32: { fieldNum: 13, name: 'f13_float32', type: 'float32' },
|
|
393
|
+
f14Float64: { fieldNum: 14, name: 'f14_float64', type: 'float64' },
|
|
394
|
+
f15Fixed32: { fieldNum: 15, name: 'f15_fixed32', type: 'fixed32' },
|
|
395
|
+
f16Fixed64: { fieldNum: 16, name: 'f16_fixed64', type: 'fixed64' },
|
|
396
|
+
f20OverflowStr: { fieldNum: 20, name: 'f20_overflow_str', type: 'string' },
|
|
397
|
+
});
|
|
398
|
+
class TestAllTypesMsg {
|
|
399
|
+
f1Uint32 = 0;
|
|
400
|
+
get f1_uint32() {
|
|
401
|
+
return this.f1Uint32;
|
|
402
|
+
}
|
|
403
|
+
set f1_uint32(v) {
|
|
404
|
+
this.f1Uint32 = v;
|
|
405
|
+
}
|
|
406
|
+
f2Uint64 = 0;
|
|
407
|
+
get f2_uint64() {
|
|
408
|
+
return this.f2Uint64;
|
|
409
|
+
}
|
|
410
|
+
set f2_uint64(v) {
|
|
411
|
+
this.f2Uint64 = v;
|
|
412
|
+
}
|
|
413
|
+
f3Sint32 = 0;
|
|
414
|
+
get f3_sint32() {
|
|
415
|
+
return this.f3Sint32;
|
|
416
|
+
}
|
|
417
|
+
set f3_sint32(v) {
|
|
418
|
+
this.f3Sint32 = v;
|
|
419
|
+
}
|
|
420
|
+
f4Sint64 = 0;
|
|
421
|
+
get f4_sint64() {
|
|
422
|
+
return this.f4Sint64;
|
|
423
|
+
}
|
|
424
|
+
set f4_sint64(v) {
|
|
425
|
+
this.f4Sint64 = v;
|
|
426
|
+
}
|
|
427
|
+
f5Bool = false;
|
|
428
|
+
get f5_bool() {
|
|
429
|
+
return this.f5Bool;
|
|
430
|
+
}
|
|
431
|
+
set f5_bool(v) {
|
|
432
|
+
this.f5Bool = v;
|
|
433
|
+
}
|
|
434
|
+
f6String = '';
|
|
435
|
+
get f6_string() {
|
|
436
|
+
return this.f6String;
|
|
437
|
+
}
|
|
438
|
+
set f6_string(v) {
|
|
439
|
+
this.f6String = v;
|
|
440
|
+
}
|
|
441
|
+
f7Bytes = new Uint8Array(0);
|
|
442
|
+
get f7_bytes() {
|
|
443
|
+
return this.f7Bytes;
|
|
444
|
+
}
|
|
445
|
+
set f7_bytes(v) {
|
|
446
|
+
this.f7Bytes = v;
|
|
447
|
+
}
|
|
448
|
+
f8SubMsg = null;
|
|
449
|
+
get f8_sub_msg() {
|
|
450
|
+
return this.f8SubMsg;
|
|
451
|
+
}
|
|
452
|
+
set f8_sub_msg(v) {
|
|
453
|
+
this.f8SubMsg = v;
|
|
454
|
+
}
|
|
455
|
+
f9StringArr = [];
|
|
456
|
+
get f9_string_arr() {
|
|
457
|
+
return this.f9StringArr;
|
|
458
|
+
}
|
|
459
|
+
set f9_string_arr(v) {
|
|
460
|
+
this.f9StringArr = v;
|
|
461
|
+
}
|
|
462
|
+
f10Uint32Arr = [];
|
|
463
|
+
get f10_uint32_arr() {
|
|
464
|
+
return this.f10Uint32Arr;
|
|
465
|
+
}
|
|
466
|
+
set f10_uint32_arr(v) {
|
|
467
|
+
this.f10Uint32Arr = v;
|
|
468
|
+
}
|
|
469
|
+
f11SubMsgArr = [];
|
|
470
|
+
get f11_sub_msg_arr() {
|
|
471
|
+
return this.f11SubMsgArr;
|
|
472
|
+
}
|
|
473
|
+
set f11_sub_msg_arr(v) {
|
|
474
|
+
this.f11SubMsgArr = v;
|
|
475
|
+
}
|
|
476
|
+
f12MapStrUint = {};
|
|
477
|
+
get f12_map_str_uint() {
|
|
478
|
+
return this.f12MapStrUint;
|
|
479
|
+
}
|
|
480
|
+
set f12_map_str_uint(v) {
|
|
481
|
+
this.f12MapStrUint = v;
|
|
482
|
+
}
|
|
483
|
+
f13Float32 = 0;
|
|
484
|
+
get f13_float32() {
|
|
485
|
+
return this.f13Float32;
|
|
486
|
+
}
|
|
487
|
+
set f13_float32(v) {
|
|
488
|
+
this.f13Float32 = v;
|
|
489
|
+
}
|
|
490
|
+
f14Float64 = 0;
|
|
491
|
+
get f14_float64() {
|
|
492
|
+
return this.f14Float64;
|
|
493
|
+
}
|
|
494
|
+
set f14_float64(v) {
|
|
495
|
+
this.f14Float64 = v;
|
|
496
|
+
}
|
|
497
|
+
f15Fixed32 = 0;
|
|
498
|
+
get f15_fixed32() {
|
|
499
|
+
return this.f15Fixed32;
|
|
500
|
+
}
|
|
501
|
+
set f15_fixed32(v) {
|
|
502
|
+
this.f15Fixed32 = v;
|
|
503
|
+
}
|
|
504
|
+
f16Fixed64 = 0;
|
|
505
|
+
get f16_fixed64() {
|
|
506
|
+
return this.f16Fixed64;
|
|
507
|
+
}
|
|
508
|
+
set f16_fixed64(v) {
|
|
509
|
+
this.f16Fixed64 = v;
|
|
510
|
+
}
|
|
511
|
+
f20OverflowStr = '';
|
|
512
|
+
get f20_overflow_str() {
|
|
513
|
+
return this.f20OverflowStr;
|
|
514
|
+
}
|
|
515
|
+
set f20_overflow_str(v) {
|
|
516
|
+
this.f20OverflowStr = v;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
Object.defineProperty(TestAllTypesMsg.prototype, '$typeName', {
|
|
520
|
+
value: 'omnibuf.conformance.TestAllTypes',
|
|
521
|
+
enumerable: false,
|
|
522
|
+
writable: true,
|
|
523
|
+
configurable: true,
|
|
524
|
+
});
|
|
525
|
+
export function createTestAllTypes(init) {
|
|
526
|
+
if (init === undefined)
|
|
527
|
+
return new TestAllTypesMsg();
|
|
528
|
+
return TestAllTypesSchema.create(init);
|
|
529
|
+
}
|
|
530
|
+
export function encodeTestAllTypes(enc, msg, options) {
|
|
531
|
+
enc.writeUint(1, Number(msg.f1Uint32 ?? msg.f1_uint32 ?? 0) >>> 0);
|
|
532
|
+
enc.writeUint(2, msg.f2Uint64 ?? msg.f2_uint64 ?? 0);
|
|
533
|
+
enc.writeInt(3, msg.f3Sint32 ?? msg.f3_sint32 ?? 0);
|
|
534
|
+
enc.writeInt(4, msg.f4Sint64 ?? msg.f4_sint64 ?? 0);
|
|
535
|
+
enc.writeBool(5, Boolean(msg.f5Bool ?? msg.f5_bool));
|
|
536
|
+
enc.writeString(6, msg.f6String ?? msg.f6_string ?? '');
|
|
537
|
+
enc.writeBytes(7, msg.f7Bytes ?? msg.f7_bytes ?? new Uint8Array(0));
|
|
538
|
+
{
|
|
539
|
+
const subVal = msg.f8SubMsg ?? msg.f8_sub_msg;
|
|
540
|
+
if (subVal !== null && subVal !== undefined) {
|
|
541
|
+
enc.beginSubMsg(8);
|
|
542
|
+
encodeAllTypesSubMsg(enc, subVal, options);
|
|
543
|
+
enc.endSubMsg();
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
enc.writeStringArr(9, msg.f9StringArr ?? msg.f9_string_arr ?? []);
|
|
547
|
+
enc.writeUint32Arr(10, msg.f10Uint32Arr ?? msg.f10_uint32_arr ?? []);
|
|
548
|
+
{
|
|
549
|
+
const arr = msg.f11SubMsgArr ?? msg.f11_sub_msg_arr ?? [];
|
|
550
|
+
enc.beginSubMsgArr(11);
|
|
551
|
+
for (let i = 0; i < arr.length; i++) {
|
|
552
|
+
enc.beginSubMsgElem();
|
|
553
|
+
encodeAllTypesSubMsg(enc, arr[i], options);
|
|
554
|
+
enc.endSubMsgElem();
|
|
555
|
+
}
|
|
556
|
+
enc.endSubMsgArr();
|
|
557
|
+
}
|
|
558
|
+
{
|
|
559
|
+
const entries = Object.entries(msg.f12MapStrUint ?? msg.f12_map_str_uint ?? {});
|
|
560
|
+
if (options?.deterministic)
|
|
561
|
+
entries.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
562
|
+
enc.writeTag(12, 14);
|
|
563
|
+
enc.beginContainer();
|
|
564
|
+
enc.writeByte(10);
|
|
565
|
+
enc.writeByte(0);
|
|
566
|
+
enc.writeRawVarint(entries.length);
|
|
567
|
+
for (const [k, v] of entries) {
|
|
568
|
+
enc.writeRawStringPayload(k);
|
|
569
|
+
enc.writeRawVarint(BigInt(v));
|
|
570
|
+
}
|
|
571
|
+
enc.endContainer();
|
|
572
|
+
}
|
|
573
|
+
enc.writeFloat32(13, msg.f13Float32 ?? msg.f13_float32 ?? 0);
|
|
574
|
+
enc.writeFloat64(14, msg.f14Float64 ?? msg.f14_float64 ?? 0);
|
|
575
|
+
enc.writeFixed32(15, msg.f15Fixed32 ?? msg.f15_fixed32 ?? 0);
|
|
576
|
+
enc.writeFixed64(16, msg.f16Fixed64 ?? msg.f16_fixed64 ?? 0);
|
|
577
|
+
enc.writeString(20, msg.f20OverflowStr ?? msg.f20_overflow_str ?? '');
|
|
578
|
+
if (options?.writeUnknownFields && Array.isArray(msg.$unknown)) {
|
|
579
|
+
for (const uf of msg.$unknown) {
|
|
580
|
+
enc.writeTag(uf.no, uf.wireType);
|
|
581
|
+
enc.writeRaw(uf.data);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
export function marshalTestAllTypesOmniBuf(msg, options) {
|
|
586
|
+
const enc = new Encoder(256);
|
|
587
|
+
if (options?.selfDescribing) {
|
|
588
|
+
writeField0SchemaMeta(enc, TestAllTypesSchema.getSchemaMeta(0, msg), Boolean(options.deterministic));
|
|
589
|
+
}
|
|
590
|
+
encodeTestAllTypes(enc, msg, options);
|
|
591
|
+
return enc.finish();
|
|
592
|
+
}
|
|
593
|
+
export function decodeTestAllTypes(buf, target, depth = 0, options, startPos = 0, endPos = buf.length) {
|
|
594
|
+
const maxDepth = options?.recursionLimit ?? MaxNestingDepth;
|
|
595
|
+
const readUnknown = options?.readUnknownFields ?? true;
|
|
596
|
+
if (depth > maxDepth) {
|
|
597
|
+
throw new Error(`omnibuf: nesting depth ${depth} exceeds MaxNestingDepth (${maxDepth})`);
|
|
598
|
+
}
|
|
599
|
+
const out = target ?? new TestAllTypesMsg();
|
|
600
|
+
if (target !== undefined && !options?.merge) {
|
|
601
|
+
Object.assign(out, new TestAllTypesMsg());
|
|
602
|
+
delete out.$unknown;
|
|
603
|
+
}
|
|
604
|
+
const n = endPos;
|
|
605
|
+
let pos = startPos;
|
|
606
|
+
let seenMask = 0;
|
|
607
|
+
let unknownFields = Array.isArray(out.$unknown)
|
|
608
|
+
? out.$unknown
|
|
609
|
+
: null;
|
|
610
|
+
while (pos < n) {
|
|
611
|
+
let tag = 0;
|
|
612
|
+
const b0 = buf[pos];
|
|
613
|
+
if ((b0 & 1) !== 0) {
|
|
614
|
+
tag = b0 >>> 1;
|
|
615
|
+
pos += 1;
|
|
616
|
+
}
|
|
617
|
+
else if ((b0 & 2) !== 0) {
|
|
618
|
+
if (pos + 2 > n)
|
|
619
|
+
throw new Error('omnibuf: truncated tag');
|
|
620
|
+
tag = ((b0 | (buf[pos + 1] << 8)) >>> 2) >>> 0;
|
|
621
|
+
pos += 2;
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
const [t64, tn] = decodeVarintBigInt(buf, pos, n);
|
|
625
|
+
if (tn === 0 || t64 >> 4n > 536870911n)
|
|
626
|
+
throw new Error('omnibuf: invalid tag');
|
|
627
|
+
tag = Number(t64);
|
|
628
|
+
pos += tn;
|
|
629
|
+
}
|
|
630
|
+
const fieldNum = tag <= 0x7fffffff ? tag >>> 4 : Math.floor(tag / 16);
|
|
631
|
+
const wt = tag & 0x0f;
|
|
632
|
+
if (fieldNum === 0) {
|
|
633
|
+
if (wt !== 12)
|
|
634
|
+
throw new Error('omnibuf: invalid Field #0 wire type');
|
|
635
|
+
const [meta, nextPos] = readLenSlice(buf, pos, 0, n);
|
|
636
|
+
decodeSchemaMeta(meta, depth + 1, maxDepth);
|
|
637
|
+
pos = nextPos;
|
|
638
|
+
continue;
|
|
639
|
+
}
|
|
640
|
+
const bit = fieldNum <= 30 ? 1 << fieldNum : 0;
|
|
641
|
+
const alreadySeen = (seenMask & bit) !== 0 || Boolean(options?.merge);
|
|
642
|
+
switch (fieldNum) {
|
|
643
|
+
case 1: {
|
|
644
|
+
if (!(wt === 0)) {
|
|
645
|
+
const valStart = pos;
|
|
646
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
647
|
+
if (readUnknown) {
|
|
648
|
+
if (!unknownFields)
|
|
649
|
+
unknownFields = [];
|
|
650
|
+
unknownFields.push({
|
|
651
|
+
no: fieldNum,
|
|
652
|
+
wireType: wt,
|
|
653
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
break;
|
|
657
|
+
}
|
|
658
|
+
seenMask |= bit;
|
|
659
|
+
if (pos >= n)
|
|
660
|
+
throw new Error('omnibuf: truncated uint32');
|
|
661
|
+
const vb = buf[pos];
|
|
662
|
+
let u32Val = 0;
|
|
663
|
+
if ((vb & 1) !== 0) {
|
|
664
|
+
u32Val = vb >>> 1;
|
|
665
|
+
pos += 1;
|
|
666
|
+
}
|
|
667
|
+
else if ((vb & 2) !== 0) {
|
|
668
|
+
if (pos + 2 > n)
|
|
669
|
+
throw new Error('omnibuf: truncated uint32');
|
|
670
|
+
u32Val = (vb | (buf[pos + 1] << 8)) >>> 2;
|
|
671
|
+
pos += 2;
|
|
672
|
+
}
|
|
673
|
+
else if ((vb & 4) !== 0) {
|
|
674
|
+
if (pos + 4 > n)
|
|
675
|
+
throw new Error('omnibuf: truncated uint32');
|
|
676
|
+
u32Val =
|
|
677
|
+
((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
|
|
678
|
+
0;
|
|
679
|
+
pos += 4;
|
|
680
|
+
}
|
|
681
|
+
else {
|
|
682
|
+
if (vb !== 0 || pos + 9 > n)
|
|
683
|
+
throw new Error('omnibuf: truncated uint32');
|
|
684
|
+
u32Val =
|
|
685
|
+
(buf[pos + 1] |
|
|
686
|
+
(buf[pos + 2] << 8) |
|
|
687
|
+
(buf[pos + 3] << 16) |
|
|
688
|
+
(buf[pos + 4] << 24)) >>>
|
|
689
|
+
0;
|
|
690
|
+
pos += 9;
|
|
691
|
+
}
|
|
692
|
+
out.f1Uint32 = u32Val;
|
|
693
|
+
break;
|
|
694
|
+
}
|
|
695
|
+
case 2: {
|
|
696
|
+
if (!(wt === 0)) {
|
|
697
|
+
const valStart = pos;
|
|
698
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
699
|
+
if (readUnknown) {
|
|
700
|
+
if (!unknownFields)
|
|
701
|
+
unknownFields = [];
|
|
702
|
+
unknownFields.push({
|
|
703
|
+
no: fieldNum,
|
|
704
|
+
wireType: wt,
|
|
705
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
break;
|
|
709
|
+
}
|
|
710
|
+
seenMask |= bit;
|
|
711
|
+
if (pos >= n)
|
|
712
|
+
throw new Error('omnibuf: truncated uint64');
|
|
713
|
+
const vb = buf[pos];
|
|
714
|
+
let u64Val;
|
|
715
|
+
if ((vb & 1) !== 0) {
|
|
716
|
+
u64Val = vb >>> 1;
|
|
717
|
+
pos += 1;
|
|
718
|
+
}
|
|
719
|
+
else if ((vb & 2) !== 0) {
|
|
720
|
+
if (pos + 2 > n)
|
|
721
|
+
throw new Error('omnibuf: truncated uint64');
|
|
722
|
+
u64Val = (vb | (buf[pos + 1] << 8)) >>> 2;
|
|
723
|
+
pos += 2;
|
|
724
|
+
}
|
|
725
|
+
else if ((vb & 4) !== 0) {
|
|
726
|
+
if (pos + 4 > n)
|
|
727
|
+
throw new Error('omnibuf: truncated uint64');
|
|
728
|
+
u64Val =
|
|
729
|
+
((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
|
|
730
|
+
0;
|
|
731
|
+
pos += 4;
|
|
732
|
+
}
|
|
733
|
+
else {
|
|
734
|
+
if (vb !== 0 || pos + 9 > n)
|
|
735
|
+
throw new Error('omnibuf: truncated uint64');
|
|
736
|
+
const lo = (buf[pos + 1] |
|
|
737
|
+
(buf[pos + 2] << 8) |
|
|
738
|
+
(buf[pos + 3] << 16) |
|
|
739
|
+
(buf[pos + 4] << 24)) >>>
|
|
740
|
+
0;
|
|
741
|
+
const hi = (buf[pos + 5] |
|
|
742
|
+
(buf[pos + 6] << 8) |
|
|
743
|
+
(buf[pos + 7] << 16) |
|
|
744
|
+
(buf[pos + 8] << 24)) >>>
|
|
745
|
+
0;
|
|
746
|
+
u64Val = hi <= 0x1fffff ? hi * 0x100000000 + lo : (BigInt(hi) << 32n) | BigInt(lo);
|
|
747
|
+
pos += 9;
|
|
748
|
+
}
|
|
749
|
+
out.f2Uint64 = u64Val;
|
|
750
|
+
break;
|
|
751
|
+
}
|
|
752
|
+
case 3: {
|
|
753
|
+
if (!(wt === 1)) {
|
|
754
|
+
const valStart = pos;
|
|
755
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
756
|
+
if (readUnknown) {
|
|
757
|
+
if (!unknownFields)
|
|
758
|
+
unknownFields = [];
|
|
759
|
+
unknownFields.push({
|
|
760
|
+
no: fieldNum,
|
|
761
|
+
wireType: wt,
|
|
762
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
break;
|
|
766
|
+
}
|
|
767
|
+
seenMask |= bit;
|
|
768
|
+
if (pos >= n)
|
|
769
|
+
throw new Error('omnibuf: truncated int32/enum');
|
|
770
|
+
const vb = buf[pos];
|
|
771
|
+
let i32Val = 0;
|
|
772
|
+
if ((vb & 1) !== 0) {
|
|
773
|
+
const u = vb >>> 1;
|
|
774
|
+
i32Val = (u >>> 1) ^ -(u & 1);
|
|
775
|
+
pos += 1;
|
|
776
|
+
}
|
|
777
|
+
else if ((vb & 2) !== 0) {
|
|
778
|
+
if (pos + 2 > n)
|
|
779
|
+
throw new Error('omnibuf: truncated int32/enum');
|
|
780
|
+
const u = (vb | (buf[pos + 1] << 8)) >>> 2;
|
|
781
|
+
i32Val = (u >>> 1) ^ -(u & 1);
|
|
782
|
+
pos += 2;
|
|
783
|
+
}
|
|
784
|
+
else if ((vb & 4) !== 0) {
|
|
785
|
+
if (pos + 4 > n)
|
|
786
|
+
throw new Error('omnibuf: truncated int32/enum');
|
|
787
|
+
const u = ((vb | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 3) >>>
|
|
788
|
+
0;
|
|
789
|
+
i32Val = (u >>> 1) ^ -(u & 1);
|
|
790
|
+
pos += 4;
|
|
791
|
+
}
|
|
792
|
+
else {
|
|
793
|
+
const [v, vn] = decodeVarintBigInt(buf, pos, n);
|
|
794
|
+
if (vn === 0)
|
|
795
|
+
throw new Error('omnibuf: truncated int32/enum');
|
|
796
|
+
i32Val = decodeZigZag(v) | 0;
|
|
797
|
+
pos += vn;
|
|
798
|
+
}
|
|
799
|
+
out.f3Sint32 = i32Val;
|
|
800
|
+
break;
|
|
801
|
+
}
|
|
802
|
+
case 4: {
|
|
803
|
+
if (!(wt === 1)) {
|
|
804
|
+
const valStart = pos;
|
|
805
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
806
|
+
if (readUnknown) {
|
|
807
|
+
if (!unknownFields)
|
|
808
|
+
unknownFields = [];
|
|
809
|
+
unknownFields.push({
|
|
810
|
+
no: fieldNum,
|
|
811
|
+
wireType: wt,
|
|
812
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
break;
|
|
816
|
+
}
|
|
817
|
+
seenMask |= bit;
|
|
818
|
+
const [v, vn] = decodeVarintBigInt(buf, pos, n);
|
|
819
|
+
if (vn === 0)
|
|
820
|
+
throw new Error('omnibuf: truncated int64');
|
|
821
|
+
out.f4Sint64 = decodeZigZagAuto(v);
|
|
822
|
+
pos += vn;
|
|
823
|
+
break;
|
|
824
|
+
}
|
|
825
|
+
case 5: {
|
|
826
|
+
if (!(wt === 2 || wt === 3)) {
|
|
827
|
+
const valStart = pos;
|
|
828
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
829
|
+
if (readUnknown) {
|
|
830
|
+
if (!unknownFields)
|
|
831
|
+
unknownFields = [];
|
|
832
|
+
unknownFields.push({
|
|
833
|
+
no: fieldNum,
|
|
834
|
+
wireType: wt,
|
|
835
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
break;
|
|
839
|
+
}
|
|
840
|
+
seenMask |= bit;
|
|
841
|
+
out.f5Bool = wt === 3;
|
|
842
|
+
break;
|
|
843
|
+
}
|
|
844
|
+
case 6: {
|
|
845
|
+
if (!(wt === 10)) {
|
|
846
|
+
const valStart = pos;
|
|
847
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
848
|
+
if (readUnknown) {
|
|
849
|
+
if (!unknownFields)
|
|
850
|
+
unknownFields = [];
|
|
851
|
+
unknownFields.push({
|
|
852
|
+
no: fieldNum,
|
|
853
|
+
wireType: wt,
|
|
854
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
break;
|
|
858
|
+
}
|
|
859
|
+
seenMask |= bit;
|
|
860
|
+
if (pos >= n)
|
|
861
|
+
throw new Error('omnibuf: truncated string');
|
|
862
|
+
const sb = buf[pos];
|
|
863
|
+
if ((sb & 1) !== 0) {
|
|
864
|
+
const sLen = sb >>> 1;
|
|
865
|
+
pos += 1;
|
|
866
|
+
if (pos + sLen > n)
|
|
867
|
+
throw new Error('omnibuf: truncated string');
|
|
868
|
+
out.f6String = decodeUTF8(buf, pos, pos + sLen);
|
|
869
|
+
pos += sLen;
|
|
870
|
+
}
|
|
871
|
+
else {
|
|
872
|
+
const [s, nextPos] = readLenSlice(buf, pos, 0, n);
|
|
873
|
+
out.f6String = decodeUTF8(s);
|
|
874
|
+
pos = nextPos;
|
|
875
|
+
}
|
|
876
|
+
break;
|
|
877
|
+
}
|
|
878
|
+
case 7: {
|
|
879
|
+
if (!(wt === 11)) {
|
|
880
|
+
const valStart = pos;
|
|
881
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
882
|
+
if (readUnknown) {
|
|
883
|
+
if (!unknownFields)
|
|
884
|
+
unknownFields = [];
|
|
885
|
+
unknownFields.push({
|
|
886
|
+
no: fieldNum,
|
|
887
|
+
wireType: wt,
|
|
888
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
break;
|
|
892
|
+
}
|
|
893
|
+
seenMask |= bit;
|
|
894
|
+
const [b, nextPos] = readLenSlice(buf, pos, 0, n);
|
|
895
|
+
out.f7Bytes = b.slice();
|
|
896
|
+
pos = nextPos;
|
|
897
|
+
break;
|
|
898
|
+
}
|
|
899
|
+
case 8: {
|
|
900
|
+
if (!(wt === 12)) {
|
|
901
|
+
const valStart = pos;
|
|
902
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
903
|
+
if (readUnknown) {
|
|
904
|
+
if (!unknownFields)
|
|
905
|
+
unknownFields = [];
|
|
906
|
+
unknownFields.push({
|
|
907
|
+
no: fieldNum,
|
|
908
|
+
wireType: wt,
|
|
909
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
break;
|
|
913
|
+
}
|
|
914
|
+
seenMask |= bit;
|
|
915
|
+
if (pos >= n)
|
|
916
|
+
throw new Error('omnibuf: truncated submsg');
|
|
917
|
+
let subLen = 0;
|
|
918
|
+
const lb = buf[pos];
|
|
919
|
+
if ((lb & 1) !== 0) {
|
|
920
|
+
subLen = lb >>> 1;
|
|
921
|
+
pos += 1;
|
|
922
|
+
}
|
|
923
|
+
else if ((lb & 2) !== 0) {
|
|
924
|
+
if (pos + 2 > n)
|
|
925
|
+
throw new Error('omnibuf: truncated submsg');
|
|
926
|
+
subLen = (lb | (buf[pos + 1] << 8)) >>> 2;
|
|
927
|
+
pos += 2;
|
|
928
|
+
}
|
|
929
|
+
else {
|
|
930
|
+
const [subBytes, nextPos] = readLenSlice(buf, pos, 0, n);
|
|
931
|
+
const existing = out.f8SubMsg;
|
|
932
|
+
const doMerge = alreadySeen;
|
|
933
|
+
const decodedSub = decodeAllTypesSubMsg(subBytes, doMerge ? (existing ?? undefined) : undefined, depth + 1, doMerge ? { ...options, merge: true } : options);
|
|
934
|
+
out.f8SubMsg = decodedSub;
|
|
935
|
+
pos = nextPos;
|
|
936
|
+
break;
|
|
937
|
+
}
|
|
938
|
+
if (pos + subLen > n)
|
|
939
|
+
throw new Error('omnibuf: truncated submsg');
|
|
940
|
+
const existing = out.f8SubMsg;
|
|
941
|
+
const doMerge = alreadySeen;
|
|
942
|
+
const decodedSub = decodeAllTypesSubMsg(buf, doMerge ? (existing ?? undefined) : undefined, depth + 1, doMerge ? { ...options, merge: true } : options, pos, pos + subLen);
|
|
943
|
+
out.f8SubMsg = decodedSub;
|
|
944
|
+
pos += subLen;
|
|
945
|
+
break;
|
|
946
|
+
}
|
|
947
|
+
case 9: {
|
|
948
|
+
if (!(wt === 13)) {
|
|
949
|
+
const valStart = pos;
|
|
950
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
951
|
+
if (readUnknown) {
|
|
952
|
+
if (!unknownFields)
|
|
953
|
+
unknownFields = [];
|
|
954
|
+
unknownFields.push({
|
|
955
|
+
no: fieldNum,
|
|
956
|
+
wireType: wt,
|
|
957
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
break;
|
|
961
|
+
}
|
|
962
|
+
seenMask |= bit;
|
|
963
|
+
if (pos >= n)
|
|
964
|
+
throw new Error('omnibuf: invalid string array');
|
|
965
|
+
const lb = buf[pos];
|
|
966
|
+
let bodyLen = 0;
|
|
967
|
+
if ((lb & 1) !== 0) {
|
|
968
|
+
bodyLen = lb >>> 1;
|
|
969
|
+
pos += 1;
|
|
970
|
+
}
|
|
971
|
+
else if ((lb & 2) !== 0) {
|
|
972
|
+
if (pos + 2 > n)
|
|
973
|
+
throw new Error('omnibuf: invalid string array');
|
|
974
|
+
bodyLen = (lb | (buf[pos + 1] << 8)) >>> 2;
|
|
975
|
+
pos += 2;
|
|
976
|
+
}
|
|
977
|
+
else {
|
|
978
|
+
const [body, nextPos] = readLenSlice(buf, pos, 2, n);
|
|
979
|
+
const prev = alreadySeen && Array.isArray(out.f9StringArr) ? out.f9StringArr : [];
|
|
980
|
+
const [arr, ok] = appendStringArrBody(prev, body);
|
|
981
|
+
if (!ok)
|
|
982
|
+
throw new Error('omnibuf: invalid string array');
|
|
983
|
+
out.f9StringArr = arr;
|
|
984
|
+
pos = nextPos;
|
|
985
|
+
break;
|
|
986
|
+
}
|
|
987
|
+
const bodyEnd = pos + bodyLen;
|
|
988
|
+
if (bodyLen < 2 || bodyEnd > n)
|
|
989
|
+
throw new Error('omnibuf: invalid string array');
|
|
990
|
+
if (buf[pos] === 10 && (buf[pos + 1] & 1) !== 0) {
|
|
991
|
+
const count = buf[pos + 1] >>> 1;
|
|
992
|
+
let p = pos + 2;
|
|
993
|
+
if (count > bodyEnd - p)
|
|
994
|
+
throw new Error('omnibuf: invalid string array');
|
|
995
|
+
let dst = out.f9StringArr;
|
|
996
|
+
if (!Array.isArray(dst)) {
|
|
997
|
+
dst = [];
|
|
998
|
+
out.f9StringArr = dst;
|
|
999
|
+
}
|
|
1000
|
+
else if (!alreadySeen) {
|
|
1001
|
+
dst.length = 0;
|
|
1002
|
+
}
|
|
1003
|
+
for (let i = 0; i < count; i++) {
|
|
1004
|
+
if (p >= bodyEnd)
|
|
1005
|
+
throw new Error('omnibuf: invalid string array');
|
|
1006
|
+
const sb = buf[p];
|
|
1007
|
+
if ((sb & 1) !== 0) {
|
|
1008
|
+
const sLen = sb >>> 1;
|
|
1009
|
+
p += 1;
|
|
1010
|
+
if (p + sLen > bodyEnd)
|
|
1011
|
+
throw new Error('omnibuf: invalid string array');
|
|
1012
|
+
dst.push(decodeUTF8(buf, p, p + sLen));
|
|
1013
|
+
p += sLen;
|
|
1014
|
+
}
|
|
1015
|
+
else {
|
|
1016
|
+
const [sLen, sn] = decodeVarintBigInt(buf, p, bodyEnd);
|
|
1017
|
+
if (sn === 0 || sLen > BigInt(bodyEnd - (p + sn)))
|
|
1018
|
+
throw new Error('omnibuf: invalid string array');
|
|
1019
|
+
p += sn;
|
|
1020
|
+
const sLenNum = Number(sLen);
|
|
1021
|
+
dst.push(decodeUTF8(buf, p, p + sLenNum));
|
|
1022
|
+
p += sLenNum;
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
if (p !== bodyEnd)
|
|
1026
|
+
throw new Error('omnibuf: invalid string array');
|
|
1027
|
+
pos = bodyEnd;
|
|
1028
|
+
break;
|
|
1029
|
+
}
|
|
1030
|
+
const prev = alreadySeen && Array.isArray(out.f9StringArr) ? out.f9StringArr : [];
|
|
1031
|
+
const [arr, ok] = appendStringArrBody(prev, buf.subarray(pos, bodyEnd));
|
|
1032
|
+
if (!ok)
|
|
1033
|
+
throw new Error('omnibuf: invalid string array');
|
|
1034
|
+
out.f9StringArr = arr;
|
|
1035
|
+
pos = bodyEnd;
|
|
1036
|
+
break;
|
|
1037
|
+
}
|
|
1038
|
+
case 10: {
|
|
1039
|
+
if (!(wt === 13)) {
|
|
1040
|
+
const valStart = pos;
|
|
1041
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
1042
|
+
if (readUnknown) {
|
|
1043
|
+
if (!unknownFields)
|
|
1044
|
+
unknownFields = [];
|
|
1045
|
+
unknownFields.push({
|
|
1046
|
+
no: fieldNum,
|
|
1047
|
+
wireType: wt,
|
|
1048
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
break;
|
|
1052
|
+
}
|
|
1053
|
+
seenMask |= bit;
|
|
1054
|
+
if (pos >= n)
|
|
1055
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1056
|
+
const lb = buf[pos];
|
|
1057
|
+
let bodyLen = 0;
|
|
1058
|
+
if ((lb & 1) !== 0) {
|
|
1059
|
+
bodyLen = lb >>> 1;
|
|
1060
|
+
pos += 1;
|
|
1061
|
+
}
|
|
1062
|
+
else if ((lb & 2) !== 0) {
|
|
1063
|
+
if (pos + 2 > n)
|
|
1064
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1065
|
+
bodyLen = (lb | (buf[pos + 1] << 8)) >>> 2;
|
|
1066
|
+
pos += 2;
|
|
1067
|
+
}
|
|
1068
|
+
else {
|
|
1069
|
+
const [body, nextPos] = readLenSlice(buf, pos, 2, n);
|
|
1070
|
+
const prev = alreadySeen && Array.isArray(out.f10Uint32Arr) ? out.f10Uint32Arr : [];
|
|
1071
|
+
const [arr, ok] = appendUint32ArrBody(prev, body);
|
|
1072
|
+
if (!ok)
|
|
1073
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1074
|
+
out.f10Uint32Arr = arr;
|
|
1075
|
+
pos = nextPos;
|
|
1076
|
+
break;
|
|
1077
|
+
}
|
|
1078
|
+
const bodyEnd = pos + bodyLen;
|
|
1079
|
+
if (bodyLen < 2 || bodyEnd > n)
|
|
1080
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1081
|
+
if (buf[pos] === 0 && (buf[pos + 1] & 1) !== 0) {
|
|
1082
|
+
const count = buf[pos + 1] >>> 1;
|
|
1083
|
+
let p = pos + 2;
|
|
1084
|
+
if (count > bodyEnd - p)
|
|
1085
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1086
|
+
let dst = out.f10Uint32Arr;
|
|
1087
|
+
if (!Array.isArray(dst)) {
|
|
1088
|
+
dst = [];
|
|
1089
|
+
out.f10Uint32Arr = dst;
|
|
1090
|
+
}
|
|
1091
|
+
else if (!alreadySeen) {
|
|
1092
|
+
dst.length = 0;
|
|
1093
|
+
}
|
|
1094
|
+
for (let i = 0; i < count; i++) {
|
|
1095
|
+
if (p >= bodyEnd)
|
|
1096
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1097
|
+
const vb = buf[p];
|
|
1098
|
+
if ((vb & 1) !== 0) {
|
|
1099
|
+
dst.push(vb >>> 1);
|
|
1100
|
+
p += 1;
|
|
1101
|
+
}
|
|
1102
|
+
else if ((vb & 2) !== 0) {
|
|
1103
|
+
if (p + 2 > bodyEnd)
|
|
1104
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1105
|
+
dst.push((vb | (buf[p + 1] << 8)) >>> 2);
|
|
1106
|
+
p += 2;
|
|
1107
|
+
}
|
|
1108
|
+
else if ((vb & 4) !== 0) {
|
|
1109
|
+
if (p + 4 > bodyEnd)
|
|
1110
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1111
|
+
dst.push(((vb | (buf[p + 1] << 8) | (buf[p + 2] << 16) | (buf[p + 3] << 24)) >>> 3) >>> 0);
|
|
1112
|
+
p += 4;
|
|
1113
|
+
}
|
|
1114
|
+
else {
|
|
1115
|
+
if (vb !== 0 || p + 9 > bodyEnd)
|
|
1116
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1117
|
+
dst.push((buf[p + 1] | (buf[p + 2] << 8) | (buf[p + 3] << 16) | (buf[p + 4] << 24)) >>>
|
|
1118
|
+
0);
|
|
1119
|
+
p += 9;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
if (p !== bodyEnd)
|
|
1123
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1124
|
+
pos = bodyEnd;
|
|
1125
|
+
break;
|
|
1126
|
+
}
|
|
1127
|
+
const prev = alreadySeen && Array.isArray(out.f10Uint32Arr) ? out.f10Uint32Arr : [];
|
|
1128
|
+
const [arr, ok] = appendUint32ArrBody(prev, buf.subarray(pos, bodyEnd));
|
|
1129
|
+
if (!ok)
|
|
1130
|
+
throw new Error('omnibuf: invalid uint32 array');
|
|
1131
|
+
out.f10Uint32Arr = arr;
|
|
1132
|
+
pos = bodyEnd;
|
|
1133
|
+
break;
|
|
1134
|
+
}
|
|
1135
|
+
case 11: {
|
|
1136
|
+
if (!(wt === 13)) {
|
|
1137
|
+
const valStart = pos;
|
|
1138
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
1139
|
+
if (readUnknown) {
|
|
1140
|
+
if (!unknownFields)
|
|
1141
|
+
unknownFields = [];
|
|
1142
|
+
unknownFields.push({
|
|
1143
|
+
no: fieldNum,
|
|
1144
|
+
wireType: wt,
|
|
1145
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
break;
|
|
1149
|
+
}
|
|
1150
|
+
seenMask |= bit;
|
|
1151
|
+
if (pos >= n)
|
|
1152
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1153
|
+
let arrLen = 0;
|
|
1154
|
+
const lb = buf[pos];
|
|
1155
|
+
if ((lb & 1) !== 0) {
|
|
1156
|
+
arrLen = lb >>> 1;
|
|
1157
|
+
pos += 1;
|
|
1158
|
+
}
|
|
1159
|
+
else if ((lb & 2) !== 0) {
|
|
1160
|
+
if (pos + 2 > n)
|
|
1161
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1162
|
+
arrLen = (lb | (buf[pos + 1] << 8)) >>> 2;
|
|
1163
|
+
pos += 2;
|
|
1164
|
+
}
|
|
1165
|
+
else {
|
|
1166
|
+
const [arrPayload, nextPos] = readLenSlice(buf, pos, 2, n);
|
|
1167
|
+
const [elemCount, ok] = countSubMsgArrElems(arrPayload);
|
|
1168
|
+
if (!ok)
|
|
1169
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1170
|
+
const elems = alreadySeen && Array.isArray(out.f11SubMsgArr) ? out.f11SubMsgArr : [];
|
|
1171
|
+
let [, , p] = parseArrayHeader(arrPayload);
|
|
1172
|
+
for (let i = 0; i < elemCount; i++) {
|
|
1173
|
+
const [el, en] = decodeVarintBigInt(arrPayload, p);
|
|
1174
|
+
p += en;
|
|
1175
|
+
const elNum = Number(el);
|
|
1176
|
+
elems.push(decodeAllTypesSubMsg(arrPayload, undefined, depth + 1, options, p, p + elNum));
|
|
1177
|
+
p += elNum;
|
|
1178
|
+
}
|
|
1179
|
+
out.f11SubMsgArr = elems;
|
|
1180
|
+
pos = nextPos;
|
|
1181
|
+
break;
|
|
1182
|
+
}
|
|
1183
|
+
const arrEnd = pos + arrLen;
|
|
1184
|
+
if (arrLen < 2 || arrEnd > n)
|
|
1185
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1186
|
+
if (buf[pos] === 12 && (buf[pos + 1] & 1) !== 0) {
|
|
1187
|
+
const elemCount = buf[pos + 1] >>> 1;
|
|
1188
|
+
let p = pos + 2;
|
|
1189
|
+
if (elemCount > arrEnd - p)
|
|
1190
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1191
|
+
let elems = out.f11SubMsgArr;
|
|
1192
|
+
if (!Array.isArray(elems)) {
|
|
1193
|
+
elems = [];
|
|
1194
|
+
out.f11SubMsgArr = elems;
|
|
1195
|
+
}
|
|
1196
|
+
else if (!alreadySeen) {
|
|
1197
|
+
elems.length = 0;
|
|
1198
|
+
}
|
|
1199
|
+
for (let i = 0; i < elemCount; i++) {
|
|
1200
|
+
if (p >= arrEnd)
|
|
1201
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1202
|
+
let elNum = 0;
|
|
1203
|
+
const eb0 = buf[p];
|
|
1204
|
+
if ((eb0 & 1) !== 0) {
|
|
1205
|
+
elNum = eb0 >>> 1;
|
|
1206
|
+
p += 1;
|
|
1207
|
+
}
|
|
1208
|
+
else if ((eb0 & 2) !== 0) {
|
|
1209
|
+
if (p + 2 > arrEnd)
|
|
1210
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1211
|
+
elNum = (eb0 | (buf[p + 1] << 8)) >>> 2;
|
|
1212
|
+
p += 2;
|
|
1213
|
+
}
|
|
1214
|
+
else {
|
|
1215
|
+
const [el, en] = decodeVarintBigInt(buf, p, arrEnd);
|
|
1216
|
+
if (en === 0 || el > BigInt(arrEnd - (p + en)))
|
|
1217
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1218
|
+
p += en;
|
|
1219
|
+
elNum = Number(el);
|
|
1220
|
+
}
|
|
1221
|
+
if (p + elNum > arrEnd)
|
|
1222
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1223
|
+
elems.push(decodeAllTypesSubMsg(buf, undefined, depth + 1, options, p, p + elNum));
|
|
1224
|
+
p += elNum;
|
|
1225
|
+
}
|
|
1226
|
+
if (p !== arrEnd)
|
|
1227
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1228
|
+
pos = arrEnd;
|
|
1229
|
+
break;
|
|
1230
|
+
}
|
|
1231
|
+
const arrPayload = buf.subarray(pos, arrEnd);
|
|
1232
|
+
const [elemCount, ok] = countSubMsgArrElems(arrPayload);
|
|
1233
|
+
if (!ok)
|
|
1234
|
+
throw new Error('omnibuf: corrupt submsg array');
|
|
1235
|
+
const elems = alreadySeen && Array.isArray(out.f11SubMsgArr) ? out.f11SubMsgArr : [];
|
|
1236
|
+
let [, , p] = parseArrayHeader(arrPayload);
|
|
1237
|
+
for (let i = 0; i < elemCount; i++) {
|
|
1238
|
+
const [el, en] = decodeVarintBigInt(arrPayload, p);
|
|
1239
|
+
p += en;
|
|
1240
|
+
const elNum = Number(el);
|
|
1241
|
+
elems.push(decodeAllTypesSubMsg(arrPayload, undefined, depth + 1, options, p, p + elNum));
|
|
1242
|
+
p += elNum;
|
|
1243
|
+
}
|
|
1244
|
+
out.f11SubMsgArr = elems;
|
|
1245
|
+
pos = arrEnd;
|
|
1246
|
+
break;
|
|
1247
|
+
}
|
|
1248
|
+
case 12: {
|
|
1249
|
+
if (!(wt === 14)) {
|
|
1250
|
+
const valStart = pos;
|
|
1251
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
1252
|
+
if (readUnknown) {
|
|
1253
|
+
if (!unknownFields)
|
|
1254
|
+
unknownFields = [];
|
|
1255
|
+
unknownFields.push({
|
|
1256
|
+
no: fieldNum,
|
|
1257
|
+
wireType: wt,
|
|
1258
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
1259
|
+
});
|
|
1260
|
+
}
|
|
1261
|
+
break;
|
|
1262
|
+
}
|
|
1263
|
+
seenMask |= bit;
|
|
1264
|
+
const [body, nextPos] = readLenSlice(buf, pos, 3, n);
|
|
1265
|
+
const keyWT = body[0];
|
|
1266
|
+
const valWT = body[1];
|
|
1267
|
+
validateMapTypes(keyWT, valWT);
|
|
1268
|
+
const [count, cn] = decodeVarintBigInt(body, 2);
|
|
1269
|
+
if (cn === 0 || count > BigInt(Math.floor((body.length - (2 + cn)) / 2)))
|
|
1270
|
+
throw new Error('omnibuf: invalid map count');
|
|
1271
|
+
const dst = alreadySeen && out.f12MapStrUint && typeof out.f12MapStrUint === 'object'
|
|
1272
|
+
? out.f12MapStrUint
|
|
1273
|
+
: {};
|
|
1274
|
+
let p = 2 + cn;
|
|
1275
|
+
const c = Number(count);
|
|
1276
|
+
for (let i = 0; i < c; i++) {
|
|
1277
|
+
let kVal;
|
|
1278
|
+
let vVal;
|
|
1279
|
+
{
|
|
1280
|
+
if (keyWT !== 10)
|
|
1281
|
+
throw new Error('omnibuf: invalid map string wire type');
|
|
1282
|
+
const [__s, __np] = readLenSlice(body, p, 0);
|
|
1283
|
+
kVal = decodeUTF8(__s);
|
|
1284
|
+
p = __np;
|
|
1285
|
+
}
|
|
1286
|
+
{
|
|
1287
|
+
if (valWT !== 0)
|
|
1288
|
+
throw new Error('omnibuf: invalid map uint64 wire type');
|
|
1289
|
+
const [__u, __un] = decodeVarintAuto(body, p);
|
|
1290
|
+
if (__un === 0)
|
|
1291
|
+
throw new Error('omnibuf: truncated map uint64');
|
|
1292
|
+
vVal = __u;
|
|
1293
|
+
p += __un;
|
|
1294
|
+
}
|
|
1295
|
+
Object.defineProperty(dst, String(kVal), {
|
|
1296
|
+
value: vVal,
|
|
1297
|
+
writable: true,
|
|
1298
|
+
enumerable: true,
|
|
1299
|
+
configurable: true,
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
if (p !== body.length)
|
|
1303
|
+
throw new Error('omnibuf: map trailing bytes');
|
|
1304
|
+
out.f12MapStrUint = dst;
|
|
1305
|
+
pos = nextPos;
|
|
1306
|
+
break;
|
|
1307
|
+
}
|
|
1308
|
+
case 13: {
|
|
1309
|
+
if (!(wt === 8)) {
|
|
1310
|
+
const valStart = pos;
|
|
1311
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
1312
|
+
if (readUnknown) {
|
|
1313
|
+
if (!unknownFields)
|
|
1314
|
+
unknownFields = [];
|
|
1315
|
+
unknownFields.push({
|
|
1316
|
+
no: fieldNum,
|
|
1317
|
+
wireType: wt,
|
|
1318
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
1319
|
+
});
|
|
1320
|
+
}
|
|
1321
|
+
break;
|
|
1322
|
+
}
|
|
1323
|
+
seenMask |= bit;
|
|
1324
|
+
if (n - pos < 4)
|
|
1325
|
+
throw new Error('omnibuf: truncated float32');
|
|
1326
|
+
const bits = (buf[pos] | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 0;
|
|
1327
|
+
out.f13Float32 = roundFloat32Shortest(float32FromBits(bits));
|
|
1328
|
+
pos += 4;
|
|
1329
|
+
break;
|
|
1330
|
+
}
|
|
1331
|
+
case 14: {
|
|
1332
|
+
if (!(wt === 9)) {
|
|
1333
|
+
const valStart = pos;
|
|
1334
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
1335
|
+
if (readUnknown) {
|
|
1336
|
+
if (!unknownFields)
|
|
1337
|
+
unknownFields = [];
|
|
1338
|
+
unknownFields.push({
|
|
1339
|
+
no: fieldNum,
|
|
1340
|
+
wireType: wt,
|
|
1341
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
break;
|
|
1345
|
+
}
|
|
1346
|
+
seenMask |= bit;
|
|
1347
|
+
if (n - pos < 8)
|
|
1348
|
+
throw new Error('omnibuf: truncated float64');
|
|
1349
|
+
out.f14Float64 = readFloat64At(buf, pos);
|
|
1350
|
+
pos += 8;
|
|
1351
|
+
break;
|
|
1352
|
+
}
|
|
1353
|
+
case 15: {
|
|
1354
|
+
if (!(wt === 4)) {
|
|
1355
|
+
const valStart = pos;
|
|
1356
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
1357
|
+
if (readUnknown) {
|
|
1358
|
+
if (!unknownFields)
|
|
1359
|
+
unknownFields = [];
|
|
1360
|
+
unknownFields.push({
|
|
1361
|
+
no: fieldNum,
|
|
1362
|
+
wireType: wt,
|
|
1363
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
1364
|
+
});
|
|
1365
|
+
}
|
|
1366
|
+
break;
|
|
1367
|
+
}
|
|
1368
|
+
seenMask |= bit;
|
|
1369
|
+
if (n - pos < 4)
|
|
1370
|
+
throw new Error('omnibuf: truncated fixed32');
|
|
1371
|
+
const bits = (buf[pos] | (buf[pos + 1] << 8) | (buf[pos + 2] << 16) | (buf[pos + 3] << 24)) >>> 0;
|
|
1372
|
+
out.f15Fixed32 = bits;
|
|
1373
|
+
pos += 4;
|
|
1374
|
+
break;
|
|
1375
|
+
}
|
|
1376
|
+
case 16: {
|
|
1377
|
+
if (!(wt === 5)) {
|
|
1378
|
+
const valStart = pos;
|
|
1379
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
1380
|
+
if (readUnknown) {
|
|
1381
|
+
if (!unknownFields)
|
|
1382
|
+
unknownFields = [];
|
|
1383
|
+
unknownFields.push({
|
|
1384
|
+
no: fieldNum,
|
|
1385
|
+
wireType: wt,
|
|
1386
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1389
|
+
break;
|
|
1390
|
+
}
|
|
1391
|
+
seenMask |= bit;
|
|
1392
|
+
if (n - pos < 8)
|
|
1393
|
+
throw new Error('omnibuf: truncated fixed64');
|
|
1394
|
+
let u64 = 0n;
|
|
1395
|
+
for (let b = 7; b >= 0; b--)
|
|
1396
|
+
u64 = (u64 << 8n) | BigInt(buf[pos + b]);
|
|
1397
|
+
out.f16Fixed64 = u64 <= 9007199254740991n ? Number(u64) : u64;
|
|
1398
|
+
pos += 8;
|
|
1399
|
+
break;
|
|
1400
|
+
}
|
|
1401
|
+
case 20: {
|
|
1402
|
+
if (!(wt === 10)) {
|
|
1403
|
+
const valStart = pos;
|
|
1404
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
1405
|
+
if (readUnknown) {
|
|
1406
|
+
if (!unknownFields)
|
|
1407
|
+
unknownFields = [];
|
|
1408
|
+
unknownFields.push({
|
|
1409
|
+
no: fieldNum,
|
|
1410
|
+
wireType: wt,
|
|
1411
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
1412
|
+
});
|
|
1413
|
+
}
|
|
1414
|
+
break;
|
|
1415
|
+
}
|
|
1416
|
+
seenMask |= bit;
|
|
1417
|
+
if (pos >= n)
|
|
1418
|
+
throw new Error('omnibuf: truncated string');
|
|
1419
|
+
const sb = buf[pos];
|
|
1420
|
+
if ((sb & 1) !== 0) {
|
|
1421
|
+
const sLen = sb >>> 1;
|
|
1422
|
+
pos += 1;
|
|
1423
|
+
if (pos + sLen > n)
|
|
1424
|
+
throw new Error('omnibuf: truncated string');
|
|
1425
|
+
out.f20OverflowStr = decodeUTF8(buf, pos, pos + sLen);
|
|
1426
|
+
pos += sLen;
|
|
1427
|
+
}
|
|
1428
|
+
else {
|
|
1429
|
+
const [s, nextPos] = readLenSlice(buf, pos, 0, n);
|
|
1430
|
+
out.f20OverflowStr = decodeUTF8(s);
|
|
1431
|
+
pos = nextPos;
|
|
1432
|
+
}
|
|
1433
|
+
break;
|
|
1434
|
+
}
|
|
1435
|
+
default: {
|
|
1436
|
+
const valStart = pos;
|
|
1437
|
+
pos = validateValue(n < buf.length ? buf.subarray(0, n) : buf, pos, wt, depth, maxDepth);
|
|
1438
|
+
if (readUnknown) {
|
|
1439
|
+
if (!unknownFields)
|
|
1440
|
+
unknownFields = [];
|
|
1441
|
+
unknownFields.push({
|
|
1442
|
+
no: fieldNum,
|
|
1443
|
+
wireType: wt,
|
|
1444
|
+
data: buf.subarray(valStart, pos).slice(),
|
|
1445
|
+
});
|
|
1446
|
+
}
|
|
1447
|
+
break;
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
if (unknownFields && unknownFields.length > 0 && !('$unknown' in out)) {
|
|
1452
|
+
Object.defineProperty(out, '$unknown', {
|
|
1453
|
+
value: unknownFields,
|
|
1454
|
+
enumerable: false,
|
|
1455
|
+
writable: true,
|
|
1456
|
+
configurable: true,
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
return out;
|
|
1460
|
+
}
|
|
1461
|
+
export function unmarshalTestAllTypesOmniBuf(buf, options) {
|
|
1462
|
+
return decodeTestAllTypes(buf, undefined, 0, options);
|
|
1463
|
+
}
|
|
1464
|
+
TestAllTypesSchema.setGeneratedCodec({
|
|
1465
|
+
create: () => new TestAllTypesMsg(),
|
|
1466
|
+
encode: encodeTestAllTypes,
|
|
1467
|
+
decode: decodeTestAllTypes,
|
|
1468
|
+
});
|
|
1469
|
+
export class OpaqueTestAllTypes {
|
|
1470
|
+
_raw;
|
|
1471
|
+
_dirtyMask = 0;
|
|
1472
|
+
_f1Uint32;
|
|
1473
|
+
_f2Uint64;
|
|
1474
|
+
_f3Sint32;
|
|
1475
|
+
_f4Sint64;
|
|
1476
|
+
_f5Bool;
|
|
1477
|
+
_f6String;
|
|
1478
|
+
_f7Bytes;
|
|
1479
|
+
_f8SubMsg;
|
|
1480
|
+
_f9StringArr;
|
|
1481
|
+
_f10Uint32Arr;
|
|
1482
|
+
_f11SubMsgArr;
|
|
1483
|
+
_f12MapStrUint;
|
|
1484
|
+
_f13Float32;
|
|
1485
|
+
_f14Float64;
|
|
1486
|
+
_f15Fixed32;
|
|
1487
|
+
_f16Fixed64;
|
|
1488
|
+
_f20OverflowStr;
|
|
1489
|
+
constructor(raw) {
|
|
1490
|
+
this._raw = raw;
|
|
1491
|
+
}
|
|
1492
|
+
raw() {
|
|
1493
|
+
return this._raw;
|
|
1494
|
+
}
|
|
1495
|
+
getF1Uint32() {
|
|
1496
|
+
if ((this._dirtyMask & (1 << 1)) !== 0) {
|
|
1497
|
+
return this._f1Uint32;
|
|
1498
|
+
}
|
|
1499
|
+
return readUint(this._raw, 1)[0];
|
|
1500
|
+
}
|
|
1501
|
+
f1Uint32() {
|
|
1502
|
+
return this.getF1Uint32();
|
|
1503
|
+
}
|
|
1504
|
+
f1_uint32() {
|
|
1505
|
+
return this.getF1Uint32();
|
|
1506
|
+
}
|
|
1507
|
+
setF1Uint32(val) {
|
|
1508
|
+
this._f1Uint32 = val;
|
|
1509
|
+
this._dirtyMask |= 1 << 1;
|
|
1510
|
+
}
|
|
1511
|
+
getF2Uint64() {
|
|
1512
|
+
if ((this._dirtyMask & (1 << 2)) !== 0) {
|
|
1513
|
+
return this._f2Uint64;
|
|
1514
|
+
}
|
|
1515
|
+
return readUintAuto(this._raw, 2)[0];
|
|
1516
|
+
}
|
|
1517
|
+
f2Uint64() {
|
|
1518
|
+
return this.getF2Uint64();
|
|
1519
|
+
}
|
|
1520
|
+
f2_uint64() {
|
|
1521
|
+
return this.getF2Uint64();
|
|
1522
|
+
}
|
|
1523
|
+
setF2Uint64(val) {
|
|
1524
|
+
this._f2Uint64 = val;
|
|
1525
|
+
this._dirtyMask |= 1 << 2;
|
|
1526
|
+
}
|
|
1527
|
+
getF3Sint32() {
|
|
1528
|
+
if ((this._dirtyMask & (1 << 3)) !== 0) {
|
|
1529
|
+
return this._f3Sint32;
|
|
1530
|
+
}
|
|
1531
|
+
return readInt(this._raw, 3)[0];
|
|
1532
|
+
}
|
|
1533
|
+
f3Sint32() {
|
|
1534
|
+
return this.getF3Sint32();
|
|
1535
|
+
}
|
|
1536
|
+
f3_sint32() {
|
|
1537
|
+
return this.getF3Sint32();
|
|
1538
|
+
}
|
|
1539
|
+
setF3Sint32(val) {
|
|
1540
|
+
this._f3Sint32 = val;
|
|
1541
|
+
this._dirtyMask |= 1 << 3;
|
|
1542
|
+
}
|
|
1543
|
+
getF4Sint64() {
|
|
1544
|
+
if ((this._dirtyMask & (1 << 4)) !== 0) {
|
|
1545
|
+
return this._f4Sint64;
|
|
1546
|
+
}
|
|
1547
|
+
return readIntAuto(this._raw, 4)[0];
|
|
1548
|
+
}
|
|
1549
|
+
f4Sint64() {
|
|
1550
|
+
return this.getF4Sint64();
|
|
1551
|
+
}
|
|
1552
|
+
f4_sint64() {
|
|
1553
|
+
return this.getF4Sint64();
|
|
1554
|
+
}
|
|
1555
|
+
setF4Sint64(val) {
|
|
1556
|
+
this._f4Sint64 = val;
|
|
1557
|
+
this._dirtyMask |= 1 << 4;
|
|
1558
|
+
}
|
|
1559
|
+
getF5Bool() {
|
|
1560
|
+
if ((this._dirtyMask & (1 << 5)) !== 0) {
|
|
1561
|
+
return this._f5Bool;
|
|
1562
|
+
}
|
|
1563
|
+
return readBool(this._raw, 5)[0];
|
|
1564
|
+
}
|
|
1565
|
+
f5Bool() {
|
|
1566
|
+
return this.getF5Bool();
|
|
1567
|
+
}
|
|
1568
|
+
f5_bool() {
|
|
1569
|
+
return this.getF5Bool();
|
|
1570
|
+
}
|
|
1571
|
+
setF5Bool(val) {
|
|
1572
|
+
this._f5Bool = val;
|
|
1573
|
+
this._dirtyMask |= 1 << 5;
|
|
1574
|
+
}
|
|
1575
|
+
getF6String() {
|
|
1576
|
+
if ((this._dirtyMask & (1 << 6)) !== 0) {
|
|
1577
|
+
return this._f6String;
|
|
1578
|
+
}
|
|
1579
|
+
return readString(this._raw, 6)[0];
|
|
1580
|
+
}
|
|
1581
|
+
f6String() {
|
|
1582
|
+
return this.getF6String();
|
|
1583
|
+
}
|
|
1584
|
+
f6_string() {
|
|
1585
|
+
return this.getF6String();
|
|
1586
|
+
}
|
|
1587
|
+
setF6String(val) {
|
|
1588
|
+
this._f6String = val;
|
|
1589
|
+
this._dirtyMask |= 1 << 6;
|
|
1590
|
+
}
|
|
1591
|
+
getF7Bytes() {
|
|
1592
|
+
if ((this._dirtyMask & (1 << 7)) !== 0) {
|
|
1593
|
+
return this._f7Bytes;
|
|
1594
|
+
}
|
|
1595
|
+
return readBytes(this._raw, 7)[0];
|
|
1596
|
+
}
|
|
1597
|
+
f7Bytes() {
|
|
1598
|
+
return this.getF7Bytes();
|
|
1599
|
+
}
|
|
1600
|
+
f7_bytes() {
|
|
1601
|
+
return this.getF7Bytes();
|
|
1602
|
+
}
|
|
1603
|
+
setF7Bytes(val) {
|
|
1604
|
+
this._f7Bytes = val;
|
|
1605
|
+
this._dirtyMask |= 1 << 7;
|
|
1606
|
+
}
|
|
1607
|
+
getF8SubMsg() {
|
|
1608
|
+
if ((this._dirtyMask & (1 << 8)) !== 0) {
|
|
1609
|
+
return this._f8SubMsg;
|
|
1610
|
+
}
|
|
1611
|
+
if (this._f8SubMsg === undefined) {
|
|
1612
|
+
this._f8SubMsg = readSubMsgMerged(this._raw, 8, (sub, target, merge, s, e) => decodeAllTypesSubMsg(sub, target, 0, merge ? { merge: true } : undefined, s, e))[0];
|
|
1613
|
+
}
|
|
1614
|
+
return this._f8SubMsg;
|
|
1615
|
+
}
|
|
1616
|
+
f8SubMsg() {
|
|
1617
|
+
return this.getF8SubMsg();
|
|
1618
|
+
}
|
|
1619
|
+
f8_sub_msg() {
|
|
1620
|
+
return this.getF8SubMsg();
|
|
1621
|
+
}
|
|
1622
|
+
setF8SubMsg(val) {
|
|
1623
|
+
this._f8SubMsg = val;
|
|
1624
|
+
this._dirtyMask |= 1 << 8;
|
|
1625
|
+
}
|
|
1626
|
+
getF9StringArr() {
|
|
1627
|
+
if ((this._dirtyMask & (1 << 9)) !== 0) {
|
|
1628
|
+
return this._f9StringArr;
|
|
1629
|
+
}
|
|
1630
|
+
if (this._f9StringArr === undefined) {
|
|
1631
|
+
this._f9StringArr = readStringArr(this._raw, 9)[0];
|
|
1632
|
+
}
|
|
1633
|
+
return this._f9StringArr;
|
|
1634
|
+
}
|
|
1635
|
+
f9StringArr() {
|
|
1636
|
+
return this.getF9StringArr();
|
|
1637
|
+
}
|
|
1638
|
+
f9_string_arr() {
|
|
1639
|
+
return this.getF9StringArr();
|
|
1640
|
+
}
|
|
1641
|
+
setF9StringArr(val) {
|
|
1642
|
+
this._f9StringArr = val;
|
|
1643
|
+
this._dirtyMask |= 1 << 9;
|
|
1644
|
+
}
|
|
1645
|
+
getF10Uint32Arr() {
|
|
1646
|
+
if ((this._dirtyMask & (1 << 10)) !== 0) {
|
|
1647
|
+
return this._f10Uint32Arr;
|
|
1648
|
+
}
|
|
1649
|
+
if (this._f10Uint32Arr === undefined) {
|
|
1650
|
+
this._f10Uint32Arr = readUint32Arr(this._raw, 10)[0];
|
|
1651
|
+
}
|
|
1652
|
+
return this._f10Uint32Arr;
|
|
1653
|
+
}
|
|
1654
|
+
f10Uint32Arr() {
|
|
1655
|
+
return this.getF10Uint32Arr();
|
|
1656
|
+
}
|
|
1657
|
+
f10_uint32_arr() {
|
|
1658
|
+
return this.getF10Uint32Arr();
|
|
1659
|
+
}
|
|
1660
|
+
setF10Uint32Arr(val) {
|
|
1661
|
+
this._f10Uint32Arr = val;
|
|
1662
|
+
this._dirtyMask |= 1 << 10;
|
|
1663
|
+
}
|
|
1664
|
+
getF11SubMsgArr() {
|
|
1665
|
+
if ((this._dirtyMask & (1 << 11)) !== 0) {
|
|
1666
|
+
return this._f11SubMsgArr;
|
|
1667
|
+
}
|
|
1668
|
+
if (this._f11SubMsgArr === undefined) {
|
|
1669
|
+
this._f11SubMsgArr = readSubMsgArrDecoded(this._raw, 11, (sub) => decodeAllTypesSubMsg(sub))[0];
|
|
1670
|
+
}
|
|
1671
|
+
return this._f11SubMsgArr;
|
|
1672
|
+
}
|
|
1673
|
+
f11SubMsgArr() {
|
|
1674
|
+
return this.getF11SubMsgArr();
|
|
1675
|
+
}
|
|
1676
|
+
f11_sub_msg_arr() {
|
|
1677
|
+
return this.getF11SubMsgArr();
|
|
1678
|
+
}
|
|
1679
|
+
setF11SubMsgArr(val) {
|
|
1680
|
+
this._f11SubMsgArr = val;
|
|
1681
|
+
this._dirtyMask |= 1 << 11;
|
|
1682
|
+
}
|
|
1683
|
+
getF12MapStrUint() {
|
|
1684
|
+
if ((this._dirtyMask & (1 << 12)) !== 0) {
|
|
1685
|
+
return this._f12MapStrUint;
|
|
1686
|
+
}
|
|
1687
|
+
if (this._f12MapStrUint === undefined) {
|
|
1688
|
+
this._f12MapStrUint = readTypedMap(this._raw, 12, 'string', 'uint64')[0];
|
|
1689
|
+
}
|
|
1690
|
+
return this._f12MapStrUint;
|
|
1691
|
+
}
|
|
1692
|
+
f12MapStrUint() {
|
|
1693
|
+
return this.getF12MapStrUint();
|
|
1694
|
+
}
|
|
1695
|
+
f12_map_str_uint() {
|
|
1696
|
+
return this.getF12MapStrUint();
|
|
1697
|
+
}
|
|
1698
|
+
setF12MapStrUint(val) {
|
|
1699
|
+
this._f12MapStrUint = val;
|
|
1700
|
+
this._dirtyMask |= 1 << 12;
|
|
1701
|
+
}
|
|
1702
|
+
getF13Float32() {
|
|
1703
|
+
if ((this._dirtyMask & (1 << 13)) !== 0) {
|
|
1704
|
+
return this._f13Float32;
|
|
1705
|
+
}
|
|
1706
|
+
return roundFloat32Shortest(readFloat32(this._raw, 13)[0]);
|
|
1707
|
+
}
|
|
1708
|
+
f13Float32() {
|
|
1709
|
+
return this.getF13Float32();
|
|
1710
|
+
}
|
|
1711
|
+
f13_float32() {
|
|
1712
|
+
return this.getF13Float32();
|
|
1713
|
+
}
|
|
1714
|
+
setF13Float32(val) {
|
|
1715
|
+
this._f13Float32 = val;
|
|
1716
|
+
this._dirtyMask |= 1 << 13;
|
|
1717
|
+
}
|
|
1718
|
+
getF14Float64() {
|
|
1719
|
+
if ((this._dirtyMask & (1 << 14)) !== 0) {
|
|
1720
|
+
return this._f14Float64;
|
|
1721
|
+
}
|
|
1722
|
+
return readFloat64(this._raw, 14)[0];
|
|
1723
|
+
}
|
|
1724
|
+
f14Float64() {
|
|
1725
|
+
return this.getF14Float64();
|
|
1726
|
+
}
|
|
1727
|
+
f14_float64() {
|
|
1728
|
+
return this.getF14Float64();
|
|
1729
|
+
}
|
|
1730
|
+
setF14Float64(val) {
|
|
1731
|
+
this._f14Float64 = val;
|
|
1732
|
+
this._dirtyMask |= 1 << 14;
|
|
1733
|
+
}
|
|
1734
|
+
getF15Fixed32() {
|
|
1735
|
+
if ((this._dirtyMask & (1 << 15)) !== 0) {
|
|
1736
|
+
return this._f15Fixed32;
|
|
1737
|
+
}
|
|
1738
|
+
return readFixed32(this._raw, 15)[0];
|
|
1739
|
+
}
|
|
1740
|
+
f15Fixed32() {
|
|
1741
|
+
return this.getF15Fixed32();
|
|
1742
|
+
}
|
|
1743
|
+
f15_fixed32() {
|
|
1744
|
+
return this.getF15Fixed32();
|
|
1745
|
+
}
|
|
1746
|
+
setF15Fixed32(val) {
|
|
1747
|
+
this._f15Fixed32 = val;
|
|
1748
|
+
this._dirtyMask |= 1 << 15;
|
|
1749
|
+
}
|
|
1750
|
+
getF16Fixed64() {
|
|
1751
|
+
if ((this._dirtyMask & (1 << 16)) !== 0) {
|
|
1752
|
+
return this._f16Fixed64;
|
|
1753
|
+
}
|
|
1754
|
+
return readFixed64Auto(this._raw, 16)[0];
|
|
1755
|
+
}
|
|
1756
|
+
f16Fixed64() {
|
|
1757
|
+
return this.getF16Fixed64();
|
|
1758
|
+
}
|
|
1759
|
+
f16_fixed64() {
|
|
1760
|
+
return this.getF16Fixed64();
|
|
1761
|
+
}
|
|
1762
|
+
setF16Fixed64(val) {
|
|
1763
|
+
this._f16Fixed64 = val;
|
|
1764
|
+
this._dirtyMask |= 1 << 16;
|
|
1765
|
+
}
|
|
1766
|
+
getF20OverflowStr() {
|
|
1767
|
+
if ((this._dirtyMask & (1 << 20)) !== 0) {
|
|
1768
|
+
return this._f20OverflowStr;
|
|
1769
|
+
}
|
|
1770
|
+
return readString(this._raw, 20)[0];
|
|
1771
|
+
}
|
|
1772
|
+
f20OverflowStr() {
|
|
1773
|
+
return this.getF20OverflowStr();
|
|
1774
|
+
}
|
|
1775
|
+
f20_overflow_str() {
|
|
1776
|
+
return this.getF20OverflowStr();
|
|
1777
|
+
}
|
|
1778
|
+
setF20OverflowStr(val) {
|
|
1779
|
+
this._f20OverflowStr = val;
|
|
1780
|
+
this._dirtyMask |= 1 << 20;
|
|
1781
|
+
}
|
|
1782
|
+
marshal(options) {
|
|
1783
|
+
if (this._dirtyMask !== 0) {
|
|
1784
|
+
this._raw = spliceFields(this._raw, this._dirtyMask, 20, (enc, fnum) => {
|
|
1785
|
+
switch (fnum) {
|
|
1786
|
+
case 1: {
|
|
1787
|
+
const msg = { f1Uint32: this._f1Uint32 };
|
|
1788
|
+
enc.writeUint(1, Number(msg.f1Uint32 ?? msg.f1_uint32 ?? 0) >>> 0);
|
|
1789
|
+
break;
|
|
1790
|
+
}
|
|
1791
|
+
case 2: {
|
|
1792
|
+
const msg = { f2Uint64: this._f2Uint64 };
|
|
1793
|
+
enc.writeUint(2, msg.f2Uint64 ?? msg.f2_uint64 ?? 0);
|
|
1794
|
+
break;
|
|
1795
|
+
}
|
|
1796
|
+
case 3: {
|
|
1797
|
+
const msg = { f3Sint32: this._f3Sint32 };
|
|
1798
|
+
enc.writeInt(3, msg.f3Sint32 ?? msg.f3_sint32 ?? 0);
|
|
1799
|
+
break;
|
|
1800
|
+
}
|
|
1801
|
+
case 4: {
|
|
1802
|
+
const msg = { f4Sint64: this._f4Sint64 };
|
|
1803
|
+
enc.writeInt(4, msg.f4Sint64 ?? msg.f4_sint64 ?? 0);
|
|
1804
|
+
break;
|
|
1805
|
+
}
|
|
1806
|
+
case 5: {
|
|
1807
|
+
const msg = { f5Bool: this._f5Bool };
|
|
1808
|
+
enc.writeBool(5, Boolean(msg.f5Bool ?? msg.f5_bool));
|
|
1809
|
+
break;
|
|
1810
|
+
}
|
|
1811
|
+
case 6: {
|
|
1812
|
+
const msg = { f6String: this._f6String };
|
|
1813
|
+
enc.writeString(6, msg.f6String ?? msg.f6_string ?? '');
|
|
1814
|
+
break;
|
|
1815
|
+
}
|
|
1816
|
+
case 7: {
|
|
1817
|
+
const msg = { f7Bytes: this._f7Bytes };
|
|
1818
|
+
enc.writeBytes(7, msg.f7Bytes ?? msg.f7_bytes ?? new Uint8Array(0));
|
|
1819
|
+
break;
|
|
1820
|
+
}
|
|
1821
|
+
case 8: {
|
|
1822
|
+
const msg = { f8SubMsg: this._f8SubMsg };
|
|
1823
|
+
{
|
|
1824
|
+
const subVal = msg.f8SubMsg ?? msg.f8_sub_msg;
|
|
1825
|
+
if (subVal !== null && subVal !== undefined) {
|
|
1826
|
+
enc.beginSubMsg(8);
|
|
1827
|
+
encodeAllTypesSubMsg(enc, subVal, options);
|
|
1828
|
+
enc.endSubMsg();
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
break;
|
|
1832
|
+
}
|
|
1833
|
+
case 9: {
|
|
1834
|
+
const msg = { f9StringArr: this._f9StringArr };
|
|
1835
|
+
enc.writeStringArr(9, msg.f9StringArr ?? msg.f9_string_arr ?? []);
|
|
1836
|
+
break;
|
|
1837
|
+
}
|
|
1838
|
+
case 10: {
|
|
1839
|
+
const msg = { f10Uint32Arr: this._f10Uint32Arr };
|
|
1840
|
+
enc.writeUint32Arr(10, msg.f10Uint32Arr ?? msg.f10_uint32_arr ?? []);
|
|
1841
|
+
break;
|
|
1842
|
+
}
|
|
1843
|
+
case 11: {
|
|
1844
|
+
const msg = { f11SubMsgArr: this._f11SubMsgArr };
|
|
1845
|
+
{
|
|
1846
|
+
const arr = msg.f11SubMsgArr ?? msg.f11_sub_msg_arr ?? [];
|
|
1847
|
+
enc.beginSubMsgArr(11);
|
|
1848
|
+
for (let i = 0; i < arr.length; i++) {
|
|
1849
|
+
enc.beginSubMsgElem();
|
|
1850
|
+
encodeAllTypesSubMsg(enc, arr[i], options);
|
|
1851
|
+
enc.endSubMsgElem();
|
|
1852
|
+
}
|
|
1853
|
+
enc.endSubMsgArr();
|
|
1854
|
+
}
|
|
1855
|
+
break;
|
|
1856
|
+
}
|
|
1857
|
+
case 12: {
|
|
1858
|
+
const msg = { f12MapStrUint: this._f12MapStrUint };
|
|
1859
|
+
{
|
|
1860
|
+
const entries = Object.entries(msg.f12MapStrUint ?? msg.f12_map_str_uint ?? {});
|
|
1861
|
+
if (options?.deterministic)
|
|
1862
|
+
entries.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
1863
|
+
enc.writeTag(12, 14);
|
|
1864
|
+
enc.beginContainer();
|
|
1865
|
+
enc.writeByte(10);
|
|
1866
|
+
enc.writeByte(0);
|
|
1867
|
+
enc.writeRawVarint(entries.length);
|
|
1868
|
+
for (const [k, v] of entries) {
|
|
1869
|
+
enc.writeRawStringPayload(k);
|
|
1870
|
+
enc.writeRawVarint(BigInt(v));
|
|
1871
|
+
}
|
|
1872
|
+
enc.endContainer();
|
|
1873
|
+
}
|
|
1874
|
+
break;
|
|
1875
|
+
}
|
|
1876
|
+
case 13: {
|
|
1877
|
+
const msg = { f13Float32: this._f13Float32 };
|
|
1878
|
+
enc.writeFloat32(13, msg.f13Float32 ?? msg.f13_float32 ?? 0);
|
|
1879
|
+
break;
|
|
1880
|
+
}
|
|
1881
|
+
case 14: {
|
|
1882
|
+
const msg = { f14Float64: this._f14Float64 };
|
|
1883
|
+
enc.writeFloat64(14, msg.f14Float64 ?? msg.f14_float64 ?? 0);
|
|
1884
|
+
break;
|
|
1885
|
+
}
|
|
1886
|
+
case 15: {
|
|
1887
|
+
const msg = { f15Fixed32: this._f15Fixed32 };
|
|
1888
|
+
enc.writeFixed32(15, msg.f15Fixed32 ?? msg.f15_fixed32 ?? 0);
|
|
1889
|
+
break;
|
|
1890
|
+
}
|
|
1891
|
+
case 16: {
|
|
1892
|
+
const msg = { f16Fixed64: this._f16Fixed64 };
|
|
1893
|
+
enc.writeFixed64(16, msg.f16Fixed64 ?? msg.f16_fixed64 ?? 0);
|
|
1894
|
+
break;
|
|
1895
|
+
}
|
|
1896
|
+
case 20: {
|
|
1897
|
+
const msg = { f20OverflowStr: this._f20OverflowStr };
|
|
1898
|
+
enc.writeString(20, msg.f20OverflowStr ?? msg.f20_overflow_str ?? '');
|
|
1899
|
+
break;
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
});
|
|
1903
|
+
this._dirtyMask = 0;
|
|
1904
|
+
}
|
|
1905
|
+
if (options?.selfDescribing && (this._raw.length === 0 || this._raw[0] !== 0x19)) {
|
|
1906
|
+
const f0 = encodeField0SchemaMeta(TestAllTypesSchema.getSchemaMeta(0), Boolean(options.deterministic));
|
|
1907
|
+
const out = new Uint8Array(f0.length + this._raw.length);
|
|
1908
|
+
out.set(f0, 0);
|
|
1909
|
+
out.set(this._raw, f0.length);
|
|
1910
|
+
return out;
|
|
1911
|
+
}
|
|
1912
|
+
return this._raw;
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
//# sourceMappingURL=conformance_omnibuf.pb.js.map
|