Skip to content

Commit 305b57f

Browse files
committed
Fix signal parameter type not propagated to editor
1 parent b0d28df commit 305b57f

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

gdnative-core/src/export/class_builder.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use crate::core_types::GodotString;
21
use std::ffi::CString;
32
use std::marker::PhantomData;
43
use std::ptr;
54

5+
use crate::core_types::{GodotString, VariantType};
66
use crate::export::*;
77
use crate::object::NewRef;
88
use crate::private::get_api;
@@ -176,13 +176,13 @@ impl<C: NativeClass> ClassBuilder<C> {
176176

177177
let mut sys_args = args_and_hints
178178
.iter()
179-
.map(|(arg, hint_string)| sys::godot_signal_argument {
180-
name: arg.name.to_sys(),
181-
type_: arg.default.get_type() as i32,
182-
hint: arg.export_info.hint_kind,
179+
.map(|(param, hint_string)| sys::godot_signal_argument {
180+
name: param.name.to_sys(),
181+
type_: Self::get_param_type(param) as i32,
182+
hint: param.export_info.hint_kind,
183183
hint_string: hint_string.to_sys(),
184-
usage: arg.usage.to_sys(),
185-
default_value: arg.default.to_sys(),
184+
usage: param.usage.to_sys(),
185+
default_value: param.default.to_sys(),
186186
})
187187
.collect::<Vec<_>>();
188188

@@ -200,6 +200,16 @@ impl<C: NativeClass> ClassBuilder<C> {
200200
}
201201
}
202202

203+
/// Returns the declared parameter type, or the default value's type, or Nil (in that order)
204+
fn get_param_type(arg: &SignalParam) -> VariantType {
205+
let export_type = arg.export_info.variant_type;
206+
if export_type != VariantType::Nil {
207+
export_type
208+
} else {
209+
arg.default.get_type()
210+
}
211+
}
212+
203213
pub(crate) fn add_method(&self, method: ScriptMethod) {
204214
let method_name = CString::new(method.name).unwrap();
205215

0 commit comments

Comments
 (0)