blob: 06169619e48e4ff634670a0a21614be304705603 [file] [log] [blame]
/*
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 "JSDatabase.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSSQLTransactionCallback.h"
#include "JSSQLTransactionErrorCallback.h"
#include "JSVoidCallback.h"
#include "URL.h"
#include <runtime/Error.h>
#include <runtime/FunctionPrototype.h>
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsDatabasePrototypeFunctionChangeVersion(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsDatabasePrototypeFunctionTransaction(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsDatabasePrototypeFunctionReadTransaction(JSC::ExecState*);
// Attributes
JSC::EncodedJSValue jsDatabaseVersion(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsDatabaseConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSDatabaseConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSDatabasePrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSDatabasePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSDatabasePrototype* ptr = new (NotNull, JSC::allocateCell<JSDatabasePrototype>(vm.heap)) JSDatabasePrototype(vm, globalObject, structure);
ptr->finishCreation(vm);
return ptr;
}
DECLARE_INFO;
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
{
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
}
private:
JSDatabasePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructorNotConstructable<JSDatabase> JSDatabaseConstructor;
template<> JSValue JSDatabaseConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
UNUSED_PARAM(vm);
return globalObject.functionPrototype();
}
template<> void JSDatabaseConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSDatabase::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("Database"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
}
template<> const ClassInfo JSDatabaseConstructor::s_info = { "Database", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDatabaseConstructor) };
/* Hash table for prototype */
static const HashTableValue JSDatabasePrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDatabaseConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDatabaseConstructor) } },
{ "version", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDatabaseVersion), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "changeVersion", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDatabasePrototypeFunctionChangeVersion), (intptr_t) (2) } },
{ "transaction", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDatabasePrototypeFunctionTransaction), (intptr_t) (1) } },
{ "readTransaction", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDatabasePrototypeFunctionReadTransaction), (intptr_t) (1) } },
};
const ClassInfo JSDatabasePrototype::s_info = { "DatabasePrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDatabasePrototype) };
void JSDatabasePrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSDatabasePrototypeTableValues, *this);
}
const ClassInfo JSDatabase::s_info = { "Database", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDatabase) };
JSDatabase::JSDatabase(Structure* structure, JSDOMGlobalObject& globalObject, Ref<Database>&& impl)
: JSDOMWrapper<Database>(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSDatabase::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSDatabasePrototype::create(vm, globalObject, JSDatabasePrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
JSObject* JSDatabase::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSDatabase>(vm, globalObject);
}
void JSDatabase::destroy(JSC::JSCell* cell)
{
JSDatabase* thisObject = static_cast<JSDatabase*>(cell);
thisObject->JSDatabase::~JSDatabase();
}
EncodedJSValue jsDatabaseVersion(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSDatabase*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "Database", "version");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.version());
return JSValue::encode(result);
}
EncodedJSValue jsDatabaseConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSDatabasePrototype* domObject = jsDynamicCast<JSDatabasePrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSDatabase::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSDatabaseConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSDatabasePrototype* domObject = jsDynamicCast<JSDatabasePrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject)) {
throwVMTypeError(state, throwScope);
return false;
}
// Shadowing a built-in constructor
return domObject->putDirect(state->vm(), state->propertyNames().constructor, value);
}
JSValue JSDatabase::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSDatabaseConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
EncodedJSValue JSC_HOST_CALL jsDatabasePrototypeFunctionChangeVersion(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSDatabase*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "Database", "changeVersion");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSDatabase::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 2))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto oldVersion = state->uncheckedArgument(0).toWTFString(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto newVersion = state->uncheckedArgument(1).toWTFString(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
RefPtr<SQLTransactionCallback> callback;
if (!state->argument(2).isUndefinedOrNull()) {
if (!state->uncheckedArgument(2).isFunction())
return throwArgumentMustBeFunctionError(*state, throwScope, 2, "callback", "Database", "changeVersion");
callback = JSSQLTransactionCallback::create(asObject(state->uncheckedArgument(2)), castedThis->globalObject());
}
RefPtr<SQLTransactionErrorCallback> errorCallback;
if (!state->argument(3).isUndefinedOrNull()) {
if (!state->uncheckedArgument(3).isFunction())
return throwArgumentMustBeFunctionError(*state, throwScope, 3, "errorCallback", "Database", "changeVersion");
errorCallback = JSSQLTransactionErrorCallback::create(asObject(state->uncheckedArgument(3)), castedThis->globalObject());
}
RefPtr<VoidCallback> successCallback;
if (!state->argument(4).isUndefinedOrNull()) {
if (!state->uncheckedArgument(4).isFunction())
return throwArgumentMustBeFunctionError(*state, throwScope, 4, "successCallback", "Database", "changeVersion");
successCallback = JSVoidCallback::create(asObject(state->uncheckedArgument(4)), castedThis->globalObject());
}
impl.changeVersion(WTFMove(oldVersion), WTFMove(newVersion), WTFMove(callback), WTFMove(errorCallback), WTFMove(successCallback));
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsDatabasePrototypeFunctionTransaction(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSDatabase*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "Database", "transaction");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSDatabase::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
if (UNLIKELY(!state->uncheckedArgument(0).isFunction()))
return throwArgumentMustBeFunctionError(*state, throwScope, 0, "callback", "Database", "transaction");
auto callback = JSSQLTransactionCallback::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
RefPtr<SQLTransactionErrorCallback> errorCallback;
if (!state->argument(1).isUndefinedOrNull()) {
if (!state->uncheckedArgument(1).isFunction())
return throwArgumentMustBeFunctionError(*state, throwScope, 1, "errorCallback", "Database", "transaction");
errorCallback = JSSQLTransactionErrorCallback::create(asObject(state->uncheckedArgument(1)), castedThis->globalObject());
}
RefPtr<VoidCallback> successCallback;
if (!state->argument(2).isUndefinedOrNull()) {
if (!state->uncheckedArgument(2).isFunction())
return throwArgumentMustBeFunctionError(*state, throwScope, 2, "successCallback", "Database", "transaction");
successCallback = JSVoidCallback::create(asObject(state->uncheckedArgument(2)), castedThis->globalObject());
}
impl.transaction(WTFMove(callback), WTFMove(errorCallback), WTFMove(successCallback));
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsDatabasePrototypeFunctionReadTransaction(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSDatabase*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "Database", "readTransaction");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSDatabase::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
if (UNLIKELY(!state->uncheckedArgument(0).isFunction()))
return throwArgumentMustBeFunctionError(*state, throwScope, 0, "callback", "Database", "readTransaction");
auto callback = JSSQLTransactionCallback::create(asObject(state->uncheckedArgument(0)), castedThis->globalObject());
RefPtr<SQLTransactionErrorCallback> errorCallback;
if (!state->argument(1).isUndefinedOrNull()) {
if (!state->uncheckedArgument(1).isFunction())
return throwArgumentMustBeFunctionError(*state, throwScope, 1, "errorCallback", "Database", "readTransaction");
errorCallback = JSSQLTransactionErrorCallback::create(asObject(state->uncheckedArgument(1)), castedThis->globalObject());
}
RefPtr<VoidCallback> successCallback;
if (!state->argument(2).isUndefinedOrNull()) {
if (!state->uncheckedArgument(2).isFunction())
return throwArgumentMustBeFunctionError(*state, throwScope, 2, "successCallback", "Database", "readTransaction");
successCallback = JSVoidCallback::create(asObject(state->uncheckedArgument(2)), castedThis->globalObject());
}
impl.readTransaction(WTFMove(callback), WTFMove(errorCallback), WTFMove(successCallback));
return JSValue::encode(jsUndefined());
}
bool JSDatabaseOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
UNUSED_PARAM(handle);
UNUSED_PARAM(visitor);
return false;
}
void JSDatabaseOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
auto* jsDatabase = jsCast<JSDatabase*>(handle.slot()->asCell());
auto& world = *static_cast<DOMWrapperWorld*>(context);
uncacheWrapper(world, &jsDatabase->wrapped(), jsDatabase);
}
#if ENABLE(BINDING_INTEGRITY)
#if PLATFORM(WIN)
#pragma warning(disable: 4483)
extern "C" { extern void (*const __identifier("??_7Database@WebCore@@6B@")[])(); }
#else
extern "C" { extern void* _ZTVN7WebCore8DatabaseE[]; }
#endif
#endif
JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<Database>&& impl)
{
#if ENABLE(BINDING_INTEGRITY)
void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
#if PLATFORM(WIN)
void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7Database@WebCore@@6B@"));
#else
void* expectedVTablePointer = &_ZTVN7WebCore8DatabaseE[2];
#if COMPILER(CLANG)
// If this fails Database does not have a vtable, so you need to add the
// ImplementationLacksVTable attribute to the interface definition
static_assert(__is_polymorphic(Database), "Database is not polymorphic");
#endif
#endif
// If you hit this assertion you either have a use after free bug, or
// Database has subclasses. If Database has subclasses that get passed
// to toJS() we currently require Database you to opt out of binding hardening
// by adding the SkipVTableValidation attribute to the interface IDL definition
RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
#endif
return createWrapper<Database>(globalObject, WTFMove(impl));
}
JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, Database& impl)
{
return wrap(state, globalObject, impl);
}
Database* JSDatabase::toWrapped(JSC::JSValue value)
{
if (auto* wrapper = jsDynamicCast<JSDatabase*>(value))
return &wrapper->wrapped();
return nullptr;
}
}