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

Commit 840e46a

Browse files
committed
Drop non-working V8\Context extensions support
BC-break: removed $extensions argument from V8\Context constructor
1 parent 2b5ecaa commit 840e46a

File tree

79 files changed

+105
-273
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+105
-273
lines changed

src/php_v8_context.cc

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,14 @@ php_v8_context_t * php_v8_context_get_reference(v8::Local<v8::Context> context)
8989
static PHP_METHOD(V8Context, __construct)
9090
{
9191
zval *php_v8_isolate_zv;
92-
zval *extensions_zv = NULL;
9392
zval *php_v8_global_template_zv = NULL;
9493
zval *php_v8_global_object_zv = NULL;
9594

9695
v8::ExtensionConfiguration *extensions = NULL;
9796
v8::Local<v8::ObjectTemplate> global_template;
9897
v8::Local<v8::Value> global_object;
9998

100-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o|a!o!o!", &php_v8_isolate_zv, &extensions_zv, &php_v8_global_template_zv, &php_v8_global_object_zv) == FAILURE) {
99+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o|o!o!", &php_v8_isolate_zv, &php_v8_global_template_zv, &php_v8_global_object_zv) == FAILURE) {
101100
return;
102101
}
103102

@@ -108,20 +107,10 @@ static PHP_METHOD(V8Context, __construct)
108107
PHP_V8_STORE_POINTER_TO_ISOLATE(php_v8_context, php_v8_isolate);
109108
PHP_V8_ENTER_ISOLATE(php_v8_isolate);
110109

111-
if (extensions_zv) {
112-
zend_update_property(this_ce, getThis(), ZEND_STRL("extensions"), extensions_zv);
113-
}
114-
115110
if (php_v8_global_template_zv) {
116111
zend_update_property(this_ce, getThis(), ZEND_STRL("global_template"), php_v8_global_template_zv);
117112
}
118113

