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 "JSWebGPUProgrammablePassEncoder.h"
26
27#include "JSDOMBinding.h"
28#include "JSDOMConstructorNotConstructable.h"
29#include "JSDOMConvertInterface.h"
30#include "JSDOMConvertNumbers.h"
31#include "JSDOMExceptionHandling.h"
32#include "JSDOMOperation.h"
33#include "JSDOMWrapperCache.h"
34#include "JSWebGPUBindGroup.h"
35#include "ScriptExecutionContext.h"
36#include <JavaScriptCore/FunctionPrototype.h>
37#include <JavaScriptCore/HeapSnapshotBuilder.h>
38#include <JavaScriptCore/JSCInlines.h>
39#include <wtf/GetPtr.h>
40#include <wtf/PointerPreparations.h>
41#include <wtf/URL.h>
42
43
44namespace WebCore {
45using namespace JSC;
46
47// Functions
48
49JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUProgrammablePassEncoderPrototypeFunctionEndPass(JSC::ExecState*);
50JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUProgrammablePassEncoderPrototypeFunctionSetBindGroup(JSC::ExecState*);
51
52// Attributes
53
54JSC::EncodedJSValue jsWebGPUProgrammablePassEncoderConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
55bool setJSWebGPUProgrammablePassEncoderConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
56
57class JSWebGPUProgrammablePassEncoderPrototype : public JSC::JSNonFinalObject {
58public:
59 using Base = JSC::JSNonFinalObject;
60 static JSWebGPUProgrammablePassEncoderPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
61 {
62 JSWebGPUProgrammablePassEncoderPrototype* ptr = new (NotNull, JSC::allocateCell<JSWebGPUProgrammablePassEncoderPrototype>(vm.heap)) JSWebGPUProgrammablePassEncoderPrototype(vm, globalObject, structure);
63 ptr->finishCreation(vm);
64 return ptr;
65 }
66
67 DECLARE_INFO;
68 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
69 {
70 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
71 }
72
73private:
74 JSWebGPUProgrammablePassEncoderPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
75 : JSC::JSNonFinalObject(vm, structure)
76 {
77 }
78
79 void finishCreation(JSC::VM&);
80};
81
82using JSWebGPUProgrammablePassEncoderConstructor = JSDOMConstructorNotConstructable<JSWebGPUProgrammablePassEncoder>;
83
84template<> JSValue JSWebGPUProgrammablePassEncoderConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
85{
86 UNUSED_PARAM(vm);
87 return globalObject.functionPrototype();
88}
89
90template<> void JSWebGPUProgrammablePassEncoderConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
91{
92 putDirect(vm, vm.propertyNames->prototype, JSWebGPUProgrammablePassEncoder::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
93 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("GPUProgrammablePassEncoder"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
94 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
95}
96
97template<> const ClassInfo JSWebGPUProgrammablePassEncoderConstructor::s_info = { "GPUProgrammablePassEncoder", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUProgrammablePassEncoderConstructor) };
98
99/* Hash table for prototype */
100
101static const HashTableValue JSWebGPUProgrammablePassEncoderPrototypeTableValues[] =
102{
103 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebGPUProgrammablePassEncoderConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWebGPUProgrammablePassEncoderConstructor) } },
104 { "endPass", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUProgrammablePassEncoderPrototypeFunctionEndPass), (intptr_t) (0) } },
105 { "setBindGroup", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUProgrammablePassEncoderPrototypeFunctionSetBindGroup), (intptr_t) (2) } },
106};
107
108const ClassInfo JSWebGPUProgrammablePassEncoderPrototype::s_info = { "GPUProgrammablePassEncoderPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUProgrammablePassEncoderPrototype) };
109
110void JSWebGPUProgrammablePassEncoderPrototype::finishCreation(VM& vm)
111{
112 Base::finishCreation(vm);
113 reifyStaticProperties(vm, JSWebGPUProgrammablePassEncoder::info(), JSWebGPUProgrammablePassEncoderPrototypeTableValues, *this);
114}
115
116const ClassInfo JSWebGPUProgrammablePassEncoder::s_info = { "GPUProgrammablePassEncoder", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUProgrammablePassEncoder) };
117
118JSWebGPUProgrammablePassEncoder::JSWebGPUProgrammablePassEncoder(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WebGPUProgrammablePassEncoder>&& impl)
119 : JSDOMWrapper<WebGPUProgrammablePassEncoder>(structure, globalObject, WTFMove(impl))
120{
121}
122
123void JSWebGPUProgrammablePassEncoder::finishCreation(VM& vm)
124{
125 Base::finishCreation(vm);
126 ASSERT(inherits(vm, info()));
127
128}
129
130JSObject* JSWebGPUProgrammablePassEncoder::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
131{
132 return JSWebGPUProgrammablePassEncoderPrototype::create(vm, &globalObject, JSWebGPUProgrammablePassEncoderPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
133}
134
135JSObject* JSWebGPUProgrammablePassEncoder::prototype(VM& vm, JSDOMGlobalObject& globalObject)
136{
137 return getDOMPrototype<JSWebGPUProgrammablePassEncoder>(vm, globalObject);
138}
139
140JSValue JSWebGPUProgrammablePassEncoder::getConstructor(VM& vm, const JSGlobalObject* globalObject)
141{
142 return getDOMConstructor<JSWebGPUProgrammablePassEncoderConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
143}
144
145void JSWebGPUProgrammablePassEncoder::destroy(JSC::JSCell* cell)
146{
147 JSWebGPUProgrammablePassEncoder* thisObject = static_cast<JSWebGPUProgrammablePassEncoder*>(cell);
148 thisObject->JSWebGPUProgrammablePassEncoder::~JSWebGPUProgrammablePassEncoder();
149}
150
151template<> inline JSWebGPUProgrammablePassEncoder* IDLOperation<JSWebGPUProgrammablePassEncoder>::cast(ExecState& state)
152{
153 return jsDynamicCast<JSWebGPUProgrammablePassEncoder*>(state.vm(), state.thisValue());
154}
155
156EncodedJSValue jsWebGPUProgrammablePassEncoderConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
157{
158 VM& vm = state->vm();
159 auto throwScope = DECLARE_THROW_SCOPE(vm);
160 auto* prototype = jsDynamicCast<JSWebGPUProgrammablePassEncoderPrototype*>(vm, JSValue::decode(thisValue));
161 if (UNLIKELY(!prototype))
162 return throwVMTypeError(state, throwScope);
163 return JSValue::encode(JSWebGPUProgrammablePassEncoder::getConstructor(state->vm(), prototype->globalObject()));
164}
165
166bool setJSWebGPUProgrammablePassEncoderConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
167{
168 VM& vm = state->vm();
169 auto throwScope = DECLARE_THROW_SCOPE(vm);
170 auto* prototype = jsDynamicCast<JSWebGPUProgrammablePassEncoderPrototype*>(vm, JSValue::decode(thisValue));
171 if (UNLIKELY(!prototype)) {
172 throwVMTypeError(state, throwScope);
173 return false;
174 }
175 // Shadowing a built-in constructor
176 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
177}
178
179static inline JSC::EncodedJSValue jsWebGPUProgrammablePassEncoderPrototypeFunctionEndPassBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUProgrammablePassEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
180{
181 UNUSED_PARAM(state);
182 UNUSED_PARAM(throwScope);
183 auto& impl = castedThis->wrapped();
184 impl.endPass();
185 return JSValue::encode(jsUndefined());
186}
187
188EncodedJSValue JSC_HOST_CALL jsWebGPUProgrammablePassEncoderPrototypeFunctionEndPass(ExecState* state)
189{
190 return IDLOperation<JSWebGPUProgrammablePassEncoder>::call<jsWebGPUProgrammablePassEncoderPrototypeFunctionEndPassBody>(*state, "endPass");
191}
192
193static inline JSC::EncodedJSValue jsWebGPUProgrammablePassEncoderPrototypeFunctionSetBindGroupBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUProgrammablePassEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
194{
195 UNUSED_PARAM(state);
196 UNUSED_PARAM(throwScope);
197 auto& impl = castedThis->wrapped();
198 if (UNLIKELY(state->argumentCount() < 2))
199 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
200 auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0));
201 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
202 auto bindGroup = convert<IDLInterface<WebGPUBindGroup>>(*state, state->uncheckedArgument(1), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 1, "bindGroup", "GPUProgrammablePassEncoder", "setBindGroup", "WebGPUBindGroup"); });
203 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
204 impl.setBindGroup(WTFMove(index), *bindGroup);
205 return JSValue::encode(jsUndefined());
206}
207
208EncodedJSValue JSC_HOST_CALL jsWebGPUProgrammablePassEncoderPrototypeFunctionSetBindGroup(ExecState* state)
209{
210 return IDLOperation<JSWebGPUProgrammablePassEncoder>::call<jsWebGPUProgrammablePassEncoderPrototypeFunctionSetBindGroupBody>(*state, "setBindGroup");
211}
212
213void JSWebGPUProgrammablePassEncoder::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
214{
215 auto* thisObject = jsCast<JSWebGPUProgrammablePassEncoder*>(cell);
216 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
217 if (thisObject->scriptExecutionContext())
218 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
219 Base::heapSnapshot(cell, builder);
220}
221
222bool JSWebGPUProgrammablePassEncoderOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
223{
224 UNUSED_PARAM(handle);
225 UNUSED_PARAM(visitor);
226 UNUSED_PARAM(reason);
227 return false;
228}
229
230void JSWebGPUProgrammablePassEncoderOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
231{
232 auto* jsWebGPUProgrammablePassEncoder = static_cast<JSWebGPUProgrammablePassEncoder*>(handle.slot()->asCell());
233 auto& world = *static_cast<DOMWrapperWorld*>(context);
234 uncacheWrapper(world, &jsWebGPUProgrammablePassEncoder->wrapped(), jsWebGPUProgrammablePassEncoder);
235}
236
237JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<WebGPUProgrammablePassEncoder>&& impl)
238{
239 return createWrapper<WebGPUProgrammablePassEncoder>(globalObject, WTFMove(impl));
240}
241
242JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, WebGPUProgrammablePassEncoder& impl)
243{
244 return wrap(state, globalObject, impl);
245}
246
247WebGPUProgrammablePassEncoder* JSWebGPUProgrammablePassEncoder::toWrapped(JSC::VM& vm, JSC::JSValue value)
248{
249 if (auto* wrapper = jsDynamicCast<JSWebGPUProgrammablePassEncoder*>(vm, value))
250 return &wrapper->wrapped();
251 return nullptr;
252}
253
254}
255
256#endif // ENABLE(WEBGPU)
257