/*
    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"

#if ENABLE(DATABASE)

#include "JSSQLResultSetRowList.h"

#include "SQLResultSetRowList.h"
#include <runtime/Error.h>
#include <runtime/JSNumberCell.h>
#include <wtf/GetPtr.h>

using namespace JSC;

namespace WebCore {

ASSERT_CLASS_FITS_IN_CELL(JSSQLResultSetRowList);

/* Hash table */
#if ENABLE(JIT)
#define THUNK_GENERATOR(generator) , generator
#else
#define THUNK_GENERATOR(generator)
#endif

static const HashTableValue JSSQLResultSetRowListTableValues[2] =
{
    { "length", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSQLResultSetRowListLength), (intptr_t)0 THUNK_GENERATOR(0) },
    { 0, 0, 0, 0 THUNK_GENERATOR(0) }
};

#undef THUNK_GENERATOR
static JSC_CONST_HASHTABLE HashTable JSSQLResultSetRowListTable = { 2, 1, JSSQLResultSetRowListTableValues, 0 };
/* Hash table for prototype */
#if ENABLE(JIT)
#define THUNK_GENERATOR(generator) , generator
#else
#define THUNK_GENERATOR(generator)
#endif

static const HashTableValue JSSQLResultSetRowListPrototypeTableValues[2] =
{
    { "item", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsSQLResultSetRowListPrototypeFunctionItem), (intptr_t)1 THUNK_GENERATOR(0) },
    { 0, 0, 0, 0 THUNK_GENERATOR(0) }
};

#undef THUNK_GENERATOR
static JSC_CONST_HASHTABLE HashTable JSSQLResultSetRowListPrototypeTable = { 2, 1, JSSQLResultSetRowListPrototypeTableValues, 0 };
static const HashTable* getJSSQLResultSetRowListPrototypeTable(ExecState* exec)
{
    return getHashTableForGlobalData(exec->globalData(), &JSSQLResultSetRowListPrototypeTable);
}
const ClassInfo JSSQLResultSetRowListPrototype::s_info = { "SQLResultSetRowListPrototype", 0, 0, getJSSQLResultSetRowListPrototypeTable };

JSObject* JSSQLResultSetRowListPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
{
    return getDOMPrototype<JSSQLResultSetRowList>(exec, globalObject);
}

bool JSSQLResultSetRowListPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
    return getStaticFunctionSlot<JSObject>(exec, getJSSQLResultSetRowListPrototypeTable(exec), this, propertyName, slot);
}

bool JSSQLResultSetRowListPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
    return getStaticFunctionDescriptor<JSObject>(exec, getJSSQLResultSetRowListPrototypeTable(exec), this, propertyName, descriptor);
}

static const HashTable* getJSSQLResultSetRowListTable(ExecState* exec)
{
    return getHashTableForGlobalData(exec->globalData(), &JSSQLResultSetRowListTable);
}
const ClassInfo JSSQLResultSetRowList::s_info = { "SQLResultSetRowList", 0, 0, getJSSQLResultSetRowListTable };

JSSQLResultSetRowList::JSSQLResultSetRowList(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<SQLResultSetRowList> impl)
    : DOMObjectWithGlobalPointer(structure, globalObject)
    , m_impl(impl)
{
}

JSSQLResultSetRowList::~JSSQLResultSetRowList()
{
    forgetDOMObject(this, impl());
}

JSObject* JSSQLResultSetRowList::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
{
    return new (exec) JSSQLResultSetRowListPrototype(globalObject, JSSQLResultSetRowListPrototype::createStructure(globalObject->objectPrototype()));
}

bool JSSQLResultSetRowList::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
    return getStaticValueSlot<JSSQLResultSetRowList, Base>(exec, getJSSQLResultSetRowListTable(exec), this, propertyName, slot);
}

bool JSSQLResultSetRowList::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
{
    return getStaticValueDescriptor<JSSQLResultSetRowList, Base>(exec, getJSSQLResultSetRowListTable(exec), this, propertyName, descriptor);
}

JSValue jsSQLResultSetRowListLength(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSSQLResultSetRowList* castedThis = static_cast<JSSQLResultSetRowList*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    SQLResultSetRowList* imp = static_cast<SQLResultSetRowList*>(castedThis->impl());
    JSValue result = jsNumber(exec, imp->length());
    return result;
}

EncodedJSValue JSC_HOST_CALL jsSQLResultSetRowListPrototypeFunctionItem(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSSQLResultSetRowList::s_info))
        return throwVMTypeError(exec);
    JSSQLResultSetRowList* castedThis = static_cast<JSSQLResultSetRowList*>(asObject(thisValue));
    return JSValue::encode(castedThis->item(exec));
}

JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, SQLResultSetRowList* object)
{
    return getDOMObjectWrapper<JSSQLResultSetRowList>(exec, globalObject, object);
}
SQLResultSetRowList* toSQLResultSetRowList(JSC::JSValue value)
{
    return value.inherits(&JSSQLResultSetRowList::s_info) ? static_cast<JSSQLResultSetRowList*>(asObject(value))->impl() : 0;
}

}

#endif // ENABLE(DATABASE)