119-
// TODO: implement extensions, note this feature is controversial, it also requires v8::RegisterExtension()
120-
// TODO: store registered extensions somewhere and validate them by name before setting?
121-
if (extensions_zv && zend_array_count(Z_ARRVAL_P(extensions_zv)) > 0) {
122-
zend_error(E_WARNING, "Extensions are not supported yet");
123-
}
124-
125114
if (php_v8_global_template_zv && Z_TYPE_P(php_v8_global_template_zv) != IS_NULL) {
126115
PHP_V8_FETCH_OBJECT_TEMPLATE_WITH_CHECK(php_v8_global_template_zv, php_v8_global_template);
127116
PHP_V8_DATA_ISOLATES_CHECK(php_v8_context, php_v8_global_template);
@@ -308,7 +297,6 @@ static PHP_METHOD(V8Context, EstimatedSize)
308297

309298
ZEND_BEGIN_ARG_INFO_EX(arginfo_v8_context___construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
310299
ZEND_ARG_OBJ_INFO(0, isolate, V8\\Isolate, 0)
311-
ZEND_ARG_ARRAY_INFO(0, extensions, 1)
312300
ZEND_ARG_OBJ_INFO(0, global_template, V8\\ObjectTemplate, 1)
313301
ZEND_ARG_OBJ_INFO(0, global_object, V8\\ObjectValue, 1)
314302
ZEND_END_ARG_INFO()
@@ -383,7 +371,6 @@ PHP_MINIT_FUNCTION(php_v8_context)
383371
this_ce->create_object = php_v8_context_ctor;
384372

385373
zend_declare_property_null(this_ce, ZEND_STRL("isolate"), ZEND_ACC_PRIVATE);
386-
zend_declare_property_null(this_ce, ZEND_STRL("extensions"), ZEND_ACC_PRIVATE);
387374
zend_declare_property_null(this_ce, ZEND_STRL("global_template"), ZEND_ACC_PRIVATE);
388375
zend_declare_property_null(this_ce, ZEND_STRL("global_object"), ZEND_ACC_PRIVATE);
389376

stubs/src/Context.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ class Context
3232
*
3333
* \param isolate The isolate in which to create the context.
3434
*
35-
* \param extensions An optional extension configuration containing
36-
* the extensions to be installed in the newly created context.
37-
*
3835
* \param global_template An optional object template from which the
3936
* global object for the newly created context will be created.
4037
*
@@ -45,15 +42,13 @@ class Context
4542
* and only object identify will remain.
4643
*
4744
* @param \V8\Isolate $isolate
48-
* @param array|null $extensions Currently unused as there are not extensions support
4945
* @param \V8\ObjectTemplate|null $global_template
5046
* @param \V8\ObjectValue|null $global_object
47+
*
48+
* @internal param array|null $extensions Currently unused as there are not extensions support
5149
*/
5250
public function __construct(
53-
Isolate $isolate,
54-
array $extensions = null,
55-
ObjectTemplate $global_template = null,
56-
ObjectValue $global_object = null
51+
Isolate $isolate, ObjectTemplate $global_template = null, ObjectValue $global_object = null
5752
) {
5853
}
5954

tests/003-V8ObjectTemplate_recursive_global.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ try {
2525
$helper->exception_export($e);
2626
}
2727

28-
$context = new \V8\Context($isolate, [], $template);
28+
$context = new \V8\Context($isolate, $template);
2929

3030

3131
?>

tests/V8ArrayObject.phpt

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ require '.v8-helpers.php';
1212
$v8_helper = new PhpV8Helpers($helper);
1313

1414
$isolate = new \V8\Isolate();
15-
$extensions1 = [];
1615
$global_template1 = new V8\ObjectTemplate($isolate);
1716

1817
$global_template1->Set(new \V8\StringValue($isolate, 'print'), $v8_helper->getPrintFunctionTemplate($isolate), \V8\PropertyAttribute::DontDelete);
19-
$context = new V8\Context($isolate, $extensions1, $global_template1);
18+
$context = new V8\Context($isolate, $global_template1);
2019

2120
$value = new V8\ArrayObject($context);
2221

@@ -81,7 +80,7 @@ object(V8\ArrayObject)#6 (2) {
8180
bool(false)
8281
}
8382
["context":"V8\ObjectValue":private]=>
84-
object(V8\Context)#5 (4) {
83+
object(V8\Context)#5 (3) {
8584
["isolate":"V8\Context":private]=>
8685
object(V8\Isolate)#3 (5) {
8786
["snapshot":"V8\Isolate":private]=>
@@ -95,9 +94,6 @@ object(V8\ArrayObject)#6 (2) {
9594
["memory_limit_hit":"V8\Isolate":private]=>
9695
bool(false)
9796
}
98-
["extensions":"V8\Context":private]=>
99-
array(0) {
100-
}
10197
["global_template":"V8\Context":private]=>
10298
object(V8\ObjectTemplate)#4 (1) {
10399
["isolate":"V8\Template":private]=>
@@ -267,7 +263,7 @@ V8\ArrayObject(V8\Value)->ToObject():
267263
bool(false)
268264
}
269265
["context":"V8\ObjectValue":private]=>
270-
object(V8\Context)#5 (4) {
266+
object(V8\Context)#5 (3) {
271267
["isolate":"V8\Context":private]=>
272268
object(V8\Isolate)#3 (5) {
273269
["snapshot":"V8\Isolate":private]=>
@@ -281,9 +277,6 @@ V8\ArrayObject(V8\Value)->ToObject():
281277
["memory_limit_hit":"V8\Isolate":private]=>
282278
bool(false)
283279
}
284-
["extensions":"V8\Context":private]=>
285-
array(0) {
286-
}
287280
["global_template":"V8\Context":private]=>
288281
object(V8\ObjectTemplate)#4 (1) {
289282
["isolate":"V8\Template":private]=>

tests/V8ArrayObject_Length.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ V8\ArrayObject::Length
99
$helper = require '.testsuite.php';
1010

1111
$isolate1 = new \V8\Isolate();
12-
$extensions1 = [];
1312
$global_template1 = new V8\ObjectTemplate($isolate1);
1413

15-
$context1 = new V8\Context($isolate1, $extensions1, $global_template1);
14+
$context1 = new V8\Context($isolate1, $global_template1);
1615

1716
$source1 = '
1817
[1,2,3]

