Skip to content

Commit 1e7d006

Browse files
committed
Special cases: operate on Godot method names, not Rust ones
1 parent 35194d1 commit 1e7d006

File tree

4 files changed

+217
-203
lines changed

4 files changed

+217
-203
lines changed

godot-codegen/src/generator/functions_common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ pub(crate) fn make_params_exprs_virtual<'a>(
614614
RustTy::EngineClass { .. }
615615
if !special_cases::is_class_method_param_required(
616616
function_sig.surrounding_class().unwrap(),
617-
function_sig.name(),
617+
function_sig.godot_name(),
618618
param_name,
619619
) =>
620620
{

godot-codegen/src/generator/virtual_traits.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,10 @@ fn make_all_virtual_methods(
212212
for method in base_class.methods.iter() {
213213
// Certain derived classes in Godot implement a virtual method declared in a base class, thus no longer
214214
// making it required. This isn't advertised in the extension_api, but instead manually tracked via special cases.
215-
let derived_presence =
216-
special_cases::get_derived_virtual_method_presence(class.name(), method.name());
215+
let derived_presence = special_cases::get_derived_virtual_method_presence(
216+
class.name(),
217+
method.godot_name(),
218+
);
217219

218220
// Collect all changes in a Markdown table.
219221
let new = match derived_presence {

godot-codegen/src/models/domain_mapping.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ impl ClassMethod {
489489
// Since Godot 4.4, GDExtension advertises whether virtual methods have a default implementation or are required to be overridden.
490490
#[cfg(before_api = "4.4")]
491491
let is_virtual_required =
492-
special_cases::is_virtual_method_required(&class_name, rust_method_name);
492+
special_cases::is_virtual_method_required(&class_name, &method.name);
493493

494494
#[cfg(since_api = "4.4")]
495495
#[allow(clippy::let_and_return)]
@@ -530,12 +530,17 @@ impl ClassMethod {
530530
}
531531

532532
fn make_virtual_method_name<'m>(class_name: &TyName, godot_method_name: &'m str) -> &'m str {
533-
// Remove leading underscore from virtual method names.
534-
let method_name = godot_method_name
535-
.strip_prefix('_')
536-
.unwrap_or(godot_method_name);
533+
// Hardcoded overrides.
534+
if let Some(rust_name) =
535+
special_cases::maybe_rename_virtual_method(class_name, godot_method_name)
536+
{
537+
return rust_name;
538+
}
537539

538-
special_cases::maybe_rename_virtual_method(class_name, method_name)
540+
// In general, just rlemove leading underscore from virtual method names.
541+
godot_method_name
542+
.strip_prefix('_')
543+
.unwrap_or(godot_method_name)
539544
}
540545

541546
fn function_uses_pointers(parameters: &[FnParam], return_value: &FnReturn) -> bool {

0 commit comments

Comments
 (0)