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 | |
23 | #if ENABLE(VIDEO) |
24 | |
25 | #include "JSTimeRanges.h" |
26 | |
27 | #include "JSDOMAttribute.h" |
28 | #include "JSDOMBinding.h" |
29 | #include "JSDOMConstructorNotConstructable.h" |
30 | #include "JSDOMConvertNumbers.h" |
31 | #include "JSDOMExceptionHandling.h" |
32 | #include "JSDOMOperation.h" |
33 | #include "JSDOMWrapperCache.h" |
34 | #include "ScriptExecutionContext.h" |
35 | #include <JavaScriptCore/FunctionPrototype.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 | |
43 | namespace WebCore { |
44 | using namespace JSC; |
45 | |
46 | // Functions |
47 | |
48 | JSC::EncodedJSValue JSC_HOST_CALL jsTimeRangesPrototypeFunctionStart(JSC::ExecState*); |
49 | JSC::EncodedJSValue JSC_HOST_CALL jsTimeRangesPrototypeFunctionEnd(JSC::ExecState*); |
50 | |
51 | // Attributes |
52 | |
53 | JSC::EncodedJSValue jsTimeRangesConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
54 | bool setJSTimeRangesConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
55 | JSC::EncodedJSValue jsTimeRangesLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
56 | |
57 | class JSTimeRangesPrototype : public JSC::JSNonFinalObject { |
58 | public: |
59 | using Base = JSC::JSNonFinalObject; |
60 | static JSTimeRangesPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
61 | { |
62 | JSTimeRangesPrototype* ptr = new (NotNull, JSC::allocateCell<JSTimeRangesPrototype>(vm.heap)) JSTimeRangesPrototype(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 | JSTimeRangesPrototype(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 JSTimeRangesConstructor = JSDOMConstructorNotConstructable<JSTimeRanges>; |
83 | |
84 | template<> JSValue JSTimeRangesConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
85 | { |
86 | UNUSED_PARAM(vm); |
87 | return globalObject.functionPrototype(); |
88 | } |
89 | |
90 | template<> void JSTimeRangesConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
91 | { |
92 | putDirect(vm, vm.propertyNames->prototype, JSTimeRanges::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
93 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("TimeRanges"_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 JSTimeRangesConstructor::s_info = { "TimeRanges" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTimeRangesConstructor) }; |
98 | |
99 | /* Hash table for prototype */ |
100 | |
101 | static const HashTableValue JSTimeRangesPrototypeTableValues[] = |
102 | { |
103 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTimeRangesConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTimeRangesConstructor) } }, |
104 | { "length" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTimeRangesLength), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
105 | { "start" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTimeRangesPrototypeFunctionStart), (intptr_t) (1) } }, |
106 | { "end" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTimeRangesPrototypeFunctionEnd), (intptr_t) (1) } }, |
107 | }; |
108 | |
109 | const ClassInfo JSTimeRangesPrototype::s_info = { "TimeRangesPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTimeRangesPrototype) }; |
110 | |
111 | void JSTimeRangesPrototype::finishCreation(VM& vm) |
112 | { |
113 | Base::finishCreation(vm); |
114 | reifyStaticProperties(vm, JSTimeRanges::info(), JSTimeRangesPrototypeTableValues, *this); |
115 | } |
116 | |
117 | const ClassInfo JSTimeRanges::s_info = { "TimeRanges" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTimeRanges) }; |
118 | |
119 | JSTimeRanges::JSTimeRanges(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TimeRanges>&& impl) |
120 | : JSDOMWrapper<TimeRanges>(structure, globalObject, WTFMove(impl)) |
121 | { |
122 | } |
123 | |
124 | void JSTimeRanges::finishCreation(VM& vm) |
125 | { |
126 | Base::finishCreation(vm); |
127 | ASSERT(inherits(vm, info())); |
128 | |
129 | } |
130 | |
131 | JSObject* JSTimeRanges::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
132 | { |
133 | return JSTimeRangesPrototype::create(vm, &globalObject, JSTimeRangesPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
134 | } |
135 | |
136 | JSObject* JSTimeRanges::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
137 | { |
138 | return getDOMPrototype<JSTimeRanges>(vm, globalObject); |
139 | } |
140 | |
141 | JSValue JSTimeRanges::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
142 | { |
143 | return getDOMConstructor<JSTimeRangesConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
144 | } |
145 | |
146 | void JSTimeRanges::destroy(JSC::JSCell* cell) |
147 | { |
148 | JSTimeRanges* thisObject = static_cast<JSTimeRanges*>(cell); |
149 | thisObject->JSTimeRanges::~JSTimeRanges(); |
150 | } |
151 | |
152 | template<> inline JSTimeRanges* IDLAttribute<JSTimeRanges>::cast(ExecState& state, EncodedJSValue thisValue) |
153 | { |
154 | return jsDynamicCast<JSTimeRanges*>(state.vm(), JSValue::decode(thisValue)); |
155 | } |
156 | |
157 | template<> inline JSTimeRanges* IDLOperation<JSTimeRanges>::cast(ExecState& state) |
158 | { |
159 | return jsDynamicCast<JSTimeRanges*>(state.vm(), state.thisValue()); |
160 | } |
161 | |
162 | EncodedJSValue jsTimeRangesConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
163 | { |
164 | VM& vm = state->vm(); |
165 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
166 | auto* prototype = jsDynamicCast<JSTimeRangesPrototype*>(vm, JSValue::decode(thisValue)); |
167 | if (UNLIKELY(!prototype)) |
168 | return throwVMTypeError(state, throwScope); |
169 | return JSValue::encode(JSTimeRanges::getConstructor(state->vm(), prototype->globalObject())); |
170 | } |
171 | |
172 | bool setJSTimeRangesConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
173 | { |
174 | VM& vm = state->vm(); |
175 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
176 | auto* prototype = jsDynamicCast<JSTimeRangesPrototype*>(vm, JSValue::decode(thisValue)); |
177 | if (UNLIKELY(!prototype)) { |
178 | throwVMTypeError(state, throwScope); |
179 | return false; |
180 | } |
181 | // Shadowing a built-in constructor |
182 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
183 | } |
184 | |
185 | static inline JSValue jsTimeRangesLengthGetter(ExecState& state, JSTimeRanges& thisObject, ThrowScope& throwScope) |
186 | { |
187 | UNUSED_PARAM(throwScope); |
188 | UNUSED_PARAM(state); |
189 | auto& impl = thisObject.wrapped(); |
190 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.length()); |
191 | return result; |
192 | } |
193 | |
194 | EncodedJSValue jsTimeRangesLength(ExecState* state, EncodedJSValue thisValue, PropertyName) |
195 | { |
196 | return IDLAttribute<JSTimeRanges>::get<jsTimeRangesLengthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "length" ); |
197 | } |
198 | |
199 | static inline JSC::EncodedJSValue jsTimeRangesPrototypeFunctionStartBody(JSC::ExecState* state, typename IDLOperation<JSTimeRanges>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
200 | { |
201 | UNUSED_PARAM(state); |
202 | UNUSED_PARAM(throwScope); |
203 | auto& impl = castedThis->wrapped(); |
204 | if (UNLIKELY(state->argumentCount() < 1)) |
205 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
206 | auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
207 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
208 | return JSValue::encode(toJS<IDLUnrestrictedDouble>(*state, throwScope, impl.start(WTFMove(index)))); |
209 | } |
210 | |
211 | EncodedJSValue JSC_HOST_CALL jsTimeRangesPrototypeFunctionStart(ExecState* state) |
212 | { |
213 | return IDLOperation<JSTimeRanges>::call<jsTimeRangesPrototypeFunctionStartBody>(*state, "start" ); |
214 | } |
215 | |
216 | static inline JSC::EncodedJSValue jsTimeRangesPrototypeFunctionEndBody(JSC::ExecState* state, typename IDLOperation<JSTimeRanges>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
217 | { |
218 | UNUSED_PARAM(state); |
219 | UNUSED_PARAM(throwScope); |
220 | auto& impl = castedThis->wrapped(); |
221 | if (UNLIKELY(state->argumentCount() < 1)) |
222 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
223 | auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
224 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
225 | return JSValue::encode(toJS<IDLUnrestrictedDouble>(*state, throwScope, impl.end(WTFMove(index)))); |
226 | } |
227 | |
228 | EncodedJSValue JSC_HOST_CALL jsTimeRangesPrototypeFunctionEnd(ExecState* state) |
229 | { |
230 | return IDLOperation<JSTimeRanges>::call<jsTimeRangesPrototypeFunctionEndBody>(*state, "end" ); |
231 | } |
232 | |
233 | void JSTimeRanges::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
234 | { |
235 | auto* thisObject = jsCast<JSTimeRanges*>(cell); |
236 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
237 | if (thisObject->scriptExecutionContext()) |
238 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
239 | Base::heapSnapshot(cell, builder); |
240 | } |
241 | |
242 | bool JSTimeRangesOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
243 | { |
244 | UNUSED_PARAM(handle); |
245 | UNUSED_PARAM(visitor); |
246 | UNUSED_PARAM(reason); |
247 | return false; |
248 | } |
249 | |
250 | void JSTimeRangesOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
251 | { |
252 | auto* jsTimeRanges = static_cast<JSTimeRanges*>(handle.slot()->asCell()); |
253 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
254 | uncacheWrapper(world, &jsTimeRanges->wrapped(), jsTimeRanges); |
255 | } |
256 | |
257 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TimeRanges>&& impl) |
258 | { |
259 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
260 | // attribute. You should remove that attribute. If the class has subclasses |
261 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
262 | // attribute to TimeRanges. |
263 | static_assert(!std::is_polymorphic<TimeRanges>::value, "TimeRanges is polymorphic but the IDL claims it is not" ); |
264 | return createWrapper<TimeRanges>(globalObject, WTFMove(impl)); |
265 | } |
266 | |
267 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TimeRanges& impl) |
268 | { |
269 | return wrap(state, globalObject, impl); |
270 | } |
271 | |
272 | TimeRanges* JSTimeRanges::toWrapped(JSC::VM& vm, JSC::JSValue value) |
273 | { |
274 | if (auto* wrapper = jsDynamicCast<JSTimeRanges*>(vm, value)) |
275 | return &wrapper->wrapped(); |
276 | return nullptr; |
277 | } |
278 | |
279 | } |
280 | |
281 | #endif // ENABLE(VIDEO) |
282 | |