| 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) => | 7 int align(int size) => |
| 8 size + ((kAlignment - (size & kAlignmentMask)) & kAlignmentMask); | 8 size + ((kAlignment - (size & kAlignmentMask)) & kAlignmentMask); |
| 9 | 9 |
| 10 const int kAlignment = 8; | 10 const int kAlignment = 8; |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 if ((boolIndex < value.length) && value[boolIndex]) { | 344 if ((boolIndex < value.length) && value[boolIndex]) { |
| 345 bytes[i] |= (1 << j); | 345 bytes[i] |= (1 << j); |
| 346 } | 346 } |
| 347 } | 347 } |
| 348 } | 348 } |
| 349 var encoder = | 349 var encoder = |
| 350 encoderForArrayByTotalSize(bytes.length, value.length, offset); | 350 encoderForArrayByTotalSize(bytes.length, value.length, offset); |
| 351 encoder.appendUint8Array(bytes); | 351 encoder.appendUint8Array(bytes); |
| 352 } | 352 } |
| 353 | 353 |
| 354 void encodeArray(Function arrayAppend, int elementBytes, List<int> value, | 354 void encodeArray(Function arrayAppend, int elementBytes, List value, |
| 355 int offset, int nullability, int expectedLength) { | 355 int offset, int nullability, int expectedLength) { |
| 356 if (value == null) { | 356 if (value == null) { |
| 357 encodeNullPointer(offset, isArrayNullable(nullability)); | 357 encodeNullPointer(offset, isArrayNullable(nullability)); |
| 358 return; | 358 return; |
| 359 } | 359 } |
| 360 var encoder = | 360 var encoder = |
| 361 encoderForArray(elementBytes, value.length, offset, expectedLength); | 361 encoderForArray(elementBytes, value.length, offset, expectedLength); |
| 362 arrayAppend(encoder, value); | 362 arrayAppend(encoder, value); |
| 363 } | 363 } |
| 364 | 364 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 List<int> value, int offset, int nullability, int expectedLength) => | 396 List<int> value, int offset, int nullability, int expectedLength) => |
| 397 encodeArray((e, v) => e.appendInt64Array(v), 8, value, offset, | 397 encodeArray((e, v) => e.appendInt64Array(v), 8, value, offset, |
| 398 nullability, expectedLength); | 398 nullability, expectedLength); |
| 399 | 399 |
| 400 void encodeUint64Array( | 400 void encodeUint64Array( |
| 401 List<int> value, int offset, int nullability, int expectedLength) => | 401 List<int> value, int offset, int nullability, int expectedLength) => |
| 402 encodeArray((e, v) => e.appendUint64Array(v), 8, value, offset, | 402 encodeArray((e, v) => e.appendUint64Array(v), 8, value, offset, |
| 403 nullability, expectedLength); | 403 nullability, expectedLength); |
| 404 | 404 |
| 405 void encodeFloatArray( | 405 void encodeFloatArray( |
| 406 List<int> value, int offset, int nullability, int expectedLength) => | 406 List<double> value, int offset, int nullability, |
| 407 int expectedLength) => |
| 407 encodeArray((e, v) => e.appendFloatArray(v), 4, value, offset, | 408 encodeArray((e, v) => e.appendFloatArray(v), 4, value, offset, |
| 408 nullability, expectedLength); | 409 nullability, expectedLength); |
| 409 | 410 |
| 410 void encodeDoubleArray( | 411 void encodeDoubleArray( |
| 411 List<int> value, int offset, int nullability, int expectedLength) => | 412 List<double> value, int offset, int nullability, |
| 413 int expectedLength) => |
| 412 encodeArray((e, v) => e.appendDoubleArray(v), 8, value, offset, | 414 encodeArray((e, v) => e.appendDoubleArray(v), 8, value, offset, |
| 413 nullability, expectedLength); | 415 nullability, expectedLength); |
| 414 | 416 |
| 415 void _handleArrayEncodeHelper(Function elementEncoder, List value, int offset, | 417 void _handleArrayEncodeHelper(Function elementEncoder, List value, int offset, |
| 416 int elementSize, int nullability, int expectedLength) { | 418 int elementSize, int nullability, int expectedLength) { |
| 417 if (value == null) { | 419 if (value == null) { |
| 418 encodeNullPointer(offset, isArrayNullable(nullability)); | 420 encodeNullPointer(offset, isArrayNullable(nullability)); |
| 419 return; | 421 return; |
| 420 } | 422 } |
| 421 var encoder = | 423 var encoder = |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 throw new MojoCodecError( | 1100 throw new MojoCodecError( |
| 1099 'Incorrect header for map. The size is incorrect.'); | 1101 'Incorrect header for map. The size is incorrect.'); |
| 1100 } | 1102 } |
| 1101 if (header.version != kMapStructHeader.version) { | 1103 if (header.version != kMapStructHeader.version) { |
| 1102 throw new MojoCodecError( | 1104 throw new MojoCodecError( |
| 1103 'Incorrect header for map. The version is incorrect.'); | 1105 'Incorrect header for map. The version is incorrect.'); |
| 1104 } | 1106 } |
| 1105 return header; | 1107 return header; |
| 1106 } | 1108 } |
| 1107 } | 1109 } |
| OLD | NEW |