| 1 | /* |
| 2 | This file is part of the WebKit open source project. |
| 3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Library General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Library General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Library General Public License |
| 16 | along with this library; see the file COPYING.LIB. If not, write to |
| 17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | Boston, MA 02110-1301, USA. |
| 19 | */ |
| 20 | |
| 21 | #include "config.h" |
| 22 | |
| 23 | #if ENABLE(INDEXED_DATABASE) |
| 24 | |
| 25 | #include "JSIDBIndex.h" |
| 26 | |
| 27 | #include "JSDOMAttribute.h" |
| 28 | #include "JSDOMBinding.h" |
| 29 | #include "JSDOMConstructorNotConstructable.h" |
| 30 | #include "JSDOMConvertAny.h" |
| 31 | #include "JSDOMConvertBoolean.h" |
| 32 | #include "JSDOMConvertEnumeration.h" |
| 33 | #include "JSDOMConvertInterface.h" |
| 34 | #include "JSDOMConvertNullable.h" |
| 35 | #include "JSDOMConvertNumbers.h" |
| 36 | #include "JSDOMConvertSequences.h" |
| 37 | #include "JSDOMConvertStrings.h" |
| 38 | #include "JSDOMConvertUnion.h" |
| 39 | #include "JSDOMExceptionHandling.h" |
| 40 | #include "JSDOMGlobalObject.h" |
| 41 | #include "JSDOMOperation.h" |
| 42 | #include "JSDOMWrapperCache.h" |
| 43 | #include "JSIDBCursorDirection.h" |
| 44 | #include "JSIDBKeyRange.h" |
| 45 | #include "JSIDBObjectStore.h" |
| 46 | #include "JSIDBRequest.h" |
| 47 | #include "ScriptExecutionContext.h" |
| 48 | #include <JavaScriptCore/FunctionPrototype.h> |
| 49 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 50 | #include <JavaScriptCore/JSArray.h> |
| 51 | #include <JavaScriptCore/JSCInlines.h> |
| 52 | #include <wtf/GetPtr.h> |
| 53 | #include <wtf/PointerPreparations.h> |
| 54 | #include <wtf/URL.h> |
| 55 | #include <wtf/Variant.h> |
| 56 | |
| 57 | |
| 58 | namespace WebCore { |
| 59 | using namespace JSC; |
| 60 | |
| 61 | // Functions |
| 62 | |
| 63 | JSC::EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionOpenCursor(JSC::ExecState*); |
| 64 | JSC::EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionOpenKeyCursor(JSC::ExecState*); |
| 65 | JSC::EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionGet(JSC::ExecState*); |
| 66 | JSC::EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionGetKey(JSC::ExecState*); |
| 67 | JSC::EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionGetAll(JSC::ExecState*); |
| 68 | JSC::EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionGetAllKeys(JSC::ExecState*); |
| 69 | JSC::EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionCount(JSC::ExecState*); |
| 70 | |
| 71 | // Attributes |
| 72 | |
| 73 | JSC::EncodedJSValue jsIDBIndexConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 74 | bool setJSIDBIndexConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 75 | JSC::EncodedJSValue jsIDBIndexName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 76 | bool setJSIDBIndexName(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 77 | JSC::EncodedJSValue jsIDBIndexObjectStore(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 78 | JSC::EncodedJSValue jsIDBIndexKeyPath(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 79 | JSC::EncodedJSValue jsIDBIndexMultiEntry(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 80 | JSC::EncodedJSValue jsIDBIndexUnique(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 81 | |
| 82 | class JSIDBIndexPrototype : public JSC::JSNonFinalObject { |
| 83 | public: |
| 84 | using Base = JSC::JSNonFinalObject; |
| 85 | static JSIDBIndexPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 86 | { |
| 87 | JSIDBIndexPrototype* ptr = new (NotNull, JSC::allocateCell<JSIDBIndexPrototype>(vm.heap)) JSIDBIndexPrototype(vm, globalObject, structure); |
| 88 | ptr->finishCreation(vm); |
| 89 | return ptr; |
| 90 | } |
| 91 | |
| 92 | DECLARE_INFO; |
| 93 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 94 | { |
| 95 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 96 | } |
| 97 | |
| 98 | private: |
| 99 | JSIDBIndexPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 100 | : JSC::JSNonFinalObject(vm, structure) |
| 101 | { |
| 102 | } |
| 103 | |
| 104 | void finishCreation(JSC::VM&); |
| 105 | }; |
| 106 | |
| 107 | using JSIDBIndexConstructor = JSDOMConstructorNotConstructable<JSIDBIndex>; |
| 108 | |
| 109 | template<> JSValue JSIDBIndexConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 110 | { |
| 111 | UNUSED_PARAM(vm); |
| 112 | return globalObject.functionPrototype(); |
| 113 | } |
| 114 | |
| 115 | template<> void JSIDBIndexConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 116 | { |
| 117 | putDirect(vm, vm.propertyNames->prototype, JSIDBIndex::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 118 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("IDBIndex"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 119 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 120 | } |
| 121 | |
| 122 | template<> const ClassInfo JSIDBIndexConstructor::s_info = { "IDBIndex" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIDBIndexConstructor) }; |
| 123 | |
| 124 | /* Hash table for prototype */ |
| 125 | |
| 126 | static const HashTableValue JSIDBIndexPrototypeTableValues[] = |
| 127 | { |
| 128 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBIndexConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSIDBIndexConstructor) } }, |
| 129 | { "name" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBIndexName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSIDBIndexName) } }, |
| 130 | { "objectStore" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBIndexObjectStore), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 131 | { "keyPath" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBIndexKeyPath), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 132 | { "multiEntry" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBIndexMultiEntry), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 133 | { "unique" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBIndexUnique), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 134 | { "openCursor" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsIDBIndexPrototypeFunctionOpenCursor), (intptr_t) (0) } }, |
| 135 | { "openKeyCursor" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsIDBIndexPrototypeFunctionOpenKeyCursor), (intptr_t) (0) } }, |
| 136 | { "get" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsIDBIndexPrototypeFunctionGet), (intptr_t) (1) } }, |
| 137 | { "getKey" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsIDBIndexPrototypeFunctionGetKey), (intptr_t) (1) } }, |
| 138 | { "getAll" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsIDBIndexPrototypeFunctionGetAll), (intptr_t) (0) } }, |
| 139 | { "getAllKeys" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsIDBIndexPrototypeFunctionGetAllKeys), (intptr_t) (0) } }, |
| 140 | { "count" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsIDBIndexPrototypeFunctionCount), (intptr_t) (0) } }, |
| 141 | }; |
| 142 | |
| 143 | const ClassInfo JSIDBIndexPrototype::s_info = { "IDBIndexPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIDBIndexPrototype) }; |
| 144 | |
| 145 | void JSIDBIndexPrototype::finishCreation(VM& vm) |
| 146 | { |
| 147 | Base::finishCreation(vm); |
| 148 | reifyStaticProperties(vm, JSIDBIndex::info(), JSIDBIndexPrototypeTableValues, *this); |
| 149 | } |
| 150 | |
| 151 | const ClassInfo JSIDBIndex::s_info = { "IDBIndex" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIDBIndex) }; |
| 152 | |
| 153 | JSIDBIndex::JSIDBIndex(Structure* structure, JSDOMGlobalObject& globalObject, Ref<IDBIndex>&& impl) |
| 154 | : JSDOMWrapper<IDBIndex>(structure, globalObject, WTFMove(impl)) |
| 155 | { |
| 156 | } |
| 157 | |
| 158 | void JSIDBIndex::finishCreation(VM& vm) |
| 159 | { |
| 160 | Base::finishCreation(vm); |
| 161 | ASSERT(inherits(vm, info())); |
| 162 | |
| 163 | } |
| 164 | |
| 165 | JSObject* JSIDBIndex::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 166 | { |
| 167 | return JSIDBIndexPrototype::create(vm, &globalObject, JSIDBIndexPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 168 | } |
| 169 | |
| 170 | JSObject* JSIDBIndex::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 171 | { |
| 172 | return getDOMPrototype<JSIDBIndex>(vm, globalObject); |
| 173 | } |
| 174 | |
| 175 | JSValue JSIDBIndex::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 176 | { |
| 177 | return getDOMConstructor<JSIDBIndexConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 178 | } |
| 179 | |
| 180 | void JSIDBIndex::destroy(JSC::JSCell* cell) |
| 181 | { |
| 182 | JSIDBIndex* thisObject = static_cast<JSIDBIndex*>(cell); |
| 183 | thisObject->JSIDBIndex::~JSIDBIndex(); |
| 184 | } |
| 185 | |
| 186 | template<> inline JSIDBIndex* IDLAttribute<JSIDBIndex>::cast(ExecState& state, EncodedJSValue thisValue) |
| 187 | { |
| 188 | return jsDynamicCast<JSIDBIndex*>(state.vm(), JSValue::decode(thisValue)); |
| 189 | } |
| 190 | |
| 191 | template<> inline JSIDBIndex* IDLOperation<JSIDBIndex>::cast(ExecState& state) |
| 192 | { |
| 193 | return jsDynamicCast<JSIDBIndex*>(state.vm(), state.thisValue()); |
| 194 | } |
| 195 | |
| 196 | EncodedJSValue jsIDBIndexConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 197 | { |
| 198 | VM& vm = state->vm(); |
| 199 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 200 | auto* prototype = jsDynamicCast<JSIDBIndexPrototype*>(vm, JSValue::decode(thisValue)); |
| 201 | if (UNLIKELY(!prototype)) |
| 202 | return throwVMTypeError(state, throwScope); |
| 203 | return JSValue::encode(JSIDBIndex::getConstructor(state->vm(), prototype->globalObject())); |
| 204 | } |
| 205 | |
| 206 | bool setJSIDBIndexConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 207 | { |
| 208 | VM& vm = state->vm(); |
| 209 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 210 | auto* prototype = jsDynamicCast<JSIDBIndexPrototype*>(vm, JSValue::decode(thisValue)); |
| 211 | if (UNLIKELY(!prototype)) { |
| 212 | throwVMTypeError(state, throwScope); |
| 213 | return false; |
| 214 | } |
| 215 | // Shadowing a built-in constructor |
| 216 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 217 | } |
| 218 | |
| 219 | static inline JSValue jsIDBIndexNameGetter(ExecState& state, JSIDBIndex& thisObject, ThrowScope& throwScope) |
| 220 | { |
| 221 | UNUSED_PARAM(throwScope); |
| 222 | UNUSED_PARAM(state); |
| 223 | auto& impl = thisObject.wrapped(); |
| 224 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.name()); |
| 225 | return result; |
| 226 | } |
| 227 | |
| 228 | EncodedJSValue jsIDBIndexName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 229 | { |
| 230 | return IDLAttribute<JSIDBIndex>::get<jsIDBIndexNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "name" ); |
| 231 | } |
| 232 | |
| 233 | static inline bool setJSIDBIndexNameSetter(ExecState& state, JSIDBIndex& thisObject, JSValue value, ThrowScope& throwScope) |
| 234 | { |
| 235 | UNUSED_PARAM(throwScope); |
| 236 | auto& impl = thisObject.wrapped(); |
| 237 | auto nativeValue = convert<IDLDOMString>(state, value); |
| 238 | RETURN_IF_EXCEPTION(throwScope, false); |
| 239 | AttributeSetter::call(state, throwScope, [&] { |
| 240 | return impl.setName(WTFMove(nativeValue)); |
| 241 | }); |
| 242 | return true; |
| 243 | } |
| 244 | |
| 245 | bool setJSIDBIndexName(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 246 | { |
| 247 | return IDLAttribute<JSIDBIndex>::set<setJSIDBIndexNameSetter>(*state, thisValue, encodedValue, "name" ); |
| 248 | } |
| 249 | |
| 250 | static inline JSValue jsIDBIndexObjectStoreGetter(ExecState& state, JSIDBIndex& thisObject, ThrowScope& throwScope) |
| 251 | { |
| 252 | UNUSED_PARAM(throwScope); |
| 253 | UNUSED_PARAM(state); |
| 254 | auto& impl = thisObject.wrapped(); |
| 255 | JSValue result = toJS<IDLInterface<IDBObjectStore>>(state, *thisObject.globalObject(), throwScope, impl.objectStore()); |
| 256 | return result; |
| 257 | } |
| 258 | |
| 259 | EncodedJSValue jsIDBIndexObjectStore(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 260 | { |
| 261 | return IDLAttribute<JSIDBIndex>::get<jsIDBIndexObjectStoreGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "objectStore" ); |
| 262 | } |
| 263 | |
| 264 | static inline JSValue jsIDBIndexKeyPathGetter(ExecState& state, JSIDBIndex& thisObject, ThrowScope& throwScope) |
| 265 | { |
| 266 | UNUSED_PARAM(throwScope); |
| 267 | UNUSED_PARAM(state); |
| 268 | auto& impl = thisObject.wrapped(); |
| 269 | JSValue result = toJS<IDLNullable<IDLUnion<IDLDOMString, IDLSequence<IDLDOMString>>>>(state, *thisObject.globalObject(), throwScope, impl.keyPath()); |
| 270 | return result; |
| 271 | } |
| 272 | |
| 273 | EncodedJSValue jsIDBIndexKeyPath(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 274 | { |
| 275 | return IDLAttribute<JSIDBIndex>::get<jsIDBIndexKeyPathGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "keyPath" ); |
| 276 | } |
| 277 | |
| 278 | static inline JSValue jsIDBIndexMultiEntryGetter(ExecState& state, JSIDBIndex& thisObject, ThrowScope& throwScope) |
| 279 | { |
| 280 | UNUSED_PARAM(throwScope); |
| 281 | UNUSED_PARAM(state); |
| 282 | auto& impl = thisObject.wrapped(); |
| 283 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.multiEntry()); |
| 284 | return result; |
| 285 | } |
| 286 | |
| 287 | EncodedJSValue jsIDBIndexMultiEntry(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 288 | { |
| 289 | return IDLAttribute<JSIDBIndex>::get<jsIDBIndexMultiEntryGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "multiEntry" ); |
| 290 | } |
| 291 | |
| 292 | static inline JSValue jsIDBIndexUniqueGetter(ExecState& state, JSIDBIndex& thisObject, ThrowScope& throwScope) |
| 293 | { |
| 294 | UNUSED_PARAM(throwScope); |
| 295 | UNUSED_PARAM(state); |
| 296 | auto& impl = thisObject.wrapped(); |
| 297 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.unique()); |
| 298 | return result; |
| 299 | } |
| 300 | |
| 301 | EncodedJSValue jsIDBIndexUnique(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 302 | { |
| 303 | return IDLAttribute<JSIDBIndex>::get<jsIDBIndexUniqueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "unique" ); |
| 304 | } |
| 305 | |
| 306 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionOpenCursor1Body(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 307 | { |
| 308 | UNUSED_PARAM(state); |
| 309 | UNUSED_PARAM(throwScope); |
| 310 | auto& impl = castedThis->wrapped(); |
| 311 | auto range = convert<IDLNullable<IDLInterface<IDBKeyRange>>>(*state, state->argument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "range" , "IDBIndex" , "openCursor" , "IDBKeyRange" ); }); |
| 312 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 313 | auto direction = state->argument(1).isUndefined() ? IDBCursorDirection::Next : convert<IDLEnumeration<IDBCursorDirection>>(*state, state->uncheckedArgument(1), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeEnumError(state, scope, 1, "direction" , "IDBIndex" , "openCursor" , expectedEnumerationValues<IDBCursorDirection>()); }); |
| 314 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 315 | return JSValue::encode(toJS<IDLInterface<IDBRequest>>(*state, *castedThis->globalObject(), throwScope, impl.openCursor(*state, WTFMove(range), WTFMove(direction)))); |
| 316 | } |
| 317 | |
| 318 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionOpenCursor2Body(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 319 | { |
| 320 | UNUSED_PARAM(state); |
| 321 | UNUSED_PARAM(throwScope); |
| 322 | auto& impl = castedThis->wrapped(); |
| 323 | auto key = convert<IDLAny>(*state, state->uncheckedArgument(0)); |
| 324 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 325 | auto direction = state->argument(1).isUndefined() ? IDBCursorDirection::Next : convert<IDLEnumeration<IDBCursorDirection>>(*state, state->uncheckedArgument(1), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeEnumError(state, scope, 1, "direction" , "IDBIndex" , "openCursor" , expectedEnumerationValues<IDBCursorDirection>()); }); |
| 326 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 327 | return JSValue::encode(toJS<IDLInterface<IDBRequest>>(*state, *castedThis->globalObject(), throwScope, impl.openCursor(*state, WTFMove(key), WTFMove(direction)))); |
| 328 | } |
| 329 | |
| 330 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionOpenCursorOverloadDispatcher(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 331 | { |
| 332 | UNUSED_PARAM(state); |
| 333 | UNUSED_PARAM(throwScope); |
| 334 | VM& vm = state->vm(); |
| 335 | UNUSED_PARAM(vm); |
| 336 | size_t argsCount = std::min<size_t>(2, state->argumentCount()); |
| 337 | if (argsCount == 0) { |
| 338 | return jsIDBIndexPrototypeFunctionOpenCursor1Body(state, castedThis, throwScope); |
| 339 | } |
| 340 | if (argsCount == 1) { |
| 341 | JSValue distinguishingArg = state->uncheckedArgument(0); |
| 342 | if (distinguishingArg.isUndefined()) |
| 343 | return jsIDBIndexPrototypeFunctionOpenCursor1Body(state, castedThis, throwScope); |
| 344 | if (distinguishingArg.isUndefinedOrNull()) |
| 345 | return jsIDBIndexPrototypeFunctionOpenCursor1Body(state, castedThis, throwScope); |
| 346 | if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits<JSIDBKeyRange>(vm)) |
| 347 | return jsIDBIndexPrototypeFunctionOpenCursor1Body(state, castedThis, throwScope); |
| 348 | return jsIDBIndexPrototypeFunctionOpenCursor2Body(state, castedThis, throwScope); |
| 349 | } |
| 350 | if (argsCount == 2) { |
| 351 | JSValue distinguishingArg = state->uncheckedArgument(0); |
| 352 | if (distinguishingArg.isUndefined()) |
| 353 | return jsIDBIndexPrototypeFunctionOpenCursor1Body(state, castedThis, throwScope); |
| 354 | if (distinguishingArg.isUndefinedOrNull()) |
| 355 | return jsIDBIndexPrototypeFunctionOpenCursor1Body(state, castedThis, throwScope); |
| 356 | if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits<JSIDBKeyRange>(vm)) |
| 357 | return jsIDBIndexPrototypeFunctionOpenCursor1Body(state, castedThis, throwScope); |
| 358 | return jsIDBIndexPrototypeFunctionOpenCursor2Body(state, castedThis, throwScope); |
| 359 | } |
| 360 | return throwVMTypeError(state, throwScope); |
| 361 | } |
| 362 | |
| 363 | EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionOpenCursor(ExecState* state) |
| 364 | { |
| 365 | return IDLOperation<JSIDBIndex>::call<jsIDBIndexPrototypeFunctionOpenCursorOverloadDispatcher>(*state, "openCursor" ); |
| 366 | } |
| 367 | |
| 368 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionOpenKeyCursor1Body(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 369 | { |
| 370 | UNUSED_PARAM(state); |
| 371 | UNUSED_PARAM(throwScope); |
| 372 | auto& impl = castedThis->wrapped(); |
| 373 | auto range = convert<IDLNullable<IDLInterface<IDBKeyRange>>>(*state, state->argument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "range" , "IDBIndex" , "openKeyCursor" , "IDBKeyRange" ); }); |
| 374 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 375 | auto direction = state->argument(1).isUndefined() ? IDBCursorDirection::Next : convert<IDLEnumeration<IDBCursorDirection>>(*state, state->uncheckedArgument(1), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeEnumError(state, scope, 1, "direction" , "IDBIndex" , "openKeyCursor" , expectedEnumerationValues<IDBCursorDirection>()); }); |
| 376 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 377 | return JSValue::encode(toJS<IDLInterface<IDBRequest>>(*state, *castedThis->globalObject(), throwScope, impl.openKeyCursor(*state, WTFMove(range), WTFMove(direction)))); |
| 378 | } |
| 379 | |
| 380 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionOpenKeyCursor2Body(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 381 | { |
| 382 | UNUSED_PARAM(state); |
| 383 | UNUSED_PARAM(throwScope); |
| 384 | auto& impl = castedThis->wrapped(); |
| 385 | auto key = convert<IDLAny>(*state, state->uncheckedArgument(0)); |
| 386 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 387 | auto direction = state->argument(1).isUndefined() ? IDBCursorDirection::Next : convert<IDLEnumeration<IDBCursorDirection>>(*state, state->uncheckedArgument(1), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeEnumError(state, scope, 1, "direction" , "IDBIndex" , "openKeyCursor" , expectedEnumerationValues<IDBCursorDirection>()); }); |
| 388 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 389 | return JSValue::encode(toJS<IDLInterface<IDBRequest>>(*state, *castedThis->globalObject(), throwScope, impl.openKeyCursor(*state, WTFMove(key), WTFMove(direction)))); |
| 390 | } |
| 391 | |
| 392 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionOpenKeyCursorOverloadDispatcher(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 393 | { |
| 394 | UNUSED_PARAM(state); |
| 395 | UNUSED_PARAM(throwScope); |
| 396 | VM& vm = state->vm(); |
| 397 | UNUSED_PARAM(vm); |
| 398 | size_t argsCount = std::min<size_t>(2, state->argumentCount()); |
| 399 | if (argsCount == 0) { |
| 400 | return jsIDBIndexPrototypeFunctionOpenKeyCursor1Body(state, castedThis, throwScope); |
| 401 | } |
| 402 | if (argsCount == 1) { |
| 403 | JSValue distinguishingArg = state->uncheckedArgument(0); |
| 404 | if (distinguishingArg.isUndefined()) |
| 405 | return jsIDBIndexPrototypeFunctionOpenKeyCursor1Body(state, castedThis, throwScope); |
| 406 | if (distinguishingArg.isUndefinedOrNull()) |
| 407 | return jsIDBIndexPrototypeFunctionOpenKeyCursor1Body(state, castedThis, throwScope); |
| 408 | if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits<JSIDBKeyRange>(vm)) |
| 409 | return jsIDBIndexPrototypeFunctionOpenKeyCursor1Body(state, castedThis, throwScope); |
| 410 | return jsIDBIndexPrototypeFunctionOpenKeyCursor2Body(state, castedThis, throwScope); |
| 411 | } |
| 412 | if (argsCount == 2) { |
| 413 | JSValue distinguishingArg = state->uncheckedArgument(0); |
| 414 | if (distinguishingArg.isUndefined()) |
| 415 | return jsIDBIndexPrototypeFunctionOpenKeyCursor1Body(state, castedThis, throwScope); |
| 416 | if (distinguishingArg.isUndefinedOrNull()) |
| 417 | return jsIDBIndexPrototypeFunctionOpenKeyCursor1Body(state, castedThis, throwScope); |
| 418 | if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits<JSIDBKeyRange>(vm)) |
| 419 | return jsIDBIndexPrototypeFunctionOpenKeyCursor1Body(state, castedThis, throwScope); |
| 420 | return jsIDBIndexPrototypeFunctionOpenKeyCursor2Body(state, castedThis, throwScope); |
| 421 | } |
| 422 | return throwVMTypeError(state, throwScope); |
| 423 | } |
| 424 | |
| 425 | EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionOpenKeyCursor(ExecState* state) |
| 426 | { |
| 427 | return IDLOperation<JSIDBIndex>::call<jsIDBIndexPrototypeFunctionOpenKeyCursorOverloadDispatcher>(*state, "openKeyCursor" ); |
| 428 | } |
| 429 | |
| 430 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionGet1Body(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 431 | { |
| 432 | UNUSED_PARAM(state); |
| 433 | UNUSED_PARAM(throwScope); |
| 434 | auto& impl = castedThis->wrapped(); |
| 435 | auto key = convert<IDLNullable<IDLInterface<IDBKeyRange>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "key" , "IDBIndex" , "get" , "IDBKeyRange" ); }); |
| 436 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 437 | return JSValue::encode(toJS<IDLInterface<IDBRequest>>(*state, *castedThis->globalObject(), throwScope, impl.get(*state, WTFMove(key)))); |
| 438 | } |
| 439 | |
| 440 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionGet2Body(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 441 | { |
| 442 | UNUSED_PARAM(state); |
| 443 | UNUSED_PARAM(throwScope); |
| 444 | auto& impl = castedThis->wrapped(); |
| 445 | auto key = convert<IDLAny>(*state, state->uncheckedArgument(0)); |
| 446 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 447 | return JSValue::encode(toJS<IDLInterface<IDBRequest>>(*state, *castedThis->globalObject(), throwScope, impl.get(*state, WTFMove(key)))); |
| 448 | } |
| 449 | |
| 450 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionGetOverloadDispatcher(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 451 | { |
| 452 | UNUSED_PARAM(state); |
| 453 | UNUSED_PARAM(throwScope); |
| 454 | VM& vm = state->vm(); |
| 455 | UNUSED_PARAM(vm); |
| 456 | size_t argsCount = std::min<size_t>(1, state->argumentCount()); |
| 457 | if (argsCount == 1) { |
| 458 | JSValue distinguishingArg = state->uncheckedArgument(0); |
| 459 | if (distinguishingArg.isUndefinedOrNull()) |
| 460 | return jsIDBIndexPrototypeFunctionGet1Body(state, castedThis, throwScope); |
| 461 | if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits<JSIDBKeyRange>(vm)) |
| 462 | return jsIDBIndexPrototypeFunctionGet1Body(state, castedThis, throwScope); |
| 463 | return jsIDBIndexPrototypeFunctionGet2Body(state, castedThis, throwScope); |
| 464 | } |
| 465 | return argsCount < 1 ? throwVMError(state, throwScope, createNotEnoughArgumentsError(state)) : throwVMTypeError(state, throwScope); |
| 466 | } |
| 467 | |
| 468 | EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionGet(ExecState* state) |
| 469 | { |
| 470 | return IDLOperation<JSIDBIndex>::call<jsIDBIndexPrototypeFunctionGetOverloadDispatcher>(*state, "get" ); |
| 471 | } |
| 472 | |
| 473 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionGetKey1Body(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 474 | { |
| 475 | UNUSED_PARAM(state); |
| 476 | UNUSED_PARAM(throwScope); |
| 477 | auto& impl = castedThis->wrapped(); |
| 478 | auto key = convert<IDLNullable<IDLInterface<IDBKeyRange>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "key" , "IDBIndex" , "getKey" , "IDBKeyRange" ); }); |
| 479 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 480 | return JSValue::encode(toJS<IDLInterface<IDBRequest>>(*state, *castedThis->globalObject(), throwScope, impl.getKey(*state, WTFMove(key)))); |
| 481 | } |
| 482 | |
| 483 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionGetKey2Body(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 484 | { |
| 485 | UNUSED_PARAM(state); |
| 486 | UNUSED_PARAM(throwScope); |
| 487 | auto& impl = castedThis->wrapped(); |
| 488 | auto key = convert<IDLAny>(*state, state->uncheckedArgument(0)); |
| 489 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 490 | return JSValue::encode(toJS<IDLInterface<IDBRequest>>(*state, *castedThis->globalObject(), throwScope, impl.getKey(*state, WTFMove(key)))); |
| 491 | } |
| 492 | |
| 493 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionGetKeyOverloadDispatcher(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 494 | { |
| 495 | UNUSED_PARAM(state); |
| 496 | UNUSED_PARAM(throwScope); |
| 497 | VM& vm = state->vm(); |
| 498 | UNUSED_PARAM(vm); |
| 499 | size_t argsCount = std::min<size_t>(1, state->argumentCount()); |
| 500 | if (argsCount == 1) { |
| 501 | JSValue distinguishingArg = state->uncheckedArgument(0); |
| 502 | if (distinguishingArg.isUndefinedOrNull()) |
| 503 | return jsIDBIndexPrototypeFunctionGetKey1Body(state, castedThis, throwScope); |
| 504 | if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits<JSIDBKeyRange>(vm)) |
| 505 | return jsIDBIndexPrototypeFunctionGetKey1Body(state, castedThis, throwScope); |
| 506 | return jsIDBIndexPrototypeFunctionGetKey2Body(state, castedThis, throwScope); |
| 507 | } |
| 508 | return argsCount < 1 ? throwVMError(state, throwScope, createNotEnoughArgumentsError(state)) : throwVMTypeError(state, throwScope); |
| 509 | } |
| 510 | |
| 511 | EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionGetKey(ExecState* state) |
| 512 | { |
| 513 | return IDLOperation<JSIDBIndex>::call<jsIDBIndexPrototypeFunctionGetKeyOverloadDispatcher>(*state, "getKey" ); |
| 514 | } |
| 515 | |
| 516 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionGetAll1Body(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 517 | { |
| 518 | UNUSED_PARAM(state); |
| 519 | UNUSED_PARAM(throwScope); |
| 520 | auto& impl = castedThis->wrapped(); |
| 521 | auto range = convert<IDLNullable<IDLInterface<IDBKeyRange>>>(*state, state->argument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "range" , "IDBIndex" , "getAll" , "IDBKeyRange" ); }); |
| 522 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 523 | auto count = state->argument(1).isUndefined() ? Optional<Converter<IDLEnforceRangeAdaptor<IDLUnsignedLong>>::ReturnType>() : Optional<Converter<IDLEnforceRangeAdaptor<IDLUnsignedLong>>::ReturnType>(convert<IDLEnforceRangeAdaptor<IDLUnsignedLong>>(*state, state->uncheckedArgument(1))); |
| 524 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 525 | return JSValue::encode(toJS<IDLInterface<IDBRequest>>(*state, *castedThis->globalObject(), throwScope, impl.getAll(*state, WTFMove(range), WTFMove(count)))); |
| 526 | } |
| 527 | |
| 528 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionGetAll2Body(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 529 | { |
| 530 | UNUSED_PARAM(state); |
| 531 | UNUSED_PARAM(throwScope); |
| 532 | auto& impl = castedThis->wrapped(); |
| 533 | auto key = convert<IDLAny>(*state, state->uncheckedArgument(0)); |
| 534 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 535 | auto count = state->argument(1).isUndefined() ? Optional<Converter<IDLEnforceRangeAdaptor<IDLUnsignedLong>>::ReturnType>() : Optional<Converter<IDLEnforceRangeAdaptor<IDLUnsignedLong>>::ReturnType>(convert<IDLEnforceRangeAdaptor<IDLUnsignedLong>>(*state, state->uncheckedArgument(1))); |
| 536 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 537 | return JSValue::encode(toJS<IDLInterface<IDBRequest>>(*state, *castedThis->globalObject(), throwScope, impl.getAll(*state, WTFMove(key), WTFMove(count)))); |
| 538 | } |
| 539 | |
| 540 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionGetAllOverloadDispatcher(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 541 | { |
| 542 | UNUSED_PARAM(state); |
| 543 | UNUSED_PARAM(throwScope); |
| 544 | VM& vm = state->vm(); |
| 545 | UNUSED_PARAM(vm); |
| 546 | size_t argsCount = std::min<size_t>(2, state->argumentCount()); |
| 547 | if (argsCount == 0) { |
| 548 | return jsIDBIndexPrototypeFunctionGetAll1Body(state, castedThis, throwScope); |
| 549 | } |
| 550 | if (argsCount == 1) { |
| 551 | JSValue distinguishingArg = state->uncheckedArgument(0); |
| 552 | if (distinguishingArg.isUndefined()) |
| 553 | return jsIDBIndexPrototypeFunctionGetAll1Body(state, castedThis, throwScope); |
| 554 | if (distinguishingArg.isUndefinedOrNull()) |
| 555 | return jsIDBIndexPrototypeFunctionGetAll1Body(state, castedThis, throwScope); |
| 556 | if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits<JSIDBKeyRange>(vm)) |
| 557 | return jsIDBIndexPrototypeFunctionGetAll1Body(state, castedThis, throwScope); |
| 558 | return jsIDBIndexPrototypeFunctionGetAll2Body(state, castedThis, throwScope); |
| 559 | } |
| 560 | if (argsCount == 2) { |
| 561 | JSValue distinguishingArg = state->uncheckedArgument(0); |
| 562 | if (distinguishingArg.isUndefined()) |
| 563 | return jsIDBIndexPrototypeFunctionGetAll1Body(state, castedThis, throwScope); |
| 564 | if (distinguishingArg.isUndefinedOrNull()) |
| 565 | return jsIDBIndexPrototypeFunctionGetAll1Body(state, castedThis, throwScope); |
| 566 | if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits<JSIDBKeyRange>(vm)) |
| 567 | return jsIDBIndexPrototypeFunctionGetAll1Body(state, castedThis, throwScope); |
| 568 | return jsIDBIndexPrototypeFunctionGetAll2Body(state, castedThis, throwScope); |
| 569 | } |
| 570 | return throwVMTypeError(state, throwScope); |
| 571 | } |
| 572 | |
| 573 | EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionGetAll(ExecState* state) |
| 574 | { |
| 575 | return IDLOperation<JSIDBIndex>::call<jsIDBIndexPrototypeFunctionGetAllOverloadDispatcher>(*state, "getAll" ); |
| 576 | } |
| 577 | |
| 578 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionGetAllKeys1Body(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 579 | { |
| 580 | UNUSED_PARAM(state); |
| 581 | UNUSED_PARAM(throwScope); |
| 582 | auto& impl = castedThis->wrapped(); |
| 583 | auto range = convert<IDLNullable<IDLInterface<IDBKeyRange>>>(*state, state->argument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "range" , "IDBIndex" , "getAllKeys" , "IDBKeyRange" ); }); |
| 584 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 585 | auto count = state->argument(1).isUndefined() ? Optional<Converter<IDLEnforceRangeAdaptor<IDLUnsignedLong>>::ReturnType>() : Optional<Converter<IDLEnforceRangeAdaptor<IDLUnsignedLong>>::ReturnType>(convert<IDLEnforceRangeAdaptor<IDLUnsignedLong>>(*state, state->uncheckedArgument(1))); |
| 586 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 587 | return JSValue::encode(toJS<IDLInterface<IDBRequest>>(*state, *castedThis->globalObject(), throwScope, impl.getAllKeys(*state, WTFMove(range), WTFMove(count)))); |
| 588 | } |
| 589 | |
| 590 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionGetAllKeys2Body(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 591 | { |
| 592 | UNUSED_PARAM(state); |
| 593 | UNUSED_PARAM(throwScope); |
| 594 | auto& impl = castedThis->wrapped(); |
| 595 | auto key = convert<IDLAny>(*state, state->uncheckedArgument(0)); |
| 596 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 597 | auto count = state->argument(1).isUndefined() ? Optional<Converter<IDLEnforceRangeAdaptor<IDLUnsignedLong>>::ReturnType>() : Optional<Converter<IDLEnforceRangeAdaptor<IDLUnsignedLong>>::ReturnType>(convert<IDLEnforceRangeAdaptor<IDLUnsignedLong>>(*state, state->uncheckedArgument(1))); |
| 598 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 599 | return JSValue::encode(toJS<IDLInterface<IDBRequest>>(*state, *castedThis->globalObject(), throwScope, impl.getAllKeys(*state, WTFMove(key), WTFMove(count)))); |
| 600 | } |
| 601 | |
| 602 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionGetAllKeysOverloadDispatcher(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 603 | { |
| 604 | UNUSED_PARAM(state); |
| 605 | UNUSED_PARAM(throwScope); |
| 606 | VM& vm = state->vm(); |
| 607 | UNUSED_PARAM(vm); |
| 608 | size_t argsCount = std::min<size_t>(2, state->argumentCount()); |
| 609 | if (argsCount == 0) { |
| 610 | return jsIDBIndexPrototypeFunctionGetAllKeys1Body(state, castedThis, throwScope); |
| 611 | } |
| 612 | if (argsCount == 1) { |
| 613 | JSValue distinguishingArg = state->uncheckedArgument(0); |
| 614 | if (distinguishingArg.isUndefined()) |
| 615 | return jsIDBIndexPrototypeFunctionGetAllKeys1Body(state, castedThis, throwScope); |
| 616 | if (distinguishingArg.isUndefinedOrNull()) |
| 617 | return jsIDBIndexPrototypeFunctionGetAllKeys1Body(state, castedThis, throwScope); |
| 618 | if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits<JSIDBKeyRange>(vm)) |
| 619 | return jsIDBIndexPrototypeFunctionGetAllKeys1Body(state, castedThis, throwScope); |
| 620 | return jsIDBIndexPrototypeFunctionGetAllKeys2Body(state, castedThis, throwScope); |
| 621 | } |
| 622 | if (argsCount == 2) { |
| 623 | JSValue distinguishingArg = state->uncheckedArgument(0); |
| 624 | if (distinguishingArg.isUndefined()) |
| 625 | return jsIDBIndexPrototypeFunctionGetAllKeys1Body(state, castedThis, throwScope); |
| 626 | if (distinguishingArg.isUndefinedOrNull()) |
| 627 | return jsIDBIndexPrototypeFunctionGetAllKeys1Body(state, castedThis, throwScope); |
| 628 | if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits<JSIDBKeyRange>(vm)) |
| 629 | return jsIDBIndexPrototypeFunctionGetAllKeys1Body(state, castedThis, throwScope); |
| 630 | return jsIDBIndexPrototypeFunctionGetAllKeys2Body(state, castedThis, throwScope); |
| 631 | } |
| 632 | return throwVMTypeError(state, throwScope); |
| 633 | } |
| 634 | |
| 635 | EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionGetAllKeys(ExecState* state) |
| 636 | { |
| 637 | return IDLOperation<JSIDBIndex>::call<jsIDBIndexPrototypeFunctionGetAllKeysOverloadDispatcher>(*state, "getAllKeys" ); |
| 638 | } |
| 639 | |
| 640 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionCount1Body(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 641 | { |
| 642 | UNUSED_PARAM(state); |
| 643 | UNUSED_PARAM(throwScope); |
| 644 | auto& impl = castedThis->wrapped(); |
| 645 | auto range = convert<IDLNullable<IDLInterface<IDBKeyRange>>>(*state, state->argument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "range" , "IDBIndex" , "count" , "IDBKeyRange" ); }); |
| 646 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 647 | return JSValue::encode(toJS<IDLInterface<IDBRequest>>(*state, *castedThis->globalObject(), throwScope, impl.count(*state, WTFMove(range)))); |
| 648 | } |
| 649 | |
| 650 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionCount2Body(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 651 | { |
| 652 | UNUSED_PARAM(state); |
| 653 | UNUSED_PARAM(throwScope); |
| 654 | auto& impl = castedThis->wrapped(); |
| 655 | auto key = convert<IDLAny>(*state, state->uncheckedArgument(0)); |
| 656 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 657 | return JSValue::encode(toJS<IDLInterface<IDBRequest>>(*state, *castedThis->globalObject(), throwScope, impl.count(*state, WTFMove(key)))); |
| 658 | } |
| 659 | |
| 660 | static inline JSC::EncodedJSValue jsIDBIndexPrototypeFunctionCountOverloadDispatcher(JSC::ExecState* state, typename IDLOperation<JSIDBIndex>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 661 | { |
| 662 | UNUSED_PARAM(state); |
| 663 | UNUSED_PARAM(throwScope); |
| 664 | VM& vm = state->vm(); |
| 665 | UNUSED_PARAM(vm); |
| 666 | size_t argsCount = std::min<size_t>(1, state->argumentCount()); |
| 667 | if (argsCount == 0) { |
| 668 | return jsIDBIndexPrototypeFunctionCount1Body(state, castedThis, throwScope); |
| 669 | } |
| 670 | if (argsCount == 1) { |
| 671 | JSValue distinguishingArg = state->uncheckedArgument(0); |
| 672 | if (distinguishingArg.isUndefined()) |
| 673 | return jsIDBIndexPrototypeFunctionCount1Body(state, castedThis, throwScope); |
| 674 | if (distinguishingArg.isUndefinedOrNull()) |
| 675 | return jsIDBIndexPrototypeFunctionCount1Body(state, castedThis, throwScope); |
| 676 | if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits<JSIDBKeyRange>(vm)) |
| 677 | return jsIDBIndexPrototypeFunctionCount1Body(state, castedThis, throwScope); |
| 678 | return jsIDBIndexPrototypeFunctionCount2Body(state, castedThis, throwScope); |
| 679 | } |
| 680 | return throwVMTypeError(state, throwScope); |
| 681 | } |
| 682 | |
| 683 | EncodedJSValue JSC_HOST_CALL jsIDBIndexPrototypeFunctionCount(ExecState* state) |
| 684 | { |
| 685 | return IDLOperation<JSIDBIndex>::call<jsIDBIndexPrototypeFunctionCountOverloadDispatcher>(*state, "count" ); |
| 686 | } |
| 687 | |
| 688 | void JSIDBIndex::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| 689 | { |
| 690 | auto* thisObject = jsCast<JSIDBIndex*>(cell); |
| 691 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 692 | Base::visitChildren(thisObject, visitor); |
| 693 | thisObject->visitAdditionalChildren(visitor); |
| 694 | } |
| 695 | |
| 696 | void JSIDBIndex::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor) |
| 697 | { |
| 698 | auto* thisObject = jsCast<JSIDBIndex*>(cell); |
| 699 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 700 | Base::visitOutputConstraints(thisObject, visitor); |
| 701 | thisObject->visitAdditionalChildren(visitor); |
| 702 | } |
| 703 | |
| 704 | void JSIDBIndex::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 705 | { |
| 706 | auto* thisObject = jsCast<JSIDBIndex*>(cell); |
| 707 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 708 | if (thisObject->scriptExecutionContext()) |
| 709 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 710 | Base::heapSnapshot(cell, builder); |
| 711 | } |
| 712 | |
| 713 | bool JSIDBIndexOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 714 | { |
| 715 | auto* jsIDBIndex = jsCast<JSIDBIndex*>(handle.slot()->asCell()); |
| 716 | IDBIndex* root = &jsIDBIndex->wrapped(); |
| 717 | if (UNLIKELY(reason)) |
| 718 | *reason = "Reachable from IDBIndex" ; |
| 719 | return visitor.containsOpaqueRoot(root); |
| 720 | } |
| 721 | |
| 722 | void JSIDBIndexOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 723 | { |
| 724 | auto* jsIDBIndex = static_cast<JSIDBIndex*>(handle.slot()->asCell()); |
| 725 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 726 | uncacheWrapper(world, &jsIDBIndex->wrapped(), jsIDBIndex); |
| 727 | } |
| 728 | |
| 729 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<IDBIndex>&& impl) |
| 730 | { |
| 731 | return createWrapper<IDBIndex>(globalObject, WTFMove(impl)); |
| 732 | } |
| 733 | |
| 734 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, IDBIndex& impl) |
| 735 | { |
| 736 | return wrap(state, globalObject, impl); |
| 737 | } |
| 738 | |
| 739 | IDBIndex* JSIDBIndex::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 740 | { |
| 741 | if (auto* wrapper = jsDynamicCast<JSIDBIndex*>(vm, value)) |
| 742 | return &wrapper->wrapped(); |
| 743 | return nullptr; |
| 744 | } |
| 745 | |
| 746 | } |
| 747 | |
| 748 | #endif // ENABLE(INDEXED_DATABASE) |
| 749 | |