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