diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/callbacks.rs | 6 | ||||
-rw-r--r-- | src/ir/function.rs | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/callbacks.rs b/src/callbacks.rs index 9b345449..d0eb4667 100644 --- a/src/callbacks.rs +++ b/src/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/src/ir/function.rs b/src/ir/function.rs index 27192bcf..89905351 100644 --- a/src/ir/function.rs +++ b/src/ir/function.rs @@ -635,6 +635,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(); |