Skip to content

Commit 2a103a0

Browse files
committed
Final fixes after merge
1 parent 30153f7 commit 2a103a0

File tree

7 files changed

+37
-9
lines changed

7 files changed

+37
-9
lines changed

godot-core/src/builtin/array.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use super::meta::{FromGodot, GodotConvert, GodotFfiVariant, GodotType, ToGodot};
2828
///
2929
/// Godot also supports typed arrays, which are also just `Variant` arrays under the hood, but with
3030
/// runtime checks that no values of the wrong type are put into the array. We represent this as
31-
/// `Array<T>`, where the type `T` implements `VariantMetadata`, `FromGodot` and `ToGodot`.
31+
/// `Array<T>`, where the type `T` implements `GodotType`.
3232
///
3333
/// # Reference semantics
3434
///
@@ -47,10 +47,10 @@ use super::meta::{FromGodot, GodotConvert, GodotFfiVariant, GodotType, ToGodot};
4747
4848
/// concurrent modification on other threads (e.g. created through GDScript).
4949
50-
// `T` must be restricted to `VariantMetadata` in the type, because `Drop` can only be implemented
50+
// `T` must be restricted to `GodotType` in the type, because `Drop` can only be implemented
5151
// for `T: GodotType` because `drop()` requires `sys_mut()`, which is on the `GodotFfi`
5252
// trait, whose `from_sys_init()` requires `Default`, which is only implemented for `T:
53-
// VariantMetadata`. Whew. This could be fixed by splitting up `GodotFfi` if desired.
53+
// GodotType`. Whew. This could be fixed by splitting up `GodotFfi` if desired.
5454
#[repr(C)]
5555
pub struct Array<T: GodotType> {
5656
opaque: sys::types::OpaqueArray,

godot-core/src/builtin/meta/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ pub trait GodotType: GodotConvert<Via = Self> + ToGodot + FromGodot + sealed::Se
126126
}
127127

128128
fn class_name() -> ClassName {
129+
println!("class_name default impl");
129130
// If we use `ClassName::of::<()>()` then this type shows up as `(no base)` in documentation.
130131
ClassName::none()
131132
}
@@ -184,6 +185,26 @@ where
184185

185186
Some(GodotType::from_ffi(ffi))
186187
}
188+
189+
fn param_metadata() -> sys::GDExtensionClassMethodArgumentMetadata {
190+
T::param_metadata()
191+
}
192+
193+
fn class_name() -> ClassName {
194+
T::class_name()
195+
}
196+
197+
fn property_info(property_name: &str) -> PropertyInfo {
198+
T::property_info(property_name)
199+
}
200+
201+
fn argument_info(property_name: &str) -> MethodParamOrReturnInfo {
202+
T::argument_info(property_name)
203+
}
204+
205+
fn return_info() -> Option<MethodParamOrReturnInfo> {
206+
T::return_info()
207+
}
187208
}
188209

189210
// ----------------------------------------------------------------------------------------------------------------------------------------------

godot-core/src/obj/gd.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@ impl<T: GodotClass> GodotType for Gd<T> {
459459
Some(Self { raw })
460460
}
461461
}
462+
463+
fn class_name() -> crate::builtin::meta::ClassName {
464+
println!("class_name gd");
465+
T::class_name()
466+
}
462467
}
463468

464469
impl<T: GodotClass> Clone for Gd<T> {
@@ -540,13 +545,13 @@ impl<T: GodotClass> Eq for Gd<T> {}
540545

541546
impl<T: GodotClass> Display for Gd<T> {
542547
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
543-
engine::display_string(&self, f)
548+
engine::display_string(self, f)
544549
}
545550
}
546551

547552
impl<T: GodotClass> Debug for Gd<T> {
548553
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
549-
engine::debug_string(&self, f, "Gd")
554+
engine::debug_string(self, f, "Gd")
550555
}
551556
}
552557

godot-core/src/obj/raw.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,8 @@ impl<T: GodotClass> GodotType for RawGd<T> {
514514
}
515515

516516
fn class_name() -> ClassName {
517+
println!("class_name gd");
518+
517519
T::class_name()
518520
}
519521
}

godot-macros/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ pub fn derive_godot_compatible(input: TokenStream) -> TokenStream {
474474
/// assert_eq!(obj.to_variant(), dict.to_variant());
475475
/// ```
476476
///
477-
/// You can use the `#[skip]` attribute to ignore a field from being converted to `ToVariant`.
477+
/// You can use the `#[skip]` attribute to ignore a field from being converted to `ToGodot`.
478478
#[proc_macro_derive(ToGodot, attributes(variant))]
479479
pub fn derive_to_godot(input: TokenStream) -> TokenStream {
480480
translate(input, derive::derive_to_godot)

godot-macros/src/util/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ pub fn class_name_obj(class: &impl ToTokens) -> TokenStream {
3434

3535
pub fn property_variant_type(property_type: &impl ToTokens) -> TokenStream {
3636
let property_type = property_type.to_token_stream();
37-
quote! {<<#property_type as ::godot::bind::property::Property>::Intermediate as ::godot::builtin::meta::VariantMetadata>::variant_type()}
37+
quote! { <<<#property_type as ::godot::bind::property::Property>::Intermediate as ::godot::builtin::meta::GodotConvert>::Via as ::godot::builtin::meta::GodotType>::Ffi::variant_type() }
3838
}
3939

4040
pub fn property_variant_class_name(property_type: &impl ToTokens) -> TokenStream {
4141
let property_type = property_type.to_token_stream();
42-
quote! {<<#property_type as ::godot::bind::property::Property>::Intermediate as ::godot::builtin::meta::VariantMetadata>::class_name()}
42+
quote! { <<<#property_type as ::godot::bind::property::Property>::Intermediate as ::godot::builtin::meta::GodotConvert>::Via as ::godot::builtin::meta::GodotType>::class_name() }
4343
}
4444

4545
pub fn bail_fn<R, T>(msg: impl AsRef<str>, tokens: T) -> ParseResult<R>

itest/rust/src/object_tests/property_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,6 @@ fn export_resource() {
449449
class.free();
450450
}
451451

452-
fn check_property(property: &Dictionary, key: &str, expected: impl ToVariant) {
452+
fn check_property(property: &Dictionary, key: &str, expected: impl ToGodot) {
453453
assert_eq!(property.get_or_nil(key), expected.to_variant());
454454
}

0 commit comments

Comments
 (0)