/*
    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"

#if ENABLE(BLOB)

#include "JSFileException.h"

#include "ExceptionCode.h"
#include "FileException.h"
#include "JSDOMBinding.h"
#include "URL.h"
#include <runtime/Error.h>
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>

using namespace JSC;

namespace WebCore {

/* Hash table */

static const HashTableValue JSFileExceptionTableValues[] =
{
    { "code", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileExceptionCode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "name", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileExceptionName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "message", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileExceptionMessage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSFileExceptionTable = { 9, 7, true, JSFileExceptionTableValues, 0 };
/* Hash table for prototype */

static const HashTableValue JSFileExceptionPrototypeTableValues[] =
{
    { "NOT_FOUND_ERR", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileExceptionNOT_FOUND_ERR), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "SECURITY_ERR", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileExceptionSECURITY_ERR), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "ABORT_ERR", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileExceptionABORT_ERR), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "NOT_READABLE_ERR", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileExceptionNOT_READABLE_ERR), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "ENCODING_ERR", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileExceptionENCODING_ERR), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "NO_MODIFICATION_ALLOWED_ERR", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileExceptionNO_MODIFICATION_ALLOWED_ERR), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "INVALID_STATE_ERR", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileExceptionINVALID_STATE_ERR), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "SYNTAX_ERR", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileExceptionSYNTAX_ERR), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "INVALID_MODIFICATION_ERR", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileExceptionINVALID_MODIFICATION_ERR), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "QUOTA_EXCEEDED_ERR", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileExceptionQUOTA_EXCEEDED_ERR), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "TYPE_MISMATCH_ERR", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileExceptionTYPE_MISMATCH_ERR), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "PATH_EXISTS_ERR", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileExceptionPATH_EXISTS_ERR), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "toString", DontEnum | JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsFileExceptionPrototypeFunctionToString), (intptr_t) (0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSFileExceptionPrototypeTable = { 35, 31, true, JSFileExceptionPrototypeTableValues, 0 };
static const HashTable& getJSFileExceptionPrototypeTable(VM& vm)
{
    return getHashTableForGlobalData(vm, JSFileExceptionPrototypeTable);
}

const ClassInfo JSFileExceptionPrototype::s_info = { "FileExceptionPrototype", &Base::s_info, 0, getJSFileExceptionPrototypeTable, CREATE_METHOD_TABLE(JSFileExceptionPrototype) };

JSObject* JSFileExceptionPrototype::self(VM& vm, JSGlobalObject* globalObject)
{
    return getDOMPrototype<JSFileException>(vm, globalObject);
}

bool JSFileExceptionPrototype::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
    JSFileExceptionPrototype* thisObject = jsCast<JSFileExceptionPrototype*>(object);
    return getStaticPropertySlot<JSFileExceptionPrototype, JSObject>(exec, getJSFileExceptionPrototypeTable(exec->vm()), thisObject, propertyName, slot);
}

static const HashTable& getJSFileExceptionTable(VM& vm)
{
    return getHashTableForGlobalData(vm, JSFileExceptionTable);
}

const ClassInfo JSFileException::s_info = { "FileException", &Base::s_info, 0, getJSFileExceptionTable , CREATE_METHOD_TABLE(JSFileException) };

JSFileException::JSFileException(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<FileException> impl)
    : JSDOMWrapper(structure, globalObject)
    , m_impl(impl.leakRef())
{
}

void JSFileException::finishCreation(VM& vm)
{
    Base::finishCreation(vm);
    ASSERT(inherits(info()));
}

JSObject* JSFileException::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
    return JSFileExceptionPrototype::create(vm, globalObject, JSFileExceptionPrototype::createStructure(vm, globalObject, globalObject->errorPrototype()));
}

void JSFileException::destroy(JSC::JSCell* cell)
{
    JSFileException* thisObject = static_cast<JSFileException*>(cell);
    thisObject->JSFileException::~JSFileException();
}

JSFileException::~JSFileException()
{
    releaseImplIfNotNull();
}

bool JSFileException::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
    JSFileException* thisObject = jsCast<JSFileException*>(object);
    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
    return getStaticValueSlot<JSFileException, Base>(exec, getJSFileExceptionTable(exec->vm()), thisObject, propertyName, slot);
}

EncodedJSValue jsFileExceptionCode(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSFileException* castedThis = jsDynamicCast<JSFileException*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    FileException& impl = castedThis->impl();
    JSValue result = jsNumber(impl.code());
    return JSValue::encode(result);
}


EncodedJSValue jsFileExceptionName(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSFileException* castedThis = jsDynamicCast<JSFileException*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    FileException& impl = castedThis->impl();
    JSValue result = jsStringWithCache(exec, impl.name());
    return JSValue::encode(result);
}


EncodedJSValue jsFileExceptionMessage(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSFileException* castedThis = jsDynamicCast<JSFileException*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    FileException& impl = castedThis->impl();
    JSValue result = jsStringWithCache(exec, impl.message());
    return JSValue::encode(result);
}


