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

#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSNode.h"
#include "MutationEvent.h"
#include "Node.h"
#include "URL.h"
#include <runtime/Error.h>
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>

using namespace JSC;

namespace WebCore {

/* Hash table */

static const HashTableValue JSMutationEventTableValues[] =
{
    { "relatedNode", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventRelatedNode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "prevValue", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventPrevValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "newValue", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventNewValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "attrName", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventAttrName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "attrChange", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventAttrChange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSMutationEventTable = { 17, 15, true, JSMutationEventTableValues, 0 };
/* Hash table for constructor */

static const HashTableValue JSMutationEventConstructorTableValues[] =
{
    { "MODIFICATION", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventMODIFICATION), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "ADDITION", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventADDITION), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "REMOVAL", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventREMOVAL), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSMutationEventConstructorTable = { 8, 7, true, JSMutationEventConstructorTableValues, 0 };

COMPILE_ASSERT(1 == MutationEvent::MODIFICATION, MutationEventEnumMODIFICATIONIsWrongUseDoNotCheckConstants);
COMPILE_ASSERT(2 == MutationEvent::ADDITION, MutationEventEnumADDITIONIsWrongUseDoNotCheckConstants);
COMPILE_ASSERT(3 == MutationEvent::REMOVAL, MutationEventEnumREMOVALIsWrongUseDoNotCheckConstants);

const ClassInfo JSMutationEventConstructor::s_info = { "MutationEventConstructor", &Base::s_info, &JSMutationEventConstructorTable, 0, CREATE_METHOD_TABLE(JSMutationEventConstructor) };

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

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

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

/* Hash table for prototype */

static const HashTableValue JSMutationEventPrototypeTableValues[] =
{
    { "MODIFICATION", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventMODIFICATION), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "ADDITION", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventADDITION), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "REMOVAL", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventREMOVAL), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "initMutationEvent", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsMutationEventPrototypeFunctionInitMutationEvent), (intptr_t) (0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSMutationEventPrototypeTable = { 8, 7, true, JSMutationEventPrototypeTableValues, 0 };
const ClassInfo JSMutationEventPrototype::s_info = { "MutationEventPrototype", &Base::s_info, &JSMutationEventPrototypeTable, 0, CREATE_METHOD_TABLE(JSMutationEventPrototype) };

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

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

const ClassInfo JSMutationEvent::s_info = { "MutationEvent", &Base::s_info, &JSMutationEventTable, 0 , CREATE_METHOD_TABLE(JSMutationEvent) };

JSMutationEvent::JSMutationEvent(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<MutationEvent> impl)
    : JSEvent(structure, globalObject, impl)
{
}

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

JSObject* JSMutationEvent::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
    return JSMutationEventPrototype::create(vm, globalObject, JSMutationEventPrototype::createStructure(vm, globalObject, JSEventPrototype::self(vm, globalObject)));
}

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

EncodedJSValue jsMutationEventRelatedNode(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSMutationEvent* castedThis = jsDynamicCast<JSMutationEvent*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    MutationEvent& impl = castedThis->impl();
    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl.relatedNode()));
    return JSValue::encode(result);
}


EncodedJSValue jsMutationEventPrevValue(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSMutationEvent* castedThis = jsDynamicCast<JSMutationEvent*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    MutationEvent& impl = castedThis->impl();
    JSValue result = jsStringWithCache(exec, impl.prevValue());
    return JSValue::encode(result);
}


EncodedJSValue jsMutationEventNewValue(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSMutationEvent* castedThis = jsDynamicCast<JSMutationEvent*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    MutationEvent& impl = castedThis->impl();
    JSValue result = jsStringWithCache(exec, impl.newValue());
    return JSValue::encode(result);
}


EncodedJSValue jsMutationEventAttrName(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSMutationEvent* castedThis = jsDynamicCast<JSMutationEvent*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    MutationEvent& impl = castedThis->impl();
    JSValue result = jsStringWithCache(exec, impl.attrName());
    return JSValue::encode(result);
}


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


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

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

EncodedJSValue JSC_HOST_CALL jsMutationEventPrototypeFunctionInitMutationEvent(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSMutationEvent* castedThis = jsDynamicCast<JSMutationEvent*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSMutationEvent::info());
    MutationEvent& impl = castedThis->impl();
    const String& type(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    bool canBubble(exec->argument(1).toBoolean(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    bool cancelable(exec->argument(2).toBoolean(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    Node* relatedNode(toNode(exec->argument(3)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    const String& prevValue(exec->argument(4).isEmpty() ? String() : exec->argument(4).toString(exec)->value(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    const String& newValue(exec->argument(5).isEmpty() ? String() : exec->argument(5).toString(exec)->value(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    const String& attrName(exec->argument(6).isEmpty() ? String() : exec->argument(6).toString(exec)->value(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    uint16_t attrChange(toUInt16(exec, exec->argument(7), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl.initMutationEvent(type, canBubble, cancelable, relatedNode, prevValue, newValue, attrName, attrChange);
    return JSValue::encode(jsUndefined());
}

// Constant getters

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

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

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


}
