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 "JSPaymentDetailsUpdate.h"
26
27#include "JSAddressErrors.h"
28#include "JSDOMConvertObject.h"
29#include "JSDOMConvertSequences.h"
30#include "JSDOMConvertStrings.h"
31#include "JSPayerErrorFields.h"
32#include "JSPaymentDetailsModifier.h"
33#include "JSPaymentItem.h"
34#include "JSPaymentShippingOption.h"
35#include <JavaScriptCore/JSArray.h>
36#include <JavaScriptCore/JSCInlines.h>
37
38
39namespace WebCore {
40using namespace JSC;
41
42#if ENABLE(PAYMENT_REQUEST)
43
44template<> PaymentDetailsUpdate convertDictionary<PaymentDetailsUpdate>(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 PaymentDetailsUpdate result;
55 JSValue displayItemsValue;
56 if (isNullOrUndefined)
57 displayItemsValue = jsUndefined();
58 else {
59 displayItemsValue = object->get(&state, Identifier::fromString(&state, "displayItems"));
60 RETURN_IF_EXCEPTION(throwScope, { });
61 }
62 if (!displayItemsValue.isUndefined()) {
63 result.displayItems = convert<IDLSequence<IDLDictionary<PaymentItem>>>(state, displayItemsValue);
64 RETURN_IF_EXCEPTION(throwScope, { });
65 }
66 JSValue modifiersValue;
67 if (isNullOrUndefined)
68 modifiersValue = jsUndefined();
69 else {
70 modifiersValue = object->get(&state, Identifier::fromString(&state, "modifiers"));
71 RETURN_IF_EXCEPTION(throwScope, { });
72 }
73 if (!modifiersValue.isUndefined()) {
74 result.modifiers = convert<IDLSequence<IDLDictionary<PaymentDetailsModifier>>>(state, modifiersValue);
75 RETURN_IF_EXCEPTION(throwScope, { });
76 }
77 JSValue shippingOptionsValue;
78 if (isNullOrUndefined)
79 shippingOptionsValue = jsUndefined();
80 else {
81 shippingOptionsValue = object->get(&state, Identifier::fromString(&state, "shippingOptions"));
82 RETURN_IF_EXCEPTION(throwScope, { });
83 }
84 if (!shippingOptionsValue.isUndefined()) {
85 result.shippingOptions = convert<IDLSequence<IDLDictionary<PaymentShippingOption>>>(state, shippingOptionsValue);
86 RETURN_IF_EXCEPTION(throwScope, { });
87 }
88 JSValue errorValue;
89 if (isNullOrUndefined)
90 errorValue = jsUndefined();
91 else {
92 errorValue = object->get(&state, Identifier::fromString(&state, "error"));
93 RETURN_IF_EXCEPTION(throwScope, { });
94 }
95 if (!errorValue.isUndefined()) {
96 result.error = convert<IDLDOMString>(state, errorValue);
97 RETURN_IF_EXCEPTION(throwScope, { });
98 }
99 JSValue payerErrorsValue;
100 if (isNullOrUndefined)
101 payerErrorsValue = jsUndefined();
102 else {
103 payerErrorsValue = object->get(&state, Identifier::fromString(&state, "payerErrors"));
104 RETURN_IF_EXCEPTION(throwScope, { });
105 }
106 if (!payerErrorsValue.isUndefined()) {
107 result.payerErrors = convert<IDLDictionary<PayerErrorFields>>(state, payerErrorsValue);
108 RETURN_IF_EXCEPTION(throwScope, { });
109 }
110 JSValue paymentMethodErrorsValue;
111 if (isNullOrUndefined)
112 paymentMethodErrorsValue = jsUndefined();
113 else {
114 paymentMethodErrorsValue = object->get(&state, Identifier::fromString(&state, "paymentMethodErrors"));
115 RETURN_IF_EXCEPTION(throwScope, { });
116 }
117 if (!paymentMethodErrorsValue.isUndefined()) {
118 result.paymentMethodErrors = convert<IDLObject>(state, paymentMethodErrorsValue);
119 RETURN_IF_EXCEPTION(throwScope, { });
120 }
121 JSValue shippingAddressErrorsValue;
122 if (isNullOrUndefined)
123 shippingAddressErrorsValue = jsUndefined();
124 else {
125 shippingAddressErrorsValue = object->get(&state, Identifier::fromString(&state, "shippingAddressErrors"));
126 RETURN_IF_EXCEPTION(throwScope, { });
127 }
128 if (!shippingAddressErrorsValue.isUndefined()) {
129 result.shippingAddressErrors = convert<IDLDictionary<AddressErrors>>(state, shippingAddressErrorsValue);
130 RETURN_IF_EXCEPTION(throwScope, { });
131 }
132 JSValue totalValue;
133 if (isNullOrUndefined)
134 totalValue = jsUndefined();
135 else {
136 totalValue = object->get(&state, Identifier::fromString(&state, "total"));
137 RETURN_IF_EXCEPTION(throwScope, { });
138 }
139 if (!totalValue.isUndefined()) {
140 result.total = convert<IDLDictionary<PaymentItem>>(state, totalValue);
141 RETURN_IF_EXCEPTION(throwScope, { });
142 }
143 return result;
144}
145
146#endif
147
148} // namespace WebCore
149
150#endif // ENABLE(PAYMENT_REQUEST)
151