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

#include "CSSPrimitiveValue.h"
#include "JSCSSPrimitiveValue.h"
#include "RGBColor.h"
#include <wtf/GetPtr.h>

using namespace JSC;

namespace WebCore {

ASSERT_CLASS_FITS_IN_CELL(JSRGBColor);

/* Hash table */
#if ENABLE(JIT)
#define THUNK_GENERATOR(generator) , generator
#else
#define THUNK_GENERATOR(generator)
#endif

static const HashTableValue JSRGBColorTableValues[5] =
{
    { "red", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRGBColorRed), (intptr_t)0 THUNK_GENERATOR(0) },
    { "green", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRGBColorGreen), (intptr_t)0 THUNK_GENERATOR(0) },
    { "blue", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRGBColorBlue), (intptr_t)0 THUNK_GENERATOR(0) },
    { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRGBColorConstructor), (intptr_t)0 THUNK_GENERATOR(0) },
    { 0, 0, 0, 0 THUNK_GENERATOR(0) }
};

#undef THUNK_GENERATOR
static JSC_CONST_HASHTABLE HashTable JSRGBColorTable = { 8, 7, JSRGBColorTableValues, 0 };
/* Hash table for constructor */
#if ENABLE(JIT)
#define THUNK_GENERATOR(generator) , generator
#else
#define THUNK_GENERATOR(generator)
#endif

static const HashTableValue JSRGBColorConstructorTableValues[1] =
{
    { 0, 0, 0, 0 THUNK_GENERATOR(0) }
};

#undef THUNK_GENERATOR
static JSC_CONST_HASHTABLE HashTable JSRGBColorConstructorTable = { 1, 0, JSRGBColorConstructorTableValues, 0 };
class JSRGBColorConstructor : public DOMConstructorObject {
public:
    JSRGBColorConstructor(JSC::ExecState*, JSDOMGlobalObject*);

    virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&);
    virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&);
    virtual const JSC::ClassInfo* classInfo() const { return &s_info; }
    static const JSC::ClassInfo s_info;
    static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype)
    {
        return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount);
    }
protected:
    static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags;
};

const ClassInfo JSRGBColorConstructor::s_info = { "RGBColorConstructor", 0, &JSRGBColorConstructorTable, 0 };

JSRGBColorConstructor::JSRGBColorConstructor(ExecState* exec, JSDOMGlobalObject* globalObject)
    : DOMConstructorObject(JSRGBColorConstructor::createStructure(globalObject->objectPrototype()), globalObject)
{
    putDirect(exec->propertyNames().prototype, JSRGBColorPrototype::self(exec, globalObject), DontDelete | ReadOnly);
}

bool JSRGBColorConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
    return getStaticValueSlot<JSRGBColorConstructor, DOMObject>(exec, &JSRGBColorConstructorTable, this, propertyName, slot);
}

bool JSRGBColorConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
    return getStaticValueDescriptor<JSRGBColorConstructor, DOMObject>(exec, &JSRGBColorConstructorTable, this, propertyName, descriptor);
}

/* Hash table for prototype */
#if ENABLE(JIT)
#define THUNK_GENERATOR(generator) , generator
#else
#define THUNK_GENERATOR(generator)
#endif

static const HashTableValue JSRGBColorPrototypeTableValues[1] =
{
    { 0, 0, 0, 0 THUNK_GENERATOR(0) }
};

#undef THUNK_GENERATOR
static JSC_CONST_HASHTABLE HashTable JSRGBColorPrototypeTable = { 1, 0, JSRGBColorPrototypeTableValues, 0 };
const ClassInfo JSRGBColorPrototype::s_info = { "RGBColorPrototype", 0, &JSRGBColorPrototypeTable, 0 };

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

const ClassInfo JSRGBColor::s_info = { "RGBColor", 0, &JSRGBColorTable, 0 };

JSRGBColor::JSRGBColor(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<RGBColor> impl)
    : DOMObjectWithGlobalPointer(structure, globalObject)
    , m_impl(impl)
{
}

JSRGBColor::~JSRGBColor()
{
    forgetDOMObject(this, impl());
}

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

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

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

JSValue jsRGBColorRed(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSRGBColor* castedThis = static_cast<JSRGBColor*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    RGBColor* imp = static_cast<RGBColor*>(castedThis->impl());
    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->red()));
    return result;
}

JSValue jsRGBColorGreen(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSRGBColor* castedThis = static_cast<JSRGBColor*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    RGBColor* imp = static_cast<RGBColor*>(castedThis->impl());
    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->green()));
    return result;
}

JSValue jsRGBColorBlue(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSRGBColor* castedThis = static_cast<JSRGBColor*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    RGBColor* imp = static_cast<RGBColor*>(castedThis->impl());
    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->blue()));
    return result;
}

JSValue jsRGBColorConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSRGBColor* domObject = static_cast<JSRGBColor*>(asObject(slotBase));
    return JSRGBColor::getConstructor(exec, domObject->globalObject());
}
JSValue JSRGBColor::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
{
    return getDOMConstructor<JSRGBColorConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
}

JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, RGBColor* object)
{
    return getDOMObjectWrapper<JSRGBColor>(exec, globalObject, object);
}
RGBColor* toRGBColor(JSC::JSValue value)
{
    return value.inherits(&JSRGBColor::s_info) ? static_cast<JSRGBColor*>(asObject(value))->impl() : 0;
}

}
