Skip to content
Open
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
20 changes: 11 additions & 9 deletions packages/pigeon/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## NEXT
## 26.4.0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Breaking change because of the description thing?


* Overrides `toString` (or equivalent) methods on generated data classes.
* [swift] Updates `isNullish` to handle double nested `Any?` values.
* Updates minimum supported SDK version to Flutter 3.38/Dart 3.10.

## 26.3.4
Expand Down Expand Up @@ -919,7 +921,7 @@

## 3.0.3

* Adds ability for generators to do AST validation. This can help generators
* Adds ability for generators to do AST validation. This can help generators
without complete implementations to report gaps in coverage.

## 3.0.2
Expand Down Expand Up @@ -1082,11 +1084,11 @@
`dart:mirrors` doesn't support null-safe code so there were a class of
features we couldn't implement without this migration.
* **BREAKING CHANGE** - the `configurePigeon` function has been migrated to a
`@ConfigurePigeon` annotation. See `./pigeons/message.dart` for an example.
`@ConfigurePigeon` annotation. See `./pigeons/message.dart` for an example.
The annotation can be attached to anything in the file to take effect.
* **BREAKING CHANGE** - Now Pigeon files must be in one file per invocation of
Pigeon. For example, the classes your APIs use must be in the same file as
your APIs. If your Pigeon file imports another source file, it won't actually
Pigeon. For example, the classes your APIs use must be in the same file as
your APIs. If your Pigeon file imports another source file, it won't actually
import it.

## 0.2.4
Expand All @@ -1108,10 +1110,10 @@

## 0.2.0

* **BREAKING CHANGE** - Pigeon files must be null-safe now. That means the
* **BREAKING CHANGE** - Pigeon files must be null-safe now. That means the
fields inside of the classes must be declared nullable (
[non-null fields](https://github.com/flutter/flutter/issues/59118) aren't yet
supported). Migration example:
supported). Migration example:

```dart
// Version 0.1.x
Expand All @@ -1127,7 +1129,7 @@ class Foo {
}
```

* **BREAKING CHANGE** - The default output from Pigeon is now null-safe. If you
* **BREAKING CHANGE** - The default output from Pigeon is now null-safe. If you
want non-null-safe code you must provide the `--no-dart_null_safety` flag.
* The Pigeon source code is now null-safe.
* Fixed niladic non-value returning async functions in the Java generator.
Expand Down Expand Up @@ -1213,7 +1215,7 @@ class Foo {

## 0.1.8

* Started spawning pigeon_lib in an isolate instead of a subprocess. The
* Started spawning pigeon_lib in an isolate instead of a subprocess. The
subprocess could have lead to errors if the dart version on $PATH didn't match
the one that comes with flutter.

Expand Down
12 changes: 6 additions & 6 deletions packages/pigeon/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Description

Pigeon is a code generation tool that adds type safety to Flutter’s Platform
Channels. This document serves as an overview of how it functions to help
Channels. This document serves as an overview of how it functions to help
people who would like to contribute to the project.

## Source Index
Expand Down Expand Up @@ -32,15 +32,15 @@ Pigeon has 3 types of tests; you'll find them all in

* Unit tests - These are the fastest tests that are just typical unit tests,
they may be generating code and checking it against a regular expression to
see if it's correct. Example:
see if it's correct. Example:
[dart_generator_test.dart](./test/dart_generator_test.dart)
* Compilation tests - These tests generate code, then attempt to compile that
code. These are tests are much slower than unit tests, but not as slow as
integration tests. These tests are typically run against the Pigeon files in
code. These are tests are much slower than unit tests, but not as slow as
integration tests. These tests are typically run against the Pigeon files in
[pigeons](./pigeons).
* Integration tests - These tests generate code, then compile the generated
code, then execute the generated code. It can be thought of as unit-tests run
against the generated code. Examples: [platform_tests](./platform_tests)
code, then execute the generated code. It can be thought of as unit-tests run
against the generated code. Examples: [platform_tests](./platform_tests)

For local testing, always use `test.dart` rather than `run_tests.dart`, as
`run_tests.dart` is specifically a CI entrypoint. When iterating on a specific
Expand Down
4 changes: 2 additions & 2 deletions packages/pigeon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ to the api to allow for multiple instances to be created and operate in parallel
1) Custom classes used by APIs are defined as classes with fields of the
supported datatypes (see the supported Datatypes section).
1) APIs should be defined as an `abstract class` with either `@HostApi()` or
`@FlutterApi()` as metadata. `@HostApi()` being for procedures that are defined
`@FlutterApi()` as metadata. `@HostApi()` being for procedures that are defined
on the host platform and the `@FlutterApi()` for procedures that are defined in Dart.
1) Method declarations on the API classes should have arguments and a return
value whose types are defined in the file, are supported datatypes, or are
Expand Down Expand Up @@ -150,7 +150,7 @@ to the api to allow for multiple instances to be created and operate in parallel
### Calling into Flutter from the host platform

