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

#include "ValidityState.h"
#include <wtf/GetPtr.h>

using namespace JSC;

namespace WebCore {

/* Hash table */

static const HashTableValue JSValidityStateTableValues[] =
{
    { "valueMissing", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateValueMissing), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "typeMismatch", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateTypeMismatch), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "patternMismatch", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStatePatternMismatch), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "tooLong", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateTooLong), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "rangeUnderflow", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateRangeUnderflow), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "rangeOverflow", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateRangeOverflow), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "stepMismatch", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateStepMismatch), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "badInput", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateBadInput), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "customError", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateCustomError), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "valid", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsValidityStateValid), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSValidityStateTable = { 35, 31, true, JSValidityStateTableValues, 0 };
/* Hash table for prototype */

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

static const HashTable JSValidityStatePrototypeTable = { 1, 0, false, JSValidityStatePrototypeTableValues, 0 };
const ClassInfo JSValidityStatePrototype::s_info = { "ValidityStatePrototype", &Base::s_info, &JSValidityStatePrototypeTable, 0, CREATE_METHOD_TABLE(JSValidityStatePrototype) };

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

const ClassInfo JSValidityState::s_info = { "ValidityState", &Base::s_info, &JSValidityStateTable, 0 , CREATE_METHOD_TABLE(JSValidityState) };

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

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

JSObject* JSValidityState::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
    return JSValidityStatePrototype::create(vm, globalObject, JSValidityStatePrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}

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

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

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

EncodedJSValue jsValidityStateValueMissing(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSValidityState* castedThis = jsDynamicCast<JSValidityState*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    ValidityState& impl = castedThis->impl();
    JSValue result = jsBoolean(impl.valueMissing());
    return JSValue::encode(result);
}


EncodedJSValue jsValidityStateTypeMismatch(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSValidityState* castedThis = jsDynamicCast<JSValidityState*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    ValidityState& impl = castedThis->impl();
    JSValue result = jsBoolean(impl.typeMismatch());
    return JSValue::encode(result);
}


EncodedJSValue jsValidityStatePatternMismatch(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSValidityState* castedThis = jsDynamicCast<JSValidityState*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    ValidityState& impl = castedThis->impl();
    JSValue result = jsBoolean(impl.patternMismatch());
    return JSValue::encode(result);
}


EncodedJSValue jsValidityStateTooLong(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSValidityState* castedThis = jsDynamicCast<JSValidityState*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    ValidityState& impl = castedThis->impl();
    JSValue result = jsBoolean(impl.tooLong());
    return JSValue::encode(result);
}


EncodedJSValue jsValidityStateRangeUnderflow(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSValidityState* castedThis = jsDynamicCast<JSValidityState*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    ValidityState& impl = castedThis->impl();
    JSValue result = jsBoolean(impl.rangeUnderflow());
    return JSValue::encode(result);
}


EncodedJSValue jsValidityStateRangeOverflow(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSValidityState* castedThis = jsDynamicCast<JSValidityState*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    ValidityState& impl = castedThis->impl();
    JSValue result = jsBoolean(impl.rangeOverflow());
    return JSValue::encode(result);
}


EncodedJSValue jsValidityStateStepMismatch(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSValidityState* castedThis = jsDynamicCast<JSValidityState*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    ValidityState& impl = castedThis->impl();
    JSValue result = jsBoolean(impl.stepMismatch());
    return JSValue::encode(result);
}


EncodedJSValue jsValidityStateBadInput(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSValidityState* castedThis = jsDynamicCast<JSValidityState*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    ValidityState& impl = castedThis->impl();
    JSValue result = jsBoolean(impl.badInput());
    return JSValue::encode(result);
}


EncodedJSValue jsValidityStateCustomError(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSValidityState* castedThis = jsDynamicCast<JSValidityState*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    ValidityState& impl = castedThis->impl();
    JSValue result = jsBoolean(impl.customError());
    return JSValue::encode(result);
}


EncodedJSValue jsValidityStateValid(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSValidityState* castedThis = jsDynamicCast<JSValidityState*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    ValidityState& impl = castedThis->impl();
    JSValue result = jsBoolean(impl.valid());
    return JSValue::encode(result);
}


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

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

JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, ValidityState* impl)
{
    if (!impl)
        return jsNull();
    if (JSValue result = getExistingWrapper<JSValidityState>(exec, impl))
        return result;
    ReportMemoryCost<ValidityState>::reportMemoryCost(exec, impl);
    return createNewWrapper<JSValidityState>(exec, globalObject, impl);
}

ValidityState* toValidityState(JSC::JSValue value)
{
    return value.inherits(JSValidityState::info()) ? &jsCast<JSValidityState*>(value)->impl() : 0;
}

}
