77use  std:: marker:: PhantomData ; 
88
99use  godot:: builtin:: { 
10-     Callable ,  Dictionary ,  GString ,  NodePath ,  StringName ,  Variant ,  Vector2 ,  Vector3 , 
10+     Callable ,  Dictionary ,  GString ,  NodePath ,  StringName ,  Variant ,  Vector2 ,  Vector3 ,   Vector4 , 
1111} ; 
1212use  godot:: classes:: Object ; 
1313use  godot:: global:: { Error ,  PropertyHint } ; 
1414use  godot:: meta:: { GodotConvert ,  GodotType ,  ToGodot } ; 
15- use  godot:: obj:: Gd ; 
15+ use  godot:: obj:: { Gd ,   GodotClass } ; 
1616
1717use  crate :: static_script_registry:: RustScriptPropDesc ; 
18- 
19- pub  trait  ScriptSignal  { 
20-     type  Args :  SignalArguments ; 
21- 
22-     fn  new ( host :  Gd < Object > ,  name :  & ' static  str )  -> Self ; 
23- 
24-     fn  emit ( & self ,  args :  Self :: Args ) ; 
25- 
26-     fn  connect ( & mut  self ,  callable :  Callable )  -> Result < ( ) ,  Error > ; 
27- 
28-     fn  argument_desc ( )  -> Box < [ RustScriptPropDesc ] > ; 
29- 
30-     fn  name ( & self )  -> & str ; 
31- } 
18+ use  crate :: { GodotScript ,  RsRef } ; 
3219
3320pub  trait  SignalArguments  { 
34-     fn   count ( )  ->  u8 ; 
21+     const   COUNT :  u8 ; 
3522
3623    fn  to_variants ( & self )  -> Vec < Variant > ; 
3724
38-     fn  argument_desc ( )  -> Box < [ RustScriptPropDesc ] > ; 
25+     fn  argument_desc ( arg_names :   Option < & [ & ' static   str ] > )  -> Box < [ RustScriptPropDesc ] > ; 
3926} 
4027
4128impl  SignalArguments  for  ( )  { 
42-     fn  count ( )  -> u8  { 
43-         0 
44-     } 
29+     const  COUNT :  u8  = 0 ; 
4530
4631    fn  to_variants ( & self )  -> Vec < Variant >  { 
4732        vec ! [ ] 
4833    } 
4934
50-     fn  argument_desc ( )  -> Box < [ RustScriptPropDesc ] >  { 
35+     fn  argument_desc ( _arg_names :   Option < & [ & ' static   str ] > )  -> Box < [ RustScriptPropDesc ] >  { 
5136        Box :: new ( [ ] ) 
5237    } 
5338} 
@@ -60,9 +45,7 @@ macro_rules! count_tts {
6045macro_rules!  tuple_args { 
6146    ( impl  $( $arg:  ident) ,+)  => { 
6247        impl <$( $arg:  ToGodot ) ,+> SignalArguments  for  ( $( $arg, ) +)  { 
63-             fn  count( )  -> u8  { 
64-                 count_tts!( $( $arg) +) 
65-             } 
48+             const  COUNT :  u8  = count_tts!( $( $arg) +) ; 
6649
6750            fn  to_variants( & self )  -> Vec <Variant > { 
6851                #[ allow( non_snake_case) ] 
@@ -73,9 +56,12 @@ macro_rules! tuple_args {
7356                ] 
7457            } 
7558
76-             fn  argument_desc( )  -> Box <[ RustScriptPropDesc ] > { 
59+             fn  argument_desc( arg_names:  Option <& [ & ' static  str ] >)  -> Box <[ RustScriptPropDesc ] > { 
60+                 #[ expect( non_snake_case) ] 
61+                 let  [ $( $arg) ,+]  = arg_names. unwrap_or( & [ $( stringify!( $arg) ) ,+] ) . try_into( ) . unwrap( ) ;  //.unwrap_or_else(|| [$(stringify!($arg)),+]); 
62+ 
7763                Box :: new( [ 
78-                     $( signal_argument_desc!( "0" ,  $arg) ) ,+
64+                     $( signal_argument_desc!( $arg ,  $arg) ) ,+
7965                ] ) 
8066            } 
8167        } 
@@ -98,17 +84,17 @@ macro_rules! tuple_args {
9884macro_rules!  single_args { 
9985    ( impl  $arg:  ty)  => { 
10086        impl  SignalArguments  for  $arg { 
101-             fn  count( )  -> u8  { 
102-                 1 
103-             } 
87+             const  COUNT :  u8  = 1 ; 
10488
10589            fn  to_variants( & self )  -> Vec <Variant > { 
10690                vec![ self . to_variant( ) ] 
10791            } 
10892
109-             fn  argument_desc( )  -> Box <[ RustScriptPropDesc ] > { 
93+             fn  argument_desc( arg_names:  Option <& [ & ' static  str ] >)  -> Box <[ RustScriptPropDesc ] > { 
94+                 let  [ arg_name]  = arg_names. unwrap_or_else( || & [ "0" ] ) . try_into( ) . unwrap( ) ; 
95+ 
11096                Box :: new( [ 
111-                     signal_argument_desc!( "0" ,  $arg) , 
97+                     signal_argument_desc!( arg_name ,  $arg) , 
11298                ] ) 
11399            } 
114100        } 
@@ -120,7 +106,7 @@ macro_rules! single_args {
120106} 
121107
122108macro_rules!  signal_argument_desc { 
123-     ( $name: literal ,  $type: ty)  => { 
109+     ( $name: expr ,  $type: ty)  => { 
124110        RustScriptPropDesc  { 
125111            name:  $name, 
126112            ty:  <<<$type as  GodotConvert >:: Via  as  GodotType >:: Ffi  as  godot:: sys:: GodotFfi >:: VARIANT_TYPE . variant_as_nil( ) , 
@@ -135,55 +121,96 @@ macro_rules! signal_argument_desc {
135121
136122tuple_args ! ( A1 ,  A2 ,  A3 ,  A4 ,  A5 ,  A6 ,  A7 ,  A8 ,  A9 ,  A10 ) ; 
137123single_args ! ( 
138-     bool ,  u8 ,  u16 ,  u32 ,  u64 ,  i8 ,  i16 ,  i32 ,  i64 ,  f64 ,  GString ,  StringName ,  NodePath ,  Vector2 , 
139-     Vector3 ,  Dictionary 
124+     bool ,  u8 ,  u16 ,  u32 ,  u64 ,  i8 ,  i16 ,  i32 ,  i64 ,  f32 ,   f64 ,  GString ,  StringName ,  NodePath ,  Vector2 , 
125+     Vector3 ,  Vector4 ,   Dictionary 
140126) ; 
141127
128+ impl < T :  GodotClass >  SignalArguments  for  Gd < T >  { 
129+     const  COUNT :  u8  = 1 ; 
130+ 
131+     fn  to_variants ( & self )  -> Vec < Variant >  { 
132+         vec ! [ self . to_variant( ) ] 
133+     } 
134+ 
135+     fn  argument_desc ( arg_names :  Option < & [ & ' static  str ] > )  -> Box < [ RustScriptPropDesc ] >  { 
136+         let  name = arg_names
137+             . and_then ( |list| list. first ( ) ) 
138+             . copied ( ) 
139+             . unwrap_or ( "0" ) ; 
140+ 
141+         Box :: new ( [ signal_argument_desc ! ( name,  Self ) ] ) 
142+     } 
143+ } 
144+ 
145+ impl < T :  GodotScript >  SignalArguments  for  RsRef < T >  { 
146+     const  COUNT :  u8  = 1 ; 
147+ 
148+     fn  to_variants ( & self )  -> Vec < Variant >  { 
149+         vec ! [ self . to_variant( ) ] 
150+     } 
151+ 
152+     fn  argument_desc ( arg_names :  Option < & [ & ' static  str ] > )  -> Box < [ RustScriptPropDesc ] >  { 
153+         Box :: new ( [ signal_argument_desc ! ( 
154+             arg_names
155+                 . and_then( |list| list. first( ) ) 
156+                 . copied( ) 
157+                 . unwrap_or( "0" ) , 
158+             Self 
159+         ) ] ) 
160+     } 
161+ } 
162+ 
142163#[ derive( Debug ) ]  
143- pub  struct  Signal < T :  SignalArguments >  { 
164+ pub  struct  ScriptSignal < T :  SignalArguments >  { 
144165    host :  Gd < Object > , 
145166    name :  & ' static  str , 
146167    args :  PhantomData < T > , 
147168} 
148169
149- impl < T :  SignalArguments >  ScriptSignal  for  Signal < T >  { 
150-     type  Args  = T ; 
170+ #[ deprecated(  
171+     note = "The Signal type has been deprecated and will be removed soon. Please use the ScriptSignal instead."  
172+ ) ] 
173+ pub  type  Signal < T >  = ScriptSignal < T > ; 
174+ 
175+ impl < T :  SignalArguments >  ScriptSignal < T >  { 
176+     pub  const  ARG_COUNT :  u8  = T :: COUNT ; 
151177
152-     fn  new ( host :  Gd < Object > ,  name :  & ' static  str )  -> Self  { 
178+     pub   fn  new ( host :  Gd < Object > ,  name :  & ' static  str )  -> Self  { 
153179        Self  { 
154180            host, 
155181            name, 
156182            args :  PhantomData , 
157183        } 
158184    } 
159185
160-     fn  emit ( & self ,  args :  Self :: Args )  { 
186+     pub   fn  emit ( & self ,  args :  T )  { 
161187        self . host 
162188            . clone ( ) 
163189            . emit_signal ( self . name ,  & args. to_variants ( ) ) ; 
164190    } 
165191
166-     fn  connect ( & mut  self ,  callable :  Callable )  -> Result < ( ) ,  Error >  { 
192+     pub   fn  connect ( & mut  self ,  callable :  Callable )  -> Result < ( ) ,  Error >  { 
167193        match  self . host . connect ( self . name ,  & callable)  { 
168194            Error :: OK  => Ok ( ( ) ) , 
169195            error => Err ( error) , 
170196        } 
171197    } 
172198
173-     fn  argument_desc ( )  -> Box < [ RustScriptPropDesc ] >  { 
174-         <T  as  SignalArguments >:: argument_desc ( ) 
199+     #[ doc( hidden) ]  
200+     pub  fn  argument_desc ( arg_names :  Option < & [ & ' static  str ] > )  -> Box < [ RustScriptPropDesc ] >  { 
201+         <T  as  SignalArguments >:: argument_desc ( arg_names) 
175202    } 
176203
177-     fn  name ( & self )  -> & str  { 
204+     pub   fn  name ( & self )  -> & str  { 
178205        self . name 
179206    } 
180207} 
181208
182- impl < T :  SignalArguments >  GodotConvert  for  Signal < T >  { 
209+ impl < T :  SignalArguments >  GodotConvert  for  ScriptSignal < T >  { 
183210    type  Via  = godot:: builtin:: Signal ; 
184211} 
185212
186- impl < T :  SignalArguments >  ToGodot  for  Signal < T >  { 
213+ impl < T :  SignalArguments >  ToGodot  for  ScriptSignal < T >  { 
187214    type  ToVia < ' v > 
188215        = Self :: Via 
189216    where 
0 commit comments