diff --git a/derive/src/impl_attribute.rs b/derive/src/impl_attribute.rs index 7a4e107..4db7e15 100644 --- a/derive/src/impl_attribute.rs +++ b/derive/src/impl_attribute.rs @@ -57,6 +57,7 @@ pub fn godot_script_impl( .enumerate() .map(|(index, arg)| { let arg_name = arg.pat.as_ref(); + let arg_rust_type = arg.ty.as_ref(); let arg_type = rust_to_variant_type(arg.ty.as_ref()).unwrap(); is_context_type(arg.ty.as_ref()).then(|| { @@ -72,6 +73,7 @@ pub fn godot_script_impl( ::godot_rust_script::private_export::RustScriptPropDesc { name: stringify!(#arg_name), ty: #arg_type, + class_name: <<#arg_rust_type as #godot_types::meta::GodotConvert>::Via as #godot_types::meta::GodotType>::class_name(), exported: false, hint: #property_hints::NONE, hint_string: String::new(), @@ -132,6 +134,7 @@ pub fn godot_script_impl( return_type: ::godot_rust_script::private_export::RustScriptPropDesc { name: #fn_name_str, ty: #fn_return_ty, + class_name: <<#fn_return_ty_rust as #godot_types::meta::GodotConvert>::Via as #godot_types::meta::GodotType>::class_name(), exported: false, hint: #property_hints::NONE, hint_string: String::new(), diff --git a/derive/src/lib.rs b/derive/src/lib.rs index e0fdde8..1591a9c 100644 --- a/derive/src/lib.rs +++ b/derive/src/lib.rs @@ -372,6 +372,7 @@ fn derive_field_metadata( field: &SpannedValue, is_exported: bool, ) -> Result { + let godot_types = godot_types(); let property_hint_ty = property_hints(); let name = field .ident @@ -379,6 +380,7 @@ fn derive_field_metadata( .map(|field| field.to_string()) .unwrap_or_default(); + let rust_ty = &field.ty; let ty = rust_to_variant_type(&field.ty)?; let (hint, hint_string) = is_exported @@ -401,6 +403,7 @@ fn derive_field_metadata( ::godot_rust_script::private_export::RustScriptPropDesc { name: #name, ty: #ty, + class_name: <<#rust_ty as #godot_types::meta::GodotConvert>::Via as #godot_types::meta::GodotType>::class_name(), exported: #is_exported, hint: #hint, hint_string: #hint_string, diff --git a/rust-script/src/interface/signals.rs b/rust-script/src/interface/signals.rs index 374dcb8..2a6ca42 100644 --- a/rust-script/src/interface/signals.rs +++ b/rust-script/src/interface/signals.rs @@ -124,6 +124,7 @@ macro_rules! signal_argument_desc { RustScriptPropDesc { name: $name, ty: <<<$type as GodotConvert>::Via as GodotType>::Ffi as godot::sys::GodotFfi>::variant_type(), + class_name: <<$type as GodotConvert>::Via as GodotType>::class_name(), exported: false, hint: PropertyHint::NONE, hint_string: String::new(), diff --git a/rust-script/src/static_script_registry.rs b/rust-script/src/static_script_registry.rs index 3f16b0b..17571ab 100644 --- a/rust-script/src/static_script_registry.rs +++ b/rust-script/src/static_script_registry.rs @@ -80,6 +80,7 @@ pub enum RegistryItem { pub struct RustScriptPropDesc { pub name: &'static str, pub ty: VariantType, + pub class_name: ClassName, pub exported: bool, pub hint: PropertyHint, pub hint_string: String, @@ -87,10 +88,10 @@ pub struct RustScriptPropDesc { } impl RustScriptPropDesc { - pub fn to_property_info(&self, class_name: &'static str) -> RustScriptPropertyInfo { + pub fn to_property_info(&self) -> RustScriptPropertyInfo { RustScriptPropertyInfo { variant_type: self.ty, - class_name, + class_name: self.class_name.as_str(), property_name: self.name, usage: if self.exported { (PropertyUsageFlags::EDITOR | PropertyUsageFlags::STORAGE).ord() @@ -118,12 +119,12 @@ impl RustScriptMethodDesc { id, method_name: self.name, class_name, - return_type: self.return_type.to_property_info(class_name), + return_type: self.return_type.to_property_info(), flags: self.flags.ord(), arguments: self .arguments .iter() - .map(|arg| arg.to_property_info(class_name)) + .map(|arg| arg.to_property_info()) .collect(), description: self.description, } @@ -143,7 +144,7 @@ impl From for RustScriptSignalInfo { arguments: value .arguments .iter() - .map(|arg| arg.to_property_info("\0")) + .map(|arg| arg.to_property_info()) .collect(), description: value.description, } @@ -174,7 +175,7 @@ pub fn assemble_metadata<'a>( .map(|class| { let props = (class.properties)() .into_iter() - .map(|prop| prop.to_property_info(class.class_name)) + .map(|prop| prop.to_property_info()) .collect(); let methods = methods