summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-08-26 15:39:39 +0200
committerNikita Popov <nikita.ppv@gmail.com>2019-08-26 15:39:39 +0200
commita98307df8771f9b7fb0227ac2d4459e1419b887c (patch)
treed324381bd0df219b4d311e12be17986981485014 /scripts
parente047e9d8939d77484a5d9eac5611622597a3d189 (diff)
downloadphp-git-a98307df8771f9b7fb0227ac2d4459e1419b887c.tar.gz
Make arginfo printing of prefer-ref arguments nicer
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/dev/gen_stub.php22
1 files changed, 17 insertions, 5 deletions
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);
}
}