@@ -158,11 +158,6 @@ impl<'a> Function<'a> {
158
158
. iter ( )
159
159
. map ( TypedArg :: arg_builder)
160
160
. collect :: < Result < Vec < _ > > > ( ) ?;
161
- let variadic = self . args . typed . iter ( ) . any ( |arg| arg. variadic ) . then ( || {
162
- quote ! {
163
- . variadic( )
164
- }
165
- } ) ;
166
161
let returns = self . output . as_ref ( ) . map ( |output| {
167
162
quote ! {
168
163
. returns(
@@ -219,7 +214,6 @@ impl<'a> Function<'a> {
219
214
#( . arg( & mut #required_arg_names) ) *
220
215
. not_required( )
221
216
#( . arg( & mut #not_required_arg_names) ) *
222
- #variadic
223
217
. parse( ) ;
224
218
if parse_result. is_err( ) {
225
219
return ;
@@ -264,7 +258,6 @@ impl<'a> Function<'a> {
264
258
#( . arg( #required_args) ) *
265
259
. not_required( )
266
260
#( . arg( #not_required_args) ) *
267
- #variadic
268
261
#returns
269
262
#docs
270
263
} )
@@ -432,6 +425,7 @@ impl<'a> Args<'a> {
432
425
let as_ref = ref_. mutability . is_some ( ) ;
433
426
match ref_. elem . as_ref ( ) {
434
427
Type :: Slice ( slice) => (
428
+ // TODO: Allow specifying the variadic type.
435
429
slice. elem . to_token_stream ( ) . to_string ( ) == "& Zval" ,
436
430
as_ref,
437
431
ty. clone ( ) ,
@@ -512,6 +506,21 @@ impl TypedArg<'_> {
512
506
fn clean_ty ( & self ) -> Type {
513
507
let mut ty = self . ty . clone ( ) ;
514
508
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
+
515
524
ty
516
525
}
517
526
@@ -563,6 +572,10 @@ impl TypedArg<'_> {
563
572
quote ! {
564
573
#name. val( ) . unwrap_or( #default . into( ) )
565
574
}
575
+ } else if self . variadic {
576
+ quote ! {
577
+ & #name. variadic_vals( )
578
+ }
566
579
} else if self . nullable {
567
580
// Originally I thought we could just use the below case for `null` options, as
568
581
// `val()` will return `Option<Option<T>>`, however, this isn't the case when
0 commit comments