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