Skip to content

Commit

Permalink
remove dead code, fix lowering for >32 bit flags
Browse files Browse the repository at this point in the history
  • Loading branch information
yowl committed Dec 23, 2023
1 parent c0620e5 commit 56534ba
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions crates/csharp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1164,14 +1164,6 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> {

let name = name.to_upper_camel_case();

let ty = match flags.repr() {
FlagsRepr::U8 => "byte",
FlagsRepr::U16 => "ushort",
FlagsRepr::U32(1) => "uint",
FlagsRepr::U32(2) => "ulong",
repr => todo!("flags {repr:?}"),
};

let enum_elements = flags
.flags
.iter()
Expand Down Expand Up @@ -1500,9 +1492,14 @@ impl Bindgen for FunctionBindgen<'_, '_> {
ty: _,
} => {
if flags.flags.len() > 32 {
results.push(format!("((int){})", operands[0].to_string()));
results.push(format!(
"(int)(((long){}) & uint.MaxValue)",
operands[0].to_string()
));
results.push(format!("((int)({})) >> 32", operands[0].to_string()));
} else {
results.push(format!("(int){}", operands[0].to_string()));
}
results.push(format!("((int){})", operands[0].to_string()));
}

Instruction::FlagsLift { flags, name, ty } => {
Expand Down

0 comments on commit 56534ba

Please sign in to comment.