reader.js 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296
  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 a delimited field. Used to
  180. * conditionally parse packed repeated fields.
  181. */
  182. jspb.BinaryReader.prototype.isDelimited = function() {
  183. return this.nextWireType_ == jspb.BinaryConstants.WireType.DELIMITED;
  184. };
  185. /**
  186. * @return {boolean} Whether the current wire type is an end-group tag. Used as
  187. * an exit condition in decoder loops in generated code.
  188. */
  189. jspb.BinaryReader.prototype.isEndGroup = function() {
  190. return this.nextWireType_ == jspb.BinaryConstants.WireType.END_GROUP;
  191. };
  192. /**
  193. * Returns true if this reader hit an error due to corrupt data.
  194. * @return {boolean}
  195. */
  196. jspb.BinaryReader.prototype.getError = function() {
  197. return this.error_ || this.decoder_.getError();
  198. };
  199. /**
  200. * Points this reader at a new block of bytes.
  201. * @param {!Uint8Array} bytes The block of bytes we're reading from.
  202. * @param {number} start The offset to start reading at.
  203. * @param {number} length The length of the block to read.
  204. */
  205. jspb.BinaryReader.prototype.setBlock = function(bytes, start, length) {
  206. this.decoder_.setBlock(bytes, start, length);
  207. this.nextField_ = jspb.BinaryConstants.INVALID_FIELD_NUMBER;
  208. this.nextWireType_ = jspb.BinaryConstants.WireType.INVALID;
  209. };
  210. /**
  211. * Rewinds the stream cursor to the beginning of the buffer and resets all
  212. * internal state.
  213. */
  214. jspb.BinaryReader.prototype.reset = function() {
  215. this.decoder_.reset();
  216. this.nextField_ = jspb.BinaryConstants.INVALID_FIELD_NUMBER;
  217. this.nextWireType_ = jspb.BinaryConstants.WireType.INVALID;
  218. };
  219. /**
  220. * Advances the stream cursor by the given number of bytes.
  221. * @param {number} count The number of bytes to advance by.
  222. */
  223. jspb.BinaryReader.prototype.advance = function(count) {
  224. this.decoder_.advance(count);
  225. };
  226. /**
  227. * Reads the next field header in the stream if there is one, returns true if
  228. * we saw a valid field header or false if we've read the whole stream.
  229. * Throws an error if we encountered a deprecated START_GROUP/END_GROUP field.
  230. * @return {boolean} True if the stream contains more fields.
  231. */
  232. jspb.BinaryReader.prototype.nextField = function() {
  233. // If we're at the end of the block, there are no more fields.
  234. if (this.decoder_.atEnd()) {
  235. return false;
  236. }
  237. // If we hit an error decoding the previous field, stop now before we
  238. // try to decode anything else
  239. if (this.getError()) {
  240. goog.asserts.fail('Decoder hit an error');
  241. return false;
  242. }
  243. // Otherwise just read the header of the next field.
  244. this.fieldCursor_ = this.decoder_.getCursor();
  245. var header = this.decoder_.readUnsignedVarint32();
  246. var nextField = header >>> 3;
  247. var nextWireType = /** @type {jspb.BinaryConstants.WireType} */
  248. (header & 0x7);
  249. // If the wire type isn't one of the valid ones, something's broken.
  250. if (nextWireType != jspb.BinaryConstants.WireType.VARINT &&
  251. nextWireType != jspb.BinaryConstants.WireType.FIXED32 &&
  252. nextWireType != jspb.BinaryConstants.WireType.FIXED64 &&
  253. nextWireType != jspb.BinaryConstants.WireType.DELIMITED &&
  254. nextWireType != jspb.BinaryConstants.WireType.START_GROUP &&
  255. nextWireType != jspb.BinaryConstants.WireType.END_GROUP) {
  256. goog.asserts.fail(
  257. 'Invalid wire type: %s (at position %s)', nextWireType,
  258. this.fieldCursor_);
  259. this.error_ = true;
  260. return false;
  261. }
  262. this.nextField_ = nextField;
  263. this.nextWireType_ = nextWireType;
  264. return true;
  265. };
  266. /**
  267. * Winds the reader back to just before this field's header.
  268. */
  269. jspb.BinaryReader.prototype.unskipHeader = function() {
  270. this.decoder_.unskipVarint((this.nextField_ << 3) | this.nextWireType_);
  271. };
  272. /**
  273. * Skips all contiguous fields whose header matches the one we just read.
  274. */
  275. jspb.BinaryReader.prototype.skipMatchingFields = function() {
  276. var field = this.nextField_;
  277. this.unskipHeader();
  278. while (this.nextField() && (this.getFieldNumber() == field)) {
  279. this.skipField();
  280. }
  281. if (!this.decoder_.atEnd()) {
  282. this.unskipHeader();
  283. }
  284. };
  285. /**
  286. * Skips over the next varint field in the binary stream.
  287. */
  288. jspb.BinaryReader.prototype.skipVarintField = function() {
  289. if (this.nextWireType_ != jspb.BinaryConstants.WireType.VARINT) {
  290. goog.asserts.fail('Invalid wire type for skipVarintField');
  291. this.skipField();
  292. return;
  293. }
  294. this.decoder_.skipVarint();
  295. };
  296. /**
  297. * Skips over the next delimited field in the binary stream.
  298. */
  299. jspb.BinaryReader.prototype.skipDelimitedField = function() {
  300. if (this.nextWireType_ != jspb.BinaryConstants.WireType.DELIMITED) {
  301. goog.asserts.fail('Invalid wire type for skipDelimitedField');
  302. this.skipField();
  303. return;
  304. }
  305. var length = this.decoder_.readUnsignedVarint32();
  306. this.decoder_.advance(length);
  307. };
  308. /**
  309. * Skips over the next fixed32 field in the binary stream.
  310. */
  311. jspb.BinaryReader.prototype.skipFixed32Field = function() {
  312. if (this.nextWireType_ != jspb.BinaryConstants.WireType.FIXED32) {
  313. goog.asserts.fail('Invalid wire type for skipFixed32Field');
  314. this.skipField();
  315. return;
  316. }
  317. this.decoder_.advance(4);
  318. };
  319. /**
  320. * Skips over the next fixed64 field in the binary stream.
  321. */
  322. jspb.BinaryReader.prototype.skipFixed64Field = function() {
  323. if (this.nextWireType_ != jspb.BinaryConstants.WireType.FIXED64) {
  324. goog.asserts.fail('Invalid wire type for skipFixed64Field');
  325. this.skipField();
  326. return;
  327. }
  328. this.decoder_.advance(8);
  329. };
  330. /**
  331. * Skips over the next group field in the binary stream.
  332. */
  333. jspb.BinaryReader.prototype.skipGroup = function() {
  334. var previousField = this.nextField_;
  335. do {
  336. if (!this.nextField()) {
  337. goog.asserts.fail('Unmatched start-group tag: stream EOF');
  338. this.error_ = true;
  339. return;
  340. }
  341. if (this.nextWireType_ ==
  342. jspb.BinaryConstants.WireType.END_GROUP) {
  343. // Group end: check that it matches top-of-stack.
  344. if (this.nextField_ != previousField) {
  345. goog.asserts.fail('Unmatched end-group tag');
  346. this.error_ = true;
  347. return;
  348. }
  349. return;
  350. }
  351. this.skipField();
  352. } while (true);
  353. };
  354. /**
  355. * Skips over the next field in the binary stream - this is useful if we're
  356. * decoding a message that contain unknown fields.
  357. */
  358. jspb.BinaryReader.prototype.skipField = function() {
  359. switch (this.nextWireType_) {
  360. case jspb.BinaryConstants.WireType.VARINT:
  361. this.skipVarintField();
  362. break;
  363. case jspb.BinaryConstants.WireType.FIXED64:
  364. this.skipFixed64Field();
  365. break;
  366. case jspb.BinaryConstants.WireType.DELIMITED:
  367. this.skipDelimitedField();
  368. break;
  369. case jspb.BinaryConstants.WireType.FIXED32:
  370. this.skipFixed32Field();
  371. break;
  372. case jspb.BinaryConstants.WireType.START_GROUP:
  373. this.skipGroup();
  374. break;
  375. default:
  376. goog.asserts.fail('Invalid wire encoding for field.');
  377. }
  378. };
  379. /**
  380. * Registers a user-defined read callback.
  381. * @param {string} callbackName
  382. * @param {function(!jspb.BinaryReader):*} callback
  383. */
  384. jspb.BinaryReader.prototype.registerReadCallback = function(
  385. callbackName, callback) {
  386. if (this.readCallbacks_ === null) {
  387. this.readCallbacks_ = {};
  388. }
  389. goog.asserts.assert(!this.readCallbacks_[callbackName]);
  390. this.readCallbacks_[callbackName] = callback;
  391. };
  392. /**
  393. * Runs a registered read callback.
  394. * @param {string} callbackName The name the callback is registered under.
  395. * @return {*} The value returned by the callback.
  396. */
  397. jspb.BinaryReader.prototype.runReadCallback = function(callbackName) {
  398. goog.asserts.assert(this.readCallbacks_ !== null);
  399. var callback = this.readCallbacks_[callbackName];
  400. goog.asserts.assert(callback);
  401. return callback(this);
  402. };
  403. /**
  404. * Reads a field of any valid non-message type from the binary stream.
  405. * @param {jspb.BinaryConstants.FieldType} fieldType
  406. * @return {jspb.AnyFieldType}
  407. */
  408. jspb.BinaryReader.prototype.readAny = function(fieldType) {
  409. this.nextWireType_ = jspb.BinaryConstants.FieldTypeToWireType(fieldType);
  410. var fieldTypes = jspb.BinaryConstants.FieldType;
  411. switch (fieldType) {
  412. case fieldTypes.DOUBLE:
  413. return this.readDouble();
  414. case fieldTypes.FLOAT:
  415. return this.readFloat();
  416. case fieldTypes.INT64:
  417. return this.readInt64();
  418. case fieldTypes.UINT64:
  419. return this.readUint64();
  420. case fieldTypes.INT32:
  421. return this.readInt32();
  422. case fieldTypes.FIXED64:
  423. return this.readFixed64();
  424. case fieldTypes.FIXED32:
  425. return this.readFixed32();
  426. case fieldTypes.BOOL:
  427. return this.readBool();
  428. case fieldTypes.STRING:
  429. return this.readString();
  430. case fieldTypes.GROUP:
  431. goog.asserts.fail('Group field type not supported in readAny()');
  432. case fieldTypes.MESSAGE:
  433. goog.asserts.fail('Message field type not supported in readAny()');
  434. case fieldTypes.BYTES:
  435. return this.readBytes();
  436. case fieldTypes.UINT32:
  437. return this.readUint32();
  438. case fieldTypes.ENUM:
  439. return this.readEnum();
  440. case fieldTypes.SFIXED32:
  441. return this.readSfixed32();
  442. case fieldTypes.SFIXED64:
  443. return this.readSfixed64();
  444. case fieldTypes.SINT32:
  445. return this.readSint32();
  446. case fieldTypes.SINT64:
  447. return this.readSint64();
  448. case fieldTypes.FHASH64:
  449. return this.readFixedHash64();
  450. case fieldTypes.VHASH64:
  451. return this.readVarintHash64();
  452. default:
  453. goog.asserts.fail('Invalid field type in readAny()');
  454. }
  455. return 0;
  456. };
  457. /**
  458. * Deserialize a proto into the provided message object using the provided
  459. * reader function. This function is templated as we currently have one client
  460. * who is using manual deserialization instead of the code-generated versions.
  461. * @template T
  462. * @param {T} message
  463. * @param {function(T, !jspb.BinaryReader)} reader
  464. */
  465. jspb.BinaryReader.prototype.readMessage = function(message, reader) {
  466. goog.asserts.assert(
  467. this.nextWireType_ == jspb.BinaryConstants.WireType.DELIMITED);
  468. // Save the current endpoint of the decoder and move it to the end of the
  469. // embedded message.
  470. var oldEnd = this.decoder_.getEnd();
  471. var length = this.decoder_.readUnsignedVarint32();
  472. var newEnd = this.decoder_.getCursor() + length;
  473. this.decoder_.setEnd(newEnd);
  474. // Deserialize the embedded message.
  475. reader(message, this);
  476. // Advance the decoder past the embedded message and restore the endpoint.
  477. this.decoder_.setCursor(newEnd);
  478. this.decoder_.setEnd(oldEnd);
  479. };
  480. /**
  481. * Deserialize a proto into the provided message object using the provided
  482. * reader function, assuming that the message is serialized as a group
  483. * with the given tag.
  484. * @template T
  485. * @param {number} field
  486. * @param {T} message
  487. * @param {function(T, !jspb.BinaryReader)} reader
  488. */
  489. jspb.BinaryReader.prototype.readGroup =
  490. function(field, message, reader) {
  491. // Ensure that the wire type is correct.
  492. goog.asserts.assert(
  493. this.nextWireType_ == jspb.BinaryConstants.WireType.START_GROUP);
  494. // Ensure that the field number is correct.
  495. goog.asserts.assert(this.nextField_ == field);
  496. // Deserialize the message. The deserialization will stop at an END_GROUP tag.
  497. reader(message, this);
  498. if (!this.error_ &&
  499. this.nextWireType_ != jspb.BinaryConstants.WireType.END_GROUP) {
  500. goog.asserts.fail('Group submessage did not end with an END_GROUP tag');
  501. this.error_ = true;
  502. }
  503. };
  504. /**
  505. * Return a decoder that wraps the current delimited field.
  506. * @return {!jspb.BinaryDecoder}
  507. */
  508. jspb.BinaryReader.prototype.getFieldDecoder = function() {
  509. goog.asserts.assert(
  510. this.nextWireType_ == jspb.BinaryConstants.WireType.DELIMITED);
  511. var length = this.decoder_.readUnsignedVarint32();
  512. var start = this.decoder_.getCursor();
  513. var end = start + length;
  514. var innerDecoder =
  515. jspb.BinaryDecoder.alloc(this.decoder_.getBuffer(), start, length);
  516. this.decoder_.setCursor(end);
  517. return innerDecoder;
  518. };
  519. /**
  520. * Reads a signed 32-bit integer field from the binary stream, or throws an
  521. * error if the next field in the stream is not of the correct wire type.
  522. *
  523. * @return {number} The value of the signed 32-bit integer field.
  524. */
  525. jspb.BinaryReader.prototype.readInt32 = function() {
  526. goog.asserts.assert(
  527. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  528. return this.decoder_.readSignedVarint32();
  529. };
  530. /**
  531. * Reads a signed 32-bit integer field from the binary stream, or throws an
  532. * error if the next field in the stream is not of the correct wire type.
  533. *
  534. * Returns the value as a string.
  535. *
  536. * @return {string} The value of the signed 32-bit integer field as a decimal
  537. * string.
  538. */
  539. jspb.BinaryReader.prototype.readInt32String = function() {
  540. goog.asserts.assert(
  541. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  542. return this.decoder_.readSignedVarint32String();
  543. };
  544. /**
  545. * Reads a signed 64-bit integer field from the binary stream, or throws an
  546. * error if the next field in the stream is not of the correct wire type.
  547. *
  548. * @return {number} The value of the signed 64-bit integer field.
  549. */
  550. jspb.BinaryReader.prototype.readInt64 = function() {
  551. goog.asserts.assert(
  552. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  553. return this.decoder_.readSignedVarint64();
  554. };
  555. /**
  556. * Reads a signed 64-bit integer field from the binary stream, or throws an
  557. * error if the next field in the stream is not of the correct wire type.
  558. *
  559. * Returns the value as a string.
  560. *
  561. * @return {string} The value of the signed 64-bit integer field as a decimal
  562. * string.
  563. */
  564. jspb.BinaryReader.prototype.readInt64String = function() {
  565. goog.asserts.assert(
  566. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  567. return this.decoder_.readSignedVarint64String();
  568. };
  569. /**
  570. * Reads an unsigned 32-bit integer field from the binary stream, or throws an
  571. * error if the next field in the stream is not of the correct wire type.
  572. *
  573. * @return {number} The value of the unsigned 32-bit integer field.
  574. */
  575. jspb.BinaryReader.prototype.readUint32 = function() {
  576. goog.asserts.assert(
  577. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  578. return this.decoder_.readUnsignedVarint32();
  579. };
  580. /**
  581. * Reads an unsigned 32-bit integer field from the binary stream, or throws an
  582. * error if the next field in the stream is not of the correct wire type.
  583. *
  584. * Returns the value as a string.
  585. *
  586. * @return {string} The value of the unsigned 32-bit integer field as a decimal
  587. * string.
  588. */
  589. jspb.BinaryReader.prototype.readUint32String = function() {
  590. goog.asserts.assert(
  591. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  592. return this.decoder_.readUnsignedVarint32String();
  593. };
  594. /**
  595. * Reads an unsigned 64-bit integer field from the binary stream, or throws an
  596. * error if the next field in the stream is not of the correct wire type.
  597. *
  598. * @return {number} The value of the unsigned 64-bit integer field.
  599. */
  600. jspb.BinaryReader.prototype.readUint64 = function() {
  601. goog.asserts.assert(
  602. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  603. return this.decoder_.readUnsignedVarint64();
  604. };
  605. /**
  606. * Reads an unsigned 64-bit integer field from the binary stream, or throws an
  607. * error if the next field in the stream is not of the correct wire type.
  608. *
  609. * Returns the value as a string.
  610. *
  611. * @return {string} The value of the unsigned 64-bit integer field as a decimal
  612. * string.
  613. */
  614. jspb.BinaryReader.prototype.readUint64String = function() {
  615. goog.asserts.assert(
  616. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  617. return this.decoder_.readUnsignedVarint64String();
  618. };
  619. /**
  620. * Reads a signed zigzag-encoded 32-bit integer field from the binary stream,
  621. * or throws an error if the next field in the stream is not of the correct
  622. * wire type.
  623. *
  624. * @return {number} The value of the signed 32-bit integer field.
  625. */
  626. jspb.BinaryReader.prototype.readSint32 = function() {
  627. goog.asserts.assert(
  628. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  629. return this.decoder_.readZigzagVarint32();
  630. };
  631. /**
  632. * Reads a signed zigzag-encoded 64-bit integer field from the binary stream,
  633. * or throws an error if the next field in the stream is not of the correct
  634. * wire type.
  635. *
  636. * @return {number} The value of the signed 64-bit integer field.
  637. */
  638. jspb.BinaryReader.prototype.readSint64 = function() {
  639. goog.asserts.assert(
  640. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  641. return this.decoder_.readZigzagVarint64();
  642. };
  643. /**
  644. * Reads a signed zigzag-encoded 64-bit integer field from the binary stream,
  645. * or throws an error if the next field in the stream is not of the correct
  646. * wire type.
  647. *
  648. * @return {string} The value of the signed 64-bit integer field as a decimal string.
  649. */
  650. jspb.BinaryReader.prototype.readSint64String = function() {
  651. goog.asserts.assert(
  652. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  653. return this.decoder_.readZigzagVarint64String();
  654. };
  655. /**
  656. * Reads an unsigned 32-bit fixed-length integer fiield from the binary stream,
  657. * or throws an error if the next field in the stream is not of the correct
  658. * wire type.
  659. *
  660. * @return {number} The value of the double field.
  661. */
  662. jspb.BinaryReader.prototype.readFixed32 = function() {
  663. goog.asserts.assert(
  664. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED32);
  665. return this.decoder_.readUint32();
  666. };
  667. /**
  668. * Reads an unsigned 64-bit fixed-length integer fiield from the binary stream,
  669. * or throws an error if the next field in the stream is not of the correct
  670. * wire type.
  671. *
  672. * @return {number} The value of the float field.
  673. */
  674. jspb.BinaryReader.prototype.readFixed64 = function() {
  675. goog.asserts.assert(
  676. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64);
  677. return this.decoder_.readUint64();
  678. };
  679. /**
  680. * Reads a signed 64-bit integer field from the binary stream as a string, or
  681. * throws an error if the next field in the stream is not of the correct wire
  682. * type.
  683. *
  684. * Returns the value as a string.
  685. *
  686. * @return {string} The value of the unsigned 64-bit integer field as a decimal
  687. * string.
  688. */
  689. jspb.BinaryReader.prototype.readFixed64String = function() {
  690. goog.asserts.assert(
  691. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64);
  692. return this.decoder_.readUint64String();
  693. };
  694. /**
  695. * Reads a signed 32-bit fixed-length integer fiield from the binary stream, or
  696. * throws an error if the next field in the stream is not of the correct wire
  697. * type.
  698. *
  699. * @return {number} The value of the signed 32-bit integer field.
  700. */
  701. jspb.BinaryReader.prototype.readSfixed32 = function() {
  702. goog.asserts.assert(
  703. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED32);
  704. return this.decoder_.readInt32();
  705. };
  706. /**
  707. * Reads a signed 32-bit fixed-length integer fiield from the binary stream, or
  708. * throws an error if the next field in the stream is not of the correct wire
  709. * type.
  710. *
  711. * @return {string} The value of the signed 32-bit integer field as a decimal
  712. * string.
  713. */
  714. jspb.BinaryReader.prototype.readSfixed32String = function() {
  715. goog.asserts.assert(
  716. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED32);
  717. return this.decoder_.readInt32().toString();
  718. };
  719. /**
  720. * Reads a signed 64-bit fixed-length integer fiield from the binary stream, or
  721. * throws an error if the next field in the stream is not of the correct wire
  722. * type.
  723. *
  724. * @return {number} The value of the sfixed64 field.
  725. */
  726. jspb.BinaryReader.prototype.readSfixed64 = function() {
  727. goog.asserts.assert(
  728. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64);
  729. return this.decoder_.readInt64();
  730. };
  731. /**
  732. * Reads a signed 64-bit fixed-length integer fiield from the binary stream, or
  733. * throws an error if the next field in the stream is not of the correct wire
  734. * type.
  735. *
  736. * Returns the value as a string.
  737. *
  738. * @return {string} The value of the sfixed64 field as a decimal string.
  739. */
  740. jspb.BinaryReader.prototype.readSfixed64String = function() {
  741. goog.asserts.assert(
  742. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64);
  743. return this.decoder_.readInt64String();
  744. };
  745. /**
  746. * Reads a 32-bit floating-point field from the binary stream, or throws an
  747. * error if the next field in the stream is not of the correct wire type.
  748. *
  749. * @return {number} The value of the float field.
  750. */
  751. jspb.BinaryReader.prototype.readFloat = function() {
  752. goog.asserts.assert(
  753. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED32);
  754. return this.decoder_.readFloat();
  755. };
  756. /**
  757. * Reads a 64-bit floating-point field from the binary stream, or throws an
  758. * error if the next field in the stream is not of the correct wire type.
  759. *
  760. * @return {number} The value of the double field.
  761. */
  762. jspb.BinaryReader.prototype.readDouble = function() {
  763. goog.asserts.assert(
  764. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64);
  765. return this.decoder_.readDouble();
  766. };
  767. /**
  768. * Reads a boolean field from the binary stream, or throws an error if the next
  769. * field in the stream is not of the correct wire type.
  770. *
  771. * @return {boolean} The value of the boolean field.
  772. */
  773. jspb.BinaryReader.prototype.readBool = function() {
  774. goog.asserts.assert(
  775. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  776. return !!this.decoder_.readUnsignedVarint32();
  777. };
  778. /**
  779. * Reads an enum field from the binary stream, or throws an error if the next
  780. * field in the stream is not of the correct wire type.
  781. *
  782. * @return {number} The value of the enum field.
  783. */
  784. jspb.BinaryReader.prototype.readEnum = function() {
  785. goog.asserts.assert(
  786. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  787. return this.decoder_.readSignedVarint64();
  788. };
  789. /**
  790. * Reads a string field from the binary stream, or throws an error if the next
  791. * field in the stream is not of the correct wire type.
  792. *
  793. * @return {string} The value of the string field.
  794. */
  795. jspb.BinaryReader.prototype.readString = function() {
  796. goog.asserts.assert(
  797. this.nextWireType_ == jspb.BinaryConstants.WireType.DELIMITED);
  798. var length = this.decoder_.readUnsignedVarint32();
  799. return this.decoder_.readString(length);
  800. };
  801. /**
  802. * Reads a length-prefixed block of bytes from the binary stream, or returns
  803. * null if the next field in the stream has an invalid length value.
  804. *
  805. * @return {!Uint8Array} The block of bytes.
  806. */
  807. jspb.BinaryReader.prototype.readBytes = function() {
  808. goog.asserts.assert(
  809. this.nextWireType_ == jspb.BinaryConstants.WireType.DELIMITED);
  810. var length = this.decoder_.readUnsignedVarint32();
  811. return this.decoder_.readBytes(length);
  812. };
  813. /**
  814. * Reads a 64-bit varint or fixed64 field from the stream and returns it as an
  815. * 8-character Unicode string for use as a hash table key, or throws an error
  816. * if the next field in the stream is not of the correct wire type.
  817. *
  818. * @return {string} The hash value.
  819. */
  820. jspb.BinaryReader.prototype.readVarintHash64 = function() {
  821. goog.asserts.assert(
  822. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  823. return this.decoder_.readVarintHash64();
  824. };
  825. /**
  826. * Reads an sint64 field from the stream and returns it as an 8-character
  827. * Unicode string for use as a hash table key, or throws an error if the next
  828. * field in the stream is not of the correct wire type.
  829. *
  830. * @return {string} The hash value.
  831. */
  832. jspb.BinaryReader.prototype.readSintHash64 = function() {
  833. goog.asserts.assert(
  834. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  835. return this.decoder_.readZigzagVarintHash64();
  836. };
  837. /**
  838. * Reads a 64-bit varint field from the stream and invokes `convert` to produce
  839. * the return value, or throws an error if the next field in the stream is not
  840. * of the correct wire type.
  841. *
  842. * @param {function(number, number): T} convert Conversion function to produce
  843. * the result value, takes parameters (lowBits, highBits).
  844. * @return {T}
  845. * @template T
  846. */
  847. jspb.BinaryReader.prototype.readSplitVarint64 = function(convert) {
  848. goog.asserts.assert(
  849. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  850. return this.decoder_.readSplitVarint64(convert);
  851. };
  852. /**
  853. * Reads a 64-bit zig-zag varint field from the stream and invokes `convert` to
  854. * produce the return value, or throws an error if the next field in the stream
  855. * is not of the correct wire type.
  856. *
  857. * @param {function(number, number): T} convert Conversion function to produce
  858. * the result value, takes parameters (lowBits, highBits).
  859. * @return {T}
  860. * @template T
  861. */
  862. jspb.BinaryReader.prototype.readSplitZigzagVarint64 = function(convert) {
  863. goog.asserts.assert(
  864. this.nextWireType_ == jspb.BinaryConstants.WireType.VARINT);
  865. return this.decoder_.readSplitVarint64(function(lowBits, highBits) {
  866. return jspb.utils.fromZigzag64(lowBits, highBits, convert);
  867. });
  868. };
  869. /**
  870. * Reads a 64-bit varint or fixed64 field from the stream and returns it as a
  871. * 8-character Unicode string for use as a hash table key, or throws an error
  872. * if the next field in the stream is not of the correct wire type.
  873. *
  874. * @return {string} The hash value.
  875. */
  876. jspb.BinaryReader.prototype.readFixedHash64 = function() {
  877. goog.asserts.assert(
  878. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64);
  879. return this.decoder_.readFixedHash64();
  880. };
  881. /**
  882. * Reads a 64-bit fixed64 field from the stream and invokes `convert`
  883. * to produce the return value, or throws an error if the next field in the
  884. * stream is not of the correct wire type.
  885. *
  886. * @param {function(number, number): T} convert Conversion function to produce
  887. * the result value, takes parameters (lowBits, highBits).
  888. * @return {T}
  889. * @template T
  890. */
  891. jspb.BinaryReader.prototype.readSplitFixed64 = function(convert) {
  892. goog.asserts.assert(
  893. this.nextWireType_ == jspb.BinaryConstants.WireType.FIXED64);
  894. return this.decoder_.readSplitFixed64(convert);
  895. };
  896. /**
  897. * Reads a packed scalar field using the supplied raw reader function.
  898. * @param {function(this:jspb.BinaryDecoder)} decodeMethod
  899. * @return {!Array}
  900. * @private
  901. */
  902. jspb.BinaryReader.prototype.readPackedField_ = function(decodeMethod) {
  903. goog.asserts.assert(
  904. this.nextWireType_ == jspb.BinaryConstants.WireType.DELIMITED);
  905. var length = this.decoder_.readUnsignedVarint32();
  906. var end = this.decoder_.getCursor() + length;
  907. var result = [];
  908. while (this.decoder_.getCursor() < end) {
  909. // TODO(aappleby): .call is slow
  910. result.push(decodeMethod.call(this.decoder_));
  911. }
  912. return result;
  913. };
  914. /**
  915. * Reads a packed int32 field, which consists of a length header and a list of
  916. * signed varints.
  917. * @return {!Array<number>}
  918. */
  919. jspb.BinaryReader.prototype.readPackedInt32 = function() {
  920. return this.readPackedField_(this.decoder_.readSignedVarint32);
  921. };
  922. /**
  923. * Reads a packed int32 field, which consists of a length header and a list of
  924. * signed varints. Returns a list of strings.
  925. * @return {!Array<string>}
  926. */
  927. jspb.BinaryReader.prototype.readPackedInt32String = function() {
  928. return this.readPackedField_(this.decoder_.readSignedVarint32String);
  929. };
  930. /**
  931. * Reads a packed int64 field, which consists of a length header and a list of
  932. * signed varints.
  933. * @return {!Array<number>}
  934. */
  935. jspb.BinaryReader.prototype.readPackedInt64 = function() {
  936. return this.readPackedField_(this.decoder_.readSignedVarint64);
  937. };
  938. /**
  939. * Reads a packed int64 field, which consists of a length header and a list of
  940. * signed varints. Returns a list of strings.
  941. * @return {!Array<string>}
  942. */
  943. jspb.BinaryReader.prototype.readPackedInt64String = function() {
  944. return this.readPackedField_(this.decoder_.readSignedVarint64String);
  945. };
  946. /**
  947. * Reads a packed uint32 field, which consists of a length header and a list of
  948. * unsigned varints.
  949. * @return {!Array<number>}
  950. */
  951. jspb.BinaryReader.prototype.readPackedUint32 = function() {
  952. return this.readPackedField_(this.decoder_.readUnsignedVarint32);
  953. };
  954. /**
  955. * Reads a packed uint32 field, which consists of a length header and a list of
  956. * unsigned varints. Returns a list of strings.
  957. * @return {!Array<string>}
  958. */
  959. jspb.BinaryReader.prototype.readPackedUint32String = function() {
  960. return this.readPackedField_(this.decoder_.readUnsignedVarint32String);
  961. };
  962. /**
  963. * Reads a packed uint64 field, which consists of a length header and a list of
  964. * unsigned varints.
  965. * @return {!Array<number>}
  966. */
  967. jspb.BinaryReader.prototype.readPackedUint64 = function() {
  968. return this.readPackedField_(this.decoder_.readUnsignedVarint64);
  969. };
  970. /**
  971. * Reads a packed uint64 field, which consists of a length header and a list of
  972. * unsigned varints. Returns a list of strings.
  973. * @return {!Array<string>}
  974. */
  975. jspb.BinaryReader.prototype.readPackedUint64String = function() {
  976. return this.readPackedField_(this.decoder_.readUnsignedVarint64String);
  977. };
  978. /**
  979. * Reads a packed sint32 field, which consists of a length header and a list of
  980. * zigzag varints.
  981. * @return {!Array<number>}
  982. */
  983. jspb.BinaryReader.prototype.readPackedSint32 = function() {
  984. return this.readPackedField_(this.decoder_.readZigzagVarint32);
  985. };
  986. /**
  987. * Reads a packed sint64 field, which consists of a length header and a list of
  988. * zigzag varints.
  989. * @return {!Array<number>}
  990. */
  991. jspb.BinaryReader.prototype.readPackedSint64 = function() {
  992. return this.readPackedField_(this.decoder_.readZigzagVarint64);
  993. };
  994. /**
  995. * Reads a packed sint64 field, which consists of a length header and a list of
  996. * zigzag varints. Returns a list of strings.
  997. * @return {!Array<string>}
  998. */
  999. jspb.BinaryReader.prototype.readPackedSint64String = function() {
  1000. return this.readPackedField_(this.decoder_.readZigzagVarint64String);
  1001. };
  1002. /**
  1003. * Reads a packed fixed32 field, which consists of a length header and a list
  1004. * of unsigned 32-bit ints.
  1005. * @return {!Array<number>}
  1006. */
  1007. jspb.BinaryReader.prototype.readPackedFixed32 = function() {
  1008. return this.readPackedField_(this.decoder_.readUint32);
  1009. };
  1010. /**
  1011. * Reads a packed fixed64 field, which consists of a length header and a list
  1012. * of unsigned 64-bit ints.
  1013. * @return {!Array<number>}
  1014. */
  1015. jspb.BinaryReader.prototype.readPackedFixed64 = function() {
  1016. return this.readPackedField_(this.decoder_.readUint64);
  1017. };
  1018. /**
  1019. * Reads a packed fixed64 field, which consists of a length header and a list
  1020. * of unsigned 64-bit ints. Returns a list of strings.
  1021. * @return {!Array<number>}
  1022. */
  1023. jspb.BinaryReader.prototype.readPackedFixed64String = function() {
  1024. return this.readPackedField_(this.decoder_.readUint64String);
  1025. };
  1026. /**
  1027. * Reads a packed sfixed32 field, which consists of a length header and a list
  1028. * of 32-bit ints.
  1029. * @return {!Array<number>}
  1030. */
  1031. jspb.BinaryReader.prototype.readPackedSfixed32 = function() {
  1032. return this.readPackedField_(this.decoder_.readInt32);
  1033. };
  1034. /**
  1035. * Reads a packed sfixed64 field, which consists of a length header and a list
  1036. * of 64-bit ints.
  1037. * @return {!Array<number>}
  1038. */
  1039. jspb.BinaryReader.prototype.readPackedSfixed64 = function() {
  1040. return this.readPackedField_(this.decoder_.readInt64);
  1041. };
  1042. /**
  1043. * Reads a packed sfixed64 field, which consists of a length header and a list
  1044. * of 64-bit ints. Returns a list of strings.
  1045. * @return {!Array<string>}
  1046. */
  1047. jspb.BinaryReader.prototype.readPackedSfixed64String = function() {
  1048. return this.readPackedField_(this.decoder_.readInt64String);
  1049. };
  1050. /**
  1051. * Reads a packed float field, which consists of a length header and a list of
  1052. * floats.
  1053. * @return {!Array<number>}
  1054. */
  1055. jspb.BinaryReader.prototype.readPackedFloat = function() {
  1056. return this.readPackedField_(this.decoder_.readFloat);
  1057. };
  1058. /**
  1059. * Reads a packed double field, which consists of a length header and a list of
  1060. * doubles.
  1061. * @return {!Array<number>}
  1062. */
  1063. jspb.BinaryReader.prototype.readPackedDouble = function() {
  1064. return this.readPackedField_(this.decoder_.readDouble);
  1065. };
  1066. /**
  1067. * Reads a packed bool field, which consists of a length header and a list of
  1068. * unsigned varints.
  1069. * @return {!Array<boolean>}
  1070. */
  1071. jspb.BinaryReader.prototype.readPackedBool = function() {
  1072. return this.readPackedField_(this.decoder_.readBool);
  1073. };
  1074. /**
  1075. * Reads a packed enum field, which consists of a length header and a list of
  1076. * unsigned varints.
  1077. * @return {!Array<number>}
  1078. */
  1079. jspb.BinaryReader.prototype.readPackedEnum = function() {
  1080. return this.readPackedField_(this.decoder_.readEnum);
  1081. };
  1082. /**
  1083. * Reads a packed varint hash64 field, which consists of a length header and a
  1084. * list of varint hash64s.
  1085. * @return {!Array<string>}
  1086. */
  1087. jspb.BinaryReader.prototype.readPackedVarintHash64 = function() {
  1088. return this.readPackedField_(this.decoder_.readVarintHash64);
  1089. };
  1090. /**
  1091. * Reads a packed fixed hash64 field, which consists of a length header and a
  1092. * list of fixed hash64s.
  1093. * @return {!Array<string>}
  1094. */
  1095. jspb.BinaryReader.prototype.readPackedFixedHash64 = function() {
  1096. return this.readPackedField_(this.decoder_.readFixedHash64);
  1097. };