Skip to content

A macro transformation hack based on AST translation. #3385

Description

@823984418

The current macro translation solution has many defects, such as being unable to translate a simple integer type conversion. Therefore, I implemented a macro translation solution based on lang-c using recursive transformation. A simple hack implementation is here (non-invasive to bindgen, because modifying the bindgen library seems like a big project):

https://github.com/823984418/lang-c/blob/hack-for-bindgen/src/hack_bindgen.rs

This is an example of my use of it:
https://github.com/823984418/hc32_driver_sys

I think this is a great idea, so I’m sharing it here. The implementation is still rough, but it simply expresses what I want to achieve.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions