Skip to content

Add a feature to simplify enums used as tagged unions #353

@porky11

Description

@porky11

When enum variants contain data, they will be converted to a tagged union in C.
The variants will be converted to new types with complicated long names.

In cases, where the enum variants only contain a single field, it seems preferable not to define new types for the fields of the untagged union in the C struct, representing the tagged union, but just use the single field types.

An example, where this causes unnecessary structs, is wgpu.
I just described in this issue, how I'd prefer the C code to look like.

Since I don't see a reason to have single value wrapper structs in a C binding, I'd prefer it to just use the existing types by default in this case.
But I can also think of configuration options for enums.
For consistency reasons it may be more reasonable to always create a new type, except the specific option is set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions