[api] consistently expose all well-known symbols.
R=jochen@chromium.org Review-Url: https://codereview.chromium.org/2812603002 Cr-Commit-Position: refs/heads/master@{#44643}
This commit is contained in:
parent
a011e2b83f
commit
c80c0f11f4
@ -2793,11 +2793,16 @@ class V8_EXPORT Symbol : public Name {
|
||||
static Local<Symbol> ForApi(Isolate *isolate, Local<String> name);
|
||||
|
||||
// Well-known symbols
|
||||
static Local<Symbol> GetHasInstance(Isolate* isolate);
|
||||
static Local<Symbol> GetIsConcatSpreadable(Isolate* isolate);
|
||||
static Local<Symbol> GetIterator(Isolate* isolate);
|
||||
static Local<Symbol> GetUnscopables(Isolate* isolate);
|
||||
static Local<Symbol> GetMatch(Isolate* isolate);
|
||||
static Local<Symbol> GetReplace(Isolate* isolate);
|
||||
static Local<Symbol> GetSearch(Isolate* isolate);
|
||||
static Local<Symbol> GetSplit(Isolate* isolate);
|
||||
static Local<Symbol> GetToPrimitive(Isolate* isolate);
|
||||
static Local<Symbol> GetToStringTag(Isolate* isolate);
|
||||
static Local<Symbol> GetIsConcatSpreadable(Isolate* isolate);
|
||||
static Local<Symbol> GetUnscopables(Isolate* isolate);
|
||||
|
||||
V8_INLINE static Symbol* Cast(Value* obj);
|
||||
|
||||
|
44
src/api.cc
44
src/api.cc
@ -8026,34 +8026,28 @@ Local<Symbol> v8::Symbol::ForApi(Isolate* isolate, Local<String> name) {
|
||||
i_isolate->SymbolFor(i::Heap::kApiSymbolTableRootIndex, i_name, false));
|
||||
}
|
||||
|
||||
#define WELL_KNOWN_SYMBOLS(V) \
|
||||
V(HasInstance, has_instance) \
|
||||
V(IsConcatSpreadable, is_concat_spreadable) \
|
||||
V(Iterator, iterator) \
|
||||
V(Match, match) \
|
||||
V(Replace, replace) \
|
||||
V(Search, search) \
|
||||
V(Split, split) \
|
||||
V(ToPrimitive, to_primitive) \
|
||||
V(ToStringTag, to_string_tag) \
|
||||
V(Unscopables, unscopables)
|
||||
|
||||
Local<Symbol> v8::Symbol::GetIterator(Isolate* isolate) {
|
||||
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
|
||||
return Utils::ToLocal(i_isolate->factory()->iterator_symbol());
|
||||
}
|
||||
#define SYMBOL_GETTER(Name, name) \
|
||||
Local<Symbol> v8::Symbol::Get##Name(Isolate* isolate) { \
|
||||
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); \
|
||||
return Utils::ToLocal(i_isolate->factory()->name##_symbol()); \
|
||||
}
|
||||
|
||||
WELL_KNOWN_SYMBOLS(SYMBOL_GETTER)
|
||||
|
||||
Local<Symbol> v8::Symbol::GetUnscopables(Isolate* isolate) {
|
||||
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
|
||||
return Utils::ToLocal(i_isolate->factory()->unscopables_symbol());
|
||||
}
|
||||
|
||||
Local<Symbol> v8::Symbol::GetToPrimitive(Isolate* isolate) {
|
||||
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
|
||||
return Utils::ToLocal(i_isolate->factory()->to_primitive_symbol());
|
||||
}
|
||||
|
||||
Local<Symbol> v8::Symbol::GetToStringTag(Isolate* isolate) {
|
||||
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
|
||||
return Utils::ToLocal(i_isolate->factory()->to_string_tag_symbol());
|
||||
}
|
||||
|
||||
|
||||
Local<Symbol> v8::Symbol::GetIsConcatSpreadable(Isolate* isolate) {
|
||||
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
|
||||
return Utils::ToLocal(i_isolate->factory()->is_concat_spreadable_symbol());
|
||||
}
|
||||
|
||||
#undef SYMBOL_GETTER
|
||||
#undef WELL_KNOWN_SYMBOLS
|
||||
|
||||
Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) {
|
||||
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
|
||||
|
@ -3357,6 +3357,15 @@ static void CheckWellKnownSymbol(v8::Local<v8::Symbol>(*getter)(v8::Isolate*),
|
||||
THREADED_TEST(WellKnownSymbols) {
|
||||
CheckWellKnownSymbol(v8::Symbol::GetIterator, "Symbol.iterator");
|
||||
CheckWellKnownSymbol(v8::Symbol::GetUnscopables, "Symbol.unscopables");
|
||||
CheckWellKnownSymbol(v8::Symbol::GetHasInstance, "Symbol.hasInstance");
|
||||
CheckWellKnownSymbol(v8::Symbol::GetIsConcatSpreadable,
|
||||
"Symbol.isConcatSpreadable");
|
||||
CheckWellKnownSymbol(v8::Symbol::GetMatch, "Symbol.match");
|
||||
CheckWellKnownSymbol(v8::Symbol::GetReplace, "Symbol.replace");
|
||||
CheckWellKnownSymbol(v8::Symbol::GetSearch, "Symbol.search");
|
||||
CheckWellKnownSymbol(v8::Symbol::GetSplit, "Symbol.split");
|
||||
CheckWellKnownSymbol(v8::Symbol::GetToPrimitive, "Symbol.toPrimitive");
|
||||
CheckWellKnownSymbol(v8::Symbol::GetToStringTag, "Symbol.toStringTag");
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user