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(WEB_CRYPTO)
24
25#include "JSCryptoRsaHashedKeyAlgorithm.h"
26
27#include "JSCryptoKeyAlgorithm.h"
28#include "JSDOMConvertBufferSource.h"
29#include "JSDOMConvertNumbers.h"
30#include "JSDOMConvertStrings.h"
31#include "JSDOMGlobalObject.h"
32#include <JavaScriptCore/JSCInlines.h>
33#include <JavaScriptCore/ObjectConstructor.h>
34
35
36namespace WebCore {
37using namespace JSC;
38
39#if ENABLE(WEB_CRYPTO)
40
41template<> CryptoRsaHashedKeyAlgorithm convertDictionary<CryptoRsaHashedKeyAlgorithm>(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 CryptoRsaHashedKeyAlgorithm result;
52 JSValue nameValue;
53 if (isNullOrUndefined)
54 nameValue = jsUndefined();
55 else {
56 nameValue = object->get(&state, Identifier::fromString(&state, "name"));
57 RETURN_IF_EXCEPTION(throwScope, { });
58 }
59 if (!nameValue.isUndefined()) {
60 result.name = convert<IDLDOMString>(state, nameValue);
61 RETURN_IF_EXCEPTION(throwScope, { });
62 } else {
63 throwRequiredMemberTypeError(state, throwScope, "name", "CryptoRsaHashedKeyAlgorithm", "DOMString");
64 return { };
65 }
66 JSValue modulusLengthValue;
67 if (isNullOrUndefined)
68 modulusLengthValue = jsUndefined();
69 else {
70 modulusLengthValue = object->get(&state, Identifier::fromString(&state, "modulusLength"));
71 RETURN_IF_EXCEPTION(throwScope, { });
72 }
73 if (!modulusLengthValue.isUndefined()) {
74 result.modulusLength = convert<IDLUnsignedLong>(state, modulusLengthValue);
75 RETURN_IF_EXCEPTION(throwScope, { });
76 } else {
77 throwRequiredMemberTypeError(state, throwScope, "modulusLength", "CryptoRsaHashedKeyAlgorithm", "unsigned long");
78 return { };
79 }
80 JSValue publicExponentValue;
81 if (isNullOrUndefined)
82 publicExponentValue = jsUndefined();
83 else {
84 publicExponentValue = object->get(&state, Identifier::fromString(&state, "publicExponent"));
85 RETURN_IF_EXCEPTION(throwScope, { });
86 }
87 if (!publicExponentValue.isUndefined()) {
88 result.publicExponent = convert<IDLUint8Array>(state, publicExponentValue);
89 RETURN_IF_EXCEPTION(throwScope, { });
90 } else {
91 throwRequiredMemberTypeError(state, throwScope, "publicExponent", "CryptoRsaHashedKeyAlgorithm", "Uint8Array");
92 return { };
93 }
94 JSValue hashValue;
95 if (isNullOrUndefined)
96 hashValue = jsUndefined();
97 else {
98 hashValue = object->get(&state, Identifier::fromString(&state, "hash"));
99 RETURN_IF_EXCEPTION(throwScope, { });
100 }
101 if (!hashValue.isUndefined()) {
102 result.hash = convert<IDLDictionary<CryptoKeyAlgorithm>>(state, hashValue);
103 RETURN_IF_EXCEPTION(throwScope, { });
104 } else {
105 throwRequiredMemberTypeError(state, throwScope, "hash", "CryptoRsaHashedKeyAlgorithm", "CryptoKeyAlgorithm");
106 return { };
107 }
108 return result;
109}
110
111JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const CryptoRsaHashedKeyAlgorithm& dictionary)
112{
113 auto& vm = state.vm();
114
115 auto result = constructEmptyObject(&state, globalObject.objectPrototype());
116
117 auto nameValue = toJS<IDLDOMString>(state, dictionary.name);
118 result->putDirect(vm, JSC::Identifier::fromString(&vm, "name"), nameValue);
119 auto modulusLengthValue = toJS<IDLUnsignedLong>(dictionary.modulusLength);
120 result->putDirect(vm, JSC::Identifier::fromString(&vm, "modulusLength"), modulusLengthValue);
121 auto publicExponentValue = toJS<IDLUint8Array>(state, globalObject, dictionary.publicExponent);
122 result->putDirect(vm, JSC::Identifier::fromString(&vm, "publicExponent"), publicExponentValue);
123 auto hashValue = toJS<IDLDictionary<CryptoKeyAlgorithm>>(state, globalObject, dictionary.hash);
124 result->putDirect(vm, JSC::Identifier::fromString(&vm, "hash"), hashValue);
125 return result;
126}
127
128#endif
129
130} // namespace WebCore
131
132#endif // ENABLE(WEB_CRYPTO)
133