Skip to content

Commit 2dc78d2

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

File tree

6 files changed

+33
-9
lines changed

6 files changed

+33
-9
lines changed

godot-core/src/builtin/array.rs

+3-3
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

+20
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,26 @@ where
184184

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

189209
// ----------------------------------------------------------------------------------------------------------------------------------------------

godot-core/src/obj/gd.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,10 @@ impl<T: GodotClass> GodotType for Gd<T> {
459459
Some(Self { raw })
460460
}
461461
}
462+
463+
fn class_name() -> crate::builtin::meta::ClassName {
464+
T::class_name()
465+
}
462466
}
463467

464468
impl<T: GodotClass> Clone for Gd<T> {
@@ -540,13 +544,13 @@ impl<T: GodotClass> Eq for Gd<T> {}
540544

541545
impl<T: GodotClass> Display for Gd<T> {
542546
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
543-
engine::display_string(&self, f)
547+
engine::display_string(self, f)
544548
}
545549
}
546550

547551
impl<T: GodotClass> Debug for Gd<T> {
548552
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
549-
engine::debug_string(&self, f, "Gd")
553+
engine::debug_string(self, f, "Gd")
550554
}
551555
}
552556

godot-macros/src/lib.rs

+1-1
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

+2-2
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

+1-1
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)