Skip to content

Commit

Permalink
Try #162:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Mar 12, 2023
2 parents 54cb201 + 5965e0b commit 7d8b596
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion godot-codegen/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,20 @@ pub fn make_enum_definition(enum_: &Enum) -> TokenStream {
None
};

let mut derives = vec!["Copy", "Clone", "Eq", "PartialEq", "Debug", "Hash"];

if enum_.is_bitfield {
derives.push("Default");
}

let derives: Vec<_> = derives.into_iter().map(ident).collect();

// Enumerator ordinal stored as i32, since that's enough to hold all current values and the default repr in C++.
// Public interface is i64 though, for consistency (and possibly forward compatibility?).
// TODO maybe generalize GodotFfi over EngineEnum trait
quote! {
#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash)]
#[derive(#( #derives ),*)]
pub struct #enum_name {
ord: i32
}
Expand Down

0 comments on commit 7d8b596

Please sign in to comment.