/*
    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(SVG)

#include "JSSVGRect.h"

#include <runtime/JSNumberCell.h>
#include <wtf/GetPtr.h>

using namespace JSC;

namespace WebCore {

ASSERT_CLASS_FITS_IN_CELL(JSSVGRect);

/* Hash table */

static const HashTableValue JSSVGRectTableValues[5] =
{
    { "x", DontDelete, (intptr_t)jsSVGRectX, (intptr_t)setJSSVGRectX },
    { "y", DontDelete, (intptr_t)jsSVGRectY, (intptr_t)setJSSVGRectY },
    { "width", DontDelete, (intptr_t)jsSVGRectWidth, (intptr_t)setJSSVGRectWidth },
    { "height", DontDelete, (intptr_t)jsSVGRectHeight, (intptr_t)setJSSVGRectHeight },
    { 0, 0, 0, 0 }
};

static JSC_CONST_HASHTABLE HashTable JSSVGRectTable =
#if ENABLE(PERFECT_HASH_SIZE)
    { 15, JSSVGRectTableValues, 0 };
#else
    { 9, 7, JSSVGRectTableValues, 0 };
#endif

/* Hash table for prototype */

static const HashTableValue JSSVGRectPrototypeTableValues[1] =
{
    { 0, 0, 0, 0 }
};

static JSC_CONST_HASHTABLE HashTable JSSVGRectPrototypeTable =
#if ENABLE(PERFECT_HASH_SIZE)
    { 0, JSSVGRectPrototypeTableValues, 0 };
#else
    { 1, 0, JSSVGRectPrototypeTableValues, 0 };
#endif

const ClassInfo JSSVGRectPrototype::s_info = { "SVGRectPrototype", 0, &JSSVGRectPrototypeTable, 0 };

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

const ClassInfo JSSVGRect::s_info = { "SVGRect", 0, &JSSVGRectTable, 0 };

JSSVGRect::JSSVGRect(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<JSSVGPODTypeWrapper<FloatRect> > impl, SVGElement* context)
    : DOMObjectWithSVGContext(structure, globalObject, context)
    , m_impl(impl)
{
}

JSSVGRect::~JSSVGRect()
{
    JSSVGDynamicPODTypeWrapperCache<FloatRect, SVGAnimatedRect>::forgetWrapper(m_impl.get());
    forgetDOMObject(*Heap::heap(this)->globalData(), impl());
}

JSObject* JSSVGRect::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
{
    return new (exec) JSSVGRectPrototype(JSSVGRectPrototype::createStructure(globalObject->objectPrototype()));
}

bool JSSVGRect::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
    return getStaticValueSlot<JSSVGRect, Base>(exec, &JSSVGRectTable, this, propertyName, slot);
}

bool JSSVGRect::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
    return getStaticValueDescriptor<JSSVGRect, Base>(exec, &JSSVGRectTable, this, propertyName, descriptor);
}

JSValue jsSVGRectX(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
    JSSVGRect* castedThis = static_cast<JSSVGRect*>(asObject(slot.slotBase()));
    UNUSED_PARAM(exec);
    FloatRect imp(*castedThis->impl());
    return jsNumber(exec, imp.x());
}

JSValue jsSVGRectY(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
    JSSVGRect* castedThis = static_cast<JSSVGRect*>(asObject(slot.slotBase()));
    UNUSED_PARAM(exec);
    FloatRect imp(*castedThis->impl());
    return jsNumber(exec, imp.y());
}

JSValue jsSVGRectWidth(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
    JSSVGRect* castedThis = static_cast<JSSVGRect*>(asObject(slot.slotBase()));
    UNUSED_PARAM(exec);
    FloatRect imp(*castedThis->impl());
    return jsNumber(exec, imp.width());
}

JSValue jsSVGRectHeight(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
    JSSVGRect* castedThis = static_cast<JSSVGRect*>(asObject(slot.slotBase()));
    UNUSED_PARAM(exec);
    FloatRect imp(*castedThis->impl());
    return jsNumber(exec, imp.height());
}

void JSSVGRect::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
{
    lookupPut<JSSVGRect, Base>(exec, propertyName, value, &JSSVGRectTable, this, slot);
}

void setJSSVGRectX(ExecState* exec, JSObject* thisObject, JSValue value)
{
    FloatRect imp(*static_cast<JSSVGRect*>(thisObject)->impl());
    imp.setX(value.toFloat(exec));
        static_cast<JSSVGRect*>(thisObject)->impl()->commitChange(imp, static_cast<JSSVGRect*>(thisObject)->context());
}

void setJSSVGRectY(ExecState* exec, JSObject* thisObject, JSValue value)
{
    FloatRect imp(*static_cast<JSSVGRect*>(thisObject)->impl());
    imp.setY(value.toFloat(exec));
        static_cast<JSSVGRect*>(thisObject)->impl()->commitChange(imp, static_cast<JSSVGRect*>(thisObject)->context());
}

void setJSSVGRectWidth(ExecState* exec, JSObject* thisObject, JSValue value)
{
    FloatRect imp(*static_cast<JSSVGRect*>(thisObject)->impl());
    imp.setWidth(value.toFloat(exec));
        static_cast<JSSVGRect*>(thisObject)->impl()->commitChange(imp, static_cast<JSSVGRect*>(thisObject)->context());
}

void setJSSVGRectHeight(ExecState* exec, JSObject* thisObject, JSValue value)
{
    FloatRect imp(*static_cast<JSSVGRect*>(thisObject)->impl());
    imp.setHeight(value.toFloat(exec));
        static_cast<JSSVGRect*>(thisObject)->impl()->commitChange(imp, static_cast<JSSVGRect*>(thisObject)->context());
}

JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, JSSVGPODTypeWrapper<FloatRect>* object, SVGElement* context)
{
    return getDOMObjectWrapper<JSSVGRect, JSSVGPODTypeWrapper<FloatRect> >(exec, globalObject, object, context);
}
FloatRect toSVGRect(JSC::JSValue value)
{
    return value.inherits(&JSSVGRect::s_info) ? (FloatRect) *static_cast<JSSVGRect*>(asObject(value))->impl() : FloatRect();
}

}

#endif // ENABLE(SVG)
