From 62f0f8bab58ad35dd9b30609ae7959a6ec97c349 Mon Sep 17 00:00:00 2001 From: mio991 Date: Thu, 9 Mar 2023 11:48:38 +0100 Subject: [PATCH] Implemet Default for Bitsets --- godot-codegen/src/util.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/godot-codegen/src/util.rs b/godot-codegen/src/util.rs index e599e170e..d3b4735f0 100644 --- a/godot-codegen/src/util.rs +++ b/godot-codegen/src/util.rs @@ -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 = derives.into_iter().map(ident); + // 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 }