Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pigeon] Added basic C++ support #476

Merged
merged 66 commits into from May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
b77bfb6
Added basic C++ support for Pigeon
azchohfi Sep 28, 2021
c100ec4
Hooked up the cpp generator to the test runner.
gaaclarke Nov 23, 2021
aad47a2
Merge branch 'main' into pigeon_cpp
azchohfi Feb 10, 2022
0c33cd8
Fixed tests.
azchohfi Feb 11, 2022
799d86e
Merge branch 'main' into pigeon_cpp
azchohfi Feb 11, 2022
fd87805
Merge branch 'main' into pigeon_cpp
azchohfi Feb 14, 2022
3f84bbd
Merge branch 'main' into pigeon_cpp
azchohfi Feb 15, 2022
91c35d7
Merge branch 'main' into pigeon_cpp
azchohfi Feb 17, 2022
10a6c7e
Merge branch 'main' into pigeon_cpp
azchohfi Feb 23, 2022
97d9838
Merge branch 'main' into pigeon_cpp
azchohfi Mar 1, 2022
4790995
Small fix on generated C++.
azchohfi Mar 2, 2022
7ad88b4
Merge branch 'main' into pigeon_cpp
azchohfi Mar 2, 2022
cd194a8
Added documentation for Pigeon/C++.
azchohfi Mar 2, 2022
c3d5221
Fixed codec generation.
azchohfi Mar 3, 2022
a00efe9
Fixed wrong return type of GetCodec.
azchohfi Mar 3, 2022
cc837be
Merge branch 'main' into pigeon_cpp
azchohfi Mar 3, 2022
01d37d3
added cpp unittest
gaaclarke Mar 3, 2022
5da698f
updated the readme to designate c++ as experimental
gaaclarke Mar 3, 2022
35c39cc
added all_datatypes compilation test
gaaclarke Mar 3, 2022
b8c5a0a
removed unnused function
gaaclarke Mar 3, 2022
86b6217
Fixed multiple parameters on API method.
azchohfi Mar 4, 2022
1f75aef
Merge branch 'pigeon_cpp' of https://github.com/azchohfi/packages int…
azchohfi Mar 4, 2022
928fdda
Fixed async with void return type.
azchohfi Mar 4, 2022
bd50ec2
Enabled multiple Windows compilation tests.
azchohfi Mar 4, 2022
3e2076a
Fixed Windows tests.
azchohfi Mar 4, 2022
22925cc
Merge branch 'main' into pigeon_cpp
azchohfi Mar 4, 2022
095018b
Fixed analyzers.
azchohfi Mar 4, 2022
16e4d55
Added a unit test that will execute the generated code for HostApi's
gaaclarke Mar 4, 2022
0434b1a
added using namespace
gaaclarke Mar 4, 2022
1e6a0d3
added a test that sends an argument
gaaclarke Mar 5, 2022
7520594
made the encode and decode function of data classes private
gaaclarke Mar 5, 2022
e3204fe
Merge branch 'main' into pigeon_cpp
azchohfi Mar 9, 2022
7dba5e3
C++ generated code improvements.
azchohfi Mar 10, 2022
4d61edb
Fixed tests.
azchohfi Mar 10, 2022
77a4b33
Better handling of nullable types.
azchohfi Mar 11, 2022
8563665
Merge branch 'main' into pigeon_cpp
azchohfi Mar 11, 2022
3ef8b08
Removed unused variable.
azchohfi Mar 11, 2022
dc3def3
Removed space at end of method.
azchohfi Mar 11, 2022
8995cc7
Added ErrorOr class for handling C++ errors.
azchohfi Mar 12, 2022
8f82bf9
Merge branch 'main' into pigeon_cpp
azchohfi Mar 17, 2022
ce48443
Merge branch 'main' into pigeon_cpp
azchohfi Mar 25, 2022
c820c8c
Merge branch 'main' into pigeon_cpp
azchohfi Apr 8, 2022
d0e334b
Merge branch 'main' into pigeon_cpp
azchohfi Apr 13, 2022
1982681
Small fixes.
azchohfi Apr 14, 2022
7438b5e
Added experimental prefix to cpp options.
azchohfi Apr 14, 2022
53fcab3
Merge branch 'main' into pigeon_cpp
azchohfi Apr 14, 2022
41b5a42
Fix format.
azchohfi Apr 14, 2022
e801842
PR feedback.
azchohfi Apr 14, 2022
3b8df15
Merge branch 'main' into pigeon_cpp
azchohfi Apr 19, 2022
cd2f504
PR Feedback on reference types.
azchohfi Apr 19, 2022
5a445e1
Fix format.
azchohfi Apr 20, 2022
e57c3a8
Merge branch 'main' into pigeon_cpp
azchohfi Apr 20, 2022
cfd4fc6
Implemented missing Generator method.
azchohfi Apr 21, 2022
86ebf6a
Merge branch 'main' into pigeon_cpp
azchohfi Apr 21, 2022
c60ca5d
NRE fix.
azchohfi Apr 21, 2022
178997b
Merge branch 'main' into pigeon_cpp
azchohfi Apr 26, 2022
a61e09a
Small PR feedback.
azchohfi Apr 27, 2022
658a050
Merge branch 'main' into pigeon_cpp
azchohfi May 3, 2022
11a8650
Added ability to use unique_ptr with ErrorOr.
azchohfi May 3, 2022
7c6d5bd
Merge branch 'main' into pigeon_cpp
azchohfi May 6, 2022
64eceaf
Fix for non-nullable return types.
azchohfi May 9, 2022
e18416a
Merge branch 'main' into pigeon_cpp
azchohfi May 9, 2022
e2453f1
Added validator for the cpp generator.
gaaclarke May 9, 2022
88d1a75
Removed non_null_fields test until supported.
azchohfi May 13, 2022
99aa43c
Merge branch 'main' into pigeon_cpp
azchohfi May 16, 2022
02ecf8e
Merge branch 'main' into pigeon_cpp
azchohfi May 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/pigeon/CHANGELOG.md
@@ -1,3 +1,7 @@
## 3.1.0

