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 "JSMediaDecodingConfiguration.h" |
23 | |
24 | #include "JSAudioConfiguration.h" |
25 | #include "JSDOMConvertEnumeration.h" |
26 | #include "JSDOMGlobalObject.h" |
27 | #include "JSMediaDecodingType.h" |
28 | #include "JSVideoConfiguration.h" |
29 | #include <JavaScriptCore/JSCInlines.h> |
30 | #include <JavaScriptCore/ObjectConstructor.h> |
31 | |
32 | |
33 | namespace WebCore { |
34 | using namespace JSC; |
35 | |
36 | template<> MediaDecodingConfiguration convertDictionary<MediaDecodingConfiguration>(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 | MediaDecodingConfiguration result; |
47 | JSValue audioValue; |
48 | if (isNullOrUndefined) |
49 | audioValue = jsUndefined(); |
50 | else { |
51 | audioValue = object->get(&state, Identifier::fromString(&state, "audio" )); |
52 | RETURN_IF_EXCEPTION(throwScope, { }); |
53 | } |
54 | if (!audioValue.isUndefined()) { |
55 | result.audio = convert<IDLDictionary<AudioConfiguration>>(state, audioValue); |
56 | RETURN_IF_EXCEPTION(throwScope, { }); |
57 | } |
58 | JSValue videoValue; |
59 | if (isNullOrUndefined) |
60 | videoValue = jsUndefined(); |
61 | else { |
62 | videoValue = object->get(&state, Identifier::fromString(&state, "video" )); |
63 | RETURN_IF_EXCEPTION(throwScope, { }); |
64 | } |
65 | if (!videoValue.isUndefined()) { |
66 | result.video = convert<IDLDictionary<VideoConfiguration>>(state, videoValue); |
67 | RETURN_IF_EXCEPTION(throwScope, { }); |
68 | } |
69 | JSValue typeValue; |
70 | if (isNullOrUndefined) |
71 | typeValue = jsUndefined(); |
72 | else { |
73 | typeValue = object->get(&state, Identifier::fromString(&state, "type" )); |
74 | RETURN_IF_EXCEPTION(throwScope, { }); |
75 | } |
76 | if (!typeValue.isUndefined()) { |
77 | result.type = convert<IDLEnumeration<MediaDecodingType>>(state, typeValue); |
78 | RETURN_IF_EXCEPTION(throwScope, { }); |
79 | } else { |
80 | throwRequiredMemberTypeError(state, throwScope, "type" , "MediaDecodingConfiguration" , "MediaDecodingType" ); |
81 | return { }; |
82 | } |
83 | return result; |
84 | } |
85 | |
86 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const MediaDecodingConfiguration& dictionary) |
87 | { |
88 | auto& vm = state.vm(); |
89 | |
90 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
91 | |
92 | if (!IDLDictionary<AudioConfiguration>::isNullValue(dictionary.audio)) { |
93 | auto audioValue = toJS<IDLDictionary<AudioConfiguration>>(state, globalObject, IDLDictionary<AudioConfiguration>::extractValueFromNullable(dictionary.audio)); |
94 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "audio" ), audioValue); |
95 | } |
96 | if (!IDLDictionary<VideoConfiguration>::isNullValue(dictionary.video)) { |
97 | auto videoValue = toJS<IDLDictionary<VideoConfiguration>>(state, globalObject, IDLDictionary<VideoConfiguration>::extractValueFromNullable(dictionary.video)); |
98 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "video" ), videoValue); |
99 | } |
100 | auto typeValue = toJS<IDLEnumeration<MediaDecodingType>>(state, dictionary.type); |
101 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "type" ), typeValue); |
102 | return result; |
103 | } |
104 | |
105 | } // namespace WebCore |
106 | |