Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit fcc9eb1

Browse files
committed
Add ObjectValue::IsConstructor() method
V8 commit: v8/v8@acbbd59
1 parent c2fe6e2 commit fcc9eb1

19 files changed

+159
-44
lines changed

scripts/replace_expect.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
$test_content .= PHP_EOL;
2121
file_put_contents($tests_dir . '/' . $test_file, $test_content);
2222

23-
foreach (['.diff', '.exp', '.log', '.mem', '.out', '.php'] as $ext) {
23+
foreach (['.diff', '.exp', '.log', '.mem', '.out', '.php', '.sh'] as $ext) {
2424
@unlink($tests_dir. '/'.$base_name . $ext);
2525
}
2626
} else {

src/php_v8_object.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,21 @@ static PHP_METHOD(V8Object, IsCallable) {
12931293
RETURN_BOOL(local_object->IsCallable());
12941294
}
12951295

1296+
1297+
static PHP_METHOD(V8Object, IsConstructor) {
1298+
if (zend_parse_parameters_none() == FAILURE) {
1299+
return;
1300+
}
1301+
1302+
PHP_V8_VALUE_FETCH_WITH_CHECK(getThis(), php_v8_value);
1303+
PHP_V8_ENTER_ISOLATE(php_v8_value->php_v8_isolate);
1304+
1305+
v8::Local<v8::Value> local_value = php_v8_value_get_value_local(isolate, php_v8_value);
1306+
v8::Local<v8::Object> local_object = v8::Local<v8::Object>::Cast(local_value);
1307+
1308+
RETURN_BOOL(local_object->IsConstructor());
1309+
}
1310+
12961311
static PHP_METHOD(V8Object, CallAsFunction) {
12971312
zval *php_v8_context_zv;
12981313
zval *php_v8_recv_zv;
@@ -1568,6 +1583,9 @@ ZEND_END_ARG_INFO()
15681583
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_v8_object_IsCallable, ZEND_RETURN_VALUE, 0, _IS_BOOL, NULL, 0)
15691584
ZEND_END_ARG_INFO()
15701585

1586+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_v8_object_IsConstructor, ZEND_RETURN_VALUE, 0, _IS_BOOL, NULL, 0)
1587+
ZEND_END_ARG_INFO()
1588+
15711589
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_v8_object_CallAsFunction, ZEND_RETURN_VALUE, 2, IS_OBJECT, PHP_V8_NS "\\Value", 0)
15721590
ZEND_ARG_OBJ_INFO(0, context, V8\\Context, 0)
15731591
ZEND_ARG_OBJ_INFO(0, recv, V8\\Value, 0)
@@ -1630,6 +1648,7 @@ static const zend_function_entry php_v8_object_methods[] = {
16301648
PHP_ME(V8Object, CreationContext, arginfo_v8_object_CreationContext, ZEND_ACC_PUBLIC)
16311649

16321650
PHP_ME(V8Object, IsCallable, arginfo_v8_object_IsCallable, ZEND_ACC_PUBLIC)
1651+
PHP_ME(V8Object, IsConstructor, arginfo_v8_object_IsConstructor, ZEND_ACC_PUBLIC)
16331652
PHP_ME(V8Object, CallAsFunction, arginfo_v8_object_CallAsFunction, ZEND_ACC_PUBLIC)
16341653
PHP_ME(V8Object, CallAsConstructor, arginfo_v8_object_CallAsConstructor, ZEND_ACC_PUBLIC)
16351654

stubs/src/ObjectValue.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,15 @@ public function IsCallable() : bool
477477
{
478478
}
479479

480+
/**
481+
* True if this object is a constructor.
482+
*
483+
* @return bool
484+
*/
485+
public function IsConstructor() : bool
486+
{
487+
}
488+
480489
/**
481490
* Call an Object as a function if a callback is set by the
482491
* ObjectTemplate::SetCallAsFunctionHandler method.

tests/V8ArrayObject.phpt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ V8\ArrayObject::CreationContext() matches expected value
129129
Converters:
130130
-----------
131131
V8\ArrayObject(V8\Value)->ToBoolean():
132-
object(V8\BooleanValue)#94 (1) {
132+
object(V8\BooleanValue)#95 (1) {
133133
["isolate":"V8\Value":private]=>
134134
object(V8\Isolate)#3 (5) {
135135
["snapshot":"V8\Isolate":private]=>
@@ -145,7 +145,7 @@ V8\ArrayObject(V8\Value)->ToBoolean():
145145
}
146146
}
147147
V8\ArrayObject(V8\Value)->ToNumber():
148-
object(V8\NumberValue)#94 (1) {
148+
object(V8\NumberValue)#95 (1) {
149149
["isolate":"V8\Value":private]=>
150150
object(V8\Isolate)#3 (5) {
151151
["snapshot":"V8\Isolate":private]=>
@@ -161,7 +161,7 @@ V8\ArrayObject(V8\Value)->ToNumber():
161161
}
162162
}
163163
V8\ArrayObject(V8\Value)->ToString():
164-
object(V8\StringValue)#94 (1) {
164+
object(V8\StringValue)#95 (1) {
165165
["isolate":"V8\Value":private]=>
166166
object(V8\Isolate)#3 (5) {
167167
["snapshot":"V8\Isolate":private]=>
@@ -177,7 +177,7 @@ V8\ArrayObject(V8\Value)->ToString():
177177
}
178178
}
179179
V8\ArrayObject(V8\Value)->ToDetailString():
180-
object(V8\StringValue)#94 (1) {
180+
object(V8\StringValue)#95 (1) {
181181
["isolate":"V8\Value":private]=>
182182
object(V8\Isolate)#3 (5) {
183183
["snapshot":"V8\Isolate":private]=>
@@ -246,7 +246,7 @@ V8\ArrayObject(V8\Value)->ToObject():
246246
}
247247
}
248248
V8\ArrayObject(V8\Value)->ToInteger():
249-
object(V8\NumberValue)#94 (1) {
249+
object(V8\NumberValue)#95 (1) {
250250
["isolate":"V8\Value":private]=>
251251
object(V8\Isolate)#3 (5) {
252252
["snapshot":"V8\Isolate":private]=>
@@ -262,7 +262,7 @@ V8\ArrayObject(V8\Value)->ToInteger():
262262
}
263263
}
264264
V8\ArrayObject(V8\Value)->ToUint32():
265-
object(V8\NumberValue)#94 (1) {
265+
object(V8\NumberValue)#95 (1) {
266266
["isolate":"V8\Value":private]=>
267267
object(V8\Isolate)#3 (5) {
268268
["snapshot":"V8\Isolate":private]=>
@@ -278,7 +278,7 @@ V8\ArrayObject(V8\Value)->ToUint32():
278278
}
279279
}
280280
V8\ArrayObject(V8\Value)->ToInt32():
281-
object(V8\NumberValue)#94 (1) {
281+
object(V8\NumberValue)#95 (1) {
282282
["isolate":"V8\Value":private]=>
283283
object(V8\Isolate)#3 (5) {
284284
["snapshot":"V8\Isolate":private]=>

tests/V8BooleanObject.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ Checkers:
124124
V8\BooleanObject(V8\Value)->TypeOf(): V8\StringValue->Value(): string(6) "object"
125125

126126
V8\BooleanObject(V8\ObjectValue)->IsCallable(): bool(false)
127+
V8\BooleanObject(V8\ObjectValue)->IsConstructor(): bool(false)
127128
V8\BooleanObject(V8\Value)->IsUndefined(): bool(false)
128129
V8\BooleanObject(V8\Value)->IsNull(): bool(false)
129130
V8\BooleanObject(V8\Value)->IsTrue(): bool(false)
@@ -157,6 +158,7 @@ Checkers on boxed from script:
157158
V8\BooleanObject(V8\Value)->TypeOf(): V8\StringValue->Value(): string(6) "object"
158159

159160
V8\BooleanObject(V8\ObjectValue)->IsCallable(): bool(false)
161+
V8\BooleanObject(V8\ObjectValue)->IsConstructor(): bool(false)
160162
V8\BooleanObject(V8\Value)->IsUndefined(): bool(false)
161163
V8\BooleanObject(V8\Value)->IsNull(): bool(false)
162164
V8\BooleanObject(V8\Value)->IsTrue(): bool(false)

tests/V8DateObject.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ Checkers:
182182
V8\DateObject(V8\Value)->TypeOf(): V8\StringValue->Value(): string(6) "object"
183183

184184
V8\DateObject(V8\ObjectValue)->IsCallable(): bool(false)
185+
V8\DateObject(V8\ObjectValue)->IsConstructor(): bool(false)
185186
V8\DateObject(V8\Value)->IsUndefined(): bool(false)
186187
V8\DateObject(V8\Value)->IsNull(): bool(false)
187188
V8\DateObject(V8\Value)->IsTrue(): bool(false)

tests/V8Exception_CreateMessage.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ Checks on V8\ObjectValue:
157157
V8\ObjectValue(V8\Value)->TypeOf(): V8\StringValue->Value(): string(6) "object"
158158

159159
V8\ObjectValue->IsCallable(): bool(false)
160+
V8\ObjectValue->IsConstructor(): bool(false)
160161
V8\ObjectValue(V8\Value)->IsUndefined(): bool(false)
161162
V8\ObjectValue(V8\Value)->IsNull(): bool(false)
162163
V8\ObjectValue(V8\Value)->IsTrue(): bool(false)

tests/V8Exception_Error.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Checks on V8\ObjectValue:
105105
V8\ObjectValue(V8\Value)->TypeOf(): V8\StringValue->Value(): string(6) "object"
106106

107107
V8\ObjectValue->IsCallable(): bool(false)
108+
V8\ObjectValue->IsConstructor(): bool(false)
108109
V8\ObjectValue(V8\Value)->IsUndefined(): bool(false)
109110
V8\ObjectValue(V8\Value)->IsNull(): bool(false)
110111
V8\ObjectValue(V8\Value)->IsTrue(): bool(false)

tests/V8Exception_RangeError.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ Checks on V8\ObjectValue:
106106
V8\ObjectValue(V8\Value)->TypeOf(): V8\StringValue->Value(): string(6) "object"
107107

108108
V8\ObjectValue->IsCallable(): bool(false)
109+
V8\ObjectValue->IsConstructor(): bool(false)
109110
V8\ObjectValue(V8\Value)->IsUndefined(): bool(false)
110111
V8\ObjectValue(V8\Value)->IsNull(): bool(false)
111112
V8\ObjectValue(V8\Value)->IsTrue(): bool(false)

tests/V8Exception_ReferenceError.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ Checks on V8\ObjectValue:
106106
V8\ObjectValue(V8\Value)->TypeOf(): V8\StringValue->Value(): string(6) "object"
107107

108108
V8\ObjectValue->IsCallable(): bool(false)
109+
V8\ObjectValue->IsConstructor(): bool(false)
109110
V8\ObjectValue(V8\Value)->IsUndefined(): bool(false)
110111
V8\ObjectValue(V8\Value)->IsNull(): bool(false)
111112
V8\ObjectValue(V8\Value)->IsTrue(): bool(false)

0 commit comments

Comments
 (0)