Skip to content

Commit 14f19fa

Browse files
committed
Some Debug/Display impls
1 parent f4ec18c commit 14f19fa

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

godot-codegen/src/context.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,19 @@ impl<'a> Context<'a> {
6464
}
6565

6666
// Populate class lookup by name
67-
println!("-- add engine class {}", class_name.description());
6867
engine_classes.insert(class_name.clone(), class);
6968

7069
// Populate derived-to-base relations
7170
if let Some(base) = class.inherits.as_ref() {
7271
let base_name = TyName::from_godot(base);
73-
println!(" -- inherits {}", base_name.description());
72+
println!(
73+
"* Add engine class {} <- inherits {}",
74+
class_name.description(),
75+
base_name.description()
76+
);
7477
ctx.inheritance_tree.insert(class_name.clone(), base_name);
78+
} else {
79+
println!("* Add engine class {}", class_name.description());
7580
}
7681

7782
// Populate notification constants (first, only for classes that declare them themselves).

godot-codegen/src/models/domain.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,17 @@ impl FnParam {
530530
}
531531
}
532532

533+
impl fmt::Debug for FnParam {
534+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
535+
let def_val = self
536+
.default_value
537+
.as_ref()
538+
.map_or(String::new(), |v| format!(" (default {v})"));
539+
540+
write!(f, "{}: {}{}", self.name, self.type_, def_val)
541+
}
542+
}
543+
533544
// ----------------------------------------------------------------------------------------------------------------------------------------------
534545

535546
pub struct FnReturn {
@@ -684,6 +695,12 @@ impl ToTokens for RustTy {
684695
}
685696
}
686697

698+
impl fmt::Display for RustTy {
699+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
700+
write!(f, "{}", self.to_token_stream().to_string().replace(" ", ""))
701+
}
702+
}
703+
687704
// ----------------------------------------------------------------------------------------------------------------------------------------------
688705

689706
/// Contains multiple naming conventions for types (classes, builtin classes, enums).

0 commit comments

Comments
 (0)