/*
    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"
#include "JSScriptProfile.h"

#include "JSScriptProfileNode.h"
#include "ScriptProfile.h"
#include "ScriptProfileNode.h"
#include "URL.h"
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>

using namespace JSC;

namespace WebCore {

/* Hash table */

static const HashTableValue JSScriptProfileTableValues[] =
{
    { "title", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScriptProfileTitle), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "uid", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScriptProfileUid), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "head", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScriptProfileHead), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "idleTime", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScriptProfileIdleTime), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSScriptProfileTable = { 9, 7, true, JSScriptProfileTableValues, 0 };
/* Hash table for prototype */

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

static const HashTable JSScriptProfilePrototypeTable = { 1, 0, false, JSScriptProfilePrototypeTableValues, 0 };
const ClassInfo JSScriptProfilePrototype::s_info = { "ScriptProfilePrototype", &Base::s_info, &JSScriptProfilePrototypeTable, 0, CREATE_METHOD_TABLE(JSScriptProfilePrototype) };

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

const ClassInfo JSScriptProfile::s_info = { "ScriptProfile", &Base::s_info, &JSScriptProfileTable, 0 , CREATE_METHOD_TABLE(JSScriptProfile) };

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

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

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

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

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

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

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


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


EncodedJSValue jsScriptProfileHead(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSScriptProfile* castedThis = jsDynamicCast<JSScriptProfile*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    ScriptProfile& impl = castedThis->impl();
    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl.head()));
    return JSValue::encode(result);
}


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


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

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

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

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

ScriptProfile* toScriptProfile(JSC::JSValue value)
{
    return value.inherits(JSScriptProfile::info()) ? &jsCast<JSScriptProfile*>(value)->impl() : 0;
}

}
