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

Commit a957cb2

Browse files
Dart 2 fixes. (#106)
* Breaking change: Generated RpcClient stubs use the generic invoke method. Requires package:protobuf version 0.8.0 or newer. * Dart 2 fixes.
1 parent 8289fd1 commit a957cb2

13 files changed

Lines changed: 51 additions & 34 deletions

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ sudo: false
55
# them against each Dart version.
66
matrix:
77
include:
8-
- dart: stable
8+
- dart: dev
99
dart_task: dartfmt
10-
- dart: stable
10+
- dart: dev
1111
env: PROTOC_VERSION=3.0.0
1212
install: ./tool/travis/setup.sh
1313
script: ./tool/travis/test.sh

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.8.0 - 2018-05-17
2+
3+
* Breaking change: Generated RpcClient stubs use the generic invoke method.
4+
Requires package:protobuf version 0.8.0 or newer.
5+
* Dart 2 fixes.
6+
17
## 0.7.11 - 2018-04-09
28

39
* Dart 2 fix.

benchmark/lib/report.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
library protoc.benchmark.report;
66

7-
import 'dart:convert' show JSON;
7+
import 'dart:convert' show jsonEncode;
88

99
import 'generated/benchmark.pb.dart' as pb;
1010

@@ -159,15 +159,15 @@ String _stringifyMap(StringBuffer out, Map json, String indent) {
159159

160160
var value = json[key];
161161
out.write(childIndent);
162-
out.write(JSON.encode(key));
162+
out.write(jsonEncode(key));
163163
out.write(": ");
164164

165165
if (value is List) {
166166
_stringifyList(out, value, childIndent);
167167
} else if (value is Map && indent.length < 4) {
168168
_stringifyMap(out, value, childIndent);
169169
} else {
170-
out.write(JSON.encode(value));
170+
out.write(jsonEncode(value));
171171
}
172172
}
173173
out.write("\n$indent}");
@@ -182,7 +182,7 @@ void _stringifyList(StringBuffer out, List json, String indent) {
182182
if (!first) out.write(",\n");
183183
first = false;
184184
out.write(childIndent);
185-
out.write(JSON.encode(item));
185+
out.write(jsonEncode(item));
186186
}
187187
out.write("\n$indent]");
188188
}

lib/base_type.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class BaseType {
7070
"double", r"$_setDouble", null);
7171
case FieldDescriptorProto_Type.TYPE_INT32:
7272
return const BaseType._raw(FieldDescriptorProto_Type.TYPE_INT32, "3",
73-
"int", r"$_setUnsignedInt32", null);
73+
"int", r"$_setSignedInt32", null);
7474
case FieldDescriptorProto_Type.TYPE_UINT32:
7575
return const BaseType._raw(FieldDescriptorProto_Type.TYPE_UINT32, "U3",
7676
"int", r"$_setUnsignedInt32", null);

lib/client_generator.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class ClientApiGenerator {
3737
'ClientContext ctx, $inputType request) {',
3838
'}', () {
3939
out.println('var emptyResponse = new $outputType();');
40-
out.println('return _client.invoke(ctx, \'${service._descriptor.name}\', '
40+
out.println(
41+
'return _client.invoke<$outputType>(ctx, \'${service._descriptor.name}\', '
4142
'\'${m.name}\', request, emptyResponse);');
4243
});
4344
}

lib/protobuf_field.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,11 @@ class ProtobufField {
203203
'0' == descriptor.defaultValue) {
204204
return null;
205205
} else if (descriptor.defaultValue == 'inf') {
206-
return 'double.INFINITY';
206+
return 'double.infinity';
207207
} else if (descriptor.defaultValue == '-inf') {
208-
return 'double.NEGATIVE_INFINITY';
208+
return 'double.negativeInfinity';
209209
} else if (descriptor.defaultValue == 'nan') {
210-
return 'double.NAN';
210+
return 'double.nan';
211211
} else if (HEX_LITERAL_REGEX.hasMatch(descriptor.defaultValue)) {
212212
return '(${descriptor.defaultValue}).toDouble()';
213213
} else if (INTEGER_LITERAL_REGEX.hasMatch(descriptor.defaultValue)) {

lib/src/descriptor.pb.dart

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/plugin.pb.dart

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: protoc_plugin
2-
version: 0.7.11
2+
version: 0.8.0
33
author: Dart Team <misc@dartlang.org>
44
description: Protoc compiler plugin to generate Dart code
55
homepage: https://github.com/dart-lang/dart-protoc-plugin
@@ -8,7 +8,7 @@ environment:
88
dependencies:
99
fixnum: ^0.10.5
1010
path: ^1.0.0
11-
protobuf: ^0.7.1
11+
protobuf: ^0.8.0
1212
dart_style: ^1.0.6
1313
dev_dependencies:
1414
browser: any

test/client_generator_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ class TestApi {
2121
2222
Future<SomeReply> aMethod(ClientContext ctx, SomeRequest request) {
2323
var emptyResponse = new SomeReply();
24-
return _client.invoke(ctx, 'Test', 'AMethod', request, emptyResponse);
24+
return _client.invoke<SomeReply>(ctx, 'Test', 'AMethod', request, emptyResponse);
2525
}
2626
Future<$foo$bar.AnotherReply> anotherMethod(ClientContext ctx, $foo$bar.EmptyMessage request) {
2727
var emptyResponse = new $foo$bar.AnotherReply();
28-
return _client.invoke(ctx, 'Test', 'AnotherMethod', request, emptyResponse);
28+
return _client.invoke<$foo$bar.AnotherReply>(ctx, 'Test', 'AnotherMethod', request, emptyResponse);
2929
}
3030
}
3131

0 commit comments

Comments
 (0)