reader.js 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287
  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are
  7. // met:
  8. //
  9. // * Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. // * Redistributions in binary form must reproduce the above
  12. // copyright notice, this list of conditions and the following disclaimer
  13. // in the documentation and/or other materials provided with the
  14. // distribution.
  15. // * Neither the name of Google Inc. nor the names of its
  16. // contributors may be used to endorse or promote products derived from
  17. // this software without specific prior written permission.
  18. //
  19. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. /**
  31. * @fileoverview This file contains utilities for converting binary,
  32. * wire-format protocol buffers into Javascript data structures.
  33. *
  34. * jspb's BinaryReader class wraps the BinaryDecoder class to add methods
  35. * that understand the protocol buffer syntax and can do the type checking and
  36. * bookkeeping necessary to parse trees of nested messages.
  37. *
  38. * Major caveat - Users of this library _must_ keep their Javascript proto
  39. * parsing code in sync with the original .proto file - presumably you'll be
  40. * using the typed jspb code generator, but if you bypass that you'll need
  41. * to keep things in sync by hand.
  42. *
  43. * @suppress {missingRequire} TODO(b/152540451): this shouldn't be needed
  44. * @author aappleby@google.com (Austin Appleby)
  45. */
  46. goog.provide('jspb.BinaryReader');
  47. goog.require('goog.asserts');
  48. goog.require('jspb.BinaryConstants');
  49. goog.require('jspb.BinaryDecoder');
  50. goog.require('jspb.utils');
  51. /**
  52. * BinaryReader implements the decoders for all the wire types specified in
  53. * https://developers.google.com/protocol-buffers/docs/encoding.
  54. *
  55. * @param {jspb.ByteSource=} opt_bytes The bytes we're reading from.
  56. * @param {number=} opt_start The optional offset to start reading at.
  57. * @param {number=} opt_length The optional length of the block to read -
  58. * we'll throw an assertion if we go off the end of the block.
  59. * @constructor
  60. * @struct
  61. */
  62. jspb.BinaryReader = function(opt_bytes, opt_start, opt_length) {
  63. /**
  64. * Wire-format decoder.
  65. * @private {!jspb.BinaryDecoder}
  66. */
  67. this.decoder_ = jspb.BinaryDecoder.alloc(opt_bytes, opt_start, opt_length);
  68. /**
  69. * Cursor immediately before the field tag.
  70. * @private {number}
  71. */
  72. this.fieldCursor_ = this.decoder_.getCursor();
  73. /**
  74. * Field number of the next field in the buffer, filled in by nextField().
  75. * @private {number}
  76. */
  77. this.nextField_ = jspb.BinaryConstants.INVALID_FIELD_NUMBER;
  78. /**
  79. * Wire type of the next proto field in the buffer, filled in by
  80. * nextField().
  81. * @private {jspb.BinaryConstants.WireType}
  82. */
  83. this.nextWireType_ = jspb.BinaryConstants.WireType.INVALID;
  84. /**
  85. * Set to true if this reader encountered an error due to corrupt data.
  86. * @private {boolean}
  87. */
  88. this.error_ = false;
  89. /**
  90. * User-defined reader callbacks.
  91. * @private {?Object<string, function(!jspb.BinaryReader):*>}
  92. */
  93. this.readCallbacks_ = null;
  94. };
  95. /**
  96. * Global pool of BinaryReader instances.
  97. * @private {!Array<!jspb.BinaryReader>}
  98. */
  99. jspb.BinaryReader.instanceCache_ = [];
  100. /**
  101. * Pops an instance off the instance cache, or creates one if the cache is
  102. * empty.
  103. * @param {jspb.ByteSource=} opt_bytes The bytes we're reading from.
  104. * @param {number=} opt_start The optional offset to start reading at.
  105. * @param {number=} opt_length The optional length of the block to read -
  106. * we'll throw an assertion if we go off the end of the block.
  107. * @return {!jspb.BinaryReader}
  108. */
  109. jspb.BinaryReader.alloc =
  110. function(opt_bytes, opt_start, opt_length) {
  111. if (jspb.BinaryReader.instanceCache_.length) {
  112. var newReader = jspb.BinaryReader.instanceCache_.pop();
  113. if (opt_bytes) {
  114. newReader.decoder_.setBlock(opt_bytes, opt_start, opt_length);
  115. }
  116. return newReader;
  117. } else {
  118. return new jspb.BinaryReader(opt_bytes, opt_start, opt_length);
  119. }
  120. };
  121. /**
  122. * Alias for the above method.
  123. * @param {jspb.ByteSource=} opt_bytes The bytes we're reading from.
  124. * @param {number=} opt_start The optional offset to start reading at.
  125. * @param {number=} opt_length The optional length of the block to read -
  126. * we'll throw an assertion if we go off the end of the block.
  127. * @return {!jspb.BinaryReader}
  128. */
  129. jspb.BinaryReader.prototype.alloc = jspb.BinaryReader.alloc;
  130. /**
  131. * Puts this instance back in the instance cache.
  132. */
  133. jspb.BinaryReader.prototype.free = function() {
  134. this.decoder_.clear();
  135. this.nextField_ = jspb.BinaryConstants.INVALID_FIELD_NUMBER;
  136. this.nextWireType_ = jspb.BinaryConstants.WireType.INVALID;
  137. this.error_ = false;
  138. this.readCallbacks_ = null;
  139. if (jspb.BinaryReader.instanceCache_.length < 100) {
  140. jspb.BinaryReader.instanceCache_.push(this);
  141. }
  142. };
  143. /**
  144. * Returns the cursor immediately before the current field's tag.
  145. * @return {number} The internal read cursor.
  146. */
  147. jspb.BinaryReader.prototype.getFieldCursor = function() {
  148. return this.fieldCursor_;
  149. };
  150. /**
  151. * Returns the internal read cursor.
  152. * @return {number} The internal read cursor.
  153. */
  154. jspb.BinaryReader.prototype.getCursor = function() {
  155. return this.decoder_.getCursor();
  156. };
  157. /**
  158. * Returns the raw buffer.
  159. * @return {?Uint8Array} The raw buffer.
  160. */
  161. jspb.BinaryReader.prototype.getBuffer = function() {
  162. return this.decoder_.getBuffer();
  163. };
  164. /**
  165. * @return {number} The field number of the next field in the buffer, or
  166. * INVALID_FIELD_NUMBER if there is no next field.
  167. */
  168. jspb.BinaryReader.prototype.getFieldNumber = function() {
  169. return this.nextField_;
  170. };
  171. /**
  172. * @return {jspb.BinaryConstants.WireType} The wire type of the next field
  173. * in the stream, or WireType.INVALID if there is no next field.
  174. */
  175. jspb.BinaryReader.prototype.getWireType = function() {
  176. return this.nextWireType_;
  177. };
  178. /**
  179. * @return {boolean} Whether the current wire type is an end-group tag. Used as
  180. * an exit condition in decoder loops in generated code.
  181. */
  182. jspb.BinaryReader.prototype.isEndGroup = function() {
  183. return this.nextWireType_ == jspb.BinaryConstants.WireType.END_GROUP;
  184. };
  185. /**
  186. * Returns true if this reader hit an error due to corrupt data.
  187. * @return {boolean}
  188. */
  189. jspb.BinaryReader.prototype.getError = function() {
  190. return this.error_ || this.decoder_.getError();
  191. };
  192. /**
  193. * Points this reader at a new block of bytes.
  194. * @param {!Uint8Array} bytes The block of bytes we're reading from.
  195. * @param {number} start The offset to start reading at.
  196. * @param {number} length The length of the block to read.
  197. */
  198. jspb.BinaryReader.prototype.setBlock = function(bytes, start, length) {
  199. this.decoder_.setBlock(bytes, start, length);
  200. this.nextField_ = jspb.BinaryConstants.INVALID_FIELD_NUMBER;
  201. this.nextWireType_ = jspb.BinaryConstants.WireType.INVALID;
  202. };
  203. /**
  204. * Rewinds the stream cursor to the beginning of the buffer and resets all
  205. * internal state.
  206. */
  207. jspb.BinaryReader.prototype.reset = function() {
  208. this.decoder_.reset();
  209. this.nextField_ = jspb.BinaryConstants.INVALID_FIELD_NUMBER;
  210. this.nextWireType_ = jspb.BinaryConstants.WireType.INVALID;
  211. };
  212. /**
  213. * Advances the stream cursor by the given number of bytes.
  214. * @param {number} count The number of bytes to advance by.
  215. */
  216. jspb.BinaryReader.prototype.advance = function(count) {
  217. this.decoder_.advance(count);
  218. };
  219. /**
  220. * Reads the next field header in the stream if there is one, returns true if
  221. * we saw a valid field header or false if we've read the whole stream.
  222. * Throws an error if we encountered a deprecated START_GROUP/END_GROUP field.
  223. * @return {boolean} True if the stream contains more fields.
  224. */
  225. jspb.BinaryReader.prototype.nextField = function() {
  226. // If we're at the end of the block, there are no more fields.
  227. if (this.decoder_.atEnd()) {
  228. return false;
  229. }
  230. // If we hit an error decoding the previous field, stop now before we
  231. // try to decode anything else
  232. if (this.getError()) {
  233. goog.asserts.fail('Decoder hit an error');
  234. return false;
  235. }
  236. // Otherwise just read the header of the next field.
  237. this.fieldCursor_ = this.decoder_.getCursor();
  238. var header = this.decoder_.readUnsignedVarint32();
  239. var nextField = header >>> 3;
  240. var nextWireType = /** @type {jspb.BinaryConstants.WireType} */
  241. (header & 0x7);
  242. // If the wire type isn't one of the valid ones, something's broken.
  243. if (nextWireType != jspb.BinaryConstants.WireType.VARINT &&
  244. nextWireType != jspb.BinaryConstants.WireType.FIXED32 &&
  245. nextWireType != jspb.BinaryConstants.WireType.FIXED64 &&
  246. nextWireType != jspb.BinaryConstants.WireType.DELIMITED &&
  247. nextWireType != jspb.BinaryConstants.WireType.START_GROUP &&
  248. nextWireType != jspb.BinaryConstants.WireType.END_GROUP) {
  249. goog.asserts.fail(
  250. 'Invalid wire type: %s (at position %s)', nextWireType,
  251. this.fieldCursor_);
  252. this.error_ = true;
  253. return false;
  254. }
  255. this.nextField_ = nextField;
  256. this.nextWireType_ = nextWireType;
  257. return true;
  258. };
  259. /**
  260. * Winds the reader back to just before this field's header.
  261. */
  262. jspb.BinaryReader.prototype.unskipHeader = function() {
  263. this.decoder_.unskipVarint((this.nextField_ << 3) | this.nextWireType_);
  264. };
  265. /**
  266. * Skips all contiguous fields whose header matches the one we just read.
  267. */
  268. jspb.BinaryReader.prototype.skipMatchingFields = function() {
  269. var field = this.nextField_;
  270. this.unskipHeader();
  271. while (this.nextField() && (this.getFieldNumber() == field)) {
  272. this.skipField();
  273. }
  274. if (!this.decoder_.atEnd()) {
  275. this.unskipHeader();
  276. }
  277. };
  278. /**
  279. * Skips over the next varint field in the binary stream.
  280. */
  281. jspb.BinaryReader.prototype.skipVarintField = function() {
  282. if (this.nextWireType_ != jspb.BinaryConstants.WireType.VARINT) {
  283. goog.asserts.fail('Invalid wire type for skipVarintField');
  284. this.skipField();
  285. return;
  286. }
  287. this.decoder_.skipVarint();
  288. };
  289. /**
  290. * Skips over the next delimited field in the binary stream.
  291. */
  292. jspb.BinaryReader.prototype.skipDelimitedField = function() {
  293. if (this.nextWireType_ != jspb.BinaryConstants.WireType.DELIMITED) {
  294. goog.asserts.fail('Invalid wire type for skipDelimitedField');
  295. this.skipField();
  296. return;
  297. }
  298. var length = this.decoder_.readUnsignedVarint32();
  299. this.decoder_.advance(length);
  300. };
  301. /**
  302. * Skips over the next fixed32 field in the binary stream.
  303. */
  304. jspb.BinaryReader.prototype.skipFixed32Field = function() {
  305. if (this.nextWireType_ != jspb.BinaryConstants.WireType.FIXED32) {
  306. goog.asserts.fail('Invalid wire type for skipFixed32Field');
  307. this.skipField();
  308. return;
  309. }
  310. this.decoder_.advance(4);
  311. };
  312. /**
  313. * Skips over the next fixed64 field in the binary stream.
  314. */
  315. jspb.BinaryReader.prototype.skipFixed64Field = function() {
  316. if (this.nextWireType_ != jspb.BinaryConstants.WireType.FIXED64) {
  317. goog.asserts.fail('Invalid wire type for skipFixed64Field');
  318. this.skipField();
  319. return;
  320. }
  321. this.decoder_.advance(8);
  322. };
  323. /**
  324. * Skips over the next group field in the binary stream.
  325. */
  326. jspb.BinaryReader.prototype.skipGroup = function() {
  327. var previousField = this.nextField_;
  328. do {
  329. if (!this.nextField()) {
  330. goog.asserts.fail('Unmatched start-group tag: stream EOF');
  331. this.error_ = true;
  332. return;
  333. }
  334. if (this.nextWireType_ ==
  335. jspb.BinaryConstants.WireType.END_GROUP) {
  336. // Group end: check that it matches top-of-stack.
  337. if (this.nextField_ != previousField) {
  338. goog.asserts.fail('Unmatched end-group tag');
  339. this.error_ = true;
  340. return;
  341. }
  342. return;
  343. }
  344. this.skipField();
  345. } while (true);
  346. };
  347. /**
  348. * Skips over the next field in the binary stream - this is useful if we're
  349. * decoding a message that contain unknown fields.
  350. */
  351. jspb.BinaryReader.prototype.skipField = function() {
  352. switch (this.nextWireType_) {
  353. case jspb.BinaryConstants.WireType.VARINT:
  354. this.skipVarintField();
  355. break;
  356. case jspb.BinaryConstants.WireType.FIXED64:
  357. this.skipFixed64Field();
  358. break;
  359. case jspb.BinaryConstants.WireType.DELIMITED:
  360. this.skipDelimitedField();
  361. break;
  362. case jspb.BinaryConstants.WireType.FIXED32:
  363. this.skipFixed32Field();
  364. break;
  365. case jspb.BinaryConstants.WireType.START_GROUP:
  366. this.skipGroup();
  367. break;
  368. default:
  369. goog.asserts.fail('Invalid wire encoding for field.');
  370. }
  371. };
  372. /**
  373. * Registers a user-defined read callback.
  374. * @param {string} callbackName
  375. * @param {function(!jspb.BinaryReader):*} callback
  376. */
  377. jspb.BinaryReader.prototype.registerReadCallback = function(
  378. callbackName, callback) {
  379. if (this.readCallbacks_ === null) {
  380. this.readCallbacks_ = {};
  381. }
  382. goog.asserts.assert(!this.readCallbacks_[callbackName]);
  383. this.readCallbacks_[callbackName] = callback;
  384. };
  385. /**
  386. * Runs a registered read callback.
  387. * @param {string} callbackName The name the callback is registered under.
  388. * @return {*} The value returned by the callback.
  389. */
  390. jspb.BinaryReader.prototype.runReadCallback = function(callbackName) {
  391. goog.asserts.assert(this.readCallbacks_ !== null);
  392. var callback = this.readCallbacks_[callbackName];
  393. goog.asserts.assert(callback);
  394. return callback(this);
  395. };
  396. /**
  397. * Reads a field of any valid non-message type from the binary stream.
  398. * @param {jspb.BinaryConstants.FieldType} fieldType
  399. * @return {jspb.AnyFieldType}
  400. */
  401. jspb.BinaryReader.prototype.readAny = function(fieldType) {
  402. this.nextWireType_ = jspb.BinaryConstants.FieldTypeToWireType(fieldType);
  403. var fieldTypes = jspb.BinaryConstants.FieldType;
  404. switch (fieldType) {
  405. case fieldTypes.DOUBLE:
  406. return this.readDouble();
  407. case fieldTypes.FLOAT:
  408. return this.readFloat();
  409. case fieldTypes.INT64:
  410. return this.readInt64();
  411. case fieldTypes.UINT64:
  412. return this.readUint64();
  413. case fieldTypes.INT32:
  414. return this.readInt32();
  415. case fieldTypes.FIXED64:
  416. return this.readFixed64();
  417. case fieldTypes.FIXED32:
  418. return this.readFixed32();
  419. case fieldTypes.BOOL:
  420. return this.readBool();
  421. case fieldTypes.STRING:
  422. return this.readString();
  423. case fieldTypes.GROUP:
  424. goog.asserts.fail('Group field type not supported in readAny()');
  425. case fieldTypes.MESSAGE:
  426. goog.asserts.fail('Message field type not supported in readAny()');
  427. case fieldTypes.BYTES:
  428. return this.readBytes();
  429. case fieldTypes.UINT32:
  430. return this.readUint32();
  431. case fieldTypes.ENUM:
  432. return this.readEnum();
  433. case fieldTypes.SFIXED32:
  434. return this.readSfixed32();
  435. case fieldTypes.SFIXED64:
  436. return this.readSfixed64();
  437. case fieldTypes.SINT32:
  438. return this.readSint32();
  439. case fieldTypes.SINT64:
  440. return this.readSint64();
  441. case fieldTypes.FHASH64:
  442. return this.readFixedHash64();
  443. case fieldTypes.VHASH64:
  444. return this.readVarintHash64();
  445. default:
  446. goog.asserts.fail('Invalid field type in readAny()');
  447. }
  448. return 0;
  449. };
  450. /**
  451. * Deserialize a proto into the provided message object using the provided
  452. * reader function. This function is templated as we currently have one client
  453. * who is using manual deserialization instead of the code-generated versions.
  454. * @template T
  455. * @param {T} message
  456. * @param {function(T, !jspb.BinaryReader)} reader
  457. */
  458. jspb.BinaryReader.prototype.readMessage = function(message, reader) {
  459. goog.asserts.assert(
  460. this.nextWireType_ == jspb.BinaryConstants.WireType.DELIMITED);
  461. // Save the current endpoint of the decoder and move it to the end of the
  462. // embedded message.
  463. var oldEnd = this.decoder_.getEnd();
  464. var length = this.decoder_.readUnsignedVarint32();
  465. var newEnd = this.decoder_.getCursor() + length;
  466. this.decoder_.setEnd(newEnd);
  467. // Deserialize the embedded message.
  468. reader(message, this);
  469. // Advance the decoder past the embedded message and restore the endpoint.
  470. this.decoder_.setCursor(newEnd);
  471. this.decoder_.setEnd(oldEnd);
  472. };
  473. /**
  474. * Deserialize a proto into the provided message object using the provided
  475. * reader function, assuming that the message is serialized as a group
  476. * with the given tag.
  477. * @template T
  478. * @param {number} field
  479. * @param {T} message
  480. * @param {function(T, !jspb.BinaryReader)} reader
  481. */
  482. jspb.BinaryReader.prototype.readGroup =
  483. function(field, message, reader) {
  484. // Ensure that the wire type is correct.
  485. goog.asserts.assert(
  486. this.nextWireType_ == jspb.BinaryConstants.WireType.START_GROUP);
  487. // Ensure that the field number is correct.
  488. goog.asserts.assert(this.nextField_ == field);
  489. // Deserialize the message. The deserialization will stop at an END_GROUP tag.
  490. reader(message, this);
  491. if (!this.error_ &&
  492. this.nextWireType_ != jspb.BinaryConstants.WireType.END_GROUP) {
  493. goog.asserts.fail('Group submessage did not end with an END_GROUP tag');
  494. this.error_ = true;
  495. }
  496. };
  497. /**
  498. * Return a decoder that wraps the current delimited field.
  499. * @return {!jspb.BinaryDecoder}
  500. */
  501. jspb.BinaryReader.prototype.getFieldDecoder = function() {
  502. goog.asserts.assert(
  503. this.nextWireType_ == jspb.BinaryConstants.WireType.DELIMITED);
  504. var length = this.decoder_.readUnsignedVarint32();
  505. var start = this.decoder_.getCursor();
  506. var end = start + length;
  507. var innerDecoder =
  508. jspb.BinaryDecoder.alloc(this.decoder_.getBuffer(), start, length);
  509. this.decoder_.setCursor(end);
  510. return innerDecoder;
  511. };
  512. /**
  513. * Reads a signed 32-bit integer field from the binary stream, or throws an
  514. * error if the next field in the stream is not of the correct wire type.
  515. *
  516. * @return {number} The value of the signed 32-bit integer field.
  517. */
  518. jspb.BinaryReader.prototype.readInt32 = function() {
  519. goog.asserts.assert(
  520. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  521. return this.decoder_.readSignedVarint32();
  522. };
  523. /**
  524. * Reads a signed 32-bit integer field from the binary stream, or throws an
  525. * error if the next field in the stream is not of the correct wire type.
  526. *
  527. * Returns the value as a string.
  528. *
  529. * @return {string} The value of the signed 32-bit integer field as a decimal
  530. * string.
  531. */
  532. jspb.BinaryReader.prototype.readInt32String = function() {
  533. goog.asserts.assert(
  534. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  535. return this.decoder_.readSignedVarint32String();
  536. };
  537. /**
  538. * Reads a signed 64-bit integer field from the binary stream, or throws an
  539. * error if the next field in the stream is not of the correct wire type.
  540. *
  541. * @return {number} The value of the signed 64-bit integer field.
  542. */
  543. jspb.BinaryReader.prototype.readInt64 = function() {
  544. goog.asserts.assert(
  545. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  546. return this.decoder_.readSignedVarint64();
  547. };
  548. /**
  549. * Reads a signed 64-bit integer field from the binary stream, or throws an
  550. * error if the next field in the stream is not of the correct wire type.
  551. *
  552. * Returns the value as a string.
  553. *
  554. * @return {string} The value of the signed 64-bit integer field as a decimal
  555. * string.
  556. */
  557. jspb.BinaryReader.prototype.readInt64String = function() {
  558. goog.asserts.assert(
  559. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  560. return this.decoder_.readSignedVarint64String();
  561. };
  562. /**
  563. * Reads an unsigned 32-bit integer field from the binary stream, or throws an
  564. * error if the next field in the stream is not of the correct wire type.
  565. *
  566. * @return {number} The value of the unsigned 32-bit integer field.
  567. */
  568. jspb.BinaryReader.prototype.readUint32 = function() {
  569. goog.asserts.assert(
  570. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  571. return this.decoder_.readUnsignedVarint32();
  572. };
  573. /**
  574. * Reads an unsigned 32-bit integer field from the binary stream, or throws an
  575. * error if the next field in the stream is not of the correct wire type.
  576. *
  577. * Returns the value as a string.
  578. *
  579. * @return {string} The value of the unsigned 32-bit integer field as a decimal
  580. * string.
  581. */
  582. jspb.BinaryReader.prototype.readUint32String = function() {
  583. goog.asserts.assert(
  584. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  585. return this.decoder_.readUnsignedVarint32String();
  586. };
  587. /**
  588. * Reads an unsigned 64-bit integer field from the binary stream, or throws an
  589. * error if the next field in the stream is not of the correct wire type.
  590. *
  591. * @return {number} The value of the unsigned 64-bit integer field.
  592. */
  593. jspb.BinaryReader.prototype.readUint64 = function() {
  594. goog.asserts.assert(
  595. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  596. return this.decoder_.readUnsignedVarint64();
  597. };
  598. /**
  599. * Reads an unsigned 64-bit integer field from the binary stream, or throws an
  600. * error if the next field in the stream is not of the correct wire type.
  601. *
  602. * Returns the value as a string.
  603. *
  604. * @return {string} The value of the unsigned 64-bit integer field as a decimal
  605. * string.
  606. */
  607. jspb.BinaryReader.prototype.readUint64String = function() {
  608. goog.asserts.assert(
  609. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  610. return this.decoder_.readUnsignedVarint64String();
  611. };
  612. /**
  613. * Reads a signed zigzag-encoded 32-bit integer field from the binary stream,
  614. * or throws an error if the next field in the stream is not of the correct
  615. * wire type.
  616. *
  617. * @return {number} The value of the signed 32-bit integer field.
  618. */
  619. jspb.BinaryReader.prototype.readSint32 = function() {
  620. goog.asserts.assert(
  621. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  622. return this.decoder_.readZigzagVarint32();
  623. };
  624. /**
  625. * Reads a signed zigzag-encoded 64-bit integer field from the binary stream,
  626. * or throws an error if the next field in the stream is not of the correct
  627. * wire type.
  628. *
  629. * @return {number} The value of the signed 64-bit integer field.
  630. */
  631. jspb.BinaryReader.prototype.readSint64 = function() {
  632. goog.asserts.assert(
  633. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  634. return this.decoder_.readZigzagVarint64();
  635. };
  636. /**
  637. * Reads a signed zigzag-encoded 64-bit integer field from the binary stream,
  638. * or throws an error if the next field in the stream is not of the correct
  639. * wire type.
  640. *
  641. * @return {string} The value of the signed 64-bit integer field as a decimal string.
  642. */
  643. jspb.BinaryReader.prototype.readSint64String = function() {
  644. goog.asserts.assert(
  645. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  646. return this.decoder_.readZigzagVarint64String();
  647. };
  648. /**
  649. * Reads an unsigned 32-bit fixed-length integer fiield from the binary stream,
  650. * or throws an error if the next field in the stream is not of the correct
  651. * wire type.
  652. *
  653. * @return {number} The value of the double field.
  654. */
  655. jspb.BinaryReader.prototype.readFixed32 = function() {
  656. goog.asserts.assert(
  657. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED32);
  658. return this.decoder_.readUint32();
  659. };
  660. /**
  661. * Reads an unsigned 64-bit fixed-length integer fiield from the binary stream,
  662. * or throws an error if the next field in the stream is not of the correct
  663. * wire type.
  664. *
  665. * @return {number} The value of the float field.
  666. */
  667. jspb.BinaryReader.prototype.readFixed64 = function() {
  668. goog.asserts.assert(
  669. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64);
  670. return this.decoder_.readUint64();
  671. };
  672. /**
  673. * Reads a signed 64-bit integer field from the binary stream as a string, or
  674. * throws an error if the next field in the stream is not of the correct wire
  675. * type.
  676. *
  677. * Returns the value as a string.
  678. *
  679. * @return {string} The value of the unsigned 64-bit integer field as a decimal
  680. * string.
  681. */
  682. jspb.BinaryReader.prototype.readFixed64String = function() {
  683. goog.asserts.assert(
  684. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64);
  685. return this.decoder_.readUint64String();
  686. };
  687. /**
  688. * Reads a signed 32-bit fixed-length integer fiield from the binary stream, or
  689. * throws an error if the next field in the stream is not of the correct wire
  690. * type.
  691. *
  692. * @return {number} The value of the signed 32-bit integer field.
  693. */
  694. jspb.BinaryReader.prototype.readSfixed32 = function() {
  695. goog.asserts.assert(
  696. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED32);
  697. return this.decoder_.readInt32();
  698. };
  699. /**
  700. * Reads a signed 32-bit fixed-length integer fiield from the binary stream, or
  701. * throws an error if the next field in the stream is not of the correct wire
  702. * type.
  703. *
  704. * @return {string} The value of the signed 32-bit integer field as a decimal
  705. * string.
  706. */
  707. jspb.BinaryReader.prototype.readSfixed32String = function() {
  708. goog.asserts.assert(
  709. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED32);
  710. return this.decoder_.readInt32().toString();
  711. };
  712. /**
  713. * Reads a signed 64-bit fixed-length integer fiield from the binary stream, or
  714. * throws an error if the next field in the stream is not of the correct wire
  715. * type.
  716. *
  717. * @return {number} The value of the sfixed64 field.
  718. */
  719. jspb.BinaryReader.prototype.readSfixed64 = function() {
  720. goog.asserts.assert(
  721. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64);
  722. return this.decoder_.readInt64();
  723. };
  724. /**
  725. * Reads a signed 64-bit fixed-length integer fiield from the binary stream, or
  726. * throws an error if the next field in the stream is not of the correct wire
  727. * type.
  728. *
  729. * Returns the value as a string.
  730. *
  731. * @return {string} The value of the sfixed64 field as a decimal string.
  732. */
  733. jspb.BinaryReader.prototype.readSfixed64String = function() {
  734. goog.asserts.assert(
  735. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64);
  736. return this.decoder_.readInt64String();
  737. };
  738. /**
  739. * Reads a 32-bit floating-point field from the binary stream, or throws an
  740. * error if the next field in the stream is not of the correct wire type.
  741. *
  742. * @return {number} The value of the float field.
  743. */
  744. jspb.BinaryReader.prototype.readFloat = function() {
  745. goog.asserts.assert(
  746. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED32);
  747. return this.decoder_.readFloat();
  748. };
  749. /**
  750. * Reads a 64-bit floating-point field from the binary stream, or throws an
  751. * error if the next field in the stream is not of the correct wire type.
  752. *
  753. * @return {number} The value of the double field.
  754. */
  755. jspb.BinaryReader.prototype.readDouble = function() {
  756. goog.asserts.assert(
  757. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64);
  758. return this.decoder_.readDouble();
  759. };
  760. /**
  761. * Reads a boolean field from the binary stream, or throws an error if the next
  762. * field in the stream is not of the correct wire type.
  763. *
  764. * @return {boolean} The value of the boolean field.
  765. */
  766. jspb.BinaryReader.prototype.readBool = function() {
  767. goog.asserts.assert(
  768. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  769. return !!this.decoder_.readUnsignedVarint32();
  770. };
  771. /**
  772. * Reads an enum field from the binary stream, or throws an error if the next
  773. * field in the stream is not of the correct wire type.
  774. *
  775. * @return {number} The value of the enum field.
  776. */
  777. jspb.BinaryReader.prototype.readEnum = function() {
  778. goog.asserts.assert(
  779. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  780. return this.decoder_.readSignedVarint64();
  781. };
  782. /**
  783. * Reads a string field from the binary stream, or throws an error if the next
  784. * field in the stream is not of the correct wire type.
  785. *
  786. * @return {string} The value of the string field.
  787. */
  788. jspb.BinaryReader.prototype.readString = function() {
  789. goog.asserts.assert(
  790. this.nextWireType_ == jspb.BinaryConstants.WireType.DELIMITED);
  791. var length = this.decoder_.readUnsignedVarint32();
  792. return this.decoder_.readString(length);
  793. };
  794. /**
  795. * Reads a length-prefixed block of bytes from the binary stream, or returns
  796. * null if the next field in the stream has an invalid length value.
  797. *
  798. * @return {!Uint8Array} The block of bytes.
  799. */
  800. jspb.BinaryReader.prototype.readBytes = function() {
  801. goog.asserts.assert(
  802. this.nextWireType_ == jspb.BinaryConstants.WireType.DELIMITED);
  803. var length = this.decoder_.readUnsignedVarint32();
  804. return this.decoder_.readBytes(length);
  805. };
  806. /**
  807. * Reads a 64-bit varint or fixed64 field from the stream and returns it as an
  808. * 8-character Unicode string for use as a hash table key, or throws an error
  809. * if the next field in the stream is not of the correct wire type.
  810. *
  811. * @return {string} The hash value.
  812. */
  813. jspb.BinaryReader.prototype.readVarintHash64 = function() {
  814. goog.asserts.assert(
  815. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  816. return this.decoder_.readVarintHash64();
  817. };
  818. /**
  819. * Reads an sint64 field from the stream and returns it as an 8-character
  820. * Unicode string for use as a hash table key, or throws an error if the next
  821. * field in the stream is not of the correct wire type.
  822. *
  823. * @return {string} The hash value.
  824. */
  825. jspb.BinaryReader.prototype.readSintHash64 = function() {
  826. goog.asserts.assert(
  827. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  828. return this.decoder_.readZigzagVarintHash64();
  829. };
  830. /**
  831. * Reads a 64-bit varint field from the stream and invokes `convert` to produce
  832. * the return value, or throws an error if the next field in the stream is not
  833. * of the correct wire type.
  834. *
  835. * @param {function(number, number): T} convert Conversion function to produce
  836. * the result value, takes parameters (lowBits, highBits).
  837. * @return {T}
  838. * @template T
  839. */
  840. jspb.BinaryReader.prototype.readSplitVarint64 = function(convert) {
  841. goog.asserts.assert(
  842. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  843. return this.decoder_.readSplitVarint64(convert);
  844. };
  845. /**
  846. * Reads a 64-bit zig-zag varint field from the stream and invokes `convert` to
  847. * produce the return value, or throws an error if the next field in the stream
  848. * is not of the correct wire type.
  849. *
  850. * @param {function(number, number): T} convert Conversion function to produce
  851. * the result value, takes parameters (lowBits, highBits).
  852. * @return {T}
  853. * @template T
  854. */
  855. jspb.BinaryReader.prototype.readSplitZigzagVarint64 = function(convert) {
  856. goog.asserts.assert(
  857. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  858. return this.decoder_.readSplitVarint64(function(lowBits, highBits) {
  859. return jspb.utils.fromZigzag64(lowBits, highBits, convert);
  860. });
  861. };
  862. /**
  863. * Reads a 64-bit varint or fixed64 field from the stream and returns it as a
  864. * 8-character Unicode string for use as a hash table key, or throws an error
  865. * if the next field in the stream is not of the correct wire type.
  866. *
  867. * @return {string} The hash value.
  868. */
  869. jspb.BinaryReader.prototype.readFixedHash64 = function() {
  870. goog.asserts.assert(
  871. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64);
  872. return this.decoder_.readFixedHash64();
  873. };
  874. /**
  875. * Reads a 64-bit fixed64 field from the stream and invokes `convert`
  876. * to produce the return value, or throws an error if the next field in the
  877. * stream is not of the correct wire type.
  878. *
  879. * @param {function(number, number): T} convert Conversion function to produce
  880. * the result value, takes parameters (lowBits, highBits).
  881. * @return {T}
  882. * @template T
  883. */
  884. jspb.BinaryReader.prototype.readSplitFixed64 = function(convert) {
  885. goog.asserts.assert(
  886. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64);
  887. return this.decoder_.readSplitFixed64(convert);
  888. };
  889. /**
  890. * Reads a packed scalar field using the supplied raw reader function.
  891. * @param {function(this:jspb.BinaryDecoder)} decodeMethod
  892. * @return {!Array}
  893. * @private
  894. */
  895. jspb.BinaryReader.prototype.readPackedField_ = function(decodeMethod) {
  896. goog.asserts.assert(
  897. this.nextWireType_ == jspb.BinaryConstants.WireType.DELIMITED);
  898. var length = this.decoder_.readUnsignedVarint32();
  899. var end = this.decoder_.getCursor() + length;
  900. var result = [];
  901. while (this.decoder_.getCursor() < end) {
  902. // TODO(aappleby): .call is slow
  903. result.push(decodeMethod.call(this.decoder_));
  904. }
  905. return result;
  906. };
  907. /**
  908. * Reads a packed int32 field, which consists of a length header and a list of
  909. * signed varints.
  910. * @return {!Array<number>}
  911. */
  912. jspb.BinaryReader.prototype.readPackedInt32 = function() {
  913. return this.readPackedField_(this.decoder_.readSignedVarint32);
  914. };
  915. /**
  916. * Reads a packed int32 field, which consists of a length header and a list of
  917. * signed varints. Returns a list of strings.
  918. * @return {!Array<string>}
  919. */
  920. jspb.BinaryReader.prototype.readPackedInt32String = function() {
  921. return this.readPackedField_(this.decoder_.readSignedVarint32String);
  922. };
  923. /**
  924. * Reads a packed int64 field, which consists of a length header and a list of
  925. * signed varints.
  926. * @return {!Array<number>}
  927. */
  928. jspb.BinaryReader.prototype.readPackedInt64 = function() {
  929. return this.readPackedField_(this.decoder_.readSignedVarint64);
  930. };
  931. /**
  932. * Reads a packed int64 field, which consists of a length header and a list of
  933. * signed varints. Returns a list of strings.
  934. * @return {!Array<string>}
  935. */
  936. jspb.BinaryReader.prototype.readPackedInt64String = function() {
  937. return this.readPackedField_(this.decoder_.readSignedVarint64String);
  938. };
  939. /**
  940. * Reads a packed uint32 field, which consists of a length header and a list of
  941. * unsigned varints.
  942. * @return {!Array<number>}
  943. */
  944. jspb.BinaryReader.prototype.readPackedUint32 = function() {
  945. return this.readPackedField_(this.decoder_.readUnsignedVarint32);
  946. };
  947. /**
  948. * Reads a packed uint32 field, which consists of a length header and a list of
  949. * unsigned varints. Returns a list of strings.
  950. * @return {!Array<string>}
  951. */
  952. jspb.BinaryReader.prototype.readPackedUint32String = function() {
  953. return this.readPackedField_(this.decoder_.readUnsignedVarint32String);
  954. };
  955. /**
  956. * Reads a packed uint64 field, which consists of a length header and a list of
  957. * unsigned varints.
  958. * @return {!Array<number>}
  959. */
  960. jspb.BinaryReader.prototype.readPackedUint64 = function() {
  961. return this.readPackedField_(this.decoder_.readUnsignedVarint64);
  962. };
  963. /**
  964. * Reads a packed uint64 field, which consists of a length header and a list of
  965. * unsigned varints. Returns a list of strings.
  966. * @return {!Array<string>}
  967. */
  968. jspb.BinaryReader.prototype.readPackedUint64String = function() {
  969. return this.readPackedField_(this.decoder_.readUnsignedVarint64String);
  970. };
  971. /**
  972. * Reads a packed sint32 field, which consists of a length header and a list of
  973. * zigzag varints.
  974. * @return {!Array<number>}
  975. */
  976. jspb.BinaryReader.prototype.readPackedSint32 = function() {
  977. return this.readPackedField_(this.decoder_.readZigzagVarint32);
  978. };
  979. /**
  980. * Reads a packed sint64 field, which consists of a length header and a list of
  981. * zigzag varints.
  982. * @return {!Array<number>}
  983. */
  984. jspb.BinaryReader.prototype.readPackedSint64 = function() {
  985. return this.readPackedField_(this.decoder_.readZigzagVarint64);
  986. };
  987. /**
  988. * Reads a packed sint64 field, which consists of a length header and a list of
  989. * zigzag varints. Returns a list of strings.
  990. * @return {!Array<string>}
  991. */
  992. jspb.BinaryReader.prototype.readPackedSint64String = function() {
  993. return this.readPackedField_(this.decoder_.readZigzagVarint64String);
  994. };
  995. /**
  996. * Reads a packed fixed32 field, which consists of a length header and a list
  997. * of unsigned 32-bit ints.
  998. * @return {!Array<number>}
  999. */
  1000. jspb.BinaryReader.prototype.readPackedFixed32 = function() {
  1001. return this.readPackedField_(this.decoder_.readUint32);
  1002. };
  1003. /**
  1004. * Reads a packed fixed64 field, which consists of a length header and a list
  1005. * of unsigned 64-bit ints.
  1006. * @return {!Array<number>}
  1007. */
  1008. jspb.BinaryReader.prototype.readPackedFixed64 = function() {
  1009. return this.readPackedField_(this.decoder_.readUint64);
  1010. };
  1011. /**
  1012. * Reads a packed fixed64 field, which consists of a length header and a list
  1013. * of unsigned 64-bit ints. Returns a list of strings.
  1014. * @return {!Array<number>}
  1015. */
  1016. jspb.BinaryReader.prototype.readPackedFixed64String = function() {
  1017. return this.readPackedField_(this.decoder_.readUint64String);
  1018. };
  1019. /**
  1020. * Reads a packed sfixed32 field, which consists of a length header and a list
  1021. * of 32-bit ints.
  1022. * @return {!Array<number>}
  1023. */
  1024. jspb.BinaryReader.prototype.readPackedSfixed32 = function() {
  1025. return this.readPackedField_(this.decoder_.readInt32);
  1026. };
  1027. /**
  1028. * Reads a packed sfixed64 field, which consists of a length header and a list
  1029. * of 64-bit ints.
  1030. * @return {!Array<number>}
  1031. */
  1032. jspb.BinaryReader.prototype.readPackedSfixed64 = function() {
  1033. return this.readPackedField_(this.decoder_.readInt64);
  1034. };
  1035. /**
  1036. * Reads a packed sfixed64 field, which consists of a length header and a list
  1037. * of 64-bit ints. Returns a list of strings.
  1038. * @return {!Array<string>}
  1039. */
  1040. jspb.BinaryReader.prototype.readPackedSfixed64String = function() {
  1041. return this.readPackedField_(this.decoder_.readInt64String);
  1042. };
  1043. /**
  1044. * Reads a packed float field, which consists of a length header and a list of
  1045. * floats.
  1046. * @return {!Array<number>}
  1047. */
  1048. jspb.BinaryReader.prototype.readPackedFloat = function() {
  1049. return this.readPackedField_(this.decoder_.readFloat);
  1050. };
  1051. /**
  1052. * Reads a packed double field, which consists of a length header and a list of
  1053. * doubles.
  1054. * @return {!Array<number>}
  1055. */
  1056. jspb.BinaryReader.prototype.readPackedDouble = function() {
  1057. return this.readPackedField_(this.decoder_.readDouble);
  1058. };
  1059. /**
  1060. * Reads a packed bool field, which consists of a length header and a list of
  1061. * unsigned varints.
  1062. * @return {!Array<boolean>}
  1063. */
  1064. jspb.BinaryReader.prototype.readPackedBool = function() {
  1065. return this.readPackedField_(this.decoder_.readBool);
  1066. };
  1067. /**
  1068. * Reads a packed enum field, which consists of a length header and a list of
  1069. * unsigned varints.
  1070. * @return {!Array<number>}
  1071. */
  1072. jspb.BinaryReader.prototype.readPackedEnum = function() {
  1073. return this.readPackedField_(this.decoder_.readEnum);
  1074. };
  1075. /**
  1076. * Reads a packed varint hash64 field, which consists of a length header and a
  1077. * list of varint hash64s.
  1078. * @return {!Array<string>}
  1079. */
  1080. jspb.BinaryReader.prototype.readPackedVarintHash64 = function() {
  1081. return this.readPackedField_(this.decoder_.readVarintHash64);
  1082. };
  1083. /**
  1084. * Reads a packed fixed hash64 field, which consists of a length header and a
  1085. * list of fixed hash64s.
  1086. * @return {!Array<string>}
  1087. */
  1088. jspb.BinaryReader.prototype.readPackedFixedHash64 = function() {
  1089. return this.readPackedField_(this.decoder_.readFixedHash64);
  1090. };