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

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

using namespace JSC;

namespace WebCore {

/* Hash table */

static const HashTableValue JSClientRectTableValues[] =
{
    { "top", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsClientRectTop), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "right", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsClientRectRight), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "bottom", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsClientRectBottom), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "left", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsClientRectLeft), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "width", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsClientRectWidth), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "height", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsClientRectHeight), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsClientRectConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSClientRectTable = { 18, 15, true, JSClientRectTableValues, 0 };
/* Hash table for constructor */

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

static const HashTable JSClientRectConstructorTable = { 1, 0, false, JSClientRectConstructorTableValues, 0 };
const ClassInfo JSClientRectConstructor::s_info = { "ClientRectConstructor", &Base::s_info, &JSClientRectConstructorTable, 0, CREATE_METHOD_TABLE(JSClientRectConstructor) };

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

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

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

/* Hash table for prototype */

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

static const HashTable JSClientRectPrototypeTable = { 1, 0, false, JSClientRectPrototypeTableValues, 0 };
const ClassInfo JSClientRectPrototype::s_info = { "ClientRectPrototype", &Base::s_info, &JSClientRectPrototypeTable, 0, CREATE_METHOD_TABLE(JSClientRectPrototype) };

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

const ClassInfo JSClientRect::s_info = { "ClientRect", &Base::s_info, &JSClientRectTable, 0 , CREATE_METHOD_TABLE(JSClientRect) };

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

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

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

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

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

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

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


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


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


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


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


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


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

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

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

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

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

ClientRect* toClientRect(JSC::JSValue value)
{
    return value.inherits(JSClientRect::info()) ? &jsCast<JSClientRect*>(value)->impl() : 0;
}

}
