1
- use crate :: core_types:: GodotString ;
2
1
use std:: ffi:: CString ;
3
2
use std:: marker:: PhantomData ;
4
3
use std:: ptr;
5
4
5
+ use crate :: core_types:: { GodotString , VariantType } ;
6
6
use crate :: export:: * ;
7
7
use crate :: object:: NewRef ;
8
8
use crate :: private:: get_api;
@@ -176,13 +176,13 @@ impl<C: NativeClass> ClassBuilder<C> {
176
176
177
177
let mut sys_args = args_and_hints
178
178
. 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 ,
183
183
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 ( ) ,
186
186
} )
187
187
. collect :: < Vec < _ > > ( ) ;
188
188
@@ -200,6 +200,16 @@ impl<C: NativeClass> ClassBuilder<C> {
200
200
}
201
201
}
202
202
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
+
203
213
pub ( crate ) fn add_method ( & self , method : ScriptMethod ) {
204
214
let method_name = CString :: new ( method. name ) . unwrap ( ) ;
205
215
0 commit comments