Changeset 48565 in webkit
- Timestamp:
- Sep 19, 2009 3:14:56 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r48563 r48565 22 22 (JSC::Heap::freeBlock): 23 23 * runtime/Collector.h: 24 25 2009-09-19 Oliver Hunt <oliver@apple.com> 26 27 Reviewed by Sam Weinig. 28 29 Implement ES5 Object.defineProperties function 30 https://bugs.webkit.org/show_bug.cgi?id=29522 31 32 Implement Object.defineProperties. Fairly simple patch, simply makes use of 33 existing functionality used for defineProperty. 34 35 * runtime/CommonIdentifiers.h: 36 * runtime/ObjectConstructor.cpp: 37 (JSC::ObjectConstructor::ObjectConstructor): 38 (JSC::defineProperties): 39 (JSC::objectConstructorDefineProperties): 24 40 25 41 2009-09-19 Oliver Hunt <oliver@apple.com> -
trunk/JavaScriptCore/runtime/CommonIdentifiers.h
r48542 r48565 41 41 macro(constructor) \ 42 42 macro(defineProperty) \ 43 macro(defineProperties) \ 43 44 macro(enumerable) \ 44 45 macro(eval) \ -
trunk/JavaScriptCore/runtime/ObjectConstructor.cpp
r48542 r48565 39 39 static JSValue JSC_HOST_CALL objectConstructorKeys(ExecState*, JSObject*, JSValue, const ArgList&); 40 40 static JSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState*, JSObject*, JSValue, const ArgList&); 41 static JSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState*, JSObject*, JSValue, const ArgList&); 41 42 42 43 ObjectConstructor::ObjectConstructor(ExecState* exec, PassRefPtr<Structure> structure, ObjectPrototype* objectPrototype, Structure* prototypeFunctionStructure) … … 52 53 putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().getOwnPropertyDescriptor, objectConstructorGetOwnPropertyDescriptor), DontEnum); 53 54 putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().keys, objectConstructorKeys), DontEnum); 54 putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 3, exec->propertyNames().defineProperty, objectConstructorDefineProperty), DontEnum); 55 putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 3, exec->propertyNames().defineProperty, objectConstructorDefineProperty), DontEnum); 56 putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().defineProperties, objectConstructorDefineProperties), DontEnum); 55 57 } 56 58 … … 238 240 } 239 241 242 static JSValue defineProperties(ExecState* exec, JSObject* object, JSObject* properties) 243 { 244 PropertyNameArray propertyNames(exec); 245 asObject(properties)->getOwnPropertyNames(exec, propertyNames); 246 size_t numProperties = propertyNames.size(); 247 Vector<PropertyDescriptor> descriptors; 248 MarkedArgumentBuffer markBuffer; 249 for (size_t i = 0; i < numProperties; i++) { 250 PropertySlot slot; 251 JSValue prop = properties->get(exec, propertyNames[i]); 252 if (exec->hadException()) 253 return jsNull(); 254 PropertyDescriptor descriptor; 255 if (!toPropertyDescriptor(exec, prop, descriptor)) 256 return jsNull(); 257 descriptors.append(descriptor); 258 // Ensure we mark all the values that we're accumulating 259 if (descriptor.isDataDescriptor() && descriptor.value()) 260 markBuffer.append(descriptor.value()); 261 if (descriptor.isAccessorDescriptor()) { 262 if (descriptor.getter()) 263 markBuffer.append(descriptor.getter()); 264 if (descriptor.setter()) 265 markBuffer.append(descriptor.setter()); 266 } 267 } 268 for (size_t i = 0; i < numProperties; i++) { 269 object->defineOwnProperty(exec, propertyNames[i], descriptors[i], true); 270 if (exec->hadException()) 271 return jsNull(); 272 } 273 return object; 274 } 275 276 JSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState* exec, JSObject*, JSValue, const ArgList& args) 277 { 278 if (!args.at(0).isObject()) 279 return throwError(exec, TypeError, "Properties can only be defined on Objects."); 280 if (!args.at(1).isObject()) 281 return throwError(exec, TypeError, "Property descriptor list must be an Object."); 282 return defineProperties(exec, asObject(args.at(0)), asObject(args.at(1))); 283 } 284 240 285 } // namespace JSC -
trunk/LayoutTests/ChangeLog
r48564 r48565 1 2009-09-19 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 Implement ES5 Object.defineProperties function 6 https://bugs.webkit.org/show_bug.cgi?id=29522 7 8 Add tests for Object.defineProperties API. 9 10 * fast/js/Object-defineProperties-expected.txt: Added. 11 * fast/js/Object-defineProperties.html: Added. 12 * fast/js/resources/Object-defineProperties.js: Added. 13 1 14 2009-09-19 Daniel Bates <dbates@webkit.org> 2 15
Note: See TracChangeset
for help on using the changeset viewer.