Skip to content

[Enhancement] Allow to process macro body with ParseCallbacks #937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
target-san opened this issue Aug 29, 2017 · 1 comment
Closed

[Enhancement] Allow to process macro body with ParseCallbacks #937

target-san opened this issue Aug 29, 2017 · 1 comment

Comments

@target-san
Copy link

ATM if bindgen user needs to parse macros by hand, he's forced to do it manually - know all headers involved, parse them by hand and finally do something with parsing results.

I think it would be beneficial if ParseCallbacks would provide way to not only get notified that certain macro was parsed, but also have its body, at least as a string.
Changes proposed, discussion welcome:

pub trait ParseCallbacks {
    // Provides callback implementor ways to customize macro parsing
    // @param  name - macro name
    // @param  args - list of macro arguments; None for constant macro;
    //                Some(...) for function-like macro,
    //                with vector containing argument identifiers
    // @param  body - raw macro body as a string slice, allows to parse it by hand
    // @return        None to perform default parsing;
    //                Some(...) to insert specified text into generated bindings module
    fn parsed_macro(&self, name: &str, args: Option<Vec<&str>>, body: &str) -> Option<String>;
    // ... leftover
}
@fitzgen
Copy link
Member

fitzgen commented Aug 29, 2017

Thanks for the bug report! This is the same issue as #666, so let's keep the discussion centralized there.

@fitzgen fitzgen closed this as completed Aug 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants