Chromium Code Reviews| Index: src/proxy.js |
| =================================================================== |
| --- src/proxy.js (revision 7800) |
| +++ src/proxy.js (working copy) |
| @@ -26,3 +26,41 @@ |
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 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) { |
| + var type = typeof proto |
| + if (type != "object" && type != "function") proto = $Object.prototype |
|
Kevin Millikin (Chromium)
2011/05/13 08:08:30
You should write this as if (!IS_SPEC_OBJECT(proto
rossberg
2011/05/13 09:21:53
Done.
|
| + return %CreateJSProxy(handler, proto) |
| +} |