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(WEBGPU)
24
25#include "JSWebGPUBindGroupBinding.h"
26
27#include "JSDOMConvertInterface.h"
28#include "JSDOMConvertNumbers.h"
29#include "JSDOMConvertUnion.h"
30#include "JSWebGPUBufferBinding.h"
31#include "JSWebGPUSampler.h"
32#include "JSWebGPUTextureView.h"
33#include <JavaScriptCore/JSCInlines.h>
34#include <wtf/Variant.h>
35
36
37namespace WebCore {
38using namespace JSC;
39
40#if ENABLE(WEBGPU)
41
42template<> WebGPUBindGroupBinding convertDictionary<WebGPUBindGroupBinding>(ExecState& state, JSValue value)
43{
44 VM& vm = state.vm();
45 auto throwScope = DECLARE_THROW_SCOPE(vm);
46 bool isNullOrUndefined = value.isUndefinedOrNull();
47 auto* object = isNullOrUndefined ? nullptr : value.getObject();
48 if (UNLIKELY(!isNullOrUndefined && !object)) {
49 throwTypeError(&state, throwScope);
50 return { };
51 }
52 WebGPUBindGroupBinding result;
53 JSValue bindingValue;
54 if (isNullOrUndefined)
55 bindingValue = jsUndefined();
56 else {
57 bindingValue = object->get(&state, Identifier::fromString(&state, "binding"));
58 RETURN_IF_EXCEPTION(throwScope, { });
59 }
60 if (!bindingValue.isUndefined()) {
61 result.binding = convert<IDLUnsignedLong>(state, bindingValue);
62 RETURN_IF_EXCEPTION(throwScope, { });
63 } else {
64 throwRequiredMemberTypeError(state, throwScope, "binding", "WebGPUBindGroupBinding", "unsigned long");
65 return { };
66 }
67 JSValue resourceValue;
68 if (isNullOrUndefined)
69 resourceValue = jsUndefined();
70 else {
71 resourceValue = object->get(&state, Identifier::fromString(&state, "resource"));
72 RETURN_IF_EXCEPTION(throwScope, { });
73 }
74 if (!resourceValue.isUndefined()) {
75 result.resource = convert<IDLUnion<IDLInterface<WebGPUSampler>, IDLInterface<WebGPUTextureView>, IDLDictionary<WebGPUBufferBinding>>>(state, resourceValue);
76 RETURN_IF_EXCEPTION(throwScope, { });
77 } else {
78 throwRequiredMemberTypeError(state, throwScope, "resource", "WebGPUBindGroupBinding", "(WebGPUSampler or WebGPUTextureView or WebGPUBufferBinding)");
79 return { };
80 }
81 return result;
82}
83
84#endif
85
86} // namespace WebCore
87
88#endif // ENABLE(WEBGPU)
89