-
Notifications
You must be signed in to change notification settings - Fork 716
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
Refactor C interop #5881
Refactor C interop #5881
Conversation
Visit the preview URL for this PR (updated for commit 5697550): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @atsansone!
src/content/interop/c-interop.md
Outdated
|
||
The [`hello.dart` file]({{hw}}/hello.dart) | ||
illustrates the steps for using `dart:ffi` to call a C function: | ||
To learn how to call a C function using the `dart:ffi` package, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dart:
is not a package, package:
is a package. Did you mean to say library?
Once you understand the `hello_world` example, | ||
consult the [other `dart:ffi` examples](#download-example-files). | ||
|
||
## Bundle and load C libraries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose we mostly want to reference what is non-experimental here.
The work on native assets (which is currently an experiment in Dart and Flutter), will make bundling / distributing native code platform agnostic.
Edit: Ah we already have a section for native assets, maybe link it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already done on line 264
src/content/interop/c-interop.md
Outdated
* It makes the native assets available at runtime through | ||
* Build the native code or obtains the binaries | ||
using a package's `build.dart` script. | ||
* Bundle the native [`Asset`][] that the `build.dart` script reports. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new terminology is build hook, build.dart
hook, or hook/build.dart
. The hook was moved inside the hook/
directory, and we don't use "script" anymore.
src/content/interop/c-interop.md
Outdated
### Experiment opt-in | ||
* To learn about native assets in Dart FFI, | ||
consult the `dart:ffi` API reference for [`Native`][] and [`DefaultAsset`][]. | ||
* To learn about the `build.dart` script, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
script -> hook
src/content/interop/c-interop.md
Outdated
When a Dart or Flutter project depends on `package:native_add_library`, | ||
the `build.dart` script will automatically be | ||
invoked on `run`, `build`, and `test` commands. | ||
it invokes the `build.dart` script on `run`, `build`, and `test` commands. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build.dart
-> hook/build.dart
src/content/interop/c-interop.md
Outdated
| [`src/native_add_library.c`][] | The C file containing the code for `add`. | | ||
| [`lib/native_add_library.dart`][] | The Dart file that invokes the C function `add` in asset `package:native_add_library/native_add_library.dart` through FFI. (Note that _asset id_ defaults to the library uri.) | | ||
| [`test/native_add_library_test.dart`][] | A Dart test using the native code. | | ||
| [`hook/build.dart`][] | A script for compiling `src/native_add_library.c` and declaring the compiled asset with id `package:native_add_library/native_add_library.dart`. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
script -> hook
Fixes #3894
Expands on this issue by updating links to code examples, updating style