Skip to content

Commit 3470977

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

File tree

6 files changed

+34
-11
lines changed

6 files changed

+34
-11
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

+7-4
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ impl<T: GodotClass> Gd<T> {
209209
/// ⚠️ Returns the last known, possibly invalid instance ID of this object.
210210
///
211211
/// This function does not check that the returned instance ID points to a valid instance!
212-
/// Unless performance is a problem, use [`instance_id()`][Self::instance_id] or
213-
/// [`instance_id_or_none()`][Self::instance_id_or_none] instead.
212+
/// Unless performance is a problem, use [`instance_id()`][Self::instance_id] instead.
214213
pub fn instance_id_unchecked(&self) -> InstanceId {
215214
// SAFETY:
216215
// A `Gd` can only be created from a non-null `RawGd`. Meaning `raw.instance_id_unchecked()` will
@@ -459,6 +458,10 @@ impl<T: GodotClass> GodotType for Gd<T> {
459458
Some(Self { raw })
460459
}
461460
}
461+
462+
fn class_name() -> crate::builtin::meta::ClassName {
463+
T::class_name()
464+
}
462465
}
463466

464467
impl<T: GodotClass> Clone for Gd<T> {
@@ -540,13 +543,13 @@ impl<T: GodotClass> Eq for Gd<T> {}
540543

541544
impl<T: GodotClass> Display for Gd<T> {
542545
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
543-
engine::display_string(&self, f)
546+
engine::display_string(self, f)
544547
}
545548
}
546549

547550
impl<T: GodotClass> Debug for Gd<T> {
548551
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
549-
engine::debug_string(&self, f, "Gd")
552+
engine::debug_string(self, f, "Gd")
550553
}
551554
}
552555

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)