diff options
author | Christian Poveda Ruiz <31802960+pvdrz@users.noreply.github.com> | 2022-11-22 11:25:13 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-22 11:25:13 -0500 |
commit | f160d11d56007fe1b1125d04f0cb31af0b18fc6e (patch) | |
tree | 7b8906d8bf4919c0eab989262f1bad194027ca99 /bindgen/lib.rs | |
parent | 34f0bacb7eb72413c9c27684cb01a205ee43037e (diff) |
Add `ParseCallbacks::process_comment` (#2347)
This method can be used to process comments and replace them with whatever the user wants.
Diffstat (limited to 'bindgen/lib.rs')
-rw-r--r-- | bindgen/lib.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/bindgen/lib.rs b/bindgen/lib.rs index bfc22bb6..d281e949 100644 --- a/bindgen/lib.rs +++ b/bindgen/lib.rs @@ -78,6 +78,8 @@ doc_mod!(ir, ir_docs); doc_mod!(parse, parse_docs); doc_mod!(regex_set, regex_set_docs); +use ir::comment; + pub use crate::codegen::{ AliasVariation, EnumVariation, MacroTypeVariation, NonCopyUnionStyle, }; @@ -2176,6 +2178,14 @@ impl BindgenOptions { .flat_map(|cb| f(cb.as_ref())) .collect() } + + fn process_comment(&self, comment: &str) -> String { + let comment = comment::preprocess(comment); + self.parse_callbacks + .last() + .and_then(|cb| cb.process_comment(&comment)) + .unwrap_or(comment) + } } impl Default for BindgenOptions { |