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 "JSMediaQueryList.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConvertBoolean.h"
27#include "JSDOMConvertCallbacks.h"
28#include "JSDOMConvertNullable.h"
29#include "JSDOMConvertStrings.h"
30#include "JSDOMExceptionHandling.h"
31#include "JSDOMGlobalObject.h"
32#include "JSDOMOperation.h"
33#include "JSDOMWrapperCache.h"
34#include "JSMediaQueryListListener.h"
35#include "ScriptExecutionContext.h"
36#include <JavaScriptCore/HeapSnapshotBuilder.h>
37#include <JavaScriptCore/JSCInlines.h>
38#include <wtf/GetPtr.h>
39#include <wtf/PointerPreparations.h>
40#include <wtf/URL.h>
41
42
43namespace WebCore {
44using namespace JSC;
45
46// Functions
47
48JSC::EncodedJSValue JSC_HOST_CALL jsMediaQueryListPrototypeFunctionAddListener(JSC::ExecState*);
49JSC::EncodedJSValue JSC_HOST_CALL jsMediaQueryListPrototypeFunctionRemoveListener(JSC::ExecState*);
50
51// Attributes
52
53JSC::EncodedJSValue jsMediaQueryListMedia(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
54JSC::EncodedJSValue jsMediaQueryListMatches(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
55
56class JSMediaQueryListPrototype : public JSC::JSNonFinalObject {
57public:
58 using Base = JSC::JSNonFinalObject;
59 static JSMediaQueryListPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
60 {
61 JSMediaQueryListPrototype* ptr = new (NotNull, JSC::allocateCell<JSMediaQueryListPrototype>(vm.heap)) JSMediaQueryListPrototype(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 JSMediaQueryListPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
74 : JSC::JSNonFinalObject(vm, structure)
75 {
76 }
77
78 void finishCreation(JSC::VM&);
79};
80
81/* Hash table for prototype */
82
83static const HashTableValue JSMediaQueryListPrototypeTableValues[] =
84{
85 { "media", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaQueryListMedia), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
86 { "matches", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaQueryListMatches), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
87 { "addListener", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaQueryListPrototypeFunctionAddListener), (intptr_t) (0) } },
88 { "removeListener", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMediaQueryListPrototypeFunctionRemoveListener), (intptr_t) (0) } },
89};
90
91const ClassInfo JSMediaQueryListPrototype::s_info = { "MediaQueryListPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaQueryListPrototype) };
92
93void JSMediaQueryListPrototype::finishCreation(VM& vm)
94{
95 Base::finishCreation(vm);
96 reifyStaticProperties(vm, JSMediaQueryList::info(), JSMediaQueryListPrototypeTableValues, *this);
97}
98
99const ClassInfo JSMediaQueryList::s_info = { "MediaQueryList", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaQueryList) };
100
101JSMediaQueryList::JSMediaQueryList(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MediaQueryList>&& impl)
102 : JSDOMWrapper<MediaQueryList>(structure, globalObject, WTFMove(impl))
103{
104}
105
106void JSMediaQueryList::finishCreation(VM& vm)
107{
108 Base::finishCreation(vm);
109 ASSERT(inherits(vm, info()));
110
111}
112
113JSObject* JSMediaQueryList::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
114{
115 return JSMediaQueryListPrototype::create(vm, &globalObject, JSMediaQueryListPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
116}
117
118JSObject* JSMediaQueryList::prototype(VM& vm, JSDOMGlobalObject& globalObject)
119{
120 return getDOMPrototype<JSMediaQueryList>(vm, globalObject);
121}
122
123void JSMediaQueryList::destroy(JSC::JSCell* cell)
124{
125 JSMediaQueryList* thisObject = static_cast<JSMediaQueryList*>(cell);
126 thisObject->JSMediaQueryList::~JSMediaQueryList();
127}
128
129template<> inline JSMediaQueryList* IDLAttribute<JSMediaQueryList>::cast(ExecState& state, EncodedJSValue thisValue)
130{
131 return jsDynamicCast<JSMediaQueryList*>(state.vm(), JSValue::decode(thisValue));
132}
133
134template<> inline JSMediaQueryList* IDLOperation<JSMediaQueryList>::cast(ExecState& state)
135{
136 return jsDynamicCast<JSMediaQueryList*>(state.vm(), state.thisValue());
137}
138
139static inline JSValue jsMediaQueryListMediaGetter(ExecState& state, JSMediaQueryList& thisObject, ThrowScope& throwScope)
140{
141 UNUSED_PARAM(throwScope);
142 UNUSED_PARAM(state);
143 auto& impl = thisObject.wrapped();
144 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.media());
145 return result;
146}
147
148EncodedJSValue jsMediaQueryListMedia(ExecState* state, EncodedJSValue thisValue, PropertyName)
149{
150 return IDLAttribute<JSMediaQueryList>::get<jsMediaQueryListMediaGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "media");
151}
152
153static inline JSValue jsMediaQueryListMatchesGetter(ExecState& state, JSMediaQueryList& thisObject, ThrowScope& throwScope)
154{
155 UNUSED_PARAM(throwScope);
156 UNUSED_PARAM(state);
157 auto& impl = thisObject.wrapped();
158 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.matches());
159 return result;
160}
161
162EncodedJSValue jsMediaQueryListMatches(ExecState* state, EncodedJSValue thisValue, PropertyName)
163{
164 return IDLAttribute<JSMediaQueryList>::get<jsMediaQueryListMatchesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "matches");
165}
166
167static inline JSC::EncodedJSValue jsMediaQueryListPrototypeFunctionAddListenerBody(JSC::ExecState* state, typename IDLOperation<JSMediaQueryList>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
168{
169 UNUSED_PARAM(state);
170 UNUSED_PARAM(throwScope);
171 auto& impl = castedThis->wrapped();
172 auto listener = convert<IDLNullable<IDLCallbackFunction<JSMediaQueryListListener>>>(*state, state->argument(0), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 0, "listener", "MediaQueryList", "addListener"); });
173 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
174 impl.addListener(WTFMove(listener));
175 return JSValue::encode(jsUndefined());
176}
177
178EncodedJSValue JSC_HOST_CALL jsMediaQueryListPrototypeFunctionAddListener(ExecState* state)
179{
180 return IDLOperation<JSMediaQueryList>::call<jsMediaQueryListPrototypeFunctionAddListenerBody>(*state, "addListener");
181}
182
183static inline JSC::EncodedJSValue jsMediaQueryListPrototypeFunctionRemoveListenerBody(JSC::ExecState* state, typename IDLOperation<JSMediaQueryList>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
184{
185 UNUSED_PARAM(state);
186 UNUSED_PARAM(throwScope);
187 auto& impl = castedThis->wrapped();
188 auto listener = convert<IDLNullable<IDLCallbackFunction<JSMediaQueryListListener>>>(*state, state->argument(0), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 0, "listener", "MediaQueryList", "removeListener"); });
189 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
190 impl.removeListener(WTFMove(listener));
191 return JSValue::encode(jsUndefined());
192}
193
194EncodedJSValue JSC_HOST_CALL jsMediaQueryListPrototypeFunctionRemoveListener(ExecState* state)
195{
196 return IDLOperation<JSMediaQueryList>::call<jsMediaQueryListPrototypeFunctionRemoveListenerBody>(*state, "removeListener");
197}
198
199void JSMediaQueryList::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
200{
201 auto* thisObject = jsCast<JSMediaQueryList*>(cell);
202 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
203 if (thisObject->scriptExecutionContext())
204 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
205 Base::heapSnapshot(cell, builder);
206}
207
208bool JSMediaQueryListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
209{
210 UNUSED_PARAM(handle);
211 UNUSED_PARAM(visitor);
212 UNUSED_PARAM(reason);
213 return false;
214}
215
216void JSMediaQueryListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
217{
218 auto* jsMediaQueryList = static_cast<JSMediaQueryList*>(handle.slot()->asCell());
219 auto& world = *static_cast<DOMWrapperWorld*>(context);
220 uncacheWrapper(world, &jsMediaQueryList->wrapped(), jsMediaQueryList);
221}
222
223JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MediaQueryList>&& impl)
224{
225 // If you hit this failure the interface definition has the ImplementationLacksVTable
226 // attribute. You should remove that attribute. If the class has subclasses
227 // that may be passed through this toJS() function you should use the SkipVTableValidation
228 // attribute to MediaQueryList.
229 static_assert(!std::is_polymorphic<MediaQueryList>::value, "MediaQueryList is polymorphic but the IDL claims it is not");
230 return createWrapper<MediaQueryList>(globalObject, WTFMove(impl));
231}
232
233JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MediaQueryList& impl)
234{
235 return wrap(state, globalObject, impl);
236}
237
238MediaQueryList* JSMediaQueryList::toWrapped(JSC::VM& vm, JSC::JSValue value)
239{
240 if (auto* wrapper = jsDynamicCast<JSMediaQueryList*>(vm, value))
241 return &wrapper->wrapped();
242 return nullptr;
243}
244
245}
246