/*
    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(INPUT_SPEECH)

#include "JSSpeechInputResult.h"

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

using namespace JSC;

namespace WebCore {

/* Hash table */

static const HashTableValue JSSpeechInputResultTableValues[] =
{
    { "utterance", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechInputResultUtterance), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "confidence", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSpeechInputResultConfidence), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSSpeechInputResultTable = { 4, 3, true, JSSpeechInputResultTableValues, 0 };
/* Hash table for prototype */

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

static const HashTable JSSpeechInputResultPrototypeTable = { 1, 0, false, JSSpeechInputResultPrototypeTableValues, 0 };
const ClassInfo JSSpeechInputResultPrototype::s_info = { "SpeechInputResultPrototype", &Base::s_info, &JSSpeechInputResultPrototypeTable, 0, CREATE_METHOD_TABLE(JSSpeechInputResultPrototype) };

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

const ClassInfo JSSpeechInputResult::s_info = { "SpeechInputResult", &Base::s_info, &JSSpeechInputResultTable, 0 , CREATE_METHOD_TABLE(JSSpeechInputResult) };

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

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

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

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

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

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

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


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


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

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

JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, SpeechInputResult* impl)
{
    if (!impl)
        return jsNull();
    if (JSValue result = getExistingWrapper<JSSpeechInputResult>(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 SpeechInputResult.
    COMPILE_ASSERT(!__is_polymorphic(SpeechInputResult), SpeechInputResult_is_polymorphic_but_idl_claims_not_to_be);
#endif
    ReportMemoryCost<SpeechInputResult>::reportMemoryCost(exec, impl);
    return createNewWrapper<JSSpeechInputResult>(exec, globalObject, impl);
}

SpeechInputResult* toSpeechInputResult(JSC::JSValue value)
{
    return value.inherits(JSSpeechInputResult::info()) ? &jsCast<JSSpeechInputResult*>(value)->impl() : 0;
}

}

#endif // ENABLE(INPUT_SPEECH)