Pigeon also supports calling in the opposite direction. The steps are similar
but reversed. For more information look at the annotation `@FlutterApi()` which
but reversed. For more information look at the annotation `@FlutterApi()` which
denotes APIs that live in Flutter but are invoked from the host platform.
[Example](./example/README.md#FlutterApi_Example).

Expand Down
4 changes: 2 additions & 2 deletions packages/pigeon/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ enum Code { one, two }
class MessageData {
MessageData({required this.code, required this.data});
String? name;
String? description;
String? messageDescription;
Code code;
Map<String, String> data;
}
Expand Down Expand Up @@ -107,7 +107,7 @@ Future<bool> sendMessage(String messageText) {
final message = MessageData(
code: Code.one,
data: <String, String>{'header': 'this is a header'},
description: 'uri text',
messageDescription: 'uri text',
);
try {
return _api.sendMessage(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,14 @@ public void setName(@Nullable String setterArg) {
this.name = setterArg;
}

private @Nullable String description;
private @Nullable String messageDescription;

public @Nullable String getDescription() {
return description;
public @Nullable String getMessageDescription() {
return messageDescription;
}

public void setDescription(@Nullable String setterArg) {
this.description = setterArg;
public void setMessageDescription(@Nullable String setterArg) {
this.messageDescription = setterArg;
}

private @NonNull Code code;
Expand Down Expand Up @@ -300,17 +300,34 @@ public boolean equals(Object o) {
}
MessageData that = (MessageData) o;
return pigeonDeepEquals(name, that.name)
&& pigeonDeepEquals(description, that.description)
&& pigeonDeepEquals(messageDescription, that.messageDescription)
&& pigeonDeepEquals(code, that.code)
&& pigeonDeepEquals(data, that.data);
}

@Override
public int hashCode() {
Object[] fields = new Object[] {getClass(), name, description, code, data};
Object[] fields = new Object[] {getClass(), name, messageDescription, code, data};
return pigeonDeepHashCode(fields);
}

@Override
public String toString() {
return "MessageData{"
+ "name="
+ name
+ ", "
+ "messageDescription="
+ messageDescription
+ ", "
+ "code="
+ code
+ ", "
+ "data="
+ data
+ "}";
}

public static final class Builder {

private @Nullable String name;
Expand All @@ -321,11 +338,11 @@ public static final class Builder {
return this;
}

private @Nullable String description;
private @Nullable String messageDescription;

@CanIgnoreReturnValue
public @NonNull Builder setDescription(@Nullable String setterArg) {
this.description = setterArg;
public @NonNull Builder setMessageDescription(@Nullable String setterArg) {
this.messageDescription = setterArg;
return this;
}

Expand All @@ -348,7 +365,7 @@ public static final class Builder {
public @NonNull MessageData build() {
MessageData pigeonReturn = new MessageData();
pigeonReturn.setName(name);
pigeonReturn.setDescription(description);
pigeonReturn.setMessageDescription(messageDescription);
pigeonReturn.setCode(code);
pigeonReturn.setData(data);
return pigeonReturn;
Expand All @@ -359,7 +376,7 @@ public static final class Builder {
ArrayList<Object> toList() {
ArrayList<Object> toListResult = new ArrayList<>(4);
toListResult.add(name);
toListResult.add(description);
toListResult.add(messageDescription);
toListResult.add(code);
toListResult.add(data);
return toListResult;
Expand All @@ -369,8 +386,8 @@ ArrayList<Object> toList() {
MessageData pigeonResult = new MessageData();
Object name = pigeonVar_list.get(0);
pigeonResult.setName((String) name);
Object description = pigeonVar_list.get(1);
pigeonResult.setDescription((String) description);
Object messageDescription = pigeonVar_list.get(1);
pigeonResult.setMessageDescription((String) messageDescription);
Object code = pigeonVar_list.get(2);
pigeonResult.setCode((Code) code);
Object data = pigeonVar_list.get(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ data class IntEvent(val data: Long) : PlatformEvent() {
result = 31 * result + EventChannelMessagesPigeonUtils.deepHash(this.data)
return result
}

override fun toString(): String {
return "IntEvent(data=$data)"
}
}

/** Generated class from Pigeon that represents data sent in messages. */
Expand Down Expand Up @@ -227,6 +231,10 @@ data class StringEvent(val data: String) : PlatformEvent() {
result = 31 * result + EventChannelMessagesPigeonUtils.deepHash(this.data)
return result
}

override fun toString(): String {
return "StringEvent(data=$data)"
}
}

private open class EventChannelMessagesPigeonCodec : StandardMessageCodec() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,24 +207,24 @@ enum class Code(val raw: Int) {
/** Generated class from Pigeon that represents data sent in messages. */
data class MessageData(
val name: String? = null,
val description: String? = null,
val messageDescription: String? = null,
val code: Code,
val data: Map<String, String>
) {
companion object {
fun fromList(pigeonVar_list: List<Any?>): MessageData {
val name = pigeonVar_list[0] as String?
val description = pigeonVar_list[1] as String?
val messageDescription = pigeonVar_list[1] as String?
val code = pigeonVar_list[2] as Code
val data = pigeonVar_list[3] as Map<String, String>
return MessageData(name, description, code, data)
return MessageData(name, messageDescription, code, data)
}
}

fun toList(): List<Any?> {
return listOf(
name,
description,
messageDescription,
code,
data,
)
Expand All @@ -239,19 +239,23 @@ data class MessageData(
}
val other = other as MessageData
return MessagesPigeonUtils.deepEquals(this.name, other.name) &&
MessagesPigeonUtils.deepEquals(this.description, other.description) &&
MessagesPigeonUtils.deepEquals(this.messageDescription, other.messageDescription) &&
MessagesPigeonUtils.deepEquals(this.code, other.code) &&
MessagesPigeonUtils.deepEquals(this.data, other.data)
}

override fun hashCode(): Int {
var result = javaClass.hashCode()
result = 31 * result + MessagesPigeonUtils.deepHash(this.name)
result = 31 * result + MessagesPigeonUtils.deepHash(this.description)
result = 31 * result + MessagesPigeonUtils.deepHash(this.messageDescription)
result = 31 * result + MessagesPigeonUtils.deepHash(this.code)
result = 31 * result + MessagesPigeonUtils.deepHash(this.data)
return result
}

override fun toString(): String {
return "MessageData(name=$name, messageDescription=$messageDescription, code=$code, data=$data)"
}
}

private open class MessagesPigeonCodec : StandardMessageCodec() {
Expand Down
Loading
Loading