| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 part of bindings; | 5 part of bindings; |
| 6 | 6 |
| 7 int align(int size) => size + (kAlignment - (size % kAlignment)) % kAlignment; | 7 int align(int size) => size + (kAlignment - (size % kAlignment)) % kAlignment; |
| 8 | 8 |
| 9 const int kAlignment = 8; | 9 const int kAlignment = 8; |
| 10 const int kSerializedHandleSize = 4; | 10 const int kSerializedHandleSize = 4; |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 result[boolIndex] = (bytes[i] & (1 << j)) != 0; | 690 result[boolIndex] = (bytes[i] & (1 << j)) != 0; |
| 691 } | 691 } |
| 692 } | 692 } |
| 693 } | 693 } |
| 694 return result; | 694 return result; |
| 695 } | 695 } |
| 696 | 696 |
| 697 ArrayDataHeader decodeDataHeaderForArray(int elementSize, | 697 ArrayDataHeader decodeDataHeaderForArray(int elementSize, |
| 698 int expectedLength) { | 698 int expectedLength) { |
| 699 var header = decodeArrayDataHeader(); | 699 var header = decodeArrayDataHeader(); |
| 700 var arrayByteCount = | 700 var arrayByteCount = |
| 701 ArrayDataHeader.kHeaderSize + header.numElements * elementSize; | 701 ArrayDataHeader.kHeaderSize + header.numElements * elementSize; |
| 702 if (header.size < arrayByteCount) { | 702 if (header.size < arrayByteCount) { |
| 703 throw new MojoCodecError( | 703 throw new MojoCodecError( |
| 704 'Array header is incorrect: $header, elementSize = $elementSize'); | 704 'Array header is incorrect: $header, elementSize = $elementSize'); |
| 705 } | 705 } |
| 706 if ((expectedLength != kUnspecifiedArrayLength) && | 706 if ((expectedLength != kUnspecifiedArrayLength) && |
| 707 (header.numElements != expectedLength)) { | 707 (header.numElements != expectedLength)) { |
| 708 throw new MojoCodecError( | 708 throw new MojoCodecError( |
| 709 'Incorrect array length. Expected $expectedLength, but got ' | 709 'Incorrect array length. Expected $expectedLength, but got ' |
| 710 '${header.numElements}'); | 710 '${header.numElements}'); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 throw new MojoCodecError( | 862 throw new MojoCodecError( |
| 863 'Incorrect header for map. The size is incorrect.'); | 863 'Incorrect header for map. The size is incorrect.'); |
| 864 } | 864 } |
| 865 if (header.version != kMapStructHeader.version) { | 865 if (header.version != kMapStructHeader.version) { |
| 866 throw new MojoCodecError( | 866 throw new MojoCodecError( |
| 867 'Incorrect header for map. The version is incorrect.'); | 867 'Incorrect header for map. The version is incorrect.'); |
| 868 } | 868 } |
| 869 return header; | 869 return header; |
| 870 } | 870 } |
| 871 } | 871 } |
| OLD | NEW |