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 "JSPbkdf2Params.h" |
26 | |
27 | #include "JSDOMConvertBufferSource.h" |
28 | #include "JSDOMConvertNumbers.h" |
29 | #include "JSDOMConvertObject.h" |
30 | #include "JSDOMConvertStrings.h" |
31 | #include "JSDOMConvertUnion.h" |
32 | #include <JavaScriptCore/JSCInlines.h> |
33 | #include <wtf/Variant.h> |
34 | |
35 | |
36 | namespace WebCore { |
37 | using namespace JSC; |
38 | |
39 | #if ENABLE(WEB_CRYPTO) |
40 | |
41 | template<> CryptoAlgorithmPbkdf2Params convertDictionary<CryptoAlgorithmPbkdf2Params>(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 | CryptoAlgorithmPbkdf2Params 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" , "Pbkdf2Params" , "DOMString" ); |
64 | return { }; |
65 | } |
66 | JSValue hashValue; |
67 | if (isNullOrUndefined) |
68 | hashValue = jsUndefined(); |
69 | else { |
70 | hashValue = object->get(&state, Identifier::fromString(&state, "hash" )); |
71 | RETURN_IF_EXCEPTION(throwScope, { }); |
72 | } |
73 | if (!hashValue.isUndefined()) { |
74 | result.hash = convert<IDLUnion<IDLObject, IDLDOMString>>(state, hashValue); |
75 | RETURN_IF_EXCEPTION(throwScope, { }); |
76 | } else { |
77 | throwRequiredMemberTypeError(state, throwScope, "hash" , "Pbkdf2Params" , "(object or DOMString)" ); |
78 | return { }; |
79 | } |
80 | JSValue iterationsValue; |
81 | if (isNullOrUndefined) |
82 | iterationsValue = jsUndefined(); |
83 | else { |
84 | iterationsValue = object->get(&state, Identifier::fromString(&state, "iterations" )); |
85 | RETURN_IF_EXCEPTION(throwScope, { }); |
86 | } |
87 | if (!iterationsValue.isUndefined()) { |
88 | result.iterations = convert<IDLEnforceRangeAdaptor<IDLUnsignedLong>>(state, iterationsValue); |
89 | RETURN_IF_EXCEPTION(throwScope, { }); |
90 | } else { |
91 | throwRequiredMemberTypeError(state, throwScope, "iterations" , "Pbkdf2Params" , "unsigned long" ); |
92 | return { }; |
93 | } |
94 | JSValue saltValue; |
95 | if (isNullOrUndefined) |
96 | saltValue = jsUndefined(); |
97 | else { |
98 | saltValue = object->get(&state, Identifier::fromString(&state, "salt" )); |
99 | RETURN_IF_EXCEPTION(throwScope, { }); |
100 | } |
101 | if (!saltValue.isUndefined()) { |
102 | result.salt = convert<IDLUnion<IDLArrayBufferView, IDLArrayBuffer>>(state, saltValue); |
103 | RETURN_IF_EXCEPTION(throwScope, { }); |
104 | } else { |
105 | throwRequiredMemberTypeError(state, throwScope, "salt" , "Pbkdf2Params" , "(ArrayBufferView or ArrayBuffer)" ); |
106 | return { }; |
107 | } |
108 | return result; |
109 | } |
110 | |
111 | #endif |
112 | |
113 | } // namespace WebCore |
114 | |
115 | #endif // ENABLE(WEB_CRYPTO) |
116 | |