OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 * Per-message type setup. | 8 * Per-message type setup. |
9 */ | 9 */ |
10 class BuilderInfo { | 10 class BuilderInfo { |
11 final String messageName; | 11 final String messageName; |
12 final Map<int, FieldInfo> fieldInfo = new Map<int, FieldInfo>(); | 12 final Map<int, FieldInfo> fieldInfo = new Map<int, FieldInfo>(); |
13 final Map<String, FieldInfo> byName = <String, FieldInfo>{}; | 13 final Map<String, FieldInfo> byName = <String, FieldInfo>{}; |
14 bool hasExtensions = false; | 14 bool hasExtensions = false; |
15 bool hasRequiredFields = true; | 15 bool hasRequiredFields = true; |
16 | 16 |
17 BuilderInfo(this.messageName); | 17 BuilderInfo(this.messageName); |
18 | 18 |
19 void add(int tagNumber, String name, int fieldType, | 19 void add(int tagNumber, String name, int fieldType, |
20 MakeDefaultFunc makeDefault, | 20 dynamic defaultOrMaker, |
21 CreateBuilderFunc subBuilder, | 21 CreateBuilderFunc subBuilder, |
22 ValueOfFunc valueOf) { | 22 ValueOfFunc valueOf) { |
23 fieldInfo[tagNumber] = byName[name] = new FieldInfo( | 23 fieldInfo[tagNumber] = byName[name] = new FieldInfo( |
24 name, tagNumber, fieldType, makeDefault, subBuilder, valueOf); | 24 name, tagNumber, fieldType, defaultOrMaker, subBuilder, valueOf); |
25 } | 25 } |
26 | 26 |
27 void a(int tagNumber, String name, int fieldType, | 27 void a(int tagNumber, String name, int fieldType, |
28 [MakeDefaultFunc makeDefault, | 28 [dynamic defaultOrMaker, |
29 CreateBuilderFunc subBuilder, | 29 CreateBuilderFunc subBuilder, |
30 ValueOfFunc valueOf]) { | 30 ValueOfFunc valueOf]) { |
31 add(tagNumber, name, fieldType, | 31 add(tagNumber, name, fieldType, |
32 makeDefault, subBuilder, valueOf); | 32 defaultOrMaker, subBuilder, valueOf); |
33 } | 33 } |
34 | 34 |
35 // Enum. | 35 // Enum. |
36 void e(int tagNumber, String name, int fieldType, | 36 void e(int tagNumber, String name, int fieldType, |
37 MakeDefaultFunc makeDefault, ValueOfFunc valueOf) { | 37 dynamic defaultOrMaker, ValueOfFunc valueOf) { |
38 add(tagNumber, name, fieldType, | 38 add(tagNumber, name, fieldType, |
39 makeDefault, null, valueOf); | 39 defaultOrMaker, null, valueOf); |
40 } | 40 } |
41 | 41 |
42 // Repeated message. | 42 // Repeated message. |
43 // TODO(antonm): change the order of CreateBuilderFunc and MakeDefaultFunc. | 43 // TODO(antonm): change the order of CreateBuilderFunc and MakeDefaultFunc. |
44 void m(int tagNumber, String name, | 44 void m(int tagNumber, String name, |
45 CreateBuilderFunc subBuilder, MakeDefaultFunc makeDefault) { | 45 CreateBuilderFunc subBuilder, MakeDefaultFunc makeDefault) { |
46 add(tagNumber, name, GeneratedMessage._REPEATED_MESSAGE, | 46 add(tagNumber, name, GeneratedMessage._REPEATED_MESSAGE, |
47 makeDefault, subBuilder, null); | 47 makeDefault, subBuilder, null); |
48 } | 48 } |
49 | 49 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 } else if((fieldType & GeneratedMessage._REQUIRED_BIT) != 0) { | 224 } else if((fieldType & GeneratedMessage._REQUIRED_BIT) != 0) { |
225 // Required 'primitive' must be present. | 225 // Required 'primitive' must be present. |
226 if (fieldValues[tagNumber] == null) { | 226 if (fieldValues[tagNumber] == null) { |
227 invalidFields.add('${prefix}${field.name}'); | 227 invalidFields.add('${prefix}${field.name}'); |
228 } | 228 } |
229 } | 229 } |
230 }); | 230 }); |
231 return invalidFields; | 231 return invalidFields; |
232 } | 232 } |
233 } | 233 } |
OLD | NEW |