| 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 "JSWebGPUComputePassEncoder.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 "JSWebGPUComputePipeline.h" |
| 35 | #include "ScriptExecutionContext.h" |
| 36 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 37 | #include <JavaScriptCore/JSCInlines.h> |
| 38 | #include <wtf/GetPtr.h> |
| 39 | #include <wtf/PointerPreparations.h> |
| 40 | #include <wtf/URL.h> |
| 41 | |
| 42 | |
| 43 | namespace WebCore { |
| 44 | using namespace JSC; |
| 45 | |
| 46 | // Functions |
| 47 | |
| 48 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUComputePassEncoderPrototypeFunctionSetPipeline(JSC::ExecState*); |
| 49 | JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUComputePassEncoderPrototypeFunctionDispatch(JSC::ExecState*); |
| 50 | |
| 51 | // Attributes |
| 52 | |
| 53 | JSC::EncodedJSValue jsWebGPUComputePassEncoderConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 54 | bool setJSWebGPUComputePassEncoderConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 55 | |
| 56 | class JSWebGPUComputePassEncoderPrototype : public JSC::JSNonFinalObject { |
| 57 | public: |
| 58 | using Base = JSC::JSNonFinalObject; |
| 59 | static JSWebGPUComputePassEncoderPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 60 | { |
| 61 | JSWebGPUComputePassEncoderPrototype* ptr = new (NotNull, JSC::allocateCell<JSWebGPUComputePassEncoderPrototype>(vm.heap)) JSWebGPUComputePassEncoderPrototype(vm, globalObject, structure); |
| 62 | ptr->finishCreation(vm); |
| 63 | return ptr; |
| 64 | } |
| 65 | |
| 66 | DECLARE_INFO; |
| 67 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 68 | { |
| 69 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 70 | } |
| 71 | |
| 72 | private: |
| 73 | JSWebGPUComputePassEncoderPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 74 | : JSC::JSNonFinalObject(vm, structure) |
| 75 | { |
| 76 | } |
| 77 | |
| 78 | void finishCreation(JSC::VM&); |
| 79 | }; |
| 80 | |
| 81 | using JSWebGPUComputePassEncoderConstructor = JSDOMConstructorNotConstructable<JSWebGPUComputePassEncoder>; |
| 82 | |
| 83 | template<> JSValue JSWebGPUComputePassEncoderConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 84 | { |
| 85 | return JSWebGPUProgrammablePassEncoder::getConstructor(vm, &globalObject); |
| 86 | } |
| 87 | |
| 88 | template<> void JSWebGPUComputePassEncoderConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 89 | { |
| 90 | putDirect(vm, vm.propertyNames->prototype, JSWebGPUComputePassEncoder::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 91 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("GPUComputePassEncoder"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 92 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 93 | } |
| 94 | |
| 95 | template<> const ClassInfo JSWebGPUComputePassEncoderConstructor::s_info = { "GPUComputePassEncoder" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUComputePassEncoderConstructor) }; |
| 96 | |
| 97 | /* Hash table for prototype */ |
| 98 | |
| 99 | static const HashTableValue JSWebGPUComputePassEncoderPrototypeTableValues[] = |
| 100 | { |
| 101 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebGPUComputePassEncoderConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWebGPUComputePassEncoderConstructor) } }, |
| 102 | { "setPipeline" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUComputePassEncoderPrototypeFunctionSetPipeline), (intptr_t) (1) } }, |
| 103 | { "dispatch" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUComputePassEncoderPrototypeFunctionDispatch), (intptr_t) (3) } }, |
| 104 | }; |
| 105 | |
| 106 | const ClassInfo JSWebGPUComputePassEncoderPrototype::s_info = { "GPUComputePassEncoderPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUComputePassEncoderPrototype) }; |
| 107 | |
| 108 | void JSWebGPUComputePassEncoderPrototype::finishCreation(VM& vm) |
| 109 | { |
| 110 | Base::finishCreation(vm); |
| 111 | reifyStaticProperties(vm, JSWebGPUComputePassEncoder::info(), JSWebGPUComputePassEncoderPrototypeTableValues, *this); |
| 112 | } |
| 113 | |
| 114 | const ClassInfo JSWebGPUComputePassEncoder::s_info = { "GPUComputePassEncoder" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUComputePassEncoder) }; |
| 115 | |
| 116 | JSWebGPUComputePassEncoder::JSWebGPUComputePassEncoder(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WebGPUComputePassEncoder>&& impl) |
| 117 | : JSWebGPUProgrammablePassEncoder(structure, globalObject, WTFMove(impl)) |
| 118 | { |
| 119 | } |
| 120 | |
| 121 | void JSWebGPUComputePassEncoder::finishCreation(VM& vm) |
| 122 | { |
| 123 | Base::finishCreation(vm); |
| 124 | ASSERT(inherits(vm, info())); |
| 125 | |
| 126 | } |
| 127 | |
| 128 | JSObject* JSWebGPUComputePassEncoder::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 129 | { |
| 130 | return JSWebGPUComputePassEncoderPrototype::create(vm, &globalObject, JSWebGPUComputePassEncoderPrototype::createStructure(vm, &globalObject, JSWebGPUProgrammablePassEncoder::prototype(vm, globalObject))); |
| 131 | } |
| 132 | |
| 133 | JSObject* JSWebGPUComputePassEncoder::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 134 | { |
| 135 | return getDOMPrototype<JSWebGPUComputePassEncoder>(vm, globalObject); |
| 136 | } |
| 137 | |
| 138 | JSValue JSWebGPUComputePassEncoder::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 139 | { |
| 140 | return getDOMConstructor<JSWebGPUComputePassEncoderConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 141 | } |
| 142 | |
| 143 | template<> inline JSWebGPUComputePassEncoder* IDLOperation<JSWebGPUComputePassEncoder>::cast(ExecState& state) |
| 144 | { |
| 145 | return jsDynamicCast<JSWebGPUComputePassEncoder*>(state.vm(), state.thisValue()); |
| 146 | } |
| 147 | |
| 148 | EncodedJSValue jsWebGPUComputePassEncoderConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 149 | { |
| 150 | VM& vm = state->vm(); |
| 151 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 152 | auto* prototype = jsDynamicCast<JSWebGPUComputePassEncoderPrototype*>(vm, JSValue::decode(thisValue)); |
| 153 | if (UNLIKELY(!prototype)) |
| 154 | return throwVMTypeError(state, throwScope); |
| 155 | return JSValue::encode(JSWebGPUComputePassEncoder::getConstructor(state->vm(), prototype->globalObject())); |
| 156 | } |
| 157 | |
| 158 | bool setJSWebGPUComputePassEncoderConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 159 | { |
| 160 | VM& vm = state->vm(); |
| 161 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 162 | auto* prototype = jsDynamicCast<JSWebGPUComputePassEncoderPrototype*>(vm, JSValue::decode(thisValue)); |
| 163 | if (UNLIKELY(!prototype)) { |
| 164 | throwVMTypeError(state, throwScope); |
| 165 | return false; |
| 166 | } |
| 167 | // Shadowing a built-in constructor |
| 168 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 169 | } |
| 170 | |
| 171 | static inline JSC::EncodedJSValue jsWebGPUComputePassEncoderPrototypeFunctionSetPipelineBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUComputePassEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 172 | { |
| 173 | UNUSED_PARAM(state); |
| 174 | UNUSED_PARAM(throwScope); |
| 175 | auto& impl = castedThis->wrapped(); |
| 176 | if (UNLIKELY(state->argumentCount() < 1)) |
| 177 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 178 | auto pipeline = convert<IDLInterface<WebGPUComputePipeline>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "pipeline" , "GPUComputePassEncoder" , "setPipeline" , "WebGPUComputePipeline" ); }); |
| 179 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 180 | impl.setPipeline(*pipeline); |
| 181 | return JSValue::encode(jsUndefined()); |
| 182 | } |
| 183 | |
| 184 | EncodedJSValue JSC_HOST_CALL jsWebGPUComputePassEncoderPrototypeFunctionSetPipeline(ExecState* state) |
| 185 | { |
| 186 | return IDLOperation<JSWebGPUComputePassEncoder>::call<jsWebGPUComputePassEncoderPrototypeFunctionSetPipelineBody>(*state, "setPipeline" ); |
| 187 | } |
| 188 | |
| 189 | static inline JSC::EncodedJSValue jsWebGPUComputePassEncoderPrototypeFunctionDispatchBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUComputePassEncoder>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 190 | { |
| 191 | UNUSED_PARAM(state); |
| 192 | UNUSED_PARAM(throwScope); |
| 193 | auto& impl = castedThis->wrapped(); |
| 194 | if (UNLIKELY(state->argumentCount() < 3)) |
| 195 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 196 | auto x = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
| 197 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 198 | auto y = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(1)); |
| 199 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 200 | auto z = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(2)); |
| 201 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 202 | impl.dispatch(WTFMove(x), WTFMove(y), WTFMove(z)); |
| 203 | return JSValue::encode(jsUndefined()); |
| 204 | } |
| 205 | |
| 206 | EncodedJSValue JSC_HOST_CALL jsWebGPUComputePassEncoderPrototypeFunctionDispatch(ExecState* state) |
| 207 | { |
| 208 | return IDLOperation<JSWebGPUComputePassEncoder>::call<jsWebGPUComputePassEncoderPrototypeFunctionDispatchBody>(*state, "dispatch" ); |
| 209 | } |
| 210 | |
| 211 | void JSWebGPUComputePassEncoder::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 212 | { |
| 213 | auto* thisObject = jsCast<JSWebGPUComputePassEncoder*>(cell); |
| 214 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 215 | if (thisObject->scriptExecutionContext()) |
| 216 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 217 | Base::heapSnapshot(cell, builder); |
| 218 | } |
| 219 | |
| 220 | #if ENABLE(BINDING_INTEGRITY) |
| 221 | #if PLATFORM(WIN) |
| 222 | #pragma warning(disable: 4483) |
| 223 | extern "C" { extern void (*const __identifier("??_7WebGPUComputePassEncoder@WebCore@@6B@" )[])(); } |
| 224 | #else |
| 225 | extern "C" { extern void* _ZTVN7WebCore24WebGPUComputePassEncoderE[]; } |
| 226 | #endif |
| 227 | #endif |
| 228 | |
| 229 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<WebGPUComputePassEncoder>&& impl) |
| 230 | { |
| 231 | |
| 232 | #if ENABLE(BINDING_INTEGRITY) |
| 233 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 234 | #if PLATFORM(WIN) |
| 235 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7WebGPUComputePassEncoder@WebCore@@6B@" )); |
| 236 | #else |
| 237 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore24WebGPUComputePassEncoderE[2]); |
| 238 | #endif |
| 239 | |
| 240 | // If this fails WebGPUComputePassEncoder does not have a vtable, so you need to add the |
| 241 | // ImplementationLacksVTable attribute to the interface definition |
| 242 | static_assert(std::is_polymorphic<WebGPUComputePassEncoder>::value, "WebGPUComputePassEncoder is not polymorphic" ); |
| 243 | |
| 244 | // If you hit this assertion you either have a use after free bug, or |
| 245 | // WebGPUComputePassEncoder has subclasses. If WebGPUComputePassEncoder has subclasses that get passed |
| 246 | // to toJS() we currently require WebGPUComputePassEncoder you to opt out of binding hardening |
| 247 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 248 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 249 | #endif |
| 250 | return createWrapper<WebGPUComputePassEncoder>(globalObject, WTFMove(impl)); |
| 251 | } |
| 252 | |
| 253 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, WebGPUComputePassEncoder& impl) |
| 254 | { |
| 255 | return wrap(state, globalObject, impl); |
| 256 | } |
| 257 | |
| 258 | |
| 259 | } |
| 260 | |
| 261 | #endif // ENABLE(WEBGPU) |
| 262 | |