| /* |
| 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(INDEXED_DATABASE) |
| |
| #include "JSIDBIndex.h" |
| |
| #include "ExceptionCode.h" |
| #include "IDBBindingUtilities.h" |
| #include "IDBRequest.h" |
| #include "JSDOMBinding.h" |
| #include "JSDOMConstructor.h" |
| #include "JSIDBKeyRange.h" |
| #include "JSIDBObjectStore.h" |
| #include "JSIDBRequest.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 jsIDBIndexPrototypeFunctionOpenCursor(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionOpenKeyCursor(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionGet(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionGetKey(JSC::ExecState*); |
| JSC::EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionCount(JSC::ExecState*); |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsIDBIndexName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsIDBIndexObjectStore(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsIDBIndexKeyPath(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsIDBIndexMultiEntry(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsIDBIndexUnique(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsIDBIndexConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSIDBIndexConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSIDBIndexPrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSIDBIndexPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSIDBIndexPrototype* ptr = new (NotNull, JSC::allocateCell<JSIDBIndexPrototype>(vm.heap)) JSIDBIndexPrototype(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: |
| JSIDBIndexPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| typedef JSDOMConstructorNotConstructable<JSIDBIndex> JSIDBIndexConstructor; |
| |
| template<> JSValue JSIDBIndexConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| { |
| UNUSED_PARAM(vm); |
| return globalObject.functionPrototype(); |
| } |
| |
| template<> void JSIDBIndexConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| { |
| putDirect(vm, vm.propertyNames->prototype, JSIDBIndex::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("IDBIndex"))), ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum); |
| } |
| |
| template<> const ClassInfo JSIDBIndexConstructor::s_info = { "IDBIndex", &Base::s_info, 0, CREATE_METHOD_TABLE(JSIDBIndexConstructor) }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSIDBIndexPrototypeTableValues[] = |
| { |
| { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBIndexConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSIDBIndexConstructor) } }, |
| { "name", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBIndexName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "objectStore", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBIndexObjectStore), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "keyPath", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBIndexKeyPath), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "multiEntry", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBIndexMultiEntry), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "unique", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBIndexUnique), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "openCursor", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsIDBIndexPrototypeFunctionOpenCursor), (intptr_t) (0) } }, |
| { "openKeyCursor", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsIDBIndexPrototypeFunctionOpenKeyCursor), (intptr_t) (0) } }, |
| { "get", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsIDBIndexPrototypeFunctionGet), (intptr_t) (1) } }, |
| { "getKey", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsIDBIndexPrototypeFunctionGetKey), (intptr_t) (1) } }, |
| { "count", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsIDBIndexPrototypeFunctionCount), (intptr_t) (0) } }, |
| }; |
| |
| const ClassInfo JSIDBIndexPrototype::s_info = { "IDBIndexPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSIDBIndexPrototype) }; |
| |
| void JSIDBIndexPrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSIDBIndexPrototypeTableValues, *this); |
| } |
| |
| const ClassInfo JSIDBIndex::s_info = { "IDBIndex", &Base::s_info, 0, CREATE_METHOD_TABLE(JSIDBIndex) }; |
| |
| JSIDBIndex::JSIDBIndex(Structure* structure, JSDOMGlobalObject& globalObject, Ref<IDBIndex>&& impl) |
| : JSDOMWrapper<IDBIndex>(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSIDBIndex::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSIDBIndexPrototype::create(vm, globalObject, JSIDBIndexPrototype::createStructure(vm, globalObject, globalObject->objectPrototype())); |
| } |
| |
| JSObject* JSIDBIndex::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSIDBIndex>(vm, globalObject); |
| } |
| |
| void JSIDBIndex::destroy(JSC::JSCell* cell) |
| { |
| JSIDBIndex* thisObject = static_cast<JSIDBIndex*>(cell); |
| thisObject->JSIDBIndex::~JSIDBIndex(); |
| } |
| |
| EncodedJSValue jsIDBIndexName(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<JSIDBIndex*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "IDBIndex", "name"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.name()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsIDBIndexObjectStore(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<JSIDBIndex*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "IDBIndex", "objectStore"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.objectStore()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsIDBIndexKeyPath(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<JSIDBIndex*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "IDBIndex", "keyPath"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = toJS(*state, *castedThis->globalObject(), impl.keyPath()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsIDBIndexMultiEntry(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<JSIDBIndex*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "IDBIndex", "multiEntry"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsBoolean(impl.multiEntry()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsIDBIndexUnique(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<JSIDBIndex*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "IDBIndex", "unique"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsBoolean(impl.unique()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsIDBIndexConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSIDBIndexPrototype* domObject = jsDynamicCast<JSIDBIndexPrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) |
| return throwVMTypeError(state, throwScope); |
| return JSValue::encode(JSIDBIndex::getConstructor(state->vm(), domObject->globalObject())); |
| } |
| |
| bool setJSIDBIndexConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSIDBIndexPrototype* domObject = jsDynamicCast<JSIDBIndexPrototype*>(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 JSIDBIndex::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| { |
| return getDOMConstructor<JSIDBIndexConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| } |
| |
| static inline EncodedJSValue jsIDBIndexPrototypeFunctionOpenCursor1(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSIDBIndex*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "IDBIndex", "openCursor"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSIDBIndex::info()); |
| auto& impl = castedThis->wrapped(); |
| ExceptionCodeWithMessage ec; |
| IDBKeyRange* range = nullptr; |
| if (!state->argument(0).isUndefinedOrNull()) { |
| range = JSIDBKeyRange::toWrapped(state->uncheckedArgument(0)); |
| if (UNLIKELY(!range)) |
| return throwArgumentTypeError(*state, throwScope, 0, "range", "IDBIndex", "openCursor", "IDBKeyRange"); |
| } |
| auto direction = state->argument(1).isUndefined() ? ASCIILiteral("next") : state->uncheckedArgument(1).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.openCursor(*state, WTFMove(range), WTFMove(direction), ec)); |
| |
| setDOMException(state, throwScope, ec); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| return JSValue::encode(result); |
| } |
| |
| static inline EncodedJSValue jsIDBIndexPrototypeFunctionOpenCursor2(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSIDBIndex*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "IDBIndex", "openCursor"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSIDBIndex::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| ExceptionCodeWithMessage ec; |
| auto key = state->uncheckedArgument(0); |
| auto direction = state->argument(1).isUndefined() ? ASCIILiteral("next") : state->uncheckedArgument(1).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.openCursor(*state, WTFMove(key), WTFMove(direction), ec)); |
| |
| setDOMException(state, throwScope, ec); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| return JSValue::encode(result); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionOpenCursor(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| size_t argsCount = std::min<size_t>(2, state->argumentCount()); |
| if (argsCount == 0) { |
| return jsIDBIndexPrototypeFunctionOpenCursor1(state); |
| } |
| if (argsCount == 1) { |
| JSValue distinguishingArg = state->uncheckedArgument(0); |
| if (distinguishingArg.isUndefined()) |
| return jsIDBIndexPrototypeFunctionOpenCursor1(state); |
| if (distinguishingArg.isUndefinedOrNull()) |
| return jsIDBIndexPrototypeFunctionOpenCursor1(state); |
| if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSIDBKeyRange::info())) |
| return jsIDBIndexPrototypeFunctionOpenCursor1(state); |
| return jsIDBIndexPrototypeFunctionOpenCursor2(state); |
| } |
| if (argsCount == 2) { |
| JSValue distinguishingArg = state->uncheckedArgument(0); |
| if (distinguishingArg.isUndefined()) |
| return jsIDBIndexPrototypeFunctionOpenCursor1(state); |
| if (distinguishingArg.isUndefinedOrNull()) |
| return jsIDBIndexPrototypeFunctionOpenCursor1(state); |
| if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSIDBKeyRange::info())) |
| return jsIDBIndexPrototypeFunctionOpenCursor1(state); |
| return jsIDBIndexPrototypeFunctionOpenCursor2(state); |
| } |
| return throwVMTypeError(state, throwScope); |
| } |
| |
| static inline EncodedJSValue jsIDBIndexPrototypeFunctionOpenKeyCursor1(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSIDBIndex*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "IDBIndex", "openKeyCursor"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSIDBIndex::info()); |
| auto& impl = castedThis->wrapped(); |
| ExceptionCodeWithMessage ec; |
| IDBKeyRange* range = nullptr; |
| if (!state->argument(0).isUndefinedOrNull()) { |
| range = JSIDBKeyRange::toWrapped(state->uncheckedArgument(0)); |
| if (UNLIKELY(!range)) |
| return throwArgumentTypeError(*state, throwScope, 0, "range", "IDBIndex", "openKeyCursor", "IDBKeyRange"); |
| } |
| auto direction = state->argument(1).isUndefined() ? ASCIILiteral("next") : state->uncheckedArgument(1).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.openKeyCursor(*state, WTFMove(range), WTFMove(direction), ec)); |
| |
| setDOMException(state, throwScope, ec); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| return JSValue::encode(result); |
| } |
| |
| static inline EncodedJSValue jsIDBIndexPrototypeFunctionOpenKeyCursor2(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSIDBIndex*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "IDBIndex", "openKeyCursor"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSIDBIndex::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| ExceptionCodeWithMessage ec; |
| auto key = state->uncheckedArgument(0); |
| auto direction = state->argument(1).isUndefined() ? ASCIILiteral("next") : state->uncheckedArgument(1).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.openKeyCursor(*state, WTFMove(key), WTFMove(direction), ec)); |
| |
| setDOMException(state, throwScope, ec); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| return JSValue::encode(result); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionOpenKeyCursor(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| size_t argsCount = std::min<size_t>(2, state->argumentCount()); |
| if (argsCount == 0) { |
| return jsIDBIndexPrototypeFunctionOpenKeyCursor1(state); |
| } |
| if (argsCount == 1) { |
| JSValue distinguishingArg = state->uncheckedArgument(0); |
| if (distinguishingArg.isUndefined()) |
| return jsIDBIndexPrototypeFunctionOpenKeyCursor1(state); |
| if (distinguishingArg.isUndefinedOrNull()) |
| return jsIDBIndexPrototypeFunctionOpenKeyCursor1(state); |
| if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSIDBKeyRange::info())) |
| return jsIDBIndexPrototypeFunctionOpenKeyCursor1(state); |
| return jsIDBIndexPrototypeFunctionOpenKeyCursor2(state); |
| } |
| if (argsCount == 2) { |
| JSValue distinguishingArg = state->uncheckedArgument(0); |
| if (distinguishingArg.isUndefined()) |
| return jsIDBIndexPrototypeFunctionOpenKeyCursor1(state); |
| if (distinguishingArg.isUndefinedOrNull()) |
| return jsIDBIndexPrototypeFunctionOpenKeyCursor1(state); |
| if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSIDBKeyRange::info())) |
| return jsIDBIndexPrototypeFunctionOpenKeyCursor1(state); |
| return jsIDBIndexPrototypeFunctionOpenKeyCursor2(state); |
| } |
| return throwVMTypeError(state, throwScope); |
| } |
| |
| static inline EncodedJSValue jsIDBIndexPrototypeFunctionGet1(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSIDBIndex*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "IDBIndex", "get"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSIDBIndex::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| ExceptionCodeWithMessage ec; |
| IDBKeyRange* key = nullptr; |
| if (!state->uncheckedArgument(0).isUndefinedOrNull()) { |
| key = JSIDBKeyRange::toWrapped(state->uncheckedArgument(0)); |
| if (UNLIKELY(!key)) |
| return throwArgumentTypeError(*state, throwScope, 0, "key", "IDBIndex", "get", "IDBKeyRange"); |
| } |
| JSValue result = toJS(state, castedThis->globalObject(), impl.get(*state, WTFMove(key), ec)); |
| |
| setDOMException(state, throwScope, ec); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| return JSValue::encode(result); |
| } |
| |
| static inline EncodedJSValue jsIDBIndexPrototypeFunctionGet2(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSIDBIndex*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "IDBIndex", "get"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSIDBIndex::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| ExceptionCodeWithMessage ec; |
| auto key = state->uncheckedArgument(0); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.get(*state, WTFMove(key), ec)); |
| |
| setDOMException(state, throwScope, ec); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| return JSValue::encode(result); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionGet(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| size_t argsCount = std::min<size_t>(1, state->argumentCount()); |
| if (argsCount == 1) { |
| JSValue distinguishingArg = state->uncheckedArgument(0); |
| if (distinguishingArg.isUndefinedOrNull()) |
| return jsIDBIndexPrototypeFunctionGet1(state); |
| if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSIDBKeyRange::info())) |
| return jsIDBIndexPrototypeFunctionGet1(state); |
| return jsIDBIndexPrototypeFunctionGet2(state); |
| } |
| return argsCount < 1 ? throwVMError(state, throwScope, createNotEnoughArgumentsError(state)) : throwVMTypeError(state, throwScope); |
| } |
| |
| static inline EncodedJSValue jsIDBIndexPrototypeFunctionGetKey1(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSIDBIndex*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "IDBIndex", "getKey"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSIDBIndex::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| ExceptionCodeWithMessage ec; |
| IDBKeyRange* key = nullptr; |
| if (!state->uncheckedArgument(0).isUndefinedOrNull()) { |
| key = JSIDBKeyRange::toWrapped(state->uncheckedArgument(0)); |
| if (UNLIKELY(!key)) |
| return throwArgumentTypeError(*state, throwScope, 0, "key", "IDBIndex", "getKey", "IDBKeyRange"); |
| } |
| JSValue result = toJS(state, castedThis->globalObject(), impl.getKey(*state, WTFMove(key), ec)); |
| |
| setDOMException(state, throwScope, ec); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| return JSValue::encode(result); |
| } |
| |
| static inline EncodedJSValue jsIDBIndexPrototypeFunctionGetKey2(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSIDBIndex*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "IDBIndex", "getKey"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSIDBIndex::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| ExceptionCodeWithMessage ec; |
| auto key = state->uncheckedArgument(0); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.getKey(*state, WTFMove(key), ec)); |
| |
| setDOMException(state, throwScope, ec); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| return JSValue::encode(result); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionGetKey(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| size_t argsCount = std::min<size_t>(1, state->argumentCount()); |
| if (argsCount == 1) { |
| JSValue distinguishingArg = state->uncheckedArgument(0); |
| if (distinguishingArg.isUndefinedOrNull()) |
| return jsIDBIndexPrototypeFunctionGetKey1(state); |
| if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSIDBKeyRange::info())) |
| return jsIDBIndexPrototypeFunctionGetKey1(state); |
| return jsIDBIndexPrototypeFunctionGetKey2(state); |
| } |
| return argsCount < 1 ? throwVMError(state, throwScope, createNotEnoughArgumentsError(state)) : throwVMTypeError(state, throwScope); |
| } |
| |
| static inline EncodedJSValue jsIDBIndexPrototypeFunctionCount1(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSIDBIndex*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "IDBIndex", "count"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSIDBIndex::info()); |
| auto& impl = castedThis->wrapped(); |
| ExceptionCodeWithMessage ec; |
| IDBKeyRange* range = nullptr; |
| if (!state->argument(0).isUndefinedOrNull()) { |
| range = JSIDBKeyRange::toWrapped(state->uncheckedArgument(0)); |
| if (UNLIKELY(!range)) |
| return throwArgumentTypeError(*state, throwScope, 0, "range", "IDBIndex", "count", "IDBKeyRange"); |
| } |
| JSValue result = toJS(state, castedThis->globalObject(), impl.count(*state, WTFMove(range), ec)); |
| |
| setDOMException(state, throwScope, ec); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| return JSValue::encode(result); |
| } |
| |
| static inline EncodedJSValue jsIDBIndexPrototypeFunctionCount2(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSIDBIndex*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "IDBIndex", "count"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSIDBIndex::info()); |
| auto& impl = castedThis->wrapped(); |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| ExceptionCodeWithMessage ec; |
| auto key = state->uncheckedArgument(0); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.count(*state, WTFMove(key), ec)); |
| |
| setDOMException(state, throwScope, ec); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| return JSValue::encode(result); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionCount(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| size_t argsCount = std::min<size_t>(1, state->argumentCount()); |
| if (argsCount == 0) { |
| return jsIDBIndexPrototypeFunctionCount1(state); |
| } |
| if (argsCount == 1) { |
| JSValue distinguishingArg = state->uncheckedArgument(0); |
| if (distinguishingArg.isUndefined()) |
| return jsIDBIndexPrototypeFunctionCount1(state); |
| if (distinguishingArg.isUndefinedOrNull()) |
| return jsIDBIndexPrototypeFunctionCount1(state); |
| if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSIDBKeyRange::info())) |
| return jsIDBIndexPrototypeFunctionCount1(state); |
| return jsIDBIndexPrototypeFunctionCount2(state); |
| } |
| return throwVMTypeError(state, throwScope); |
| } |
| |
| void JSIDBIndex::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| { |
| auto* thisObject = jsCast<JSIDBIndex*>(cell); |
| ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| Base::visitChildren(thisObject, visitor); |
| thisObject->visitAdditionalChildren(visitor); |
| } |
| |
| bool JSIDBIndexOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) |
| { |
| auto* jsIDBIndex = jsCast<JSIDBIndex*>(handle.slot()->asCell()); |
| IDBIndex* root = &jsIDBIndex->wrapped(); |
| return visitor.containsOpaqueRoot(root); |
| } |
| |
| void JSIDBIndexOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| { |
| auto* jsIDBIndex = jsCast<JSIDBIndex*>(handle.slot()->asCell()); |
| auto& world = *static_cast<DOMWrapperWorld*>(context); |
| uncacheWrapper(world, &jsIDBIndex->wrapped(), jsIDBIndex); |
| } |
| |
| JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<IDBIndex>&& impl) |
| { |
| return createWrapper<IDBIndex>(globalObject, WTFMove(impl)); |
| } |
| |
| JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, IDBIndex& impl) |
| { |
| return wrap(state, globalObject, impl); |
| } |
| |
| IDBIndex* JSIDBIndex::toWrapped(JSC::JSValue value) |
| { |
| if (auto* wrapper = jsDynamicCast<JSIDBIndex*>(value)) |
| return &wrapper->wrapped(); |
| return nullptr; |
| } |
| |
| } |
| |
| #endif // ENABLE(INDEXED_DATABASE) |