/*
    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 <wtf/Platform.h>


#if ENABLE(VIDEO)

#include "JSHTMLVideoElement.h"

#include <wtf/GetPtr.h>

#include <kjs/ExecState.h>

using namespace KJS;

#include "HTMLVideoElement.h"

using namespace KJS;

namespace khtml {

/* Hash table */

static const HashEntry JSHTMLVideoElementTableEntries[] =
{
    { nullptr, 0, 0, 0, nullptr },
    { "videoWidth", JSHTMLVideoElement::VideoWidthAttrNum, DontDelete|ReadOnly, 0, nullptr },
    { "videoHeight", JSHTMLVideoElement::VideoHeightAttrNum, DontDelete|ReadOnly, 0, nullptr },
    { "width", JSHTMLVideoElement::WidthAttrNum, DontDelete, 0, nullptr },
    { nullptr, 0, 0, 0, nullptr },
    { nullptr, 0, 0, 0, nullptr },
    { nullptr, 0, 0, 0, nullptr },
    { nullptr, 0, 0, 0, nullptr },
    { nullptr, 0, 0, 0, nullptr },
    { "height", JSHTMLVideoElement::HeightAttrNum, DontDelete, 0, &JSHTMLVideoElementTableEntries[16] },
    { nullptr, 0, 0, 0, nullptr },
    { "poster", JSHTMLVideoElement::PosterAttrNum, DontDelete, 0, nullptr },
    { nullptr, 0, 0, 0, nullptr },
    { nullptr, 0, 0, 0, nullptr },
    { nullptr, 0, 0, 0, nullptr },
    { nullptr, 0, 0, 0, nullptr },
    { "constructor", JSHTMLVideoElement::ConstructorAttrNum, DontDelete|DontEnum|ReadOnly, 0, nullptr }
};

static const HashTable JSHTMLVideoElementTable = 
{
    2, 17, JSHTMLVideoElementTableEntries, 16
};

/* Hash table for constructor */

static const HashEntry JSHTMLVideoElementConstructorTableEntries[] =
{
    { nullptr, 0, 0, 0, nullptr }
};

static const HashTable JSHTMLVideoElementConstructorTable = 
{
    2, 1, JSHTMLVideoElementConstructorTableEntries, 1
};

class JSHTMLVideoElementConstructor : public DOMObject {
public:
    JSHTMLVideoElementConstructor(ExecState* exec)
    {
        setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
        putDirect(exec->propertyNames().prototype, JSHTMLVideoElementPrototype::self(exec), None);
    }
    using KJS::JSObject::getOwnPropertySlot;
    virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
    JSValue* getValueProperty(ExecState*, int token) const;
    virtual const ClassInfo* classInfo() const { return &s_info; }
    static const ClassInfo s_info;

    virtual bool implementsHasInstance() const { return true; }
};

const ClassInfo JSHTMLVideoElementConstructor::s_info = { "HTMLVideoElementConstructor", nullptr, &JSHTMLVideoElementConstructorTable, nullptr };

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

JSValue* JSHTMLVideoElementConstructor::getValueProperty(ExecState*, int token) const
{
    // The token is the numeric value of its associated constant
    return jsNumber(token);
}

/* Hash table for prototype */

static const HashEntry JSHTMLVideoElementPrototypeTableEntries[] =
{
    { nullptr, 0, 0, 0, nullptr }
};

static const HashTable JSHTMLVideoElementPrototypeTable = 
{
    2, 1, JSHTMLVideoElementPrototypeTableEntries, 1
};

const ClassInfo JSHTMLVideoElementPrototype::s_info = { "HTMLVideoElementPrototype", nullptr, &JSHTMLVideoElementPrototypeTable, nullptr };

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

const ClassInfo JSHTMLVideoElement::s_info = { "HTMLVideoElement", &JSHTMLMediaElement::s_info, &JSHTMLVideoElementTable , nullptr };

JSHTMLVideoElement::JSHTMLVideoElement(ExecState* exec, HTMLVideoElement* impl)
    : JSHTMLMediaElement(exec, impl)
{
    setPrototype(JSHTMLVideoElementPrototype::self(exec));
}

bool JSHTMLVideoElement::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
    return getStaticValueSlot<JSHTMLVideoElement, JSHTMLMediaElement>(exec, &JSHTMLVideoElementTable, this, propertyName, slot);
}

JSValue* JSHTMLVideoElement::getValueProperty(ExecState* exec, int token) const
{
    switch (token) {
    case WidthAttrNum: {
        HTMLVideoElement* imp = static_cast<HTMLVideoElement*>(impl());

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

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

        return jsNumber(imp->videoWidth());
    }
    case VideoHeightAttrNum: {
        HTMLVideoElement* imp = static_cast<HTMLVideoElement*>(impl());

        return jsNumber(imp->videoHeight());
    }
    case PosterAttrNum: {
        HTMLVideoElement* imp = static_cast<HTMLVideoElement*>(impl());

        return jsString(imp->poster());
    }
    case ConstructorAttrNum:
        return getConstructor(exec);
    }
    return nullptr;
}

void JSHTMLVideoElement::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
    lookupPut<JSHTMLVideoElement, JSHTMLMediaElement>(exec, propertyName, value, attr, &JSHTMLVideoElementTable, this);
}

void JSHTMLVideoElement::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/)
{
    switch (token) {
    case WidthAttrNum: {
        HTMLVideoElement* imp = static_cast<HTMLVideoElement*>(impl());

        imp->setWidth(value->toInt32(exec));
        break;
    }
    case HeightAttrNum: {
        HTMLVideoElement* imp = static_cast<HTMLVideoElement*>(impl());

        imp->setHeight(value->toInt32(exec));
        break;
    }
    case PosterAttrNum: {
        HTMLVideoElement* imp = static_cast<HTMLVideoElement*>(impl());

        imp->setPoster(valueToStringWithNullCheck(exec, value));
        break;
    }
    }
}

JSValue* JSHTMLVideoElement::getConstructor(ExecState* exec)
{
    return ::cacheGlobalObject<JSHTMLVideoElementConstructor>(exec, "[[HTMLVideoElement.constructor]]");
}

}

#endif // ENABLE(VIDEO)
