Skip to content

Commit 62f0f8b

Browse files
committed
Implemet Default for Bitsets
1 parent ac5f78c commit 62f0f8b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

godot-codegen/src/util.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,20 @@ pub fn make_enum_definition(enum_: &Enum) -> TokenStream {
5858
None
5959
};
6060

61+
let mut derives = vec!["Copy", "Clone", "Eq", "PartialEq", "Debug", "Hash"];
62+
63+
if enum_.is_bitfield {
64+
derives.push("Default");
65+
}
66+
67+
let derives = derives.into_iter().map(ident);
68+
6169
// Enumerator ordinal stored as i32, since that's enough to hold all current values and the default repr in C++.
6270
// Public interface is i64 though, for consistency (and possibly forward compatibility?).
6371
// TODO maybe generalize GodotFfi over EngineEnum trait
6472
quote! {
6573
#[repr(transparent)]
66-
#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash)]
74+
#[derive(#( #derives ),*)]
6775
pub struct #enum_name {
6876
ord: i32
6977
}

0 commit comments

Comments
 (0)