rust-lang / rust-lang/rust-bindgen
Problems binding to Resonance Audio - failing cargo layout tests, methods generated as free functions, probable struct return problem
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Hi,
I'm attempting to create bindings for Resonance audio. Here are some things I've noticed, which I'm not sure might be part of the cause:
- When running
cargo test, there are numerous failures, and I noticed the failing test cases are either:
- instantiations of template functions
- Classes inheriting from parents that in turn, inherit from someone else. The parent class has implementation of some of the grandparent's methods, with some virtual.
- Most methods in c++ are generated as free-standing functions that take a this pointer in Rust. For example,
int vraudio::ResonanceAudioApiImpl::CreateStereoSource(size_t num_channels)
comes out as
pub unsafe extern "C" fn ResonanceAudioApiImpl_CreateStereoSource(
this: *mut c_void,
num_channels: usize
) -> ResonanceAudioApi_SourceId
type ResonanceAudioApi_SourceId = c_int;
- It crashes when after I create a class, I attempt to call a method on it (src/main.rs). As discussed in the previous issue, the most likely cause is https://github.com/rust-lang/rust/issues/38258
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
Start by reproducing the reported failures with cargo test in the Resonance Audio bindings project, then inspect src/main.rs for the crash when calling a method on a created class. Compare the generated free-function signatures and struct-return behavior with the failing tests; done means the relevant layout tests pass and the method call no longer crashes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100