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