Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** | 7 /** |
| 8 * An object representing a protobuf message field. | 8 * An object representing a protobuf message field. |
| 9 */ | 9 */ |
| 10 class FieldInfo { | 10 class FieldInfo { |
| 11 final String name; | 11 final String name; |
| 12 final int tagNumber; | 12 final int tagNumber; |
| 13 final int type; | 13 final int type; |
| 14 final MakeDefaultFunc makeDefault; | 14 final MakeDefaultFunc makeDefault; |
| 15 final CreateBuilderFunc subBuilder; | 15 final CreateBuilderFunc subBuilder; |
| 16 final ValueOfFunc valueOf; | 16 final ValueOfFunc valueOf; |
| 17 | 17 |
| 18 FieldInfo(this.name, this.tagNumber, int type, | 18 FieldInfo(this.name, this.tagNumber, int type, |
| 19 [MakeDefaultFunc makeDefault, | 19 [dynamic defaultOrMaker, |
| 20 this.subBuilder, | 20 this.subBuilder, |
| 21 this.valueOf]) | 21 this.valueOf]) |
| 22 : this.type = type, | 22 : this.type = type, |
| 23 this.makeDefault = makeDefault == null ? | 23 this.makeDefault = findMakeDefault(type, defaultOrMaker); |
| 24 GeneratedMessage._defaultForType(type) : makeDefault; | 24 |
| 25 static MakeDefaultFunc findMakeDefault(int type, dynamic defaultOrMaker) { | |
| 26 if (defaultOrMaker == null) return GeneratedMessage._defaultForType(type); | |
| 27 if (defaultOrMaker is Function) return defaultOrMaker; | |
|
Siggi Cherem (dart-lang)
2014/12/19 21:53:38
is Function => is MakeDefaultFunc ?
| |
| 28 return () => defaultOrMaker; | |
| 29 } | |
| 25 | 30 |
| 26 String toString() => name; | 31 String toString() => name; |
| 27 } | 32 } |
| OLD | NEW |