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

#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSScriptProfileNode.h"
#include "ScriptProfileNode.h"
#include "URL.h"
#include <runtime/Error.h>
#include <runtime/JSArray.h>
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>

using namespace JSC;

namespace WebCore {

/* Hash table */

static const HashTableValue JSScriptProfileNodeTableValues[] =
{
    { "functionName", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScriptProfileNodeFunctionName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "url", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScriptProfileNodeUrl), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "lineNumber", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScriptProfileNodeLineNumber), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "totalTime", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScriptProfileNodeTotalTime), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "selfTime", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScriptProfileNodeSelfTime), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "numberOfCalls", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScriptProfileNodeNumberOfCalls), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "callUID", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScriptProfileNodeCallUID), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSScriptProfileNodeTable = { 18, 15, true, JSScriptProfileNodeTableValues, 0 };
/* Hash table for prototype */

static const HashTableValue JSScriptProfileNodePrototypeTableValues[] =
{
    { "children", JSC::Function, NoIntrinsic, (intptr_t)static_cast<NativeFunction>(jsScriptProfileNodePrototypeFunctionChildren), (intptr_t) (0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSScriptProfileNodePrototypeTable = { 2, 1, false, JSScriptProfileNodePrototypeTableValues, 0 };
const ClassInfo JSScriptProfileNodePrototype::s_info = { "ScriptProfileNodePrototype", &Base::s_info, &JSScriptProfileNodePrototypeTable, 0, CREATE_METHOD_TABLE(JSScriptProfileNodePrototype) };

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

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

const ClassInfo JSScriptProfileNode::s_info = { "ScriptProfileNode", &Base::s_info, &JSScriptProfileNodeTable, 0 , CREATE_METHOD_TABLE(JSScriptProfileNode) };

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

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

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

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

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

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

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


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


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


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


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


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


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


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

    JSC::JSValue result = jsArray(exec, castedThis->globalObject(), impl.children());
    return JSValue::encode(result);
}

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

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

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

ScriptProfileNode* toScriptProfileNode(JSC::JSValue value)
{
    return value.inherits(JSScriptProfileNode::info()) ? &jsCast<JSScriptProfileNode*>(value)->impl() : 0;
}

}
