| Index: src/proxy.js
|
| diff --git a/src/proxy.js b/src/proxy.js
|
| index 28391595631e8877e39bae9fcefd62181b35433a..4e44cd4ef3d069709d4ad8855803e1765b40ce5e 100644
|
| --- a/src/proxy.js
|
| +++ b/src/proxy.js
|
| @@ -29,36 +29,6 @@ global.Proxy = new $Object();
|
|
|
| var $Proxy = global.Proxy
|
|
|
| -var fundamentalTraps = [
|
| - "getOwnPropertyDescriptor",
|
| - "getPropertyDescriptor",
|
| - "getOwnPropertyNames",
|
| - "getPropertyNames",
|
| - "defineProperty",
|
| - "delete",
|
| - "fix",
|
| -]
|
| -
|
| -var derivedTraps = [
|
| - "has",
|
| - "hasOwn",
|
| - "get",
|
| - "set",
|
| - "enumerate",
|
| - "keys",
|
| -]
|
| -
|
| -var functionTraps = [
|
| - "callTrap",
|
| - "constructTrap",
|
| -]
|
| -
|
| -$Proxy.createFunction = function(handler, callTrap, constructTrap) {
|
| - handler.callTrap = callTrap
|
| - handler.constructTrap = constructTrap
|
| - $Proxy.create(handler)
|
| -}
|
| -
|
| $Proxy.create = function(handler, proto) {
|
| if (!IS_SPEC_OBJECT(handler))
|
| throw MakeTypeError("handler_non_object", ["create"])
|
| @@ -66,6 +36,20 @@ $Proxy.create = function(handler, proto) {
|
| return %CreateJSProxy(handler, proto)
|
| }
|
|
|
| +$Proxy.createFunction = function(handler, callTrap, constructTrap) {
|
| + if (!IS_SPEC_OBJECT(handler))
|
| + throw MakeTypeError("handler_non_object", ["create"])
|
| + if (!IS_SPEC_FUNCTION(callTrap))
|
| + throw MakeTypeError("trap_function_expected", ["createFunction", "call"])
|
| + if (IS_UNDEFINED(constructTrap)) {
|
| + constructTrap = callTrap
|
| + } else if (!IS_SPEC_FUNCTION(constructTrap)) {
|
| + throw MakeTypeError("trap_function_expected",
|
| + ["createFunction", "construct"])
|
| + }
|
| + return %CreateJSFunctionProxy(
|
| + handler, callTrap, constructTrap, $Function.prototype)
|
| +}
|
|
|
|
|
|
|
| @@ -73,6 +57,13 @@ $Proxy.create = function(handler, proto) {
|
| // Builtins
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|
| +function DelegateCallAndConstruct(callTrap, constructTrap) {
|
| + return function() {
|
| + return %Apply(%_IsConstructCall() ? constructTrap : callTrap,
|
| + this, arguments, 0, %_ArgumentsLength())
|
| + }
|
| +}
|
| +
|
| function DerivedGetTrap(receiver, name) {
|
| var desc = this.getPropertyDescriptor(name)
|
| if (IS_UNDEFINED(desc)) { return desc }
|
|
|