File tree 5 files changed +12
-19
lines changed
itest/rust/src/object_tests
5 files changed +12
-19
lines changed Original file line number Diff line number Diff line change @@ -197,11 +197,11 @@ fn make_enum_engine_trait_impl(enum_: &Enum) -> TokenStream {
197
197
// }
198
198
199
199
impl #engine_trait for #name {
200
- fn try_from_ord( ord: u64 ) -> Option <Self > {
200
+ fn try_from_ord( ord: i64 ) -> Option <Self > {
201
201
Some ( Self { ord } )
202
202
}
203
203
204
- fn ord( self ) -> u64 {
204
+ fn ord( self ) -> i64 {
205
205
self . ord
206
206
}
207
207
}
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ impl Enum {
39
39
/// The type we use to represent values of this enum.
40
40
pub fn ord_type ( & self ) -> Ident {
41
41
if self . is_bitfield {
42
- ident ( "u64 " )
42
+ ident ( "i64 " )
43
43
} else {
44
44
ident ( "i32" )
45
45
}
@@ -126,7 +126,7 @@ pub struct Enumerator {
126
126
#[ derive( Clone ) ]
127
127
pub enum EnumeratorValue {
128
128
Enum ( i32 ) ,
129
- Bitfield ( u64 ) ,
129
+ Bitfield ( i64 ) ,
130
130
}
131
131
132
132
impl EnumeratorValue {
@@ -145,7 +145,7 @@ impl EnumeratorValue {
145
145
// Conversion is safe because i64 is used in the original JSON.
146
146
match self {
147
147
EnumeratorValue :: Enum ( i) => * i as i64 ,
148
- EnumeratorValue :: Bitfield ( i) => * i as i64 ,
148
+ EnumeratorValue :: Bitfield ( i) => * i,
149
149
}
150
150
}
151
151
Original file line number Diff line number Diff line change @@ -571,14 +571,7 @@ impl Enum {
571
571
impl Enumerator {
572
572
pub fn from_json ( json : & JsonEnumConstant , rust_name : Ident , is_bitfield : bool ) -> Self {
573
573
let value = if is_bitfield {
574
- let ord = json. value . try_into ( ) . unwrap_or_else ( |_| {
575
- panic ! (
576
- "bitfield value {} = {} is negative; please report this" ,
577
- json. name, json. value
578
- )
579
- } ) ;
580
-
581
- EnumeratorValue :: Bitfield ( ord)
574
+ EnumeratorValue :: Bitfield ( json. value )
582
575
} else {
583
576
let ord = json. value . try_into ( ) . unwrap_or_else ( |_| {
584
577
panic ! (
Original file line number Diff line number Diff line change @@ -167,12 +167,12 @@ pub trait EngineEnum: Copy {
167
167
168
168
/// Auto-implemented for all engine-provided bitfields.
169
169
pub trait EngineBitfield : Copy {
170
- fn try_from_ord ( ord : u64 ) -> Option < Self > ;
170
+ fn try_from_ord ( ord : i64 ) -> Option < Self > ;
171
171
172
172
/// Ordinal value of the bit flag, as specified in Godot.
173
- fn ord ( self ) -> u64 ;
173
+ fn ord ( self ) -> i64 ;
174
174
175
- fn from_ord ( ord : u64 ) -> Self {
175
+ fn from_ord ( ord : i64 ) -> Self {
176
176
Self :: try_from_ord ( ord)
177
177
. unwrap_or_else ( || panic ! ( "ordinal {ord} does not map to any valid bit flag" ) )
178
178
}
Original file line number Diff line number Diff line change @@ -61,12 +61,12 @@ fn property_template_test(ctx: &TestContext) {
61
61
let mut rust_usage = rust_prop. get ( "usage" ) . unwrap ( ) . to :: < i64 > ( ) ;
62
62
63
63
// the GDSscript variables are script variables, and so have `PROPERTY_USAGE_SCRIPT_VARIABLE` set.
64
- if rust_usage == PropertyUsageFlags :: STORAGE . ord ( ) as i64 {
64
+ if rust_usage == PropertyUsageFlags :: STORAGE . ord ( ) {
65
65
// `PROPERTY_USAGE_SCRIPT_VARIABLE` does the same thing as `PROPERTY_USAGE_STORAGE` and so
66
66
// GDScript doesn't set both if it doesn't need to.
67
- rust_usage = PropertyUsageFlags :: SCRIPT_VARIABLE . ord ( ) as i64
67
+ rust_usage = PropertyUsageFlags :: SCRIPT_VARIABLE . ord ( )
68
68
} else {
69
- rust_usage |= PropertyUsageFlags :: SCRIPT_VARIABLE . ord ( ) as i64 ;
69
+ rust_usage |= PropertyUsageFlags :: SCRIPT_VARIABLE . ord ( ) ;
70
70
}
71
71
72
72
rust_prop. set ( "usage" , rust_usage) ;
You can’t perform that action at this time.
0 commit comments