rust-lang / rust-lang/rust-bindgen
Make C++ function overloading less dependent on source ordering
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
(Original report hidden by @fitzgen)
It would be nice to be able to rename the rust-side name for overloaded methods (methods and constructors) based on their signature by passing in some kind of mapping file to bindgen. Without this, there's no guarantee that the function names will be stable (e.g. if upstream adds another constructor/overload).
If there's an easy way to parse rust-like syntax (e.g. via the macro mechanism, but dynamically?), then maybe a mapping file could look something like:
rename SkPaint {
SkPaint() -> Self => new;
SkPaint(*const root::SkPaint) -> Self => new_copy;
someOverloadedMethod(i32) => some_overloaded_i32;
someOverloadedMethod(f32) => some_overloaded_f32;
// remove this method from the output entirely, overloaded or otherwise (maybe?)
anotherMethod(i32) => None;
}
someone could later expand upon that to allow you to reorder arguments or manually specify which method to call to implement Clone or Copy traits.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files, tests, or entry points. Start by examining how bindgen represents C++ overloaded methods and constructors, then define a mapping mechanism that gives generated Rust names based on signatures; done means overload names remain stable when upstream adds another overload.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100