OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 protoc; | 5 part of protoc; |
6 | 6 |
7 class EnumAlias { | 7 class EnumAlias { |
8 final EnumValueDescriptorProto value; | 8 final EnumValueDescriptorProto value; |
9 final EnumValueDescriptorProto canonicalValue; | 9 final EnumValueDescriptorProto canonicalValue; |
10 EnumAlias(this.value, this.canonicalValue); | 10 EnumAlias(this.value, this.canonicalValue); |
11 } | 11 } |
12 | 12 |
13 class EnumGenerator implements ProtobufContainer { | 13 class EnumGenerator extends ProtobufContainer { |
14 final ProtobufContainer _parent; | 14 final ProtobufContainer _parent; |
15 final String classname; | 15 final String classname; |
16 final String fqname; | 16 final String fqname; |
17 final List<EnumValueDescriptorProto> _canonicalValues = | 17 final List<EnumValueDescriptorProto> _canonicalValues = |
18 <EnumValueDescriptorProto>[]; | 18 <EnumValueDescriptorProto>[]; |
19 final List<EnumAlias> _aliases = <EnumAlias>[]; | 19 final List<EnumAlias> _aliases = <EnumAlias>[]; |
20 | 20 |
21 EnumGenerator( | 21 EnumGenerator( |
22 EnumDescriptorProto descriptor, | 22 EnumDescriptorProto descriptor, |
23 ProtobufContainer parent, | 23 ProtobufContainer parent, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 '${SP}ProtobufEnum.initByValue(values);'); | 73 '${SP}ProtobufEnum.initByValue(values);'); |
74 out.println('static ${classname} valueOf(int value)${SP}=>' | 74 out.println('static ${classname} valueOf(int value)${SP}=>' |
75 '${SP}_byValue[value];'); | 75 '${SP}_byValue[value];'); |
76 out.println(); | 76 out.println(); |
77 | 77 |
78 out.println('const ${classname}._(int v,${SP}String n)${SP}' | 78 out.println('const ${classname}._(int v,${SP}String n)${SP}' |
79 ':${SP}super(v,${SP}n);'); | 79 ':${SP}super(v,${SP}n);'); |
80 }); | 80 }); |
81 } | 81 } |
82 } | 82 } |
OLD | NEW |