@@ -21,7 +21,7 @@ use sys::GodotFfi;
2121//
2222// Thus we can use `init` to indicate when it must be initialized in 4.0.
2323macro_rules! impl_ffi_variant {
24- ( $T: ty, $from_fn: ident, $to_fn: ident) => {
24+ ( $T: ty, $from_fn: ident, $to_fn: ident $ ( ; $godot_type_name : ident ) ? ) => {
2525 impl GodotFfiVariant for $T {
2626 fn ffi_to_variant( & self ) -> Variant {
2727 let variant = unsafe {
@@ -73,6 +73,20 @@ macro_rules! impl_ffi_variant {
7373 fn try_from_ffi( ffi: Self :: Ffi ) -> Option <Self > {
7474 Some ( ffi)
7575 }
76+
77+ impl_ffi_variant!( @godot_type_name $T $( , $godot_type_name) ?) ;
78+ }
79+ } ;
80+
81+ ( @godot_type_name $T: ty) => {
82+ fn godot_type_name( ) -> String {
83+ stringify!( $T) . into( )
84+ }
85+ } ;
86+
87+ ( @godot_type_name $T: ty, $godot_type_name: ident) => {
88+ fn godot_type_name( ) -> String {
89+ stringify!( $godot_type_name) . into( )
7690 }
7791 } ;
7892}
@@ -85,7 +99,7 @@ macro_rules! impl_ffi_variant {
8599mod impls {
86100 use super :: * ;
87101
88- impl_ffi_variant ! ( Aabb , aabb_to_variant, aabb_from_variant) ;
102+ impl_ffi_variant ! ( Aabb , aabb_to_variant, aabb_from_variant; AABB ) ;
89103 impl_ffi_variant ! ( bool , bool_to_variant, bool_from_variant) ;
90104 impl_ffi_variant ! ( Basis , basis_to_variant, basis_from_variant) ;
91105 impl_ffi_variant ! ( Callable , callable_to_variant, callable_from_variant) ;
@@ -94,10 +108,10 @@ mod impls {
94108 impl_ffi_variant ! ( Vector4 , vector4_to_variant, vector4_from_variant) ;
95109 impl_ffi_variant ! ( Vector2i , vector2i_to_variant, vector2i_from_variant) ;
96110 impl_ffi_variant ! ( Vector3i , vector3i_to_variant, vector3i_from_variant) ;
97- impl_ffi_variant ! ( Vector4i , vector3i_to_variant , vector3i_from_variant ) ;
111+ impl_ffi_variant ! ( Vector4i , vector4i_to_variant , vector4i_from_variant ) ;
98112 impl_ffi_variant ! ( Quaternion , quaternion_to_variant, quaternion_from_variant) ;
99113 impl_ffi_variant ! ( Color , color_to_variant, color_from_variant) ;
100- impl_ffi_variant ! ( GodotString , string_to_variant, string_from_variant) ;
114+ impl_ffi_variant ! ( GodotString , string_to_variant, string_from_variant; String ) ;
101115 impl_ffi_variant ! ( StringName , string_name_to_variant, string_name_from_variant) ;
102116 impl_ffi_variant ! ( NodePath , node_path_to_variant, node_path_from_variant) ;
103117 impl_ffi_variant ! ( PackedByteArray , packed_byte_array_to_variant, packed_byte_array_from_variant) ;
@@ -111,15 +125,15 @@ mod impls {
111125 impl_ffi_variant ! ( PackedColorArray , packed_color_array_to_variant, packed_color_array_from_variant) ;
112126 impl_ffi_variant ! ( Plane , plane_to_variant, plane_from_variant) ;
113127 impl_ffi_variant ! ( Projection , projection_to_variant, projection_from_variant) ;
114- impl_ffi_variant ! ( Rid , rid_to_variant, rid_from_variant) ;
128+ impl_ffi_variant ! ( Rid , rid_to_variant, rid_from_variant; RID ) ;
115129 impl_ffi_variant ! ( Rect2 , rect2_to_variant, rect2_from_variant) ;
116130 impl_ffi_variant ! ( Rect2i , rect2i_to_variant, rect2i_from_variant) ;
117131 impl_ffi_variant ! ( Signal , signal_to_variant, signal_from_variant) ;
118132 impl_ffi_variant ! ( Transform2D , transform_2d_to_variant, transform_2d_from_variant) ;
119133 impl_ffi_variant ! ( Transform3D , transform_3d_to_variant, transform_3d_from_variant) ;
120134 impl_ffi_variant ! ( Dictionary , dictionary_to_variant, dictionary_from_variant) ;
121- impl_ffi_variant ! ( i64 , int_to_variant, int_from_variant) ;
122- impl_ffi_variant ! ( f64 , float_to_variant, float_from_variant) ;
135+ impl_ffi_variant ! ( i64 , int_to_variant, int_from_variant; int ) ;
136+ impl_ffi_variant ! ( f64 , float_to_variant, float_from_variant; float ) ;
123137
124138}
125139
@@ -151,6 +165,10 @@ impl GodotType for () {
151165 fn try_from_ffi ( _: Self :: Ffi ) -> Option < Self > {
152166 Some ( ( ) )
153167 }
168+
169+ fn godot_type_name ( ) -> String {
170+ "Variant" . into ( )
171+ }
154172}
155173
156174impl GodotFfiVariant for Variant {
@@ -192,4 +210,8 @@ impl GodotType for Variant {
192210 fn param_metadata ( ) -> sys:: GDExtensionClassMethodArgumentMetadata {
193211 sys:: GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT8
194212 }
213+
214+ fn godot_type_name ( ) -> String {
215+ "Variant" . into ( )
216+ }
195217}
0 commit comments