| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** |
| 6 * @constructor |
| 7 * @param {ArrayBuffer} arrayBuffer //TODO(JSDOC). |
| 8 * @param {number=} opt_offset //TODO(JSDOC). |
| 9 * @param {number=} opt_length //TODO(JSDOC). |
| 10 */ |
| 5 function ByteReader(arrayBuffer, opt_offset, opt_length) { | 11 function ByteReader(arrayBuffer, opt_offset, opt_length) { |
| 6 opt_offset = opt_offset || 0; | 12 opt_offset = opt_offset || 0; |
| 7 opt_length = opt_length || (arrayBuffer.byteLength - opt_offset); | 13 opt_length = opt_length || (arrayBuffer.byteLength - opt_offset); |
| 8 this.view_ = new DataView(arrayBuffer, opt_offset, opt_length); | 14 this.view_ = new DataView(arrayBuffer, opt_offset, opt_length); |
| 9 this.pos_ = 0; | 15 this.pos_ = 0; |
| 10 this.seekStack_ = []; | 16 this.seekStack_ = []; |
| 11 this.setByteOrder(ByteReader.BIG_ENDIAN); | 17 this.setByteOrder(ByteReader.BIG_ENDIAN); |
| 12 } | 18 } |
| 13 | 19 |
| 14 // Static const and methods. | 20 // Static constants and methods. |
| 15 | 21 |
| 16 /** | 22 /** |
| 17 * Intel, 0x1234 is [0x34, 0x12] | 23 * Intel, 0x1234 is [0x34, 0x12] |
| 18 * @const | 24 * @const |
| 19 * @type {number} | 25 * @type {number} |
| 20 */ | 26 */ |
| 21 ByteReader.LITTLE_ENDIAN = 0; | 27 ByteReader.LITTLE_ENDIAN = 0; |
| 22 /** | 28 /** |
| 23 * Motorola, 0x1234 is [0x12, 0x34] | 29 * Motorola, 0x1234 is [0x12, 0x34] |
| 24 * @const | 30 * @const |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 this.seek(this.seekStack_.pop()); | 524 this.seek(this.seekStack_.pop()); |
| 519 }; | 525 }; |
| 520 | 526 |
| 521 /** | 527 /** |
| 522 * Return the current read position. | 528 * Return the current read position. |
| 523 * @return {number} //TODO(JSDOC). | 529 * @return {number} //TODO(JSDOC). |
| 524 */ | 530 */ |
| 525 ByteReader.prototype.tell = function() { | 531 ByteReader.prototype.tell = function() { |
| 526 return this.pos_; | 532 return this.pos_; |
| 527 }; | 533 }; |
| OLD | NEW |