@@ -166,13 +166,172 @@ mod impls {
166
166
impl_ffi_variant ! ( ref PackedStringArray , packed_string_array_to_variant, packed_string_array_from_variant) ;
167
167
impl_ffi_variant ! ( ref PackedVector2Array , packed_vector2_array_to_variant, packed_vector2_array_from_variant) ;
168
168
impl_ffi_variant ! ( ref PackedVector3Array , packed_vector3_array_to_variant, packed_vector3_array_from_variant) ;
169
- #[ cfg( since_api = "4.3" ) ]
170
- impl_ffi_variant ! ( ref PackedVector4Array , packed_vector4_array_to_variant, packed_vector4_array_from_variant) ;
171
169
impl_ffi_variant ! ( ref PackedColorArray , packed_color_array_to_variant, packed_color_array_from_variant) ;
172
170
impl_ffi_variant ! ( ref Signal , signal_to_variant, signal_from_variant) ;
173
171
impl_ffi_variant ! ( ref Callable , callable_to_variant, callable_from_variant) ;
172
+
173
+ #[ cfg( since_api = "4.2" ) ]
174
+ mod api_4_2 {
175
+ use crate :: task:: impl_dynamic_send;
176
+
177
+ impl_dynamic_send ! (
178
+ Send ;
179
+ bool , u8 , u16 , u32 , u64 , i8 , i16 , i32 , i64 , f32 , f64
180
+ ) ;
181
+
182
+ impl_dynamic_send ! (
183
+ Send ;
184
+ builtin:: {
185
+ StringName , Transform2D , Transform3D , Vector2 , Vector2i , Vector2Axis ,
186
+ Vector3 , Vector3i , Vector3Axis , Vector4 , Vector4i , Rect2 , Rect2i , Plane , Quaternion , Aabb , Basis , Projection , Color , Rid
187
+ }
188
+ ) ;
189
+
190
+ impl_dynamic_send ! (
191
+ !Send ;
192
+ Variant , GString , Dictionary , VariantArray , Callable , NodePath , PackedByteArray , PackedInt32Array , PackedInt64Array , PackedFloat32Array ,
193
+ PackedFloat64Array , PackedStringArray , PackedVector2Array , PackedVector3Array , PackedColorArray , Signal
194
+ ) ;
195
+
196
+ // This should be kept in sync with crate::registry::signal::variadic.
197
+ impl_dynamic_send ! ( tuple; ) ;
198
+ impl_dynamic_send ! ( tuple; arg1: A1 ) ;
199
+ impl_dynamic_send ! ( tuple; arg1: A1 , arg2: A2 ) ;
200
+ impl_dynamic_send ! ( tuple; arg1: A1 , arg2: A2 , arg3: A3 ) ;
201
+ impl_dynamic_send ! ( tuple; arg1: A1 , arg2: A2 , arg3: A3 , arg4: A4 ) ;
202
+ impl_dynamic_send ! ( tuple; arg1: A1 , arg2: A2 , arg3: A3 , arg4: A4 , arg5: A5 ) ;
203
+ impl_dynamic_send ! ( tuple; arg1: A1 , arg2: A2 , arg3: A3 , arg4: A4 , arg5: A5 , arg6: A6 ) ;
204
+ impl_dynamic_send ! ( tuple; arg1: A1 , arg2: A2 , arg3: A3 , arg4: A4 , arg5: A5 , arg6: A6 , arg7: A7 ) ;
205
+ impl_dynamic_send ! ( tuple; arg1: A1 , arg2: A2 , arg3: A3 , arg4: A4 , arg5: A5 , arg6: A6 , arg7: A7 , arg8: A8 ) ;
206
+ impl_dynamic_send ! ( tuple; arg1: A1 , arg2: A2 , arg3: A3 , arg4: A4 , arg5: A5 , arg6: A6 , arg7: A7 , arg8: A8 , arg9: A9 ) ;
207
+ }
208
+
209
+ #[ cfg( since_api = "4.3" ) ]
210
+ mod api_4_3 {
211
+ use crate :: task:: impl_dynamic_send;
212
+
213
+ use super :: * ;
214
+
215
+ impl_ffi_variant ! ( ref PackedVector4Array , packed_vector4_array_to_variant, packed_vector4_array_from_variant) ;
216
+
217
+ impl_dynamic_send ! ( !Send ; PackedVector4Array ) ;
218
+ }
174
219
}
175
220
221
+ // Compile time check that we cover all the Variant types with trait implementations for:
222
+ // - IntoDynamicSend
223
+ // - DynamicSend
224
+ // - GodotType
225
+ // - ArrayElement
226
+ const _: ( ) = {
227
+ use crate :: classes:: Object ;
228
+ use crate :: obj:: { Gd , IndexEnum } ;
229
+
230
+ #[ cfg( before_api = "4.2" ) ]
231
+ const fn variant_type < T : GodotType + ArrayElement > ( ) -> VariantType {
232
+ <T :: Ffi as sys:: GodotFfi >:: VARIANT_TYPE
233
+ }
234
+
235
+ #[ cfg( since_api = "4.2" ) ]
236
+ const fn variant_type < T : crate :: task:: IntoDynamicSend + GodotType + ArrayElement > (
237
+ ) -> VariantType {
238
+ <T :: Ffi as sys:: GodotFfi >:: VARIANT_TYPE
239
+ }
240
+
241
+ const NIL : VariantType = variant_type :: < Variant > ( ) ;
242
+ const BOOL : VariantType = variant_type :: < bool > ( ) ;
243
+ const I64 : VariantType = variant_type :: < i64 > ( ) ;
244
+ const F64 : VariantType = variant_type :: < f64 > ( ) ;
245
+ const GSTRING : VariantType = variant_type :: < GString > ( ) ;
246
+
247
+ const VECTOR2 : VariantType = variant_type :: < Vector2 > ( ) ;
248
+ const VECTOR2I : VariantType = variant_type :: < Vector2i > ( ) ;
249
+ const RECT2 : VariantType = variant_type :: < Rect2 > ( ) ;
250
+ const RECT2I : VariantType = variant_type :: < Rect2i > ( ) ;
251
+ const VECTOR3 : VariantType = variant_type :: < Vector3 > ( ) ;
252
+ const VECTOR3I : VariantType = variant_type :: < Vector3i > ( ) ;
253
+ const TRANSFORM2D : VariantType = variant_type :: < Transform2D > ( ) ;
254
+ const TRANSFORM3D : VariantType = variant_type :: < Transform3D > ( ) ;
255
+ const VECTOR4 : VariantType = variant_type :: < Vector4 > ( ) ;
256
+ const VECTOR4I : VariantType = variant_type :: < Vector4i > ( ) ;
257
+ const PLANE : VariantType = variant_type :: < Plane > ( ) ;
258
+ const QUATERNION : VariantType = variant_type :: < Quaternion > ( ) ;
259
+ const AABB : VariantType = variant_type :: < Aabb > ( ) ;
260
+ const BASIS : VariantType = variant_type :: < Basis > ( ) ;
261
+ const PROJECTION : VariantType = variant_type :: < Projection > ( ) ;
262
+ const COLOR : VariantType = variant_type :: < Color > ( ) ;
263
+ const STRING_NAME : VariantType = variant_type :: < StringName > ( ) ;
264
+ const NODE_PATH : VariantType = variant_type :: < NodePath > ( ) ;
265
+ const RID : VariantType = variant_type :: < Rid > ( ) ;
266
+ const OBJECT : VariantType = variant_type :: < Gd < Object > > ( ) ;
267
+ const CALLABLE : VariantType = variant_type :: < Callable > ( ) ;
268
+ const SIGNAL : VariantType = variant_type :: < Signal > ( ) ;
269
+ const DICTIONARY : VariantType = variant_type :: < Dictionary > ( ) ;
270
+ const ARRAY : VariantType = variant_type :: < VariantArray > ( ) ;
271
+ const PACKED_BYTE_ARRAY : VariantType = variant_type :: < PackedByteArray > ( ) ;
272
+ const PACKED_INT32_ARRAY : VariantType = variant_type :: < PackedInt32Array > ( ) ;
273
+ const PACKED_INT64_ARRAY : VariantType = variant_type :: < PackedInt64Array > ( ) ;
274
+ const PACKED_FLOAT32_ARRAY : VariantType = variant_type :: < PackedFloat32Array > ( ) ;
275
+ const PACKED_FLOAT64_ARRAY : VariantType = variant_type :: < PackedFloat64Array > ( ) ;
276
+ const PACKED_STRING_ARRAY : VariantType = variant_type :: < PackedStringArray > ( ) ;
277
+ const PACKED_VECTOR2_ARRAY : VariantType = variant_type :: < PackedVector2Array > ( ) ;
278
+ const PACKED_VECTOR3_ARRAY : VariantType = variant_type :: < PackedVector3Array > ( ) ;
279
+ const PACKED_COLOR_ARRAY : VariantType = variant_type :: < PackedColorArray > ( ) ;
280
+
281
+ #[ cfg( since_api = "4.3" ) ]
282
+ const PACKED_VECTOR4_ARRAY : VariantType = variant_type :: < PackedVector4Array > ( ) ;
283
+
284
+ const MAX : i32 = VariantType :: ENUMERATOR_COUNT as i32 ;
285
+
286
+ // The matched value is not relevant, we just want to ensure that the full list from 0 to MAX is covered.
287
+ #[ deny( unreachable_patterns) ]
288
+ match VariantType :: STRING {
289
+ VariantType { ord : i32:: MIN ..0 } => panic ! ( "ord is out of defined range!" ) ,
290
+ NIL => ( ) ,
291
+ BOOL => ( ) ,
292
+ I64 => ( ) ,
293
+ F64 => ( ) ,
294
+ GSTRING => ( ) ,
295
+ VECTOR2 => ( ) ,
296
+ VECTOR2I => ( ) ,
297
+ RECT2 => ( ) ,
298
+ RECT2I => ( ) ,
299
+ VECTOR3 => ( ) ,
300
+ VECTOR3I => ( ) ,
301
+ TRANSFORM2D => ( ) ,
302
+ VECTOR4 => ( ) ,
303
+ VECTOR4I => ( ) ,
304
+ PLANE => ( ) ,
305
+ QUATERNION => ( ) ,
306
+ AABB => ( ) ,
307
+ BASIS => ( ) ,
308
+ TRANSFORM3D => ( ) ,
309
+ PROJECTION => ( ) ,
310
+ COLOR => ( ) ,
311
+ STRING_NAME => ( ) ,
312
+ NODE_PATH => ( ) ,
313
+ RID => ( ) ,
314
+ OBJECT => ( ) ,
315
+ CALLABLE => ( ) ,
316
+ SIGNAL => ( ) ,
317
+ DICTIONARY => ( ) ,
318
+ ARRAY => ( ) ,
319
+ PACKED_BYTE_ARRAY => ( ) ,
320
+ PACKED_INT32_ARRAY => ( ) ,
321
+ PACKED_INT64_ARRAY => ( ) ,
322
+ PACKED_FLOAT32_ARRAY => ( ) ,
323
+ PACKED_FLOAT64_ARRAY => ( ) ,
324
+ PACKED_STRING_ARRAY => ( ) ,
325
+ PACKED_VECTOR2_ARRAY => ( ) ,
326
+ PACKED_VECTOR3_ARRAY => ( ) ,
327
+ PACKED_COLOR_ARRAY => ( ) ,
328
+
329
+ #[ cfg( since_api = "4.3" ) ]
330
+ PACKED_VECTOR4_ARRAY => ( ) ,
331
+ VariantType { ord : MAX .. } => panic ! ( "ord is out of defined range!" ) ,
332
+ }
333
+ } ;
334
+
176
335
// ----------------------------------------------------------------------------------------------------------------------------------------------
177
336
// Explicit impls
178
337
0 commit comments