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 "JSIDBVersionChangeEvent.h" |
26 | |
27 | #include "JSDOMAttribute.h" |
28 | #include "JSDOMBinding.h" |
29 | #include "JSDOMConstructor.h" |
30 | #include "JSDOMConvertBoolean.h" |
31 | #include "JSDOMConvertInterface.h" |
32 | #include "JSDOMConvertNullable.h" |
33 | #include "JSDOMConvertNumbers.h" |
34 | #include "JSDOMExceptionHandling.h" |
35 | #include "JSDOMWrapperCache.h" |
36 | #include "ScriptExecutionContext.h" |
37 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
38 | #include <JavaScriptCore/JSCInlines.h> |
39 | #include <wtf/GetPtr.h> |
40 | #include <wtf/PointerPreparations.h> |
41 | #include <wtf/URL.h> |
42 | |
43 | #if ENABLE(INDEXED_DATABASE) |
44 | #include "JSDOMConvertStrings.h" |
45 | #endif |
46 | |
47 | |
48 | namespace WebCore { |
49 | using namespace JSC; |
50 | |
51 | template<> IDBVersionChangeEvent::Init convertDictionary<IDBVersionChangeEvent::Init>(ExecState& state, JSValue value) |
52 | { |
53 | VM& vm = state.vm(); |
54 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
55 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
56 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
57 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
58 | throwTypeError(&state, throwScope); |
59 | return { }; |
60 | } |
61 | IDBVersionChangeEvent::Init result; |
62 | JSValue bubblesValue; |
63 | if (isNullOrUndefined) |
64 | bubblesValue = jsUndefined(); |
65 | else { |
66 | bubblesValue = object->get(&state, Identifier::fromString(&state, "bubbles" )); |
67 | RETURN_IF_EXCEPTION(throwScope, { }); |
68 | } |
69 | if (!bubblesValue.isUndefined()) { |
70 | result.bubbles = convert<IDLBoolean>(state, bubblesValue); |
71 | RETURN_IF_EXCEPTION(throwScope, { }); |
72 | } else |
73 | result.bubbles = false; |
74 | JSValue cancelableValue; |
75 | if (isNullOrUndefined) |
76 | cancelableValue = jsUndefined(); |
77 | else { |
78 | cancelableValue = object->get(&state, Identifier::fromString(&state, "cancelable" )); |
79 | RETURN_IF_EXCEPTION(throwScope, { }); |
80 | } |
81 | if (!cancelableValue.isUndefined()) { |
82 | result.cancelable = convert<IDLBoolean>(state, cancelableValue); |
83 | RETURN_IF_EXCEPTION(throwScope, { }); |
84 | } else |
85 | result.cancelable = false; |
86 | JSValue composedValue; |
87 | if (isNullOrUndefined) |
88 | composedValue = jsUndefined(); |
89 | else { |
90 | composedValue = object->get(&state, Identifier::fromString(&state, "composed" )); |
91 | RETURN_IF_EXCEPTION(throwScope, { }); |
92 | } |
93 | if (!composedValue.isUndefined()) { |
94 | result.composed = convert<IDLBoolean>(state, composedValue); |
95 | RETURN_IF_EXCEPTION(throwScope, { }); |
96 | } else |
97 | result.composed = false; |
98 | JSValue newVersionValue; |
99 | if (isNullOrUndefined) |
100 | newVersionValue = jsUndefined(); |
101 | else { |
102 | newVersionValue = object->get(&state, Identifier::fromString(&state, "newVersion" )); |
103 | RETURN_IF_EXCEPTION(throwScope, { }); |
104 | } |
105 | if (!newVersionValue.isUndefined()) { |
106 | result.newVersion = convert<IDLNullable<IDLUnsignedLongLong>>(state, newVersionValue); |
107 | RETURN_IF_EXCEPTION(throwScope, { }); |
108 | } else |
109 | result.newVersion = WTF::nullopt; |
110 | JSValue oldVersionValue; |
111 | if (isNullOrUndefined) |
112 | oldVersionValue = jsUndefined(); |
113 | else { |
114 | oldVersionValue = object->get(&state, Identifier::fromString(&state, "oldVersion" )); |
115 | RETURN_IF_EXCEPTION(throwScope, { }); |
116 | } |
117 | if (!oldVersionValue.isUndefined()) { |
118 | result.oldVersion = convert<IDLUnsignedLongLong>(state, oldVersionValue); |
119 | RETURN_IF_EXCEPTION(throwScope, { }); |
120 | } else |
121 | result.oldVersion = 0; |
122 | return result; |
123 | } |
124 | |
125 | // Attributes |
126 | |
127 | JSC::EncodedJSValue jsIDBVersionChangeEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
128 | bool setJSIDBVersionChangeEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
129 | JSC::EncodedJSValue jsIDBVersionChangeEventOldVersion(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
130 | JSC::EncodedJSValue jsIDBVersionChangeEventNewVersion(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
131 | |
132 | class JSIDBVersionChangeEventPrototype : public JSC::JSNonFinalObject { |
133 | public: |
134 | using Base = JSC::JSNonFinalObject; |
135 | static JSIDBVersionChangeEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
136 | { |
137 | JSIDBVersionChangeEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSIDBVersionChangeEventPrototype>(vm.heap)) JSIDBVersionChangeEventPrototype(vm, globalObject, structure); |
138 | ptr->finishCreation(vm); |
139 | return ptr; |
140 | } |
141 | |
142 | DECLARE_INFO; |
143 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
144 | { |
145 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
146 | } |
147 | |
148 | private: |
149 | JSIDBVersionChangeEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
150 | : JSC::JSNonFinalObject(vm, structure) |
151 | { |
152 | } |
153 | |
154 | void finishCreation(JSC::VM&); |
155 | }; |
156 | |
157 | using JSIDBVersionChangeEventConstructor = JSDOMConstructor<JSIDBVersionChangeEvent>; |
158 | |
159 | template<> EncodedJSValue JSC_HOST_CALL JSIDBVersionChangeEventConstructor::construct(ExecState* state) |
160 | { |
161 | VM& vm = state->vm(); |
162 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
163 | UNUSED_PARAM(throwScope); |
164 | auto* castedThis = jsCast<JSIDBVersionChangeEventConstructor*>(state->jsCallee()); |
165 | ASSERT(castedThis); |
166 | if (UNLIKELY(state->argumentCount() < 1)) |
167 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
168 | auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
169 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
170 | auto eventInitDict = convert<IDLDictionary<IDBVersionChangeEvent::Init>>(*state, state->argument(1)); |
171 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
172 | auto object = IDBVersionChangeEvent::create(WTFMove(type), WTFMove(eventInitDict)); |
173 | return JSValue::encode(toJSNewlyCreated<IDLInterface<IDBVersionChangeEvent>>(*state, *castedThis->globalObject(), WTFMove(object))); |
174 | } |
175 | |
176 | template<> JSValue JSIDBVersionChangeEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
177 | { |
178 | return JSEvent::getConstructor(vm, &globalObject); |
179 | } |
180 | |
181 | template<> void JSIDBVersionChangeEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
182 | { |
183 | putDirect(vm, vm.propertyNames->prototype, JSIDBVersionChangeEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
184 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("IDBVersionChangeEvent"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
185 | putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
186 | } |
187 | |
188 | template<> const ClassInfo JSIDBVersionChangeEventConstructor::s_info = { "IDBVersionChangeEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIDBVersionChangeEventConstructor) }; |
189 | |
190 | /* Hash table for prototype */ |
191 | |
192 | static const HashTableValue JSIDBVersionChangeEventPrototypeTableValues[] = |
193 | { |
194 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBVersionChangeEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSIDBVersionChangeEventConstructor) } }, |
195 | { "oldVersion" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBVersionChangeEventOldVersion), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
196 | { "newVersion" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIDBVersionChangeEventNewVersion), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
197 | }; |
198 | |
199 | const ClassInfo JSIDBVersionChangeEventPrototype::s_info = { "IDBVersionChangeEventPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIDBVersionChangeEventPrototype) }; |
200 | |
201 | void JSIDBVersionChangeEventPrototype::finishCreation(VM& vm) |
202 | { |
203 | Base::finishCreation(vm); |
204 | reifyStaticProperties(vm, JSIDBVersionChangeEvent::info(), JSIDBVersionChangeEventPrototypeTableValues, *this); |
205 | } |
206 | |
207 | const ClassInfo JSIDBVersionChangeEvent::s_info = { "IDBVersionChangeEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIDBVersionChangeEvent) }; |
208 | |
209 | JSIDBVersionChangeEvent::JSIDBVersionChangeEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<IDBVersionChangeEvent>&& impl) |
210 | : JSEvent(structure, globalObject, WTFMove(impl)) |
211 | { |
212 | } |
213 | |
214 | void JSIDBVersionChangeEvent::finishCreation(VM& vm) |
215 | { |
216 | Base::finishCreation(vm); |
217 | ASSERT(inherits(vm, info())); |
218 | |
219 | } |
220 | |
221 | JSObject* JSIDBVersionChangeEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
222 | { |
223 | return JSIDBVersionChangeEventPrototype::create(vm, &globalObject, JSIDBVersionChangeEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject))); |
224 | } |
225 | |
226 | JSObject* JSIDBVersionChangeEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
227 | { |
228 | return getDOMPrototype<JSIDBVersionChangeEvent>(vm, globalObject); |
229 | } |
230 | |
231 | JSValue JSIDBVersionChangeEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
232 | { |
233 | return getDOMConstructor<JSIDBVersionChangeEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
234 | } |
235 | |
236 | template<> inline JSIDBVersionChangeEvent* IDLAttribute<JSIDBVersionChangeEvent>::cast(ExecState& state, EncodedJSValue thisValue) |
237 | { |
238 | return jsDynamicCast<JSIDBVersionChangeEvent*>(state.vm(), JSValue::decode(thisValue)); |
239 | } |
240 | |
241 | EncodedJSValue jsIDBVersionChangeEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
242 | { |
243 | VM& vm = state->vm(); |
244 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
245 | auto* prototype = jsDynamicCast<JSIDBVersionChangeEventPrototype*>(vm, JSValue::decode(thisValue)); |
246 | if (UNLIKELY(!prototype)) |
247 | return throwVMTypeError(state, throwScope); |
248 | return JSValue::encode(JSIDBVersionChangeEvent::getConstructor(state->vm(), prototype->globalObject())); |
249 | } |
250 | |
251 | bool setJSIDBVersionChangeEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
252 | { |
253 | VM& vm = state->vm(); |
254 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
255 | auto* prototype = jsDynamicCast<JSIDBVersionChangeEventPrototype*>(vm, JSValue::decode(thisValue)); |
256 | if (UNLIKELY(!prototype)) { |
257 | throwVMTypeError(state, throwScope); |
258 | return false; |
259 | } |
260 | // Shadowing a built-in constructor |
261 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
262 | } |
263 | |
264 | static inline JSValue jsIDBVersionChangeEventOldVersionGetter(ExecState& state, JSIDBVersionChangeEvent& thisObject, ThrowScope& throwScope) |
265 | { |
266 | UNUSED_PARAM(throwScope); |
267 | UNUSED_PARAM(state); |
268 | auto& impl = thisObject.wrapped(); |
269 | JSValue result = toJS<IDLUnsignedLongLong>(state, throwScope, impl.oldVersion()); |
270 | return result; |
271 | } |
272 | |
273 | EncodedJSValue jsIDBVersionChangeEventOldVersion(ExecState* state, EncodedJSValue thisValue, PropertyName) |
274 | { |
275 | return IDLAttribute<JSIDBVersionChangeEvent>::get<jsIDBVersionChangeEventOldVersionGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "oldVersion" ); |
276 | } |
277 | |
278 | static inline JSValue jsIDBVersionChangeEventNewVersionGetter(ExecState& state, JSIDBVersionChangeEvent& thisObject, ThrowScope& throwScope) |
279 | { |
280 | UNUSED_PARAM(throwScope); |
281 | UNUSED_PARAM(state); |
282 | auto& impl = thisObject.wrapped(); |
283 | JSValue result = toJS<IDLNullable<IDLUnsignedLongLong>>(state, throwScope, impl.newVersion()); |
284 | return result; |
285 | } |
286 | |
287 | EncodedJSValue jsIDBVersionChangeEventNewVersion(ExecState* state, EncodedJSValue thisValue, PropertyName) |
288 | { |
289 | return IDLAttribute<JSIDBVersionChangeEvent>::get<jsIDBVersionChangeEventNewVersionGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "newVersion" ); |
290 | } |
291 | |
292 | void JSIDBVersionChangeEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
293 | { |
294 | auto* thisObject = jsCast<JSIDBVersionChangeEvent*>(cell); |
295 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
296 | if (thisObject->scriptExecutionContext()) |
297 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
298 | Base::heapSnapshot(cell, builder); |
299 | } |
300 | |
301 | #if ENABLE(BINDING_INTEGRITY) |
302 | #if PLATFORM(WIN) |
303 | #pragma warning(disable: 4483) |
304 | extern "C" { extern void (*const __identifier("??_7IDBVersionChangeEvent@WebCore@@6B@" )[])(); } |
305 | #else |
306 | extern "C" { extern void* _ZTVN7WebCore21IDBVersionChangeEventE[]; } |
307 | #endif |
308 | #endif |
309 | |
310 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<IDBVersionChangeEvent>&& impl) |
311 | { |
312 | |
313 | #if ENABLE(BINDING_INTEGRITY) |
314 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
315 | #if PLATFORM(WIN) |
316 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7IDBVersionChangeEvent@WebCore@@6B@" )); |
317 | #else |
318 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore21IDBVersionChangeEventE[2]); |
319 | #endif |
320 | |
321 | // If this fails IDBVersionChangeEvent does not have a vtable, so you need to add the |
322 | // ImplementationLacksVTable attribute to the interface definition |
323 | static_assert(std::is_polymorphic<IDBVersionChangeEvent>::value, "IDBVersionChangeEvent is not polymorphic" ); |
324 | |
325 | // If you hit this assertion you either have a use after free bug, or |
326 | // IDBVersionChangeEvent has subclasses. If IDBVersionChangeEvent has subclasses that get passed |
327 | // to toJS() we currently require IDBVersionChangeEvent you to opt out of binding hardening |
328 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
329 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
330 | #endif |
331 | return createWrapper<IDBVersionChangeEvent>(globalObject, WTFMove(impl)); |
332 | } |
333 | |
334 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, IDBVersionChangeEvent& impl) |
335 | { |
336 | return wrap(state, globalObject, impl); |
337 | } |
338 | |
339 | |
340 | } |
341 | |
342 | #endif // ENABLE(INDEXED_DATABASE) |
343 | |