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 "JSWebGPURenderPassEncoder.h" |
26 | |
27 | #include "JSDOMBinding.h" |
28 | #include "JSDOMConstructorNotConstructable.h" |
29 | #include "JSDOMConvertDictionary.h" |
30 | #include "JSDOMConvertInterface.h" |
31 | #include "JSDOMConvertNumbers.h" |
32 | #include "JSDOMConvertSequences.h" |
33 | #include "JSDOMExceptionHandling.h" |
34 | #include "JSDOMOperation.h" |
35 | #include "JSDOMWrapperCache.h" |
36 | #include "JSGPUColor.h" |
37 | #include "JSWebGPUBuffer.h" |
38 | #include "JSWebGPURenderPipeline.h" |
39 | #include "ScriptExecutionContext.h" |
40 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
41 | #include <JavaScriptCore/JSArray.h> |
42 | #include <JavaScriptCore/JSCInlines.h> |
43 | #include <wtf/GetPtr.h> |
44 | #include <wtf/PointerPreparations.h> |
45 | #include <wtf/URL.h> |
46 | |
47 | |
48 | namespace WebCore { |
49 | using namespace JSC; |
50 | |
51 | // Functions |
52 | |
53 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPURenderPassEncoderPrototypeFunctionSetPipeline(JSC::ExecState*); |
54 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPURenderPassEncoderPrototypeFunctionSetBlendColor(JSC::ExecState*); |
55 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPURenderPassEncoderPrototypeFunctionSetViewport(JSC::ExecState*); |
56 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPURenderPassEncoderPrototypeFunctionSetScissorRect(JSC::ExecState*); |
57 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPURenderPassEncoderPrototypeFunctionSetIndexBuffer(JSC::ExecState*); |
58 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPURenderPassEncoderPrototypeFunctionSetVertexBuffers(JSC::ExecState*); |
59 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPURenderPassEncoderPrototypeFunctionDraw(JSC::ExecState*); |
60 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPURenderPassEncoderPrototypeFunctionDrawIndexed(JSC::ExecState*); |
61 | |
62 | // Attributes |
63 | |
64 | JSC::EncodedJSValue jsWebGPURenderPassEncoderConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
65 | bool setJSWebGPURenderPassEncoderConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
66 | |
67 | class JSWebGPURenderPassEncoderPrototype : public JSC::JSNonFinalObject { |
68 | public: |
69 | using Base = JSC::JSNonFinalObject; |
70 | static JSWebGPURenderPassEncoderPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
71 | { |
72 | JSWebGPURenderPassEncoderPrototype* ptr = new (NotNull, JSC::allocateCell<JSWebGPURenderPassEncoderPrototype>(vm.heap)) JSWebGPURenderPassEncoderPrototype(vm, globalObject, structure); |
73 | ptr->finishCreation(vm); |
74 | return ptr; |
75 | } |
76 | |
77 | DECLARE_INFO; |
78 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
79 | { |
80 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
81 | } |
82 | |
83 | private: |
84 | JSWebGPURenderPassEncoderPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
85 | : JSC::JSNonFinalObject(vm, structure) |
86 | { |
87 | } |
88 | |
89 | void finishCreation(JSC::VM&); |
90 | }; |
91 | |
92 | using JSWebGPURenderPassEncoderConstructor = JSDOMConstructorNotConstructable<JSWebGPURenderPassEncoder>; |
93 | |
94 | template<> JSValue JSWebGPURenderPassEncoderConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
95 | { |
96 | return JSWebGPUProgrammablePassEncoder::getConstructor(vm, &globalObject); |
97 | } |
98 | |
99 | template<> void JSWebGPURenderPassEncoderConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
100 | { |
101 | putDirect(vm, vm.propertyNames->prototype, JSWebGPURenderPassEncoder::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
102 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("GPURenderPassEncoder"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
103 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
104 | } |
105 | |
106 | template<> const ClassInfo JSWebGPURenderPassEncoderConstructor::s_info = { "GPURenderPassEncoder" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPURenderPassEncoderConstructor) }; |
107 | |
108 | /* Hash table for prototype */ |
109 | |
110 | static const HashTableValue JSWebGPURenderPassEncoderPrototypeTableValues[] = |
111 | { |
112 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebGPURenderPassEncoderConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWebGPURenderPassEncoderConstructor) } }, |
113 | { "setPipeline" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPURenderPassEncoderPrototypeFunctionSetPipeline), (intptr_t) (1) } }, |
114 | { "setBlendColor" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPURenderPassEncoderPrototypeFunctionSetBlendColor), (intptr_t) (1) } }, |
115 | { "setViewport" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPURenderPassEncoderPrototypeFunctionSetViewport), (intptr_t) (6) } }, |
116 | { "setScissorRect" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPURenderPassEncoderPrototypeFunctionSetScissorRect), (intptr_t) (4) } }, |
117 | { "setIndexBuffer" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPURenderPassEncoderPrototypeFunctionSetIndexBuffer), (intptr_t) (2) } }, |
118 | { "setVertexBuffers" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPURenderPassEncoderPrototypeFunctionSetVertexBuffers), (intptr_t) (3) } }, |
119 | { "draw" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPURenderPassEncoderPrototypeFunctionDraw), (intptr_t) (4) } }, |
120 | { "drawIndexed" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPURenderPassEncoderPrototypeFunctionDrawIndexed), (intptr_t) (5) } }, |
121 | }; |
122 | |
123 | const ClassInfo JSWebGPURenderPassEncoderPrototype::s_info = { "GPURenderPassEncoderPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPURenderPassEncoderPrototype) }; |
124 | |
125 | void JSWebGPURenderPassEncoderPrototype::finishCreation(VM& vm) |
126 | { |
127 | Base::finishCreation(vm); |
128 | reifyStaticProperties(vm, JSWebGPURenderPassEncoder::info(), JSWebGPURenderPassEncoderPrototypeTableValues, *this); |
129 | } |
130 | |
131 | const ClassInfo JSWebGPURenderPassEncoder::s_info = { "GPURenderPassEncoder" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPURenderPassEncoder) }; |
132 | |
133 | JSWebGPURenderPassEncoder::JSWebGPURenderPassEncoder(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WebGPURenderPassEncoder>&& impl) |
134 | : JSWebGPUProgrammablePassEncoder(structure, globalObject, WTFMove(impl)) |
135 | { |
136 | } |
137 | |
138 | void JSWebGPURenderPassEncoder::finishCreation(VM& vm) |
139 | { |
140 | Base::finishCreation(vm); |
141 | ASSERT(inherits(vm, info())); |
142 | |
143 | } |
144 | |
145 | JSObject* JSWebGPURenderPassEncoder::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
146 | { |
147 | return JSWebGPURenderPassEncoderPrototype::create(vm, &globalObject, JSWebGPURenderPassEncoderPrototype::createStructure(vm, &globalObject, JSWebGPUProgrammablePassEncoder::prototype(vm, globalObject))); |
148 | } |
149 | |
150 | JSObject* JSWebGPURenderPassEncoder::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
151 | { |
152 | return getDOMPrototype<JSWebGPURenderPassEncoder>(vm, globalObject); |
153 | } |
154 | |
155 | JSValue JSWebGPURenderPassEncoder::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
156 | { |
157 | return getDOMConstructor<JSWebGPURenderPassEncoderConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
158 | } |
159 | |
160 | template<> inline JSWebGPURenderPassEncoder* IDLOperation<JSWebGPURenderPassEncoder>::cast(ExecState& state) |
161 | { |
162 | return jsDynamicCast<JSWebGPURenderPassEncoder*>(state.vm(), state.thisValue()); |
163 | } |
164 | |
165 | EncodedJSValue jsWebGPURenderPassEncoderConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
166 | { |
167 | VM& vm = state->vm(); |
168 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
169 | auto* prototype = jsDynamicCast<JSWebGPURenderPassEncoderPrototype*>(vm, JSValue::decode(thisValue)); |
170 | if (UNLIKELY(!prototype)) |
171 | return throwVMTypeError(state, throwScope); |
172 | return JSValue::encode(JSWebGPURenderPassEncoder::getConstructor(state->vm(), prototype->globalObject())); |
173 | } |
174 | |
175 | bool setJSWebGPURenderPassEncoderConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
176 | { |
177 | VM& vm = state->vm(); |
178 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
179 | auto* prototype = jsDynamicCast<JSWebGPURenderPassEncoderPrototype*>(vm, JSValue::decode(thisValue)); |
180 | if (UNLIKELY(!prototype)) { |
181 | throwVMTypeError(state, throwScope); |
182 | return false; |
183 | } |
184 | // Shadowing a built-in constructor |
185 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
186 | } |
187 | |
188 | static inline JSC::EncodedJSValue jsWebGPURenderPassEncoderPrototypeFunctionSetPipelineBody(JSC::ExecState* state, typename IDLOperation<JSWebGPURenderPassEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
189 | { |
190 | UNUSED_PARAM(state); |
191 | UNUSED_PARAM(throwScope); |
192 | auto& impl = castedThis->wrapped(); |
193 | if (UNLIKELY(state->argumentCount() < 1)) |
194 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
195 | auto pipeline = convert<IDLInterface<WebGPURenderPipeline>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "pipeline" , "GPURenderPassEncoder" , "setPipeline" , "WebGPURenderPipeline" ); }); |
196 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
197 | impl.setPipeline(*pipeline); |
198 | return JSValue::encode(jsUndefined()); |
199 | } |
200 | |
201 | EncodedJSValue JSC_HOST_CALL jsWebGPURenderPassEncoderPrototypeFunctionSetPipeline(ExecState* state) |
202 | { |
203 | return IDLOperation<JSWebGPURenderPassEncoder>::call<jsWebGPURenderPassEncoderPrototypeFunctionSetPipelineBody>(*state, "setPipeline" ); |
204 | } |
205 | |
206 | static inline JSC::EncodedJSValue jsWebGPURenderPassEncoderPrototypeFunctionSetBlendColorBody(JSC::ExecState* state, typename IDLOperation<JSWebGPURenderPassEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
207 | { |
208 | UNUSED_PARAM(state); |
209 | UNUSED_PARAM(throwScope); |
210 | auto& impl = castedThis->wrapped(); |
211 | if (UNLIKELY(state->argumentCount() < 1)) |
212 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
213 | auto color = convert<IDLDictionary<GPUColor>>(*state, state->uncheckedArgument(0)); |
214 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
215 | impl.setBlendColor(WTFMove(color)); |
216 | return JSValue::encode(jsUndefined()); |
217 | } |
218 | |
219 | EncodedJSValue JSC_HOST_CALL jsWebGPURenderPassEncoderPrototypeFunctionSetBlendColor(ExecState* state) |
220 | { |
221 | return IDLOperation<JSWebGPURenderPassEncoder>::call<jsWebGPURenderPassEncoderPrototypeFunctionSetBlendColorBody>(*state, "setBlendColor" ); |
222 | } |
223 | |
224 | static inline JSC::EncodedJSValue jsWebGPURenderPassEncoderPrototypeFunctionSetViewportBody(JSC::ExecState* state, typename IDLOperation<JSWebGPURenderPassEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
225 | { |
226 | UNUSED_PARAM(state); |
227 | UNUSED_PARAM(throwScope); |
228 | auto& impl = castedThis->wrapped(); |
229 | if (UNLIKELY(state->argumentCount() < 6)) |
230 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
231 | auto x = convert<IDLFloat>(*state, state->uncheckedArgument(0)); |
232 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
233 | auto y = convert<IDLFloat>(*state, state->uncheckedArgument(1)); |
234 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
235 | auto width = convert<IDLFloat>(*state, state->uncheckedArgument(2)); |
236 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
237 | auto height = convert<IDLFloat>(*state, state->uncheckedArgument(3)); |
238 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
239 | auto minDepth = convert<IDLFloat>(*state, state->uncheckedArgument(4)); |
240 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
241 | auto maxDepth = convert<IDLFloat>(*state, state->uncheckedArgument(5)); |
242 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
243 | impl.setViewport(WTFMove(x), WTFMove(y), WTFMove(width), WTFMove(height), WTFMove(minDepth), WTFMove(maxDepth)); |
244 | return JSValue::encode(jsUndefined()); |
245 | } |
246 | |
247 | EncodedJSValue JSC_HOST_CALL jsWebGPURenderPassEncoderPrototypeFunctionSetViewport(ExecState* state) |
248 | { |
249 | return IDLOperation<JSWebGPURenderPassEncoder>::call<jsWebGPURenderPassEncoderPrototypeFunctionSetViewportBody>(*state, "setViewport" ); |
250 | } |
251 | |
252 | static inline JSC::EncodedJSValue jsWebGPURenderPassEncoderPrototypeFunctionSetScissorRectBody(JSC::ExecState* state, typename IDLOperation<JSWebGPURenderPassEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
253 | { |
254 | UNUSED_PARAM(state); |
255 | UNUSED_PARAM(throwScope); |
256 | auto& impl = castedThis->wrapped(); |
257 | if (UNLIKELY(state->argumentCount() < 4)) |
258 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
259 | auto x = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
260 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
261 | auto y = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(1)); |
262 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
263 | auto width = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(2)); |
264 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
265 | auto height = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(3)); |
266 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
267 | impl.setScissorRect(WTFMove(x), WTFMove(y), WTFMove(width), WTFMove(height)); |
268 | return JSValue::encode(jsUndefined()); |
269 | } |
270 | |
271 | EncodedJSValue JSC_HOST_CALL jsWebGPURenderPassEncoderPrototypeFunctionSetScissorRect(ExecState* state) |
272 | { |
273 | return IDLOperation<JSWebGPURenderPassEncoder>::call<jsWebGPURenderPassEncoderPrototypeFunctionSetScissorRectBody>(*state, "setScissorRect" ); |
274 | } |
275 | |
276 | static inline JSC::EncodedJSValue jsWebGPURenderPassEncoderPrototypeFunctionSetIndexBufferBody(JSC::ExecState* state, typename IDLOperation<JSWebGPURenderPassEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
277 | { |
278 | UNUSED_PARAM(state); |
279 | UNUSED_PARAM(throwScope); |
280 | auto& impl = castedThis->wrapped(); |
281 | if (UNLIKELY(state->argumentCount() < 2)) |
282 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
283 | auto buffer = convert<IDLInterface<WebGPUBuffer>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "buffer" , "GPURenderPassEncoder" , "setIndexBuffer" , "WebGPUBuffer" ); }); |
284 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
285 | auto offset = convert<IDLUnsignedLongLong>(*state, state->uncheckedArgument(1)); |
286 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
287 | impl.setIndexBuffer(*buffer, WTFMove(offset)); |
288 | return JSValue::encode(jsUndefined()); |
289 | } |
290 | |
291 | EncodedJSValue JSC_HOST_CALL jsWebGPURenderPassEncoderPrototypeFunctionSetIndexBuffer(ExecState* state) |
292 | { |
293 | return IDLOperation<JSWebGPURenderPassEncoder>::call<jsWebGPURenderPassEncoderPrototypeFunctionSetIndexBufferBody>(*state, "setIndexBuffer" ); |
294 | } |
295 | |
296 | static inline JSC::EncodedJSValue jsWebGPURenderPassEncoderPrototypeFunctionSetVertexBuffersBody(JSC::ExecState* state, typename IDLOperation<JSWebGPURenderPassEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
297 | { |
298 | UNUSED_PARAM(state); |
299 | UNUSED_PARAM(throwScope); |
300 | auto& impl = castedThis->wrapped(); |
301 | if (UNLIKELY(state->argumentCount() < 3)) |
302 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
303 | auto startSlot = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
304 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
305 | auto buffers = convert<IDLSequence<IDLInterface<WebGPUBuffer>>>(*state, state->uncheckedArgument(1)); |
306 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
307 | auto offsets = convert<IDLSequence<IDLUnsignedLongLong>>(*state, state->uncheckedArgument(2)); |
308 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
309 | impl.setVertexBuffers(WTFMove(startSlot), WTFMove(buffers), WTFMove(offsets)); |
310 | return JSValue::encode(jsUndefined()); |
311 | } |
312 | |
313 | EncodedJSValue JSC_HOST_CALL jsWebGPURenderPassEncoderPrototypeFunctionSetVertexBuffers(ExecState* state) |
314 | { |
315 | return IDLOperation<JSWebGPURenderPassEncoder>::call<jsWebGPURenderPassEncoderPrototypeFunctionSetVertexBuffersBody>(*state, "setVertexBuffers" ); |
316 | } |
317 | |
318 | static inline JSC::EncodedJSValue jsWebGPURenderPassEncoderPrototypeFunctionDrawBody(JSC::ExecState* state, typename IDLOperation<JSWebGPURenderPassEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
319 | { |
320 | UNUSED_PARAM(state); |
321 | UNUSED_PARAM(throwScope); |
322 | auto& impl = castedThis->wrapped(); |
323 | if (UNLIKELY(state->argumentCount() < 4)) |
324 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
325 | auto vertexCount = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
326 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
327 | auto instanceCount = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(1)); |
328 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
329 | auto firstVertex = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(2)); |
330 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
331 | auto firstInstance = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(3)); |
332 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
333 | impl.draw(WTFMove(vertexCount), WTFMove(instanceCount), WTFMove(firstVertex), WTFMove(firstInstance)); |
334 | return JSValue::encode(jsUndefined()); |
335 | } |
336 | |
337 | EncodedJSValue JSC_HOST_CALL jsWebGPURenderPassEncoderPrototypeFunctionDraw(ExecState* state) |
338 | { |
339 | return IDLOperation<JSWebGPURenderPassEncoder>::call<jsWebGPURenderPassEncoderPrototypeFunctionDrawBody>(*state, "draw" ); |
340 | } |
341 | |
342 | static inline JSC::EncodedJSValue jsWebGPURenderPassEncoderPrototypeFunctionDrawIndexedBody(JSC::ExecState* state, typename IDLOperation<JSWebGPURenderPassEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
343 | { |
344 | UNUSED_PARAM(state); |
345 | UNUSED_PARAM(throwScope); |
346 | auto& impl = castedThis->wrapped(); |
347 | if (UNLIKELY(state->argumentCount() < 5)) |
348 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
349 | auto indexCount = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
350 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
351 | auto instanceCount = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(1)); |
352 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
353 | auto firstIndex = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(2)); |
354 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
355 | auto baseVertex = convert<IDLLong>(*state, state->uncheckedArgument(3)); |
356 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
357 | auto firstInstance = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(4)); |
358 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
359 | impl.drawIndexed(WTFMove(indexCount), WTFMove(instanceCount), WTFMove(firstIndex), WTFMove(baseVertex), WTFMove(firstInstance)); |
360 | return JSValue::encode(jsUndefined()); |
361 | } |
362 | |
363 | EncodedJSValue JSC_HOST_CALL jsWebGPURenderPassEncoderPrototypeFunctionDrawIndexed(ExecState* state) |
364 | { |
365 | return IDLOperation<JSWebGPURenderPassEncoder>::call<jsWebGPURenderPassEncoderPrototypeFunctionDrawIndexedBody>(*state, "drawIndexed" ); |
366 | } |
367 | |
368 | void JSWebGPURenderPassEncoder::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
369 | { |
370 | auto* thisObject = jsCast<JSWebGPURenderPassEncoder*>(cell); |
371 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
372 | if (thisObject->scriptExecutionContext()) |
373 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
374 | Base::heapSnapshot(cell, builder); |
375 | } |
376 | |
377 | #if ENABLE(BINDING_INTEGRITY) |
378 | #if PLATFORM(WIN) |
379 | #pragma warning(disable: 4483) |
380 | extern "C" { extern void (*const __identifier("??_7WebGPURenderPassEncoder@WebCore@@6B@" )[])(); } |
381 | #else |
382 | extern "C" { extern void* _ZTVN7WebCore23WebGPURenderPassEncoderE[]; } |
383 | #endif |
384 | #endif |
385 | |
386 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<WebGPURenderPassEncoder>&& impl) |
387 | { |
388 | |
389 | #if ENABLE(BINDING_INTEGRITY) |
390 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
391 | #if PLATFORM(WIN) |
392 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7WebGPURenderPassEncoder@WebCore@@6B@" )); |
393 | #else |
394 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore23WebGPURenderPassEncoderE[2]); |
395 | #endif |
396 | |
397 | // If this fails WebGPURenderPassEncoder does not have a vtable, so you need to add the |
398 | // ImplementationLacksVTable attribute to the interface definition |
399 | static_assert(std::is_polymorphic<WebGPURenderPassEncoder>::value, "WebGPURenderPassEncoder is not polymorphic" ); |
400 | |
401 | // If you hit this assertion you either have a use after free bug, or |
402 | // WebGPURenderPassEncoder has subclasses. If WebGPURenderPassEncoder has subclasses that get passed |
403 | // to toJS() we currently require WebGPURenderPassEncoder you to opt out of binding hardening |
404 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
405 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
406 | #endif |
407 | return createWrapper<WebGPURenderPassEncoder>(globalObject, WTFMove(impl)); |
408 | } |
409 | |
410 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, WebGPURenderPassEncoder& impl) |
411 | { |
412 | return wrap(state, globalObject, impl); |
413 | } |
414 | |
415 | |
416 | } |
417 | |
418 | #endif // ENABLE(WEBGPU) |
419 | |