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

Side by Side Diff: src/js/proxy.js

Issue 1496243003: [proxies] Implement Proxy.revocable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 (function(global, utils) { 5 (function(global, utils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 24 matching lines...) Expand all
35 constructTrap = function() { 35 constructTrap = function() {
36 return %Apply(construct, UNDEFINED, arguments, 0, %_ArgumentsLength()); 36 return %Apply(construct, UNDEFINED, arguments, 0, %_ArgumentsLength());
37 } 37 }
38 } else { 38 } else {
39 throw MakeTypeError(kProxyTrapFunctionExpected, "construct") 39 throw MakeTypeError(kProxyTrapFunctionExpected, "construct")
40 } 40 }
41 return %CreateJSFunctionProxy( 41 return %CreateJSFunctionProxy(
42 {}, handler, callTrap, constructTrap, GlobalFunction.prototype) 42 {}, handler, callTrap, constructTrap, GlobalFunction.prototype)
43 } 43 }
44 44
45 function ProxyCreateRevocable(target, handler) {
46 var p = new GlobalProxy(target, handler);
47 return {proxy: p, revoke: () => %RevokeProxy(p)};
48 }
49
45 // ------------------------------------------------------------------- 50 // -------------------------------------------------------------------
46 // Proxy Builtins 51 // Proxy Builtins
47 52
48 function DerivedConstructTrap(callTrap) { 53 function DerivedConstructTrap(callTrap) {
49 return function() { 54 return function() {
50 var proto = this.prototype 55 var proto = this.prototype
51 if (!IS_SPEC_OBJECT(proto)) proto = GlobalObject.prototype 56 if (!IS_SPEC_OBJECT(proto)) proto = GlobalObject.prototype
52 var obj = { __proto__: proto }; 57 var obj = { __proto__: proto };
53 var result = %Apply(callTrap, obj, arguments, 0, %_ArgumentsLength()); 58 var result = %Apply(callTrap, obj, arguments, 0, %_ArgumentsLength());
54 return IS_SPEC_OBJECT(result) ? result : obj 59 return IS_SPEC_OBJECT(result) ? result : obj
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 142 }
138 result.push(key); 143 result.push(key);
139 } 144 }
140 return result; 145 return result;
141 } 146 }
142 147
143 //------------------------------------------------------------------- 148 //-------------------------------------------------------------------
144 149
145 //Set up non-enumerable properties of the Proxy object. 150 //Set up non-enumerable properties of the Proxy object.
146 utils.InstallFunctions(GlobalProxy, DONT_ENUM, [ 151 utils.InstallFunctions(GlobalProxy, DONT_ENUM, [
152 "revocable", ProxyCreateRevocable,
147 "createFunction", ProxyCreateFunction 153 "createFunction", ProxyCreateFunction
148 ]); 154 ]);
149 155
150 // ------------------------------------------------------------------- 156 // -------------------------------------------------------------------
151 // Exports 157 // Exports
152 158
153 utils.Export(function(to) { 159 utils.Export(function(to) {
154 to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct; 160 to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct;
155 to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap; 161 to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap;
156 }); 162 });
157 163
158 %InstallToContext([ 164 %InstallToContext([
159 "proxy_enumerate", ProxyEnumerate, 165 "proxy_enumerate", ProxyEnumerate,
160 ]); 166 ]);
161 167
162 }) 168 })
OLDNEW
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698