| 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 | #include "JSMediaCapabilitiesEncodingInfo.h" |
| 23 | |
| 24 | #include "Document.h" |
| 25 | #include "JSDOMConvertBoolean.h" |
| 26 | #include "JSDOMGlobalObject.h" |
| 27 | #include "JSMediaEncodingConfiguration.h" |
| 28 | #include "Settings.h" |
| 29 | #include <JavaScriptCore/JSCInlines.h> |
| 30 | #include <JavaScriptCore/ObjectConstructor.h> |
| 31 | |
| 32 | |
| 33 | namespace WebCore { |
| 34 | using namespace JSC; |
| 35 | |
| 36 | template<> MediaCapabilitiesEncodingInfo convertDictionary<MediaCapabilitiesEncodingInfo>(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 | MediaCapabilitiesEncodingInfo result; |
| 47 | JSValue powerEfficientValue; |
| 48 | if (isNullOrUndefined) |
| 49 | powerEfficientValue = jsUndefined(); |
| 50 | else { |
| 51 | powerEfficientValue = object->get(&state, Identifier::fromString(&state, "powerEfficient" )); |
| 52 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 53 | } |
| 54 | if (!powerEfficientValue.isUndefined()) { |
| 55 | result.powerEfficient = convert<IDLBoolean>(state, powerEfficientValue); |
| 56 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 57 | } else { |
| 58 | throwRequiredMemberTypeError(state, throwScope, "powerEfficient" , "MediaCapabilitiesEncodingInfo" , "boolean" ); |
| 59 | return { }; |
| 60 | } |
| 61 | JSValue smoothValue; |
| 62 | if (isNullOrUndefined) |
| 63 | smoothValue = jsUndefined(); |
| 64 | else { |
| 65 | smoothValue = object->get(&state, Identifier::fromString(&state, "smooth" )); |
| 66 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 67 | } |
| 68 | if (!smoothValue.isUndefined()) { |
| 69 | result.smooth = convert<IDLBoolean>(state, smoothValue); |
| 70 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 71 | } else { |
| 72 | throwRequiredMemberTypeError(state, throwScope, "smooth" , "MediaCapabilitiesEncodingInfo" , "boolean" ); |
| 73 | return { }; |
| 74 | } |
| 75 | JSValue supportedValue; |
| 76 | if (isNullOrUndefined) |
| 77 | supportedValue = jsUndefined(); |
| 78 | else { |
| 79 | supportedValue = object->get(&state, Identifier::fromString(&state, "supported" )); |
| 80 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 81 | } |
| 82 | if (!supportedValue.isUndefined()) { |
| 83 | result.supported = convert<IDLBoolean>(state, supportedValue); |
| 84 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 85 | } else { |
| 86 | throwRequiredMemberTypeError(state, throwScope, "supported" , "MediaCapabilitiesEncodingInfo" , "boolean" ); |
| 87 | return { }; |
| 88 | } |
| 89 | JSValue supportedConfigurationValue; |
| 90 | if (isNullOrUndefined) |
| 91 | supportedConfigurationValue = jsUndefined(); |
| 92 | else { |
| 93 | supportedConfigurationValue = object->get(&state, Identifier::fromString(&state, "supportedConfiguration" )); |
| 94 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 95 | } |
| 96 | if (!supportedConfigurationValue.isUndefined()) { |
| 97 | result.supportedConfiguration = convert<IDLDictionary<MediaEncodingConfiguration>>(state, supportedConfigurationValue); |
| 98 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 99 | } |
| 100 | return result; |
| 101 | } |
| 102 | |
| 103 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const MediaCapabilitiesEncodingInfo& dictionary) |
| 104 | { |
| 105 | auto& vm = state.vm(); |
| 106 | |
| 107 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 108 | |
| 109 | auto powerEfficientValue = toJS<IDLBoolean>(dictionary.powerEfficient); |
| 110 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "powerEfficient" ), powerEfficientValue); |
| 111 | auto smoothValue = toJS<IDLBoolean>(dictionary.smooth); |
| 112 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "smooth" ), smoothValue); |
| 113 | auto supportedValue = toJS<IDLBoolean>(dictionary.supported); |
| 114 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "supported" ), supportedValue); |
| 115 | if (downcast<Document>(jsCast<JSDOMGlobalObject*>(&globalObject)->scriptExecutionContext())->settings().mediaCapabilitiesExtensionsEnabled()) { |
| 116 | if (!IDLDictionary<MediaEncodingConfiguration>::isNullValue(dictionary.supportedConfiguration)) { |
| 117 | auto supportedConfigurationValue = toJS<IDLDictionary<MediaEncodingConfiguration>>(state, globalObject, IDLDictionary<MediaEncodingConfiguration>::extractValueFromNullable(dictionary.supportedConfiguration)); |
| 118 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "supportedConfiguration" ), supportedConfigurationValue); |
| 119 | } |
| 120 | } |
| 121 | return result; |
| 122 | } |
| 123 | |
| 124 | } // namespace WebCore |
| 125 | |