@@ -150,6 +150,7 @@ fn collect_inputs() -> Vec<Input> {
150
150
push ! ( inputs; PackedStringArray , PackedStringArray , PackedStringArray ( ) , PackedStringArray :: new( ) ) ;
151
151
push ! ( inputs; PackedVector2Array , PackedVector2Array , PackedVector2Array ( ) , PackedVector2Array :: new( ) ) ;
152
152
push ! ( inputs; PackedVector3Array , PackedVector3Array , PackedVector3Array ( ) , PackedVector3Array :: new( ) ) ;
153
+
153
154
// This is being run in a build script at the same time as other build-scripts, so the `rustc-cfg` directives haven't been run for this
154
155
// build-script. This means that `#[cfg(since_api = "4.3")]` wouldn't do anything.
155
156
if godot_bindings:: since_api ( "4.3" ) {
@@ -214,6 +215,7 @@ fn main() {
214
215
rust : rust_property_tests,
215
216
gdscript : gdscript_property_tests,
216
217
} = generate_property_template ( & inputs) ;
218
+
217
219
let extras = inputs. iter ( ) . map ( |input| & input. extra ) ;
218
220
219
221
let rust_tokens = quote:: quote! {
@@ -465,49 +467,63 @@ fn generate_property_template(inputs: &[Input]) -> PropertyTests {
465
467
}
466
468
}
467
469
468
- let rust = quote ! {
469
- #[ derive( GodotClass ) ]
470
- #[ class( base = Node , init) ]
471
- pub struct PropertyTestsRust {
472
- #( #rust, ) *
473
-
474
- // All the @export_file/dir variants, with GString, Array<GString> and PackedStringArray.
475
- #[ export( file) ]
476
- export_file: GString ,
470
+ // Only available in Godot 4.3+.
471
+ let rust_exports_4_3 = if godot_bindings:: before_api ( "4.3" ) {
472
+ TokenStream :: new ( )
473
+ } else {
474
+ quote ! {
477
475
#[ export( file) ]
478
476
export_file_array: Array <GString >,
479
477
#[ export( file) ]
480
478
export_file_parray: PackedStringArray ,
481
- #[ export( file = "*.txt" ) ]
482
- export_file_wildcard: GString ,
479
+
483
480
#[ export( file = "*.txt" ) ]
484
481
export_file_wildcard_array: Array <GString >,
485
482
#[ export( file = "*.txt" ) ]
486
483
export_file_wildcard_parray: PackedStringArray ,
487
- #[ export( global_file) ]
488
- export_global_file: GString ,
484
+
489
485
#[ export( global_file) ]
490
486
export_global_file_array: Array <GString >,
491
487
#[ export( global_file) ]
492
488
export_global_file_parray: PackedStringArray ,
493
- #[ export( global_file = "*.png" ) ]
494
- export_global_file_wildcard: GString ,
489
+
495
490
#[ export( global_file = "*.png" ) ]
496
491
export_global_file_wildcard_array: Array <GString >,
497
492
#[ export( global_file = "*.png" ) ]
498
493
export_global_file_wildcard_parray: PackedStringArray ,
499
- #[ export( dir) ]
500
- export_dir: GString ,
494
+
501
495
#[ export( dir) ]
502
496
export_dir_array: Array <GString >,
503
497
#[ export( dir) ]
504
498
export_dir_parray: PackedStringArray ,
505
- #[ export( global_dir) ]
506
- export_global_dir: GString ,
499
+
507
500
#[ export( global_dir) ]
508
501
export_global_dir_array: Array <GString >,
509
502
#[ export( global_dir) ]
510
503
export_global_dir_parray: PackedStringArray ,
504
+ }
505
+ } ;
506
+
507
+ let rust = quote ! {
508
+ #[ derive( GodotClass ) ]
509
+ #[ class( base = Node , init) ]
510
+ pub struct PropertyTestsRust {
511
+ #( #rust, ) *
512
+ #rust_exports_4_3
513
+
514
+ // All the @export_file/dir variants, with GString, Array<GString> and PackedStringArray.
515
+ #[ export( file) ]
516
+ export_file: GString ,
517
+ #[ export( file = "*.txt" ) ]
518
+ export_file_wildcard: GString ,
519
+ #[ export( global_file) ]
520
+ export_global_file: GString ,
521
+ #[ export( global_file = "*.png" ) ]
522
+ export_global_file_wildcard: GString ,
523
+ #[ export( dir) ]
524
+ export_dir: GString ,
525
+ #[ export( global_dir) ]
526
+ export_global_dir: GString ,
511
527
512
528
#[ export( multiline) ]
513
529
export_multiline: GString ,
@@ -548,27 +564,16 @@ fn generate_property_template(inputs: &[Input]) -> PropertyTests {
548
564
}
549
565
} ;
550
566
551
- let gdscript = format ! (
552
- r#"
553
- {}
567
+ // `extends`, basic `var` and `@export var` declarations
568
+ let basic_exports = gdscript. join ( "\n " ) ;
569
+
570
+ let advanced_exports = r#"
554
571
@export_file var export_file: String
555
- @export_file var export_file_array: Array[String]
556
- @export_file var export_file_parray: PackedStringArray
557
572
@export_file("*.txt") var export_file_wildcard: String
558
- @export_file("*.txt") var export_file_wildcard_array: Array[String]
559
- @export_file("*.txt") var export_file_wildcard_parray: PackedStringArray
560
573
@export_global_file var export_global_file: String
561
- @export_global_file var export_global_file_array: Array[String]
562
- @export_global_file var export_global_file_parray: PackedStringArray
563
574
@export_global_file("*.png") var export_global_file_wildcard: String
564
- @export_global_file("*.png") var export_global_file_wildcard_array: Array[String]
565
- @export_global_file("*.png") var export_global_file_wildcard_parray: PackedStringArray
566
575
@export_dir var export_dir: String
567
- @export_dir var export_dir_array: Array[String]
568
- @export_dir var export_dir_parray: PackedStringArray
569
576
@export_global_dir var export_global_dir: String
570
- @export_global_dir var export_global_dir_array: Array[String]
571
- @export_global_dir var export_global_dir_parray: PackedStringArray
572
577
573
578
@export_multiline var export_multiline: String
574
579
@export_range(0, 20) var export_range_float_0_20: float
@@ -588,9 +593,29 @@ fn generate_property_template(inputs: &[Input]) -> PropertyTests {
588
593
@export_enum("Warrior", "Magician", "Thief") var export_enum_int_warrior_magician_thief: int
589
594
@export_enum("Slow:30", "Average:60", "VeryFast:200") var export_enum_int_slow_30_average_60_very_fast_200: int
590
595
@export_enum("Rebecca", "Mary", "Leah") var export_enum_string_rebecca_mary_leah: String
591
- "# ,
592
- gdscript. join( "\n " )
593
- ) ;
596
+ "# ;
597
+
598
+ // Only available in Godot 4.3+.
599
+ let advanced_exports_4_3 = r#"
600
+ @export_file var export_file_array: Array[String]
601
+ @export_file var export_file_parray: PackedStringArray
602
+ @export_file("*.txt") var export_file_wildcard_array: Array[String]
603
+ @export_file("*.txt") var export_file_wildcard_parray: PackedStringArray
604
+ @export_global_file var export_global_file_array: Array[String]
605
+ @export_global_file var export_global_file_parray: PackedStringArray
606
+ @export_global_file("*.png") var export_global_file_wildcard_array: Array[String]
607
+ @export_global_file("*.png") var export_global_file_wildcard_parray: PackedStringArray
608
+ @export_dir var export_dir_array: Array[String]
609
+ @export_dir var export_dir_parray: PackedStringArray
610
+ @export_global_dir var export_global_dir_array: Array[String]
611
+ @export_global_dir var export_global_dir_parray: PackedStringArray
612
+ "# ;
613
+
614
+ let mut gdscript = format ! ( "{basic_exports}\n {advanced_exports}" ) ;
615
+ if godot_bindings:: since_api ( "4.3" ) {
616
+ gdscript. push ( '\n' ) ;
617
+ gdscript. push_str ( advanced_exports_4_3) ;
618
+ }
594
619
595
620
PropertyTests { rust, gdscript }
596
621
}
0 commit comments