From a98307df8771f9b7fb0227ac2d4459e1419b887c Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 26 Aug 2019 15:39:39 +0200 Subject: Make arginfo printing of prefer-ref arguments nicer --- scripts/dev/gen_stub.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/dev/gen_stub.php b/scripts/dev/gen_stub.php index 9fa14fc662..f03e4b82c2 100755 --- a/scripts/dev/gen_stub.php +++ b/scripts/dev/gen_stub.php @@ -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); } } -- cgit v1.2.1