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 "JSRTCRtpSynchronizationSource.h"
26
27#include "JSDOMConvertBoolean.h"
28#include "JSDOMConvertNumbers.h"
29#include "JSDOMGlobalObject.h"
30#include <JavaScriptCore/JSCInlines.h>
31#include <JavaScriptCore/ObjectConstructor.h>
32
33
34namespace WebCore {
35using namespace JSC;
36
37#if ENABLE(WEB_RTC)
38
39template<> RTCRtpSynchronizationSource convertDictionary<RTCRtpSynchronizationSource>(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 RTCRtpSynchronizationSource result;
50 JSValue audioLevelValue;
51 if (isNullOrUndefined)
52 audioLevelValue = jsUndefined();
53 else {
54 audioLevelValue = object->get(&state, Identifier::fromString(&state, "audioLevel"));
55 RETURN_IF_EXCEPTION(throwScope, { });
56 }
57 if (!audioLevelValue.isUndefined()) {
58 result.audioLevel = convert<IDLDouble>(state, audioLevelValue);
59 RETURN_IF_EXCEPTION(throwScope, { });
60 }
61 JSValue sourceValue;
62 if (isNullOrUndefined)
63 sourceValue = jsUndefined();
64 else {
65 sourceValue = object->get(&state, Identifier::fromString(&state, "source"));
66 RETURN_IF_EXCEPTION(throwScope, { });
67 }
68 if (!sourceValue.isUndefined()) {
69 result.source = convert<IDLUnsignedLong>(state, sourceValue);
70 RETURN_IF_EXCEPTION(throwScope, { });
71 } else {
72 throwRequiredMemberTypeError(state, throwScope, "source", "RTCRtpSynchronizationSource", "unsigned long");
73 return { };
74 }
75 JSValue timestampValue;
76 if (isNullOrUndefined)
77 timestampValue = jsUndefined();
78 else {
79 timestampValue = object->get(&state, Identifier::fromString(&state, "timestamp"));
80 RETURN_IF_EXCEPTION(throwScope, { });
81 }
82 if (!timestampValue.isUndefined()) {
83 result.timestamp = convert<IDLDouble>(state, timestampValue);
84 RETURN_IF_EXCEPTION(throwScope, { });
85 } else {
86 throwRequiredMemberTypeError(state, throwScope, "timestamp", "RTCRtpSynchronizationSource", "double");
87 return { };
88 }
89 JSValue voiceActivityFlagValue;
90 if (isNullOrUndefined)
91 voiceActivityFlagValue = jsUndefined();
92 else {
93 voiceActivityFlagValue = object->get(&state, Identifier::fromString(&state, "voiceActivityFlag"));
94 RETURN_IF_EXCEPTION(throwScope, { });
95 }
96 if (!voiceActivityFlagValue.isUndefined()) {
97 result.voiceActivityFlag = convert<IDLBoolean>(state, voiceActivityFlagValue);
98 RETURN_IF_EXCEPTION(throwScope, { });
99 }
100 return result;
101}
102
103JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const RTCRtpSynchronizationSource& dictionary)
104{
105 auto& vm = state.vm();
106
107 auto result = constructEmptyObject(&state, globalObject.objectPrototype());
108
109 if (!IDLDouble::isNullValue(dictionary.audioLevel)) {
110 auto audioLevelValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.audioLevel));
111 result->putDirect(vm, JSC::Identifier::fromString(&vm, "audioLevel"), audioLevelValue);
112 }
113 auto sourceValue = toJS<IDLUnsignedLong>(dictionary.source);
114 result->putDirect(vm, JSC::Identifier::fromString(&vm, "source"), sourceValue);
115 auto timestampValue = toJS<IDLDouble>(dictionary.timestamp);
116 result->putDirect(vm, JSC::Identifier::fromString(&vm, "timestamp"), timestampValue);
117 if (!IDLBoolean::isNullValue(dictionary.voiceActivityFlag)) {
118 auto voiceActivityFlagValue = toJS<IDLBoolean>(IDLBoolean::extractValueFromNullable(dictionary.voiceActivityFlag));
119 result->putDirect(vm, JSC::Identifier::fromString(&vm, "voiceActivityFlag"), voiceActivityFlagValue);
120 }
121 return result;
122}
123
124#endif
125
126} // namespace WebCore
127
128#endif // ENABLE(WEB_RTC)
129