/*
    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 "JSDataView.h"

#include "DataView.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include <runtime/Error.h>
#include <wtf/GetPtr.h>

using namespace JSC;

namespace WebCore {

/* Hash table */

static const HashTableValue JSDataViewTableValues[] =
{
    { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDataViewConstructor), (intptr_t)0, NoIntrinsic },
    { 0, 0, 0, 0, NoIntrinsic }
};

static const HashTable JSDataViewTable = { 2, 1, JSDataViewTableValues, 0 };
/* Hash table for constructor */

static const HashTableValue JSDataViewConstructorTableValues[] =
{
    { 0, 0, 0, 0, NoIntrinsic }
};

static const HashTable JSDataViewConstructorTable = { 1, 0, JSDataViewConstructorTableValues, 0 };
static const HashTable* getJSDataViewConstructorTable(ExecState* exec)
{
    return getHashTableForGlobalData(exec->vm(), &JSDataViewConstructorTable);
}

const ClassInfo JSDataViewConstructor::s_info = { "DataViewConstructor", &Base::s_info, 0, getJSDataViewConstructorTable, CREATE_METHOD_TABLE(JSDataViewConstructor) };

JSDataViewConstructor::JSDataViewConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
    : DOMConstructorObject(structure, globalObject)
{
}

void JSDataViewConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
{
    Base::finishCreation(exec->vm());
    ASSERT(inherits(&s_info));
    putDirect(exec->vm(), exec->propertyNames().prototype, JSDataViewPrototype::self(exec, globalObject), DontDelete | ReadOnly);
    putDirect(exec->vm(), exec->propertyNames().length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
}

bool JSDataViewConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
    return getStaticValueSlot<JSDataViewConstructor, JSDOMWrapper>(exec, getJSDataViewConstructorTable(exec), jsCast<JSDataViewConstructor*>(cell), propertyName, slot);
}

bool JSDataViewConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
    return getStaticValueDescriptor<JSDataViewConstructor, JSDOMWrapper>(exec, getJSDataViewConstructorTable(exec), jsCast<JSDataViewConstructor*>(object), propertyName, descriptor);
}

ConstructType JSDataViewConstructor::getConstructData(JSCell*, ConstructData& constructData)
{
    constructData.native.function = constructJSDataView;
    return ConstructTypeHost;
}

/* Hash table for prototype */

static const HashTableValue JSDataViewPrototypeTableValues[] =
{
    { "getInt8", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsDataViewPrototypeFunctionGetInt8), (intptr_t)1, NoIntrinsic },
    { "getUint8", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsDataViewPrototypeFunctionGetUint8), (intptr_t)1, NoIntrinsic },
    { "getInt16", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsDataViewPrototypeFunctionGetInt16), (intptr_t)1, NoIntrinsic },
    { "getUint16", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsDataViewPrototypeFunctionGetUint16), (intptr_t)1, NoIntrinsic },
    { "getInt32", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsDataViewPrototypeFunctionGetInt32), (intptr_t)1, NoIntrinsic },
    { "getUint32", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsDataViewPrototypeFunctionGetUint32), (intptr_t)1, NoIntrinsic },
    { "getFloat32", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsDataViewPrototypeFunctionGetFloat32), (intptr_t)1, NoIntrinsic },
    { "getFloat64", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsDataViewPrototypeFunctionGetFloat64), (intptr_t)1, NoIntrinsic },
    { "setInt8", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsDataViewPrototypeFunctionSetInt8), (intptr_t)2, NoIntrinsic },
    { "setUint8", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsDataViewPrototypeFunctionSetUint8), (intptr_t)2, NoIntrinsic },
    { "setInt16", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsDataViewPrototypeFunctionSetInt16), (intptr_t)2, NoIntrinsic },
    { "setUint16", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsDataViewPrototypeFunctionSetUint16), (intptr_t)2, NoIntrinsic },
    { "setInt32", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsDataViewPrototypeFunctionSetInt32), (intptr_t)2, NoIntrinsic },
    { "setUint32", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsDataViewPrototypeFunctionSetUint32), (intptr_t)2, NoIntrinsic },
    { "setFloat32", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsDataViewPrototypeFunctionSetFloat32), (intptr_t)2, NoIntrinsic },
    { "setFloat64", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsDataViewPrototypeFunctionSetFloat64), (intptr_t)2, NoIntrinsic },
    { 0, 0, 0, 0, NoIntrinsic }
};

