Skip to content

Commit

Permalink
Fix script-virtual functions being displayed without '_' prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Bromeon committed Oct 11, 2024
1 parent 5a361be commit 49cd1aa
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions godot-macros/src/class/data_models/inherent_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,21 +196,25 @@ fn process_godot_fns(

// For virtual methods, rename/mangle existing user method and create a new method with the original name,
// which performs a dynamic dispatch.
if func.is_virtual {
add_virtual_script_call(
let registered_name = if func.is_virtual {
let registered_name = add_virtual_script_call(
&mut virtual_functions,
function,
&signature_info,
class_name,
&func.rename,
gd_self_parameter,
);

Some(registered_name)
} else {
func.rename
};

func_definitions.push(FuncDefinition {
signature_info,
external_attributes,
registered_name: func.rename,
registered_name,
is_script_virtual: func.is_virtual,
rpc_info,
});
Expand Down Expand Up @@ -295,7 +299,7 @@ fn add_virtual_script_call(
class_name: &Ident,
rename: &Option<String>,
gd_self_parameter: Option<Ident>,
) {
) -> String {
assert!(cfg!(since_api = "4.3"));

// Update parameter names, so they can be forwarded (e.g. a "_" declared by the user cannot).
Expand Down Expand Up @@ -363,6 +367,8 @@ fn add_virtual_script_call(

std::mem::swap(&mut function.body, &mut early_bound_function.body);
virtual_functions.push(early_bound_function);

method_name_str
}

fn extract_attributes<T>(item: &mut T) -> ParseResult<Option<ItemAttr>>
Expand Down

0 comments on commit 49cd1aa

Please sign in to comment.