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 "JSGPUBufferUsage.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
40namespace WebCore {
41using namespace JSC;
42
43// Attributes
44
45JSC::EncodedJSValue jsGPUBufferUsageConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
46bool setJSGPUBufferUsageConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
47
48class JSGPUBufferUsagePrototype : public JSC::JSNonFinalObject {
49public:
50 using Base = JSC::JSNonFinalObject;
51 static JSGPUBufferUsagePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
52 {
53 JSGPUBufferUsagePrototype* ptr = new (NotNull, JSC::allocateCell<JSGPUBufferUsagePrototype>(vm.heap)) JSGPUBufferUsagePrototype(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
64private:
65 JSGPUBufferUsagePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
66 : JSC::JSNonFinalObject(vm, structure)
67 {
68 }
69
70 void finishCreation(JSC::VM&);
71};
72
73using JSGPUBufferUsageConstructor = JSDOMConstructorNotConstructable<JSGPUBufferUsage>;
74
75/* Hash table for constructor */
76
77static const HashTableValue JSGPUBufferUsageConstructorTableValues[] =
78{
79 { "NONE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } },
80 { "MAP_READ", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } },
81 { "MAP_WRITE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } },
82 { "TRANSFER_SRC", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } },
83 { "TRANSFER_DST", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } },
84 { "INDEX", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(16) } },
85 { "VERTEX", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(32) } },
86 { "UNIFORM", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(64) } },
87 { "STORAGE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(128) } },
88};
89
90template<> JSValue JSGPUBufferUsageConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
91{
92 UNUSED_PARAM(vm);
93 return globalObject.functionPrototype();
94}
95
96template<> void JSGPUBufferUsageConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
97{
98 putDirect(vm, vm.propertyNames->prototype, JSGPUBufferUsage::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
99 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("GPUBufferUsage"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
100 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
101 reifyStaticProperties(vm, JSGPUBufferUsage::info(), JSGPUBufferUsageConstructorTableValues, *this);
102}
103
104template<> const ClassInfo JSGPUBufferUsageConstructor::s_info = { "GPUBufferUsage", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSGPUBufferUsageConstructor) };
105
106/* Hash table for prototype */
107
108static const HashTableValue JSGPUBufferUsagePrototypeTableValues[] =
109{
110 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsGPUBufferUsageConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSGPUBufferUsageConstructor) } },
111 { "NONE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } },
112 { "MAP_READ", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } },
113 { "MAP_WRITE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } },
114 { "TRANSFER_SRC", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } },
115 { "TRANSFER_DST", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } },
116 { "INDEX", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(16) } },
117 { "VERTEX", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(32) } },
118 { "UNIFORM", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(64) } },
119 { "STORAGE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(128) } },
120};
121
122const ClassInfo JSGPUBufferUsagePrototype::s_info = { "GPUBufferUsagePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSGPUBufferUsagePrototype) };
123
124void JSGPUBufferUsagePrototype::finishCreation(VM& vm)
125{
126 Base::finishCreation(vm);
127 reifyStaticProperties(vm, JSGPUBufferUsage::info(), JSGPUBufferUsagePrototypeTableValues, *this);
128}
129
130const ClassInfo JSGPUBufferUsage::s_info = { "GPUBufferUsage", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSGPUBufferUsage) };
131
132JSGPUBufferUsage::JSGPUBufferUsage(Structure* structure, JSDOMGlobalObject& globalObject, Ref<GPUBufferUsage>&& impl)
133 : JSDOMWrapper<GPUBufferUsage>(structure, globalObject, WTFMove(impl))
134{
135}
136
137void JSGPUBufferUsage::finishCreation(VM& vm)
138{
139 Base::finishCreation(vm);
140 ASSERT(inherits(vm, info()));
141
142}
143
144JSObject* JSGPUBufferUsage::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
145{
146 return JSGPUBufferUsagePrototype::create(vm, &globalObject, JSGPUBufferUsagePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
147}
148
149JSObject* JSGPUBufferUsage::prototype(VM& vm, JSDOMGlobalObject& globalObject)
150{
151 return getDOMPrototype<JSGPUBufferUsage>(vm, globalObject);
152}
153
154JSValue JSGPUBufferUsage::getConstructor(VM& vm, const JSGlobalObject* globalObject)
155{
156 return getDOMConstructor<JSGPUBufferUsageConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
157}
158
159void JSGPUBufferUsage::destroy(JSC::JSCell* cell)
160{
161 JSGPUBufferUsage* thisObject = static_cast<JSGPUBufferUsage*>(cell);
162 thisObject->JSGPUBufferUsage::~JSGPUBufferUsage();
163}
164
165EncodedJSValue jsGPUBufferUsageConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
166{
167 VM& vm = state->vm();
168 auto throwScope = DECLARE_THROW_SCOPE(vm);
169 auto* prototype = jsDynamicCast<JSGPUBufferUsagePrototype*>(vm, JSValue::decode(thisValue));
170 if (UNLIKELY(!prototype))
171 return throwVMTypeError(state, throwScope);
172 return JSValue::encode(JSGPUBufferUsage::getConstructor(state->vm(), prototype->globalObject()));
173}
174
175bool setJSGPUBufferUsageConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
176{
177 VM& vm = state->vm();
178 auto throwScope = DECLARE_THROW_SCOPE(vm);
179 auto* prototype = jsDynamicCast<JSGPUBufferUsagePrototype*>(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
188void JSGPUBufferUsage::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
189{
190 auto* thisObject = jsCast<JSGPUBufferUsage*>(cell);
191 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
192 if (thisObject->scriptExecutionContext())
193 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
194 Base::heapSnapshot(cell, builder);
195}
196
197bool JSGPUBufferUsageOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
198{
199 UNUSED_PARAM(handle);
200 UNUSED_PARAM(visitor);
201 UNUSED_PARAM(reason);
202 return false;
203}
204
205void JSGPUBufferUsageOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
206{
207 auto* jsGPUBufferUsage = static_cast<JSGPUBufferUsage*>(handle.slot()->asCell());
208 auto& world = *static_cast<DOMWrapperWorld*>(context);
209 uncacheWrapper(world, &jsGPUBufferUsage->wrapped(), jsGPUBufferUsage);
210}
211
212JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<GPUBufferUsage>&& impl)
213{
214 // If you hit this failure the interface definition has the ImplementationLacksVTable
215 // attribute. You should remove that attribute. If the class has subclasses
216 // that may be passed through this toJS() function you should use the SkipVTableValidation
217 // attribute to GPUBufferUsage.
218 static_assert(!std::is_polymorphic<GPUBufferUsage>::value, "GPUBufferUsage is polymorphic but the IDL claims it is not");
219 return createWrapper<GPUBufferUsage>(globalObject, WTFMove(impl));
220}
221
222JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, GPUBufferUsage& impl)
223{
224 return wrap(state, globalObject, impl);
225}
226
227GPUBufferUsage* JSGPUBufferUsage::toWrapped(JSC::VM& vm, JSC::JSValue value)
228{
229 if (auto* wrapper = jsDynamicCast<JSGPUBufferUsage*>(vm, value))
230 return &wrapper->wrapped();
231 return nullptr;
232}
233
234}
235
236#endif // ENABLE(WEBGPU)
237