Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(386)

Unified Diff: src/api.cc

Issue 1157453002: Add basic API support for Map & Set (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/api.h ('k') | src/bootstrapper.cc » ('j') | src/bootstrapper.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 125a31be06f94b802e9f61a465335ee641b8c189..ca157bc41fc967cc8a37e5123ca4eba3db3f359a 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -3068,6 +3068,20 @@ void v8::Array::CheckCast(Value* that) {
}
+void v8::Map::CheckCast(Value* that) {
+ i::Handle<i::Object> obj = Utils::OpenHandle(that);
+ Utils::ApiCheck(obj->IsJSMap(), "v8::Map::Cast()",
+ "Could not convert to Map");
+}
+
+
+void v8::Set::CheckCast(Value* that) {
+ i::Handle<i::Object> obj = Utils::OpenHandle(that);
+ Utils::ApiCheck(obj->IsJSSet(), "v8::Set::Cast()",
+ "Could not convert to Set");
+}
+
+
void v8::Promise::CheckCast(Value* that) {
Utils::ApiCheck(that->IsPromise(),
"v8::Promise::Cast()",
@@ -6100,6 +6114,36 @@ Local<Object> Array::CloneElementAt(uint32_t index) {
}
+Local<v8::Map> v8::Map::New(Isolate* isolate) {
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ LOG_API(i_isolate, "Map::New");
+ ENTER_V8(i_isolate);
+ i::Handle<i::JSMap> obj = i_isolate->factory()->NewJSMap();
+ return Utils::ToLocal(obj);
+}
+
+
+size_t v8::Map::Size() const {
+ i::Handle<i::JSMap> obj = Utils::OpenHandle(this);
+ return i::OrderedHashMap::cast(obj->table())->NumberOfElements();
+}
+
+
+Local<v8::Set> v8::Set::New(Isolate* isolate) {
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ LOG_API(i_isolate, "Set::New");
+ ENTER_V8(i_isolate);
+ i::Handle<i::JSSet> obj = i_isolate->factory()->NewJSSet();
+ return Utils::ToLocal(obj);
+}
+
+
+size_t v8::Set::Size() const {
+ i::Handle<i::JSSet> obj = Utils::OpenHandle(this);
+ return i::OrderedHashSet::cast(obj->table())->NumberOfElements();
+}
+
+
bool Value::IsPromise() const {
auto self = Utils::OpenHandle(this);
return i::Object::IsPromise(self);
« no previous file with comments | « src/api.h ('k') | src/bootstrapper.cc » ('j') | src/bootstrapper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698