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
Generate BindgenOptions
and the Builder
methods using macros
#2473
Merged
Conversation
This file contains 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 is done so the definition, default value and `Builder` methods for each field of `BindgenOptions` are kept in the same region of code. Before this change, adding (or modifying) a new option for `bindgen` required: - Updating the fields of the `BindgenOptions` type. - Updating the `Default` implementation for `BindgenOptions`. - Updating one or several `Builder` methods with proper documentation explaining the default value of the option. - Updating the `Builder::command_line_flags` method. Each one of these steps was done in a different place inside `bindgen/lib.rs`. With this change, all these 4 steps are done in the same place. This should make less likely to have bugs. Clearly using macros implies properly documenting how to use such macros and makes adding new options a bit harder because most (all?) editors are not able to format code and suggest completions inside macros. This change also moves all the code related to setting `BindgenOptions` to the new `bindgen/options.rs` file.
All the options that support regular expressions had the following sentence in their documentation: > Regular expressions are supported This comment was factored out to the macro that documents options based on `RegexSet`s.
This is done to avoid hard to detect macro parsing issues due to missing commas.
This trait eases the conversion of `BindgenOptions` fields into CLI args. This commit also changes the `options` macro so the flag can be passed to `as_args` instead of a closure.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
TODO:
options!
macro.RegexSet
.