@@ -158,11 +158,6 @@ impl<'a> Function<'a> {
158158 . iter ( )
159159 . map ( TypedArg :: arg_builder)
160160 . collect :: < Result < Vec < _ > > > ( ) ?;
161- let variadic = self . args . typed . iter ( ) . any ( |arg| arg. variadic ) . then ( || {
162- quote ! {
163- . variadic( )
164- }
165- } ) ;
166161 let returns = self . output . as_ref ( ) . map ( |output| {
167162 quote ! {
168163 . returns(
@@ -219,7 +214,6 @@ impl<'a> Function<'a> {
219214 #( . arg( & mut #required_arg_names) ) *
220215 . not_required( )
221216 #( . arg( & mut #not_required_arg_names) ) *
222- #variadic
223217 . parse( ) ;
224218 if parse_result. is_err( ) {
225219 return ;
@@ -264,7 +258,6 @@ impl<'a> Function<'a> {
264258 #( . arg( #required_args) ) *
265259 . not_required( )
266260 #( . arg( #not_required_args) ) *
267- #variadic
268261 #returns
269262 #docs
270263 } )
@@ -432,6 +425,7 @@ impl<'a> Args<'a> {
432425 let as_ref = ref_. mutability . is_some ( ) ;
433426 match ref_. elem . as_ref ( ) {
434427 Type :: Slice ( slice) => (
428+ // TODO: Allow specifying the variadic type.
435429 slice. elem . to_token_stream ( ) . to_string ( ) == "& Zval" ,
436430 as_ref,
437431 ty. clone ( ) ,
@@ -512,6 +506,21 @@ impl TypedArg<'_> {
512506 fn clean_ty ( & self ) -> Type {
513507 let mut ty = self . ty . clone ( ) ;
514508 ty. drop_lifetimes ( ) ;
509+
510+ // Variadic arguments are passed as slices, so we need to extract the
511+ // inner type.
512+ if self . variadic {
513+ let reference = if let Type :: Reference ( r) = & ty {
514+ r
515+ } else {
516+ return ty;
517+ } ;
518+
519+ if let Type :: Slice ( inner) = & * reference. elem {
520+ return * inner. elem . clone ( ) ;
521+ }
522+ }
523+
515524 ty
516525 }
517526
@@ -563,6 +572,10 @@ impl TypedArg<'_> {
563572 quote ! {
564573 #name. val( ) . unwrap_or( #default . into( ) )
565574 }
575+ } else if self . variadic {
576+ quote ! {
577+ & #name. variadic_vals( )
578+ }
566579 } else if self . nullable {
567580 // Originally I thought we could just use the below case for `null` options, as
568581 // `val()` will return `Option<Option<T>>`, however, this isn't the case when
0 commit comments