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 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 DCHECK(!name.IsEmpty()); | 948 DCHECK(!name.IsEmpty()); |
949 DCHECK(!getter.IsEmpty() || !setter.IsEmpty()); | 949 DCHECK(!getter.IsEmpty() || !setter.IsEmpty()); |
950 i::HandleScope scope(isolate); | 950 i::HandleScope scope(isolate); |
951 i::ApiNatives::AddAccessorProperty( | 951 i::ApiNatives::AddAccessorProperty( |
952 isolate, templ, Utils::OpenHandle(*name), | 952 isolate, templ, Utils::OpenHandle(*name), |
953 Utils::OpenHandle(*getter, true), Utils::OpenHandle(*setter, true), | 953 Utils::OpenHandle(*getter, true), Utils::OpenHandle(*setter, true), |
954 static_cast<PropertyAttributes>(attribute)); | 954 static_cast<PropertyAttributes>(attribute)); |
955 } | 955 } |
956 | 956 |
957 | 957 |
| 958 #ifdef V8_JS_ACCESSORS |
| 959 void Template::SetAccessorProperty(v8::Local<v8::Name> name, |
| 960 v8::Local<Function> getter, |
| 961 v8::Local<Function> setter, |
| 962 v8::PropertyAttribute attribute) { |
| 963 auto templ = Utils::OpenHandle(this); |
| 964 auto isolate = templ->GetIsolate(); |
| 965 ENTER_V8(isolate); |
| 966 DCHECK(!name.IsEmpty()); |
| 967 DCHECK(!getter.IsEmpty() || !setter.IsEmpty()); |
| 968 i::HandleScope scope(isolate); |
| 969 i::ApiNatives::AddAccessorProperty( |
| 970 isolate, templ, Utils::OpenHandle(*name), |
| 971 Utils::OpenHandle(*getter, true), Utils::OpenHandle(*setter, true), |
| 972 static_cast<PropertyAttributes>(attribute)); |
| 973 } |
| 974 #endif // V8_JS_ACCESSORS |
| 975 |
| 976 |
958 // --- F u n c t i o n T e m p l a t e --- | 977 // --- F u n c t i o n T e m p l a t e --- |
959 static void InitializeFunctionTemplate( | 978 static void InitializeFunctionTemplate( |
960 i::Handle<i::FunctionTemplateInfo> info) { | 979 i::Handle<i::FunctionTemplateInfo> info) { |
961 InitializeTemplate(info, Consts::FUNCTION_TEMPLATE); | 980 InitializeTemplate(info, Consts::FUNCTION_TEMPLATE); |
962 info->set_flag(0); | 981 info->set_flag(0); |
963 } | 982 } |
964 | 983 |
965 | 984 |
966 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { | 985 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { |
967 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); | 986 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); |
(...skipping 7392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8360 Address callback_address = | 8379 Address callback_address = |
8361 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8380 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8362 VMState<EXTERNAL> state(isolate); | 8381 VMState<EXTERNAL> state(isolate); |
8363 ExternalCallbackScope call_scope(isolate, callback_address); | 8382 ExternalCallbackScope call_scope(isolate, callback_address); |
8364 callback(info); | 8383 callback(info); |
8365 } | 8384 } |
8366 | 8385 |
8367 | 8386 |
8368 } // namespace internal | 8387 } // namespace internal |
8369 } // namespace v8 | 8388 } // namespace v8 |
OLD | NEW |