This repository was archived by the owner on Jan 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
Add exclude-all-by-default config flag #431
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,44 @@ | ||
| # Objective C example | ||
|
|
||
| This example shows how to use ffigen to generate bindings for an Objective C | ||
| library. It uses the AVFAudio framework to play audio files. | ||
|
|
||
| ``` | ||
| dart play_audio.dart test.mp3 | ||
| ``` | ||
|
|
||
| ## Config notes | ||
|
|
||
| The ffigen config for an Objective C library looks very similar to a C library. | ||
| The most important difference is that you must set `language: objc`. If you want | ||
| to filter which interfaces are included you can use the `objc-interfaces:` | ||
| option. This works similarly to the other filtering options. | ||
|
|
||
| It is recommended that you filter out just about everything you're not | ||
| interested in binding (see the ffigen config in [pubspec.yaml](./pubspec.yaml)). | ||
| Virtually all Objective C libraries depend on Apple's internal libraries, which | ||
| are huge. Filtering can reduce the generated bindings from millions of lines to | ||
| tens of thousands. | ||
|
|
||
| In this example, we're only interested in `AVAudioPlayer`, so we've filtered out | ||
| everything else. But ffigen will automatically pull in anything referenced by | ||
| any of the fields or methods of `AVAudioPlayer`, so we're still able to use | ||
| `NSURL` etc to load our audio file. | ||
|
|
||
| ## Generating bindings | ||
|
|
||
| At the root of this example (`example/objective_c`), run: | ||
|
|
||
| ``` | ||
| dart run ffigen | ||
| ``` | ||
|
|
||
| This will generate [avf_audio_bindings.dart](./avf_audio_bindings.dart). | ||
| # Objective C example | ||
|
|
||
| This example shows how to use ffigen to generate bindings for an Objective C | ||
| library. It uses the AVFAudio framework to play audio files. | ||
|
|
||
| ``` | ||
| dart play_audio.dart test.mp3 | ||
| ``` | ||
|
|
||
| ## Config notes | ||
|
|
||
| The ffigen config for an Objective C library looks very similar to a C library. | ||
| The most important difference is that you must set `language: objc`. If you want | ||
| to filter which interfaces are included you can use the `objc-interfaces:` | ||
| option. This works similarly to the other filtering options. | ||
|
|
||
| It is recommended that you filter out just about everything you're not | ||
| interested in binding (see the ffigen config in [pubspec.yaml](./pubspec.yaml)). | ||
| Virtually all Objective C libraries depend on Apple's internal libraries, which | ||
| are huge. Filtering can reduce the generated bindings from millions of lines to | ||
| tens of thousands. You can use the `exclude-all-by-default` flag, or exclude | ||
| individual sets of declarations like this: | ||
|
|
||
| ```yaml | ||
| functions: | ||
| exclude: | ||
| - '.*' | ||
| # Same for structs/unions/enums etc. | ||
| ``` | ||
|
|
||
| In this example, we're only interested in `AVAudioPlayer`, so we've filtered out | ||
| everything else. But ffigen will automatically pull in anything referenced by | ||
| any of the fields or methods of `AVAudioPlayer`, so we're still able to use | ||
| `NSURL` etc to load our audio file. | ||
|
|
||
| ## Generating bindings | ||
|
|
||
| At the root of this example (`example/objective_c`), run: | ||
|
|
||
| ``` | ||
| dart run ffigen | ||
| ``` | ||
|
|
||
| This will generate [avf_audio_bindings.dart](./avf_audio_bindings.dart). | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Recommend you hide whitespace changes for this file. Most of these diffs are just my editor switching the line endings.