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

#include "DOMMimeType.h"
#include "DOMPlugin.h"
#include "JSDOMPlugin.h"
#include "URL.h"
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>

using namespace JSC;

namespace WebCore {

/* Hash table */

static const HashTableValue JSDOMMimeTypeTableValues[] =
{
    { "type", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMMimeTypeType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "suffixes", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMMimeTypeSuffixes), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "description", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMMimeTypeDescription), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "enabledPlugin", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMMimeTypeEnabledPlugin), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMMimeTypeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSDOMMimeTypeTable = { 16, 15, true, JSDOMMimeTypeTableValues, 0 };
/* Hash table for constructor */

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

static const HashTable JSDOMMimeTypeConstructorTable = { 1, 0, false, JSDOMMimeTypeConstructorTableValues, 0 };
const ClassInfo JSDOMMimeTypeConstructor::s_info = { "MimeTypeConstructor", &Base::s_info, &JSDOMMimeTypeConstructorTable, 0, CREATE_METHOD_TABLE(JSDOMMimeTypeConstructor) };

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

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

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

/* Hash table for prototype */

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

static const HashTable JSDOMMimeTypePrototypeTable = { 1, 0, false, JSDOMMimeTypePrototypeTableValues, 0 };
const ClassInfo JSDOMMimeTypePrototype::s_info = { "MimeTypePrototype", &Base::s_info, &JSDOMMimeTypePrototypeTable, 0, CREATE_METHOD_TABLE(JSDOMMimeTypePrototype) };

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

const ClassInfo JSDOMMimeType::s_info = { "MimeType", &Base::s_info, &JSDOMMimeTypeTable, 0 , CREATE_METHOD_TABLE(JSDOMMimeType) };

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

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

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

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

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

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

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


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


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


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


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

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

bool JSDOMMimeTypeOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
    UNUSED_PARAM(handle);
    UNUSED_PARAM(visitor);
    return false;
}

void JSDOMMimeTypeOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
    JSDOMMimeType* jsDOMMimeType = jsCast<JSDOMMimeType*>(handle.get().asCell());
    DOMWrapperWorld& world = *static_cast<DOMWrapperWorld*>(context);
    uncacheWrapper(world, &jsDOMMimeType->impl(), jsDOMMimeType);
    jsDOMMimeType->releaseImpl();
}

#if ENABLE(BINDING_INTEGRITY)
#if PLATFORM(WIN)
#pragma warning(disable: 4483)
extern "C" { extern void (*const __identifier("??_7DOMMimeType@WebCore@@6B@")[])(); }
#else
extern "C" { extern void* _ZTVN7WebCore11DOMMimeTypeE[]; }
#endif
#endif
JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, DOMMimeType* impl)
{
    if (!impl)
        return jsNull();
    if (JSValue result = getExistingWrapper<JSDOMMimeType>(exec, impl))
        return result;

#if ENABLE(BINDING_INTEGRITY)
    void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
#if PLATFORM(WIN)
    void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7DOMMimeType@WebCore@@6B@"));
#else
    void* expectedVTablePointer = &_ZTVN7WebCore11DOMMimeTypeE[2];
#if COMPILER(CLANG)
    // If this fails DOMMimeType does not have a vtable, so you need to add the
    // ImplementationLacksVTable attribute to the interface definition
    COMPILE_ASSERT(__is_polymorphic(DOMMimeType), DOMMimeType_is_not_polymorphic);
#endif
#endif
    // If you hit this assertion you either have a use after free bug, or
    // DOMMimeType has subclasses. If DOMMimeType has subclasses that get passed
    // to toJS() we currently require DOMMimeType you to opt out of binding hardening
    // by adding the SkipVTableValidation attribute to the interface IDL definition
    RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
#endif
    ReportMemoryCost<DOMMimeType>::reportMemoryCost(exec, impl);
    return createNewWrapper<JSDOMMimeType>(exec, globalObject, impl);
}

DOMMimeType* toDOMMimeType(JSC::JSValue value)
{
    return value.inherits(JSDOMMimeType::info()) ? &jsCast<JSDOMMimeType*>(value)->impl() : 0;
}

}
