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