Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bitsets implement Default #162

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = 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
}
Expand Down