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

#include "CSSValue.h"
#include "URL.h"
#include <wtf/GetPtr.h>

using namespace JSC;

namespace WebCore {

/* Hash table */

static const HashTableValue JSCSSValueTableValues[] =
{
    { "cssText", DontDelete, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSValueCssText), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCSSValueCssText) },
    { "cssValueType", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSValueCssValueType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSValueConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSCSSValueTable = { 8, 7, true, JSCSSValueTableValues, 0 };
/* Hash table for constructor */

static const HashTableValue JSCSSValueConstructorTableValues[] =
{
    { "CSS_INHERIT", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSValueCSS_INHERIT), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "CSS_PRIMITIVE_VALUE", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSValueCSS_PRIMITIVE_VALUE), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "CSS_VALUE_LIST", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSValueCSS_VALUE_LIST), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "CSS_CUSTOM", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSValueCSS_CUSTOM), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSCSSValueConstructorTable = { 8, 7, true, JSCSSValueConstructorTableValues, 0 };

COMPILE_ASSERT(0 == CSSValue::CSS_INHERIT, CSSValueEnumCSS_INHERITIsWrongUseDoNotCheckConstants);
COMPILE_ASSERT(1 == CSSValue::CSS_PRIMITIVE_VALUE, CSSValueEnumCSS_PRIMITIVE_VALUEIsWrongUseDoNotCheckConstants);
COMPILE_ASSERT(2 == CSSValue::CSS_VALUE_LIST, CSSValueEnumCSS_VALUE_LISTIsWrongUseDoNotCheckConstants);
COMPILE_ASSERT(3 == CSSValue::CSS_CUSTOM, CSSValueEnumCSS_CUSTOMIsWrongUseDoNotCheckConstants);

const ClassInfo JSCSSValueConstructor::s_info = { "CSSValueConstructor", &Base::s_info, &JSCSSValueConstructorTable, 0, CREATE_METHOD_TABLE(JSCSSValueConstructor) };

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

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

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

/* Hash table for prototype */

static const HashTableValue JSCSSValuePrototypeTableValues[] =
{
    { "CSS_INHERIT", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSValueCSS_INHERIT), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "CSS_PRIMITIVE_VALUE", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSValueCSS_PRIMITIVE_VALUE), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "CSS_VALUE_LIST", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSValueCSS_VALUE_LIST), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "CSS_CUSTOM", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSValueCSS_CUSTOM), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSCSSValuePrototypeTable = { 8, 7, true, JSCSSValuePrototypeTableValues, 0 };
const ClassInfo JSCSSValuePrototype::s_info = { "CSSValuePrototype", &Base::s_info, &JSCSSValuePrototypeTable, 0, CREATE_METHOD_TABLE(JSCSSValuePrototype) };

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

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

const ClassInfo JSCSSValue::s_info = { "CSSValue", &Base::s_info, &JSCSSValueTable, 0 , CREATE_METHOD_TABLE(JSCSSValue) };

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

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

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

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

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

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

EncodedJSValue jsCSSValueCssText(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSCSSValue* castedThis = jsDynamicCast<JSCSSValue*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    CSSValue& impl = castedThis->impl();
    JSValue result = jsStringOrNull(exec, impl.cssText());
    return JSValue::encode(result);
}


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


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

void setJSCSSValueCssText(ExecState* exec, JSObject* /* baseObject */, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
    JSValue value = JSValue::decode(encodedValue);
    UNUSED_PARAM(exec);
    JSCSSValue* castedThis = jsDynamicCast<JSCSSValue*>(JSValue::decode(thisValue));
    if (!castedThis) {
        throwVMTypeError(exec);
        return;
    }
    CSSValue& impl = castedThis->impl();
    ExceptionCode ec = 0;
    const String& nativeValue(valueToStringWithNullCheck(exec, value));
    if (exec->hadException())
        return;
    impl.setCssText(nativeValue, ec);
    setDOMException(exec, ec);
}


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

// Constant getters

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

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

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

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

CSSValue* toCSSValue(JSC::JSValue value)
{
    return value.inherits(JSCSSValue::info()) ? &jsCast<JSCSSValue*>(value)->impl() : 0;
}

}
