Chromium Code Reviews| 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 ProtobufField { | 7 class ProtobufField { |
| 8 static final RegExp HEX_LITERAL_REGEX = | 8 static final RegExp HEX_LITERAL_REGEX = |
| 9 new RegExp(r'^0x[0-9a-f]+$', multiLine: false, caseSensitive: false); | 9 new RegExp(r'^0x[0-9a-f]+$', multiLine: false, caseSensitive: false); |
| 10 static final RegExp INTEGER_LITERAL_REGEX = new RegExp(r'^[+-]?[0-9]+$'); | 10 static final RegExp INTEGER_LITERAL_REGEX = new RegExp(r'^[+-]?[0-9]+$'); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 this.typeString, this.prefixedBaseType, this.prefixedTypeString, | 101 this.typeString, this.prefixedBaseType, this.prefixedTypeString, |
| 102 this.codedStreamType, this.repeats, | 102 this.codedStreamType, this.repeats, |
| 103 this.initialization, this.prefixedInitialization, this.required, | 103 this.initialization, this.prefixedInitialization, this.required, |
| 104 this.packed, this.packable) : | 104 this.packed, this.packable) : |
| 105 this._field = field, | 105 this._field = field, |
| 106 this.parent = parent, | 106 this.parent = parent, |
| 107 fqname = '${parent.fqname}.${field.name}'; | 107 fqname = '${parent.fqname}.${field.name}'; |
| 108 | 108 |
| 109 | 109 |
| 110 factory ProtobufField(FieldDescriptorProto field, | 110 factory ProtobufField(FieldDescriptorProto field, |
| 111 MessageGenerator parent, | 111 ProtobufContainer parent, |
|
Chris Bracken
2014/05/16 22:03:19
good catch!
| |
| 112 GenerationContext context) { | 112 GenerationContext context) { |
| 113 bool required = field.label == FieldDescriptorProto_Label.LABEL_REQUIRED; | 113 bool required = field.label == FieldDescriptorProto_Label.LABEL_REQUIRED; |
| 114 bool repeats = field.label == FieldDescriptorProto_Label.LABEL_REPEATED; | 114 bool repeats = field.label == FieldDescriptorProto_Label.LABEL_REPEATED; |
| 115 bool packed = false; | 115 bool packed = false; |
| 116 | 116 |
| 117 var write; | 117 var write; |
| 118 if (repeats) { | 118 if (repeats) { |
| 119 packed = field.options == null ? false : field.options.packed; | 119 packed = field.options == null ? false : field.options.packed; |
| 120 write = (String typeString) => 'List<$typeString>'; | 120 write = (String typeString) => 'List<$typeString>'; |
| 121 } else { | 121 } else { |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 | 365 |
| 366 // For groups, use capitalization of 'typeName' rather than 'name'. | 366 // For groups, use capitalization of 'typeName' rather than 'name'. |
| 367 if (codedStreamType == 'Group') { | 367 if (codedStreamType == 'Group') { |
| 368 String name = _field.typeName; | 368 String name = _field.typeName; |
| 369 int index = name.lastIndexOf('.'); | 369 int index = name.lastIndexOf('.'); |
| 370 if (index != -1) { | 370 if (index != -1) { |
| 371 name = name.substring(index + 1); | 371 name = name.substring(index + 1); |
| 372 } | 372 } |
| 373 return underscoresToCamelCase(name); | 373 return underscoresToCamelCase(name); |
| 374 } | 374 } |
| 375 var name = context.options.fieldNameOption(fqname); | 375 var name = context.options.fieldNameOverrides[fqname]; |
| 376 return (name != null) ? name : underscoresToCamelCase(_field.name); | 376 return name != null ? name : underscoresToCamelCase(_field.name); |
| 377 } | 377 } |
| 378 | 378 |
| 379 int get wireType { | 379 int get wireType { |
| 380 switch (_field.type) { | 380 switch (_field.type) { |
| 381 case FieldDescriptorProto_Type.TYPE_INT32: | 381 case FieldDescriptorProto_Type.TYPE_INT32: |
| 382 case FieldDescriptorProto_Type.TYPE_INT64: | 382 case FieldDescriptorProto_Type.TYPE_INT64: |
| 383 case FieldDescriptorProto_Type.TYPE_UINT32: | 383 case FieldDescriptorProto_Type.TYPE_UINT32: |
| 384 case FieldDescriptorProto_Type.TYPE_UINT64: | 384 case FieldDescriptorProto_Type.TYPE_UINT64: |
| 385 case FieldDescriptorProto_Type.TYPE_SINT32: | 385 case FieldDescriptorProto_Type.TYPE_SINT32: |
| 386 case FieldDescriptorProto_Type.TYPE_SINT64: | 386 case FieldDescriptorProto_Type.TYPE_SINT64: |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 397 return 2; // Length-delimited | 397 return 2; // Length-delimited |
| 398 case FieldDescriptorProto_Type.TYPE_GROUP: | 398 case FieldDescriptorProto_Type.TYPE_GROUP: |
| 399 return 3; // Start group | 399 return 3; // Start group |
| 400 case FieldDescriptorProto_Type.TYPE_FLOAT: | 400 case FieldDescriptorProto_Type.TYPE_FLOAT: |
| 401 case FieldDescriptorProto_Type.TYPE_FIXED32: | 401 case FieldDescriptorProto_Type.TYPE_FIXED32: |
| 402 case FieldDescriptorProto_Type.TYPE_SFIXED32: | 402 case FieldDescriptorProto_Type.TYPE_SFIXED32: |
| 403 return 5; // 32-bit | 403 return 5; // 32-bit |
| 404 } | 404 } |
| 405 } | 405 } |
| 406 } | 406 } |
| OLD | NEW |