| 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 "JSWebGPUBindGroupLayout.h" |
| 26 | |
| 27 | #include "JSDOMBinding.h" |
| 28 | #include "JSDOMConstructorNotConstructable.h" |
| 29 | #include "JSDOMExceptionHandling.h" |
| 30 | #include "JSDOMWrapperCache.h" |
| 31 | #include "ScriptExecutionContext.h" |
| 32 | #include <JavaScriptCore/FunctionPrototype.h> |
| 33 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 34 | #include <JavaScriptCore/JSCInlines.h> |
| 35 | #include <wtf/GetPtr.h> |
| 36 | #include <wtf/PointerPreparations.h> |
| 37 | #include <wtf/URL.h> |
| 38 | |
| 39 | |
| 40 | namespace WebCore { |
| 41 | using namespace JSC; |
| 42 | |
| 43 | // Attributes |
| 44 | |
| 45 | JSC::EncodedJSValue jsWebGPUBindGroupLayoutConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 46 | bool setJSWebGPUBindGroupLayoutConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 47 | |
| 48 | class JSWebGPUBindGroupLayoutPrototype : public JSC::JSNonFinalObject { |
| 49 | public: |
| 50 | using Base = JSC::JSNonFinalObject; |
| 51 | static JSWebGPUBindGroupLayoutPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 52 | { |
| 53 | JSWebGPUBindGroupLayoutPrototype* ptr = new (NotNull, JSC::allocateCell<JSWebGPUBindGroupLayoutPrototype>(vm.heap)) JSWebGPUBindGroupLayoutPrototype(vm, globalObject, structure); |
| 54 | ptr->finishCreation(vm); |
| 55 | return ptr; |
| 56 | } |
| 57 | |
| 58 | DECLARE_INFO; |
| 59 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 60 | { |
| 61 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 62 | } |
| 63 | |
| 64 | private: |
| 65 | JSWebGPUBindGroupLayoutPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 66 | : JSC::JSNonFinalObject(vm, structure) |
| 67 | { |
| 68 | } |
| 69 | |
| 70 | void finishCreation(JSC::VM&); |
| 71 | }; |
| 72 | |
| 73 | using JSWebGPUBindGroupLayoutConstructor = JSDOMConstructorNotConstructable<JSWebGPUBindGroupLayout>; |
| 74 | |
| 75 | template<> JSValue JSWebGPUBindGroupLayoutConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 76 | { |
| 77 | UNUSED_PARAM(vm); |
| 78 | return globalObject.functionPrototype(); |
| 79 | } |
| 80 | |
| 81 | template<> void JSWebGPUBindGroupLayoutConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 82 | { |
| 83 | putDirect(vm, vm.propertyNames->prototype, JSWebGPUBindGroupLayout::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 84 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("GPUBindGroupLayout"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 85 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 86 | } |
| 87 | |
| 88 | template<> const ClassInfo JSWebGPUBindGroupLayoutConstructor::s_info = { "GPUBindGroupLayout" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUBindGroupLayoutConstructor) }; |
| 89 | |
| 90 | /* Hash table for prototype */ |
| 91 | |
| 92 | static const HashTableValue JSWebGPUBindGroupLayoutPrototypeTableValues[] = |
| 93 | { |
| 94 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebGPUBindGroupLayoutConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWebGPUBindGroupLayoutConstructor) } }, |
| 95 | }; |
| 96 | |
| 97 | const ClassInfo JSWebGPUBindGroupLayoutPrototype::s_info = { "GPUBindGroupLayoutPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUBindGroupLayoutPrototype) }; |
| 98 | |
| 99 | void JSWebGPUBindGroupLayoutPrototype::finishCreation(VM& vm) |
| 100 | { |
| 101 | Base::finishCreation(vm); |
| 102 | reifyStaticProperties(vm, JSWebGPUBindGroupLayout::info(), JSWebGPUBindGroupLayoutPrototypeTableValues, *this); |
| 103 | } |
| 104 | |
| 105 | const ClassInfo JSWebGPUBindGroupLayout::s_info = { "GPUBindGroupLayout" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUBindGroupLayout) }; |
| 106 | |
| 107 | JSWebGPUBindGroupLayout::JSWebGPUBindGroupLayout(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WebGPUBindGroupLayout>&& impl) |
| 108 | : JSDOMWrapper<WebGPUBindGroupLayout>(structure, globalObject, WTFMove(impl)) |
| 109 | { |
| 110 | } |
| 111 | |
| 112 | void JSWebGPUBindGroupLayout::finishCreation(VM& vm) |
| 113 | { |
| 114 | Base::finishCreation(vm); |
| 115 | ASSERT(inherits(vm, info())); |
| 116 | |
| 117 | } |
| 118 | |
| 119 | JSObject* JSWebGPUBindGroupLayout::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 120 | { |
| 121 | return JSWebGPUBindGroupLayoutPrototype::create(vm, &globalObject, JSWebGPUBindGroupLayoutPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 122 | } |
| 123 | |
| 124 | JSObject* JSWebGPUBindGroupLayout::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 125 | { |
| 126 | return getDOMPrototype<JSWebGPUBindGroupLayout>(vm, globalObject); |
| 127 | } |
| 128 | |
| 129 | JSValue JSWebGPUBindGroupLayout::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 130 | { |
| 131 | return getDOMConstructor<JSWebGPUBindGroupLayoutConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 132 | } |
| 133 | |
| 134 | void JSWebGPUBindGroupLayout::destroy(JSC::JSCell* cell) |
| 135 | { |
| 136 | JSWebGPUBindGroupLayout* thisObject = static_cast<JSWebGPUBindGroupLayout*>(cell); |
| 137 | thisObject->JSWebGPUBindGroupLayout::~JSWebGPUBindGroupLayout(); |
| 138 | } |
| 139 | |
| 140 | EncodedJSValue jsWebGPUBindGroupLayoutConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 141 | { |
| 142 | VM& vm = state->vm(); |
| 143 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 144 | auto* prototype = jsDynamicCast<JSWebGPUBindGroupLayoutPrototype*>(vm, JSValue::decode(thisValue)); |
| 145 | if (UNLIKELY(!prototype)) |
| 146 | return throwVMTypeError(state, throwScope); |
| 147 | return JSValue::encode(JSWebGPUBindGroupLayout::getConstructor(state->vm(), prototype->globalObject())); |
| 148 | } |
| 149 | |
| 150 | bool setJSWebGPUBindGroupLayoutConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 151 | { |
| 152 | VM& vm = state->vm(); |
| 153 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 154 | auto* prototype = jsDynamicCast<JSWebGPUBindGroupLayoutPrototype*>(vm, JSValue::decode(thisValue)); |
| 155 | if (UNLIKELY(!prototype)) { |
| 156 | throwVMTypeError(state, throwScope); |
| 157 | return false; |
| 158 | } |
| 159 | // Shadowing a built-in constructor |
| 160 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 161 | } |
| 162 | |
| 163 | void JSWebGPUBindGroupLayout::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 164 | { |
| 165 | auto* thisObject = jsCast<JSWebGPUBindGroupLayout*>(cell); |
| 166 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 167 | if (thisObject->scriptExecutionContext()) |
| 168 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 169 | Base::heapSnapshot(cell, builder); |
| 170 | } |
| 171 | |
| 172 | bool JSWebGPUBindGroupLayoutOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 173 | { |
| 174 | UNUSED_PARAM(handle); |
| 175 | UNUSED_PARAM(visitor); |
| 176 | UNUSED_PARAM(reason); |
| 177 | return false; |
| 178 | } |
| 179 | |
| 180 | void JSWebGPUBindGroupLayoutOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 181 | { |
| 182 | auto* jsWebGPUBindGroupLayout = static_cast<JSWebGPUBindGroupLayout*>(handle.slot()->asCell()); |
| 183 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 184 | uncacheWrapper(world, &jsWebGPUBindGroupLayout->wrapped(), jsWebGPUBindGroupLayout); |
| 185 | } |
| 186 | |
| 187 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<WebGPUBindGroupLayout>&& impl) |
| 188 | { |
| 189 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
| 190 | // attribute. You should remove that attribute. If the class has subclasses |
| 191 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
| 192 | // attribute to WebGPUBindGroupLayout. |
| 193 | static_assert(!std::is_polymorphic<WebGPUBindGroupLayout>::value, "WebGPUBindGroupLayout is polymorphic but the IDL claims it is not" ); |
| 194 | return createWrapper<WebGPUBindGroupLayout>(globalObject, WTFMove(impl)); |
| 195 | } |
| 196 | |
| 197 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, WebGPUBindGroupLayout& impl) |
| 198 | { |
| 199 | return wrap(state, globalObject, impl); |
| 200 | } |
| 201 | |
| 202 | WebGPUBindGroupLayout* JSWebGPUBindGroupLayout::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 203 | { |
| 204 | if (auto* wrapper = jsDynamicCast<JSWebGPUBindGroupLayout*>(vm, value)) |
| 205 | return &wrapper->wrapped(); |
| 206 | return nullptr; |
| 207 | } |
| 208 | |
| 209 | } |
| 210 | |
| 211 | #endif // ENABLE(WEBGPU) |
| 212 | |