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 "JSHashChangeEvent.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructor.h"
27#include "JSDOMConvertBoolean.h"
28#include "JSDOMConvertInterface.h"
29#include "JSDOMConvertStrings.h"
30#include "JSDOMExceptionHandling.h"
31#include "JSDOMOperation.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<> HashChangeEvent::Init convertDictionary<HashChangeEvent::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 HashChangeEvent::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 newURLValue;
92 if (isNullOrUndefined)
93 newURLValue = jsUndefined();
94 else {
95 newURLValue = object->get(&state, Identifier::fromString(&state, "newURL"));
96 RETURN_IF_EXCEPTION(throwScope, { });
97 }
98 if (!newURLValue.isUndefined()) {
99 result.newURL = convert<IDLUSVString>(state, newURLValue);
100 RETURN_IF_EXCEPTION(throwScope, { });
101 } else
102 result.newURL = emptyString();
103 JSValue oldURLValue;
104 if (isNullOrUndefined)
105 oldURLValue = jsUndefined();
106 else {
107 oldURLValue = object->get(&state, Identifier::fromString(&state, "oldURL"));
108 RETURN_IF_EXCEPTION(throwScope, { });
109 }
110 if (!oldURLValue.isUndefined()) {
111 result.oldURL = convert<IDLUSVString>(state, oldURLValue);
112 RETURN_IF_EXCEPTION(throwScope, { });
113 } else
114 result.oldURL = emptyString();
115 return result;
116}
117
118// Functions
119
120JSC::EncodedJSValue JSC_HOST_CALL jsHashChangeEventPrototypeFunctionInitHashChangeEvent(JSC::ExecState*);
121
122// Attributes
123
124JSC::EncodedJSValue jsHashChangeEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
125bool setJSHashChangeEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
126JSC::EncodedJSValue jsHashChangeEventOldURL(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
127JSC::EncodedJSValue jsHashChangeEventNewURL(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
128
129class JSHashChangeEventPrototype : public JSC::JSNonFinalObject {
130public:
131 using Base = JSC::JSNonFinalObject;
132 static JSHashChangeEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
133 {
134 JSHashChangeEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSHashChangeEventPrototype>(vm.heap)) JSHashChangeEventPrototype(vm, globalObject, structure);
135 ptr->finishCreation(vm);
136 return ptr;
137 }
138
139 DECLARE_INFO;
140 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
141 {
142 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
143 }
144
145private:
146 JSHashChangeEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
147 : JSC::JSNonFinalObject(vm, structure)
148 {
149 }
150
151 void finishCreation(JSC::VM&);
152};
153
154using JSHashChangeEventConstructor = JSDOMConstructor<JSHashChangeEvent>;
155
156template<> EncodedJSValue JSC_HOST_CALL JSHashChangeEventConstructor::construct(ExecState* state)
157{
158 VM& vm = state->vm();
159 auto throwScope = DECLARE_THROW_SCOPE(vm);
160 UNUSED_PARAM(throwScope);
161 auto* castedThis = jsCast<JSHashChangeEventConstructor*>(state->jsCallee());
162 ASSERT(castedThis);
163 if (UNLIKELY(state->argumentCount() < 1))
164 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
165 auto type = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
166 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
167 auto eventInitDict = convert<IDLDictionary<HashChangeEvent::Init>>(*state, state->argument(1));
168 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
169 auto object = HashChangeEvent::create(WTFMove(type), WTFMove(eventInitDict));
170 return JSValue::encode(toJSNewlyCreated<IDLInterface<HashChangeEvent>>(*state, *castedThis->globalObject(), WTFMove(object)));
171}
172
173template<> JSValue JSHashChangeEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
174{
175 return JSEvent::getConstructor(vm, &globalObject);
176}
177
178template<> void JSHashChangeEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
179{
180 putDirect(vm, vm.propertyNames->prototype, JSHashChangeEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
181 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("HashChangeEvent"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
182 putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
183}
184
185template<> const ClassInfo JSHashChangeEventConstructor::s_info = { "HashChangeEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHashChangeEventConstructor) };
186
187/* Hash table for prototype */
188
189static const HashTableValue JSHashChangeEventPrototypeTableValues[] =
190{
191 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHashChangeEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHashChangeEventConstructor) } },
192 { "oldURL", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHashChangeEventOldURL), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
193 { "newURL", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHashChangeEventNewURL), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
194 { "initHashChangeEvent", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsHashChangeEventPrototypeFunctionInitHashChangeEvent), (intptr_t) (0) } },
195};
196
197const ClassInfo JSHashChangeEventPrototype::s_info = { "HashChangeEventPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHashChangeEventPrototype) };
198
199void JSHashChangeEventPrototype::finishCreation(VM& vm)
200{
201 Base::finishCreation(vm);
202 reifyStaticProperties(vm, JSHashChangeEvent::info(), JSHashChangeEventPrototypeTableValues, *this);
203}
204
205const ClassInfo JSHashChangeEvent::s_info = { "HashChangeEvent", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHashChangeEvent) };
206
207JSHashChangeEvent::JSHashChangeEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<HashChangeEvent>&& impl)
208 : JSEvent(structure, globalObject, WTFMove(impl))
209{
210}
211
212void JSHashChangeEvent::finishCreation(VM& vm)
213{
214 Base::finishCreation(vm);
215 ASSERT(inherits(vm, info()));
216
217}
218
219JSObject* JSHashChangeEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
220{
221 return JSHashChangeEventPrototype::create(vm, &globalObject, JSHashChangeEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject)));
222}
223
224JSObject* JSHashChangeEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject)
225{
226 return getDOMPrototype<JSHashChangeEvent>(vm, globalObject);
227}
228
229JSValue JSHashChangeEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject)
230{
231 return getDOMConstructor<JSHashChangeEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
232}
233
234template<> inline JSHashChangeEvent* IDLAttribute<JSHashChangeEvent>::cast(ExecState& state, EncodedJSValue thisValue)
235{
236 return jsDynamicCast<JSHashChangeEvent*>(state.vm(), JSValue::decode(thisValue));
237}
238
239template<> inline JSHashChangeEvent* IDLOperation<JSHashChangeEvent>::cast(ExecState& state)
240{
241 return jsDynamicCast<JSHashChangeEvent*>(state.vm(), state.thisValue());
242}
243
244EncodedJSValue jsHashChangeEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
245{
246 VM& vm = state->vm();
247 auto throwScope = DECLARE_THROW_SCOPE(vm);
248 auto* prototype = jsDynamicCast<JSHashChangeEventPrototype*>(vm, JSValue::decode(thisValue));
249 if (UNLIKELY(!prototype))
250 return throwVMTypeError(state, throwScope);
251 return JSValue::encode(JSHashChangeEvent::getConstructor(state->vm(), prototype->globalObject()));
252}
253
254bool setJSHashChangeEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
255{
256 VM& vm = state->vm();
257 auto throwScope = DECLARE_THROW_SCOPE(vm);
258 auto* prototype = jsDynamicCast<JSHashChangeEventPrototype*>(vm, JSValue::decode(thisValue));
259 if (UNLIKELY(!prototype)) {
260 throwVMTypeError(state, throwScope);
261 return false;
262 }
263 // Shadowing a built-in constructor
264 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
265}
266
267static inline JSValue jsHashChangeEventOldURLGetter(ExecState& state, JSHashChangeEvent& thisObject, ThrowScope& throwScope)
268{
269 UNUSED_PARAM(throwScope);
270 UNUSED_PARAM(state);
271 auto& impl = thisObject.wrapped();
272 JSValue result = toJS<IDLUSVString>(state, throwScope, impl.oldURL());
273 return result;
274}
275
276EncodedJSValue jsHashChangeEventOldURL(ExecState* state, EncodedJSValue thisValue, PropertyName)
277{
278 return IDLAttribute<JSHashChangeEvent>::get<jsHashChangeEventOldURLGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "oldURL");
279}
280
281static inline JSValue jsHashChangeEventNewURLGetter(ExecState& state, JSHashChangeEvent& thisObject, ThrowScope& throwScope)
282{
283 UNUSED_PARAM(throwScope);
284 UNUSED_PARAM(state);
285 auto& impl = thisObject.wrapped();
286 JSValue result = toJS<IDLUSVString>(state, throwScope, impl.newURL());
287 return result;
288}
289
290EncodedJSValue jsHashChangeEventNewURL(ExecState* state, EncodedJSValue thisValue, PropertyName)
291{
292 return IDLAttribute<JSHashChangeEvent>::get<jsHashChangeEventNewURLGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "newURL");
293}
294
295static inline JSC::EncodedJSValue jsHashChangeEventPrototypeFunctionInitHashChangeEventBody(JSC::ExecState* state, typename IDLOperation<JSHashChangeEvent>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
296{
297 UNUSED_PARAM(state);
298 UNUSED_PARAM(throwScope);
299 auto& impl = castedThis->wrapped();
300 auto type = convert<IDLDOMString>(*state, state->argument(0));
301 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
302 auto canBubble = convert<IDLBoolean>(*state, state->argument(1));
303 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
304 auto cancelable = convert<IDLBoolean>(*state, state->argument(2));
305 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
306 auto oldURL = convert<IDLUSVString>(*state, state->argument(3));
307 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
308 auto newURL = convert<IDLUSVString>(*state, state->argument(4));
309 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
310 impl.initHashChangeEvent(WTFMove(type), WTFMove(canBubble), WTFMove(cancelable), WTFMove(oldURL), WTFMove(newURL));
311 return JSValue::encode(jsUndefined());
312}
313
314EncodedJSValue JSC_HOST_CALL jsHashChangeEventPrototypeFunctionInitHashChangeEvent(ExecState* state)
315{
316 return IDLOperation<JSHashChangeEvent>::call<jsHashChangeEventPrototypeFunctionInitHashChangeEventBody>(*state, "initHashChangeEvent");
317}
318
319void JSHashChangeEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
320{
321 auto* thisObject = jsCast<JSHashChangeEvent*>(cell);
322 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
323 if (thisObject->scriptExecutionContext())
324 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
325 Base::heapSnapshot(cell, builder);
326}
327
328#if ENABLE(BINDING_INTEGRITY)
329#if PLATFORM(WIN)
330#pragma warning(disable: 4483)
331extern "C" { extern void (*const __identifier("??_7HashChangeEvent@WebCore@@6B@")[])(); }
332#else
333extern "C" { extern void* _ZTVN7WebCore15HashChangeEventE[]; }
334#endif
335#endif
336
337JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<HashChangeEvent>&& impl)
338{
339
340#if ENABLE(BINDING_INTEGRITY)
341 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
342#if PLATFORM(WIN)
343 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7HashChangeEvent@WebCore@@6B@"));
344#else
345 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore15HashChangeEventE[2]);
346#endif
347
348 // If this fails HashChangeEvent does not have a vtable, so you need to add the
349 // ImplementationLacksVTable attribute to the interface definition
350 static_assert(std::is_polymorphic<HashChangeEvent>::value, "HashChangeEvent is not polymorphic");
351
352 // If you hit this assertion you either have a use after free bug, or
353 // HashChangeEvent has subclasses. If HashChangeEvent has subclasses that get passed
354 // to toJS() we currently require HashChangeEvent you to opt out of binding hardening
355 // by adding the SkipVTableValidation attribute to the interface IDL definition
356 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
357#endif
358 return createWrapper<HashChangeEvent>(globalObject, WTFMove(impl));
359}
360
361JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, HashChangeEvent& impl)
362{
363 return wrap(state, globalObject, impl);
364}
365
366
367}
368