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