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 7910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7921 } | 7921 } |
7922 | 7922 |
7923 | 7923 |
7924 Local<Symbol> v8::Symbol::ForApi(Isolate* isolate, Local<String> name) { | 7924 Local<Symbol> v8::Symbol::ForApi(Isolate* isolate, Local<String> name) { |
7925 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7925 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
7926 i::Handle<i::String> i_name = Utils::OpenHandle(*name); | 7926 i::Handle<i::String> i_name = Utils::OpenHandle(*name); |
7927 return Utils::ToLocal( | 7927 return Utils::ToLocal( |
7928 i_isolate->SymbolFor(i::Heap::kApiSymbolTableRootIndex, i_name, false)); | 7928 i_isolate->SymbolFor(i::Heap::kApiSymbolTableRootIndex, i_name, false)); |
7929 } | 7929 } |
7930 | 7930 |
| 7931 #define WELL_KNOWN_SYMBOLS(V) \ |
| 7932 V(HasInstance, has_instance) \ |
| 7933 V(IsConcatSpreadable, is_concat_spreadable) \ |
| 7934 V(Iterator, iterator) \ |
| 7935 V(Match, match) \ |
| 7936 V(Replace, replace) \ |
| 7937 V(Search, search) \ |
| 7938 V(Split, split) \ |
| 7939 V(ToPrimitive, to_primitive) \ |
| 7940 V(ToStringTag, to_string_tag) \ |
| 7941 V(Unscopables, unscopables) |
7931 | 7942 |
7932 Local<Symbol> v8::Symbol::GetIterator(Isolate* isolate) { | 7943 #define SYMBOL_GETTER(Name, name) \ |
7933 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7944 Local<Symbol> v8::Symbol::Get##Name(Isolate* isolate) { \ |
7934 return Utils::ToLocal(i_isolate->factory()->iterator_symbol()); | 7945 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); \ |
7935 } | 7946 return Utils::ToLocal(i_isolate->factory()->name##_symbol()); \ |
| 7947 } |
7936 | 7948 |
| 7949 WELL_KNOWN_SYMBOLS(SYMBOL_GETTER) |
7937 | 7950 |
7938 Local<Symbol> v8::Symbol::GetUnscopables(Isolate* isolate) { | 7951 #undef SYMBOL_GETTER |
7939 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7952 #undef WELL_KNOWN_SYMBOLS |
7940 return Utils::ToLocal(i_isolate->factory()->unscopables_symbol()); | |
7941 } | |
7942 | |
7943 Local<Symbol> v8::Symbol::GetToPrimitive(Isolate* isolate) { | |
7944 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | |
7945 return Utils::ToLocal(i_isolate->factory()->to_primitive_symbol()); | |
7946 } | |
7947 | |
7948 Local<Symbol> v8::Symbol::GetToStringTag(Isolate* isolate) { | |
7949 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | |
7950 return Utils::ToLocal(i_isolate->factory()->to_string_tag_symbol()); | |
7951 } | |
7952 | |
7953 | |
7954 Local<Symbol> v8::Symbol::GetIsConcatSpreadable(Isolate* isolate) { | |
7955 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | |
7956 return Utils::ToLocal(i_isolate->factory()->is_concat_spreadable_symbol()); | |
7957 } | |
7958 | |
7959 | 7953 |
7960 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { | 7954 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { |
7961 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 7955 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
7962 LOG_API(i_isolate, Private, New); | 7956 LOG_API(i_isolate, Private, New); |
7963 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); | 7957 ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); |
7964 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); | 7958 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); |
7965 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); | 7959 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); |
7966 Local<Symbol> result = Utils::ToLocal(symbol); | 7960 Local<Symbol> result = Utils::ToLocal(symbol); |
7967 return v8::Local<Private>(reinterpret_cast<Private*>(*result)); | 7961 return v8::Local<Private>(reinterpret_cast<Private*>(*result)); |
7968 } | 7962 } |
(...skipping 2347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10316 Address callback_address = | 10310 Address callback_address = |
10317 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10311 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
10318 VMState<EXTERNAL> state(isolate); | 10312 VMState<EXTERNAL> state(isolate); |
10319 ExternalCallbackScope call_scope(isolate, callback_address); | 10313 ExternalCallbackScope call_scope(isolate, callback_address); |
10320 callback(info); | 10314 callback(info); |
10321 } | 10315 } |
10322 | 10316 |
10323 | 10317 |
10324 } // namespace internal | 10318 } // namespace internal |
10325 } // namespace v8 | 10319 } // namespace v8 |
OLD | NEW |