tests/V8Boolean.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ $helper->space();
3333

3434
$v8_helper->run_checks($value, 'Checkers');
3535

36-
$extensions = [];
3736
$global_template = new \V8\ObjectTemplate($isolate);
38-
$context = new \V8\Context($isolate, $extensions, $global_template);
37+
$context = new \V8\Context($isolate, $global_template);
3938

4039

4140
$helper->header('Primitive converters');

tests/V8BooleanObject.phpt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ require '.v8-helpers.php';
1212
$v8_helper = new PhpV8Helpers($helper);
1313

1414
$isolate1 = new \V8\Isolate();
15-
$extensions1 = [];
1615
$global_template1 = new V8\ObjectTemplate($isolate1);
1716

1817
// TODO: fix it, this cause segfault due to FunctionTemplate object destruction and all it internal structures cleanup
1918
//$global_template1->Set('print', $v8_helper->getPrintFunctionTemplate($isolate1), \V8\PropertyAttribute::DontDelete);
2019
$print_func_tpl = $v8_helper->getPrintFunctionTemplate($isolate1);
2120
$global_template1->Set(new \V8\StringValue($isolate1, 'print'), $print_func_tpl, \V8\PropertyAttribute::DontDelete);
2221

23-
$context1 = new V8\Context($isolate1, $extensions1, $global_template1);
22+
$context1 = new V8\Context($isolate1, $global_template1);
2423

2524
$value = new V8\BooleanObject($context1, true);
2625

@@ -73,7 +72,7 @@ object(V8\BooleanObject)#8 (2) {
7372
bool(false)
7473
}
7574
["context":"V8\ObjectValue":private]=>
76-
object(V8\Context)#7 (4) {
75+
object(V8\Context)#7 (3) {
7776
["isolate":"V8\Context":private]=>
7877
object(V8\Isolate)#3 (5) {
7978
["snapshot":"V8\Isolate":private]=>
@@ -87,9 +86,6 @@ object(V8\BooleanObject)#8 (2) {
8786
["memory_limit_hit":"V8\Isolate":private]=>
8887
bool(false)
8988
}
90-
["extensions":"V8\Context":private]=>
91-
array(0) {
92-
}
9389
["global_template":"V8\Context":private]=>
9490
object(V8\ObjectTemplate)#4 (1) {
9591
["isolate":"V8\Template":private]=>

tests/V8Context.phpt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ require '.v8-helpers.php';
1212
$v8_helper = new PhpV8Helpers($helper);
1313

1414
$isolate1 = new \V8\Isolate();
15-
$extensions1 = [];
16-
//$global_template1 = new V8\ObjectTemplate($isolate1);
17-
//$global_template1->Set('print', $v8_helper->getPrintFunctionTemplate($isolate1), \V8\PropertyAttribute::DontDelete);
18-
19-
try{
20-
$context = new \V8\Context($isolate1, ['some', 'extensions']);
21-
} catch(Exception $e) {
22-
$helper->exception_export($e);
23-
}
2415

