Skip to content

Commit 49cd1aa

Browse files
committed
Fix script-virtual functions being displayed without '_' prefix
1 parent 5a361be commit 49cd1aa

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

godot-macros/src/class/data_models/inherent_impl.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -196,21 +196,25 @@ fn process_godot_fns(
196196

197197
// For virtual methods, rename/mangle existing user method and create a new method with the original name,
198198
// which performs a dynamic dispatch.
199-
if func.is_virtual {
200-
add_virtual_script_call(
199+
let registered_name = if func.is_virtual {
200+
let registered_name = add_virtual_script_call(
201201
&mut virtual_functions,
202202
function,
203203
&signature_info,
204204
class_name,
205205
&func.rename,
206206
gd_self_parameter,
207207
);
208+
209+
Some(registered_name)
210+
} else {
211+
func.rename
208212
};
209213

210214
func_definitions.push(FuncDefinition {
211215
signature_info,
212216
external_attributes,
213-
registered_name: func.rename,
217+
registered_name,
214218
is_script_virtual: func.is_virtual,
215219
rpc_info,
216220
});
@@ -295,7 +299,7 @@ fn add_virtual_script_call(
295299
class_name: &Ident,
296300
rename: &Option<String>,
297301
gd_self_parameter: Option<Ident>,
298-
) {
302+
) -> String {
299303
assert!(cfg!(since_api = "4.3"));
300304

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

364368
std::mem::swap(&mut function.body, &mut early_bound_function.body);
365369
virtual_functions.push(early_bound_function);
370+
371+
method_name_str
366372
}
367373

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

0 commit comments

Comments
 (0)