| 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @constructor | 8 * @constructor |
| 9 * @param {ArrayBuffer} arrayBuffer An array of buffers to be read from. | 9 * @param {ArrayBuffer} arrayBuffer An array of buffers to be read from. |
| 10 * @param {number=} opt_offset Offset to read bytes at. | 10 * @param {number=} opt_offset Offset to read bytes at. |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 * You may optionally pass opt_end to override what is considered to be the | 298 * You may optionally pass opt_end to override what is considered to be the |
| 299 * end of the buffer. | 299 * end of the buffer. |
| 300 * | 300 * |
| 301 * @param {number} size Number of bytes to read. | 301 * @param {number} size Number of bytes to read. |
| 302 * @param {number=} opt_end Maximum position to read from. | 302 * @param {number=} opt_end Maximum position to read from. |
| 303 */ | 303 */ |
| 304 ByteReader.prototype.validateRead = function(size, opt_end) { | 304 ByteReader.prototype.validateRead = function(size, opt_end) { |
| 305 if (typeof opt_end == 'undefined') | 305 if (typeof opt_end == 'undefined') |
| 306 opt_end = this.view_.byteLength; | 306 opt_end = this.view_.byteLength; |
| 307 | 307 |
| 308 ByteReader.validateRead(this.view_, this.pos_, size, opt_end); | 308 ByteReader.validateRead(this.pos_, size, opt_end); |
| 309 }; | 309 }; |
| 310 | 310 |
| 311 /** | 311 /** |
| 312 * @param {number} width Number of bytes to read. | 312 * @param {number} width Number of bytes to read. |
| 313 * @param {boolean=} opt_signed True if signed, false otherwise. | 313 * @param {boolean=} opt_signed True if signed, false otherwise. |
| 314 * @param {number=} opt_end Maximum position to read from. | 314 * @param {number=} opt_end Maximum position to read from. |
| 315 * @return {string} Scalar value. | 315 * @return {string} Scalar value. |
| 316 */ | 316 */ |
| 317 ByteReader.prototype.readScalar = function(width, opt_signed, opt_end) { | 317 ByteReader.prototype.readScalar = function(width, opt_signed, opt_end) { |
| 318 var method = opt_signed ? 'getInt' : 'getUint'; | 318 var method = opt_signed ? 'getInt' : 'getUint'; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 * @param {number=} opt_end Maximum position to read from. | 432 * @param {number=} opt_end Maximum position to read from. |
| 433 * @param {function(new:Array.<*>)=} opt_arrayConstructor Array constructor. | 433 * @param {function(new:Array.<*>)=} opt_arrayConstructor Array constructor. |
| 434 * @return {Array.<*>} Array of bytes. | 434 * @return {Array.<*>} Array of bytes. |
| 435 */ | 435 */ |
| 436 ByteReader.prototype.readSlice = function(size, opt_end, | 436 ByteReader.prototype.readSlice = function(size, opt_end, |
| 437 opt_arrayConstructor) { | 437 opt_arrayConstructor) { |
| 438 this.validateRead(size, opt_end); | 438 this.validateRead(size, opt_end); |
| 439 | 439 |
| 440 var arrayConstructor = opt_arrayConstructor || Uint8Array; | 440 var arrayConstructor = opt_arrayConstructor || Uint8Array; |
| 441 var slice = new arrayConstructor( | 441 var slice = new arrayConstructor( |
| 442 this.view_.buffer, this.view_.byteOffset + this.pos, size); | 442 this.view_.buffer, this.view_.byteOffset + this.pos_, size); |
| 443 this.pos_ += size; | 443 this.pos_ += size; |
| 444 | 444 |
| 445 return slice; | 445 return slice; |
| 446 }; | 446 }; |
| 447 | 447 |
| 448 /** | 448 /** |
| 449 * Read as a sequence of bytes, returning them as a single base64 encoded | 449 * Read as a sequence of bytes, returning them as a single base64 encoded |
| 450 * string. | 450 * string. |
| 451 * | 451 * |
| 452 * Adjusts the current position on success. Throws an exception if the | 452 * Adjusts the current position on success. Throws an exception if the |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 this.seek(this.seekStack_.pop()); | 526 this.seek(this.seekStack_.pop()); |
| 527 }; | 527 }; |
| 528 | 528 |
| 529 /** | 529 /** |
| 530 * Return the current read position. | 530 * Return the current read position. |
| 531 * @return {number} Current position in bytes. | 531 * @return {number} Current position in bytes. |
| 532 */ | 532 */ |
| 533 ByteReader.prototype.tell = function() { | 533 ByteReader.prototype.tell = function() { |
| 534 return this.pos_; | 534 return this.pos_; |
| 535 }; | 535 }; |
| OLD | NEW |