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