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