Skip to content

Commit 2ba76f2

Browse files
committed
changed bitfields to be i64 instead of u64
1 parent 8ecd619 commit 2ba76f2

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

godot-codegen/src/generator/enums.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ pub fn make_enum_definition(enum_: &Enum) -> TokenStream {
8989
}
9090
}
9191
};
92-
enum_ord_type = quote! { u64 };
92+
enum_ord_type = quote! { i64 };
9393
self_as_trait = quote! { <Self as crate::obj::EngineBitfield> };
9494
engine_impl = quote! {
9595
impl crate::obj::EngineBitfield for #rust_enum_name {
96-
fn try_from_ord(ord: u64) -> Option<Self> {
96+
fn try_from_ord(ord: i64) -> Option<Self> {
9797
Some(Self { ord })
9898
}
9999

100-
fn ord(self) -> u64 {
100+
fn ord(self) -> i64 {
101101
self.ord
102102
}
103103
}
@@ -128,7 +128,7 @@ pub fn make_enum_definition(enum_: &Enum) -> TokenStream {
128128

129129
// Enumerator ordinal stored as i32, since that's enough to hold all current values and the default repr in C++.
130130
// Public interface is i64 though, for consistency (and possibly forward compatibility?).
131-
// Bitfield ordinals are stored as u64. See also: https://github.com/godotengine/godot-cpp/pull/1320
131+
// Bitfield ordinals are stored as i64.
132132
quote! {
133133
#[repr(transparent)]
134134
#[derive(#( #derives ),*)]
@@ -172,8 +172,8 @@ pub fn make_enumerator_ord(ord: i32) -> Literal {
172172
// ----------------------------------------------------------------------------------------------------------------------------------------------
173173
// Implementation
174174

175-
fn make_bitfield_flag_ord(ord: u64) -> Literal {
176-
Literal::u64_suffixed(ord)
175+
fn make_bitfield_flag_ord(ord: i64) -> Literal {
176+
Literal::i64_suffixed(ord)
177177
}
178178

179179
fn make_enumerator_definition(enumerator: &Enumerator) -> TokenStream {

godot-codegen/src/models/domain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ pub struct Enumerator {
201201
}
202202
pub enum EnumeratorValue {
203203
Enum(i32),
204-
Bitfield(u64),
204+
Bitfield(i64),
205205
}
206206

207207
impl EnumeratorValue {

godot-core/src/obj/traits.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,12 @@ pub trait EngineEnum: Copy {
161161

162162
/// Auto-implemented for all engine-provided bitfields.
163163
pub trait EngineBitfield: Copy {
164-
fn try_from_ord(ord: u64) -> Option<Self>;
164+
fn try_from_ord(ord: i64) -> Option<Self>;
165165

166166
/// Ordinal value of the bit flag, as specified in Godot.
167-
fn ord(self) -> u64;
167+
fn ord(self) -> i64;
168168

169-
fn from_ord(ord: u64) -> Self {
169+
fn from_ord(ord: i64) -> Self {
170170
Self::try_from_ord(ord)
171171
.unwrap_or_else(|| panic!("ordinal {ord} does not map to any valid bit flag"))
172172
}

0 commit comments

Comments
 (0)