JSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState* exec, JSObject*, JSValue, const ArgList& args) { if (!args.at(0).isObject()) return throwError(exec, TypeError, "Properties can only be defined on Objects."); JSObject* O = asObject(args.at(0)); UString propertyName = args.at(1).toString(exec); if (exec->hadException()) return jsNull(); PropertyDescriptor descriptor; if (!toPropertyDescriptor(exec, args.at(2), descriptor)) return jsNull(); ASSERT((descriptor.attributes() & (Getter | Setter)) || (!descriptor.isAccessorDescriptor())); ASSERT(!exec->hadException()); O->defineOwnProperty(exec, Identifier(exec, propertyName), descriptor, true); return O; }
EncodedJSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState* exec) { if (!exec->argument(0).isObject()) return throwVMError(exec, createTypeError(exec, "Properties can only be defined on Objects.")); JSObject* O = asObject(exec->argument(0)); UString propertyName = exec->argument(1).toString(exec); if (exec->hadException()) return JSValue::encode(jsNull()); PropertyDescriptor descriptor; if (!toPropertyDescriptor(exec, exec->argument(2), descriptor)) return JSValue::encode(jsNull()); ASSERT((descriptor.attributes() & (Getter | Setter)) || (!descriptor.isAccessorDescriptor())); ASSERT(!exec->hadException()); O->defineOwnProperty(exec, Identifier(exec, propertyName), descriptor, true); return JSValue::encode(O); }