diff options
author | Christian Poveda Ruiz <31802960+pvdrz@users.noreply.github.com> | 2022-11-22 11:41:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-22 11:41:32 -0500 |
commit | 046d6f9eea1803253c06dd99a0d38f5dcb5ed9c1 (patch) | |
tree | 286eeb0d0a9b7c7f2b756e96b01a21253158dc64 /bindgen/lib.rs | |
parent | f160d11d56007fe1b1125d04f0cb31af0b18fc6e (diff) |
Add `--wrap-unsafe-ops` option (#2354)
This reverts commit e8ffb42ab66405ac56d04494a30e54b584f2d4dd and adds a new `--wrap-unsafe-ops` option as a workaround.
Diffstat (limited to 'bindgen/lib.rs')
-rw-r--r-- | bindgen/lib.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/bindgen/lib.rs b/bindgen/lib.rs index d281e949..53bbd887 100644 --- a/bindgen/lib.rs +++ b/bindgen/lib.rs @@ -645,6 +645,10 @@ impl Builder { output_vector.push("--merge-extern-blocks".into()); } + if self.options.wrap_unsafe_ops { + output_vector.push("--wrap-unsafe-ops".into()); + } + // Add clang arguments output_vector.push("--".into()); @@ -1770,6 +1774,12 @@ impl Builder { .insert(arg.into()); self } + + /// If true, wraps unsafe operations in unsafe blocks. + pub fn wrap_unsafe_ops(mut self, doit: bool) -> Self { + self.options.wrap_unsafe_ops = doit; + self + } } /// Configuration options for generated bindings. @@ -2107,6 +2117,9 @@ struct BindgenOptions { merge_extern_blocks: bool, abi_overrides: HashMap<Abi, RegexSet>, + + /// Whether to wrap unsafe operations in unsafe blocks or not. + wrap_unsafe_ops: bool, } impl BindgenOptions { @@ -2298,6 +2311,7 @@ impl Default for BindgenOptions { sort_semantically, merge_extern_blocks, abi_overrides, + wrap_unsafe_ops, } } } |