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 "JSGPUColorWriteBits.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 jsGPUColorWriteBitsConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
46bool setJSGPUColorWriteBitsConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
47
48class JSGPUColorWriteBitsPrototype : public JSC::JSNonFinalObject {
49public:
50 using Base = JSC::JSNonFinalObject;
51 static JSGPUColorWriteBitsPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
52 {
53 JSGPUColorWriteBitsPrototype* ptr = new (NotNull, JSC::allocateCell<JSGPUColorWriteBitsPrototype>(vm.heap)) JSGPUColorWriteBitsPrototype(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 JSGPUColorWriteBitsPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
66 : JSC::JSNonFinalObject(vm, structure)
67 {
68 }
69
70 void finishCreation(JSC::VM&);
71};
72
73using JSGPUColorWriteBitsConstructor = JSDOMConstructorNotConstructable<JSGPUColorWriteBits>;
74
75/* Hash table for constructor */
76
77static const HashTableValue JSGPUColorWriteBitsConstructorTableValues[] =
78{
79 { "NONE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } },
80 { "RED", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } },
81 { "GREEN", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } },
82 { "BLUE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } },
83 { "ALPHA", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } },
84 { "ALL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(15) } },
85};
86
87template<> JSValue JSGPUColorWriteBitsConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
88{
89 UNUSED_PARAM(vm);
90 return globalObject.functionPrototype();
91}
92
93template<> void JSGPUColorWriteBitsConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
94{
95 putDirect(vm, vm.propertyNames->prototype, JSGPUColorWriteBits::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
96 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("GPUColorWriteBits"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
97 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
98 reifyStaticProperties(vm, JSGPUColorWriteBits::info(), JSGPUColorWriteBitsConstructorTableValues, *this);
99}
100
101template<> const ClassInfo JSGPUColorWriteBitsConstructor::s_info = { "GPUColorWriteBits", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSGPUColorWriteBitsConstructor) };
102
103/* Hash table for prototype */
104
105static const HashTableValue JSGPUColorWriteBitsPrototypeTableValues[] =
106{
107 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsGPUColorWriteBitsConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSGPUColorWriteBitsConstructor) } },
108 { "NONE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } },
109 { "RED", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } },
110 { "GREEN", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } },
111 { "BLUE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } },
112 { "ALPHA", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } },
113 { "ALL", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(15) } },
114};
115
116const ClassInfo JSGPUColorWriteBitsPrototype::s_info = { "GPUColorWriteBitsPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSGPUColorWriteBitsPrototype) };
117
118void JSGPUColorWriteBitsPrototype::finishCreation(VM& vm)
119{
120 Base::finishCreation(vm);
121 reifyStaticProperties(vm, JSGPUColorWriteBits::info(), JSGPUColorWriteBitsPrototypeTableValues, *this);
122}
123
124const ClassInfo JSGPUColorWriteBits::s_info = { "GPUColorWriteBits", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSGPUColorWriteBits) };
125
126JSGPUColorWriteBits::JSGPUColorWriteBits(Structure* structure, JSDOMGlobalObject& globalObject, Ref<GPUColorWriteBits>&& impl)
127 : JSDOMWrapper<GPUColorWriteBits>(structure, globalObject, WTFMove(impl))
128{
129}
130
131void JSGPUColorWriteBits::finishCreation(VM& vm)
132{
133 Base::finishCreation(vm);
134 ASSERT(inherits(vm, info()));
135
136}
137
138JSObject* JSGPUColorWriteBits::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
139{
140 return JSGPUColorWriteBitsPrototype::create(vm, &globalObject, JSGPUColorWriteBitsPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
141}
142
143JSObject* JSGPUColorWriteBits::prototype(VM& vm, JSDOMGlobalObject& globalObject)
144{
145 return getDOMPrototype<JSGPUColorWriteBits>(vm, globalObject);
146}
147
148JSValue JSGPUColorWriteBits::getConstructor(VM& vm, const JSGlobalObject* globalObject)
149{
150 return getDOMConstructor<JSGPUColorWriteBitsConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
151}
152
153void JSGPUColorWriteBits::destroy(JSC::JSCell* cell)
154{
155 JSGPUColorWriteBits* thisObject = static_cast<JSGPUColorWriteBits*>(cell);
156 thisObject->JSGPUColorWriteBits::~JSGPUColorWriteBits();
157}
158
159EncodedJSValue jsGPUColorWriteBitsConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
160{
161 VM& vm = state->vm();
162 auto throwScope = DECLARE_THROW_SCOPE(vm);
163 auto* prototype = jsDynamicCast<JSGPUColorWriteBitsPrototype*>(vm, JSValue::decode(thisValue));
164 if (UNLIKELY(!prototype))
165 return throwVMTypeError(state, throwScope);
166 return JSValue::encode(JSGPUColorWriteBits::getConstructor(state->vm(), prototype->globalObject()));
167}
168
169bool setJSGPUColorWriteBitsConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
170{
171 VM& vm = state->vm();
172 auto throwScope = DECLARE_THROW_SCOPE(vm);
173 auto* prototype = jsDynamicCast<JSGPUColorWriteBitsPrototype*>(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
182void JSGPUColorWriteBits::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
183{
184 auto* thisObject = jsCast<JSGPUColorWriteBits*>(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
191bool JSGPUColorWriteBitsOwner::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
199void JSGPUColorWriteBitsOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
200{
201 auto* jsGPUColorWriteBits = static_cast<JSGPUColorWriteBits*>(handle.slot()->asCell());
202 auto& world = *static_cast<DOMWrapperWorld*>(context);
203 uncacheWrapper(world, &jsGPUColorWriteBits->wrapped(), jsGPUColorWriteBits);
204}
205
206JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<GPUColorWriteBits>&& 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 GPUColorWriteBits.
212 static_assert(!std::is_polymorphic<GPUColorWriteBits>::value, "GPUColorWriteBits is polymorphic but the IDL claims it is not");
213 return createWrapper<GPUColorWriteBits>(globalObject, WTFMove(impl));
214}
215
216JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, GPUColorWriteBits& impl)
217{
218 return wrap(state, globalObject, impl);
219}
220
221GPUColorWriteBits* JSGPUColorWriteBits::toWrapped(JSC::VM& vm, JSC::JSValue value)
222{
223 if (auto* wrapper = jsDynamicCast<JSGPUColorWriteBits*>(vm, value))
224 return &wrapper->wrapped();
225 return nullptr;
226}
227
228}
229
230#endif // ENABLE(WEBGPU)
231