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

Side by Side 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 unified diff | Download patch
OLDNEW
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 3050 matching lines...) Expand 10 before | Expand all | Expand 10 after
3061 3061
3062 3062
3063 void v8::Array::CheckCast(Value* that) { 3063 void v8::Array::CheckCast(Value* that) {
3064 i::Handle<i::Object> obj = Utils::OpenHandle(that); 3064 i::Handle<i::Object> obj = Utils::OpenHandle(that);
3065 Utils::ApiCheck(obj->IsJSArray(), 3065 Utils::ApiCheck(obj->IsJSArray(),
3066 "v8::Array::Cast()", 3066 "v8::Array::Cast()",
3067 "Could not convert to array"); 3067 "Could not convert to array");
3068 } 3068 }
3069 3069
3070 3070
3071 void v8::Map::CheckCast(Value* that) {
3072 i::Handle<i::Object> obj = Utils::OpenHandle(that);
3073 Utils::ApiCheck(obj->IsJSMap(), "v8::Map::Cast()",
3074 "Could not convert to Map");
3075 }
3076
3077
3078 void v8::Set::CheckCast(Value* that) {
3079 i::Handle<i::Object> obj = Utils::OpenHandle(that);
3080 Utils::ApiCheck(obj->IsJSSet(), "v8::Set::Cast()",
3081 "Could not convert to Set");
3082 }
3083
3084
3071 void v8::Promise::CheckCast(Value* that) { 3085 void v8::Promise::CheckCast(Value* that) {
3072 Utils::ApiCheck(that->IsPromise(), 3086 Utils::ApiCheck(that->IsPromise(),
3073 "v8::Promise::Cast()", 3087 "v8::Promise::Cast()",
3074 "Could not convert to promise"); 3088 "Could not convert to promise");
3075 } 3089 }
3076 3090
3077 3091
3078 void v8::Promise::Resolver::CheckCast(Value* that) { 3092 void v8::Promise::Resolver::CheckCast(Value* that) {
3079 Utils::ApiCheck(that->IsPromise(), 3093 Utils::ApiCheck(that->IsPromise(),
3080 "v8::Promise::Resolver::Cast()", 3094 "v8::Promise::Resolver::Cast()",
(...skipping 3012 matching lines...) Expand 10 before | Expand all | Expand 10 after
6093 RETURN_ESCAPED(result); 6107 RETURN_ESCAPED(result);
6094 } 6108 }
6095 6109
6096 6110
6097 Local<Object> Array::CloneElementAt(uint32_t index) { 6111 Local<Object> Array::CloneElementAt(uint32_t index) {
6098 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 6112 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
6099 RETURN_TO_LOCAL_UNCHECKED(CloneElementAt(context, index), Object); 6113 RETURN_TO_LOCAL_UNCHECKED(CloneElementAt(context, index), Object);
6100 } 6114 }
6101 6115
6102 6116
6117 Local<v8::Map> v8::Map::New(Isolate* isolate) {
6118 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6119 LOG_API(i_isolate, "Map::New");
6120 ENTER_V8(i_isolate);
6121 i::Handle<i::JSMap> obj = i_isolate->factory()->NewJSMap();
6122 return Utils::ToLocal(obj);
6123 }
6124
6125
6126 size_t v8::Map::Size() const {
6127 i::Handle<i::JSMap> obj = Utils::OpenHandle(this);
6128 return i::OrderedHashMap::cast(obj->table())->NumberOfElements();
6129 }
6130
6131
6132 Local<v8::Set> v8::Set::New(Isolate* isolate) {
6133 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6134 LOG_API(i_isolate, "Set::New");
6135 ENTER_V8(i_isolate);
6136 i::Handle<i::JSSet> obj = i_isolate->factory()->NewJSSet();
6137 return Utils::ToLocal(obj);
6138 }
6139
6140
6141 size_t v8::Set::Size() const {
6142 i::Handle<i::JSSet> obj = Utils::OpenHandle(this);
6143 return i::OrderedHashSet::cast(obj->table())->NumberOfElements();
6144 }
6145
6146
6103 bool Value::IsPromise() const { 6147 bool Value::IsPromise() const {
6104 auto self = Utils::OpenHandle(this); 6148 auto self = Utils::OpenHandle(this);
6105 return i::Object::IsPromise(self); 6149 return i::Object::IsPromise(self);
6106 } 6150 }
6107 6151
6108 6152
6109 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) { 6153 MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) {
6110 PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver); 6154 PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver);
6111 i::Handle<i::Object> result; 6155 i::Handle<i::Object> result;
6112 has_pending_exception = !i::Execution::Call( 6156 has_pending_exception = !i::Execution::Call(
(...skipping 1966 matching lines...) Expand 10 before | Expand all | Expand 10 after
8079 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8123 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
8080 Address callback_address = 8124 Address callback_address =
8081 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8125 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8082 VMState<EXTERNAL> state(isolate); 8126 VMState<EXTERNAL> state(isolate);
8083 ExternalCallbackScope call_scope(isolate, callback_address); 8127 ExternalCallbackScope call_scope(isolate, callback_address);
8084 callback(info); 8128 callback(info);
8085 } 8129 }
8086 8130
8087 8131
8088 } } // namespace v8::internal 8132 } } // namespace v8::internal
OLDNEW
« 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