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

#include "JSInspectorFrontendHost.h"

#include "Event.h"
#include "ExceptionCode.h"
#include "InspectorFrontendHost.h"
#include "JSDOMBinding.h"
#include "JSEvent.h"
#include "URL.h"
#include <runtime/Error.h>
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>

using namespace JSC;

namespace WebCore {

/* Hash table for prototype */

static const HashTableValue JSInspectorFrontendHostPrototypeTableValues[] =
{
    { "loaded", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionLoaded), (intptr_t) (0) },
    { "closeWindow", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionCloseWindow), (intptr_t) (0) },
    { "bringToFront", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionBringToFront), (intptr_t) (0) },
    { "setZoomFactor", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionSetZoomFactor), (intptr_t) (1) },
    { "inspectedURLChanged", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionInspectedURLChanged), (intptr_t) (1) },
    { "requestSetDockSide", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionRequestSetDockSide), (intptr_t) (1) },
    { "setAttachedWindowHeight", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionSetAttachedWindowHeight), (intptr_t) (1) },
    { "setAttachedWindowWidth", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionSetAttachedWindowWidth), (intptr_t) (1) },
    { "setToolbarHeight", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionSetToolbarHeight), (intptr_t) (1) },
    { "moveWindowBy", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionMoveWindowBy), (intptr_t) (2) },
    { "localizedStringsURL", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionLocalizedStringsURL), (intptr_t) (0) },
    { "debuggableType", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionDebuggableType), (intptr_t) (0) },
    { "copyText", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionCopyText), (intptr_t) (1) },
    { "openInNewTab", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionOpenInNewTab), (intptr_t) (1) },
    { "canSave", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionCanSave), (intptr_t) (0) },
    { "save", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionSave), (intptr_t) (4) },
    { "append", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionAppend), (intptr_t) (2) },
    { "close", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionClose), (intptr_t) (1) },
    { "platform", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionPlatform), (intptr_t) (0) },
    { "port", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionPort), (intptr_t) (0) },
    { "showContextMenu", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionShowContextMenu), (intptr_t) (2) },
    { "dispatchEventAsContextMenuEvent", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionDispatchEventAsContextMenuEvent), (intptr_t) (1) },
    { "sendMessageToBackend", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionSendMessageToBackend), (intptr_t) (1) },
    { "recordActionTaken", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionRecordActionTaken), (intptr_t) (1) },
    { "recordPanelShown", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionRecordPanelShown), (intptr_t) (1) },
    { "recordSettingChanged", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionRecordSettingChanged), (intptr_t) (1) },
    { "loadResourceSynchronously", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionLoadResourceSynchronously), (intptr_t) (1) },
    { "isUnderTest", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionIsUnderTest), (intptr_t) (0) },
    { "beep", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionBeep), (intptr_t) (0) },
    { "canInspectWorkers", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionCanInspectWorkers), (intptr_t) (0) },
    { "canSaveAs", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsInspectorFrontendHostPrototypeFunctionCanSaveAs), (intptr_t) (0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSInspectorFrontendHostPrototypeTable = { 70, 63, false, JSInspectorFrontendHostPrototypeTableValues, 0 };
const ClassInfo JSInspectorFrontendHostPrototype::s_info = { "InspectorFrontendHostPrototype", &Base::s_info, &JSInspectorFrontendHostPrototypeTable, 0, CREATE_METHOD_TABLE(JSInspectorFrontendHostPrototype) };

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

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

const ClassInfo JSInspectorFrontendHost::s_info = { "InspectorFrontendHost", &Base::s_info, 0, 0 , CREATE_METHOD_TABLE(JSInspectorFrontendHost) };

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

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

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

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

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

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionLoaded(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    impl.loaded();
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionCloseWindow(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    impl.closeWindow();
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionBringToFront(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    impl.bringToFront();
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionSetZoomFactor(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    float zoom(exec->argument(0).toFloat(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl.setZoomFactor(zoom);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionInspectedURLChanged(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    const String& newURL(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl.inspectedURLChanged(newURL);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionRequestSetDockSide(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    const String& side(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl.requestSetDockSide(side);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionSetAttachedWindowHeight(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    unsigned height(toUInt32(exec, exec->argument(0), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl.setAttachedWindowHeight(height);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionSetAttachedWindowWidth(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    unsigned width(toUInt32(exec, exec->argument(0), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl.setAttachedWindowWidth(width);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionSetToolbarHeight(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    float height(exec->argument(0).toFloat(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl.setToolbarHeight(height);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionMoveWindowBy(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    if (exec->argumentCount() < 2)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    float x(exec->argument(0).toFloat(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    float y(exec->argument(1).toFloat(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl.moveWindowBy(x, y);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionLocalizedStringsURL(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();

    JSC::JSValue result = jsStringWithCache(exec, impl.localizedStringsURL());
    return JSValue::encode(result);
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionDebuggableType(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();

    JSC::JSValue result = jsStringWithCache(exec, impl.debuggableType());
    return JSValue::encode(result);
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionCopyText(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    const String& text(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl.copyText(text);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionOpenInNewTab(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    const String& url(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl.openInNewTab(url);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionCanSave(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();

    JSC::JSValue result = jsBoolean(impl.canSave());
    return JSValue::encode(result);
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionSave(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    if (exec->argumentCount() < 4)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    const String& url(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    const String& content(exec->argument(1).isEmpty() ? String() : exec->argument(1).toString(exec)->value(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    bool base64Encoded(exec->argument(2).toBoolean(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    bool forceSaveAs(exec->argument(3).toBoolean(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl.save(url, content, base64Encoded, forceSaveAs);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionAppend(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    if (exec->argumentCount() < 2)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    const String& url(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    const String& content(exec->argument(1).isEmpty() ? String() : exec->argument(1).toString(exec)->value(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl.append(url, content);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionClose(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    const String& url(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl.close(url);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionPlatform(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    return JSValue::encode(castedThis->platform(exec));
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionPort(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    return JSValue::encode(castedThis->port(exec));
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionShowContextMenu(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    return JSValue::encode(castedThis->showContextMenu(exec));
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionDispatchEventAsContextMenuEvent(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    Event* event(toEvent(exec->argument(0)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl.dispatchEventAsContextMenuEvent(event);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionSendMessageToBackend(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    const String& message(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    impl.sendMessageToBackend(message);
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionRecordActionTaken(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    return JSValue::encode(castedThis->recordActionTaken(exec));
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionRecordPanelShown(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    return JSValue::encode(castedThis->recordPanelShown(exec));
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionRecordSettingChanged(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    return JSValue::encode(castedThis->recordSettingChanged(exec));
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionLoadResourceSynchronously(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    if (exec->argumentCount() < 1)
        return throwVMError(exec, createNotEnoughArgumentsError(exec));
    const String& url(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    JSC::JSValue result = jsStringWithCache(exec, impl.loadResourceSynchronously(url));
    return JSValue::encode(result);
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionIsUnderTest(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();

    JSC::JSValue result = jsBoolean(impl.isUnderTest());
    return JSValue::encode(result);
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionBeep(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();
    impl.beep();
    return JSValue::encode(jsUndefined());
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionCanInspectWorkers(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();

    JSC::JSValue result = jsBoolean(impl.canInspectWorkers());
    return JSValue::encode(result);
}

EncodedJSValue JSC_HOST_CALL jsInspectorFrontendHostPrototypeFunctionCanSaveAs(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSInspectorFrontendHost* castedThis = jsDynamicCast<JSInspectorFrontendHost*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSInspectorFrontendHost::info());
    InspectorFrontendHost& impl = castedThis->impl();

    JSC::JSValue result = jsBoolean(impl.canSaveAs());
    return JSValue::encode(result);
}

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

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

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

InspectorFrontendHost* toInspectorFrontendHost(JSC::JSValue value)
{
    return value.inherits(JSInspectorFrontendHost::info()) ? &jsCast<JSInspectorFrontendHost*>(value)->impl() : 0;
}

}

#endif // ENABLE(INSPECTOR)
