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 6209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6220 | 6220 |
6221 | 6221 |
6222 Local<Symbol> v8::Symbol::ForApi(Isolate* isolate, Local<String> name) { | 6222 Local<Symbol> v8::Symbol::ForApi(Isolate* isolate, Local<String> name) { |
6223 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6223 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6224 i::Handle<i::String> i_name = Utils::OpenHandle(*name); | 6224 i::Handle<i::String> i_name = Utils::OpenHandle(*name); |
6225 i::Handle<i::String> part = i_isolate->factory()->for_api_string(); | 6225 i::Handle<i::String> part = i_isolate->factory()->for_api_string(); |
6226 return Utils::ToLocal(SymbolFor(i_isolate, i_name, part)); | 6226 return Utils::ToLocal(SymbolFor(i_isolate, i_name, part)); |
6227 } | 6227 } |
6228 | 6228 |
6229 | 6229 |
6230 static Local<Symbol> GetWellKnownSymbol(Isolate* isolate, const char* name) { | |
6231 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | |
6232 i::Handle<i::String> i_name = | |
6233 Utils::OpenHandle(*String::NewFromUtf8(isolate, name)); | |
6234 i::Handle<i::String> part = i_isolate->factory()->for_intern_string(); | |
6235 return Utils::ToLocal(SymbolFor(i_isolate, i_name, part)); | |
6236 } | |
6237 | |
6238 | |
6239 Local<Symbol> v8::Symbol::GetIterator(Isolate* isolate) { | 6230 Local<Symbol> v8::Symbol::GetIterator(Isolate* isolate) { |
6240 return GetWellKnownSymbol(isolate, "Symbol.iterator"); | 6231 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6232 return Utils::ToLocal(i_isolate->factory()->iterator_symbol()); |
6241 } | 6233 } |
6242 | 6234 |
6243 | 6235 |
6244 Local<Symbol> v8::Symbol::GetUnscopables(Isolate* isolate) { | 6236 Local<Symbol> v8::Symbol::GetUnscopables(Isolate* isolate) { |
6245 return GetWellKnownSymbol(isolate, "Symbol.unscopables"); | 6237 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6238 return Utils::ToLocal(i_isolate->factory()->unscopables_symbol()); |
6246 } | 6239 } |
6247 | 6240 |
6248 | 6241 |
6249 Local<Symbol> v8::Symbol::GetToStringTag(Isolate* isolate) { | 6242 Local<Symbol> v8::Symbol::GetToStringTag(Isolate* isolate) { |
6250 return GetWellKnownSymbol(isolate, "Symbol.toStringTag"); | 6243 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| 6244 return Utils::ToLocal(i_isolate->factory()->to_string_tag_symbol()); |
6251 } | 6245 } |
6252 | 6246 |
6253 | 6247 |
6254 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { | 6248 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { |
6255 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 6249 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
6256 LOG_API(i_isolate, "Private::New()"); | 6250 LOG_API(i_isolate, "Private::New()"); |
6257 ENTER_V8(i_isolate); | 6251 ENTER_V8(i_isolate); |
6258 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); | 6252 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); |
6259 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); | 6253 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name)); |
6260 Local<Symbol> result = Utils::ToLocal(symbol); | 6254 Local<Symbol> result = Utils::ToLocal(symbol); |
(...skipping 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7776 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7770 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7777 Address callback_address = | 7771 Address callback_address = |
7778 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7772 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7779 VMState<EXTERNAL> state(isolate); | 7773 VMState<EXTERNAL> state(isolate); |
7780 ExternalCallbackScope call_scope(isolate, callback_address); | 7774 ExternalCallbackScope call_scope(isolate, callback_address); |
7781 callback(info); | 7775 callback(info); |
7782 } | 7776 } |
7783 | 7777 |
7784 | 7778 |
7785 } } // namespace v8::internal | 7779 } } // namespace v8::internal |
OLD | NEW |