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 "JSMediaError.h"
26
27#include "JSDOMAttribute.h"
28#include "JSDOMBinding.h"
29#include "JSDOMConstructorNotConstructable.h"
30#include "JSDOMConvertNumbers.h"
31#include "JSDOMExceptionHandling.h"
32#include "JSDOMWrapperCache.h"
33#include "ScriptExecutionContext.h"
34#include <JavaScriptCore/FunctionPrototype.h>
35#include <JavaScriptCore/HeapSnapshotBuilder.h>
36#include <JavaScriptCore/JSCInlines.h>
37#include <wtf/GetPtr.h>
38#include <wtf/PointerPreparations.h>
39#include <wtf/URL.h>
40
41
42namespace WebCore {
43using namespace JSC;
44
45// Attributes
46
47JSC::EncodedJSValue jsMediaErrorConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
48bool setJSMediaErrorConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
49JSC::EncodedJSValue jsMediaErrorCode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50
51class JSMediaErrorPrototype : public JSC::JSNonFinalObject {
52public:
53 using Base = JSC::JSNonFinalObject;
54 static JSMediaErrorPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
55 {
56 JSMediaErrorPrototype* ptr = new (NotNull, JSC::allocateCell<JSMediaErrorPrototype>(vm.heap)) JSMediaErrorPrototype(vm, globalObject, structure);
57 ptr->finishCreation(vm);
58 return ptr;
59 }
60
61 DECLARE_INFO;
62 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
63 {
64 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
65 }
66
67private:
68 JSMediaErrorPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
69 : JSC::JSNonFinalObject(vm, structure)
70 {
71 }
72
73 void finishCreation(JSC::VM&);
74};
75
76using JSMediaErrorConstructor = JSDOMConstructorNotConstructable<JSMediaError>;
77
78/* Hash table for constructor */
79
80static const HashTableValue JSMediaErrorConstructorTableValues[] =
81{
82 { "MEDIA_ERR_ABORTED", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } },
83 { "MEDIA_ERR_NETWORK", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } },
84 { "MEDIA_ERR_DECODE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } },
85 { "MEDIA_ERR_SRC_NOT_SUPPORTED", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } },
86#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
87 { "MEDIA_ERR_ENCRYPTED", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } },
88#else
89 { 0, 0, NoIntrinsic, { 0, 0 } },
90#endif
91};
92
93static_assert(MediaError::MEDIA_ERR_ABORTED == 1, "MEDIA_ERR_ABORTED in MediaError does not match value from IDL");
94static_assert(MediaError::MEDIA_ERR_NETWORK == 2, "MEDIA_ERR_NETWORK in MediaError does not match value from IDL");
95static_assert(MediaError::MEDIA_ERR_DECODE == 3, "MEDIA_ERR_DECODE in MediaError does not match value from IDL");
96static_assert(MediaError::MEDIA_ERR_SRC_NOT_SUPPORTED == 4, "MEDIA_ERR_SRC_NOT_SUPPORTED in MediaError does not match value from IDL");
97#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
98static_assert(MediaError::MEDIA_ERR_ENCRYPTED == 5, "MEDIA_ERR_ENCRYPTED in MediaError does not match value from IDL");
99#endif
100
101template<> JSValue JSMediaErrorConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
102{
103 UNUSED_PARAM(vm);
104 return globalObject.functionPrototype();
105}
106
107template<> void JSMediaErrorConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
108{
109 putDirect(vm, vm.propertyNames->prototype, JSMediaError::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
110 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("MediaError"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
111 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
112 reifyStaticProperties(vm, JSMediaError::info(), JSMediaErrorConstructorTableValues, *this);
113}
114
115template<> const ClassInfo JSMediaErrorConstructor::s_info = { "MediaError", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaErrorConstructor) };
116
117/* Hash table for prototype */
118
119static const HashTableValue JSMediaErrorPrototypeTableValues[] =
120{
121 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaErrorConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMediaErrorConstructor) } },
122 { "code", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMediaErrorCode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
123 { "MEDIA_ERR_ABORTED", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } },
124 { "MEDIA_ERR_NETWORK", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } },
125 { "MEDIA_ERR_DECODE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } },
126 { "MEDIA_ERR_SRC_NOT_SUPPORTED", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } },
127#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
128 { "MEDIA_ERR_ENCRYPTED", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } },
129#else
130 { 0, 0, NoIntrinsic, { 0, 0 } },
131#endif
132};
133
134const ClassInfo JSMediaErrorPrototype::s_info = { "MediaErrorPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaErrorPrototype) };
135
136void JSMediaErrorPrototype::finishCreation(VM& vm)
137{
138 Base::finishCreation(vm);
139 reifyStaticProperties(vm, JSMediaError::info(), JSMediaErrorPrototypeTableValues, *this);
140}
141
142const ClassInfo JSMediaError::s_info = { "MediaError", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMediaError) };
143
144JSMediaError::JSMediaError(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MediaError>&& impl)
145 : JSDOMWrapper<MediaError>(structure, globalObject, WTFMove(impl))
146{
147}
148
149void JSMediaError::finishCreation(VM& vm)
150{
151 Base::finishCreation(vm);
152 ASSERT(inherits(vm, info()));
153
154}
155
156JSObject* JSMediaError::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
157{
158 return JSMediaErrorPrototype::create(vm, &globalObject, JSMediaErrorPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
159}
160
161JSObject* JSMediaError::prototype(VM& vm, JSDOMGlobalObject& globalObject)
162{
163 return getDOMPrototype<JSMediaError>(vm, globalObject);
164}
165
166JSValue JSMediaError::getConstructor(VM& vm, const JSGlobalObject* globalObject)
167{
168 return getDOMConstructor<JSMediaErrorConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
169}
170
171void JSMediaError::destroy(JSC::JSCell* cell)
172{
173 JSMediaError* thisObject = static_cast<JSMediaError*>(cell);
174 thisObject->JSMediaError::~JSMediaError();
175}
176
177template<> inline JSMediaError* IDLAttribute<JSMediaError>::cast(ExecState& state, EncodedJSValue thisValue)
178{
179 return jsDynamicCast<JSMediaError*>(state.vm(), JSValue::decode(thisValue));
180}
181
182EncodedJSValue jsMediaErrorConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
183{
184 VM& vm = state->vm();
185 auto throwScope = DECLARE_THROW_SCOPE(vm);
186 auto* prototype = jsDynamicCast<JSMediaErrorPrototype*>(vm, JSValue::decode(thisValue));
187 if (UNLIKELY(!prototype))
188 return throwVMTypeError(state, throwScope);
189 return JSValue::encode(JSMediaError::getConstructor(state->vm(), prototype->globalObject()));
190}
191
192bool setJSMediaErrorConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
193{
194 VM& vm = state->vm();
195 auto throwScope = DECLARE_THROW_SCOPE(vm);
196 auto* prototype = jsDynamicCast<JSMediaErrorPrototype*>(vm, JSValue::decode(thisValue));
197 if (UNLIKELY(!prototype)) {
198 throwVMTypeError(state, throwScope);
199 return false;
200 }
201 // Shadowing a built-in constructor
202 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
203}
204
205static inline JSValue jsMediaErrorCodeGetter(ExecState& state, JSMediaError& 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.code());
211 return result;
212}
213
214EncodedJSValue jsMediaErrorCode(ExecState* state, EncodedJSValue thisValue, PropertyName)
215{
216 return IDLAttribute<JSMediaError>::get<jsMediaErrorCodeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "code");
217}
218
219void JSMediaError::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
220{
221 auto* thisObject = jsCast<JSMediaError*>(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
228bool JSMediaErrorOwner::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
236void JSMediaErrorOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
237{
238 auto* jsMediaError = static_cast<JSMediaError*>(handle.slot()->asCell());
239 auto& world = *static_cast<DOMWrapperWorld*>(context);
240 uncacheWrapper(world, &jsMediaError->wrapped(), jsMediaError);
241}
242
243JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MediaError>&& 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 MediaError.
249 static_assert(!std::is_polymorphic<MediaError>::value, "MediaError is polymorphic but the IDL claims it is not");
250 return createWrapper<MediaError>(globalObject, WTFMove(impl));
251}
252
253JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MediaError& impl)
254{
255 return wrap(state, globalObject, impl);
256}
257
258MediaError* JSMediaError::toWrapped(JSC::VM& vm, JSC::JSValue value)
259{
260 if (auto* wrapper = jsDynamicCast<JSMediaError*>(vm, value))
261 return &wrapper->wrapped();
262 return nullptr;
263}
264
265}
266
267#endif // ENABLE(VIDEO)
268