2516
$context = new \V8\Context($isolate1);
2617
$helper->pretty_dump('Estimated memory usage size by this context', $context->EstimatedSize());
@@ -50,7 +41,6 @@ $helper->pretty_dump('Estimated memory usage size by this context', $context->Es
5041

5142
?>
5243
--EXPECTF--
53-
ErrorException: Extensions are not supported yet
5444
Estimated memory usage size by this context: int(%d)
5545
V8\Context::GlobalObject() result is instance of V8\ObjectValue
5646
CHECK $global->SameValue($context->GlobalObject()): OK

tests/V8Context_GlobalObject.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ $v8_helper = new PhpV8Helpers($helper);
1515
require '.tracking_dtors.php';
1616

1717
$isolate1 = new \V8\Isolate();
18-
$extensions1 = [];
19-
2018
$context = new \V8\Context($isolate1);
2119

2220
$helper->method_matches_instanceof($context, 'GlobalObject', \V8\ObjectValue::class);
@@ -31,7 +29,7 @@ $helper->assert('Global object on repeatable calls holds extra props', $global1-
3129

3230
$context->DetachGlobal();
3331

34-
$context2 = new \V8\Context($isolate1, null, null, $global2);
32+
$context2 = new \V8\Context($isolate1, null, $global2);
3533
$helper->method_matches_instanceof($context2, 'GlobalObject', \V8\ObjectValue::class);
3634

3735
echo 'Global object passed from one context to another is ', ($global1 === $global2 ? 'the same' : 'not the same'), PHP_EOL;

tests/V8Context_weakness.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ class Context extends V8\Context {
1717
}
1818

1919
$isolate1 = new \V8\Isolate();
20-
$extensions1 = [];
2120

2221
$global_template1 = new V8\ObjectTemplate($isolate1);
2322

2423
$source1 = 'var obj = {}; obj';
2524
$file_name1 = 'test.js';
2625

2726
$script1 = new \V8\Script(
28-
new Context($isolate1, $extensions1, $global_template1),
27+
new Context($isolate1, $global_template1),
2928
new \V8\StringValue($isolate1, $source1),
3029
new \V8\ScriptOrigin($file_name1)
3130
);

tests/V8DateObject.phpt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ require '.v8-helpers.php';
1818
$v8_helper = new PhpV8Helpers($helper);
1919

2020
$isolate1 = new \V8\Isolate();
21-
$extensions1 = [];
2221
$global_template1 = new V8\ObjectTemplate($isolate1);
2322

2423
// TODO: fix it, this cause segfault due to FunctionTemplate object destruction and all it internal structures cleanup
2524
//$global_template1->Set('print', $v8_helper->getPrintFunctionTemplate($isolate1), \V8\PropertyAttribute::DontDelete);
2625
$print_func_tpl = $v8_helper->getPrintFunctionTemplate($isolate1);
2726
$global_template1->Set(new \V8\StringValue($isolate1, 'print'), $print_func_tpl, \V8\PropertyAttribute::DontDelete);
2827

29-
$context1 = new V8\Context($isolate1, $extensions1, $global_template1);
28+
$context1 = new V8\Context($isolate1, $global_template1);
3029

3130
$test_time = 1445444940000.0;
3231
$value = new V8\DateObject($context1, $test_time);
@@ -131,7 +130,7 @@ object(V8\DateObject)#8 (2) {
131130
bool(false)
132131
}
133132
["context":"V8\ObjectValue":private]=>
134-
object(V8\Context)#7 (4) {
133+
object(V8\Context)#7 (3) {
135134
["isolate":"V8\Context":private]=>
136135
object(V8\Isolate)#3 (5) {
137136
["snapshot":"V8\Isolate":private]=>
@@ -145,9 +144,6 @@ object(V8\DateObject)#8 (2) {
145144
["memory_limit_hit":"V8\Isolate":private]=>
146145
bool(false)
147146
}
148-
["extensions":"V8\Context":private]=>
149-
array(0) {
150-
}
151147
["global_template":"V8\Context":private]=>
152148
object(V8\ObjectTemplate)#4 (1) {
153149
["isolate":"V8\Template":private]=>

tests/V8Exception_CreateMessage.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ $global_tpl = new \V8\ObjectTemplate($isolate);
4545
$global_tpl->Set(new \V8\StringValue($isolate, 'print'), $v8_helper->getPrintFunctionTemplate($isolate));
4646
$global_tpl->Set(new \V8\StringValue($isolate, 'test'), $func_test_tpl);
4747

48-
$context = new \V8\Context($isolate, [], $global_tpl);
48+
$context = new \V8\Context($isolate, $global_tpl);
4949

5050

5151
$source = '

tests/V8Exception_Error.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ $global_tpl->Set(new \V8\StringValue($isolate, 'e'), $func_tpl);
5555
$global_tpl->Set(new \V8\StringValue($isolate, 'print'), $v8_helper->getPrintFunctionTemplate($isolate));
5656
$global_tpl->Set(new \V8\StringValue($isolate, 'test'), $func_test_tpl);
5757

58-
$context = new \V8\Context($isolate, [], $global_tpl);
58+
$context = new \V8\Context($isolate, $global_tpl);
5959

6060
$v8_helper->CompileTryRun($context, 'test()');
6161
$v8_helper->CompileTryRun($context, 'e()');

