@@ -107,9 +107,8 @@ pub fn transform_trait_impl(mut original_impl: venial::Impl) -> ParseResult<Toke
107
107
let match_arm = OverriddenVirtualFn {
108
108
cfg_attrs : vec ! [ ] ,
109
109
rust_method_name : "_ready" . to_string ( ) ,
110
- // Can't use `hashes::ready` here, as the base class might not be `Node` (see above why such a branch is still added).
111
- #[ cfg( since_api = "4.4" ) ]
112
- godot_name_hash_constant : quote ! { :: godot:: sys:: known_virtual_hashes:: Node :: ready } ,
110
+ // Can't use `virtuals::ready` here, as the base class might not be `Node` (see above why such a branch is still added).
111
+ godot_name_hash_constant : quote ! { :: godot:: sys:: godot_virtual_consts:: Node :: ready } ,
113
112
signature_info : SignatureInfo :: fn_ready ( ) ,
114
113
before_kind : BeforeKind :: OnlyBefore ,
115
114
interface_trait : None ,
@@ -136,16 +135,12 @@ pub fn transform_trait_impl(mut original_impl: venial::Impl) -> ParseResult<Toke
136
135
} ;
137
136
138
137
// See also __default_virtual_call() codegen.
139
- let ( hash_param, hashes_use , match_expr) ;
138
+ let ( hash_param, match_expr) ;
140
139
if cfg ! ( since_api = "4.4" ) {
141
140
hash_param = quote ! { hash: u32 , } ;
142
- hashes_use = quote ! {
143
- use :: godot:: sys:: known_virtual_hashes:: #trait_base_class as hashes;
144
- } ;
145
141
match_expr = quote ! { ( name, hash) } ;
146
142
} else {
147
143
hash_param = TokenStream :: new ( ) ;
148
- hashes_use = TokenStream :: new ( ) ;
149
144
match_expr = quote ! { name } ;
150
145
} ;
151
146
@@ -164,9 +159,9 @@ pub fn transform_trait_impl(mut original_impl: venial::Impl) -> ParseResult<Toke
164
159
fn __virtual_call( name: & str , #hash_param) -> :: godot:: sys:: GDExtensionClassCallVirtual {
165
160
//println!("virtual_call: {}.{}", std::any::type_name::<Self>(), name);
166
161
use :: godot:: obj:: UserClass as _;
162
+ use :: godot:: sys:: godot_virtual_consts:: #trait_base_class as virtuals;
167
163
#tool_check
168
164
169
- #hashes_use
170
165
match #match_expr {
171
166
#( #virtual_match_arms ) *
172
167
_ => None ,
@@ -459,7 +454,6 @@ fn handle_regular_virtual_fn<'a>(
459
454
cfg_attrs : Vec < & ' a venial:: Attribute > ,
460
455
decls : & mut IDecls < ' a > ,
461
456
) -> Option < ( venial:: Punctuated < venial:: FnParam > , Group ) > {
462
- #[ cfg( since_api = "4.4" ) ]
463
457
let method_name_ident = original_method. name . clone ( ) ;
464
458
let method = util:: reduce_to_signature ( original_method) ;
465
459
@@ -520,10 +514,9 @@ fn handle_regular_virtual_fn<'a>(
520
514
cfg_attrs,
521
515
rust_method_name : virtual_method_name,
522
516
// If ever the `I*` verbatim validation is relaxed (it won't work with use-renames or other weird edge cases), the approach
523
- // with known_virtual_hashes module could be changed to something like the following (GodotBase = nearest Godot base class):
517
+ // with godot_virtual_consts module could be changed to something like the following (GodotBase = nearest Godot base class):
524
518
// __get_virtual_hash::<Self::GodotBase>("method")
525
- #[ cfg( since_api = "4.4" ) ]
526
- godot_name_hash_constant : quote ! { hashes:: #method_name_ident } ,
519
+ godot_name_hash_constant : quote ! { virtuals:: #method_name_ident } ,
527
520
signature_info,
528
521
before_kind,
529
522
interface_trait : Some ( trait_path. clone ( ) ) ,
@@ -575,7 +568,8 @@ struct OverriddenVirtualFn<'a> {
575
568
cfg_attrs : Vec < & ' a venial:: Attribute > ,
576
569
rust_method_name : String ,
577
570
/// Path to a pre-defined constant storing a `("_virtual_func", 123456789)` tuple with name and hash of the virtual function.
578
- #[ cfg( since_api = "4.4" ) ]
571
+ ///
572
+ /// Before Godot 4.4, this just stores the name `"_virtual_func"`.
579
573
godot_name_hash_constant : TokenStream ,
580
574
signature_info : SignatureInfo ,
581
575
before_kind : BeforeKind ,
@@ -585,16 +579,7 @@ struct OverriddenVirtualFn<'a> {
585
579
impl OverriddenVirtualFn < ' _ > {
586
580
fn make_match_arm ( & self , class_name : & Ident ) -> TokenStream {
587
581
let cfg_attrs = self . cfg_attrs . iter ( ) ;
588
-
589
- #[ cfg( since_api = "4.4" ) ]
590
- let pattern = {
591
- let godot_name_hash_constant = & self . godot_name_hash_constant ;
592
- quote ! { #godot_name_hash_constant }
593
- } ;
594
-
595
- // Note: this is wrong before 4.4, as some methods are renamed in Rust.
596
- #[ cfg( before_api = "4.4" ) ]
597
- let pattern = self . rust_method_name . as_str ( ) ;
582
+ let godot_name_hash_constant = & self . godot_name_hash_constant ;
598
583
599
584
// Lazily generate code for the actual work (calling user function).
600
585
let method_callback = make_virtual_callback (
@@ -606,7 +591,7 @@ impl OverriddenVirtualFn<'_> {
606
591
607
592
quote ! {
608
593
#( #cfg_attrs) *
609
- #pattern => #method_callback,
594
+ #godot_name_hash_constant => #method_callback,
610
595
}
611
596
}
612
597
}
0 commit comments