reader.js 39 KB

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