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