/*
    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"

#if ENABLE(MEDIA_STREAM)

#include "JSMediaSourceStates.h"

#include "MediaSourceStates.h"
#include "URL.h"
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>

using namespace JSC;

namespace WebCore {

/* Hash table */

static const HashTableValue JSMediaSourceStatesTableValues[] =
{
    { "sourceType", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaSourceStatesSourceType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "sourceId", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaSourceStatesSourceId), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "width", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaSourceStatesWidth), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "height", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaSourceStatesHeight), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "frameRate", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaSourceStatesFrameRate), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "aspectRatio", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaSourceStatesAspectRatio), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "facingMode", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaSourceStatesFacingMode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "volume", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaSourceStatesVolume), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSMediaSourceStatesTable = { 17, 15, true, JSMediaSourceStatesTableValues, 0 };
/* Hash table for prototype */

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

static const HashTable JSMediaSourceStatesPrototypeTable = { 1, 0, false, JSMediaSourceStatesPrototypeTableValues, 0 };
const ClassInfo JSMediaSourceStatesPrototype::s_info = { "MediaSourceStatesPrototype", &Base::s_info, &JSMediaSourceStatesPrototypeTable, 0, CREATE_METHOD_TABLE(JSMediaSourceStatesPrototype) };

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

const ClassInfo JSMediaSourceStates::s_info = { "MediaSourceStates", &Base::s_info, &JSMediaSourceStatesTable, 0 , CREATE_METHOD_TABLE(JSMediaSourceStates) };

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

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

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

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

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

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

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


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


EncodedJSValue jsMediaSourceStatesWidth(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSMediaSourceStates* castedThis = jsDynamicCast<JSMediaSourceStates*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    return JSValue::encode(castedThis->width(exec));
}


EncodedJSValue jsMediaSourceStatesHeight(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSMediaSourceStates* castedThis = jsDynamicCast<JSMediaSourceStates*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    return JSValue::encode(castedThis->height(exec));
}


EncodedJSValue jsMediaSourceStatesFrameRate(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSMediaSourceStates* castedThis = jsDynamicCast<JSMediaSourceStates*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    return JSValue::encode(castedThis->frameRate(exec));
}


EncodedJSValue jsMediaSourceStatesAspectRatio(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSMediaSourceStates* castedThis = jsDynamicCast<JSMediaSourceStates*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    return JSValue::encode(castedThis->aspectRatio(exec));
}


EncodedJSValue jsMediaSourceStatesFacingMode(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSMediaSourceStates* castedThis = jsDynamicCast<JSMediaSourceStates*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    return JSValue::encode(castedThis->facingMode(exec));
}


EncodedJSValue jsMediaSourceStatesVolume(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSMediaSourceStates* castedThis = jsDynamicCast<JSMediaSourceStates*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    return JSValue::encode(castedThis->volume(exec));
}


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

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

JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, MediaSourceStates* impl)
{
    if (!impl)
        return jsNull();
    if (JSValue result = getExistingWrapper<JSMediaSourceStates>(exec, impl))
        return result;
#if COMPILER(CLANG)
    // If you hit this failure the interface definition has the ImplementationLacksVTable
    // attribute. You should remove that attribute. If the class has subclasses
    // that may be passed through this toJS() function you should use the SkipVTableValidation
    // attribute to MediaSourceStates.
    COMPILE_ASSERT(!__is_polymorphic(MediaSourceStates), MediaSourceStates_is_polymorphic_but_idl_claims_not_to_be);
#endif
    ReportMemoryCost<MediaSourceStates>::reportMemoryCost(exec, impl);
    return createNewWrapper<JSMediaSourceStates>(exec, globalObject, impl);
}

MediaSourceStates* toMediaSourceStates(JSC::JSValue value)
{
    return value.inherits(JSMediaSourceStates::info()) ? &jsCast<JSMediaSourceStates*>(value)->impl() : 0;
}

}

#endif // ENABLE(MEDIA_STREAM)