* [c++] Adds C++ code generator.

## 3.0.4

* [objc] Simplified some code output, including avoiding Xcode warnings about
Expand Down Expand Up @@ -35,8 +39,8 @@
## 2.0.2

* Fixes Java crash for nullable nested type.

* ## 2.0.1
## 2.0.1

* Adds support for TaskQueues for serial background execution.

Expand Down
1 change: 1 addition & 0 deletions packages/pigeon/CONTRIBUTING.md
Expand Up @@ -23,6 +23,7 @@ generators with that AST.
* [java_generator.dart](./lib/java_generator.dart) - The Java code generator.
* [objc_generator.dart](./lib/objc_generator.dart) - The Objective-C code
generator (header and source files).
* [cpp_generator.dart](./lib/cpp_generator.dart) - The C++ code generator.
* [generator_tools.dart](./lib/generator_tools.dart) - Shared code between generators.
* [pigeon_cl.dart](./lib/pigeon_cl.dart) - The top-level function executed by
the command line tool in [bin/][./bin].
Expand Down
58 changes: 38 additions & 20 deletions packages/pigeon/README.md
Expand Up @@ -5,8 +5,9 @@ host platform type-safe, easier and faster.

## Supported Platforms

Currently Pigeon only supports generating Objective-C code for usage on iOS and
Java code for Android. The Objective-C code is
Currently Pigeon supports generating Objective-C code for usage on iOS, Java
code for Android, and has experimental support for C++ for Windows. The
Objective-C code is
[accessible to Swift](https://developer.apple.com/documentation/swift/imported_c_and_objective-c_apis/importing_objective-c_into_swift)
and the Java code is accessible to Kotlin.

Expand All @@ -18,32 +19,39 @@ doesn't need to worry about conflicting versions of Pigeon.

## Usage

### Flutter calling into iOS Steps
1) Add Pigeon as a `dev_dependency`.
1) Make a ".dart" file outside of your "lib" directory for defining the
communication interface.
1) Run pigeon on your ".dart" file to generate the required Dart and
host-language code: `flutter pub get` then `flutter pub run pigeon`
with suitable arguments (see [example](./example)).
1) Add the generated Dart code to `./lib` for compilation.
1) Implement the host-language code and add it to your build (see below).
1) Call the generated Dart methods.

### Flutter calling into iOS steps

1) Add Pigeon as a dev_dependency.
1) Make a ".dart" file outside of your "lib" directory for defining the communication interface.
1) Run pigeon on your ".dart" file to generate the required Dart and Objective-C
code: `flutter pub get` then `flutter pub run pigeon` with suitable arguments
(see [example](./example)).
1) Add the generated Dart code to `lib` for compilation.
1) Add the generated Objective-C code to your Xcode project for compilation
(e.g. `ios/Runner.xcworkspace` or `.podspec`).
1) Implement the generated iOS protocol for handling the calls on iOS, set it up
as the handler for the messages.
1) Call the generated Dart methods.

### Flutter calling into Android Steps

1) Add Pigeon as a dev_dependency.
1) Make a ".dart" file outside of your "lib" directory for defining the communication interface.
1) Run pigeon on your ".dart" file to generate the required Dart and Java code.
`flutter pub get` then `flutter pub run pigeon` with suitable arguments
(see [example](./example)).
1) Add the generated Dart code to `./lib` for compilation.
1) Add the generated Java code to your `./android/app/src/main/java` directory for compilation.
1) Implement the generated Java interface for handling the calls on Android, set it up
as the handler for the messages.
1) Call the generated Dart methods.
1) Add the generated Java code to your `./android/app/src/main/java` directory
for compilation.
1) Implement the generated Java interface for handling the calls on Android, set
it up as the handler for the messages.

### Flutter calling into Windows Steps

1) Add the generated C++ code to your `./windows` directory for compilation, and
to your `windows/CMakeLists.txt` file.
1) Implement the generated C++ abstract class for handling the calls on Windows,
set it up as the handler for the messages.

**Note:** Windows C++ is experimental while we get more usage and add more
testing. Not all features may be supported.

### Calling into Flutter from the host platform

Expand Down Expand Up @@ -116,6 +124,16 @@ public interface Api2Host {
}
```

```c++
// C++

/** Generated class from Pigeon that represents a handler of messages from Flutter.*/
class Api2Host {
public:
virtual void calculate(Value value, flutter::MessageReply<Value> result) = 0;
stuartmorgan marked this conversation as resolved.
Show resolved Hide resolved
}
```

### Null Safety (NNBD)

Pigeon supports generating null-safe code, but it doesn't yet support:
Expand Down