EncodedJSValue JSC_HOST_CALL jsFileExceptionPrototypeFunctionToString(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSFileException* castedThis = jsDynamicCast<JSFileException*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSFileException::info());
    FileException& impl = castedThis->impl();

    JSC::JSValue result = jsStringWithCache(exec, impl.toString());
    return JSValue::encode(result);
}

// Constant getters

EncodedJSValue jsFileExceptionNOT_FOUND_ERR(ExecState* exec, EncodedJSValue, EncodedJSValue, PropertyName)
{
    UNUSED_PARAM(exec);
    return JSValue::encode(jsNumber(static_cast<int>(1)));
}

EncodedJSValue jsFileExceptionSECURITY_ERR(ExecState* exec, EncodedJSValue, EncodedJSValue, PropertyName)
{
    UNUSED_PARAM(exec);
    return JSValue::encode(jsNumber(static_cast<int>(2)));
}

EncodedJSValue jsFileExceptionABORT_ERR(ExecState* exec, EncodedJSValue, EncodedJSValue, PropertyName)
{
    UNUSED_PARAM(exec);
    return JSValue::encode(jsNumber(static_cast<int>(3)));
}

EncodedJSValue jsFileExceptionNOT_READABLE_ERR(ExecState* exec, EncodedJSValue, EncodedJSValue, PropertyName)
{
    UNUSED_PARAM(exec);
    return JSValue::encode(jsNumber(static_cast<int>(4)));
}

EncodedJSValue jsFileExceptionENCODING_ERR(ExecState* exec, EncodedJSValue, EncodedJSValue, PropertyName)
{
    UNUSED_PARAM(exec);
    return JSValue::encode(jsNumber(static_cast<int>(5)));
}

EncodedJSValue jsFileExceptionNO_MODIFICATION_ALLOWED_ERR(ExecState* exec, EncodedJSValue, EncodedJSValue, PropertyName)
{
    UNUSED_PARAM(exec);
    return JSValue::encode(jsNumber(static_cast<int>(6)));
}

EncodedJSValue jsFileExceptionINVALID_STATE_ERR(ExecState* exec, EncodedJSValue, EncodedJSValue, PropertyName)
{
    UNUSED_PARAM(exec);
    return JSValue::encode(jsNumber(static_cast<int>(7)));
}

EncodedJSValue jsFileExceptionSYNTAX_ERR(ExecState* exec, EncodedJSValue, EncodedJSValue, PropertyName)
{
    UNUSED_PARAM(exec);
    return JSValue::encode(jsNumber(static_cast<int>(8)));
}

EncodedJSValue jsFileExceptionINVALID_MODIFICATION_ERR(ExecState* exec, EncodedJSValue, EncodedJSValue, PropertyName)
{
    UNUSED_PARAM(exec);
    return JSValue::encode(jsNumber(static_cast<int>(9)));
}

EncodedJSValue jsFileExceptionQUOTA_EXCEEDED_ERR(ExecState* exec, EncodedJSValue, EncodedJSValue, PropertyName)
{
    UNUSED_PARAM(exec);
    return JSValue::encode(jsNumber(static_cast<int>(10)));
}

EncodedJSValue jsFileExceptionTYPE_MISMATCH_ERR(ExecState* exec, EncodedJSValue, EncodedJSValue, PropertyName)
{
    UNUSED_PARAM(exec);
    return JSValue::encode(jsNumber(static_cast<int>(11)));
}

EncodedJSValue jsFileExceptionPATH_EXISTS_ERR(ExecState* exec, EncodedJSValue, EncodedJSValue, PropertyName)
{
    UNUSED_PARAM(exec);
    return JSValue::encode(jsNumber(static_cast<int>(12)));
}

bool JSFileExceptionOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
    UNUSED_PARAM(handle);
    UNUSED_PARAM(visitor);
    return false;
}

void JSFileExceptionOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
    JSFileException* jsFileException = jsCast<JSFileException*>(handle.get().asCell());
    DOMWrapperWorld& world = *static_cast<DOMWrapperWorld*>(context);
    uncacheWrapper(world, &jsFileException->impl(), jsFileException);
    jsFileException->releaseImpl();
}

JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, FileException* impl)
{
    if (!impl)
        return jsNull();
    if (JSValue result = getExistingWrapper<JSFileException>(exec, impl))
        return result;
#if COMPILER(CLANG)
    // If you hit this failure the interface definition has the ImplementationLacksVTable
    // attribute. You should remove that attribute. If the class has subclasses
    // that may be passed through this toJS() function you should use the SkipVTableValidation
    // attribute to FileException.
    COMPILE_ASSERT(!__is_polymorphic(FileException), FileException_is_polymorphic_but_idl_claims_not_to_be);
#endif
    ReportMemoryCost<FileException>::reportMemoryCost(exec, impl);
    return createNewWrapper<JSFileException>(exec, globalObject, impl);
}

FileException* toFileException(JSC::JSValue value)
{
    return value.inherits(JSFileException::info()) ? &jsCast<JSFileException*>(value)->impl() : 0;
}

}

#endif // ENABLE(BLOB)
