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

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

Issue 1491893002: [proxies] Implement the Proxy constructor in C++ fully. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@BuiltinsExtraArguments
Patch Set: Address feedback. 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 | « src/builtins.cc ('k') | src/runtime/runtime.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
11 // ---------------------------------------------------------------------------- 11 // ----------------------------------------------------------------------------
12 // Imports 12 // Imports
13 // 13 //
14 var GlobalProxy = global.Proxy; 14 var GlobalProxy = global.Proxy;
15 var GlobalFunction = global.Function; 15 var GlobalFunction = global.Function;
16 var GlobalObject = global.Object; 16 var GlobalObject = global.Object;
17 var MakeTypeError; 17 var MakeTypeError;
18 var ToNameArray;
19 18
20 utils.Import(function(from) { 19 utils.Import(function(from) {
21 MakeTypeError = from.MakeTypeError; 20 MakeTypeError = from.MakeTypeError;
22 ToNameArray = from.ToNameArray;
23 }); 21 });
24 22
25 //---------------------------------------------------------------------------- 23 //----------------------------------------------------------------------------
26 24
27 function ProxyCreate(target, handler) {
28 if (IS_UNDEFINED(new.target)) {
29 throw MakeTypeError(kConstructorNotFunction, "Proxy");
30 }
31 return %CreateJSProxy(target, handler);
32 }
33
34 function ProxyCreateFunction(handler, callTrap, constructTrap) { 25 function ProxyCreateFunction(handler, callTrap, constructTrap) {
35 if (!IS_SPEC_OBJECT(handler)) 26 if (!IS_SPEC_OBJECT(handler))
36 throw MakeTypeError(kProxyHandlerNonObject, "createFunction") 27 throw MakeTypeError(kProxyHandlerNonObject, "createFunction")
37 if (!IS_CALLABLE(callTrap)) 28 if (!IS_CALLABLE(callTrap))
38 throw MakeTypeError(kProxyTrapFunctionExpected, "call") 29 throw MakeTypeError(kProxyTrapFunctionExpected, "call")
39 if (IS_UNDEFINED(constructTrap)) { 30 if (IS_UNDEFINED(constructTrap)) {
40 constructTrap = DerivedConstructTrap(callTrap) 31 constructTrap = DerivedConstructTrap(callTrap)
41 } else if (IS_CALLABLE(constructTrap)) { 32 } else if (IS_CALLABLE(constructTrap)) {
42 // Make sure the trap receives 'undefined' as this. 33 // Make sure the trap receives 'undefined' as this.
43 var construct = constructTrap 34 var construct = constructTrap
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 if (!IS_STRING(key)) { 134 if (!IS_STRING(key)) {
144 throw MakeTypeError(kProxyHandlerReturned, handler, "non-String", 135 throw MakeTypeError(kProxyHandlerReturned, handler, "non-String",
145 "enumerate-iterator"); 136 "enumerate-iterator");
146 } 137 }
147 result.push(key); 138 result.push(key);
148 } 139 }
149 return result; 140 return result;
150 } 141 }
151 142
152 //------------------------------------------------------------------- 143 //-------------------------------------------------------------------
153 %SetCode(GlobalProxy, ProxyCreate);
154 144
155 //Set up non-enumerable properties of the Proxy object. 145 //Set up non-enumerable properties of the Proxy object.
156 utils.InstallFunctions(GlobalProxy, DONT_ENUM, [ 146 utils.InstallFunctions(GlobalProxy, DONT_ENUM, [
157 "createFunction", ProxyCreateFunction 147 "createFunction", ProxyCreateFunction
158 ]); 148 ]);
159 149
160 // ------------------------------------------------------------------- 150 // -------------------------------------------------------------------
161 // Exports 151 // Exports
162 152
163 utils.Export(function(to) { 153 utils.Export(function(to) {
164 to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct; 154 to.ProxyDelegateCallAndConstruct = DelegateCallAndConstruct;
165 to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap; 155 to.ProxyDerivedHasOwnTrap = DerivedHasOwnTrap;
166 }); 156 });
167 157
168 %InstallToContext([ 158 %InstallToContext([
169 "proxy_enumerate", ProxyEnumerate, 159 "proxy_enumerate", ProxyEnumerate,
170 ]); 160 ]);
171 161
172 }) 162 })
OLDNEW
« no previous file with comments | « src/builtins.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698