Skip to content

Commit ffe241a

Browse files
committed
Various cleanup and changes to GodotConvert and related after discussion
1 parent 3aa1d81 commit ffe241a

File tree

29 files changed

+605
-621
lines changed

29 files changed

+605
-621
lines changed

godot-codegen/src/util.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -334,19 +334,19 @@ pub fn make_enum_definition(enum_: &Enum) -> TokenStream {
334334
}
335335
#index_enum_impl
336336

337-
impl crate::builtin::meta::GodotCompatible for #enum_name {
338-
type Via = i64;
337+
impl crate::builtin::meta::GodotConvert for #enum_name {
338+
type Via = i32;
339339
}
340340

341341
impl crate::builtin::meta::ToGodot for #enum_name {
342342
fn to_godot(&self) -> Self::Via {
343-
<Self as crate::obj::EngineEnum>::ord(*self) as i64
343+
<Self as crate::obj::EngineEnum>::ord(*self)
344344
}
345345
}
346346

347347
impl crate::builtin::meta::FromGodot for #enum_name {
348348
fn try_from_godot(via: Self::Via) -> Option<Self> {
349-
<Self as crate::obj::EngineEnum>::try_from_ord(i32::try_from(via).ok()?)
349+
<Self as crate::obj::EngineEnum>::try_from_ord(via)
350350
}
351351
}
352352

godot-core/src/builtin/array.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::fmt;
1313
use std::marker::PhantomData;
1414
use sys::{ffi_methods, interface_fn, GodotFfi};
1515

16-
use super::meta::{FromGodot, GodotCompatible, GodotFfiVariant, GodotType, ToGodot};
16+
use super::meta::{FromGodot, GodotConvert, GodotFfiVariant, GodotType, ToGodot};
1717

1818
/// Godot's `Array` type.
1919
///
@@ -28,7 +28,7 @@ use super::meta::{FromGodot, GodotCompatible, GodotFfiVariant, GodotType, ToGodo
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, GodotCompatible, GodotFfiVariant, GodotType, ToGodo
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,
@@ -621,7 +621,7 @@ unsafe impl<T: GodotType> GodotFfi for Array<T> {
621621
}
622622
}
623623

624-
impl<T: GodotType> GodotCompatible for Array<T> {
624+
impl<T: GodotType> GodotConvert for Array<T> {
625625
type Via = Self;
626626
}
627627

godot-core/src/builtin/callable.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ impl Callable {
4646
unsafe {
4747
sys::from_sys_init_or_init_default::<Self>(|self_ptr| {
4848
let ctor = sys::builtin_fn!(callable_from_object_method);
49-
let args = [object.to_ffi().as_arg_ptr(), method.sys_const()];
49+
let raw = object.to_ffi();
50+
let args = [raw.as_arg_ptr(), method.sys_const()];
5051
ctor(self_ptr, args.as_ptr());
5152
})
5253
}

godot-core/src/builtin/meta/godot_compat/impls.rs

-248
This file was deleted.

0 commit comments

Comments
 (0)