| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of protobuf; | 5 part of protobuf; |
| 6 | 6 |
| 7 /// All the data in a GeneratedMessage. | 7 /// All the data in a GeneratedMessage. |
| 8 /// | 8 /// |
| 9 /// These fields and methods are in a separate class to avoid | 9 /// These fields and methods are in a separate class to avoid |
| 10 /// polymorphic access due to inheritance. This turns out to | 10 /// polymorphic access due to inheritance. This turns out to |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 } | 354 } |
| 355 | 355 |
| 356 /// Calculates a hash code based on the contents of the protobuf. | 356 /// Calculates a hash code based on the contents of the protobuf. |
| 357 /// | 357 /// |
| 358 /// The hash may change when any field changes (recursively). | 358 /// The hash may change when any field changes (recursively). |
| 359 /// Therefore, protobufs used as map keys shouldn't be changed. | 359 /// Therefore, protobufs used as map keys shouldn't be changed. |
| 360 int get _hashCode { | 360 int get _hashCode { |
| 361 int hash; | 361 int hash; |
| 362 | 362 |
| 363 void hashEnumList(PbList enums) { | 363 void hashEnumList(PbList enums) { |
| 364 for (final enm in enums) { | 364 for (ProtobufEnum enm in enums) { |
| 365 hash = (31 * hash + enm.value) & 0x3fffffff; | 365 hash = (31 * hash + enm.value) & 0x3fffffff; |
| 366 } | 366 } |
| 367 } | 367 } |
| 368 | 368 |
| 369 // Hashes the value of one field (recursively). | 369 // Hashes the value of one field (recursively). |
| 370 void hashField(FieldInfo fi, value) { | 370 void hashField(FieldInfo fi, value) { |
| 371 if (value is List && value.isEmpty) { | 371 if (value is List && value.isEmpty) { |
| 372 return; // It's either repeated or an empty byte array. | 372 return; // It's either repeated or an empty byte array. |
| 373 } | 373 } |
| 374 hash = ((37 * hash) + fi.tagNumber) & 0x3fffffff; | 374 hash = ((37 * hash) + fi.tagNumber) & 0x3fffffff; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 void _appendInvalidFields(List<String> problems, String prefix) { | 552 void _appendInvalidFields(List<String> problems, String prefix) { |
| 553 if (!_hasRequiredFields) return; | 553 if (!_hasRequiredFields) return; |
| 554 for (var fi in _infos) { | 554 for (var fi in _infos) { |
| 555 var value = _values[fi.index]; | 555 var value = _values[fi.index]; |
| 556 fi._appendInvalidFields(problems, value, prefix); | 556 fi._appendInvalidFields(problems, value, prefix); |
| 557 } | 557 } |
| 558 // TODO(skybrian): search extensions as well | 558 // TODO(skybrian): search extensions as well |
| 559 // https://github.com/dart-lang/dart-protobuf/issues/46 | 559 // https://github.com/dart-lang/dart-protobuf/issues/46 |
| 560 } | 560 } |
| 561 } | 561 } |
| OLD | NEW |