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 "JSPaymentDetailsInit.h" |
26 | |
27 | #include "JSDOMConvertSequences.h" |
28 | #include "JSDOMConvertStrings.h" |
29 | #include "JSPaymentDetailsModifier.h" |
30 | #include "JSPaymentItem.h" |
31 | #include "JSPaymentShippingOption.h" |
32 | #include <JavaScriptCore/JSArray.h> |
33 | #include <JavaScriptCore/JSCInlines.h> |
34 | |
35 | |
36 | namespace WebCore { |
37 | using namespace JSC; |
38 | |
39 | #if ENABLE(PAYMENT_REQUEST) |
40 | |
41 | template<> PaymentDetailsInit convertDictionary<PaymentDetailsInit>(ExecState& state, JSValue value) |
42 | { |
43 | VM& vm = state.vm(); |
44 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
45 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
46 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
47 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
48 | throwTypeError(&state, throwScope); |
49 | return { }; |
50 | } |
51 | PaymentDetailsInit result; |
52 | JSValue displayItemsValue; |
53 | if (isNullOrUndefined) |
54 | displayItemsValue = jsUndefined(); |
55 | else { |
56 | displayItemsValue = object->get(&state, Identifier::fromString(&state, "displayItems" )); |
57 | RETURN_IF_EXCEPTION(throwScope, { }); |
58 | } |
59 | if (!displayItemsValue.isUndefined()) { |
60 | result.displayItems = convert<IDLSequence<IDLDictionary<PaymentItem>>>(state, displayItemsValue); |
61 | RETURN_IF_EXCEPTION(throwScope, { }); |
62 | } |
63 | JSValue modifiersValue; |
64 | if (isNullOrUndefined) |
65 | modifiersValue = jsUndefined(); |
66 | else { |
67 | modifiersValue = object->get(&state, Identifier::fromString(&state, "modifiers" )); |
68 | RETURN_IF_EXCEPTION(throwScope, { }); |
69 | } |
70 | if (!modifiersValue.isUndefined()) { |
71 | result.modifiers = convert<IDLSequence<IDLDictionary<PaymentDetailsModifier>>>(state, modifiersValue); |
72 | RETURN_IF_EXCEPTION(throwScope, { }); |
73 | } |
74 | JSValue shippingOptionsValue; |
75 | if (isNullOrUndefined) |
76 | shippingOptionsValue = jsUndefined(); |
77 | else { |
78 | shippingOptionsValue = object->get(&state, Identifier::fromString(&state, "shippingOptions" )); |
79 | RETURN_IF_EXCEPTION(throwScope, { }); |
80 | } |
81 | if (!shippingOptionsValue.isUndefined()) { |
82 | result.shippingOptions = convert<IDLSequence<IDLDictionary<PaymentShippingOption>>>(state, shippingOptionsValue); |
83 | RETURN_IF_EXCEPTION(throwScope, { }); |
84 | } |
85 | JSValue idValue; |
86 | if (isNullOrUndefined) |
87 | idValue = jsUndefined(); |
88 | else { |
89 | idValue = object->get(&state, Identifier::fromString(&state, "id" )); |
90 | RETURN_IF_EXCEPTION(throwScope, { }); |
91 | } |
92 | if (!idValue.isUndefined()) { |
93 | result.id = convert<IDLDOMString>(state, idValue); |
94 | RETURN_IF_EXCEPTION(throwScope, { }); |
95 | } |
96 | JSValue totalValue; |
97 | if (isNullOrUndefined) |
98 | totalValue = jsUndefined(); |
99 | else { |
100 | totalValue = object->get(&state, Identifier::fromString(&state, "total" )); |
101 | RETURN_IF_EXCEPTION(throwScope, { }); |
102 | } |
103 | if (!totalValue.isUndefined()) { |
104 | result.total = convert<IDLDictionary<PaymentItem>>(state, totalValue); |
105 | RETURN_IF_EXCEPTION(throwScope, { }); |
106 | } else { |
107 | throwRequiredMemberTypeError(state, throwScope, "total" , "PaymentDetailsInit" , "PaymentItem" ); |
108 | return { }; |
109 | } |
110 | return result; |
111 | } |
112 | |
113 | #endif |
114 | |
115 | } // namespace WebCore |
116 | |
117 | #endif // ENABLE(PAYMENT_REQUEST) |
118 | |