| 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(WEB_RTC) |
| 24 | |
| 25 | #include "JSRTCRtpContributingSource.h" |
| 26 | |
| 27 | #include "JSDOMConvertNumbers.h" |
| 28 | #include "JSDOMGlobalObject.h" |
| 29 | #include <JavaScriptCore/JSCInlines.h> |
| 30 | #include <JavaScriptCore/ObjectConstructor.h> |
| 31 | |
| 32 | |
| 33 | namespace WebCore { |
| 34 | using namespace JSC; |
| 35 | |
| 36 | #if ENABLE(WEB_RTC) |
| 37 | |
| 38 | template<> RTCRtpContributingSource convertDictionary<RTCRtpContributingSource>(ExecState& state, JSValue value) |
| 39 | { |
| 40 | VM& vm = state.vm(); |
| 41 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 42 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 43 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 44 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 45 | throwTypeError(&state, throwScope); |
| 46 | return { }; |
| 47 | } |
| 48 | RTCRtpContributingSource result; |
| 49 | JSValue audioLevelValue; |
| 50 | if (isNullOrUndefined) |
| 51 | audioLevelValue = jsUndefined(); |
| 52 | else { |
| 53 | audioLevelValue = object->get(&state, Identifier::fromString(&state, "audioLevel" )); |
| 54 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 55 | } |
| 56 | if (!audioLevelValue.isUndefined()) { |
| 57 | result.audioLevel = convert<IDLDouble>(state, audioLevelValue); |
| 58 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 59 | } |
| 60 | JSValue sourceValue; |
| 61 | if (isNullOrUndefined) |
| 62 | sourceValue = jsUndefined(); |
| 63 | else { |
| 64 | sourceValue = object->get(&state, Identifier::fromString(&state, "source" )); |
| 65 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 66 | } |
| 67 | if (!sourceValue.isUndefined()) { |
| 68 | result.source = convert<IDLUnsignedLong>(state, sourceValue); |
| 69 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 70 | } else { |
| 71 | throwRequiredMemberTypeError(state, throwScope, "source" , "RTCRtpContributingSource" , "unsigned long" ); |
| 72 | return { }; |
| 73 | } |
| 74 | JSValue timestampValue; |
| 75 | if (isNullOrUndefined) |
| 76 | timestampValue = jsUndefined(); |
| 77 | else { |
| 78 | timestampValue = object->get(&state, Identifier::fromString(&state, "timestamp" )); |
| 79 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 80 | } |
| 81 | if (!timestampValue.isUndefined()) { |
| 82 | result.timestamp = convert<IDLDouble>(state, timestampValue); |
| 83 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 84 | } else { |
| 85 | throwRequiredMemberTypeError(state, throwScope, "timestamp" , "RTCRtpContributingSource" , "double" ); |
| 86 | return { }; |
| 87 | } |
| 88 | return result; |
| 89 | } |
| 90 | |
| 91 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const RTCRtpContributingSource& dictionary) |
| 92 | { |
| 93 | auto& vm = state.vm(); |
| 94 | |
| 95 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 96 | |
| 97 | if (!IDLDouble::isNullValue(dictionary.audioLevel)) { |
| 98 | auto audioLevelValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.audioLevel)); |
| 99 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "audioLevel" ), audioLevelValue); |
| 100 | } |
| 101 | auto sourceValue = toJS<IDLUnsignedLong>(dictionary.source); |
| 102 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "source" ), sourceValue); |
| 103 | auto timestampValue = toJS<IDLDouble>(dictionary.timestamp); |
| 104 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "timestamp" ), timestampValue); |
| 105 | return result; |
| 106 | } |
| 107 | |
| 108 | #endif |
| 109 | |
| 110 | } // namespace WebCore |
| 111 | |
| 112 | #endif // ENABLE(WEB_RTC) |
| 113 | |