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 | |
44 | namespace WebCore { |
45 | using namespace JSC; |
46 | |
47 | // Functions |
48 | |
49 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUProgrammablePassEncoderPrototypeFunctionEndPass(JSC::ExecState*); |
50 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUProgrammablePassEncoderPrototypeFunctionSetBindGroup(JSC::ExecState*); |
51 | |
52 | // Attributes |
53 | |
54 | JSC::EncodedJSValue jsWebGPUProgrammablePassEncoderConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
55 | bool setJSWebGPUProgrammablePassEncoderConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
56 | |
57 | class JSWebGPUProgrammablePassEncoderPrototype : public JSC::JSNonFinalObject { |
58 | public: |
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 | |
73 | private: |
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 | |
82 | using JSWebGPUProgrammablePassEncoderConstructor = JSDOMConstructorNotConstructable<JSWebGPUProgrammablePassEncoder>; |
83 | |
84 | template<> JSValue JSWebGPUProgrammablePassEncoderConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
85 | { |
86 | UNUSED_PARAM(vm); |
87 | return globalObject.functionPrototype(); |
88 | } |
89 | |
90 | template<> 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 | |
97 | template<> const ClassInfo JSWebGPUProgrammablePassEncoderConstructor::s_info = { "GPUProgrammablePassEncoder" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUProgrammablePassEncoderConstructor) }; |
98 | |
99 | /* Hash table for prototype */ |
100 | |
101 | static 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 | |
108 | const ClassInfo JSWebGPUProgrammablePassEncoderPrototype::s_info = { "GPUProgrammablePassEncoderPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUProgrammablePassEncoderPrototype) }; |
109 | |
110 | void JSWebGPUProgrammablePassEncoderPrototype::finishCreation(VM& vm) |
111 | { |
112 | Base::finishCreation(vm); |
113 | reifyStaticProperties(vm, JSWebGPUProgrammablePassEncoder::info(), JSWebGPUProgrammablePassEncoderPrototypeTableValues, *this); |
114 | } |
115 | |
116 | const ClassInfo JSWebGPUProgrammablePassEncoder::s_info = { "GPUProgrammablePassEncoder" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUProgrammablePassEncoder) }; |
117 | |
118 | JSWebGPUProgrammablePassEncoder::JSWebGPUProgrammablePassEncoder(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WebGPUProgrammablePassEncoder>&& impl) |
119 | : JSDOMWrapper<WebGPUProgrammablePassEncoder>(structure, globalObject, WTFMove(impl)) |
120 | { |
121 | } |
122 | |
123 | void JSWebGPUProgrammablePassEncoder::finishCreation(VM& vm) |
124 | { |
125 | Base::finishCreation(vm); |
126 | ASSERT(inherits(vm, info())); |
127 | |
128 | } |
129 | |
130 | JSObject* JSWebGPUProgrammablePassEncoder::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
131 | { |
132 | return JSWebGPUProgrammablePassEncoderPrototype::create(vm, &globalObject, JSWebGPUProgrammablePassEncoderPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
133 | } |
134 | |
135 | JSObject* JSWebGPUProgrammablePassEncoder::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
136 | { |
137 | return getDOMPrototype<JSWebGPUProgrammablePassEncoder>(vm, globalObject); |
138 | } |
139 | |
140 | JSValue JSWebGPUProgrammablePassEncoder::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
141 | { |
142 | return getDOMConstructor<JSWebGPUProgrammablePassEncoderConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
143 | } |
144 | |
145 | void JSWebGPUProgrammablePassEncoder::destroy(JSC::JSCell* cell) |
146 | { |
147 | JSWebGPUProgrammablePassEncoder* thisObject = static_cast<JSWebGPUProgrammablePassEncoder*>(cell); |
148 | thisObject->JSWebGPUProgrammablePassEncoder::~JSWebGPUProgrammablePassEncoder(); |
149 | } |
150 | |
151 | template<> inline JSWebGPUProgrammablePassEncoder* IDLOperation<JSWebGPUProgrammablePassEncoder>::cast(ExecState& state) |
152 | { |
153 | return jsDynamicCast<JSWebGPUProgrammablePassEncoder*>(state.vm(), state.thisValue()); |
154 | } |
155 | |
156 | EncodedJSValue 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 | |
166 | bool 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 | |
179 | static 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 | |
188 | EncodedJSValue JSC_HOST_CALL jsWebGPUProgrammablePassEncoderPrototypeFunctionEndPass(ExecState* state) |
189 | { |
190 | return IDLOperation<JSWebGPUProgrammablePassEncoder>::call<jsWebGPUProgrammablePassEncoderPrototypeFunctionEndPassBody>(*state, "endPass" ); |
191 | } |
192 | |
193 | static 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 | |
208 | EncodedJSValue JSC_HOST_CALL jsWebGPUProgrammablePassEncoderPrototypeFunctionSetBindGroup(ExecState* state) |
209 | { |
210 | return IDLOperation<JSWebGPUProgrammablePassEncoder>::call<jsWebGPUProgrammablePassEncoderPrototypeFunctionSetBindGroupBody>(*state, "setBindGroup" ); |
211 | } |
212 | |
213 | void 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 | |
222 | bool 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 | |
230 | void 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 | |
237 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<WebGPUProgrammablePassEncoder>&& impl) |
238 | { |
239 | return createWrapper<WebGPUProgrammablePassEncoder>(globalObject, WTFMove(impl)); |
240 | } |
241 | |
242 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, WebGPUProgrammablePassEncoder& impl) |
243 | { |
244 | return wrap(state, globalObject, impl); |
245 | } |
246 | |
247 | WebGPUProgrammablePassEncoder* 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 | |