diff options
Diffstat (limited to 'bindgen')
-rw-r--r-- | bindgen/callbacks.rs | 6 | ||||
-rw-r--r-- | bindgen/ir/function.rs | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/bindgen/callbacks.rs b/bindgen/callbacks.rs index 9b345449..d0eb4667 100644 --- a/bindgen/callbacks.rs +++ b/bindgen/callbacks.rs @@ -31,6 +31,12 @@ pub trait ParseCallbacks: fmt::Debug + UnwindSafe { MacroParsingBehavior::Default } + /// This function will run for every function. The returned value determines the name visible + /// in the bindings. + fn generated_name_override(&self, _function_name: &str) -> Option<String> { + None + } + /// The integer kind an integer macro should have, given a name and the /// value of that macro, or `None` if you want the default to be chosen. fn int_macro(&self, _name: &str, _value: i64) -> Option<IntKind> { diff --git a/bindgen/ir/function.rs b/bindgen/ir/function.rs index 928b5aad..c160ed81 100644 --- a/bindgen/ir/function.rs +++ b/bindgen/ir/function.rs @@ -664,6 +664,12 @@ impl ClangSubItemParser for Function { // but seems easy enough to handle it here. name.push_str("_destructor"); } + if let Some(callbacks) = context.parse_callbacks() { + if let Some(nm) = callbacks.generated_name_override(&name) { + name = nm; + } + } + assert!(!name.is_empty(), "Empty function name."); let mangled_name = cursor_mangling(context, &cursor); let comment = cursor.raw_comment(); |