Skip to content
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

feat: add custom attributes to fn items #3088

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

oberrich
Copy link

@oberrich oberrich commented Jan 11, 2025

This PR adds functionality to add custom attributes to function items (proposed in #2978).
I've implemented this by extending the TypeKind used by AttributeInfo to include the Function(FunctionKind) variant (see AttributeItemKind).

Unifying the callback this way is a breaking change when --with_attribute_custom or matching on the kind field is used.

@oberrich oberrich marked this pull request as draft January 11, 2025 20:28
@oberrich oberrich marked this pull request as ready for review January 11, 2025 20:44
bindgen/callbacks.rs Outdated Show resolved Hide resolved
@oberrich oberrich requested a review from jschwe January 15, 2025 12:22
@oberrich
Copy link
Author

I'd love to add some tests as well but I'm not sure how I would do that, can't get anything other than basic tests to run.
Some of the tests seem to be Linux only and depend on some bash script.
Would love some advice although I don't think we necessarily need tests for this since I've basically just copied the logic from @mkroening's implementation and this should just work™.

@mkroening
Copy link
Contributor

You can take a look at #2866, where I added some tests along with the support for custom attributes on other items (attribute-custom.h, attribute-custom-cli.h, and their respective expected output).

@oberrich
Copy link
Author

I've added both regular and integration tests, CI seems to pass now as well.

@oberrich
Copy link
Author

I've added the attributes from <div bindgen attribute="..."/> annotations and included tests for them.
The PR is now ready for review.

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

Successfully merging this pull request may close these issues.

3 participants