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