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

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

using namespace JSC;

namespace WebCore {

/* Hash table */

static const HashTableValue JSCSSCharsetRuleTableValues[] =
{
    { "encoding", DontDelete, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSCharsetRuleEncoding), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCSSCharsetRuleEncoding) },
    { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSCharsetRuleConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSCSSCharsetRuleTable = { 4, 3, true, JSCSSCharsetRuleTableValues, 0 };
/* Hash table for constructor */

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

static const HashTable JSCSSCharsetRuleConstructorTable = { 1, 0, false, JSCSSCharsetRuleConstructorTableValues, 0 };
const ClassInfo JSCSSCharsetRuleConstructor::s_info = { "CSSCharsetRuleConstructor", &Base::s_info, &JSCSSCharsetRuleConstructorTable, 0, CREATE_METHOD_TABLE(JSCSSCharsetRuleConstructor) };

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

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

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

/* Hash table for prototype */

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

static const HashTable JSCSSCharsetRulePrototypeTable = { 1, 0, false, JSCSSCharsetRulePrototypeTableValues, 0 };
const ClassInfo JSCSSCharsetRulePrototype::s_info = { "CSSCharsetRulePrototype", &Base::s_info, &JSCSSCharsetRulePrototypeTable, 0, CREATE_METHOD_TABLE(JSCSSCharsetRulePrototype) };

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

const ClassInfo JSCSSCharsetRule::s_info = { "CSSCharsetRule", &Base::s_info, &JSCSSCharsetRuleTable, 0 , CREATE_METHOD_TABLE(JSCSSCharsetRule) };

JSCSSCharsetRule::JSCSSCharsetRule(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<CSSCharsetRule> impl)
    : JSCSSRule(structure, globalObject, impl)
{
}

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

JSObject* JSCSSCharsetRule::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
    return JSCSSCharsetRulePrototype::create(vm, globalObject, JSCSSCharsetRulePrototype::createStructure(vm, globalObject, JSCSSRulePrototype::self(vm, globalObject)));
}

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

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


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

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


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


}
