4 ms·
Yes, when using structs in an OO like way. Does it generate c-style rust wrapper ? or can it generate class-based rust wrapper ,perhaps with some guidance ?
by minthd 11y ago
Yes, when using structs in an OO like way. Does it generate c-style rust wrapper ? or can it generate class-based rust wrapper ,perhaps with some guidance ?
- ossreality 11y agoHow would you generate a class based wrapper from C? Do you understand what youre even asking?
- comex 11y agoAFAIK, rust-bindgen doesn't currently have support for translating C functions and structs into anything other than the same things in Rust. It's somewhat idiomatic for manually-written bindings, layered on top of the generated ones, to take care of things like providing a memory-safe interface (which can't really be done automatically), converting between native Rust types and C representations if necessary (perhaps including things like Result vs. error codes or nulls), and adding object orientation. If you want to go full automatic, though, you can do a lot with Rust macros, so give them a try. Examples of manual wrappers on top of bindgen - there are many: http://erickt.github.io/blog/2014/12/13/rust-and-mdbm/ http://erickt.github.io/blog/2014/12/13/rust-and-mdbm/ https://github.com/kenz-gelsoft/wxRust/blob/rust-servo/src/base.rs https://github.com/kenz-gelsoft/wxRust/blob/rust-servo/src/b... (I don't like the design of this one, actually) https://github.com/rust-gnome/gtk/blob/master/src/widgets/action_bar.rs https://github.com/rust-gnome/gtk/blob/master/src/widgets/ac... (better)