@@ -102,14 +102,14 @@ pub fn transform_trait_impl(mut original_impl: venial::Impl) -> ParseResult<Toke
102
102
&& !decls
103
103
. overridden_virtuals
104
104
. iter ( )
105
- . any ( |v| v. method_name == "_ready" )
105
+ . any ( |v| v. rust_method_name == "_ready" )
106
106
{
107
107
let match_arm = OverriddenVirtualFn {
108
108
cfg_attrs : vec ! [ ] ,
109
- method_name : "_ready" . to_string ( ) ,
109
+ rust_method_name : "_ready" . to_string ( ) ,
110
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
111
#[ cfg( since_api = "4.4" ) ]
112
- hash_constant : quote ! { :: godot:: sys:: known_virtual_hashes:: Node :: ready } ,
112
+ godot_name_hash_constant : quote ! { :: godot:: sys:: known_virtual_hashes:: Node :: ready } ,
113
113
signature_info : SignatureInfo :: fn_ready ( ) ,
114
114
before_kind : BeforeKind :: OnlyBefore ,
115
115
interface_trait : None ,
@@ -518,12 +518,12 @@ fn handle_regular_virtual_fn<'a>(
518
518
// each distinct method.
519
519
decls. overridden_virtuals . push ( OverriddenVirtualFn {
520
520
cfg_attrs,
521
- method_name : virtual_method_name,
521
+ rust_method_name : virtual_method_name,
522
522
// If ever the `I*` verbatim validation is relaxed (it won't work with use-renames or other weird edge cases), the approach
523
523
// with known_virtual_hashes module could be changed to something like the following (GodotBase = nearest Godot base class):
524
524
// __get_virtual_hash::<Self::GodotBase>("method")
525
525
#[ cfg( since_api = "4.4" ) ]
526
- hash_constant : quote ! { hashes:: #method_name_ident } ,
526
+ godot_name_hash_constant : quote ! { hashes:: #method_name_ident } ,
527
527
signature_info,
528
528
before_kind,
529
529
interface_trait : Some ( trait_path. clone ( ) ) ,
@@ -573,9 +573,10 @@ fn make_inactive_class_check(_return_value: TokenStream) -> TokenStream {
573
573
574
574
struct OverriddenVirtualFn < ' a > {
575
575
cfg_attrs : Vec < & ' a venial:: Attribute > ,
576
- method_name : String ,
576
+ rust_method_name : String ,
577
+ /// Path to a pre-defined constant storing a `("_virtual_func", 123456789)` tuple with name and hash of the virtual function.
577
578
#[ cfg( since_api = "4.4" ) ]
578
- hash_constant : TokenStream ,
579
+ godot_name_hash_constant : TokenStream ,
579
580
signature_info : SignatureInfo ,
580
581
before_kind : BeforeKind ,
581
582
interface_trait : Option < venial:: TypeExpr > ,
@@ -584,16 +585,16 @@ struct OverriddenVirtualFn<'a> {
584
585
impl OverriddenVirtualFn < ' _ > {
585
586
fn make_match_arm ( & self , class_name : & Ident ) -> TokenStream {
586
587
let cfg_attrs = self . cfg_attrs . iter ( ) ;
587
- let method_name_str = self . method_name . as_str ( ) ;
588
588
589
589
#[ cfg( since_api = "4.4" ) ]
590
590
let pattern = {
591
- let hash_constant = & self . hash_constant ;
592
- quote ! { ( #method_name_str , #hash_constant ) }
591
+ let godot_name_hash_constant = & self . godot_name_hash_constant ;
592
+ quote ! { #godot_name_hash_constant }
593
593
} ;
594
594
595
+ // Note: this is wrong before 4.4, as some methods are renamed in Rust.
595
596
#[ cfg( before_api = "4.4" ) ]
596
- let pattern = method_name_str ;
597
+ let pattern = self . rust_method_name . as_str ( ) ;
597
598
598
599
// Lazily generate code for the actual work (calling user function).
599
600
let method_callback = make_virtual_callback (
0 commit comments