-
Notifications
You must be signed in to change notification settings - Fork 322
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
Add rename-all=prefix: #1007
Add rename-all=prefix: #1007
Conversation
b68be3e
to
b4a40d8
Compare
This adds a new rename-all annotation which allows setting a specific prefix to all fields. For example: ```rust /// cbindgen:rename-all=prefix:ERR_ enum Error { Bad = 0, VeryBad = 1 } ``` While in principle this can be added to the config file, it's primarily useful for overrides on a case-by-case basis.
b4a40d8
to
3a3928d
Compare
Alternatively (and perhaps preferably) this could be a separate option which is applied after the normal rename rule so you can both rename and add a prefix (which could be applied after prefix-with-name or exclusive with it). |
Summary: [Fix an upstream bug](mozilla/cbindgen#1006) and [add ability to put arbitrary prefix on field names](mozilla/cbindgen#1007). Reviewed By: jasonwhite Differential Revision: D63878067 fbshipit-source-id: 16a35ed1fa2adc4c9211fc6f6332f0be7dbf4f56
Summary: [Fix an upstream bug](mozilla/cbindgen#1006) and [add ability to put arbitrary prefix on field names](mozilla/cbindgen#1007). Reviewed By: jasonwhite Differential Revision: D63878067 fbshipit-source-id: 16a35ed1fa2adc4c9211fc6f6332f0be7dbf4f56
Summary: [Fix an upstream bug](mozilla/cbindgen#1006) and [add ability to put arbitrary prefix on field names](mozilla/cbindgen#1007). Reviewed By: jasonwhite Differential Revision: D63878067 fbshipit-source-id: 16a35ed1fa2adc4c9211fc6f6332f0be7dbf4f56
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.
This is fine for now :)
@@ -171,7 +171,7 @@ impl Item for Union { | |||
let rules = self | |||
.annotations | |||
.parse_atom::<RenameRule>("rename-all") | |||
.unwrap_or(config.structure.rename_fields); | |||
.unwrap_or(config.structure.rename_fields.clone()); |
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.
Maybe avoid these clones by:
let rules = self.annotations.parse_atom::<>();
let rules = rules.as_ref().unwrap_or(&config.structure.rename_fields);
But fine either way.
Summary: PRs mozilla/cbindgen#1006 mozilla/cbindgen#1007 were accepted, so update patch to upstream git repo until next release is cut. Also bump `syn` to match cbindgen. Reviewed By: dtolnay Differential Revision: D65079945 fbshipit-source-id: 5b9f0467150d7cf81f5a9df0bb4d0c1309e67e1b
Summary: PRs mozilla/cbindgen#1006 mozilla/cbindgen#1007 were accepted, so update patch to upstream git repo until next release is cut. Also bump `syn` to match cbindgen. Reviewed By: dtolnay Differential Revision: D65079945 fbshipit-source-id: 5b9f0467150d7cf81f5a9df0bb4d0c1309e67e1b
Summary: PRs mozilla/cbindgen#1006 mozilla/cbindgen#1007 were accepted, so update patch to upstream git repo until next release is cut. Also bump `syn` to match cbindgen. Reviewed By: dtolnay Differential Revision: D65079945 fbshipit-source-id: 5b9f0467150d7cf81f5a9df0bb4d0c1309e67e1b
Summary: PRs mozilla/cbindgen#1006 mozilla/cbindgen#1007 were accepted, so update patch to upstream git repo until next release is cut. Also bump `syn` to match cbindgen. Reviewed By: dtolnay Differential Revision: D65079945 fbshipit-source-id: 5b9f0467150d7cf81f5a9df0bb4d0c1309e67e1b
Summary: PRs mozilla/cbindgen#1006 mozilla/cbindgen#1007 were accepted, so update patch to upstream git repo until next release is cut. Also bump `syn` to match cbindgen. Reviewed By: dtolnay Differential Revision: D65079945 fbshipit-source-id: 5b9f0467150d7cf81f5a9df0bb4d0c1309e67e1b
This adds a new rename-all annotation which allows setting a specific prefix to all fields. For example:
While in principle this can be added to the config file, it's primarily useful for overrides on a case-by-case basis.