Skip to content

Commit

Permalink
change enum type to be shortest to match flags length
Browse files Browse the repository at this point in the history
  • Loading branch information
yowl committed Jan 4, 2024
1 parent e4d6b6a commit 277e076
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crates/csharp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> {
.map(|(i, flag)| {
let flag_name = flag.name.to_shouty_snake_case();
let suffix = if matches!(flags.repr(), FlagsRepr::U32(2)) {
"L"
"UL"
} else {
""
};
Expand All @@ -1180,10 +1180,11 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> {
.collect::<Vec<_>>()
.join("\n");

let enum_type = if matches!(flags.repr(), FlagsRepr::U32(2)) {
": long"
} else {
""
let enum_type = match flags.repr() {
FlagsRepr::U32(2) => ": ulong",
FlagsRepr::U16 => ": ushort",
FlagsRepr::U8 => ": byte",
_ => "",
};

uwrite!(
Expand Down

0 comments on commit 277e076

Please sign in to comment.