diff options
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, } } } |