randomPoison / cs-bindgen

Experiment in using Rust to build a library that can be loaded by Unity across multiple platforms
4 stars 0 forks source link

Support exposing structs via an owned handle #15

Closed randomPoison closed 4 years ago

randomPoison commented 4 years ago

Support #[cs_bindgen] on structs and impl blocks by wrapping the struct in an opaque handle type. We generate a C# class with constructors and methods corresponding to any methods in impl blocks for the Rust types. The current system is still syntax-based, so code generation around impl blocks is pretty fragile and it'd be pretty easy to cause things to break. It works well enough as a starting point, though.