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