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

#include "CapabilityRange.h"
#include <wtf/GetPtr.h>

using namespace JSC;

namespace WebCore {

/* Hash table */

static const HashTableValue JSCapabilityRangeTableValues[] =
{
    { "max", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCapabilityRangeMax), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "min", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCapabilityRangeMin), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "supported", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCapabilityRangeSupported), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSCapabilityRangeTable = { 10, 7, true, JSCapabilityRangeTableValues, 0 };
/* Hash table for prototype */

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

static const HashTable JSCapabilityRangePrototypeTable = { 1, 0, false, JSCapabilityRangePrototypeTableValues, 0 };
const ClassInfo JSCapabilityRangePrototype::s_info = { "CapabilityRangePrototype", &Base::s_info, &JSCapabilityRangePrototypeTable, 0, CREATE_METHOD_TABLE(JSCapabilityRangePrototype) };

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

const ClassInfo JSCapabilityRange::s_info = { "CapabilityRange", &Base::s_info, &JSCapabilityRangeTable, 0 , CREATE_METHOD_TABLE(JSCapabilityRange) };

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

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

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

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

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

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

EncodedJSValue jsCapabilityRangeMax(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSCapabilityRange* castedThis = jsDynamicCast<JSCapabilityRange*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    CapabilityRange& impl = castedThis->impl();
    JSValue result = (impl.max(exec).hasNoValue() ? jsNull() : impl.max(exec).jsValue());
    return JSValue::encode(result);
}


EncodedJSValue jsCapabilityRangeMin(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSCapabilityRange* castedThis = jsDynamicCast<JSCapabilityRange*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    CapabilityRange& impl = castedThis->impl();
    JSValue result = (impl.min(exec).hasNoValue() ? jsNull() : impl.min(exec).jsValue());
    return JSValue::encode(result);
}


EncodedJSValue jsCapabilityRangeSupported(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSCapabilityRange* castedThis = jsDynamicCast<JSCapabilityRange*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    CapabilityRange& impl = castedThis->impl();
    JSValue result = jsBoolean(impl.supported());
    return JSValue::encode(result);
}


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

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

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

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

CapabilityRange* toCapabilityRange(JSC::JSValue value)
{
    return value.inherits(JSCapabilityRange::info()) ? &jsCast<JSCapabilityRange*>(value)->impl() : 0;
}

}

#endif // ENABLE(MEDIA_STREAM)
