From 8ff69e0c4af265f3973a7b83e13cdfec8cb7ae94 Mon Sep 17 00:00:00 2001 From: Lili Zoey Date: Thu, 13 Apr 2023 20:40:06 +0200 Subject: [PATCH] Fix `(no base)` showing up in all the docs --- godot-core/src/builtin/array.rs | 7 +------ godot-core/src/builtin/meta/class_name.rs | 7 +++++++ godot-core/src/builtin/meta/mod.rs | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/godot-core/src/builtin/array.rs b/godot-core/src/builtin/array.rs index ec0ec3ecd..972f2e6e2 100644 --- a/godot-core/src/builtin/array.rs +++ b/godot-core/src/builtin/array.rs @@ -883,12 +883,7 @@ struct TypeInfo { impl TypeInfo { fn new() -> Self { let variant_type = T::variant_type(); - let class_name = match variant_type { - VariantType::Object => StringName::from(T::class_name()), - // TODO for variant types other than Object, class_name() returns "(no base)"; just - // make it return "" instead? - _ => StringName::default(), - }; + let class_name: StringName = T::class_name().into(); Self { variant_type, class_name, diff --git a/godot-core/src/builtin/meta/class_name.rs b/godot-core/src/builtin/meta/class_name.rs index f698bb65b..954da4d17 100644 --- a/godot-core/src/builtin/meta/class_name.rs +++ b/godot-core/src/builtin/meta/class_name.rs @@ -19,6 +19,13 @@ pub struct ClassName { } impl ClassName { + /// In Godot, an empty `StringName` in a place that expects a class name, means that there is no class. + pub fn none() -> Self { + Self { + backing: StringName::default(), + } + } + pub fn of() -> Self { Self { backing: StringName::from(T::CLASS_NAME), diff --git a/godot-core/src/builtin/meta/mod.rs b/godot-core/src/builtin/meta/mod.rs index 534d8d31a..e13558814 100644 --- a/godot-core/src/builtin/meta/mod.rs +++ b/godot-core/src/builtin/meta/mod.rs @@ -23,7 +23,8 @@ pub trait VariantMetadata { fn variant_type() -> VariantType; fn class_name() -> ClassName { - ClassName::of::<()>() // FIXME Option or so + // If we use `ClassName::of::<()>()` then this type shows up as `(no base)` in documentation. + ClassName::none() } fn property_info(property_name: &str) -> PropertyInfo {