File tree 6 files changed +40
-13
lines changed
6 files changed +40
-13
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,10 @@ mod prebuilt {
103
103
full_string : godot4_prebuilt:: GODOT_VERSION . into ( ) ,
104
104
major : version[ 0 ] . parse ( ) . unwrap ( ) ,
105
105
minor : version[ 1 ] . parse ( ) . unwrap ( ) ,
106
- patch : version[ 2 ] . parse ( ) . unwrap ( ) ,
106
+ patch : version
107
+ . get ( 2 )
108
+ . and_then ( |patch| patch. parse ( ) . ok ( ) )
109
+ . unwrap_or ( 0 ) ,
107
110
status : "stable" . into ( ) ,
108
111
custom_rev : None ,
109
112
}
@@ -132,12 +135,12 @@ pub fn emit_godot_version_cfg() {
132
135
..
133
136
} = get_godot_version ( ) ;
134
137
135
- println ! ( r#"cargo:rustc-cfg=gdextension_api_version ="{major}.{minor}""# ) ;
138
+ println ! ( r#"cargo:rustc-cfg=gdextension_api ="{major}.{minor}""# ) ;
136
139
137
140
// Godot drops the patch version if it is 0.
138
141
if patch != 0 {
139
- println ! ( r#"cargo:rustc-cfg=gdextension_api_version_full ="{major}.{minor}.{patch}""# ) ;
142
+ println ! ( r#"cargo:rustc-cfg=gdextension_exact_api ="{major}.{minor}.{patch}""# ) ;
140
143
} else {
141
- println ! ( r#"cargo:rustc-cfg=gdextension_api_version_full ="{major}.{minor}""# ) ;
144
+ println ! ( r#"cargo:rustc-cfg=gdextension_exact_api ="{major}.{minor}""# ) ;
142
145
}
143
146
}
Original file line number Diff line number Diff line change @@ -143,12 +143,12 @@ impl Basis {
143
143
/// orthonormalized. The `target` and `up` vectors cannot be zero, and
144
144
/// cannot be parallel to each other.
145
145
///
146
- #[ cfg( gdextension_api_version = "4.0" ) ]
146
+ #[ cfg( gdextension_api = "4.0" ) ]
147
147
/// _Godot equivalent: `Basis.looking_at()`_
148
148
pub fn new_looking_at ( target : Vector3 , up : Vector3 ) -> Self {
149
149
super :: inner:: InnerBasis :: looking_at ( target, up)
150
150
}
151
- #[ cfg( not( gdextension_api_version = "4.0" ) ) ]
151
+ #[ cfg( not( gdextension_api = "4.0" ) ) ]
152
152
/// If `use_model_front` is true, the +Z axis (asset front) is treated as forward (implies +X is left)
153
153
/// and points toward the target position. By default, the -Z axis (camera forward) is treated as forward
154
154
/// (implies +X is right).
Original file line number Diff line number Diff line change @@ -145,15 +145,15 @@ impl Transform3D {
145
145
/// See [`Basis::new_looking_at()`] for more information.
146
146
///
147
147
/// _Godot equivalent: Transform3D.looking_at()_
148
- #[ cfg( gdextension_api_version = "4.0" ) ]
148
+ #[ cfg( gdextension_api = "4.0" ) ]
149
149
#[ must_use]
150
150
pub fn looking_at ( self , target : Vector3 , up : Vector3 ) -> Self {
151
151
Self {
152
152
basis : Basis :: new_looking_at ( target - self . origin , up) ,
153
153
origin : self . origin ,
154
154
}
155
155
}
156
- #[ cfg( not( gdextension_api_version = "4.0" ) ) ]
156
+ #[ cfg( not( gdextension_api = "4.0" ) ) ]
157
157
#[ must_use]
158
158
pub fn looking_at ( self , target : Vector3 , up : Vector3 , use_model_front : bool ) -> Self {
159
159
Self {
Original file line number Diff line number Diff line change @@ -61,13 +61,21 @@ macro_rules! impl_variant_traits {
61
61
return Err ( VariantConversionError :: BadType )
62
62
}
63
63
64
+ // For 4.0:
64
65
// In contrast to T -> Variant, the conversion Variant -> T assumes
65
66
// that the destination is initialized (at least for some T). For example:
66
67
// void String::operator=(const String &p_str) { _cowdata._ref(p_str._cowdata); }
67
68
// does a copy-on-write and explodes if this->_cowdata is not initialized.
68
69
// We can thus NOT use Self::from_sys_init().
70
+ //
71
+ // This was changed in 4.1.
69
72
let result = unsafe {
70
- Self :: from_sys_init( |self_ptr| {
73
+ #[ cfg( gdextension_api = "4.0" ) ]
74
+ let from_sys_init = Self :: from_sys_init_default;
75
+ #[ cfg( not( gdextension_api = "4.0" ) ) ]
76
+ let from_sys_init = Self :: from_sys_init;
77
+
78
+ from_sys_init( |self_ptr| {
71
79
let converter = sys:: builtin_fn!( $to_fn) ;
72
80
converter( self_ptr, variant. var_sys( ) ) ;
73
81
} )
Original file line number Diff line number Diff line change @@ -132,6 +132,22 @@ impl Variant {
132
132
let op_sys = op. sys ( ) ;
133
133
let mut is_valid = false as u8 ;
134
134
135
+ #[ cfg( gdextension_api = "4.0" ) ]
136
+ let result = {
137
+ #[ allow( unused_mut) ]
138
+ let mut result = Variant :: nil ( ) ;
139
+ unsafe {
140
+ interface_fn ! ( variant_evaluate) (
141
+ op_sys,
142
+ self . var_sys ( ) ,
143
+ rhs. var_sys ( ) ,
144
+ result. var_sys ( ) ,
145
+ ptr:: addr_of_mut!( is_valid) ,
146
+ )
147
+ } ;
148
+ result
149
+ } ;
150
+ #[ cfg( not( gdextension_api = "4.0" ) ) ]
135
151
let result = unsafe {
136
152
Variant :: from_var_sys_init ( |variant_ptr| {
137
153
interface_fn ! ( variant_evaluate) (
Original file line number Diff line number Diff line change @@ -152,14 +152,14 @@ pub mod private {
152
152
macro_rules! generate_gdextension_api_version {
153
153
(
154
154
$(
155
- $name: ident => {
155
+ ( $name: ident, $gdextension_api : ident ) => {
156
156
$( $version: literal, ) *
157
157
}
158
158
) ,* $( , ) ?
159
159
) => {
160
160
$(
161
161
$(
162
- #[ cfg( gdextension_api_version = $version) ]
162
+ #[ cfg( $gdextension_api = $version) ]
163
163
#[ allow( dead_code) ]
164
164
const $name: & str = $version;
165
165
) *
@@ -172,14 +172,14 @@ macro_rules! generate_gdextension_api_version {
172
172
//
173
173
// This includes all versions we're developing for, including unreleased future versions.
174
174
generate_gdextension_api_version ! (
175
- GDEXTENSION_API_VERSION_FULL => {
175
+ ( GDEXTENSION_API_VERSION_FULL , gdextension_exact_api ) => {
176
176
"4.0" ,
177
177
"4.0.1" ,
178
178
"4.0.2" ,
179
179
"4.0.3" ,
180
180
"4.1" ,
181
181
} ,
182
- GDEXTENSION_API_VERSION => {
182
+ ( GDEXTENSION_API_VERSION , gdextension_api ) => {
183
183
"4.0" ,
184
184
"4.1" ,
185
185
} ,
You can’t perform that action at this time.
0 commit comments