autorust: generate cxx bindings for C++ -> Rust calls
- Dominant language
- Rust
- Stars
- 2.6k
- Forks
- 175
- PR merge metrics
- No merged PRs in 30d
Description
The purpose of autocxx is to skip the need to describe the C++/Rust interface in the `cxx` IDL.
At the moment, this works for existing _C++ APIs_.
The concept could be extended to existing Rust APIs, by adding some sort of attribute macro e.g.
```rust
#[autocxx::gen]
struct RustStruct {
a: u32,
}
#[autocxx::gen]
pub fn doSomething(s: RustStruct) {
...
}
```
These too could contribute to the `#[cxx::bridge]` mod we generate, but functions would go into an `extern "Rust"` section rather than the current `extern "C++"` section.
We already have most of the pipeline here:
* We parse the Rust file in a codegen tool using syn
* That tool already generated a `#[cxx::bridge]` mod
* We have macros which effectively replace the real Rust declarations with something else derived from that codegen tool.
This would be a significant direction change/enhancement for autocxx, so this isn't going to happen any time soon. Recording the idea for the record!
Contributor guide
Research direction
Start by tracing the existing codegen tool that parses Rust with syn and generates the #[cxx::bridge] module, then inspect the macros that replace Rust declarations. The issue is complete only when annotated Rust structs and functions can contribute to an extern "Rust" bridge section, but it provides no concrete files, tests, or settled design.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers, devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100