| 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 "JSAddressErrors.h" |
| 26 | |
| 27 | #include "JSDOMConvertStrings.h" |
| 28 | #include <JavaScriptCore/JSCInlines.h> |
| 29 | |
| 30 | |
| 31 | namespace WebCore { |
| 32 | using namespace JSC; |
| 33 | |
| 34 | #if ENABLE(PAYMENT_REQUEST) |
| 35 | |
| 36 | template<> AddressErrors convertDictionary<AddressErrors>(ExecState& state, JSValue value) |
| 37 | { |
| 38 | VM& vm = state.vm(); |
| 39 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 40 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 41 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 42 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 43 | throwTypeError(&state, throwScope); |
| 44 | return { }; |
| 45 | } |
| 46 | AddressErrors result; |
| 47 | JSValue addressLineValue; |
| 48 | if (isNullOrUndefined) |
| 49 | addressLineValue = jsUndefined(); |
| 50 | else { |
| 51 | addressLineValue = object->get(&state, Identifier::fromString(&state, "addressLine" )); |
| 52 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 53 | } |
| 54 | if (!addressLineValue.isUndefined()) { |
| 55 | result.addressLine = convert<IDLDOMString>(state, addressLineValue); |
| 56 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 57 | } |
| 58 | JSValue cityValue; |
| 59 | if (isNullOrUndefined) |
| 60 | cityValue = jsUndefined(); |
| 61 | else { |
| 62 | cityValue = object->get(&state, Identifier::fromString(&state, "city" )); |
| 63 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 64 | } |
| 65 | if (!cityValue.isUndefined()) { |
| 66 | result.city = convert<IDLDOMString>(state, cityValue); |
| 67 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 68 | } |
| 69 | JSValue countryValue; |
| 70 | if (isNullOrUndefined) |
| 71 | countryValue = jsUndefined(); |
| 72 | else { |
| 73 | countryValue = object->get(&state, Identifier::fromString(&state, "country" )); |
| 74 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 75 | } |
| 76 | if (!countryValue.isUndefined()) { |
| 77 | result.country = convert<IDLDOMString>(state, countryValue); |
| 78 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 79 | } |
| 80 | JSValue dependentLocalityValue; |
| 81 | if (isNullOrUndefined) |
| 82 | dependentLocalityValue = jsUndefined(); |
| 83 | else { |
| 84 | dependentLocalityValue = object->get(&state, Identifier::fromString(&state, "dependentLocality" )); |
| 85 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 86 | } |
| 87 | if (!dependentLocalityValue.isUndefined()) { |
| 88 | result.dependentLocality = convert<IDLDOMString>(state, dependentLocalityValue); |
| 89 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 90 | } |
| 91 | JSValue languageCodeValue; |
| 92 | if (isNullOrUndefined) |
| 93 | languageCodeValue = jsUndefined(); |
| 94 | else { |
| 95 | languageCodeValue = object->get(&state, Identifier::fromString(&state, "languageCode" )); |
| 96 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 97 | } |
| 98 | if (!languageCodeValue.isUndefined()) { |
| 99 | result.languageCode = convert<IDLDOMString>(state, languageCodeValue); |
| 100 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 101 | } |
| 102 | JSValue organizationValue; |
| 103 | if (isNullOrUndefined) |
| 104 | organizationValue = jsUndefined(); |
| 105 | else { |
| 106 | organizationValue = object->get(&state, Identifier::fromString(&state, "organization" )); |
| 107 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 108 | } |
| 109 | if (!organizationValue.isUndefined()) { |
| 110 | result.organization = convert<IDLDOMString>(state, organizationValue); |
| 111 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 112 | } |
| 113 | JSValue phoneValue; |
| 114 | if (isNullOrUndefined) |
| 115 | phoneValue = jsUndefined(); |
| 116 | else { |
| 117 | phoneValue = object->get(&state, Identifier::fromString(&state, "phone" )); |
| 118 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 119 | } |
| 120 | if (!phoneValue.isUndefined()) { |
| 121 | result.phone = convert<IDLDOMString>(state, phoneValue); |
| 122 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 123 | } |
| 124 | JSValue postalCodeValue; |
| 125 | if (isNullOrUndefined) |
| 126 | postalCodeValue = jsUndefined(); |
| 127 | else { |
| 128 | postalCodeValue = object->get(&state, Identifier::fromString(&state, "postalCode" )); |
| 129 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 130 | } |
| 131 | if (!postalCodeValue.isUndefined()) { |
| 132 | result.postalCode = convert<IDLDOMString>(state, postalCodeValue); |
| 133 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 134 | } |
| 135 | JSValue recipientValue; |
| 136 | if (isNullOrUndefined) |
| 137 | recipientValue = jsUndefined(); |
| 138 | else { |
| 139 | recipientValue = object->get(&state, Identifier::fromString(&state, "recipient" )); |
| 140 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 141 | } |
| 142 | if (!recipientValue.isUndefined()) { |
| 143 | result.recipient = convert<IDLDOMString>(state, recipientValue); |
| 144 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 145 | } |
| 146 | JSValue regionValue; |
| 147 | if (isNullOrUndefined) |
| 148 | regionValue = jsUndefined(); |
| 149 | else { |
| 150 | regionValue = object->get(&state, Identifier::fromString(&state, "region" )); |
| 151 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 152 | } |
| 153 | if (!regionValue.isUndefined()) { |
| 154 | result.region = convert<IDLDOMString>(state, regionValue); |
| 155 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 156 | } |
| 157 | JSValue regionCodeValue; |
| 158 | if (isNullOrUndefined) |
| 159 | regionCodeValue = jsUndefined(); |
| 160 | else { |
| 161 | regionCodeValue = object->get(&state, Identifier::fromString(&state, "regionCode" )); |
| 162 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 163 | } |
| 164 | if (!regionCodeValue.isUndefined()) { |
| 165 | result.regionCode = convert<IDLDOMString>(state, regionCodeValue); |
| 166 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 167 | } |
| 168 | JSValue sortingCodeValue; |
| 169 | if (isNullOrUndefined) |
| 170 | sortingCodeValue = jsUndefined(); |
| 171 | else { |
| 172 | sortingCodeValue = object->get(&state, Identifier::fromString(&state, "sortingCode" )); |
| 173 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 174 | } |
| 175 | if (!sortingCodeValue.isUndefined()) { |
| 176 | result.sortingCode = convert<IDLDOMString>(state, sortingCodeValue); |
| 177 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 178 | } |
| 179 | return result; |
| 180 | } |
| 181 | |
| 182 | #endif |
| 183 | |
| 184 | } // namespace WebCore |
| 185 | |
| 186 | #endif // ENABLE(PAYMENT_REQUEST) |
| 187 | |