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

Unify exports for named types #31

Closed randomPoison closed 4 years ago

randomPoison commented 4 years ago

We currently differentiate between enums and structs for exported items: The Export enum has separate variants for Struct and Enum, and we have different Struct and Enum types. In practice though, these end up almost identical:

pub struct Struct {
    pub name: Cow<'static, str>,
    pub binding_style: BindingStyle,
    pub schema: Schema,
}

pub struct Enum {
    pub name: Cow<'static, str>,
    pub binding_style: BindingStyle,
    pub schema: Schema,
}

This setup also introduces some problems for the C# code generation:

We could improve this by unifying struct and enum exports into a single "named export" type.