@@ -270,3 +270,51 @@ impl PropertyInfo {
270
270
}
271
271
}
272
272
}
273
+
274
+ #[ derive( Debug ) ]
275
+ pub struct MethodInfo {
276
+ pub id : i32 ,
277
+ pub method_name : StringName ,
278
+ pub class_name : ClassName ,
279
+ pub return_type : PropertyInfo ,
280
+ pub arguments : Vec < PropertyInfo > ,
281
+ pub default_arguments : Vec < Variant > ,
282
+ pub flags : global:: MethodFlags ,
283
+ }
284
+
285
+ impl MethodInfo {
286
+ pub fn method_sys ( & self ) -> sys:: GDExtensionMethodInfo {
287
+ use crate :: obj:: EngineEnum as _;
288
+
289
+ let argument_count = self . arguments . len ( ) as u32 ;
290
+ let argument_vec = self
291
+ . arguments
292
+ . iter ( )
293
+ . map ( |arg| arg. property_sys ( ) )
294
+ . collect :: < Vec < _ > > ( )
295
+ . into_boxed_slice ( ) ;
296
+
297
+ let arguments = unsafe { ( * Box :: into_raw ( argument_vec) ) . as_mut_ptr ( ) } ;
298
+
299
+ let default_argument_count = self . default_arguments . len ( ) as u32 ;
300
+ let default_argument_vec = self
301
+ . default_arguments
302
+ . iter ( )
303
+ . map ( |arg| arg. var_sys ( ) )
304
+ . collect :: < Vec < _ > > ( )
305
+ . into_boxed_slice ( ) ;
306
+
307
+ let default_arguments = unsafe { ( * Box :: into_raw ( default_argument_vec) ) . as_mut_ptr ( ) } ;
308
+
309
+ sys:: GDExtensionMethodInfo {
310
+ id : self . id ,
311
+ name : self . method_name . string_sys ( ) ,
312
+ return_value : self . return_type . property_sys ( ) ,
313
+ argument_count,
314
+ arguments,
315
+ default_argument_count,
316
+ default_arguments,
317
+ flags : u32:: try_from ( self . flags . ord ( ) ) . expect ( "flags should be valid" ) ,
318
+ }
319
+ }
320
+ }
0 commit comments