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 "JSIDBFactory.h" |
26 | |
27 | #include "JSDOMBinding.h" |
28 | #include "JSDOMConstructorNotConstructable.h" |
29 | #include "JSDOMConvertAny.h" |
30 | #include "JSDOMConvertInterface.h" |
31 | #include "JSDOMConvertNumbers.h" |
32 | #include "JSDOMConvertStrings.h" |
33 | #include "JSDOMExceptionHandling.h" |
34 | #include "JSDOMGlobalObject.h" |
35 | #include "JSDOMOperation.h" |
36 | #include "JSDOMWrapperCache.h" |
37 | #include "JSIDBOpenDBRequest.h" |
38 | #include "ScriptExecutionContext.h" |
39 | #include <JavaScriptCore/FunctionPrototype.h> |
40 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
41 | #include <JavaScriptCore/JSCInlines.h> |
42 | #include <wtf/GetPtr.h> |
43 | #include <wtf/PointerPreparations.h> |
44 | #include <wtf/URL.h> |
45 | |
46 | |
47 | namespace WebCore { |
48 | using namespace JSC; |
49 | |
50 | // Functions |
51 | |
52 | JSC::EncodedJSValue JSC_HOST_CALL jsIDBFactoryPrototypeFunctionOpen(JSC::ExecState*); |
53 | JSC::EncodedJSValue JSC_HOST_CALL jsIDBFactoryPrototypeFunctionDeleteDatabase(JSC::ExecState*); |
54 | JSC::EncodedJSValue JSC_HOST_CALL jsIDBFactoryPrototypeFunctionCmp(JSC::ExecState*); |
55 | |
56 | // Attributes |
57 | |
58 | JSC::EncodedJSValue jsIDBFactoryConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
59 | bool setJSIDBFactoryConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
60 | |
61 | class JSIDBFactoryPrototype : public JSC::JSNonFinalObject { |
62 | public: |
63 | using Base = JSC::JSNonFinalObject; |
64 | static JSIDBFactoryPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
65 | { |
66 | JSIDBFactoryPrototype* ptr = new (NotNull, JSC::allocateCell<JSIDBFactoryPrototype>(vm.heap)) JSIDBFactoryPrototype(vm, globalObject, structure); |
67 | ptr->finishCreation(vm); |
68 | return ptr; |
69 | } |
70 | |
71 | DECLARE_INFO; |
72 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
73 | { |
74 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
75 | } |
76 | |
77 | private: |
78 | JSIDBFactoryPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
79 | : JSC::JSNonFinalObject(vm, structure) |
80 | { |
81 | } |
82 | |
83 | void finishCreation(JSC::VM&); |
84 | }; |
85 | |
86 | using JSIDBFactoryConstructor = JSDOMConstructorNotConstructable<JSIDBFactory>; |
87 | |
88 | template<> JSValue JSIDBFactoryConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
89 | { |
90 | UNUSED_PARAM(vm); |
91 | return globalObject.functionPrototype(); |
92 | } |
93 | |
94 | template<> void JSIDBFactoryConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
95 | { |
96 | putDirect(vm, vm.propertyNames->prototype, JSIDBFactory::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
97 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("IDBFactory"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
98 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
99 | } |
100 | |
101 | template<> const ClassInfo JSIDBFactoryConstructor::s_info = { "IDBFactory" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIDBFactoryConstructor) }; |
102 | |
103 | /* Hash table for prototype */ |
104 | |
105 | static const HashTableValue JSIDBFactoryPrototypeTableValues[] = |
106 | { |
107 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBFactoryConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSIDBFactoryConstructor) } }, |
108 | { "open" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsIDBFactoryPrototypeFunctionOpen), (intptr_t) (1) } }, |
109 | { "deleteDatabase" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsIDBFactoryPrototypeFunctionDeleteDatabase), (intptr_t) (1) } }, |
110 | { "cmp" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsIDBFactoryPrototypeFunctionCmp), (intptr_t) (2) } }, |
111 | }; |
112 | |
113 | const ClassInfo JSIDBFactoryPrototype::s_info = { "IDBFactoryPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIDBFactoryPrototype) }; |
114 | |
115 | void JSIDBFactoryPrototype::finishCreation(VM& vm) |
116 | { |
117 | Base::finishCreation(vm); |
118 | reifyStaticProperties(vm, JSIDBFactory::info(), JSIDBFactoryPrototypeTableValues, *this); |
119 | } |
120 | |
121 | const ClassInfo JSIDBFactory::s_info = { "IDBFactory" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIDBFactory) }; |
122 | |
123 | JSIDBFactory::JSIDBFactory(Structure* structure, JSDOMGlobalObject& globalObject, Ref<IDBFactory>&& impl) |
124 | : JSDOMWrapper<IDBFactory>(structure, globalObject, WTFMove(impl)) |
125 | { |
126 | } |
127 | |
128 | void JSIDBFactory::finishCreation(VM& vm) |
129 | { |
130 | Base::finishCreation(vm); |
131 | ASSERT(inherits(vm, info())); |
132 | |
133 | } |
134 | |
135 | JSObject* JSIDBFactory::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
136 | { |
137 | return JSIDBFactoryPrototype::create(vm, &globalObject, JSIDBFactoryPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
138 | } |
139 | |
140 | JSObject* JSIDBFactory::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
141 | { |
142 | return getDOMPrototype<JSIDBFactory>(vm, globalObject); |
143 | } |
144 | |
145 | JSValue JSIDBFactory::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
146 | { |
147 | return getDOMConstructor<JSIDBFactoryConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
148 | } |
149 | |
150 | void JSIDBFactory::destroy(JSC::JSCell* cell) |
151 | { |
152 | JSIDBFactory* thisObject = static_cast<JSIDBFactory*>(cell); |
153 | thisObject->JSIDBFactory::~JSIDBFactory(); |
154 | } |
155 | |
156 | template<> inline JSIDBFactory* IDLOperation<JSIDBFactory>::cast(ExecState& state) |
157 | { |
158 | return jsDynamicCast<JSIDBFactory*>(state.vm(), state.thisValue()); |
159 | } |
160 | |
161 | EncodedJSValue jsIDBFactoryConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
162 | { |
163 | VM& vm = state->vm(); |
164 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
165 | auto* prototype = jsDynamicCast<JSIDBFactoryPrototype*>(vm, JSValue::decode(thisValue)); |
166 | if (UNLIKELY(!prototype)) |
167 | return throwVMTypeError(state, throwScope); |
168 | return JSValue::encode(JSIDBFactory::getConstructor(state->vm(), prototype->globalObject())); |
169 | } |
170 | |
171 | bool setJSIDBFactoryConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
172 | { |
173 | VM& vm = state->vm(); |
174 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
175 | auto* prototype = jsDynamicCast<JSIDBFactoryPrototype*>(vm, JSValue::decode(thisValue)); |
176 | if (UNLIKELY(!prototype)) { |
177 | throwVMTypeError(state, throwScope); |
178 | return false; |
179 | } |
180 | // Shadowing a built-in constructor |
181 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
182 | } |
183 | |
184 | static inline JSC::EncodedJSValue jsIDBFactoryPrototypeFunctionOpenBody(JSC::ExecState* state, typename IDLOperation<JSIDBFactory>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
185 | { |
186 | UNUSED_PARAM(state); |
187 | UNUSED_PARAM(throwScope); |
188 | auto& impl = castedThis->wrapped(); |
189 | if (UNLIKELY(state->argumentCount() < 1)) |
190 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
191 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
192 | if (UNLIKELY(!context)) |
193 | return JSValue::encode(jsUndefined()); |
194 | auto name = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
195 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
196 | auto version = state->argument(1).isUndefined() ? Optional<Converter<IDLEnforceRangeAdaptor<IDLUnsignedLongLong>>::ReturnType>() : Optional<Converter<IDLEnforceRangeAdaptor<IDLUnsignedLongLong>>::ReturnType>(convert<IDLEnforceRangeAdaptor<IDLUnsignedLongLong>>(*state, state->uncheckedArgument(1))); |
197 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
198 | return JSValue::encode(toJS<IDLInterface<IDBOpenDBRequest>>(*state, *castedThis->globalObject(), throwScope, impl.open(*context, WTFMove(name), WTFMove(version)))); |
199 | } |
200 | |
201 | EncodedJSValue JSC_HOST_CALL jsIDBFactoryPrototypeFunctionOpen(ExecState* state) |
202 | { |
203 | return IDLOperation<JSIDBFactory>::call<jsIDBFactoryPrototypeFunctionOpenBody>(*state, "open" ); |
204 | } |
205 | |
206 | static inline JSC::EncodedJSValue jsIDBFactoryPrototypeFunctionDeleteDatabaseBody(JSC::ExecState* state, typename IDLOperation<JSIDBFactory>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
207 | { |
208 | UNUSED_PARAM(state); |
209 | UNUSED_PARAM(throwScope); |
210 | auto& impl = castedThis->wrapped(); |
211 | if (UNLIKELY(state->argumentCount() < 1)) |
212 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
213 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
214 | if (UNLIKELY(!context)) |
215 | return JSValue::encode(jsUndefined()); |
216 | auto name = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
217 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
218 | return JSValue::encode(toJS<IDLInterface<IDBOpenDBRequest>>(*state, *castedThis->globalObject(), throwScope, impl.deleteDatabase(*context, WTFMove(name)))); |
219 | } |
220 | |
221 | EncodedJSValue JSC_HOST_CALL jsIDBFactoryPrototypeFunctionDeleteDatabase(ExecState* state) |
222 | { |
223 | return IDLOperation<JSIDBFactory>::call<jsIDBFactoryPrototypeFunctionDeleteDatabaseBody>(*state, "deleteDatabase" ); |
224 | } |
225 | |
226 | static inline JSC::EncodedJSValue jsIDBFactoryPrototypeFunctionCmpBody(JSC::ExecState* state, typename IDLOperation<JSIDBFactory>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
227 | { |
228 | UNUSED_PARAM(state); |
229 | UNUSED_PARAM(throwScope); |
230 | auto& impl = castedThis->wrapped(); |
231 | if (UNLIKELY(state->argumentCount() < 2)) |
232 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
233 | auto first = convert<IDLAny>(*state, state->uncheckedArgument(0)); |
234 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
235 | auto second = convert<IDLAny>(*state, state->uncheckedArgument(1)); |
236 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
237 | return JSValue::encode(toJS<IDLShort>(*state, throwScope, impl.cmp(*state, WTFMove(first), WTFMove(second)))); |
238 | } |
239 | |
240 | EncodedJSValue JSC_HOST_CALL jsIDBFactoryPrototypeFunctionCmp(ExecState* state) |
241 | { |
242 | return IDLOperation<JSIDBFactory>::call<jsIDBFactoryPrototypeFunctionCmpBody>(*state, "cmp" ); |
243 | } |
244 | |
245 | void JSIDBFactory::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
246 | { |
247 | auto* thisObject = jsCast<JSIDBFactory*>(cell); |
248 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
249 | if (thisObject->scriptExecutionContext()) |
250 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
251 | Base::heapSnapshot(cell, builder); |
252 | } |
253 | |
254 | bool JSIDBFactoryOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
255 | { |
256 | UNUSED_PARAM(handle); |
257 | UNUSED_PARAM(visitor); |
258 | UNUSED_PARAM(reason); |
259 | return false; |
260 | } |
261 | |
262 | void JSIDBFactoryOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
263 | { |
264 | auto* jsIDBFactory = static_cast<JSIDBFactory*>(handle.slot()->asCell()); |
265 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
266 | uncacheWrapper(world, &jsIDBFactory->wrapped(), jsIDBFactory); |
267 | } |
268 | |
269 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<IDBFactory>&& impl) |
270 | { |
271 | return createWrapper<IDBFactory>(globalObject, WTFMove(impl)); |
272 | } |
273 | |
274 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, IDBFactory& impl) |
275 | { |
276 | return wrap(state, globalObject, impl); |
277 | } |
278 | |
279 | IDBFactory* JSIDBFactory::toWrapped(JSC::VM& vm, JSC::JSValue value) |
280 | { |
281 | if (auto* wrapper = jsDynamicCast<JSIDBFactory*>(vm, value)) |
282 | return &wrapper->wrapped(); |
283 | return nullptr; |
284 | } |
285 | |
286 | } |
287 | |
288 | #endif // ENABLE(INDEXED_DATABASE) |
289 | |