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

Unified Diff: src/js/proxy.js

Issue 1417063011: [runtime] support new Proxy() instead of Proxy.create and install getPrototypeOf trap (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: adding proxy trap strings Created 5 years, 1 month 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/js/messages.js ('k') | src/messages.h » ('j') | src/messages.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/proxy.js
diff --git a/src/js/proxy.js b/src/js/proxy.js
index fc38680a13a8daae96d7df99e3acf839ecb35232..c3358246151a552c7d2481ebc064a7ceebbf797d 100644
--- a/src/js/proxy.js
+++ b/src/js/proxy.js
@@ -10,7 +10,7 @@
// ----------------------------------------------------------------------------
// Imports
-
+var GlobalProxy = global.Proxy;
var GlobalFunction = global.Function;
var GlobalObject = global.Object;
var MakeTypeError;
@@ -23,19 +23,23 @@ utils.Import(function(from) {
//----------------------------------------------------------------------------
-function ProxyCreate(handler, proto) {
- if (!IS_SPEC_OBJECT(handler))
- throw MakeTypeError(kProxyHandlerNonObject, "create")
- if (IS_UNDEFINED(proto))
- proto = null
- else if (!(IS_SPEC_OBJECT(proto) || IS_NULL(proto)))
- throw MakeTypeError(kProxyProtoNonObject)
- return %CreateJSProxy(handler, proto)
+function ProxyCreate(target, handler) {
+ if (!%_IsConstructCall()) {
+ throw MakeTypeError(kConstructorNotFunction, "Proxy");
+ } else if (!IS_SPEC_OBJECT(target)) {
+ throw MakeTypeError(kProxyTargetNonObject, "create")
+ }
+ if (IS_UNDEFINED(handler)) {
+ handler = null
+ } else if (!(IS_SPEC_OBJECT(handler) || IS_NULL(handler))) {
+ throw MakeTypeError(kProxyHandlerNonObject)
+ }
+ return %CreateJSProxy(target, handler)
}
function ProxyCreateFunction(handler, callTrap, constructTrap) {
if (!IS_SPEC_OBJECT(handler))
- throw MakeTypeError(kProxyHandlerNonObject, "createFunction")
+ throw MakeTypeError(kProxyTargetNonObject, "createFunction")
Jakob Kummerow 2015/11/12 12:04:24 This is surprising
Camillo Bruni 2015/11/12 20:20:55 blind rename :), reverting.
if (!IS_CALLABLE(callTrap))
throw MakeTypeError(kProxyTrapFunctionExpected, "call")
if (IS_UNDEFINED(constructTrap)) {
@@ -182,16 +186,15 @@ function ProxyEnumerate(proxy) {
}
//-------------------------------------------------------------------
+%SetCode(GlobalProxy, ProxyCreate);
+%FunctionSetPrototype(GlobalProxy, new GlobalObject());
-var Proxy = new GlobalObject();
-%AddNamedProperty(global, "Proxy", Proxy, DONT_ENUM);
-
-//Set up non-enumerable properties of the Proxy object.
-utils.InstallFunctions(Proxy, DONT_ENUM, [
- "create", ProxyCreate,
+// //Set up non-enumerable properties of the Proxy object.
+utils.InstallFunctions(GlobalProxy, DONT_ENUM, [
"createFunction", ProxyCreateFunction
-])
+]);
+%AddNamedProperty(GlobalProxy.prototype, "constructor", GlobalProxy, DONT_ENUM);
// -------------------------------------------------------------------
// Exports
« no previous file with comments | « src/js/messages.js ('k') | src/messages.h » ('j') | src/messages.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698