static const HashTable JSDataViewPrototypeTable = { 37, 31, JSDataViewPrototypeTableValues, 0 };
static const HashTable* getJSDataViewPrototypeTable(ExecState* exec)
{
    return getHashTableForGlobalData(exec->vm(), &JSDataViewPrototypeTable);
}

const ClassInfo JSDataViewPrototype::s_info = { "DataViewPrototype", &Base::s_info, 0, getJSDataViewPrototypeTable, CREATE_METHOD_TABLE(JSDataViewPrototype) };

JSObject* JSDataViewPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
{
    return getDOMPrototype<JSDataView>(exec, globalObject);
}

bool JSDataViewPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
    JSDataViewPrototype* thisObject = jsCast<JSDataViewPrototype*>(cell);
    return getStaticFunctionSlot<JSObject>(exec, getJSDataViewPrototypeTable(exec), thisObject, propertyName, slot);
}

bool JSDataViewPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
    JSDataViewPrototype* thisObject = jsCast<JSDataViewPrototype*>(object);
    return getStaticFunctionDescriptor<JSObject>(exec, getJSDataViewPrototypeTable(exec), thisObject, propertyName, descriptor);
}

static const HashTable* getJSDataViewTable(ExecState* exec)
{
    return getHashTableForGlobalData(exec->vm(), &JSDataViewTable);
}

const ClassInfo JSDataView::s_info = { "DataView", &Base::s_info, 0, getJSDataViewTable , CREATE_METHOD_TABLE(JSDataView) };

JSDataView::JSDataView(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<DataView> impl)
    : JSArrayBufferView(structure, globalObject, impl)
{
}

void JSDataView::finishCreation(VM& vm)
{
    Base::finishCreation(vm);
    ASSERT(inherits(&s_info));
}

JSObject* JSDataView::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
{
    return JSDataViewPrototype::create(exec->vm(), globalObject, JSDataViewPrototype::createStructure(exec->vm(), globalObject, JSArrayBufferViewPrototype::self(exec, globalObject)));
}

bool JSDataView::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
    JSDataView* thisObject = jsCast<JSDataView*>(cell);
    ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
    return getStaticValueSlot<JSDataView, Base>(exec, getJSDataViewTable(exec), thisObject, propertyName, slot);
}

bool JSDataView::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
    JSDataView* thisObject = jsCast<JSDataView*>(object);
    ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
    return getStaticValueDescriptor<JSDataView, Base>(exec, getJSDataViewTable(exec), thisObject, propertyName, descriptor);
}

JSValue jsDataViewConstructor(ExecState* exec, JSValue slotBase, PropertyName)
{
    JSDataView* domObject = jsCast<JSDataView*>(asObject(slotBase));
    return JSDataView::getConstructor(exec, domObject->globalObject());
}

JSValue JSDataView::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
{
    return getDOMConstructor<JSDataViewConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject));
}

EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionGetInt8(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDataView::s_info))
        return throwVMTypeError(exec);
    JSDataView* castedThis = jsCast<JSDataView*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDataView::s_info);
    DataView* impl = static_cast<DataView*>(castedThis->impl());
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    ExceptionCode ec = 0;
    unsigned byteOffset(toUInt32(exec, exec->argument(0), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    JSC::JSValue result = jsNumber(impl->getInt8(byteOffset, ec));
    setDOMException(exec, ec);
    return JSValue::encode(result);
}

EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionGetUint8(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDataView::s_info))
        return throwVMTypeError(exec);
    JSDataView* castedThis = jsCast<JSDataView*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDataView::s_info);
    DataView* impl = static_cast<DataView*>(castedThis->impl());
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    ExceptionCode ec = 0;
    unsigned byteOffset(toUInt32(exec, exec->argument(0), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    JSC::JSValue result = jsNumber(impl->getUint8(byteOffset, ec));
    setDOMException(exec, ec);
    return JSValue::encode(result);
}

EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionGetInt16(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDataView::s_info))
        return throwVMTypeError(exec);
    JSDataView* castedThis = jsCast<JSDataView*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDataView::s_info);
    DataView* impl = static_cast<DataView*>(castedThis->impl());
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    ExceptionCode ec = 0;
    unsigned byteOffset(toUInt32(exec, exec->argument(0), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    size_t argsCount = exec->argumentCount();
    if (argsCount <= 1) {

        JSC::JSValue result = jsNumber(impl->getInt16(byteOffset, ec));
        setDOMException(exec, ec);
        return JSValue::encode(result);
    }

    bool littleEndian(exec->argument(1).toBoolean(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    JSC::JSValue result = jsNumber(impl->getInt16(byteOffset, littleEndian, ec));
    setDOMException(exec, ec);
    return JSValue::encode(result);
}

EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionGetUint16(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDataView::s_info))
        return throwVMTypeError(exec);
    JSDataView* castedThis = jsCast<JSDataView*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDataView::s_info);
    DataView* impl = static_cast<DataView*>(castedThis->impl());
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    ExceptionCode ec = 0;
    unsigned byteOffset(toUInt32(exec, exec->argument(0), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    size_t argsCount = exec->argumentCount();
    if (argsCount <= 1) {

        JSC::JSValue result = jsNumber(impl->getUint16(byteOffset, ec));
        setDOMException(exec, ec);
        return JSValue::encode(result);
    }

    bool littleEndian(exec->argument(1).toBoolean(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    JSC::JSValue result = jsNumber(impl->getUint16(byteOffset, littleEndian, ec));
    setDOMException(exec, ec);
    return JSValue::encode(result);
}

EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionGetInt32(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDataView::s_info))
        return throwVMTypeError(exec);
    JSDataView* castedThis = jsCast<JSDataView*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDataView::s_info);
    DataView* impl = static_cast<DataView*>(castedThis->impl());
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    ExceptionCode ec = 0;
    unsigned byteOffset(toUInt32(exec, exec->argument(0), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    size_t argsCount = exec->argumentCount();
    if (argsCount <= 1) {

        JSC::JSValue result = jsNumber(impl->getInt32(byteOffset, ec));
        setDOMException(exec, ec);
        return JSValue::encode(result);
    }

    bool littleEndian(exec->argument(1).toBoolean(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    JSC::JSValue result = jsNumber(impl->getInt32(byteOffset, littleEndian, ec));
    setDOMException(exec, ec);
    return JSValue::encode(result);
}

EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionGetUint32(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDataView::s_info))
        return throwVMTypeError(exec);
    JSDataView* castedThis = jsCast<JSDataView*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDataView::s_info);
    DataView* impl = static_cast<DataView*>(castedThis->impl());
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    ExceptionCode ec = 0;
    unsigned byteOffset(toUInt32(exec, exec->argument(0), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    size_t argsCount = exec->argumentCount();
    if (argsCount <= 1) {

        JSC::JSValue result = jsNumber(impl->getUint32(byteOffset, ec));
        setDOMException(exec, ec);
        return JSValue::encode(result);
    }

    bool littleEndian(exec->argument(1).toBoolean(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    JSC::JSValue result = jsNumber(impl->getUint32(byteOffset, littleEndian, ec));
    setDOMException(exec, ec);
    return JSValue::encode(result);
}

EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionGetFloat32(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDataView::s_info))
        return throwVMTypeError(exec);
    JSDataView* castedThis = jsCast<JSDataView*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDataView::s_info);
    return JSValue::encode(castedThis->getFloat32(exec));
}

EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionGetFloat64(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDataView::s_info))
        return throwVMTypeError(exec);
    JSDataView* castedThis = jsCast<JSDataView*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDataView::s_info);
    return JSValue::encode(castedThis->getFloat64(exec));
}

EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionSetInt8(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDataView::s_info))
        return throwVMTypeError(exec);
    JSDataView* castedThis = jsCast<JSDataView*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDataView::s_info);
    DataView* impl = static_cast<DataView*>(castedThis->impl());
    if (exec->argumentCount() < 2)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    ExceptionCode ec = 0;
    unsigned byteOffset(toUInt32(exec, exec->argument(0), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    int8_t value(toInt8(exec, exec->argument(1), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl->setInt8(byteOffset, value, ec);
    setDOMException(exec, ec);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionSetUint8(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDataView::s_info))
        return throwVMTypeError(exec);
    JSDataView* castedThis = jsCast<JSDataView*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDataView::s_info);
    DataView* impl = static_cast<DataView*>(castedThis->impl());
    if (exec->argumentCount() < 2)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    ExceptionCode ec = 0;
    unsigned byteOffset(toUInt32(exec, exec->argument(0), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    uint8_t value(toUInt8(exec, exec->argument(1), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl->setUint8(byteOffset, value, ec);
    setDOMException(exec, ec);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionSetInt16(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDataView::s_info))
        return throwVMTypeError(exec);
    JSDataView* castedThis = jsCast<JSDataView*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDataView::s_info);
    DataView* impl = static_cast<DataView*>(castedThis->impl());
    if (exec->argumentCount() < 2)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    ExceptionCode ec = 0;
    unsigned byteOffset(toUInt32(exec, exec->argument(0), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    short value(toInt32(exec, exec->argument(1), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    size_t argsCount = exec->argumentCount();
    if (argsCount <= 2) {
        impl->setInt16(byteOffset, value, ec);
        setDOMException(exec, ec);
        return JSValue::encode(jsUndefined());
    }

    bool littleEndian(exec->argument(2).toBoolean(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl->setInt16(byteOffset, value, littleEndian, ec);
    setDOMException(exec, ec);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionSetUint16(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDataView::s_info))
        return throwVMTypeError(exec);
    JSDataView* castedThis = jsCast<JSDataView*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDataView::s_info);
    DataView* impl = static_cast<DataView*>(castedThis->impl());
    if (exec->argumentCount() < 2)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    ExceptionCode ec = 0;
    unsigned byteOffset(toUInt32(exec, exec->argument(0), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    unsigned short value(toUInt32(exec, exec->argument(1), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    size_t argsCount = exec->argumentCount();
    if (argsCount <= 2) {
        impl->setUint16(byteOffset, value, ec);
        setDOMException(exec, ec);
        return JSValue::encode(jsUndefined());
    }

    bool littleEndian(exec->argument(2).toBoolean(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl->setUint16(byteOffset, value, littleEndian, ec);
    setDOMException(exec, ec);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionSetInt32(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDataView::s_info))
        return throwVMTypeError(exec);
    JSDataView* castedThis = jsCast<JSDataView*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDataView::s_info);
    DataView* impl = static_cast<DataView*>(castedThis->impl());
    if (exec->argumentCount() < 2)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    ExceptionCode ec = 0;
    unsigned byteOffset(toUInt32(exec, exec->argument(0), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    int value(toInt32(exec, exec->argument(1), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    size_t argsCount = exec->argumentCount();
    if (argsCount <= 2) {
        impl->setInt32(byteOffset, value, ec);
        setDOMException(exec, ec);
        return JSValue::encode(jsUndefined());
    }

    bool littleEndian(exec->argument(2).toBoolean(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl->setInt32(byteOffset, value, littleEndian, ec);
    setDOMException(exec, ec);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionSetUint32(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDataView::s_info))
        return throwVMTypeError(exec);
    JSDataView* castedThis = jsCast<JSDataView*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDataView::s_info);
    DataView* impl = static_cast<DataView*>(castedThis->impl());
    if (exec->argumentCount() < 2)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    ExceptionCode ec = 0;
    unsigned byteOffset(toUInt32(exec, exec->argument(0), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    unsigned value(toUInt32(exec, exec->argument(1), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    size_t argsCount = exec->argumentCount();
    if (argsCount <= 2) {
        impl->setUint32(byteOffset, value, ec);
        setDOMException(exec, ec);
        return JSValue::encode(jsUndefined());
    }

    bool littleEndian(exec->argument(2).toBoolean(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl->setUint32(byteOffset, value, littleEndian, ec);
    setDOMException(exec, ec);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionSetFloat32(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDataView::s_info))
        return throwVMTypeError(exec);
    JSDataView* castedThis = jsCast<JSDataView*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDataView::s_info);
    DataView* impl = static_cast<DataView*>(castedThis->impl());
    if (exec->argumentCount() < 2)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    ExceptionCode ec = 0;
    unsigned byteOffset(toUInt32(exec, exec->argument(0), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    float value(exec->argument(1).toFloat(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    size_t argsCount = exec->argumentCount();
    if (argsCount <= 2) {
        impl->setFloat32(byteOffset, value, ec);
        setDOMException(exec, ec);
        return JSValue::encode(jsUndefined());
    }

    bool littleEndian(exec->argument(2).toBoolean(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl->setFloat32(byteOffset, value, littleEndian, ec);
    setDOMException(exec, ec);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsDataViewPrototypeFunctionSetFloat64(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSDataView::s_info))
        return throwVMTypeError(exec);
    JSDataView* castedThis = jsCast<JSDataView*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSDataView::s_info);
    DataView* impl = static_cast<DataView*>(castedThis->impl());
    if (exec->argumentCount() < 2)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    ExceptionCode ec = 0;
    unsigned byteOffset(toUInt32(exec, exec->argument(0), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    double value(exec->argument(1).toNumber(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    size_t argsCount = exec->argumentCount();
    if (argsCount <= 2) {
        impl->setFloat64(byteOffset, value, ec);
        setDOMException(exec, ec);
        return JSValue::encode(jsUndefined());
    }

    bool littleEndian(exec->argument(2).toBoolean(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl->setFloat64(byteOffset, value, littleEndian, ec);
    setDOMException(exec, ec);
    return JSValue::encode(jsUndefined());
}


}
