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(PAYMENT_REQUEST) |
24 | |
25 | #include "JSPaymentMethodChangeEvent.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 "JSDOMConvertObject.h" |
34 | #include "JSDOMConvertStrings.h" |
35 | #include "JSDOMExceptionHandling.h" |
36 | #include "JSDOMWrapperCache.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 | #if ENABLE(PAYMENT_REQUEST) |
49 | |
50 | template<> PaymentMethodChangeEvent::Init convertDictionary<PaymentMethodChangeEvent::Init>(ExecState& state, JSValue value) |
51 | { |
52 | VM& vm = state.vm(); |
53 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
54 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
55 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
56 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
57 | throwTypeError(&state, throwScope); |
58 | return { }; |
59 | } |
60 | PaymentMethodChangeEvent::Init result; |
61 | JSValue bubblesValue; |
62 | if (isNullOrUndefined) |
63 | bubblesValue = jsUndefined(); |
64 | else { |
65 | bubblesValue = object->get(&state, Identifier::fromString(&state, "bubbles" )); |
66 | RETURN_IF_EXCEPTION(throwScope, { }); |
67 | } |
68 | if (!bubblesValue.isUndefined()) { |
69 | result.bubbles = convert<IDLBoolean>(state, bubblesValue); |
70 | RETURN_IF_EXCEPTION(throwScope, { }); |
71 | } else |
72 | result.bubbles = false; |
73 | JSValue cancelableValue; |
74 | if (isNullOrUndefined) |
75 | cancelableValue = jsUndefined(); |
76 | else { |
77 | cancelableValue = object->get(&state, Identifier::fromString(&state, "cancelable" )); |
78 | RETURN_IF_EXCEPTION(throwScope, { }); |
79 | } |
80 | if (!cancelableValue.isUndefined()) { |
81 | result.cancelable = convert<IDLBoolean>(state, cancelableValue); |
82 | RETURN_IF_EXCEPTION(throwScope, { }); |
83 | } else |
84 | result.cancelable = false; |
85 | JSValue composedValue; |
86 | if (isNullOrUndefined) |
87 | composedValue = jsUndefined(); |
88 | else { |
89 | composedValue = object->get(&state, Identifier::fromString(&state, "composed" )); |
90 | RETURN_IF_EXCEPTION(throwScope, { }); |
91 | } |
92 | if (!composedValue.isUndefined()) { |
93 | result.composed = convert<IDLBoolean>(state, composedValue); |
94 | RETURN_IF_EXCEPTION(throwScope, { }); |
95 | } else |
96 | result.composed = false; |
97 | JSValue methodDetailsValue; |
98 | if (isNullOrUndefined) |
99 | methodDetailsValue = jsUndefined(); |
100 | else { |
101 | methodDetailsValue = object->get(&state, Identifier::fromString(&state, "methodDetails" )); |
102 | RETURN_IF_EXCEPTION(throwScope, { }); |
103 | } |
104 | if (!methodDetailsValue.isUndefined()) { |
105 | result.methodDetails = convert<IDLNullable<IDLObject>>(state, methodDetailsValue); |
106 | RETURN_IF_EXCEPTION(throwScope, { }); |
107 | } |
108 | JSValue methodNameValue; |
109 | if (isNullOrUndefined) |
110 | methodNameValue = jsUndefined(); |
111 | else { |
112 | methodNameValue = object->get(&state, Identifier::fromString(&state, "methodName" )); |
113 | RETURN_IF_EXCEPTION(throwScope, { }); |
114 | } |
115 | if (!methodNameValue.isUndefined()) { |
116 | result.methodName = convert<IDLDOMString>(state, methodNameValue); |
117 | RETURN_IF_EXCEPTION(throwScope, { }); |
118 | } else |
119 | result.methodName = emptyString(); |
120 | return result; |
121 | } |
122 | |
123 | #endif |
124 | |
125 | // Attributes |
126 | |
127 | JSC::EncodedJSValue jsPaymentMethodChangeEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
128 | bool setJSPaymentMethodChangeEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
129 | JSC::EncodedJSValue jsPaymentMethodChangeEventMethodName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
130 | JSC::EncodedJSValue jsPaymentMethodChangeEventMethodDetails(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
131 | |
132 | class JSPaymentMethodChangeEventPrototype : public JSC::JSNonFinalObject { |
133 | public: |
134 | using Base = JSC::JSNonFinalObject; |
135 | static JSPaymentMethodChangeEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
136 | { |
137 | JSPaymentMethodChangeEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSPaymentMethodChangeEventPrototype>(vm.heap)) JSPaymentMethodChangeEventPrototype(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 | JSPaymentMethodChangeEventPrototype(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 JSPaymentMethodChangeEventConstructor = JSDOMConstructor<JSPaymentMethodChangeEvent>; |
158 | |
159 | template<> EncodedJSValue JSC_HOST_CALL JSPaymentMethodChangeEventConstructor::construct(ExecState* state) |
160 | { |
161 | VM& vm = state->vm(); |
162 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
163 | UNUSED_PARAM(throwScope); |
164 | auto* castedThis = jsCast<JSPaymentMethodChangeEventConstructor*>(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<PaymentMethodChangeEvent::Init>>(*state, state->argument(1)); |
171 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
172 | auto object = PaymentMethodChangeEvent::create(WTFMove(type), WTFMove(eventInitDict)); |
173 | return JSValue::encode(toJSNewlyCreated<IDLInterface<PaymentMethodChangeEvent>>(*state, *castedThis->globalObject(), WTFMove(object))); |
174 | } |
175 | |
176 | template<> JSValue JSPaymentMethodChangeEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
177 | { |
178 | return JSPaymentRequestUpdateEvent::getConstructor(vm, &globalObject); |
179 | } |
180 | |
181 | template<> void JSPaymentMethodChangeEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
182 | { |
183 | putDirect(vm, vm.propertyNames->prototype, JSPaymentMethodChangeEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
184 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("PaymentMethodChangeEvent"_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 JSPaymentMethodChangeEventConstructor::s_info = { "PaymentMethodChangeEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPaymentMethodChangeEventConstructor) }; |
189 | |
190 | /* Hash table for prototype */ |
191 | |
192 | static const HashTableValue JSPaymentMethodChangeEventPrototypeTableValues[] = |
193 | { |
194 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPaymentMethodChangeEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSPaymentMethodChangeEventConstructor) } }, |
195 | { "methodName" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPaymentMethodChangeEventMethodName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
196 | { "methodDetails" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsPaymentMethodChangeEventMethodDetails), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
197 | }; |
198 | |
199 | const ClassInfo JSPaymentMethodChangeEventPrototype::s_info = { "PaymentMethodChangeEventPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPaymentMethodChangeEventPrototype) }; |
200 | |
201 | void JSPaymentMethodChangeEventPrototype::finishCreation(VM& vm) |
202 | { |
203 | Base::finishCreation(vm); |
204 | reifyStaticProperties(vm, JSPaymentMethodChangeEvent::info(), JSPaymentMethodChangeEventPrototypeTableValues, *this); |
205 | } |
206 | |
207 | const ClassInfo JSPaymentMethodChangeEvent::s_info = { "PaymentMethodChangeEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPaymentMethodChangeEvent) }; |
208 | |
209 | JSPaymentMethodChangeEvent::JSPaymentMethodChangeEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<PaymentMethodChangeEvent>&& impl) |
210 | : JSPaymentRequestUpdateEvent(structure, globalObject, WTFMove(impl)) |
211 | { |
212 | } |
213 | |
214 | void JSPaymentMethodChangeEvent::finishCreation(VM& vm) |
215 | { |
216 | Base::finishCreation(vm); |
217 | ASSERT(inherits(vm, info())); |
218 | |
219 | } |
220 | |
221 | JSObject* JSPaymentMethodChangeEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
222 | { |
223 | return JSPaymentMethodChangeEventPrototype::create(vm, &globalObject, JSPaymentMethodChangeEventPrototype::createStructure(vm, &globalObject, JSPaymentRequestUpdateEvent::prototype(vm, globalObject))); |
224 | } |
225 | |
226 | JSObject* JSPaymentMethodChangeEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
227 | { |
228 | return getDOMPrototype<JSPaymentMethodChangeEvent>(vm, globalObject); |
229 | } |
230 | |
231 | JSValue JSPaymentMethodChangeEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
232 | { |
233 | return getDOMConstructor<JSPaymentMethodChangeEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
234 | } |
235 | |
236 | template<> inline JSPaymentMethodChangeEvent* IDLAttribute<JSPaymentMethodChangeEvent>::cast(ExecState& state, EncodedJSValue thisValue) |
237 | { |
238 | return jsDynamicCast<JSPaymentMethodChangeEvent*>(state.vm(), JSValue::decode(thisValue)); |
239 | } |
240 | |
241 | EncodedJSValue jsPaymentMethodChangeEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
242 | { |
243 | VM& vm = state->vm(); |
244 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
245 | auto* prototype = jsDynamicCast<JSPaymentMethodChangeEventPrototype*>(vm, JSValue::decode(thisValue)); |
246 | if (UNLIKELY(!prototype)) |
247 | return throwVMTypeError(state, throwScope); |
248 | return JSValue::encode(JSPaymentMethodChangeEvent::getConstructor(state->vm(), prototype->globalObject())); |
249 | } |
250 | |
251 | bool setJSPaymentMethodChangeEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
252 | { |
253 | VM& vm = state->vm(); |
254 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
255 | auto* prototype = jsDynamicCast<JSPaymentMethodChangeEventPrototype*>(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 jsPaymentMethodChangeEventMethodNameGetter(ExecState& state, JSPaymentMethodChangeEvent& thisObject, ThrowScope& throwScope) |
265 | { |
266 | UNUSED_PARAM(throwScope); |
267 | UNUSED_PARAM(state); |
268 | auto& impl = thisObject.wrapped(); |
269 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.methodName()); |
270 | return result; |
271 | } |
272 | |
273 | EncodedJSValue jsPaymentMethodChangeEventMethodName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
274 | { |
275 | return IDLAttribute<JSPaymentMethodChangeEvent>::get<jsPaymentMethodChangeEventMethodNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "methodName" ); |
276 | } |
277 | |
278 | static inline JSValue jsPaymentMethodChangeEventMethodDetailsGetter(ExecState& state, JSPaymentMethodChangeEvent& thisObject, ThrowScope& throwScope) |
279 | { |
280 | UNUSED_PARAM(throwScope); |
281 | UNUSED_PARAM(state); |
282 | return thisObject.methodDetails(state); |
283 | } |
284 | |
285 | EncodedJSValue jsPaymentMethodChangeEventMethodDetails(ExecState* state, EncodedJSValue thisValue, PropertyName) |
286 | { |
287 | return IDLAttribute<JSPaymentMethodChangeEvent>::get<jsPaymentMethodChangeEventMethodDetailsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "methodDetails" ); |
288 | } |
289 | |
290 | void JSPaymentMethodChangeEvent::visitChildren(JSCell* cell, SlotVisitor& visitor) |
291 | { |
292 | auto* thisObject = jsCast<JSPaymentMethodChangeEvent*>(cell); |
293 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
294 | Base::visitChildren(thisObject, visitor); |
295 | thisObject->visitAdditionalChildren(visitor); |
296 | } |
297 | |
298 | void JSPaymentMethodChangeEvent::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor) |
299 | { |
300 | auto* thisObject = jsCast<JSPaymentMethodChangeEvent*>(cell); |
301 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
302 | Base::visitOutputConstraints(thisObject, visitor); |
303 | thisObject->visitAdditionalChildren(visitor); |
304 | } |
305 | |
306 | void JSPaymentMethodChangeEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
307 | { |
308 | auto* thisObject = jsCast<JSPaymentMethodChangeEvent*>(cell); |
309 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
310 | if (thisObject->scriptExecutionContext()) |
311 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
312 | Base::heapSnapshot(cell, builder); |
313 | } |
314 | |
315 | #if ENABLE(BINDING_INTEGRITY) |
316 | #if PLATFORM(WIN) |
317 | #pragma warning(disable: 4483) |
318 | extern "C" { extern void (*const __identifier("??_7PaymentMethodChangeEvent@WebCore@@6B@" )[])(); } |
319 | #else |
320 | extern "C" { extern void* _ZTVN7WebCore24PaymentMethodChangeEventE[]; } |
321 | #endif |
322 | #endif |
323 | |
324 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<PaymentMethodChangeEvent>&& impl) |
325 | { |
326 | |
327 | #if ENABLE(BINDING_INTEGRITY) |
328 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
329 | #if PLATFORM(WIN) |
330 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7PaymentMethodChangeEvent@WebCore@@6B@" )); |
331 | #else |
332 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore24PaymentMethodChangeEventE[2]); |
333 | #endif |
334 | |
335 | // If this fails PaymentMethodChangeEvent does not have a vtable, so you need to add the |
336 | // ImplementationLacksVTable attribute to the interface definition |
337 | static_assert(std::is_polymorphic<PaymentMethodChangeEvent>::value, "PaymentMethodChangeEvent is not polymorphic" ); |
338 | |
339 | // If you hit this assertion you either have a use after free bug, or |
340 | // PaymentMethodChangeEvent has subclasses. If PaymentMethodChangeEvent has subclasses that get passed |
341 | // to toJS() we currently require PaymentMethodChangeEvent you to opt out of binding hardening |
342 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
343 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
344 | #endif |
345 | return createWrapper<PaymentMethodChangeEvent>(globalObject, WTFMove(impl)); |
346 | } |
347 | |
348 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, PaymentMethodChangeEvent& impl) |
349 | { |
350 | return wrap(state, globalObject, impl); |
351 | } |
352 | |
353 | |
354 | } |
355 | |
356 | #endif // ENABLE(PAYMENT_REQUEST) |
357 | |