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

#include "BarProp.h"
#include <wtf/GetPtr.h>

using namespace JSC;

namespace WebCore {

/* Hash table */

static const HashTableValue JSBarPropTableValues[] =
{
    { "visible", DontDelete | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBarPropVisible), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBarPropConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
    { 0, 0, NoIntrinsic, 0, 0 }
};

static const HashTable JSBarPropTable = { 4, 3, true, JSBarPropTableValues, 0 };
/* Hash table for constructor */

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

static const HashTable JSBarPropConstructorTable = { 1, 0, false, JSBarPropConstructorTableValues, 0 };
const ClassInfo JSBarPropConstructor::s_info = { "BarPropConstructor", &Base::s_info, &JSBarPropConstructorTable, 0, CREATE_METHOD_TABLE(JSBarPropConstructor) };

JSBarPropConstructor::JSBarPropConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
    : DOMConstructorObject(structure, globalObject)
{
}

void JSBarPropConstructor::finishCreation(VM& vm, JSDOMGlobalObject* globalObject)
{
    Base::finishCreation(vm);
    ASSERT(inherits(info()));
    putDirect(vm, vm.propertyNames->prototype, JSBarPropPrototype::self(vm, globalObject), DontDelete | ReadOnly);
    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
}

bool JSBarPropConstructor::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
    return getStaticValueSlot<JSBarPropConstructor, JSDOMWrapper>(exec, JSBarPropConstructorTable, jsCast<JSBarPropConstructor*>(object), propertyName, slot);
}

/* Hash table for prototype */

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

static const HashTable JSBarPropPrototypeTable = { 1, 0, false, JSBarPropPrototypeTableValues, 0 };
const ClassInfo JSBarPropPrototype::s_info = { "BarPropPrototype", &Base::s_info, &JSBarPropPrototypeTable, 0, CREATE_METHOD_TABLE(JSBarPropPrototype) };

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

const ClassInfo JSBarProp::s_info = { "BarProp", &Base::s_info, &JSBarPropTable, 0 , CREATE_METHOD_TABLE(JSBarProp) };

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

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

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

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

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

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

EncodedJSValue jsBarPropVisible(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
{
    JSBarProp* castedThis = jsDynamicCast<JSBarProp*>(JSValue::decode(thisValue));
    UNUSED_PARAM(slotBase);
    if (!castedThis)
        return throwVMTypeError(exec);
    UNUSED_PARAM(exec);
    BarProp& impl = castedThis->impl();
    JSValue result = jsBoolean(impl.visible());
    return JSValue::encode(result);
}


EncodedJSValue jsBarPropConstructor(ExecState* exec, EncodedJSValue thisValue, EncodedJSValue, PropertyName)
{
    JSBarProp* domObject = jsDynamicCast<JSBarProp*>(JSValue::decode(thisValue));
    if (!domObject)
        return throwVMTypeError(exec);
    if (!domObject)
        return throwVMTypeError(exec);
    return JSValue::encode(JSBarProp::getConstructor(exec->vm(), domObject->globalObject()));
}

JSValue JSBarProp::getConstructor(VM& vm, JSGlobalObject* globalObject)
{
    return getDOMConstructor<JSBarPropConstructor>(vm, jsCast<JSDOMGlobalObject*>(globalObject));
}

static inline bool isObservable(JSBarProp* jsBarProp)
{
    if (jsBarProp->hasCustomProperties())
        return true;
    return false;
}

bool JSBarPropOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
    JSBarProp* jsBarProp = jsCast<JSBarProp*>(handle.get().asCell());
    if (!isObservable(jsBarProp))
        return false;
    Frame* root = jsBarProp->impl().frame();
    if (!root)
        return false;
    return visitor.containsOpaqueRoot(root);
}

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

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

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

BarProp* toBarProp(JSC::JSValue value)
{
    return value.inherits(JSBarProp::info()) ? &jsCast<JSBarProp*>(value)->impl() : 0;
}

}
