| 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 "JSPaymentValidationErrors.h" |
| 26 | |
| 27 | #include "JSAddressErrors.h" |
| 28 | #include "JSDOMConvertObject.h" |
| 29 | #include "JSDOMConvertStrings.h" |
| 30 | #include "JSPayerErrorFields.h" |
| 31 | #include <JavaScriptCore/JSCInlines.h> |
| 32 | |
| 33 | |
| 34 | namespace WebCore { |
| 35 | using namespace JSC; |
| 36 | |
| 37 | #if ENABLE(PAYMENT_REQUEST) |
| 38 | |
| 39 | template<> PaymentValidationErrors convertDictionary<PaymentValidationErrors>(ExecState& state, JSValue value) |
| 40 | { |
| 41 | VM& vm = state.vm(); |
| 42 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 43 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 44 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 45 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 46 | throwTypeError(&state, throwScope); |
| 47 | return { }; |
| 48 | } |
| 49 | PaymentValidationErrors result; |
| 50 | JSValue errorValue; |
| 51 | if (isNullOrUndefined) |
| 52 | errorValue = jsUndefined(); |
| 53 | else { |
| 54 | errorValue = object->get(&state, Identifier::fromString(&state, "error" )); |
| 55 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 56 | } |
| 57 | if (!errorValue.isUndefined()) { |
| 58 | result.error = convert<IDLDOMString>(state, errorValue); |
| 59 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 60 | } |
| 61 | JSValue payerValue; |
| 62 | if (isNullOrUndefined) |
| 63 | payerValue = jsUndefined(); |
| 64 | else { |
| 65 | payerValue = object->get(&state, Identifier::fromString(&state, "payer" )); |
| 66 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 67 | } |
| 68 | if (!payerValue.isUndefined()) { |
| 69 | result.payer = convert<IDLDictionary<PayerErrorFields>>(state, payerValue); |
| 70 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 71 | } |
| 72 | JSValue paymentMethodValue; |
| 73 | if (isNullOrUndefined) |
| 74 | paymentMethodValue = jsUndefined(); |
| 75 | else { |
| 76 | paymentMethodValue = object->get(&state, Identifier::fromString(&state, "paymentMethod" )); |
| 77 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 78 | } |
| 79 | if (!paymentMethodValue.isUndefined()) { |
| 80 | result.paymentMethod = convert<IDLObject>(state, paymentMethodValue); |
| 81 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 82 | } |
| 83 | JSValue shippingAddressValue; |
| 84 | if (isNullOrUndefined) |
| 85 | shippingAddressValue = jsUndefined(); |
| 86 | else { |
| 87 | shippingAddressValue = object->get(&state, Identifier::fromString(&state, "shippingAddress" )); |
| 88 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 89 | } |
| 90 | if (!shippingAddressValue.isUndefined()) { |
| 91 | result.shippingAddress = convert<IDLDictionary<AddressErrors>>(state, shippingAddressValue); |
| 92 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 93 | } |
| 94 | return result; |
| 95 | } |
| 96 | |
| 97 | #endif |
| 98 | |
| 99 | } // namespace WebCore |
| 100 | |
| 101 | #endif // ENABLE(PAYMENT_REQUEST) |
| 102 | |