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

#include "DocumentType.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSNamedNodeMap.h"
#include "NamedNodeMap.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 JSDocumentTypeTableValues[] =
{
    { "name", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDocumentTypeName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "entities", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDocumentTypeEntities), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "notations", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDocumentTypeNotations), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "publicId", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDocumentTypePublicId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "systemId", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDocumentTypeSystemId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "internalSubset", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDocumentTypeInternalSubset), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDocumentTypeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSDocumentTypeTable = { 18, 15, true, JSDocumentTypeTableValues, 0 };
/* Hash table for constructor */

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

static const HashTable JSDocumentTypeConstructorTable = { 1, 0, false, JSDocumentTypeConstructorTableValues, 0 };
const ClassInfo JSDocumentTypeConstructor::s_info = { "DocumentTypeConstructor", &Base::s_info, &JSDocumentTypeConstructorTable, 0, CREATE_METHOD_TABLE(JSDocumentTypeConstructor) };

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

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

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

/* Hash table for prototype */

static const HashTableValue JSDocumentTypePrototypeTableValues[] =
{
    { "remove", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsDocumentTypePrototypeFunctionRemove), (intptr_t) (0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSDocumentTypePrototypeTable = { 2, 1, false, JSDocumentTypePrototypeTableValues, 0 };
const ClassInfo JSDocumentTypePrototype::s_info = { "DocumentTypePrototype", &Base::s_info, &JSDocumentTypePrototypeTable, 0, CREATE_METHOD_TABLE(JSDocumentTypePrototype) };

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

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

const ClassInfo JSDocumentType::s_info = { "DocumentType", &Base::s_info, &JSDocumentTypeTable, 0 , CREATE_METHOD_TABLE(JSDocumentType) };

JSDocumentType::JSDocumentType(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<DocumentType> impl)
    : JSNode(structure, globalObject, impl)
{
}

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

JSObject* JSDocumentType::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
    return JSDocumentTypePrototype::create(vm, globalObject, JSDocumentTypePrototype::createStructure(vm, globalObject, JSNodePrototype::self(vm, globalObject)));
}

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

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


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


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


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


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


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


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

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

EncodedJSValue JSC_HOST_CALL jsDocumentTypePrototypeFunctionRemove(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSDocumentType* castedThis = jsDynamicCast<JSDocumentType*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSDocumentType::info());
    DocumentType& impl = castedThis->impl();
    ExceptionCode ec = 0;
    impl.remove(ec);
    setDOMException(exec, ec);
    return JSValue::encode(jsUndefined());
}

DocumentType* toDocumentType(JSC::JSValue value)
{
    return value.inherits(JSDocumentType::info()) ? &jsCast<JSDocumentType*>(value)->impl() : 0;
}

}
