@@ -16,32 +16,28 @@ use sys::{ffi_methods, interface_fn, GodotFfi, TagString, TagType};
16
16
macro_rules! impl_packed_array {
17
17
(
18
18
// Name of the type to define, e.g. `PackedByteArray`.
19
- $PackedArray: ident,
19
+ type_name : $PackedArray: ident,
20
20
// Type of elements contained in the array, e.g. `u8`.
21
- $Element: ty,
21
+ element_type : $Element: ty,
22
22
// Name of wrapped opaque type, e.g. `OpaquePackedByteArray`.
23
- $Opaque: ty,
23
+ opaque_type : $Opaque: ty,
24
24
// Name of inner type, e.g. `InnerPackedByteArray`.
25
- $Inner: ident,
25
+ inner_type : $Inner: ident,
26
26
// Name of type that represents elements in function call arguments, e.g. `i64`. See
27
27
// `Self::into_arg()`.
28
- $Arg: ty,
28
+ argument_type : $Arg: ty,
29
29
// Type that is returned from `$operator_index` and `$operator_index_const`.
30
- $IndexRetType: ty,
31
- // Name of default constructor function from FFI, e.g.
32
- // `packed_byte_array_construct_default`.
33
- $construct_default: ident,
34
- // Name of copy constructor function from FFI, e.g.
35
- // `packed_byte_array_construct_copy`.
36
- $construct_copy: ident,
30
+ return_type: $IndexRetType: ty,
37
31
// Name of constructor function from `Array` from FFI, e.g. `packed_byte_array_from_array`.
38
- $from_array: ident,
39
- // Name of destructor function from FFI, e.g. `packed_byte_array_destroy`.
40
- $destroy: ident,
32
+ from_array: $from_array: ident,
41
33
// Name of index operator from FFI, e.g. `packed_byte_array_operator_index`.
42
- $operator_index: ident,
34
+ operator_index : $operator_index: ident,
43
35
// Name of const index operator from FFI, e.g. `packed_byte_array_operator_index_const`.
44
- $operator_index_const: ident,
36
+ operator_index_const: $operator_index_const: ident,
37
+ // Invocation passed to `impl_builtin_traits!` macro.
38
+ trait_impls: {
39
+ $( $trait_impls: tt) *
40
+ } ,
45
41
) => {
46
42
// TODO expand type names in doc comments (use e.g. `paste` crate)
47
43
/// Implements Godot's `$PackedArray` type, which is an efficient array of `$Element`s.
@@ -324,9 +320,7 @@ macro_rules! impl_packed_array {
324
320
325
321
impl_builtin_traits! {
326
322
for $PackedArray {
327
- Default => $construct_default;
328
- Clone => $construct_copy;
329
- Drop => $destroy;
323
+ $( $trait_impls) *
330
324
}
331
325
}
332
326
@@ -413,136 +407,163 @@ macro_rules! impl_packed_array {
413
407
}
414
408
415
409
impl_packed_array ! (
416
- PackedByteArray ,
417
- u8 ,
418
- OpaquePackedByteArray ,
419
- InnerPackedByteArray ,
420
- i64 ,
421
- u8 ,
422
- packed_byte_array_construct_default,
423
- packed_byte_array_construct_copy,
424
- packed_byte_array_from_array,
425
- packed_byte_array_destroy,
426
- packed_byte_array_operator_index,
427
- packed_byte_array_operator_index_const,
410
+ type_name: PackedByteArray ,
411
+ element_type: u8 ,
412
+ opaque_type: OpaquePackedByteArray ,
413
+ inner_type: InnerPackedByteArray ,
414
+ argument_type: i64 ,
415
+ return_type: u8 ,
416
+ from_array: packed_byte_array_from_array,
417
+ operator_index: packed_byte_array_operator_index,
418
+ operator_index_const: packed_byte_array_operator_index_const,
419
+ trait_impls: {
420
+ Default => packed_byte_array_construct_default;
421
+ Clone => packed_byte_array_construct_copy;
422
+ Drop => packed_byte_array_destroy;
423
+ Eq => packed_byte_array_operator_equal;
424
+ } ,
428
425
) ;
429
426
430
427
impl_packed_array ! (
431
- PackedInt32Array ,
432
- i32 ,
433
- OpaquePackedInt32Array ,
434
- InnerPackedInt32Array ,
435
- i64 ,
436
- i32 ,
437
- packed_int32_array_construct_default,
438
- packed_int32_array_construct_copy,
439
- packed_int32_array_from_array,
440
- packed_int32_array_destroy,
441
- packed_int32_array_operator_index,
442
- packed_int32_array_operator_index_const,
428
+ type_name: PackedInt32Array ,
429
+ element_type: i32 ,
430
+ opaque_type: OpaquePackedInt32Array ,
431
+ inner_type: InnerPackedInt32Array ,
432
+ argument_type: i64 ,
433
+ return_type: i32 ,
434
+ from_array: packed_int32_array_from_array,
435
+ operator_index: packed_int32_array_operator_index,
436
+ operator_index_const: packed_int32_array_operator_index_const,
437
+ trait_impls: {
438
+ Default => packed_int32_array_construct_default;
439
+ Clone => packed_int32_array_construct_copy;
440
+ Drop => packed_int32_array_destroy;
441
+ Eq => packed_int32_array_operator_equal;
442
+ } ,
443
443
) ;
444
444
445
445
impl_packed_array ! (
446
- PackedInt64Array ,
447
- i64 ,
448
- OpaquePackedInt64Array ,
449
- InnerPackedInt64Array ,
450
- i64 ,
451
- i64 ,
452
- packed_int64_array_construct_default,
453
- packed_int64_array_construct_copy,
454
- packed_int64_array_from_array,
455
- packed_int64_array_destroy,
456
- packed_int64_array_operator_index,
457
- packed_int64_array_operator_index_const,
446
+ type_name: PackedInt64Array ,
447
+ element_type: i64 ,
448
+ opaque_type: OpaquePackedInt64Array ,
449
+ inner_type: InnerPackedInt64Array ,
450
+ argument_type: i64 ,
451
+ return_type: i64 ,
452
+ from_array: packed_int64_array_from_array,
453
+ operator_index: packed_int64_array_operator_index,
454
+ operator_index_const: packed_int64_array_operator_index_const,
455
+ trait_impls: {
456
+ Default => packed_int64_array_construct_default;
457
+ Clone => packed_int64_array_construct_copy;
458
+ Drop => packed_int64_array_destroy;
459
+ Eq => packed_int64_array_operator_equal;
460
+ } ,
458
461
) ;
459
462
460
463
impl_packed_array ! (
461
- PackedFloat32Array ,
462
- f32 ,
463
- OpaquePackedFloat32Array ,
464
- InnerPackedFloat32Array ,
465
- f64 ,
466
- f32 ,
467
- packed_float32_array_construct_default,
468
- packed_float32_array_construct_copy,
469
- packed_float32_array_from_array,
470
- packed_float32_array_destroy,
471
- packed_float32_array_operator_index,
472
- packed_float32_array_operator_index_const,
464
+ type_name: PackedFloat32Array ,
465
+ element_type: f32 ,
466
+ opaque_type: OpaquePackedFloat32Array ,
467
+ inner_type: InnerPackedFloat32Array ,
468
+ argument_type: f64 ,
469
+ return_type: f32 ,
470
+ from_array: packed_float32_array_from_array,
471
+ operator_index: packed_float32_array_operator_index,
472
+ operator_index_const: packed_float32_array_operator_index_const,
473
+ trait_impls: {
474
+ Default => packed_float32_array_construct_default;
475
+ Clone => packed_float32_array_construct_copy;
476
+ Drop => packed_float32_array_destroy;
477
+ PartialEq => packed_float32_array_operator_equal;
478
+ } ,
473
479
) ;
474
480
475
481
impl_packed_array ! (
476
- PackedFloat64Array ,
477
- f64 ,
478
- OpaquePackedFloat64Array ,
479
- InnerPackedFloat64Array ,
480
- f64 ,
481
- f64 ,
482
- packed_float64_array_construct_default,
483
- packed_float64_array_construct_copy,
484
- packed_float64_array_from_array,
485
- packed_float64_array_destroy,
486
- packed_float64_array_operator_index,
487
- packed_float64_array_operator_index_const,
482
+ type_name: PackedFloat64Array ,
483
+ element_type: f64 ,
484
+ opaque_type: OpaquePackedFloat64Array ,
485
+ inner_type: InnerPackedFloat64Array ,
486
+ argument_type: f64 ,
487
+ return_type: f64 ,
488
+ from_array: packed_float64_array_from_array,
489
+ operator_index: packed_float64_array_operator_index,
490
+ operator_index_const: packed_float64_array_operator_index_const,
491
+ trait_impls: {
492
+ Default => packed_float64_array_construct_default;
493
+ Clone => packed_float64_array_construct_copy;
494
+ Drop => packed_float64_array_destroy;
495
+ PartialEq => packed_float64_array_operator_equal;
496
+ } ,
488
497
) ;
489
498
490
499
impl_packed_array ! (
491
- PackedStringArray ,
492
- GodotString ,
493
- OpaquePackedStringArray ,
494
- InnerPackedStringArray ,
495
- GodotString ,
496
- TagString ,
497
- packed_string_array_construct_default,
498
- packed_string_array_construct_copy,
499
- packed_string_array_from_array,
500
- packed_string_array_destroy,
501
- packed_string_array_operator_index,
502
- packed_string_array_operator_index_const,
500
+ type_name: PackedStringArray ,
501
+ element_type: GodotString ,
502
+ opaque_type: OpaquePackedStringArray ,
503
+ inner_type: InnerPackedStringArray ,
504
+ argument_type: GodotString ,
505
+ return_type: TagString ,
506
+ from_array: packed_string_array_from_array,
507
+ operator_index: packed_string_array_operator_index,
508
+ operator_index_const: packed_string_array_operator_index_const,
509
+ trait_impls: {
510
+ Default => packed_string_array_construct_default;
511
+ Clone => packed_string_array_construct_copy;
512
+ Drop => packed_string_array_destroy;
513
+ Eq => packed_string_array_operator_equal;
514
+ } ,
503
515
) ;
504
516
505
517
impl_packed_array ! (
506
- PackedVector2Array ,
507
- Vector2 ,
508
- OpaquePackedVector2Array ,
509
- InnerPackedVector2Array ,
510
- Vector2 ,
511
- TagType ,
512
- packed_vector2_array_construct_default,
513
- packed_vector2_array_construct_copy,
514
- packed_vector2_array_from_array,
515
- packed_vector2_array_destroy,
516
- packed_vector2_array_operator_index,
517
- packed_vector2_array_operator_index_const,
518
+ type_name: PackedVector2Array ,
519
+ element_type: Vector2 ,
520
+ opaque_type: OpaquePackedVector2Array ,
521
+ inner_type: InnerPackedVector2Array ,
522
+ argument_type: Vector2 ,
523
+ return_type: TagType ,
524
+ from_array: packed_vector2_array_from_array,
525
+ operator_index: packed_vector2_array_operator_index,
526
+ operator_index_const: packed_vector2_array_operator_index_const,
527
+ trait_impls: {
528
+ Default => packed_vector2_array_construct_default;
529
+ Clone => packed_vector2_array_construct_copy;
530
+ Drop => packed_vector2_array_destroy;
531
+ PartialEq => packed_vector2_array_operator_equal;
532
+ } ,
518
533
) ;
519
534
520
535
impl_packed_array ! (
521
- PackedVector3Array ,
522
- Vector3 ,
523
- OpaquePackedVector3Array ,
524
- InnerPackedVector3Array ,
525
- Vector3 ,
526
- TagType ,
527
- packed_vector3_array_construct_default,
528
- packed_vector3_array_construct_copy,
529
- packed_vector3_array_from_array,
530
- packed_vector3_array_destroy,
531
- packed_vector3_array_operator_index,
532
- packed_vector3_array_operator_index_const,
536
+ type_name: PackedVector3Array ,
537
+ element_type: Vector3 ,
538
+ opaque_type: OpaquePackedVector3Array ,
539
+ inner_type: InnerPackedVector3Array ,
540
+ argument_type: Vector3 ,
541
+ return_type: TagType ,
542
+ from_array: packed_vector3_array_from_array,
543
+ operator_index: packed_vector3_array_operator_index,
544
+ operator_index_const: packed_vector3_array_operator_index_const,
545
+ trait_impls: {
546
+ Default => packed_vector3_array_construct_default;
547
+ Clone => packed_vector3_array_construct_copy;
548
+ Drop => packed_vector3_array_destroy;
549
+ PartialEq => packed_vector3_array_operator_equal;
550
+ } ,
533
551
) ;
534
552
535
553
impl_packed_array ! (
536
- PackedColorArray ,
537
- Color ,
538
- OpaquePackedColorArray ,
539
- InnerPackedColorArray ,
540
- Color ,
541
- TagType ,
542
- packed_color_array_construct_default,
543
- packed_color_array_construct_copy,
544
- packed_color_array_from_array,
545
- packed_color_array_destroy,
546
- packed_color_array_operator_index,
547
- packed_color_array_operator_index_const,
554
+ type_name: PackedColorArray ,
555
+ element_type: Color ,
556
+ opaque_type: OpaquePackedColorArray ,
557
+ inner_type: InnerPackedColorArray ,
558
+ argument_type: Color ,
559
+ return_type: TagType ,
560
+ from_array: packed_color_array_from_array,
561
+ operator_index: packed_color_array_operator_index,
562
+ operator_index_const: packed_color_array_operator_index_const,
563
+ trait_impls: {
564
+ Default => packed_color_array_construct_default;
565
+ Clone => packed_color_array_construct_copy;
566
+ Drop => packed_color_array_destroy;
567
+ PartialEq => packed_color_array_operator_equal;
568
+ } ,
548
569
) ;
0 commit comments