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