mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Make arginfo printing of prefer-ref arguments nicer
This commit is contained in:
parent
e047e9d893
commit
a98307df87
@ -20,12 +20,12 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_FFI_new, 0, 0, 1)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_FFI_free, 0, 0, 1)
|
||||
ZEND_ARG_OBJ_INFO(2, ptr, FFI\\CData, 0)
|
||||
ZEND_ARG_OBJ_INFO(ZEND_SEND_PREFER_REF, ptr, FFI\\CData, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_FFI_cast, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, type)
|
||||
ZEND_ARG_INFO(2, ptr)
|
||||
ZEND_ARG_INFO(ZEND_SEND_PREFER_REF, ptr)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_FFI_type, 0, 0, 1)
|
||||
@ -42,30 +42,30 @@ ZEND_END_ARG_INFO()
|
||||
#define arginfo_class_FFI_addr arginfo_class_FFI_free
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_FFI_sizeof, 0, 0, 1)
|
||||
ZEND_ARG_TYPE_INFO(2, ptr, IS_OBJECT, 0)
|
||||
ZEND_ARG_TYPE_INFO(ZEND_SEND_PREFER_REF, ptr, IS_OBJECT, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_class_FFI_alignof arginfo_class_FFI_sizeof
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_FFI_memcpy, 0, 0, 3)
|
||||
ZEND_ARG_OBJ_INFO(2, dst, FFI\\CData, 0)
|
||||
ZEND_ARG_INFO(2, src)
|
||||
ZEND_ARG_OBJ_INFO(ZEND_SEND_PREFER_REF, dst, FFI\\CData, 0)
|
||||
ZEND_ARG_INFO(ZEND_SEND_PREFER_REF, src)
|
||||
ZEND_ARG_TYPE_INFO(0, size, IS_LONG, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_FFI_memcmp, 0, 0, 3)
|
||||
ZEND_ARG_INFO(2, ptr1)
|
||||
ZEND_ARG_INFO(2, ptr2)
|
||||
ZEND_ARG_INFO(ZEND_SEND_PREFER_REF, ptr1)
|
||||
ZEND_ARG_INFO(ZEND_SEND_PREFER_REF, ptr2)
|
||||
ZEND_ARG_TYPE_INFO(0, size, IS_LONG, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_FFI_memset, 0, 0, 3)
|
||||
ZEND_ARG_OBJ_INFO(2, ptr, FFI\\CData, 0)
|
||||
ZEND_ARG_OBJ_INFO(ZEND_SEND_PREFER_REF, ptr, FFI\\CData, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, ch, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, size, IS_LONG, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_FFI_string, 0, 0, 1)
|
||||
ZEND_ARG_OBJ_INFO(2, ptr, FFI\\CData, 0)
|
||||
ZEND_ARG_OBJ_INFO(ZEND_SEND_PREFER_REF, ptr, FFI\\CData, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, size, IS_LONG, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
@ -151,7 +151,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_array_search, 0, 0, 2)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_extract, 0, 1, IS_LONG, 1)
|
||||
ZEND_ARG_TYPE_INFO(2, arg, IS_ARRAY, 0)
|
||||
ZEND_ARG_TYPE_INFO(ZEND_SEND_PREFER_REF, arg, IS_ARRAY, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, extract_type, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, prefix, IS_STRING, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
@ -306,10 +306,10 @@ ZEND_END_ARG_INFO()
|
||||
#define arginfo_array_udiff_uassoc arginfo_array_intersect_ukey
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_array_multisort, 0, 1, _IS_BOOL, 0)
|
||||
ZEND_ARG_INFO(2, arr1)
|
||||
ZEND_ARG_INFO(2, sort_order)
|
||||
ZEND_ARG_INFO(2, sort_flags)
|
||||
ZEND_ARG_VARIADIC_INFO(2, arr2)
|
||||
ZEND_ARG_INFO(ZEND_SEND_PREFER_REF, arr1)
|
||||
ZEND_ARG_INFO(ZEND_SEND_PREFER_REF, sort_order)
|
||||
ZEND_ARG_INFO(ZEND_SEND_PREFER_REF, sort_flags)
|
||||
ZEND_ARG_VARIADIC_INFO(ZEND_SEND_PREFER_REF, arr2)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_array_rand, 0, 0, 1)
|
||||
|
@ -135,6 +135,18 @@ class ArgInfo {
|
||||
&& $this->isVariadic === $other->isVariadic
|
||||
&& Type::equals($this->type, $other->type);
|
||||
}
|
||||
|
||||
public function getSendByString(): string {
|
||||
switch ($this->sendBy) {
|
||||
case self::SEND_BY_VAL:
|
||||
return "0";
|
||||
case self::SEND_BY_REF:
|
||||
return "1";
|
||||
case self::SEND_PREFER_REF:
|
||||
return "ZEND_SEND_PREFER_REF";
|
||||
}
|
||||
throw new Exception("Invalid sendBy value");
|
||||
}
|
||||
}
|
||||
|
||||
class ReturnInfo {
|
||||
@ -373,20 +385,20 @@ function funcInfoToCode(FuncInfo $funcInfo): string {
|
||||
if ($argInfo->type) {
|
||||
if ($argInfo->type->isBuiltin) {
|
||||
$code .= sprintf(
|
||||
"\tZEND_%s_TYPE_INFO(%d, %s, %s, %d)\n",
|
||||
$argKind, $argInfo->sendBy, $argInfo->name,
|
||||
"\tZEND_%s_TYPE_INFO(%s, %s, %s, %d)\n",
|
||||
$argKind, $argInfo->getSendByString(), $argInfo->name,
|
||||
$argInfo->type->toTypeCode(), $argInfo->type->isNullable
|
||||
);
|
||||
} else {
|
||||
$code .= sprintf(
|
||||
"\tZEND_%s_OBJ_INFO(%d, %s, %s, %d)\n",
|
||||
$argKind, $argInfo->sendBy, $argInfo->name,
|
||||
"\tZEND_%s_OBJ_INFO(%s, %s, %s, %d)\n",
|
||||
$argKind, $argInfo->getSendByString(), $argInfo->name,
|
||||
str_replace('\\', '\\\\', $argInfo->type->name), $argInfo->type->isNullable
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$code .= sprintf(
|
||||
"\tZEND_%s_INFO(%d, %s)\n", $argKind, $argInfo->sendBy, $argInfo->name);
|
||||
"\tZEND_%s_INFO(%s, %s)\n", $argKind, $argInfo->getSendByString(), $argInfo->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user