Index: src/js/proxy.js |
diff --git a/src/js/proxy.js b/src/js/proxy.js |
index fc38680a13a8daae96d7df99e3acf839ecb35232..36ade373941acff9bc280bbd51ec8ce567c99a3b 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,14 +23,18 @@ 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(this, target, handler) |
} |
function ProxyCreateFunction(handler, callTrap, constructTrap) { |
@@ -182,16 +186,15 @@ function ProxyEnumerate(proxy) { |
} |
//------------------------------------------------------------------- |
+%SetCode(GlobalProxy, ProxyCreate); |
+%FunctionSetPrototype(GlobalProxy, new GlobalObject()); |
neis
2015/11/12 23:22:51
"Proxy" shouldn't have a "prototype" property.
|
-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. |
rossberg
2015/11/12 17:04:39
Nit: weird comment delimiter?
|
+utils.InstallFunctions(GlobalProxy, DONT_ENUM, [ |
"createFunction", ProxyCreateFunction |
rossberg
2015/11/12 17:04:39
Shouldn't this go away as well?
Camillo Bruni
2015/11/12 20:20:55
yes, I'll leave this as an exercise for the intere
|
-]) |
+]); |
+%AddNamedProperty(GlobalProxy.prototype, "constructor", GlobalProxy, DONT_ENUM); |
neis
2015/11/12 23:22:51
See above.
|
// ------------------------------------------------------------------- |
// Exports |