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 "JSWebGPUSwapChain.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 "JSWebGPUTexture.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
44namespace WebCore {
45using namespace JSC;
46
47// Functions
48
49JSC::EncodedJSValue JSC_HOST_CALL jsWebGPUSwapChainPrototypeFunctionGetCurrentTexture(JSC::ExecState*);
50
51// Attributes
52
53JSC::EncodedJSValue jsWebGPUSwapChainConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
54bool setJSWebGPUSwapChainConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
55
56class JSWebGPUSwapChainPrototype : public JSC::JSNonFinalObject {
57public:
58 using Base = JSC::JSNonFinalObject;
59 static JSWebGPUSwapChainPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
60 {
61 JSWebGPUSwapChainPrototype* ptr = new (NotNull, JSC::allocateCell<JSWebGPUSwapChainPrototype>(vm.heap)) JSWebGPUSwapChainPrototype(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
72private:
73 JSWebGPUSwapChainPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
74 : JSC::JSNonFinalObject(vm, structure)
75 {
76 }
77
78 void finishCreation(JSC::VM&);
79};
80
81using JSWebGPUSwapChainConstructor = JSDOMConstructorNotConstructable<JSWebGPUSwapChain>;
82
83template<> JSValue JSWebGPUSwapChainConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
84{
85 UNUSED_PARAM(vm);
86 return globalObject.functionPrototype();
87}
88
89template<> void JSWebGPUSwapChainConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
90{
91 putDirect(vm, vm.propertyNames->prototype, JSWebGPUSwapChain::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
92 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("GPUSwapChain"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
93 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
94}
95
96template<> const ClassInfo JSWebGPUSwapChainConstructor::s_info = { "GPUSwapChain", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUSwapChainConstructor) };
97
98/* Hash table for prototype */
99
100static const HashTableValue JSWebGPUSwapChainPrototypeTableValues[] =
101{
102 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWebGPUSwapChainConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSWebGPUSwapChainConstructor) } },
103 { "getCurrentTexture", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsWebGPUSwapChainPrototypeFunctionGetCurrentTexture), (intptr_t) (0) } },
104};
105
106const ClassInfo JSWebGPUSwapChainPrototype::s_info = { "GPUSwapChainPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUSwapChainPrototype) };
107
108void JSWebGPUSwapChainPrototype::finishCreation(VM& vm)
109{
110 Base::finishCreation(vm);
111 reifyStaticProperties(vm, JSWebGPUSwapChain::info(), JSWebGPUSwapChainPrototypeTableValues, *this);
112}
113
114const ClassInfo JSWebGPUSwapChain::s_info = { "GPUSwapChain", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebGPUSwapChain) };
115
116JSWebGPUSwapChain::JSWebGPUSwapChain(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WebGPUSwapChain>&& impl)
117 : JSDOMWrapper<WebGPUSwapChain>(structure, globalObject, WTFMove(impl))
118{
119}
120
121void JSWebGPUSwapChain::finishCreation(VM& vm)
122{
123 Base::finishCreation(vm);
124 ASSERT(inherits(vm, info()));
125
126}
127
128JSObject* JSWebGPUSwapChain::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
129{
130 return JSWebGPUSwapChainPrototype::create(vm, &globalObject, JSWebGPUSwapChainPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
131}
132
133JSObject* JSWebGPUSwapChain::prototype(VM& vm, JSDOMGlobalObject& globalObject)
134{
135 return getDOMPrototype<JSWebGPUSwapChain>(vm, globalObject);
136}
137
138JSValue JSWebGPUSwapChain::getConstructor(VM& vm, const JSGlobalObject* globalObject)
139{
140 return getDOMConstructor<JSWebGPUSwapChainConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
141}
142
143void JSWebGPUSwapChain::destroy(JSC::JSCell* cell)
144{
145 JSWebGPUSwapChain* thisObject = static_cast<JSWebGPUSwapChain*>(cell);
146 thisObject->JSWebGPUSwapChain::~JSWebGPUSwapChain();
147}
148
149template<> inline JSWebGPUSwapChain* IDLOperation<JSWebGPUSwapChain>::cast(ExecState& state)
150{
151 return jsDynamicCast<JSWebGPUSwapChain*>(state.vm(), state.thisValue());
152}
153
154EncodedJSValue jsWebGPUSwapChainConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
155{
156 VM& vm = state->vm();
157 auto throwScope = DECLARE_THROW_SCOPE(vm);
158 auto* prototype = jsDynamicCast<JSWebGPUSwapChainPrototype*>(vm, JSValue::decode(thisValue));
159 if (UNLIKELY(!prototype))
160 return throwVMTypeError(state, throwScope);
161 return JSValue::encode(JSWebGPUSwapChain::getConstructor(state->vm(), prototype->globalObject()));
162}
163
164bool setJSWebGPUSwapChainConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
165{
166 VM& vm = state->vm();
167 auto throwScope = DECLARE_THROW_SCOPE(vm);
168 auto* prototype = jsDynamicCast<JSWebGPUSwapChainPrototype*>(vm, JSValue::decode(thisValue));
169 if (UNLIKELY(!prototype)) {
170 throwVMTypeError(state, throwScope);
171 return false;
172 }
173 // Shadowing a built-in constructor
174 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
175}
176
177static inline JSC::EncodedJSValue jsWebGPUSwapChainPrototypeFunctionGetCurrentTextureBody(JSC::ExecState* state, typename IDLOperation<JSWebGPUSwapChain>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
178{
179 UNUSED_PARAM(state);
180 UNUSED_PARAM(throwScope);
181 auto& impl = castedThis->wrapped();
182 return JSValue::encode(toJS<IDLInterface<WebGPUTexture>>(*state, *castedThis->globalObject(), impl.getCurrentTexture()));
183}
184
185EncodedJSValue JSC_HOST_CALL jsWebGPUSwapChainPrototypeFunctionGetCurrentTexture(ExecState* state)
186{
187 return IDLOperation<JSWebGPUSwapChain>::call<jsWebGPUSwapChainPrototypeFunctionGetCurrentTextureBody>(*state, "getCurrentTexture");
188}
189
190void JSWebGPUSwapChain::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
191{
192 auto* thisObject = jsCast<JSWebGPUSwapChain*>(cell);
193 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
194 if (thisObject->scriptExecutionContext())
195 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
196 Base::heapSnapshot(cell, builder);
197}
198
199bool JSWebGPUSwapChainOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
200{
201 UNUSED_PARAM(handle);
202 UNUSED_PARAM(visitor);
203 UNUSED_PARAM(reason);
204 return false;
205}
206
207void JSWebGPUSwapChainOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
208{
209 auto* jsWebGPUSwapChain = static_cast<JSWebGPUSwapChain*>(handle.slot()->asCell());
210 auto& world = *static_cast<DOMWrapperWorld*>(context);
211 uncacheWrapper(world, &jsWebGPUSwapChain->wrapped(), jsWebGPUSwapChain);
212}
213
214JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<WebGPUSwapChain>&& impl)
215{
216 return createWrapper<WebGPUSwapChain>(globalObject, WTFMove(impl));
217}
218
219JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, WebGPUSwapChain& impl)
220{
221 return wrap(state, globalObject, impl);
222}
223
224WebGPUSwapChain* JSWebGPUSwapChain::toWrapped(JSC::VM& vm, JSC::JSValue value)
225{
226 if (auto* wrapper = jsDynamicCast<JSWebGPUSwapChain*>(vm, value))
227 return &wrapper->wrapped();
228 return nullptr;
229}
230
231}
232
233#endif // ENABLE(WEBGPU)
234