Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

Commit

Permalink
Use real generic syntax instead of comment-based. (#89)
Browse files Browse the repository at this point in the history
Also update pubspec to support v2 dev SDKs.
  • Loading branch information
jakobr-google authored Aug 14, 2017
1 parent 4721de8 commit 3889290
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 152 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.7.5 - 2017-08-04

* Use real generic syntax instead of comment-based.
* Support 2.0.0 dev SDKs.

## 0.7.4 - 2017-07-07

* Added call options to gRPC client stubs.
Expand Down
10 changes: 5 additions & 5 deletions lib/protobuf_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,24 +106,24 @@ class ProtobufField {

if (isRepeated) {
if (baseType.isMessage || baseType.isGroup) {
return '..pp/*<$type>*/($number, $quotedName, $typeConstant,'
return '..pp<$type>($number, $quotedName, $typeConstant,'
' $type.$checkItem, $type.create)';
} else if (baseType.isEnum) {
return '..pp/*<$type>*/($number, $quotedName, $typeConstant,'
return '..pp<$type>($number, $quotedName, $typeConstant,'
' $type.$checkItem, null, $type.valueOf)';
} else {
return '..p/*<$type>*/($number, $quotedName, $typeConstant)';
return '..p<$type>($number, $quotedName, $typeConstant)';
}
}

String makeDefault = generateDefaultFunction(package);
if (baseType.isEnum) {
String valueOf = '$type.valueOf';
return '..e/*<$type>*/('
return '..e<$type>('
'$number, $quotedName, $typeConstant, $makeDefault, $valueOf)';
}

String prefix = '..a/*<$type>*/($number, $quotedName, $typeConstant';
String prefix = '..a<$type>($number, $quotedName, $typeConstant';
if (makeDefault == null) return prefix + ')';

if (baseType.isMessage || baseType.isGroup) {
Expand Down
8 changes: 4 additions & 4 deletions lib/src/dart_options.pb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import 'package:protobuf/protobuf.dart';

class DartMixin extends GeneratedMessage {
static final BuilderInfo _i = new BuilderInfo('DartMixin')
..a/*<String>*/(1, 'name', PbFieldType.OS)
..a/*<String>*/(2, 'importFrom', PbFieldType.OS)
..a/*<String>*/(3, 'parent', PbFieldType.OS)
..a<String>(1, 'name', PbFieldType.OS)
..a<String>(2, 'importFrom', PbFieldType.OS)
..a<String>(3, 'parent', PbFieldType.OS)
..hasRequiredFields = false;

DartMixin() : super();
Expand Down Expand Up @@ -66,7 +66,7 @@ class _ReadonlyDartMixin extends DartMixin with ReadonlyMessageMixin {}

class Imports extends GeneratedMessage {
static final BuilderInfo _i = new BuilderInfo('Imports')
..pp/*<DartMixin>*/(
..pp<DartMixin>(
1, 'mixins', PbFieldType.PM, DartMixin.$checkItem, DartMixin.create)
..hasRequiredFields = false;

Expand Down
236 changes: 118 additions & 118 deletions lib/src/descriptor.pb.dart

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions lib/src/plugin.pb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import 'descriptor.pb.dart' as google$protobuf;

class Version extends GeneratedMessage {
static final BuilderInfo _i = new BuilderInfo('Version')
..a/*<int>*/(1, 'major', PbFieldType.O3)
..a/*<int>*/(2, 'minor', PbFieldType.O3)
..a/*<int>*/(3, 'patch', PbFieldType.O3)
..a/*<String>*/(4, 'suffix', PbFieldType.OS)
..a<int>(1, 'major', PbFieldType.O3)
..a<int>(2, 'minor', PbFieldType.O3)
..a<int>(3, 'patch', PbFieldType.O3)
..a<String>(4, 'suffix', PbFieldType.OS)
..hasRequiredFields = false;

Version() : super();
Expand Down Expand Up @@ -77,11 +77,11 @@ class _ReadonlyVersion extends Version with ReadonlyMessageMixin {}

class CodeGeneratorRequest extends GeneratedMessage {
static final BuilderInfo _i = new BuilderInfo('CodeGeneratorRequest')
..p/*<String>*/(1, 'fileToGenerate', PbFieldType.PS)
..a/*<String>*/(2, 'parameter', PbFieldType.OS)
..a/*<Version>*/(3, 'compilerVersion', PbFieldType.OM, Version.getDefault,
..p<String>(1, 'fileToGenerate', PbFieldType.PS)
..a<String>(2, 'parameter', PbFieldType.OS)
..a<Version>(3, 'compilerVersion', PbFieldType.OM, Version.getDefault,
Version.create)
..pp/*<google$protobuf.FileDescriptorProto>*/(
..pp<google$protobuf.FileDescriptorProto>(
15,
'protoFile',
PbFieldType.PM,
Expand Down Expand Up @@ -138,9 +138,9 @@ class _ReadonlyCodeGeneratorRequest extends CodeGeneratorRequest

class CodeGeneratorResponse_File extends GeneratedMessage {
static final BuilderInfo _i = new BuilderInfo('CodeGeneratorResponse_File')
..a/*<String>*/(1, 'name', PbFieldType.OS)
..a/*<String>*/(2, 'insertionPoint', PbFieldType.OS)
..a/*<String>*/(15, 'content', PbFieldType.OS)
..a<String>(1, 'name', PbFieldType.OS)
..a<String>(2, 'insertionPoint', PbFieldType.OS)
..a<String>(15, 'content', PbFieldType.OS)
..hasRequiredFields = false;

CodeGeneratorResponse_File() : super();
Expand Down Expand Up @@ -199,8 +199,8 @@ class _ReadonlyCodeGeneratorResponse_File extends CodeGeneratorResponse_File

class CodeGeneratorResponse extends GeneratedMessage {
static final BuilderInfo _i = new BuilderInfo('CodeGeneratorResponse')
..a/*<String>*/(1, 'error', PbFieldType.OS)
..pp/*<CodeGeneratorResponse_File>*/(
..a<String>(1, 'error', PbFieldType.OS)
..pp<CodeGeneratorResponse_File>(
15,
'file',
PbFieldType.PM,
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: protoc_plugin
version: 0.7.4
version: 0.7.5
author: Dart Team <[email protected]>
description: Protoc compiler plugin to generate Dart code
homepage: https://github.com/dart-lang/dart-protoc-plugin
environment:
sdk: '>=1.13.0 <2.0.0'
sdk: '>=1.21.0 <2.0.0-dev.infinity'
dependencies:
fixnum: ^0.10.5
path: ^1.0.0
protobuf: ^0.5.4
protobuf: ^0.5.5
dart_style: ^1.0.6
dev_dependencies:
browser: any
Expand Down
12 changes: 6 additions & 6 deletions test/file_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ import 'package:protobuf/protobuf.dart';
class PhoneNumber extends GeneratedMessage {
static final BuilderInfo _i = new BuilderInfo('PhoneNumber')
..a/*<String>*/(1, 'number', PbFieldType.QS)
..a/*<int>*/(2, 'type', PbFieldType.O3)
..a/*<String>*/(3, 'name', PbFieldType.OS, '\$')
..a<String>(1, 'number', PbFieldType.QS)
..a<int>(2, 'type', PbFieldType.O3)
..a<String>(3, 'name', PbFieldType.OS, '\$')
;
PhoneNumber() : super();
Expand Down Expand Up @@ -693,9 +693,9 @@ import 'package2.pb.dart' as p2;
class M extends GeneratedMessage {
static final BuilderInfo _i = new BuilderInfo('M')
..a/*<M>*/(1, 'm', PbFieldType.OM, M.getDefault, M.create)
..a/*<p1.M>*/(2, 'm1', PbFieldType.OM, p1.M.getDefault, p1.M.create)
..a/*<p2.M>*/(3, 'm2', PbFieldType.OM, p2.M.getDefault, p2.M.create)
..a<M>(1, 'm', PbFieldType.OM, M.getDefault, M.create)
..a<p1.M>(2, 'm1', PbFieldType.OM, p1.M.getDefault, p1.M.create)
..a<p2.M>(3, 'm2', PbFieldType.OM, p2.M.getDefault, p2.M.create)
..hasRequiredFields = false
;
Expand Down
6 changes: 3 additions & 3 deletions test/message_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class PhoneNumber_PhoneType extends ProtobufEnum {
String expected = r'''
class PhoneNumber extends GeneratedMessage {
static final BuilderInfo _i = new BuilderInfo('PhoneNumber')
..a/*<String>*/(1, 'number', PbFieldType.QS)
..e/*<PhoneNumber_PhoneType>*/(2, 'type', PbFieldType.OE, PhoneNumber_PhoneType.MOBILE, PhoneNumber_PhoneType.valueOf)
..a/*<String>*/(3, 'name', PbFieldType.OS, '\$')
..a<String>(1, 'number', PbFieldType.QS)
..e<PhoneNumber_PhoneType>(2, 'type', PbFieldType.OE, PhoneNumber_PhoneType.MOBILE, PhoneNumber_PhoneType.valueOf)
..a<String>(3, 'name', PbFieldType.OS, '\$')
;
PhoneNumber() : super();
Expand Down

0 comments on commit 3889290

Please sign in to comment.