tests/V8Exception_GetStackTrace.phpt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ $global_tpl = new \V8\ObjectTemplate($isolate);
5858
$global_tpl->Set(new \V8\StringValue($isolate, 'print'), $v8_helper->getPrintFunctionTemplate($isolate));
5959
$global_tpl->Set(new \V8\StringValue($isolate, 'test'), $func_test_tpl);
6060

61-
$context = new \V8\Context($isolate, [], $global_tpl);
61+
$context = new \V8\Context($isolate, $global_tpl);
6262

6363

6464
$source = '
@@ -148,7 +148,7 @@ V8\StackTrace->AsArray():
148148
bool(false)
149149
}
150150
["context":"V8\ObjectValue":private]=>
151-
object(V8\Context)#8 (4) {
151+
object(V8\Context)#8 (3) {
152152
["isolate":"V8\Context":private]=>
153153
object(V8\Isolate)#3 (5) {
154154
["snapshot":"V8\Isolate":private]=>
@@ -162,9 +162,6 @@ V8\StackTrace->AsArray():
162162
["memory_limit_hit":"V8\Isolate":private]=>
163163
bool(false)
164164
}
165-
["extensions":"V8\Context":private]=>
166-
array(0) {
167-
}
168165
["global_template":"V8\Context":private]=>
169166
object(V8\ObjectTemplate)#7 (1) {
170167
["isolate":"V8\Template":private]=>

tests/V8Exception_RangeError.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ $global_tpl->Set(new \V8\StringValue($isolate, 'e'), $func_tpl);
5656
$global_tpl->Set(new \V8\StringValue($isolate, 'print'), $v8_helper->getPrintFunctionTemplate($isolate));
5757
$global_tpl->Set(new \V8\StringValue($isolate, 'test'), $func_test_tpl);
5858

59-
$context = new \V8\Context($isolate, [], $global_tpl);
59+
$context = new \V8\Context($isolate, $global_tpl);
6060

6161
$v8_helper->CompileTryRun($context, 'test()');
6262
$v8_helper->CompileTryRun($context, 'e()');

tests/V8Exception_ReferenceError.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ $global_tpl->Set(new \V8\StringValue($isolate, 'e'), $func_tpl);
5656
$global_tpl->Set(new \V8\StringValue($isolate, 'print'), $v8_helper->getPrintFunctionTemplate($isolate));
5757
$global_tpl->Set(new \V8\StringValue($isolate, 'test'), $func_test_tpl);
5858

59-
$context = new \V8\Context($isolate, [], $global_tpl);
59+
$context = new \V8\Context($isolate, $global_tpl);
6060

6161
$v8_helper->CompileTryRun($context, 'test()');
6262
$v8_helper->CompileTryRun($context, 'e()');

tests/V8Exception_SyntaxError.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ $global_tpl->Set(new \V8\StringValue($isolate, 'e'), $func_tpl);
5656
$global_tpl->Set(new \V8\StringValue($isolate, 'print'), $v8_helper->getPrintFunctionTemplate($isolate));
5757
$global_tpl->Set(new \V8\StringValue($isolate, 'test'), $func_test_tpl);
5858

59-
$context = new \V8\Context($isolate, [], $global_tpl);
59+
$context = new \V8\Context($isolate, $global_tpl);
6060

6161
$v8_helper->CompileTryRun($context, 'test()');
6262
$v8_helper->CompileTryRun($context, 'e()');

tests/V8Exception_TypeError.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ $global_tpl->Set(new \V8\StringValue($isolate, 'e'), $func_tpl);
5656
$global_tpl->Set(new \V8\StringValue($isolate, 'print'), $v8_helper->getPrintFunctionTemplate($isolate));
5757
$global_tpl->Set(new \V8\StringValue($isolate, 'test'), $func_test_tpl);
5858

59-
$context = new \V8\Context($isolate, [], $global_tpl);
59+
$context = new \V8\Context($isolate, $global_tpl);
6060

6161
$v8_helper->CompileTryRun($context, 'test()');
6262
$v8_helper->CompileTryRun($context, 'e()');

0 commit comments

Comments
 (0)