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

#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "RangeException.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 JSRangeExceptionTableValues[] =
{
    { "code", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeExceptionCode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "name", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeExceptionName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "message", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeExceptionMessage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeExceptionConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSRangeExceptionTable = { 10, 7, true, JSRangeExceptionTableValues, 0 };
/* Hash table for constructor */

static const HashTableValue JSRangeExceptionConstructorTableValues[] =
{
    { "BAD_BOUNDARYPOINTS_ERR", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeExceptionBAD_BOUNDARYPOINTS_ERR), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "INVALID_NODE_TYPE_ERR", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeExceptionINVALID_NODE_TYPE_ERR), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSRangeExceptionConstructorTable = { 4, 3, true, JSRangeExceptionConstructorTableValues, 0 };
const ClassInfo JSRangeExceptionConstructor::s_info = { "RangeExceptionConstructor", &Base::s_info, &JSRangeExceptionConstructorTable, 0, CREATE_METHOD_TABLE(JSRangeExceptionConstructor) };

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

void JSRangeExceptionConstructor::finishCreation(VM& vm, JSDOMGlobalObject* globalObject)
{
    Base::finishCreation(vm);
    ASSERT(inherits(info()));
    putDirect(vm, vm.propertyNames->prototype, JSRangeExceptionPrototype::self(vm, globalObject), DontDelete | ReadOnly);
    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
}

bool JSRangeExceptionConstructor::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
    return getStaticValueSlot<JSRangeExceptionConstructor, JSDOMWrapper>(exec, JSRangeExceptionConstructorTable, jsCast<JSRangeExceptionConstructor*>(object), propertyName, slot);
}

/* Hash table for prototype */

static const HashTableValue JSRangeExceptionPrototypeTableValues[] =
{
    { "BAD_BOUNDARYPOINTS_ERR", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeExceptionBAD_BOUNDARYPOINTS_ERR), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "INVALID_NODE_TYPE_ERR", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeExceptionINVALID_NODE_TYPE_ERR), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "toString", DontEnum | JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsRangeExceptionPrototypeFunctionToString), (intptr_t) (0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSRangeExceptionPrototypeTable = { 8, 7, true, JSRangeExceptionPrototypeTableValues, 0 };
const ClassInfo JSRangeExceptionPrototype::s_info = { "RangeExceptionPrototype", &Base::s_info, &JSRangeExceptionPrototypeTable, 0, CREATE_METHOD_TABLE(JSRangeExceptionPrototype) };

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

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

const ClassInfo JSRangeException::s_info = { "RangeException", &Base::s_info, &JSRangeExceptionTable, 0 , CREATE_METHOD_TABLE(JSRangeException) };

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

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

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

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

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

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

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


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


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


EncodedJSValue jsRangeExceptionConstructor(ExecState* exec, EncodedJSValue thisValue, EncodedJSValue, PropertyName)
{
    JSRangeException* domObject = jsDynamicCast<JSRangeException*>(JSValue::decode(thisValue));
    if (!domObject)
        return throwVMTypeError(exec);
    if (!domObject)
        return throwVMTypeError(exec);
    return JSValue::encode(JSRangeException::getConstructor(exec->vm(), domObject->globalObject()));
}

JSValue JSRangeException::getConstructor(VM& vm, JSGlobalObject* globalObject)
{
    return getDOMConstructor<JSRangeExceptionConstructor>(vm, jsCast<JSDOMGlobalObject*>(globalObject));
}

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

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

// Constant getters

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

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

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

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

JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, RangeException* impl)
{
    if (!impl)
        return jsNull();
    if (JSValue result = getExistingWrapper<JSRangeException>(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 RangeException.
    COMPILE_ASSERT(!__is_polymorphic(RangeException), RangeException_is_polymorphic_but_idl_claims_not_to_be);
#endif
    ReportMemoryCost<RangeException>::reportMemoryCost(exec, impl);
    return createNewWrapper<JSRangeException>(exec, globalObject, impl);
}

RangeException* toRangeException(JSC::JSValue value)
{
    return value.inherits(JSRangeException::info()) ? &jsCast<JSRangeException*>(value)->impl() : 0;
}

}
