| /* |
| This file is part of the WebKit open source project. |
| This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| |
| This library is free software; you can redistribute it and/or |
| modify it under the terms of the GNU Library General Public |
| License as published by the Free Software Foundation; either |
| version 2 of the License, or (at your option) any later version. |
| |
| This library is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| Library General Public License for more details. |
| |
| You should have received a copy of the GNU Library General Public License |
| along with this library; see the file COPYING.LIB. If not, write to |
| the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| Boston, MA 02110-1301, USA. |
| */ |
| |
| #include "config.h" |
| #include "JSFloat64Array.h" |
| |
| #include "ExceptionCode.h" |
| #include "JSArrayBufferViewHelper.h" |
| #include "JSDOMBinding.h" |
| #include "JSFloat32Array.h" |
| #include "JSInt32Array.h" |
| #include <runtime/Error.h> |
| #include <runtime/PropertyNameArray.h> |
| #include <wtf/Float64Array.h> |
| #include <wtf/GetPtr.h> |
| #include <wtf/Int32Array.h> |
| |
| using namespace JSC; |
| |
| namespace WebCore { |
| |
| /* Hash table */ |
| |
| static const HashTableValue JSFloat64ArrayTableValues[] = |
| { |
| { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFloat64ArrayConstructor), (intptr_t)0, NoIntrinsic }, |
| { 0, 0, 0, 0, NoIntrinsic } |
| }; |
| |
| static const HashTable JSFloat64ArrayTable = { 2, 1, JSFloat64ArrayTableValues, 0 }; |
| /* Hash table for constructor */ |
| |
| static const HashTableValue JSFloat64ArrayConstructorTableValues[] = |
| { |
| { 0, 0, 0, 0, NoIntrinsic } |
| }; |
| |
| static const HashTable JSFloat64ArrayConstructorTable = { 1, 0, JSFloat64ArrayConstructorTableValues, 0 }; |
| const ClassInfo JSFloat64ArrayConstructor::s_info = { "Float64ArrayConstructor", &Base::s_info, &JSFloat64ArrayConstructorTable, 0, CREATE_METHOD_TABLE(JSFloat64ArrayConstructor) }; |
| |
| JSFloat64ArrayConstructor::JSFloat64ArrayConstructor(Structure* structure, JSDOMGlobalObject* globalObject) |
| : DOMConstructorObject(structure, globalObject) |
| { |
| } |
| |
| void JSFloat64ArrayConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject) |
| { |
| Base::finishCreation(exec->globalData()); |
| ASSERT(inherits(&s_info)); |
| putDirect(exec->globalData(), exec->propertyNames().prototype, JSFloat64ArrayPrototype::self(exec, globalObject), DontDelete | ReadOnly); |
| putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(123), ReadOnly | DontDelete | DontEnum); |
| } |
| |
| bool JSFloat64ArrayConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot) |
| { |
| return getStaticValueSlot<JSFloat64ArrayConstructor, JSDOMWrapper>(exec, &JSFloat64ArrayConstructorTable, jsCast<JSFloat64ArrayConstructor*>(cell), propertyName, slot); |
| } |
| |
| bool JSFloat64ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) |
| { |
| return getStaticValueDescriptor<JSFloat64ArrayConstructor, JSDOMWrapper>(exec, &JSFloat64ArrayConstructorTable, jsCast<JSFloat64ArrayConstructor*>(object), propertyName, descriptor); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL JSFloat64ArrayConstructor::constructJSFloat64Array(ExecState* exec) |
| { |
| JSFloat64ArrayConstructor* jsConstructor = jsCast<JSFloat64ArrayConstructor*>(exec->callee()); |
| RefPtr<Float64Array> array = constructArrayBufferView<Float64Array, double>(exec); |
| if (!array.get()) |
| // Exception has already been thrown. |
| return JSValue::encode(JSValue()); |
| return JSValue::encode(asObject(toJS(exec, jsConstructor->globalObject(), array.get()))); |
| } |
| |
| JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Float64Array* object) |
| { |
| return toJSArrayBufferView<JSFloat64Array>(exec, globalObject, object); |
| } |
| |
| void JSFloat64Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) |
| { |
| impl()->set(index, value.toNumber(exec)); |
| } |
| |
| ConstructType JSFloat64ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData) |
| { |
| constructData.native.function = constructJSFloat64Array; |
| return ConstructTypeHost; |
| } |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSFloat64ArrayPrototypeTableValues[] = |
| { |
| { "foo", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsFloat64ArrayPrototypeFunctionFoo), (intptr_t)1, NoIntrinsic }, |
| { "set", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsFloat64ArrayPrototypeFunctionSet), (intptr_t)0, NoIntrinsic }, |
| { 0, 0, 0, 0, NoIntrinsic } |
| }; |
| |
| static const HashTable JSFloat64ArrayPrototypeTable = { 4, 3, JSFloat64ArrayPrototypeTableValues, 0 }; |
| static const HashTable* getJSFloat64ArrayPrototypeTable(ExecState* exec) |
| { |
| return getHashTableForGlobalData(exec->globalData(), &JSFloat64ArrayPrototypeTable); |
| } |
| |
| const ClassInfo JSFloat64ArrayPrototype::s_info = { "Float64ArrayPrototype", &Base::s_info, 0, getJSFloat64ArrayPrototypeTable, CREATE_METHOD_TABLE(JSFloat64ArrayPrototype) }; |
| |
| JSObject* JSFloat64ArrayPrototype::self(ExecState* exec, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSFloat64Array>(exec, globalObject); |
| } |
| |
| bool JSFloat64ArrayPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot) |
| { |
| JSFloat64ArrayPrototype* thisObject = jsCast<JSFloat64ArrayPrototype*>(cell); |
| return getStaticFunctionSlot<JSObject>(exec, getJSFloat64ArrayPrototypeTable(exec), thisObject, propertyName, slot); |
| } |
| |
| bool JSFloat64ArrayPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) |
| { |
| JSFloat64ArrayPrototype* thisObject = jsCast<JSFloat64ArrayPrototype*>(object); |
| return getStaticFunctionDescriptor<JSObject>(exec, getJSFloat64ArrayPrototypeTable(exec), thisObject, propertyName, descriptor); |
| } |
| |
| static const HashTable* getJSFloat64ArrayTable(ExecState* exec) |
| { |
| return getHashTableForGlobalData(exec->globalData(), &JSFloat64ArrayTable); |
| } |
| |
| const ClassInfo JSFloat64Array::s_info = { "Float64Array", &Base::s_info, 0, getJSFloat64ArrayTable , CREATE_METHOD_TABLE(JSFloat64Array) }; |
| |
| JSFloat64Array::JSFloat64Array(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<Float64Array> impl) |
| : JSArrayBufferView(structure, globalObject, impl) |
| { |
| } |
| |
| void JSFloat64Array::finishCreation(JSGlobalData& globalData) |
| { |
| Base::finishCreation(globalData); |
| TypedArrayDescriptor descriptor(&JSFloat64Array::s_info, OBJECT_OFFSETOF(JSFloat64Array, m_storage), OBJECT_OFFSETOF(JSFloat64Array, m_storageLength)); |
| globalData.registerTypedArrayDescriptor(impl(), descriptor); |
| m_storage = impl()->data(); |
| m_storageLength = impl()->length(); |
| ASSERT(inherits(&s_info)); |
| } |
| |
| JSObject* JSFloat64Array::createPrototype(ExecState* exec, JSGlobalObject* globalObject) |
| { |
| return JSFloat64ArrayPrototype::create(exec->globalData(), globalObject, JSFloat64ArrayPrototype::createStructure(exec->globalData(), globalObject, JSArrayBufferViewPrototype::self(exec, globalObject))); |
| } |
| |
| bool JSFloat64Array::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot) |
| { |
| JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(cell); |
| ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); |
| unsigned index = propertyName.asIndex(); |
| if (index != PropertyName::NotAnIndex && index < static_cast<Float64Array*>(thisObject->impl())->length()) { |
| slot.setValue(thisObject->getByIndex(exec, index)); |
| return true; |
| } |
| return getStaticValueSlot<JSFloat64Array, Base>(exec, getJSFloat64ArrayTable(exec), thisObject, propertyName, slot); |
| } |
| |
| bool JSFloat64Array::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) |
| { |
| JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(object); |
| ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); |
| unsigned index = propertyName.asIndex(); |
| if (index != PropertyName::NotAnIndex && index < static_cast<Float64Array*>(thisObject->impl())->length()) { |
| descriptor.setDescriptor(thisObject->getByIndex(exec, index), DontDelete); |
| return true; |
| } |
| return getStaticValueDescriptor<JSFloat64Array, Base>(exec, getJSFloat64ArrayTable(exec), thisObject, propertyName, descriptor); |
| } |
| |
| bool JSFloat64Array::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned index, PropertySlot& slot) |
| { |
| JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(cell); |
| ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); |
| if (index < static_cast<Float64Array*>(thisObject->impl())->length()) { |
| slot.setValue(thisObject->getByIndex(exec, index)); |
| return true; |
| } |
| return Base::getOwnPropertySlotByIndex(thisObject, exec, index, slot); |
| } |
| |
| JSValue jsFloat64ArrayConstructor(ExecState* exec, JSValue slotBase, PropertyName) |
| { |
| JSFloat64Array* domObject = jsCast<JSFloat64Array*>(asObject(slotBase)); |
| return JSFloat64Array::getConstructor(exec, domObject->globalObject()); |
| } |
| |
| void JSFloat64Array::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot) |
| { |
| JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(cell); |
| ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); |
| unsigned index = propertyName.asIndex(); |
| if (index != PropertyName::NotAnIndex) { |
| thisObject->indexSetter(exec, index, value); |
| return; |
| } |
| Base::put(thisObject, exec, propertyName, value, slot); |
| } |
| |
| void JSFloat64Array::putByIndex(JSCell* cell, ExecState* exec, unsigned index, JSValue value, bool shouldThrow) |
| { |
| JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(cell); |
| ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); |
| if (index <= MAX_ARRAY_INDEX) { |
| UNUSED_PARAM(shouldThrow); |
| thisObject->indexSetter(exec, index, value); |
| return; |
| } |
| Base::putByIndex(cell, exec, index, value, shouldThrow); |
| } |
| |
| void JSFloat64Array::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) |
| { |
| JSFloat64Array* thisObject = jsCast<JSFloat64Array*>(object); |
| ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info); |
| for (unsigned i = 0; i < static_cast<Float64Array*>(thisObject->impl())->length(); ++i) |
| propertyNames.add(Identifier::from(exec, i)); |
| Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode); |
| } |
| |
| JSValue JSFloat64Array::getConstructor(ExecState* exec, JSGlobalObject* globalObject) |
| { |
| return getDOMConstructor<JSFloat64ArrayConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject)); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsFloat64ArrayPrototypeFunctionFoo(ExecState* exec) |
| { |
| JSValue thisValue = exec->hostThisValue(); |
| if (!thisValue.inherits(&JSFloat64Array::s_info)) |
| return throwVMTypeError(exec); |
| JSFloat64Array* castedThis = jsCast<JSFloat64Array*>(asObject(thisValue)); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFloat64Array::s_info); |
| Float64Array* impl = static_cast<Float64Array*>(castedThis->impl()); |
| if (exec->argumentCount() < 1) |
| return throwVMError(exec, createNotEnoughArgumentsError(exec)); |
| Float32Array* array(toFloat32Array(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined))); |
| if (exec->hadException()) |
| return JSValue::encode(jsUndefined()); |
| |
| JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->foo(array))); |
| return JSValue::encode(result); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsFloat64ArrayPrototypeFunctionSet(ExecState* exec) |
| { |
| JSValue thisValue = exec->hostThisValue(); |
| if (!thisValue.inherits(&JSFloat64Array::s_info)) |
| return throwVMTypeError(exec); |
| JSFloat64Array* castedThis = jsCast<JSFloat64Array*>(asObject(thisValue)); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, &JSFloat64Array::s_info); |
| return JSValue::encode(setWebGLArrayHelper<Float64Array, double>(exec, castedThis->impl())); |
| } |
| |
| |
| JSValue JSFloat64Array::getByIndex(ExecState*, unsigned index) |
| { |
| ASSERT_GC_OBJECT_INHERITS(this, &s_info); |
| double result = static_cast<Float64Array*>(impl())->item(index); |
| if (isnan(result)) |
| return jsNaN(); |
| return JSValue(result); |
| } |
| |
| Float64Array* toFloat64Array(JSC::JSValue value) |
| { |
| return value.inherits(&JSFloat64Array::s_info) ? jsCast<JSFloat64Array*>(asObject(value))->impl() : 0; |
| } |
| |
| } |