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(ENCRYPTED_MEDIA) |
24 | |
25 | #include "JSMediaKeySystemMediaCapability.h" |
26 | |
27 | #include "JSDOMConvertEnumeration.h" |
28 | #include "JSDOMConvertNullable.h" |
29 | #include "JSDOMConvertStrings.h" |
30 | #include "JSDOMGlobalObject.h" |
31 | #include "JSMediaKeyEncryptionScheme.h" |
32 | #include <JavaScriptCore/JSCInlines.h> |
33 | #include <JavaScriptCore/ObjectConstructor.h> |
34 | |
35 | |
36 | namespace WebCore { |
37 | using namespace JSC; |
38 | |
39 | #if ENABLE(ENCRYPTED_MEDIA) |
40 | |
41 | template<> MediaKeySystemMediaCapability convertDictionary<MediaKeySystemMediaCapability>(ExecState& state, JSValue value) |
42 | { |
43 | VM& vm = state.vm(); |
44 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
45 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
46 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
47 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
48 | throwTypeError(&state, throwScope); |
49 | return { }; |
50 | } |
51 | MediaKeySystemMediaCapability result; |
52 | JSValue contentTypeValue; |
53 | if (isNullOrUndefined) |
54 | contentTypeValue = jsUndefined(); |
55 | else { |
56 | contentTypeValue = object->get(&state, Identifier::fromString(&state, "contentType" )); |
57 | RETURN_IF_EXCEPTION(throwScope, { }); |
58 | } |
59 | if (!contentTypeValue.isUndefined()) { |
60 | result.contentType = convert<IDLDOMString>(state, contentTypeValue); |
61 | RETURN_IF_EXCEPTION(throwScope, { }); |
62 | } else |
63 | result.contentType = emptyString(); |
64 | JSValue encryptionSchemeValue; |
65 | if (isNullOrUndefined) |
66 | encryptionSchemeValue = jsUndefined(); |
67 | else { |
68 | encryptionSchemeValue = object->get(&state, Identifier::fromString(&state, "encryptionScheme" )); |
69 | RETURN_IF_EXCEPTION(throwScope, { }); |
70 | } |
71 | if (!encryptionSchemeValue.isUndefined()) { |
72 | result.encryptionScheme = convert<IDLNullable<IDLEnumeration<MediaKeyEncryptionScheme>>>(state, encryptionSchemeValue); |
73 | RETURN_IF_EXCEPTION(throwScope, { }); |
74 | } else |
75 | result.encryptionScheme = WTF::nullopt; |
76 | JSValue robustnessValue; |
77 | if (isNullOrUndefined) |
78 | robustnessValue = jsUndefined(); |
79 | else { |
80 | robustnessValue = object->get(&state, Identifier::fromString(&state, "robustness" )); |
81 | RETURN_IF_EXCEPTION(throwScope, { }); |
82 | } |
83 | if (!robustnessValue.isUndefined()) { |
84 | result.robustness = convert<IDLDOMString>(state, robustnessValue); |
85 | RETURN_IF_EXCEPTION(throwScope, { }); |
86 | } else |
87 | result.robustness = emptyString(); |
88 | return result; |
89 | } |
90 | |
91 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const MediaKeySystemMediaCapability& dictionary) |
92 | { |
93 | auto& vm = state.vm(); |
94 | |
95 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
96 | |
97 | auto contentTypeValue = toJS<IDLDOMString>(state, dictionary.contentType); |
98 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "contentType" ), contentTypeValue); |
99 | auto encryptionSchemeValue = toJS<IDLNullable<IDLEnumeration<MediaKeyEncryptionScheme>>>(state, dictionary.encryptionScheme); |
100 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "encryptionScheme" ), encryptionSchemeValue); |
101 | auto robustnessValue = toJS<IDLDOMString>(state, dictionary.robustness); |
102 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "robustness" ), robustnessValue); |
103 | return result; |
104 | } |
105 | |
106 | #endif |
107 | |
108 | } // namespace WebCore |
109 | |
110 | #endif // ENABLE(ENCRYPTED_MEDIA) |
111 | |