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