/* This file is part of the WebKit open source project. This file has been generated by generate-bindings.pl. DO NOT MODIFY! This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "config.h" #include "JSURLPatternInit.h" #include "JSDOMConvertStrings.h" #include "JSDOMGlobalObject.h" #include #include namespace WebCore { using namespace JSC; template<> URLPatternInit convertDictionary(JSGlobalObject& lexicalGlobalObject, JSValue value) { auto& vm = JSC::getVM(&lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); bool isNullOrUndefined = value.isUndefinedOrNull(); auto* object = isNullOrUndefined ? nullptr : value.getObject(); if (!isNullOrUndefined && !object) [[unlikely]] { throwTypeError(&lexicalGlobalObject, throwScope); return {}; } URLPatternInit result; JSValue baseURLValue; if (isNullOrUndefined) baseURLValue = jsUndefined(); else { baseURLValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "baseURL"_s)); RETURN_IF_EXCEPTION(throwScope, {}); } if (!baseURLValue.isUndefined()) { result.baseURL = convert(lexicalGlobalObject, baseURLValue); RETURN_IF_EXCEPTION(throwScope, {}); } JSValue hashValue; if (isNullOrUndefined) hashValue = jsUndefined(); else { hashValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "hash"_s)); RETURN_IF_EXCEPTION(throwScope, {}); } if (!hashValue.isUndefined()) { result.hash = convert(lexicalGlobalObject, hashValue); RETURN_IF_EXCEPTION(throwScope, {}); } JSValue hostnameValue; if (isNullOrUndefined) hostnameValue = jsUndefined(); else { hostnameValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "hostname"_s)); RETURN_IF_EXCEPTION(throwScope, {}); } if (!hostnameValue.isUndefined()) { result.hostname = convert(lexicalGlobalObject, hostnameValue); RETURN_IF_EXCEPTION(throwScope, {}); } JSValue passwordValue; if (isNullOrUndefined) passwordValue = jsUndefined(); else { passwordValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "password"_s)); RETURN_IF_EXCEPTION(throwScope, {}); } if (!passwordValue.isUndefined()) { result.password = convert(lexicalGlobalObject, passwordValue); RETURN_IF_EXCEPTION(throwScope, {}); } JSValue pathnameValue; if (isNullOrUndefined) pathnameValue = jsUndefined(); else { pathnameValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "pathname"_s)); RETURN_IF_EXCEPTION(throwScope, {}); } if (!pathnameValue.isUndefined()) { result.pathname = convert(lexicalGlobalObject, pathnameValue); RETURN_IF_EXCEPTION(throwScope, {}); } JSValue portValue; if (isNullOrUndefined) portValue = jsUndefined(); else { portValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "port"_s)); RETURN_IF_EXCEPTION(throwScope, {}); } if (!portValue.isUndefined()) { result.port = convert(lexicalGlobalObject, portValue); RETURN_IF_EXCEPTION(throwScope, {}); } JSValue protocolValue; if (isNullOrUndefined) protocolValue = jsUndefined(); else { protocolValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "protocol"_s)); RETURN_IF_EXCEPTION(throwScope, {}); } if (!protocolValue.isUndefined()) { result.protocol = convert(lexicalGlobalObject, protocolValue); RETURN_IF_EXCEPTION(throwScope, {}); } JSValue searchValue; if (isNullOrUndefined) searchValue = jsUndefined(); else { searchValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "search"_s)); RETURN_IF_EXCEPTION(throwScope, {}); } if (!searchValue.isUndefined()) { result.search = convert(lexicalGlobalObject, searchValue); RETURN_IF_EXCEPTION(throwScope, {}); } JSValue usernameValue; if (isNullOrUndefined) usernameValue = jsUndefined(); else { usernameValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "username"_s)); RETURN_IF_EXCEPTION(throwScope, {}); } if (!usernameValue.isUndefined()) { result.username = convert(lexicalGlobalObject, usernameValue); RETURN_IF_EXCEPTION(throwScope, {}); } return result; } JSC::JSObject* convertDictionaryToJS(JSC::JSGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& globalObject, const URLPatternInit& dictionary) { auto& vm = JSC::getVM(&lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); auto result = constructEmptyObject(&lexicalGlobalObject, globalObject.objectPrototype()); if (!IDLUSVString::isNullValue(dictionary.baseURL)) { auto baseURLValue = toJS(lexicalGlobalObject, throwScope, IDLUSVString::extractValueFromNullable(dictionary.baseURL)); RETURN_IF_EXCEPTION(throwScope, {}); result->putDirect(vm, JSC::Identifier::fromString(vm, "baseURL"_s), baseURLValue); } if (!IDLUSVString::isNullValue(dictionary.hash)) { auto hashValue = toJS(lexicalGlobalObject, throwScope, IDLUSVString::extractValueFromNullable(dictionary.hash)); RETURN_IF_EXCEPTION(throwScope, {}); result->putDirect(vm, JSC::Identifier::fromString(vm, "hash"_s), hashValue); } if (!IDLUSVString::isNullValue(dictionary.hostname)) { auto hostnameValue = toJS(lexicalGlobalObject, throwScope, IDLUSVString::extractValueFromNullable(dictionary.hostname)); RETURN_IF_EXCEPTION(throwScope, {}); result->putDirect(vm, JSC::Identifier::fromString(vm, "hostname"_s), hostnameValue); } if (!IDLUSVString::isNullValue(dictionary.password)) { auto passwordValue = toJS(lexicalGlobalObject, throwScope, IDLUSVString::extractValueFromNullable(dictionary.password)); RETURN_IF_EXCEPTION(throwScope, {}); result->putDirect(vm, JSC::Identifier::fromString(vm, "password"_s), passwordValue); } if (!IDLUSVString::isNullValue(dictionary.pathname)) { auto pathnameValue = toJS(lexicalGlobalObject, throwScope, IDLUSVString::extractValueFromNullable(dictionary.pathname)); RETURN_IF_EXCEPTION(throwScope, {}); result->putDirect(vm, JSC::Identifier::fromString(vm, "pathname"_s), pathnameValue); } if (!IDLUSVString::isNullValue(dictionary.port)) { auto portValue = toJS(lexicalGlobalObject, throwScope, IDLUSVString::extractValueFromNullable(dictionary.port)); RETURN_IF_EXCEPTION(throwScope, {}); result->putDirect(vm, JSC::Identifier::fromString(vm, "port"_s), portValue); } if (!IDLUSVString::isNullValue(dictionary.protocol)) { auto protocolValue = toJS(lexicalGlobalObject, throwScope, IDLUSVString::extractValueFromNullable(dictionary.protocol)); RETURN_IF_EXCEPTION(throwScope, {}); result->putDirect(vm, JSC::Identifier::fromString(vm, "protocol"_s), protocolValue); } if (!IDLUSVString::isNullValue(dictionary.search)) { auto searchValue = toJS(lexicalGlobalObject, throwScope, IDLUSVString::extractValueFromNullable(dictionary.search)); RETURN_IF_EXCEPTION(throwScope, {}); result->putDirect(vm, JSC::Identifier::fromString(vm, "search"_s), searchValue); } if (!IDLUSVString::isNullValue(dictionary.username)) { auto usernameValue = toJS(lexicalGlobalObject, throwScope, IDLUSVString::extractValueFromNullable(dictionary.username)); RETURN_IF_EXCEPTION(throwScope, {}); result->putDirect(vm, JSC::Identifier::fromString(vm, "username"_s), usernameValue); } return result; } } // namespace WebCore