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 3582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3593 DefineObjectProperty(self, key_obj, value_obj, | 3593 DefineObjectProperty(self, key_obj, value_obj, |
3594 static_cast<i::PropertyAttributes>(attribs)) | 3594 static_cast<i::PropertyAttributes>(attribs)) |
3595 .is_null(); | 3595 .is_null(); |
3596 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); | 3596 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); |
3597 return true; | 3597 return true; |
3598 } | 3598 } |
3599 | 3599 |
3600 | 3600 |
3601 Maybe<bool> v8::Object::SetPrivate(Local<Context> context, Local<Private> key, | 3601 Maybe<bool> v8::Object::SetPrivate(Local<Context> context, Local<Private> key, |
3602 Local<Value> value) { | 3602 Local<Value> value) { |
3603 return DefineOwnProperty(context, Local<Name>(reinterpret_cast<Name*>(*key)), | 3603 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetPrivate()", bool); |
3604 value, DontEnum); | 3604 auto self = Utils::OpenHandle(this); |
| 3605 auto key_obj = Utils::OpenHandle(reinterpret_cast<Name*>(*key)); |
| 3606 auto value_obj = Utils::OpenHandle(*value); |
| 3607 if (self->IsJSProxy()) { |
| 3608 i::PropertyDescriptor desc; |
| 3609 desc.set_writable(true); |
| 3610 desc.set_enumerable(false); |
| 3611 desc.set_configurable(true); |
| 3612 desc.set_value(value_obj); |
| 3613 return i::JSProxy::SetPrivateProperty( |
| 3614 isolate, i::Handle<i::JSProxy>::cast(self), |
| 3615 i::Handle<i::Symbol>::cast(key_obj), &desc, i::Object::DONT_THROW); |
| 3616 } |
| 3617 auto js_object = i::Handle<i::JSObject>::cast(self); |
| 3618 i::LookupIterator it(js_object, key_obj); |
| 3619 has_pending_exception = i::JSObject::DefineOwnPropertyIgnoreAttributes( |
| 3620 &it, value_obj, i::DONT_ENUM) |
| 3621 .is_null(); |
| 3622 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); |
| 3623 return Just(true); |
3605 } | 3624 } |
3606 | 3625 |
3607 | 3626 |
3608 MaybeLocal<Value> v8::Object::Get(Local<v8::Context> context, | 3627 MaybeLocal<Value> v8::Object::Get(Local<v8::Context> context, |
3609 Local<Value> key) { | 3628 Local<Value> key) { |
3610 PREPARE_FOR_EXECUTION(context, "v8::Object::Get()", Value); | 3629 PREPARE_FOR_EXECUTION(context, "v8::Object::Get()", Value); |
3611 auto self = Utils::OpenHandle(this); | 3630 auto self = Utils::OpenHandle(this); |
3612 auto key_obj = Utils::OpenHandle(*key); | 3631 auto key_obj = Utils::OpenHandle(*key); |
3613 i::Handle<i::Object> result; | 3632 i::Handle<i::Object> result; |
3614 has_pending_exception = | 3633 has_pending_exception = |
(...skipping 4939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8554 Address callback_address = | 8573 Address callback_address = |
8555 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8574 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8556 VMState<EXTERNAL> state(isolate); | 8575 VMState<EXTERNAL> state(isolate); |
8557 ExternalCallbackScope call_scope(isolate, callback_address); | 8576 ExternalCallbackScope call_scope(isolate, callback_address); |
8558 callback(info); | 8577 callback(info); |
8559 } | 8578 } |
8560 | 8579 |
8561 | 8580 |
8562 } // namespace internal | 8581 } // namespace internal |
8563 } // namespace v8 | 8582 } // namespace v8 |
OLD | NEW |