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

#include <wtf/GetPtr.h>

#include "Screen.h"

using namespace KJS;

namespace WebCore {

/* Hash table */

static const HashEntry JSScreenTableEntries[] =
{
    { 0, 0, 0, 0, 0 },
    { "height", JSScreen::HeightAttrNum, DontDelete|ReadOnly, 0, &JSScreenTableEntries[8] },
    { 0, 0, 0, 0, 0 },
    { "width", JSScreen::WidthAttrNum, DontDelete|ReadOnly, 0, &JSScreenTableEntries[9] },
    { "availHeight", JSScreen::AvailHeightAttrNum, DontDelete|ReadOnly, 0, &JSScreenTableEntries[11] },
    { 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0 },
    { "availLeft", JSScreen::AvailLeftAttrNum, DontDelete|ReadOnly, 0, 0 },
    { "colorDepth", JSScreen::ColorDepthAttrNum, DontDelete|ReadOnly, 0, &JSScreenTableEntries[10] },
    { "pixelDepth", JSScreen::PixelDepthAttrNum, DontDelete|ReadOnly, 0, 0 },
    { "availTop", JSScreen::AvailTopAttrNum, DontDelete|ReadOnly, 0, 0 },
    { "availWidth", JSScreen::AvailWidthAttrNum, DontDelete|ReadOnly, 0, 0 }
};

static const HashTable JSScreenTable = 
{
    2, 12, JSScreenTableEntries, 8
};

/* Hash table for prototype */

static const HashEntry JSScreenPrototypeTableEntries[] =
{
    { 0, 0, 0, 0, 0 }
};

static const HashTable JSScreenPrototypeTable = 
{
    2, 1, JSScreenPrototypeTableEntries, 1
};

const ClassInfo JSScreenPrototype::info = { "ScreenPrototype", 0, &JSScreenPrototypeTable, 0 };

JSObject* JSScreenPrototype::self(ExecState* exec)
{
    return KJS::cacheGlobalObject<JSScreenPrototype>(exec, "[[JSScreen.prototype]]");
}

const ClassInfo JSScreen::info = { "Screen", 0, &JSScreenTable, 0 };

JSScreen::JSScreen(ExecState* exec, Screen* impl)
    : m_impl(impl)
{
    setPrototype(JSScreenPrototype::self(exec));
}

JSScreen::~JSScreen()
{
    ScriptInterpreter::forgetDOMObject(m_impl.get());
}

bool JSScreen::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
    return getStaticValueSlot<JSScreen, KJS::DOMObject>(exec, &JSScreenTable, this, propertyName, slot);
}

JSValue* JSScreen::getValueProperty(ExecState* exec, int token) const
{
    switch (token) {
    case HeightAttrNum: {
        Screen* imp = static_cast<Screen*>(impl());

        return jsNumber(imp->height());
    }
    case WidthAttrNum: {
        Screen* imp = static_cast<Screen*>(impl());

        return jsNumber(imp->width());
    }
    case ColorDepthAttrNum: {
        Screen* imp = static_cast<Screen*>(impl());

        return jsNumber(imp->colorDepth());
    }
    case PixelDepthAttrNum: {
        Screen* imp = static_cast<Screen*>(impl());

        return jsNumber(imp->pixelDepth());
    }
    case AvailLeftAttrNum: {
        Screen* imp = static_cast<Screen*>(impl());

        return jsNumber(imp->availLeft());
    }
    case AvailTopAttrNum: {
        Screen* imp = static_cast<Screen*>(impl());

        return jsNumber(imp->availTop());
    }
    case AvailHeightAttrNum: {
        Screen* imp = static_cast<Screen*>(impl());

        return jsNumber(imp->availHeight());
    }
    case AvailWidthAttrNum: {
        Screen* imp = static_cast<Screen*>(impl());

        return jsNumber(imp->availWidth());
    }
    }
    return 0;
}

KJS::JSValue* toJS(KJS::ExecState* exec, Screen* obj)
{
    return KJS::cacheDOMObject<Screen, JSScreen>(exec, obj);
}
Screen* toScreen(KJS::JSValue* val)
{
    return val->isObject(&JSScreen::info) ? static_cast<JSScreen*>(val)->impl() : 0;
}

}
