Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d0c4a36

Browse files
committed
adapt V8 12.8 interceptor signatures
1 parent 888684b commit d0c4a36

File tree

7 files changed

+68
-52
lines changed

7 files changed

+68
-52
lines changed

‎v8js_array_access.cc

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static zval v8js_array_access_dispatch(zend_object *object, const char *method_n
5656

5757

5858

59-
void v8js_array_access_getter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) /* {{{ */
59+
v8::Intercepted v8js_array_access_getter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info) /* {{{ */
6060
{
6161
v8::Isolate *isolate = info.GetIsolate();
6262
v8::Local<v8::Object> self = info.Holder();
@@ -70,12 +70,17 @@ void v8js_array_access_getter(uint32_t index, const v8::PropertyCallbackInfo<v8:
7070
v8::Local<v8::Value> ret_value = zval_to_v8js(&php_value, isolate);
7171
zval_ptr_dtor(&php_value);
7272

73-
info.GetReturnValue().Set(ret_value);
73+
if (ret_value.IsEmpty()) {
74+
return v8::Intercepted::kNo;
75+
} else {
76+
info.GetReturnValue().Set(ret_value);
77+
return v8::Intercepted::kYes;
78+
}
7479
}
7580
/* }}} */
7681

77-
void v8js_array_access_setter(uint32_t index, v8::Local<v8::Value> value,
78-
const v8::PropertyCallbackInfo<v8::Value>& info) /* {{{ */
82+
v8::Intercepted v8js_array_access_setter(uint32_t index, v8::Local<v8::Value> value,
83+
const v8::PropertyCallbackInfo<void>& info) /* {{{ */
7984
{
8085
v8::Isolate *isolate = info.GetIsolate();
8186
v8::Local<v8::Object> self = info.Holder();
@@ -86,20 +91,16 @@ void v8js_array_access_setter(uint32_t index, v8::Local<v8::Value> value,
8691
ZVAL_UNDEF(&zvalue);
8792

8893
if (v8js_to_zval(value, &zvalue, 0, isolate) != SUCCESS) {
89-
info.GetReturnValue().Set(v8::Local<v8::Value>());
90-
return;
94+
return v8::Intercepted::kNo;
9195
}
9296

9397
zval php_value = v8js_array_access_dispatch(object, "offsetSet", 2, index, zvalue);
9498
zval_ptr_dtor(&php_value);
9599

96-
/* simply pass back the value to tell we intercepted the call
97-
* as the offsetSet function returns void. */
98-
info.GetReturnValue().Set(value);
99-
100100
/* if PHP wanted to hold on to this value, zend_call_function would
101101
* have bumped the refcount. */
102102
zval_ptr_dtor(&zvalue);
103+
return v8::Intercepted::kYes;
103104
}
104105
/* }}} */
105106

@@ -159,7 +160,7 @@ static void v8js_array_access_length(v8::Local<v8::String> property, const v8::P
159160
}
160161
/* }}} */
161162

162-
void v8js_array_access_deleter(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info) /* {{{ */
163+
v8::Intercepted v8js_array_access_deleter(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>& info) /* {{{ */
163164
{
164165
v8::Isolate *isolate = info.GetIsolate();
165166
v8::Local<v8::Object> self = info.Holder();
@@ -173,10 +174,11 @@ void v8js_array_access_deleter(uint32_t index, const v8::PropertyCallbackInfo<v8
173174
zval_ptr_dtor(&php_value);
174175

175176
info.GetReturnValue().Set(V8JS_BOOL(true));
177+
return v8::Intercepted::kYes;
176178
}
177179
/* }}} */
178180

179-
void v8js_array_access_query(uint32_t index, const v8::PropertyCallbackInfo<v8::Integer>& info) /* {{{ */
181+
v8::Intercepted v8js_array_access_query(uint32_t index, const v8::PropertyCallbackInfo<v8::Integer>& info) /* {{{ */
180182
{
181183
v8::Isolate *isolate = info.GetIsolate();
182184
v8::Local<v8::Object> self = info.Holder();
@@ -187,7 +189,10 @@ void v8js_array_access_query(uint32_t index, const v8::PropertyCallbackInfo<v8::
187189
* otherwise we're expected to return an empty handle. */
188190
if(v8js_array_access_isset_p(object, index)) {
189191
info.GetReturnValue().Set(V8JS_UINT(v8::PropertyAttribute::None));
192+
return v8::Intercepted::kYes;
190193
}
194+
195+
return v8::Intercepted::kNo;
191196
}
192197
/* }}} */
193198

@@ -217,7 +222,7 @@ void v8js_array_access_enumerator(const v8::PropertyCallbackInfo<v8::Array>& inf
217222

218223

219224

220-
void v8js_array_access_named_getter(v8::Local<v8::Name> property_name, const v8::PropertyCallbackInfo<v8::Value> &info) /* {{{ */
225+
v8::Intercepted v8js_array_access_named_getter(v8::Local<v8::Name> property_name, const v8::PropertyCallbackInfo<v8::Value> &info) /* {{{ */
221226
{
222227
v8::Local<v8::String> property = v8::Local<v8::String>::Cast(property_name);
223228
v8::Isolate *isolate = info.GetIsolate();
@@ -226,10 +231,10 @@ void v8js_array_access_named_getter(v8::Local<v8::Name> property_name, const v8:
226231

227232
if(strcmp(name, "length") == 0) {
228233
v8js_array_access_length(property, info);
229-
return;
234+
return v8::Intercepted::kYes;
230235
}
231236

232-
v8::Local<v8::Value> ret_value = v8js_named_property_callback(property, info, V8JS_PROP_GETTER);
237+
v8::Local<v8::Value> ret_value = v8js_named_property_callback(info.GetIsolate(), info.Holder(), property, V8JS_PROP_GETTER);
233238

234239
if(ret_value.IsEmpty()) {
235240
v8::Local<v8::Array> arr = v8::Array::New(isolate);
@@ -250,6 +255,7 @@ void v8js_array_access_named_getter(v8::Local<v8::Name> property_name, const v8:
250255
}
251256

252257
info.GetReturnValue().Set(ret_value);
258+
return v8::Intercepted::kYes;
253259
}
254260
/* }}} */
255261

‎v8js_array_access.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414
#define V8JS_ARRAY_ACCESS_H
1515

1616
/* Indexed Property Handlers */
17-
void v8js_array_access_getter(uint32_t index,
18-
const v8::PropertyCallbackInfo<v8::Value>& info);
19-
void v8js_array_access_setter(uint32_t index, v8::Local<v8::Value> value,
17+
v8::Intercepted v8js_array_access_getter(uint32_t index,
2018
const v8::PropertyCallbackInfo<v8::Value>& info);
19+
v8::Intercepted v8js_array_access_setter(uint32_t index, v8::Local<v8::Value> value,
20+
const v8::PropertyCallbackInfo<void>& info);
2121
void v8js_array_access_enumerator(const v8::PropertyCallbackInfo<v8::Array>& info);
22-
void v8js_array_access_deleter(uint32_t index,
22+
v8::Intercepted v8js_array_access_deleter(uint32_t index,
2323
const v8::PropertyCallbackInfo<v8::Boolean>& info);
24-
void v8js_array_access_query(uint32_t index,
24+
v8::Intercepted v8js_array_access_query(uint32_t index,
2525
const v8::PropertyCallbackInfo<v8::Integer>& info);
2626

2727
/* Named Property Handlers */
28-
void v8js_array_access_named_getter(v8::Local<v8::Name> property,
28+
v8::Intercepted v8js_array_access_named_getter(v8::Local<v8::Name> property,
2929
const v8::PropertyCallbackInfo<v8::Value> &info);
3030

3131
#endif /* V8JS_ARRAY_ACCESS_H */

‎v8js_class.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ static void v8js_compile_script(zval *this_ptr, const zend_string *str, const ze
524524
v8::Local<v8::String> sname = identifier
525525
? V8JS_ZSTR(identifier)
526526
: V8JS_SYM("V8Js::compileString()");
527-
v8::ScriptOrigin origin(isolate, sname);
527+
v8::ScriptOrigin origin(sname);
528528

529529
if (ZSTR_LEN(str) > std::numeric_limits<int>::max()) {
530530
zend_throw_exception(php_ce_v8js_exception,

‎v8js_methods.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ V8JS_METHOD(require)
502502

503503
// Set script identifier
504504
v8::Local<v8::String> sname = V8JS_STR(normalised_module_id);
505-
v8::ScriptOrigin origin(isolate, sname);
505+
v8::ScriptOrigin origin(sname);
506506

507507
if (Z_STRLEN(module_code) > std::numeric_limits<int>::max()) {
508508
zend_throw_exception(php_ce_v8js_exception,

‎v8js_object_export.cc

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -648,12 +648,10 @@ static void v8js_fake_call_impl(const v8::FunctionCallbackInfo<v8::Value>& info)
648648
/* }}} */
649649

650650
/* This method handles named property and method get/set/query/delete. */
651-
template<typename T>
652-
v8::Local<v8::Value> v8js_named_property_callback(v8::Local<v8::Name> property_name, const v8::PropertyCallbackInfo<T> &info, property_op_t callback_type, v8::Local<v8::Value> set_value) /* {{{ */
651+
v8::Local<v8::Value> v8js_named_property_callback(v8::Isolate *isolate, v8::Local<v8::Object> self, v8::Local<v8::Name> property_name, property_op_t callback_type, v8::Local<v8::Value> set_value) /* {{{ */
653652
{
654653
v8::Local<v8::String> property = v8::Local<v8::String>::Cast(property_name);
655654

656-
v8::Isolate *isolate = info.GetIsolate();
657655
v8::Local<v8::Context> v8_context = isolate->GetEnteredOrMicrotaskContext();
658656
v8js_ctx *ctx = (v8js_ctx *) isolate->GetData(0);
659657
v8::String::Utf8Value cstr(isolate, property);
@@ -662,7 +660,6 @@ v8::Local<v8::Value> v8js_named_property_callback(v8::Local<v8::Name> property_n
662660
char *lower = estrndup(name, name_len);
663661
zend_string *method_name;
664662

665-
v8::Local<v8::Object> self = info.Holder();
666663
v8::Local<v8::Value> ret_value;
667664
v8::Local<v8::Function> cb;
668665

@@ -860,44 +857,58 @@ v8::Local<v8::Value> v8js_named_property_callback(v8::Local<v8::Name> property_n
860857
}
861858
/* }}} */
862859

863-
static void v8js_named_property_getter(v8::Local<v8::Name> property, const v8::PropertyCallbackInfo<v8::Value> &info) /* {{{ */
860+
static v8::Intercepted v8js_named_property_getter(v8::Local<v8::Name> property, const v8::PropertyCallbackInfo<v8::Value> &info) /* {{{ */
864861
{
865-
info.GetReturnValue().Set(v8js_named_property_callback(property, info, V8JS_PROP_GETTER));
862+
v8::Local<v8::Value> r = v8js_named_property_callback(info.GetIsolate(), info.Holder(), property, V8JS_PROP_GETTER);
863+
864+
if (r.IsEmpty()) {
865+
return v8::Intercepted::kNo;
866+
} else {
867+
info.GetReturnValue().Set(r);
868+
return v8::Intercepted::kYes;
869+
}
866870
}
867871
/* }}} */
868872

869-
static void v8js_named_property_setter(v8::Local<v8::Name> property, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value> &info) /* {{{ */
873+
static v8::Intercepted v8js_named_property_setter(v8::Local<v8::Name> property, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void> &info) /* {{{ */
870874
{
871-
info.GetReturnValue().Set(v8js_named_property_callback(property, info, V8JS_PROP_SETTER, value));
875+
v8::Local<v8::Value> r = v8js_named_property_callback(info.GetIsolate(), info.Holder(), property, V8JS_PROP_SETTER, value);
876+
return r.IsEmpty() ? v8::Intercepted::kNo : v8::Intercepted::kYes;
872877
}
873878
/* }}} */
874879

875-
static void v8js_named_property_query(v8::Local<v8::Name> property, const v8::PropertyCallbackInfo<v8::Integer> &info) /* {{{ */
880+
static v8::Intercepted v8js_named_property_query(v8::Local<v8::Name> property, const v8::PropertyCallbackInfo<v8::Integer> &info) /* {{{ */
876881
{
877-
v8::Local<v8::Value> r = v8js_named_property_callback(property, info, V8JS_PROP_QUERY);
882+
v8::Local<v8::Value> r = v8js_named_property_callback(info.GetIsolate(), info.Holder(), property, V8JS_PROP_QUERY);
878883
if (r.IsEmpty()) {
879-
return;
884+
return v8::Intercepted::kNo;
880885
}
881886

882887
v8::Isolate *isolate = info.GetIsolate();
883888
v8::MaybeLocal<v8::Integer> value = r->ToInteger(isolate->GetEnteredOrMicrotaskContext());
884-
if (!value.IsEmpty()) {
889+
if (value.IsEmpty()) {
890+
return v8::Intercepted::kNo;
891+
} else {
885892
info.GetReturnValue().Set(value.ToLocalChecked());
893+
return v8::Intercepted::kYes;
886894
}
887895
}
888896
/* }}} */
889897

890-
static void v8js_named_property_deleter(v8::Local<v8::Name> property, const v8::PropertyCallbackInfo<v8::Boolean> &info) /* {{{ */
898+
static v8::Intercepted v8js_named_property_deleter(v8::Local<v8::Name> property, const v8::PropertyCallbackInfo<v8::Boolean> &info) /* {{{ */
891899
{
892-
v8::Local<v8::Value> r = v8js_named_property_callback(property, info, V8JS_PROP_DELETER);
900+
v8::Local<v8::Value> r = v8js_named_property_callback(info.GetIsolate(), info.Holder(), property, V8JS_PROP_DELETER);
893901
if (r.IsEmpty()) {
894-
return;
902+
return v8::Intercepted::kNo;
895903
}
896904

897905
v8::Isolate *isolate = info.GetIsolate();
898906
v8::Local<v8::Boolean> value = r->ToBoolean(isolate);
899-
if (!value.IsEmpty()) {
907+
if (value.IsEmpty()) {
908+
return v8::Intercepted::kNo;
909+
} else {
900910
info.GetReturnValue().Set(value);
911+
return v8::Intercepted::kYes;
901912
}
902913
}
903914
/* }}} */
@@ -940,7 +951,7 @@ static v8::MaybeLocal<v8::Object> v8js_wrap_object(v8::Isolate *isolate, zend_cl
940951
/* We'll free persist_tpl_ when template_cache is destroyed */
941952

942953
v8::Local<v8::ObjectTemplate> inst_tpl = new_tpl->InstanceTemplate();
943-
v8::GenericNamedPropertyGetterCallback getter = v8js_named_property_getter;
954+
v8::NamedPropertyGetterCallback getter = v8js_named_property_getter;
944955
v8::GenericNamedPropertyEnumeratorCallback enumerator = v8js_named_property_enumerator;
945956

946957
/* Check for ArrayAccess object */
@@ -958,11 +969,12 @@ static v8::MaybeLocal<v8::Object> v8js_wrap_object(v8::Isolate *isolate, zend_cl
958969
}
959970

960971
if(has_array_access && has_countable) {
961-
inst_tpl->SetIndexedPropertyHandler(v8js_array_access_getter,
962-
v8js_array_access_setter,
963-
v8js_array_access_query,
964-
v8js_array_access_deleter,
965-
v8js_array_access_enumerator);
972+
inst_tpl->SetHandler(
973+
v8::IndexedPropertyHandlerConfiguration(v8js_array_access_getter,
974+
v8js_array_access_setter,
975+
v8js_array_access_query,
976+
v8js_array_access_deleter,
977+
v8js_array_access_enumerator));
966978

967979
/* Switch to special ArrayAccess getter, which falls back to
968980
* v8js_named_property_getter, but possibly bridges the

‎v8js_object_export.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ typedef enum {
2525
V8JS_PROP_DELETER
2626
} property_op_t;
2727

28-
template<typename T>
29-
v8::Local<v8::Value> v8js_named_property_callback(v8::Local<v8::Name> property,
30-
const v8::PropertyCallbackInfo<T> &info,
31-
property_op_t callback_type,
32-
v8::Local<v8::Value> set_value = v8::Local<v8::Value>());
28+
v8::Local<v8::Value> v8js_named_property_callback(v8::Isolate *isolate, v8::Local<v8::Object> self,
29+
v8::Local<v8::Name> property, property_op_t callback_type,
30+
v8::Local<v8::Value> set_value = v8::Local<v8::Value>());
3331

3432
void v8js_php_callback(const v8::FunctionCallbackInfo<v8::Value>& info);
3533

‎v8js_variables.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern "C" {
2525
#include "zend_exceptions.h"
2626
}
2727

28-
static void v8js_fetch_php_variable(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) /* {{{ */
28+
static void v8js_fetch_php_variable(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) /* {{{ */
2929
{
3030
v8::Local<v8::External> data = v8::Local<v8::External>::Cast(info.Data());
3131
v8js_accessor_ctx *ctx = static_cast<v8js_accessor_ctx *>(data->Value());
@@ -80,7 +80,7 @@ void v8js_register_accessors(std::vector<v8js_accessor_ctx*> *accessor_list, v8:
8080
ctx->isolate = isolate;
8181

8282
/* Set the variable fetch callback for given symbol on named property */
83-
php_obj->SetAccessor(V8JS_STRL(ZSTR_VAL(property_name), static_cast<int>(ZSTR_LEN(property_name))), v8js_fetch_php_variable, NULL, v8::External::New(isolate, ctx));
83+
php_obj->SetNativeDataProperty(V8JS_STRL(ZSTR_VAL(property_name), static_cast<int>(ZSTR_LEN(property_name))), v8js_fetch_php_variable, NULL, v8::External::New(isolate, ctx), v8::PropertyAttribute::ReadOnly);
8484

8585
/* record the context so we can free it later */
8686
accessor_list->push_back(ctx);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /