@@ -191,6 +191,7 @@ pub struct RustTypeBuilder<'env> {
191191 concurrency : library:: Concurrency ,
192192 try_from_glib : TryFromGlib ,
193193 callback_parameters_config : CallbackParameters ,
194+ c_type : String ,
194195}
195196
196197impl < ' env > RustTypeBuilder < ' env > {
@@ -205,6 +206,7 @@ impl<'env> RustTypeBuilder<'env> {
205206 concurrency : library:: Concurrency :: None ,
206207 try_from_glib : TryFromGlib :: default ( ) ,
207208 callback_parameters_config : Vec :: new ( ) ,
209+ c_type : String :: default ( ) ,
208210 }
209211 }
210212
@@ -238,6 +240,11 @@ impl<'env> RustTypeBuilder<'env> {
238240 self
239241 }
240242
243+ pub fn c_type ( mut self , c_type : String ) -> Self {
244+ self . c_type = c_type;
245+ self
246+ }
247+
241248 pub fn callback_parameters_config (
242249 mut self ,
243250 callback_parameters_config : & [ CallbackParameter ] ,
@@ -348,7 +355,8 @@ impl<'env> RustTypeBuilder<'env> {
348355 if ConversionType :: of ( self . env , inner_tid) == ConversionType :: Pointer =>
349356 {
350357 skip_option = true ;
351- let inner_ref_mode = match self . env . type_ ( inner_tid) {
358+ let inner_type = self . env . type_ ( inner_tid) ;
359+ let inner_ref_mode = match inner_type {
352360 Class ( ..) | Interface ( ..) => RefMode :: None ,
353361 Record ( record) => match RecordType :: of ( record) {
354362 RecordType :: Boxed => RefMode :: None ,
@@ -373,7 +381,57 @@ impl<'env> RustTypeBuilder<'env> {
373381 if self . ref_mode . is_ref ( ) {
374382 format ! ( "[{typ}]" )
375383 } else {
376- format ! ( "Vec<{typ}>" )
384+ let is_obj = matches ! ( inner_type, Class ( _) | Interface ( _) ) ;
385+ let is_ptr = is_obj
386+ || matches ! ( inner_type, Basic ( Pointer ) )
387+ || ( matches ! ( inner_type, Record ( _) )
388+ && self
389+ . env
390+ . config
391+ . objects
392+ . get ( & inner_tid. full_name ( & self . env . library ) )
393+ . map ( |o| !o. boxed_inline )
394+ . unwrap_or ( false ) ) ;
395+ let is_string = matches ! ( inner_type, Basic ( Utf8 ) ) ;
396+ match * type_ {
397+ CArray ( _) if is_ptr => {
398+ format ! ( "{}<{typ}>" , use_glib_type( self . env, "PtrSlice" ) )
399+ }
400+ CArray ( _)
401+ if is_string
402+ && matches ! (
403+ self . c_type. as_str( ) ,
404+ "char**" | "gchar**"
405+ ) =>
406+ {
407+ use_glib_type ( self . env , "StrV" )
408+ }
409+ CArray ( _)
410+ if !matches ! (
411+ inner_type,
412+ Basic ( Utf8 | Filename | OsString | Boolean )
413+ ) =>
414+ {
415+ format ! ( "{}<{typ}>" , use_glib_type( self . env, "Slice" ) )
416+ }
417+ List ( _) if is_ptr => {
418+ format ! ( "{}<{typ}>" , use_glib_type( self . env, "List" ) )
419+ }
420+ List ( _) if is_string => format ! (
421+ "{}<{}>" ,
422+ use_glib_type( self . env, "List" ) ,
423+ use_glib_type( self . env, "GStringPtr" )
424+ ) ,
425+ SList ( _) if is_ptr => {
426+ format ! ( "{}<{typ}>" , use_glib_type( self . env, "SList" ) )
427+ }
428+ SList ( _) if is_string => format ! (
429+ "{}<{}>" ,
430+ use_glib_type( self . env, "SList" ) ,
431+ use_glib_type( self . env, "GStringPtr" )
432+ ) ,
433+ _ => format ! ( "Vec<{typ}>" ) ,
434+ }
377435 }
378436 } )
379437 } )
@@ -623,6 +681,7 @@ impl<'env> RustTypeBuilder<'env> {
623681 . direction ( self . direction )
624682 . nullable ( self . nullable )
625683 . ref_mode ( self . ref_mode )
684+ . c_type ( self . c_type )
626685 . scope ( self . scope )
627686 . try_from_glib ( & self . try_from_glib )
628687 . try_build ( ) ;
0 commit comments