OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1445 void ObjectTemplate::MarkAsUndetectable() { | 1445 void ObjectTemplate::MarkAsUndetectable() { |
1446 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1446 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1447 ENTER_V8(isolate); | 1447 ENTER_V8(isolate); |
1448 i::HandleScope scope(isolate); | 1448 i::HandleScope scope(isolate); |
1449 auto cons = EnsureConstructor(isolate, this); | 1449 auto cons = EnsureConstructor(isolate, this); |
1450 EnsureNotInstantiated(cons, "v8::ObjectTemplate::MarkAsUndetectable"); | 1450 EnsureNotInstantiated(cons, "v8::ObjectTemplate::MarkAsUndetectable"); |
1451 cons->set_undetectable(true); | 1451 cons->set_undetectable(true); |
1452 } | 1452 } |
1453 | 1453 |
1454 | 1454 |
1455 void ObjectTemplate::SetAccessCheckCallback(AccessCheckCallback callback) { | 1455 void ObjectTemplate::SetAccessCheckCallback(AccessCheckCallback callback, |
| 1456 Local<Value> data) { |
1456 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1457 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1457 ENTER_V8(isolate); | 1458 ENTER_V8(isolate); |
1458 i::HandleScope scope(isolate); | 1459 i::HandleScope scope(isolate); |
1459 auto cons = EnsureConstructor(isolate, this); | 1460 auto cons = EnsureConstructor(isolate, this); |
1460 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetAccessCheckCallback"); | 1461 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetAccessCheckCallback"); |
1461 | 1462 |
1462 i::Handle<i::Struct> struct_info = | 1463 i::Handle<i::Struct> struct_info = |
1463 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); | 1464 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); |
1464 i::Handle<i::AccessCheckInfo> info = | 1465 i::Handle<i::AccessCheckInfo> info = |
1465 i::Handle<i::AccessCheckInfo>::cast(struct_info); | 1466 i::Handle<i::AccessCheckInfo>::cast(struct_info); |
1466 | 1467 |
1467 SET_FIELD_WRAPPED(info, set_callback, callback); | 1468 SET_FIELD_WRAPPED(info, set_callback, callback); |
1468 SET_FIELD_WRAPPED(info, set_named_callback, nullptr); | 1469 SET_FIELD_WRAPPED(info, set_named_callback, nullptr); |
1469 SET_FIELD_WRAPPED(info, set_indexed_callback, nullptr); | 1470 SET_FIELD_WRAPPED(info, set_indexed_callback, nullptr); |
1470 | 1471 |
1471 info->set_data(*isolate->factory()->undefined_value()); | 1472 if (data.IsEmpty()) { |
| 1473 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
| 1474 } |
| 1475 info->set_data(*Utils::OpenHandle(*data)); |
1472 | 1476 |
1473 cons->set_access_check_info(*info); | 1477 cons->set_access_check_info(*info); |
1474 cons->set_needs_access_check(true); | 1478 cons->set_needs_access_check(true); |
1475 } | 1479 } |
1476 | 1480 |
1477 | 1481 |
1478 void ObjectTemplate::SetAccessCheckCallbacks( | 1482 void ObjectTemplate::SetAccessCheckCallbacks( |
1479 NamedSecurityCallback named_callback, | 1483 NamedSecurityCallback named_callback, |
1480 IndexedSecurityCallback indexed_callback, Local<Value> data) { | 1484 IndexedSecurityCallback indexed_callback, Local<Value> data) { |
1481 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1485 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
(...skipping 6967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8449 Address callback_address = | 8453 Address callback_address = |
8450 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8454 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8451 VMState<EXTERNAL> state(isolate); | 8455 VMState<EXTERNAL> state(isolate); |
8452 ExternalCallbackScope call_scope(isolate, callback_address); | 8456 ExternalCallbackScope call_scope(isolate, callback_address); |
8453 callback(info); | 8457 callback(info); |
8454 } | 8458 } |
8455 | 8459 |
8456 | 8460 |
8457 } // namespace internal | 8461 } // namespace internal |
8458 } // namespace v8 | 8462 } // namespace v8 |
OLD | NEW |