Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: lib/protobuf_field.dart

Issue 269823003: Parameterize uri resolution and parsing of options, use package:path (Closed) Base URL: git@github.com:dart-lang/dart-protoc-plugin.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/output_config.dart ('k') | lib/protoc.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 }
OLDNEW
« no previous file with comments | « lib/output_config.dart ('k') | lib/protoc.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698