Skip to content

Commit 37a8408

Browse files
committed
Support typed variadic args in gen_stubs
1 parent d04c85f commit 37a8408

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

scripts/dev/gen_stub.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -316,30 +316,24 @@ function funcInfoToCode(FuncInfo $funcInfo): string {
316316
}
317317

318318
foreach ($funcInfo->args as $argInfo) {
319-
if ($argInfo->isVariadic) {
320-
if ($argInfo->type) {
321-
throw new Exception("Not implemented");
322-
}
323-
$code .= sprintf(
324-
"\tZEND_ARG_VARIADIC_INFO(%d, %s)\n",
325-
$argInfo->byRef, $argInfo->name
326-
);
327-
} else if ($argInfo->type) {
319+
$argKind = $argInfo->isVariadic ? "ARG_VARIADIC" : "ARG";
320+
if ($argInfo->type) {
328321
if ($argInfo->type->isBuiltin) {
329322
$code .= sprintf(
330-
"\tZEND_ARG_TYPE_INFO(%d, %s, %s, %d)\n",
331-
$argInfo->byRef, $argInfo->name,
323+
"\tZEND_%s_TYPE_INFO(%d, %s, %s, %d)\n",
324+
$argKind, $argInfo->byRef, $argInfo->name,
332325
$argInfo->type->toTypeCode(), $argInfo->type->isNullable
333326
);
334327
} else {
335328
$code .= sprintf(
336-
"\tZEND_ARG_OBJ_INFO(%d, %s, %s, %d)\n",
337-
$argInfo->byRef, $argInfo->name,
329+
"\tZEND_%s_OBJ_INFO(%d, %s, %s, %d)\n",
330+
$argKind, $argInfo->byRef, $argInfo->name,
338331
$argInfo->type->name, $argInfo->type->isNullable
339332
);
340333
}
341334
} else {
342-
$code .= sprintf("\tZEND_ARG_INFO(%d, %s)\n", $argInfo->byRef, $argInfo->name);
335+
$code .= sprintf(
336+
"\tZEND_%s_INFO(%d, %s)\n", $argKind, $argInfo->byRef, $argInfo->name);
343337
}
344338
}
345339

0 commit comments

Comments
 (0)