Add tool to read a Rust crate and generate C-compatible wrappers
authorMatt Corallo <git@bluematt.me>
Tue, 12 May 2020 18:49:29 +0000 (14:49 -0400)
committerMatt Corallo <git@bluematt.me>
Fri, 11 Sep 2020 01:58:44 +0000 (21:58 -0400)
commit48e8678a9a63319c87978b96a39b5848db757075
treef9910b2f1fa7b4a56a7ad6d34eb64eb3e6f849c2
parentbd5f2427c364040bc17dea4e65c9cd9174294e54
Add tool to read a Rust crate and generate C-compatible wrappers

In general, it maps:
 * Traits to a struct with a void* and a list of function pointers,
   emulating what the compiler will do for a dyn trait anyway,
 * Structs as a struct with a single opaque pointer to the
   underlying type and a flag to indicate ownership. While this is
   a bit less effecient than just a direct pointer, it neatly lets
   us expose in the public interface the concept of ownership by
   setting a flag in the generated struct.
 * Unit enums as enums with each type copied over and conversion
   functions,
 * Non-unit enums have each field converted back and forth with a
   type flag and a union across all the C-mapped fields.
c-bindings-gen/Cargo.toml [new file with mode: 0644]
c-bindings-gen/src/blocks.rs [new file with mode: 0644]
c-bindings-gen/src/main.rs [new file with mode: 0644]
c-bindings-gen/src/types.rs [new file with mode: 0644]