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