| 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 "JSWebGPUDevice.h" |
| 26 | |
| 27 | #include "JSDOMAttribute.h" |
| 28 | #include "JSDOMBinding.h" |
| 29 | #include "JSDOMConstructorNotConstructable.h" |
| 30 | #include "JSDOMConvertDictionary.h" |
| 31 | #include "JSDOMConvertInterface.h" |
| 32 | #include "JSDOMExceptionHandling.h" |
| 33 | #include "JSDOMGlobalObject.h" |
| 34 | #include "JSDOMOperation.h" |
| 35 | #include "JSDOMWrapperCache.h" |
| 36 | #include "JSGPUBindGroupLayoutDescriptor.h" |
| 37 | #include "JSGPUBufferDescriptor.h" |
| 38 | #include "JSGPUSamplerDescriptor.h" |
| 39 | #include "JSGPUTextureDescriptor.h" |
| 40 | #include "JSWebGPUAdapter.h" |
| 41 | #include "JSWebGPUBindGroup.h" |
| 42 | #include "JSWebGPUBindGroupDescriptor.h" |
| 43 | #include "JSWebGPUBindGroupLayout.h" |
| 44 | #include "JSWebGPUBuffer.h" |
| 45 | #include "JSWebGPUCommandEncoder.h" |
| 46 | #include "JSWebGPUComputePipeline.h" |
| 47 | #include "JSWebGPUComputePipelineDescriptor.h" |
| 48 | #include "JSWebGPUPipelineLayout.h" |
| 49 | #include "JSWebGPUPipelineLayoutDescriptor.h" |
| 50 | #include "JSWebGPUQueue.h" |
| 51 | #include "JSWebGPURenderPipeline.h" |
| 52 | #include "JSWebGPURenderPipelineDescriptor.h" |
| 53 | #include "JSWebGPUSampler.h" |
| 54 | #include "JSWebGPUShaderModule.h" |
| 55 | #include "JSWebGPUShaderModuleDescriptor.h" |
| 56 | #include "JSWebGPUTexture.h" |
| 57 | #include "ScriptExecutionContext.h" |
| 58 | #include <JavaScriptCore/FunctionPrototype.h> |
| 59 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 60 | #include <JavaScriptCore/JSCInlines.h> |
| 61 | #include <wtf/GetPtr.h> |
| 62 | #include <wtf/PointerPreparations.h> |
| 63 | #include <wtf/URL.h> |
| 64 | |
| 65 | |
| 66 | namespace WebCore { |
| 67 | using namespace JSC; |
| 68 | |
| 69 | // Functions |
| 70 | |
| 71 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreateBuffer(JSC::ExecState*); |
| 72 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreateTexture(JSC::ExecState*); |
| 73 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreateSampler(JSC::ExecState*); |
| 74 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreateBindGroupLayout(JSC::ExecState*); |
| 75 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreatePipelineLayout(JSC::ExecState*); |
| 76 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreateBindGroup(JSC::ExecState*); |
| 77 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreateShaderModule(JSC::ExecState*); |
| 78 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreateRenderPipeline(JSC::ExecState*); |
| 79 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreateComputePipeline(JSC::ExecState*); |
| 80 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreateCommandEncoder(JSC::ExecState*); |
| 81 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionGetQueue(JSC::ExecState*); |
| 82 | |
| 83 | // Attributes |
| 84 | |
| 85 | JSC::EncodedJSValue jsWebGPUDeviceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 86 | bool setJSWebGPUDeviceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 87 | JSC::EncodedJSValue jsWebGPUDeviceAdapter(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 88 | |
| 89 | class JSWebGPUDevicePrototype : public JSC::JSNonFinalObject { |
| 90 | public: |
| 91 | using Base = JSC::JSNonFinalObject; |
| 92 | static JSWebGPUDevicePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 93 | { |
| 94 | JSWebGPUDevicePrototype* ptr = new (NotNull, JSC::allocateCell<JSWebGPUDevicePrototype>(vm.heap)) JSWebGPUDevicePrototype(vm, globalObject, structure); |
| 95 | ptr->finishCreation(vm); |
| 96 | return ptr; |
| 97 | } |
| 98 | |
| 99 | DECLARE_INFO; |
| 100 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 101 | { |
| 102 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 103 | } |
| 104 | |
| 105 | private: |
| 106 | JSWebGPUDevicePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 107 | : JSC::JSNonFinalObject(vm, structure) |
| 108 | { |
| 109 | } |
| 110 | |
| 111 | void finishCreation(JSC::VM&); |
| 112 | }; |
| 113 | |
| 114 | using JSWebGPUDeviceConstructor = JSDOMConstructorNotConstructable<JSWebGPUDevice>; |
| 115 | |
| 116 | template<> JSValue JSWebGPUDeviceConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 117 | { |
| 118 | UNUSED_PARAM(vm); |
| 119 | return globalObject.functionPrototype(); |
| 120 | } |
| 121 | |
| 122 | template<> void JSWebGPUDeviceConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 123 | { |
| 124 | putDirect(vm, vm.propertyNames->prototype, JSWebGPUDevice::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 125 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("GPUDevice"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 126 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 127 | } |
| 128 | |
| 129 | template<> const ClassInfo JSWebGPUDeviceConstructor::s_info = { "GPUDevice" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUDeviceConstructor) }; |
| 130 | |
| 131 | /* Hash table for prototype */ |
| 132 | |
| 133 | static const HashTableValue JSWebGPUDevicePrototypeTableValues[] = |
| 134 | { |
| 135 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebGPUDeviceConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWebGPUDeviceConstructor) } }, |
| 136 | { "adapter" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebGPUDeviceAdapter), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 137 | { "createBuffer" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUDevicePrototypeFunctionCreateBuffer), (intptr_t) (1) } }, |
| 138 | { "createTexture" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUDevicePrototypeFunctionCreateTexture), (intptr_t) (1) } }, |
| 139 | { "createSampler" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUDevicePrototypeFunctionCreateSampler), (intptr_t) (1) } }, |
| 140 | { "createBindGroupLayout" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUDevicePrototypeFunctionCreateBindGroupLayout), (intptr_t) (1) } }, |
| 141 | { "createPipelineLayout" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUDevicePrototypeFunctionCreatePipelineLayout), (intptr_t) (1) } }, |
| 142 | { "createBindGroup" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUDevicePrototypeFunctionCreateBindGroup), (intptr_t) (1) } }, |
| 143 | { "createShaderModule" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUDevicePrototypeFunctionCreateShaderModule), (intptr_t) (1) } }, |
| 144 | { "createRenderPipeline" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUDevicePrototypeFunctionCreateRenderPipeline), (intptr_t) (1) } }, |
| 145 | { "createComputePipeline" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUDevicePrototypeFunctionCreateComputePipeline), (intptr_t) (1) } }, |
| 146 | { "createCommandEncoder" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUDevicePrototypeFunctionCreateCommandEncoder), (intptr_t) (0) } }, |
| 147 | { "getQueue" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUDevicePrototypeFunctionGetQueue), (intptr_t) (0) } }, |
| 148 | }; |
| 149 | |
| 150 | const ClassInfo JSWebGPUDevicePrototype::s_info = { "GPUDevicePrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUDevicePrototype) }; |
| 151 | |
| 152 | void JSWebGPUDevicePrototype::finishCreation(VM& vm) |
| 153 | { |
| 154 | Base::finishCreation(vm); |
| 155 | reifyStaticProperties(vm, JSWebGPUDevice::info(), JSWebGPUDevicePrototypeTableValues, *this); |
| 156 | } |
| 157 | |
| 158 | const ClassInfo JSWebGPUDevice::s_info = { "GPUDevice" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUDevice) }; |
| 159 | |
| 160 | JSWebGPUDevice::JSWebGPUDevice(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WebGPUDevice>&& impl) |
| 161 | : JSDOMWrapper<WebGPUDevice>(structure, globalObject, WTFMove(impl)) |
| 162 | { |
| 163 | } |
| 164 | |
| 165 | void JSWebGPUDevice::finishCreation(VM& vm) |
| 166 | { |
| 167 | Base::finishCreation(vm); |
| 168 | ASSERT(inherits(vm, info())); |
| 169 | |
| 170 | } |
| 171 | |
| 172 | JSObject* JSWebGPUDevice::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 173 | { |
| 174 | return JSWebGPUDevicePrototype::create(vm, &globalObject, JSWebGPUDevicePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 175 | } |
| 176 | |
| 177 | JSObject* JSWebGPUDevice::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 178 | { |
| 179 | return getDOMPrototype<JSWebGPUDevice>(vm, globalObject); |
| 180 | } |
| 181 | |
| 182 | JSValue JSWebGPUDevice::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 183 | { |
| 184 | return getDOMConstructor<JSWebGPUDeviceConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 185 | } |
| 186 | |
| 187 | void JSWebGPUDevice::destroy(JSC::JSCell* cell) |
| 188 | { |
| 189 | JSWebGPUDevice* thisObject = static_cast<JSWebGPUDevice*>(cell); |
| 190 | thisObject->JSWebGPUDevice::~JSWebGPUDevice(); |
| 191 | } |
| 192 | |
| 193 | template<> inline JSWebGPUDevice* IDLAttribute<JSWebGPUDevice>::cast(ExecState& state, EncodedJSValue thisValue) |
| 194 | { |
| 195 | return jsDynamicCast<JSWebGPUDevice*>(state.vm(), JSValue::decode(thisValue)); |
| 196 | } |
| 197 | |
| 198 | template<> inline JSWebGPUDevice* IDLOperation<JSWebGPUDevice>::cast(ExecState& state) |
| 199 | { |
| 200 | return jsDynamicCast<JSWebGPUDevice*>(state.vm(), state.thisValue()); |
| 201 | } |
| 202 | |
| 203 | EncodedJSValue jsWebGPUDeviceConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 204 | { |
| 205 | VM& vm = state->vm(); |
| 206 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 207 | auto* prototype = jsDynamicCast<JSWebGPUDevicePrototype*>(vm, JSValue::decode(thisValue)); |
| 208 | if (UNLIKELY(!prototype)) |
| 209 | return throwVMTypeError(state, throwScope); |
| 210 | return JSValue::encode(JSWebGPUDevice::getConstructor(state->vm(), prototype->globalObject())); |
| 211 | } |
| 212 | |
| 213 | bool setJSWebGPUDeviceConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 214 | { |
| 215 | VM& vm = state->vm(); |
| 216 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 217 | auto* prototype = jsDynamicCast<JSWebGPUDevicePrototype*>(vm, JSValue::decode(thisValue)); |
| 218 | if (UNLIKELY(!prototype)) { |
| 219 | throwVMTypeError(state, throwScope); |
| 220 | return false; |
| 221 | } |
| 222 | // Shadowing a built-in constructor |
| 223 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 224 | } |
| 225 | |
| 226 | static inline JSValue jsWebGPUDeviceAdapterGetter(ExecState& state, JSWebGPUDevice& thisObject, ThrowScope& throwScope) |
| 227 | { |
| 228 | UNUSED_PARAM(throwScope); |
| 229 | UNUSED_PARAM(state); |
| 230 | auto& impl = thisObject.wrapped(); |
| 231 | JSValue result = toJS<IDLInterface<WebGPUAdapter>>(state, *thisObject.globalObject(), throwScope, impl.adapter()); |
| 232 | return result; |
| 233 | } |
| 234 | |
| 235 | EncodedJSValue jsWebGPUDeviceAdapter(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 236 | { |
| 237 | return IDLAttribute<JSWebGPUDevice>::get<jsWebGPUDeviceAdapterGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "adapter" ); |
| 238 | } |
| 239 | |
| 240 | static inline JSC::EncodedJSValue jsWebGPUDevicePrototypeFunctionCreateBufferBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUDevice>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 241 | { |
| 242 | UNUSED_PARAM(state); |
| 243 | UNUSED_PARAM(throwScope); |
| 244 | auto& impl = castedThis->wrapped(); |
| 245 | if (UNLIKELY(state->argumentCount() < 1)) |
| 246 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 247 | auto descriptor = convert<IDLDictionary<GPUBufferDescriptor>>(*state, state->uncheckedArgument(0)); |
| 248 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 249 | return JSValue::encode(toJS<IDLInterface<WebGPUBuffer>>(*state, *castedThis->globalObject(), impl.createBuffer(WTFMove(descriptor)))); |
| 250 | } |
| 251 | |
| 252 | EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreateBuffer(ExecState* state) |
| 253 | { |
| 254 | return IDLOperation<JSWebGPUDevice>::call<jsWebGPUDevicePrototypeFunctionCreateBufferBody>(*state, "createBuffer" ); |
| 255 | } |
| 256 | |
| 257 | static inline JSC::EncodedJSValue jsWebGPUDevicePrototypeFunctionCreateTextureBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUDevice>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 258 | { |
| 259 | UNUSED_PARAM(state); |
| 260 | UNUSED_PARAM(throwScope); |
| 261 | auto& impl = castedThis->wrapped(); |
| 262 | if (UNLIKELY(state->argumentCount() < 1)) |
| 263 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 264 | auto descriptor = convert<IDLDictionary<GPUTextureDescriptor>>(*state, state->uncheckedArgument(0)); |
| 265 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 266 | return JSValue::encode(toJS<IDLInterface<WebGPUTexture>>(*state, *castedThis->globalObject(), impl.createTexture(WTFMove(descriptor)))); |
| 267 | } |
| 268 | |
| 269 | EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreateTexture(ExecState* state) |
| 270 | { |
| 271 | return IDLOperation<JSWebGPUDevice>::call<jsWebGPUDevicePrototypeFunctionCreateTextureBody>(*state, "createTexture" ); |
| 272 | } |
| 273 | |
| 274 | static inline JSC::EncodedJSValue jsWebGPUDevicePrototypeFunctionCreateSamplerBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUDevice>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 275 | { |
| 276 | UNUSED_PARAM(state); |
| 277 | UNUSED_PARAM(throwScope); |
| 278 | auto& impl = castedThis->wrapped(); |
| 279 | if (UNLIKELY(state->argumentCount() < 1)) |
| 280 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 281 | auto descriptor = convert<IDLDictionary<GPUSamplerDescriptor>>(*state, state->uncheckedArgument(0)); |
| 282 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 283 | return JSValue::encode(toJS<IDLInterface<WebGPUSampler>>(*state, *castedThis->globalObject(), impl.createSampler(WTFMove(descriptor)))); |
| 284 | } |
| 285 | |
| 286 | EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreateSampler(ExecState* state) |
| 287 | { |
| 288 | return IDLOperation<JSWebGPUDevice>::call<jsWebGPUDevicePrototypeFunctionCreateSamplerBody>(*state, "createSampler" ); |
| 289 | } |
| 290 | |
| 291 | static inline JSC::EncodedJSValue jsWebGPUDevicePrototypeFunctionCreateBindGroupLayoutBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUDevice>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 292 | { |
| 293 | UNUSED_PARAM(state); |
| 294 | UNUSED_PARAM(throwScope); |
| 295 | auto& impl = castedThis->wrapped(); |
| 296 | if (UNLIKELY(state->argumentCount() < 1)) |
| 297 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 298 | auto descriptor = convert<IDLDictionary<GPUBindGroupLayoutDescriptor>>(*state, state->uncheckedArgument(0)); |
| 299 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 300 | return JSValue::encode(toJS<IDLInterface<WebGPUBindGroupLayout>>(*state, *castedThis->globalObject(), impl.createBindGroupLayout(WTFMove(descriptor)))); |
| 301 | } |
| 302 | |
| 303 | EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreateBindGroupLayout(ExecState* state) |
| 304 | { |
| 305 | return IDLOperation<JSWebGPUDevice>::call<jsWebGPUDevicePrototypeFunctionCreateBindGroupLayoutBody>(*state, "createBindGroupLayout" ); |
| 306 | } |
| 307 | |
| 308 | static inline JSC::EncodedJSValue jsWebGPUDevicePrototypeFunctionCreatePipelineLayoutBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUDevice>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 309 | { |
| 310 | UNUSED_PARAM(state); |
| 311 | UNUSED_PARAM(throwScope); |
| 312 | auto& impl = castedThis->wrapped(); |
| 313 | if (UNLIKELY(state->argumentCount() < 1)) |
| 314 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 315 | auto descriptor = convert<IDLDictionary<WebGPUPipelineLayoutDescriptor>>(*state, state->uncheckedArgument(0)); |
| 316 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 317 | return JSValue::encode(toJS<IDLInterface<WebGPUPipelineLayout>>(*state, *castedThis->globalObject(), impl.createPipelineLayout(WTFMove(descriptor)))); |
| 318 | } |
| 319 | |
| 320 | EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreatePipelineLayout(ExecState* state) |
| 321 | { |
| 322 | return IDLOperation<JSWebGPUDevice>::call<jsWebGPUDevicePrototypeFunctionCreatePipelineLayoutBody>(*state, "createPipelineLayout" ); |
| 323 | } |
| 324 | |
| 325 | static inline JSC::EncodedJSValue jsWebGPUDevicePrototypeFunctionCreateBindGroupBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUDevice>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 326 | { |
| 327 | UNUSED_PARAM(state); |
| 328 | UNUSED_PARAM(throwScope); |
| 329 | auto& impl = castedThis->wrapped(); |
| 330 | if (UNLIKELY(state->argumentCount() < 1)) |
| 331 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 332 | auto descriptor = convert<IDLDictionary<WebGPUBindGroupDescriptor>>(*state, state->uncheckedArgument(0)); |
| 333 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 334 | return JSValue::encode(toJS<IDLInterface<WebGPUBindGroup>>(*state, *castedThis->globalObject(), impl.createBindGroup(WTFMove(descriptor)))); |
| 335 | } |
| 336 | |
| 337 | EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreateBindGroup(ExecState* state) |
| 338 | { |
| 339 | return IDLOperation<JSWebGPUDevice>::call<jsWebGPUDevicePrototypeFunctionCreateBindGroupBody>(*state, "createBindGroup" ); |
| 340 | } |
| 341 | |
| 342 | static inline JSC::EncodedJSValue jsWebGPUDevicePrototypeFunctionCreateShaderModuleBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUDevice>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 343 | { |
| 344 | UNUSED_PARAM(state); |
| 345 | UNUSED_PARAM(throwScope); |
| 346 | auto& impl = castedThis->wrapped(); |
| 347 | if (UNLIKELY(state->argumentCount() < 1)) |
| 348 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 349 | auto descriptor = convert<IDLDictionary<WebGPUShaderModuleDescriptor>>(*state, state->uncheckedArgument(0)); |
| 350 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 351 | return JSValue::encode(toJS<IDLInterface<WebGPUShaderModule>>(*state, *castedThis->globalObject(), impl.createShaderModule(WTFMove(descriptor)))); |
| 352 | } |
| 353 | |
| 354 | EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreateShaderModule(ExecState* state) |
| 355 | { |
| 356 | return IDLOperation<JSWebGPUDevice>::call<jsWebGPUDevicePrototypeFunctionCreateShaderModuleBody>(*state, "createShaderModule" ); |
| 357 | } |
| 358 | |
| 359 | static inline JSC::EncodedJSValue jsWebGPUDevicePrototypeFunctionCreateRenderPipelineBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUDevice>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 360 | { |
| 361 | UNUSED_PARAM(state); |
| 362 | UNUSED_PARAM(throwScope); |
| 363 | auto& impl = castedThis->wrapped(); |
| 364 | if (UNLIKELY(state->argumentCount() < 1)) |
| 365 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 366 | auto descriptor = convert<IDLDictionary<WebGPURenderPipelineDescriptor>>(*state, state->uncheckedArgument(0)); |
| 367 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 368 | return JSValue::encode(toJS<IDLInterface<WebGPURenderPipeline>>(*state, *castedThis->globalObject(), impl.createRenderPipeline(WTFMove(descriptor)))); |
| 369 | } |
| 370 | |
| 371 | EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreateRenderPipeline(ExecState* state) |
| 372 | { |
| 373 | return IDLOperation<JSWebGPUDevice>::call<jsWebGPUDevicePrototypeFunctionCreateRenderPipelineBody>(*state, "createRenderPipeline" ); |
| 374 | } |
| 375 | |
| 376 | static inline JSC::EncodedJSValue jsWebGPUDevicePrototypeFunctionCreateComputePipelineBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUDevice>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 377 | { |
| 378 | UNUSED_PARAM(state); |
| 379 | UNUSED_PARAM(throwScope); |
| 380 | auto& impl = castedThis->wrapped(); |
| 381 | if (UNLIKELY(state->argumentCount() < 1)) |
| 382 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 383 | auto descriptor = convert<IDLDictionary<WebGPUComputePipelineDescriptor>>(*state, state->uncheckedArgument(0)); |
| 384 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 385 | return JSValue::encode(toJS<IDLInterface<WebGPUComputePipeline>>(*state, *castedThis->globalObject(), impl.createComputePipeline(WTFMove(descriptor)))); |
| 386 | } |
| 387 | |
| 388 | EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreateComputePipeline(ExecState* state) |
| 389 | { |
| 390 | return IDLOperation<JSWebGPUDevice>::call<jsWebGPUDevicePrototypeFunctionCreateComputePipelineBody>(*state, "createComputePipeline" ); |
| 391 | } |
| 392 | |
| 393 | static inline JSC::EncodedJSValue jsWebGPUDevicePrototypeFunctionCreateCommandEncoderBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUDevice>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 394 | { |
| 395 | UNUSED_PARAM(state); |
| 396 | UNUSED_PARAM(throwScope); |
| 397 | auto& impl = castedThis->wrapped(); |
| 398 | return JSValue::encode(toJS<IDLInterface<WebGPUCommandEncoder>>(*state, *castedThis->globalObject(), impl.createCommandEncoder())); |
| 399 | } |
| 400 | |
| 401 | EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionCreateCommandEncoder(ExecState* state) |
| 402 | { |
| 403 | return IDLOperation<JSWebGPUDevice>::call<jsWebGPUDevicePrototypeFunctionCreateCommandEncoderBody>(*state, "createCommandEncoder" ); |
| 404 | } |
| 405 | |
| 406 | static inline JSC::EncodedJSValue jsWebGPUDevicePrototypeFunctionGetQueueBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUDevice>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 407 | { |
| 408 | UNUSED_PARAM(state); |
| 409 | UNUSED_PARAM(throwScope); |
| 410 | auto& impl = castedThis->wrapped(); |
| 411 | return JSValue::encode(toJS<IDLInterface<WebGPUQueue>>(*state, *castedThis->globalObject(), impl.getQueue())); |
| 412 | } |
| 413 | |
| 414 | EncodedJSValue JSC_HOST_CALL jsWebGPUDevicePrototypeFunctionGetQueue(ExecState* state) |
| 415 | { |
| 416 | return IDLOperation<JSWebGPUDevice>::call<jsWebGPUDevicePrototypeFunctionGetQueueBody>(*state, "getQueue" ); |
| 417 | } |
| 418 | |
| 419 | void JSWebGPUDevice::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 420 | { |
| 421 | auto* thisObject = jsCast<JSWebGPUDevice*>(cell); |
| 422 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 423 | if (thisObject->scriptExecutionContext()) |
| 424 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 425 | Base::heapSnapshot(cell, builder); |
| 426 | } |
| 427 | |
| 428 | bool JSWebGPUDeviceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 429 | { |
| 430 | UNUSED_PARAM(handle); |
| 431 | UNUSED_PARAM(visitor); |
| 432 | UNUSED_PARAM(reason); |
| 433 | return false; |
| 434 | } |
| 435 | |
| 436 | void JSWebGPUDeviceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 437 | { |
| 438 | auto* jsWebGPUDevice = static_cast<JSWebGPUDevice*>(handle.slot()->asCell()); |
| 439 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 440 | uncacheWrapper(world, &jsWebGPUDevice->wrapped(), jsWebGPUDevice); |
| 441 | } |
| 442 | |
| 443 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<WebGPUDevice>&& impl) |
| 444 | { |
| 445 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
| 446 | // attribute. You should remove that attribute. If the class has subclasses |
| 447 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
| 448 | // attribute to WebGPUDevice. |
| 449 | static_assert(!std::is_polymorphic<WebGPUDevice>::value, "WebGPUDevice is polymorphic but the IDL claims it is not" ); |
| 450 | return createWrapper<WebGPUDevice>(globalObject, WTFMove(impl)); |
| 451 | } |
| 452 | |
| 453 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, WebGPUDevice& impl) |
| 454 | { |
| 455 | return wrap(state, globalObject, impl); |
| 456 | } |
| 457 | |
| 458 | WebGPUDevice* JSWebGPUDevice::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 459 | { |
| 460 | if (auto* wrapper = jsDynamicCast<JSWebGPUDevice*>(vm, value)) |
| 461 | return &wrapper->wrapped(); |
| 462 | return nullptr; |
| 463 | } |
| 464 | |
| 465 | } |
| 466 | |
| 467 | #endif // ENABLE(WEBGPU) |
| 468 | |