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

Side by Side Diff: src/v8natives.js

Issue 1368753003: Add C++ implementation of Object.defineProperties (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: preview -- needs refactoring Created 5 years, 2 months 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/runtime/runtime-object.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 %CheckIsBootstrapping(); 7 %CheckIsBootstrapping();
8 8
9 // ---------------------------------------------------------------------------- 9 // ----------------------------------------------------------------------------
10 // Imports 10 // Imports
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 if (desc.enumerable) names.push(symbol); 1082 if (desc.enumerable) names.push(symbol);
1083 } 1083 }
1084 } 1084 }
1085 1085
1086 return names; 1086 return names;
1087 } 1087 }
1088 1088
1089 1089
1090 // ES5 section 15.2.3.7. 1090 // ES5 section 15.2.3.7.
1091 function ObjectDefineProperties(obj, properties) { 1091 function ObjectDefineProperties(obj, properties) {
1092 if (!IS_SPEC_OBJECT(obj)) { 1092 // The new pure-C++ implementation doesn't support Proxies yet, nor O.o.
1093 throw MakeTypeError(kCalledOnNonObject, "Object.defineProperties"); 1093 // TODO(jkummerow): Implement missing features and remove fallback path.
1094 if (%_IsJSProxy(obj) || %_IsJSProxy(properties) || %IsObserved(obj)) {
1095 if (!IS_SPEC_OBJECT(obj)) {
1096 throw MakeTypeError(kCalledOnNonObject, "Object.defineProperties");
1097 }
1098 var props = TO_OBJECT(properties);
1099 var names = GetOwnEnumerablePropertyNames(props);
1100 var descriptors = new InternalArray();
1101 for (var i = 0; i < names.length; i++) {
1102 descriptors.push(ToPropertyDescriptor(props[names[i]]));
1103 }
1104 for (var i = 0; i < names.length; i++) {
1105 DefineOwnProperty(obj, names[i], descriptors[i], true);
1106 }
1107 return obj;
1094 } 1108 }
1095 var props = TO_OBJECT(properties); 1109 return %ObjectDefineProperties(obj, properties);
1096 var names = GetOwnEnumerablePropertyNames(props);
1097 var descriptors = new InternalArray();
1098 for (var i = 0; i < names.length; i++) {
1099 descriptors.push(ToPropertyDescriptor(props[names[i]]));
1100 }
1101 for (var i = 0; i < names.length; i++) {
1102 DefineOwnProperty(obj, names[i], descriptors[i], true);
1103 }
1104 return obj;
1105 } 1110 }
1106 1111
1107 1112
1108 // Harmony proxies. 1113 // Harmony proxies.
1109 function ProxyFix(obj) { 1114 function ProxyFix(obj) {
1110 var handler = %GetHandler(obj); 1115 var handler = %GetHandler(obj);
1111 var props = CallTrap0(handler, "fix", UNDEFINED); 1116 var props = CallTrap0(handler, "fix", UNDEFINED);
1112 if (IS_UNDEFINED(props)) { 1117 if (IS_UNDEFINED(props)) {
1113 throw MakeTypeError(kProxyHandlerReturned, handler, "undefined", "fix"); 1118 throw MakeTypeError(kProxyHandlerReturned, handler, "undefined", "fix");
1114 } 1119 }
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 %InstallToContext([ 1848 %InstallToContext([
1844 "global_eval_fun", GlobalEval, 1849 "global_eval_fun", GlobalEval,
1845 "object_value_of", ObjectValueOf, 1850 "object_value_of", ObjectValueOf,
1846 "object_to_string", ObjectToString, 1851 "object_to_string", ObjectToString,
1847 "object_define_own_property", DefineOwnPropertyFromAPI, 1852 "object_define_own_property", DefineOwnPropertyFromAPI,
1848 "object_get_own_property_descriptor", ObjectGetOwnPropertyDescriptor, 1853 "object_get_own_property_descriptor", ObjectGetOwnPropertyDescriptor,
1849 "to_complete_property_descriptor", ToCompletePropertyDescriptor, 1854 "to_complete_property_descriptor", ToCompletePropertyDescriptor,
1850 ]); 1855 ]);
1851 1856
1852 }) 1857 })
OLDNEW
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698