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 "JSVideoConfiguration.h"
23
24#include "Document.h"
25#include "JSDOMConvertBoolean.h"
26#include "JSDOMConvertNumbers.h"
27#include "JSDOMConvertStrings.h"
28#include "JSDOMGlobalObject.h"
29#include "Settings.h"
30#include <JavaScriptCore/JSCInlines.h>
31#include <JavaScriptCore/ObjectConstructor.h>
32
33
34namespace WebCore {
35using namespace JSC;
36
37template<> VideoConfiguration convertDictionary<VideoConfiguration>(ExecState& state, JSValue value)
38{
39 VM& vm = state.vm();
40 auto throwScope = DECLARE_THROW_SCOPE(vm);
41 bool isNullOrUndefined = value.isUndefinedOrNull();
42 auto* object = isNullOrUndefined ? nullptr : value.getObject();
43 if (UNLIKELY(!isNullOrUndefined && !object)) {
44 throwTypeError(&state, throwScope);
45 return { };
46 }
47 VideoConfiguration result;
48 JSValue alphaChannelValue;
49 if (isNullOrUndefined)
50 alphaChannelValue = jsUndefined();
51 else {
52 alphaChannelValue = object->get(&state, Identifier::fromString(&state, "alphaChannel"));
53 RETURN_IF_EXCEPTION(throwScope, { });
54 }
55 if (!alphaChannelValue.isUndefined()) {
56 result.alphaChannel = convert<IDLBoolean>(state, alphaChannelValue);
57 RETURN_IF_EXCEPTION(throwScope, { });
58 }
59 JSValue bitrateValue;
60 if (isNullOrUndefined)
61 bitrateValue = jsUndefined();
62 else {
63 bitrateValue = object->get(&state, Identifier::fromString(&state, "bitrate"));
64 RETURN_IF_EXCEPTION(throwScope, { });
65 }
66 if (!bitrateValue.isUndefined()) {
67 result.bitrate = convert<IDLUnsignedLongLong>(state, bitrateValue);
68 RETURN_IF_EXCEPTION(throwScope, { });
69 } else {
70 throwRequiredMemberTypeError(state, throwScope, "bitrate", "VideoConfiguration", "unsigned long long");
71 return { };
72 }
73 JSValue contentTypeValue;
74 if (isNullOrUndefined)
75 contentTypeValue = jsUndefined();
76 else {
77 contentTypeValue = object->get(&state, Identifier::fromString(&state, "contentType"));
78 RETURN_IF_EXCEPTION(throwScope, { });
79 }
80 if (!contentTypeValue.isUndefined()) {
81 result.contentType = convert<IDLDOMString>(state, contentTypeValue);
82 RETURN_IF_EXCEPTION(throwScope, { });
83 } else {
84 throwRequiredMemberTypeError(state, throwScope, "contentType", "VideoConfiguration", "DOMString");
85 return { };
86 }
87 JSValue framerateValue;
88 if (isNullOrUndefined)
89 framerateValue = jsUndefined();
90 else {
91 framerateValue = object->get(&state, Identifier::fromString(&state, "framerate"));
92 RETURN_IF_EXCEPTION(throwScope, { });
93 }
94 if (!framerateValue.isUndefined()) {
95 result.framerate = convert<IDLDouble>(state, framerateValue);
96 RETURN_IF_EXCEPTION(throwScope, { });
97 } else {
98 throwRequiredMemberTypeError(state, throwScope, "framerate", "VideoConfiguration", "double");
99 return { };
100 }
101 JSValue heightValue;
102 if (isNullOrUndefined)
103 heightValue = jsUndefined();
104 else {
105 heightValue = object->get(&state, Identifier::fromString(&state, "height"));
106 RETURN_IF_EXCEPTION(throwScope, { });
107 }
108 if (!heightValue.isUndefined()) {
109 result.height = convert<IDLUnsignedLong>(state, heightValue);
110 RETURN_IF_EXCEPTION(throwScope, { });
111 } else {
112 throwRequiredMemberTypeError(state, throwScope, "height", "VideoConfiguration", "unsigned long");
113 return { };
114 }
115 JSValue widthValue;
116 if (isNullOrUndefined)
117 widthValue = jsUndefined();
118 else {
119 widthValue = object->get(&state, Identifier::fromString(&state, "width"));
120 RETURN_IF_EXCEPTION(throwScope, { });
121 }
122 if (!widthValue.isUndefined()) {
123 result.width = convert<IDLUnsignedLong>(state, widthValue);
124 RETURN_IF_EXCEPTION(throwScope, { });
125 } else {
126 throwRequiredMemberTypeError(state, throwScope, "width", "VideoConfiguration", "unsigned long");
127 return { };
128 }
129 return result;
130}
131
132JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const VideoConfiguration& dictionary)
133{
134 auto& vm = state.vm();
135
136 auto result = constructEmptyObject(&state, globalObject.objectPrototype());
137
138 if (downcast<Document>(jsCast<JSDOMGlobalObject*>(&globalObject)->scriptExecutionContext())->settings().mediaCapabilitiesExtensionsEnabled()) {
139 if (!IDLBoolean::isNullValue(dictionary.alphaChannel)) {
140 auto alphaChannelValue = toJS<IDLBoolean>(IDLBoolean::extractValueFromNullable(dictionary.alphaChannel));
141 result->putDirect(vm, JSC::Identifier::fromString(&vm, "alphaChannel"), alphaChannelValue);
142 }
143 }
144 auto bitrateValue = toJS<IDLUnsignedLongLong>(dictionary.bitrate);
145 result->putDirect(vm, JSC::Identifier::fromString(&vm, "bitrate"), bitrateValue);
146 auto contentTypeValue = toJS<IDLDOMString>(state, dictionary.contentType);
147 result->putDirect(vm, JSC::Identifier::fromString(&vm, "contentType"), contentTypeValue);
148 auto framerateValue = toJS<IDLDouble>(dictionary.framerate);
149 result->putDirect(vm, JSC::Identifier::fromString(&vm, "framerate"), framerateValue);
150 auto heightValue = toJS<IDLUnsignedLong>(dictionary.height);
151 result->putDirect(vm, JSC::Identifier::fromString(&vm, "height"), heightValue);
152 auto widthValue = toJS<IDLUnsignedLong>(dictionary.width);
153 result->putDirect(vm, JSC::Identifier::fromString(&vm, "width"), widthValue);
154 return result;
155}
156
157} // namespace WebCore
158