Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/pigeon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
## NEXT
## 1.0.16

* Updates behavior of run\_tests.dart with no arguments.
* [debugging] Adds `ast_out` to help with debugging the compiler front-end.
* [front-end, dart] Adds support for non-null fields in data classes in the
front-end parser and the Dart generator (unsupported languages ignore the
designation currently).
* [front-end, dart, objc, java] Adds support for non-null fields in data
classes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update the README section about NNBD to reflect the state with this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


## 1.0.15

Expand Down
15 changes: 11 additions & 4 deletions packages/pigeon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ denotes APIs that live in Flutter but are invoked from the host platform.
`void`.
1) Generics are supported, but can currently only be used with nullable types
(example: `List<int?>`).
1) Fields on classes currently must be nullable, arguments and return values to
methods must be non-nullable.
1) Arguments and return values to methods must be non-nullable. Fields on
classes can be nullable or non-nullable.

## Supported Datatypes

Expand Down Expand Up @@ -120,8 +120,15 @@ public interface Api2Host {

### Null Safety (NNBD)

Right now Pigeon supports generating null-safe code, but it doesn't yet support
[non-null fields](https://github.com/flutter/flutter/issues/59118).
Pigeon supports generating null-safe code, but it doesn't yet support:

1) Nullable method parameters
1) Nullable generics type arguments
1) Nullable return values

It does support:

1) Nullable and Non-nullable class fields.

The default is to generate null-safe code but in order to generate non-null-safe
code run Pigeon with the extra argument `--no-dart_null_safety`. For example:
Expand Down
88 changes: 46 additions & 42 deletions packages/pigeon/bin/run_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,53 +87,47 @@ Future<int> _runDartUnitTests() async {
return exitCode;
}

/// Generates multiple dart files based on the jobs defined in [jobs] which is
/// in the format of (key: input pigeon file path, value: output dart file
/// path).
Future<int> _generateDart(Map<String, String> jobs) async {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment to this method? I have no idea what "jobs" are.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still had to read the implementation to know what this meant, since without much context "input" and "output" are extremely generic terms.

How about: "Generates multiple dart files via pigeon invocations based on the jobs [...] the format of (key: pigeon input file, value: pigeon dart output file)."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

for (final MapEntry<String, String> job in jobs.entries) {
// TODO(gaaclarke): Make this run the jobs in parallel. A bug in Dart
// blocked this (https://github.com/dart-lang/pub/pull/3285).
final int result = await _runPigeon(
input: job.key, dartOut: job.value, streamOutput: false);
if (result != 0) {
return result;
}
}
return 0;
}

Future<int> _runFlutterUnitTests() async {
const String flutterUnitTestsPath =
'platform_tests/flutter_null_safe_unit_tests';
int generateCode = await _runPigeon(
input: 'pigeons/flutter_unittests.dart',
dartOut: '$flutterUnitTestsPath/lib/null_safe_pigeon.dart',
);
if (generateCode != 0) {
return generateCode;
}
generateCode = await _runPigeon(
input: 'pigeons/all_datatypes.dart',
dartOut: '$flutterUnitTestsPath/lib/all_datatypes.dart',
);
if (generateCode != 0) {
return generateCode;
}
generateCode = await _runPigeon(
input: 'pigeons/primitive.dart',
dartOut: '$flutterUnitTestsPath/lib/primitive.dart',
);
if (generateCode != 0) {
return generateCode;
}
generateCode = await _runPigeon(
input: 'pigeons/multiple_arity.dart',
dartOut: '$flutterUnitTestsPath/lib/multiple_arity.gen.dart',
);
final int generateCode = await _generateDart(<String, String>{
'pigeons/flutter_unittests.dart':
'$flutterUnitTestsPath/lib/null_safe_pigeon.dart',
'pigeons/all_datatypes.dart':
'$flutterUnitTestsPath/lib/all_datatypes.dart',
'pigeons/primitive.dart': '$flutterUnitTestsPath/lib/primitive.dart',
'pigeons/multiple_arity.dart':
'$flutterUnitTestsPath/lib/multiple_arity.gen.dart',
'pigeons/non_null_fields.dart':
'$flutterUnitTestsPath/lib/non_null_fields.gen.dart',
});
if (generateCode != 0) {
return generateCode;
}

const List<String> testFiles = <String>[
'null_safe_test.dart',
'all_datatypes_test.dart',
'primitive_test.dart',
'multiple_arity_test.dart'
];
for (final String testFile in testFiles) {
final int testCode = await _runProcess(
'flutter',
<String>['test', 'test/$testFile'],
workingDirectory: flutterUnitTestsPath,
);
if (testCode != 0) {
return testCode;
}
final int testCode = await _runProcess(
'flutter',
<String>['test'],
workingDirectory: flutterUnitTestsPath,
);
if (testCode != 0) {
return testCode;
}

return 0;
Expand Down Expand Up @@ -174,14 +168,17 @@ Future<int> _runPigeon(
String? cppHeaderOut,
String? cppSourceOut,
String? dartOut,
String? dartTestOut}) async {
String? dartTestOut,
bool streamOutput = true}) async {
const bool hasDart = false;
final List<String> args = <String>[
'pub',
'run',
'pigeon',
'--input',
input,
'--copyright_header',
'./copyright_header.txt',
];
if (cppHeaderOut != null) {
args.addAll(<String>[
Expand All @@ -204,9 +201,16 @@ Future<int> _runPigeon(
if (!hasDart) {
args.add('--one_language');
}
final Process generate = await _streamOutput(Process.start('dart', args));
final Process generate = streamOutput
? await _streamOutput(Process.start('dart', args))
: await Process.start('dart', args);
final int generateCode = await generate.exitCode;
if (generateCode != 0) {
if (!streamOutput) {
print('dart $args failed:');
generate.stdout.pipe(stdout);
generate.stderr.pipe(stderr);
}
return generateCode;
}
return 0;
Expand Down
Loading