Skip to content

Commit

Permalink
Fix signal parameter type not propagated to editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Bromeon committed Dec 19, 2021
1 parent fb26afa commit cb3b360
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions gdnative-core/src/export/class_builder.rs
Expand Up @@ -30,11 +30,11 @@
//! For full examples, see [`examples`](https://github.com/godot-rust/godot-rust/tree/master/examples)
//! in the godot-rust repository.

use crate::core_types::GodotString;
use std::ffi::CString;
use std::marker::PhantomData;
use std::ptr;

use crate::core_types::{GodotString, VariantType};
use crate::export::*;
use crate::object::NewRef;
use crate::private::get_api;
Expand Down Expand Up @@ -199,13 +199,13 @@ impl<C: NativeClass> ClassBuilder<C> {

let mut sys_args = args_and_hints
.iter()
.map(|(arg, hint_string)| sys::godot_signal_argument {
name: arg.name.to_sys(),
type_: arg.default.get_type() as i32,
hint: arg.export_info.hint_kind,
.map(|(param, hint_string)| sys::godot_signal_argument {
name: param.name.to_sys(),
type_: Self::get_param_type(param) as i32,
hint: param.export_info.hint_kind,
hint_string: hint_string.to_sys(),
usage: arg.usage.to_sys(),
default_value: arg.default.to_sys(),
usage: param.usage.to_sys(),
default_value: param.default.to_sys(),
})
.collect::<Vec<_>>();

Expand All @@ -223,6 +223,16 @@ impl<C: NativeClass> ClassBuilder<C> {
}
}

/// Returns the declared parameter type, or the default value's type, or Nil (in that order)
fn get_param_type(arg: &SignalParam) -> VariantType {
let export_type = arg.export_info.variant_type;
if export_type != VariantType::Nil {
export_type
} else {
arg.default.get_type()
}
}

pub(crate) fn add_method(&self, method: ScriptMethod) {
let method_name = CString::new(method.name).unwrap();

Expand Down

0 comments on commit cb3b360

Please sign in to comment.