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