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