Changeset 48568 in webkit
- Timestamp:
- Sep 19, 2009 6:13:51 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r48565 r48568 1 2009-09-19 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Maciej Stachowiak. 4 5 Implement ES5 Object.create function 6 https://bugs.webkit.org/show_bug.cgi?id=29524 7 8 Implement Object.create. Very simple patch, effectively Object.defineProperties 9 only creating the target object itself. 10 11 * runtime/CommonIdentifiers.h: 12 * runtime/ObjectConstructor.cpp: 13 (JSC::ObjectConstructor::ObjectConstructor): 14 (JSC::objectConstructorCreate): 15 1 16 2009-09-19 Dan Bernstein <mitz@apple.com> 2 17 -
trunk/JavaScriptCore/runtime/CommonIdentifiers.h
r48565 r48568 40 40 macro(configurable) \ 41 41 macro(constructor) \ 42 macro(create) \ 42 43 macro(defineProperty) \ 43 44 macro(defineProperties) \ -
trunk/JavaScriptCore/runtime/ObjectConstructor.cpp
r48565 r48568 40 40 static JSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState*, JSObject*, JSValue, const ArgList&); 41 41 static JSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState*, JSObject*, JSValue, const ArgList&); 42 static JSValue JSC_HOST_CALL objectConstructorCreate(ExecState*, JSObject*, JSValue, const ArgList&); 42 43 43 44 ObjectConstructor::ObjectConstructor(ExecState* exec, PassRefPtr<Structure> structure, ObjectPrototype* objectPrototype, Structure* prototypeFunctionStructure) … … 55 56 putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 3, exec->propertyNames().defineProperty, objectConstructorDefineProperty), DontEnum); 56 57 putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().defineProperties, objectConstructorDefineProperties), DontEnum); 58 putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 2, exec->propertyNames().create, objectConstructorCreate), DontEnum); 57 59 } 58 60 … … 283 285 } 284 286 287 JSValue JSC_HOST_CALL objectConstructorCreate(ExecState* exec, JSObject*, JSValue, const ArgList& args) 288 { 289 if (!args.at(0).isObject() && !args.at(0).isNull()) 290 return throwError(exec, TypeError, "Object prototype may only be an Object or null."); 291 JSObject* newObject = constructEmptyObject(exec); 292 newObject->setPrototype(args.at(0)); 293 if (args.at(1).isUndefined()) 294 return newObject; 295 if (!args.at(1).isObject()) 296 return throwError(exec, TypeError, "Property descriptor list must be an Object."); 297 return defineProperties(exec, newObject, asObject(args.at(1))); 298 } 299 285 300 } // namespace JSC -
trunk/LayoutTests/ChangeLog
r48566 r48568 1 2009-09-19 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Maciej Stachowiak. 4 5 Implement ES5 Object.create function 6 https://bugs.webkit.org/show_bug.cgi?id=29524 7 8 Add tests for Object.create API 9 10 * fast/js/Object-create-expected.txt: Added. 11 * fast/js/Object-create.html: Added. 12 * fast/js/resources/Object-create.js: Added. 13 1 14 2009-09-19 Sam Weinig <sam@webkit.org> 2 15
Note: See TracChangeset
for help on using the changeset viewer.