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

#include "JSWorkerNavigator.h"

#include "KURL.h"
#include "WorkerNavigator.h"
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>

using namespace JSC;

namespace WebCore {

ASSERT_CLASS_FITS_IN_CELL(JSWorkerNavigator);

/* Hash table */

static const HashTableValue JSWorkerNavigatorTableValues[6] =
{
    { "appName", DontDelete|ReadOnly, (intptr_t)jsWorkerNavigatorAppName, (intptr_t)0 },
    { "appVersion", DontDelete|ReadOnly, (intptr_t)jsWorkerNavigatorAppVersion, (intptr_t)0 },
    { "platform", DontDelete|ReadOnly, (intptr_t)jsWorkerNavigatorPlatform, (intptr_t)0 },
    { "userAgent", DontDelete|ReadOnly, (intptr_t)jsWorkerNavigatorUserAgent, (intptr_t)0 },
    { "onLine", DontDelete|ReadOnly, (intptr_t)jsWorkerNavigatorOnLine, (intptr_t)0 },
    { 0, 0, 0, 0 }
};

static JSC_CONST_HASHTABLE HashTable JSWorkerNavigatorTable =
#if ENABLE(PERFECT_HASH_SIZE)
    { 511, JSWorkerNavigatorTableValues, 0 };
#else
    { 18, 15, JSWorkerNavigatorTableValues, 0 };
#endif

/* Hash table for prototype */

static const HashTableValue JSWorkerNavigatorPrototypeTableValues[1] =
{
    { 0, 0, 0, 0 }
};

static JSC_CONST_HASHTABLE HashTable JSWorkerNavigatorPrototypeTable =
#if ENABLE(PERFECT_HASH_SIZE)
    { 0, JSWorkerNavigatorPrototypeTableValues, 0 };
#else
    { 1, 0, JSWorkerNavigatorPrototypeTableValues, 0 };
#endif

static const HashTable* getJSWorkerNavigatorPrototypeTable(ExecState* exec)
{
    return getHashTableForGlobalData(exec->globalData(), &JSWorkerNavigatorPrototypeTable);
}
const ClassInfo JSWorkerNavigatorPrototype::s_info = { "WorkerNavigatorPrototype", 0, 0, getJSWorkerNavigatorPrototypeTable };

JSObject* JSWorkerNavigatorPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
{
    return getDOMPrototype<JSWorkerNavigator>(exec, globalObject);
}

static const HashTable* getJSWorkerNavigatorTable(ExecState* exec)
{
    return getHashTableForGlobalData(exec->globalData(), &JSWorkerNavigatorTable);
}
const ClassInfo JSWorkerNavigator::s_info = { "WorkerNavigator", 0, 0, getJSWorkerNavigatorTable };

JSWorkerNavigator::JSWorkerNavigator(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<WorkerNavigator> impl)
    : DOMObjectWithGlobalPointer(structure, globalObject)
    , m_impl(impl)
{
}

JSWorkerNavigator::~JSWorkerNavigator()
{
    forgetDOMObject(this, impl());
}

JSObject* JSWorkerNavigator::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
{
    return new (exec) JSWorkerNavigatorPrototype(JSWorkerNavigatorPrototype::createStructure(globalObject->objectPrototype()));
}

bool JSWorkerNavigator::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
    return getStaticValueSlot<JSWorkerNavigator, Base>(exec, getJSWorkerNavigatorTable(exec), this, propertyName, slot);
}

bool JSWorkerNavigator::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
    return getStaticValueDescriptor<JSWorkerNavigator, Base>(exec, getJSWorkerNavigatorTable(exec), this, propertyName, descriptor);
}

JSValue jsWorkerNavigatorAppName(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
    JSWorkerNavigator* castedThis = static_cast<JSWorkerNavigator*>(asObject(slot.slotBase()));
    UNUSED_PARAM(exec);
    WorkerNavigator* imp = static_cast<WorkerNavigator*>(castedThis->impl());
    return jsString(exec, imp->appName());
}

JSValue jsWorkerNavigatorAppVersion(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
    JSWorkerNavigator* castedThis = static_cast<JSWorkerNavigator*>(asObject(slot.slotBase()));
    UNUSED_PARAM(exec);
    WorkerNavigator* imp = static_cast<WorkerNavigator*>(castedThis->impl());
    return jsString(exec, imp->appVersion());
}

JSValue jsWorkerNavigatorPlatform(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
    JSWorkerNavigator* castedThis = static_cast<JSWorkerNavigator*>(asObject(slot.slotBase()));
    UNUSED_PARAM(exec);
    WorkerNavigator* imp = static_cast<WorkerNavigator*>(castedThis->impl());
    return jsString(exec, imp->platform());
}

JSValue jsWorkerNavigatorUserAgent(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
    JSWorkerNavigator* castedThis = static_cast<JSWorkerNavigator*>(asObject(slot.slotBase()));
    UNUSED_PARAM(exec);
    WorkerNavigator* imp = static_cast<WorkerNavigator*>(castedThis->impl());
    return jsString(exec, imp->userAgent());
}

JSValue jsWorkerNavigatorOnLine(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
    JSWorkerNavigator* castedThis = static_cast<JSWorkerNavigator*>(asObject(slot.slotBase()));
    UNUSED_PARAM(exec);
    WorkerNavigator* imp = static_cast<WorkerNavigator*>(castedThis->impl());
    return jsBoolean(imp->onLine());
}

JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WorkerNavigator* object)
{
    return getDOMObjectWrapper<JSWorkerNavigator>(exec, globalObject, object);
}
WorkerNavigator* toWorkerNavigator(JSC::JSValue value)
{
    return value.inherits(&JSWorkerNavigator::s_info) ? static_cast<JSWorkerNavigator*>(asObject(value))->impl() : 0;
}

}

#endif // ENABLE(WORKERS)
