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
5 changes: 5 additions & 0 deletions packages/pigeon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.1.0-experimental.5

* Fixed runtime exception in Android with values of ints less than 2^32.
* Incremented codegen version warning.

## 0.1.0-experimental.4

* Fixed primitive types for Android Java.
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/lib/generator_tools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'dart:io';
import 'ast.dart';

/// The current version of pigeon.
const String pigeonVersion = '0.1.0-experimental.3';
const String pigeonVersion = '0.1.0-experimental.5';

/// Read all the content from [stdin] to a String.
String readStdin() {
Expand Down
15 changes: 12 additions & 3 deletions packages/pigeon/lib/java_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ String _javaTypeForDartType(String datatype) {
return _javaTypeForDartTypeMap[datatype];
}

String _mapGetter(Field field, List<Class> classes, String mapName) {
final HostDatatype hostDatatype =
getHostDatatype(field, classes, _javaTypeForDartType);
final String result = '$mapName.get("${field.name}")';
if (field.dataType == 'int') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

test?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll look into it. I have e2e tests for iOS, not Android, but they aren't checked in yet.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm going to check this in now since I can repro this manually with the video player plugin. I'll put e2e android on my queue.

return '($result instanceof Integer) ? (Integer)$result : (${hostDatatype.datatype})$result';
} else {
return '(${hostDatatype.datatype})$result';
}
}

/// Generates the ".java" file for the AST represented by [root] to [sink] with the
/// provided [options].
void generateJava(JavaOptions options, Root root, StringSink sink) {
Expand Down Expand Up @@ -197,10 +208,8 @@ void generateJava(JavaOptions options, Root root, StringSink sink) {
indent.scoped('{', '}', () {
indent.writeln('${klass.name} fromMapResult = new ${klass.name}();');
for (Field field in klass.fields) {
final HostDatatype hostDatatype =
getHostDatatype(field, root.classes, _javaTypeForDartType);
indent.writeln(
'fromMapResult.${field.name} = (${hostDatatype.datatype})map.get("${field.name}");');
'fromMapResult.${field.name} = ${_mapGetter(field, root.classes, 'map')};');
}
indent.writeln('return fromMapResult;');
});
Expand Down
2 changes: 1 addition & 1 deletion packages/pigeon/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: pigeon
version: 0.1.0-experimental.4
version: 0.1.0-experimental.5
description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
homepage: https://github.com/flutter/packages/tree/master/packages/pigeon
dependencies:
Expand Down