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

Unified Diff: src/api.cc

Issue 1542943002: [proxies] Expose proxies in the API (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2015-12-17_JSProxy_d8_printing_1530293004
Patch Set: adressing comments Created 5 years 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/builtins.cc » ('j') | no next file with comments »
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 e42cc0270d1e26a81a35bf26541efb549e5d6abc..93ea6a4c028be4b3a9d540be5ab8c9ad8ce018a2 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -2778,6 +2778,9 @@ bool Value::IsNumber() const {
}
+bool Value::IsProxy() const { return Utils::OpenHandle(this)->IsJSProxy(); }
+
+
#define VALUE_IS_SPECIFIC_TYPE(Type, Class) \
bool Value::Is##Type() const { \
i::Handle<i::Object> obj = Utils::OpenHandle(this); \
@@ -2883,6 +2886,12 @@ bool Value::IsSetIterator() const {
}
+bool Value::IsPromise() const {
+ auto self = Utils::OpenHandle(this);
+ return i::Object::IsPromise(self);
+}
+
+
MaybeLocal<String> Value::ToString(Local<Context> context) const {
auto obj = Utils::OpenHandle(this);
if (obj->IsString()) return ToApiHandle<String>(obj);
@@ -3146,6 +3155,12 @@ void v8::Promise::Resolver::CheckCast(Value* that) {
}
+void v8::Proxy::CheckCast(Value* that) {
+ Utils::ApiCheck(that->IsProxy(), "v8::Proxy::Cast()",
+ "Could not convert to proxy");
+}
+
+
void v8::ArrayBuffer::CheckCast(Value* that) {
i::Handle<i::Object> obj = Utils::OpenHandle(that);
Utils::ApiCheck(
@@ -6346,12 +6361,6 @@ Local<Array> Set::AsArray() const {
}
-bool Value::IsPromise() const {
- auto self = Utils::OpenHandle(this);
- return i::Object::IsPromise(self);
-}
-
-
MaybeLocal<Promise::Resolver> Promise::Resolver::New(Local<Context> context) {
PREPARE_FOR_EXECUTION(context, "Promise::Resolver::New", Resolver);
i::Handle<i::Object> result;
@@ -6498,6 +6507,44 @@ bool Promise::HasHandler() {
}
+Local<Object> Proxy::GetTarget() {
+ i::Handle<i::JSProxy> self = Utils::OpenHandle(this);
+ i::Handle<i::JSReceiver> target(self->target());
+ return Utils::ToLocal(target);
+}
+
+
+Local<Value> Proxy::GetHandler() {
+ i::Handle<i::JSProxy> self = Utils::OpenHandle(this);
+ i::Handle<i::Object> handler(self->handler(), self->GetIsolate());
+ return Utils::ToLocal(handler);
+}
+
+
+bool Proxy::IsRevoked() {
+ i::Handle<i::JSProxy> self = Utils::OpenHandle(this);
+ return self->IsRevoked();
+}
+
+
+void Proxy::Revoke() {
+ i::Handle<i::JSProxy> self = Utils::OpenHandle(this);
+ i::JSProxy::Revoke(self);
+}
+
+
+MaybeLocal<Proxy> Proxy::New(Local<Context> context, Local<Object> local_target,
+ Local<Object> local_handler) {
+ PREPARE_FOR_EXECUTION(context, "Proxy::New", Proxy);
+ i::Handle<i::JSReceiver> target = Utils::OpenHandle(*local_target);
+ i::Handle<i::JSReceiver> handler = Utils::OpenHandle(*local_handler);
+ Local<Proxy> result;
+ has_pending_exception =
+ !ToLocal<Proxy>(i::JSProxy::New(isolate, target, handler), &result);
+ RETURN_ON_FAILED_EXECUTION(Proxy);
+ RETURN_ESCAPED(result);
+}
+
bool v8::ArrayBuffer::IsExternal() const {
return Utils::OpenHandle(this)->is_external();
}
« no previous file with comments | « src/api.h ('k') | src/builtins.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698