diff options
Diffstat (limited to 'Source/JavaScriptCore/runtime/JSDataView.cpp')
-rw-r--r-- | Source/JavaScriptCore/runtime/JSDataView.cpp | 82 |
1 files changed, 9 insertions, 73 deletions
diff --git a/Source/JavaScriptCore/runtime/JSDataView.cpp b/Source/JavaScriptCore/runtime/JSDataView.cpp index 75c26dbfe..77640cdaf 100644 --- a/Source/JavaScriptCore/runtime/JSDataView.cpp +++ b/Source/JavaScriptCore/runtime/JSDataView.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2015 Apple Inc. All rights reserved. + * Copyright (C) 2013 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,13 +29,12 @@ #include "ArrayBufferView.h" #include "DataView.h" #include "Error.h" -#include "JSCInlines.h" -#include "Reject.h" +#include "Operations.h" namespace JSC { const ClassInfo JSDataView::s_info = { - "DataView", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDataView)}; + "DataView", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSDataView)}; JSDataView::JSDataView(VM& vm, ConstructionContext& context, ArrayBuffer* buffer) : Base(vm, context) @@ -48,13 +47,10 @@ JSDataView* JSDataView::create( unsigned byteOffset, unsigned byteLength) { RefPtr<ArrayBuffer> buffer = passedBuffer; - if (!ArrayBufferView::verifySubRangeLength(buffer, byteOffset, byteLength, sizeof(uint8_t))) { - throwVMError(exec, createRangeError(exec, ASCIILiteral("Length out of range of buffer"))); - return nullptr; - } - if (!ArrayBufferView::verifyByteOffsetAlignment(byteOffset, sizeof(uint8_t))) { - exec->vm().throwException(exec, createRangeError(exec, ASCIILiteral("Byte offset is not aligned"))); - return nullptr; + if (!ArrayBufferView::verifySubRange<uint8_t>(buffer, byteOffset, byteLength)) { + throwVMError( + exec, createRangeError(exec, "Byte offset and length out of range of buffer")); + return 0; } VM& vm = exec->vm(); ConstructionContext context( @@ -84,12 +80,6 @@ bool JSDataView::set(ExecState*, JSObject*, unsigned, unsigned) return false; } -bool JSDataView::setIndex(ExecState*, unsigned, JSValue) -{ - UNREACHABLE_FOR_PLATFORM(); - return false; -} - PassRefPtr<DataView> JSDataView::typedImpl() { return DataView::create(buffer(), byteOffset(), length()); @@ -103,62 +93,8 @@ bool JSDataView::getOwnPropertySlot( slot.setValue(thisObject, DontEnum | ReadOnly, jsNumber(thisObject->m_length)); return true; } - if (propertyName == exec->propertyNames().byteOffset) { - slot.setValue(thisObject, DontEnum | ReadOnly, jsNumber(thisObject->byteOffset())); - return true; - } - - return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot); -} - -void JSDataView::put( - JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, - PutPropertySlot& slot) -{ - JSDataView* thisObject = jsCast<JSDataView*>(cell); - if (propertyName == exec->propertyNames().byteLength - || propertyName == exec->propertyNames().byteOffset) { - reject(exec, slot.isStrictMode(), "Attempting to write to read-only typed array property."); - return; - } - - Base::put(thisObject, exec, propertyName, value, slot); -} - -bool JSDataView::defineOwnProperty( - JSObject* object, ExecState* exec, PropertyName propertyName, - const PropertyDescriptor& descriptor, bool shouldThrow) -{ - JSDataView* thisObject = jsCast<JSDataView*>(object); - if (propertyName == exec->propertyNames().byteLength - || propertyName == exec->propertyNames().byteOffset) - return reject(exec, shouldThrow, "Attempting to define read-only typed array property."); - - return Base::defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow); -} - -bool JSDataView::deleteProperty( - JSCell* cell, ExecState* exec, PropertyName propertyName) -{ - JSDataView* thisObject = jsCast<JSDataView*>(cell); - if (propertyName == exec->propertyNames().byteLength - || propertyName == exec->propertyNames().byteOffset) - return false; - - return Base::deleteProperty(thisObject, exec, propertyName); -} - -void JSDataView::getOwnNonIndexPropertyNames( - JSObject* object, ExecState* exec, PropertyNameArray& array, EnumerationMode mode) -{ - JSDataView* thisObject = jsCast<JSDataView*>(object); - if (mode.includeDontEnumProperties()) { - array.add(exec->propertyNames().byteOffset); - array.add(exec->propertyNames().byteLength); - } - - Base::getOwnNonIndexPropertyNames(thisObject, exec, array, mode); + return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot); } ArrayBuffer* JSDataView::slowDownAndWasteMemory(JSArrayBufferView*) @@ -177,7 +113,7 @@ Structure* JSDataView::createStructure( VM& vm, JSGlobalObject* globalObject, JSValue prototype) { return Structure::create( - vm, globalObject, prototype, TypeInfo(DataViewType, StructureFlags), info(), + vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info(), NonArray); } |