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) { |
| 1456 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1457 ENTER_V8(isolate); |
| 1458 i::HandleScope scope(isolate); |
| 1459 auto cons = EnsureConstructor(isolate, this); |
| 1460 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetAccessCheckCallback"); |
| 1461 |
| 1462 i::Handle<i::Struct> struct_info = |
| 1463 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); |
| 1464 i::Handle<i::AccessCheckInfo> info = |
| 1465 i::Handle<i::AccessCheckInfo>::cast(struct_info); |
| 1466 |
| 1467 SET_FIELD_WRAPPED(info, set_callback, callback); |
| 1468 SET_FIELD_WRAPPED(info, set_named_callback, nullptr); |
| 1469 SET_FIELD_WRAPPED(info, set_indexed_callback, nullptr); |
| 1470 |
| 1471 info->set_data(*isolate->factory()->undefined_value()); |
| 1472 |
| 1473 cons->set_access_check_info(*info); |
| 1474 cons->set_needs_access_check(true); |
| 1475 } |
| 1476 |
| 1477 |
1455 void ObjectTemplate::SetAccessCheckCallbacks( | 1478 void ObjectTemplate::SetAccessCheckCallbacks( |
1456 NamedSecurityCallback named_callback, | 1479 NamedSecurityCallback named_callback, |
1457 IndexedSecurityCallback indexed_callback, Local<Value> data) { | 1480 IndexedSecurityCallback indexed_callback, Local<Value> data) { |
1458 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1481 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
1459 ENTER_V8(isolate); | 1482 ENTER_V8(isolate); |
1460 i::HandleScope scope(isolate); | 1483 i::HandleScope scope(isolate); |
1461 auto cons = EnsureConstructor(isolate, this); | 1484 auto cons = EnsureConstructor(isolate, this); |
1462 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetAccessCheckCallbacks"); | 1485 EnsureNotInstantiated(cons, "v8::ObjectTemplate::SetAccessCheckCallbacks"); |
1463 | 1486 |
1464 i::Handle<i::Struct> struct_info = | 1487 i::Handle<i::Struct> struct_info = |
1465 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); | 1488 isolate->factory()->NewStruct(i::ACCESS_CHECK_INFO_TYPE); |
1466 i::Handle<i::AccessCheckInfo> info = | 1489 i::Handle<i::AccessCheckInfo> info = |
1467 i::Handle<i::AccessCheckInfo>::cast(struct_info); | 1490 i::Handle<i::AccessCheckInfo>::cast(struct_info); |
1468 | 1491 |
| 1492 SET_FIELD_WRAPPED(info, set_callback, nullptr); |
1469 SET_FIELD_WRAPPED(info, set_named_callback, named_callback); | 1493 SET_FIELD_WRAPPED(info, set_named_callback, named_callback); |
1470 SET_FIELD_WRAPPED(info, set_indexed_callback, indexed_callback); | 1494 SET_FIELD_WRAPPED(info, set_indexed_callback, indexed_callback); |
1471 | 1495 |
1472 if (data.IsEmpty()) { | 1496 if (data.IsEmpty()) { |
1473 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); | 1497 data = v8::Undefined(reinterpret_cast<v8::Isolate*>(isolate)); |
1474 } | 1498 } |
1475 info->set_data(*Utils::OpenHandle(*data)); | 1499 info->set_data(*Utils::OpenHandle(*data)); |
1476 | 1500 |
1477 cons->set_access_check_info(*info); | 1501 cons->set_access_check_info(*info); |
1478 cons->set_needs_access_check(true); | 1502 cons->set_needs_access_check(true); |
(...skipping 6908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8387 Address callback_address = | 8411 Address callback_address = |
8388 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8412 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8389 VMState<EXTERNAL> state(isolate); | 8413 VMState<EXTERNAL> state(isolate); |
8390 ExternalCallbackScope call_scope(isolate, callback_address); | 8414 ExternalCallbackScope call_scope(isolate, callback_address); |
8391 callback(info); | 8415 callback(info); |
8392 } | 8416 } |
8393 | 8417 |
8394 | 8418 |
8395 } // namespace internal | 8419 } // namespace internal |
8396 } // namespace v8 | 8420 } // namespace v8 |
OLD | NEW |