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 "JSDOMMimeType.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructorNotConstructable.h"
27#include "JSDOMConvertInterface.h"
28#include "JSDOMConvertStrings.h"
29#include "JSDOMExceptionHandling.h"
30#include "JSDOMGlobalObject.h"
31#include "JSDOMPlugin.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 jsDOMMimeTypeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
48bool setJSDOMMimeTypeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
49JSC::EncodedJSValue jsDOMMimeTypeType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50JSC::EncodedJSValue jsDOMMimeTypeSuffixes(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
51JSC::EncodedJSValue jsDOMMimeTypeDescription(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52JSC::EncodedJSValue jsDOMMimeTypeEnabledPlugin(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
53
54class JSDOMMimeTypePrototype : public JSC::JSNonFinalObject {
55public:
56 using Base = JSC::JSNonFinalObject;
57 static JSDOMMimeTypePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
58 {
59 JSDOMMimeTypePrototype* ptr = new (NotNull, JSC::allocateCell<JSDOMMimeTypePrototype>(vm.heap)) JSDOMMimeTypePrototype(vm, globalObject, structure);
60 ptr->finishCreation(vm);
61 return ptr;
62 }
63
64 DECLARE_INFO;
65 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
66 {
67 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
68 }
69
70private:
71 JSDOMMimeTypePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
72 : JSC::JSNonFinalObject(vm, structure)
73 {
74 }
75
76 void finishCreation(JSC::VM&);
77};
78
79using JSDOMMimeTypeConstructor = JSDOMConstructorNotConstructable<JSDOMMimeType>;
80
81template<> JSValue JSDOMMimeTypeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
82{
83 UNUSED_PARAM(vm);
84 return globalObject.functionPrototype();
85}
86
87template<> void JSDOMMimeTypeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
88{
89 putDirect(vm, vm.propertyNames->prototype, JSDOMMimeType::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
90 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("MimeType"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
91 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
92}
93
94template<> const ClassInfo JSDOMMimeTypeConstructor::s_info = { "MimeType", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMMimeTypeConstructor) };
95
96/* Hash table for prototype */
97
98static const HashTableValue JSDOMMimeTypePrototypeTableValues[] =
99{
100 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMMimeTypeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMMimeTypeConstructor) } },
101 { "type", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMMimeTypeType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
102 { "suffixes", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMMimeTypeSuffixes), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
103 { "description", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMMimeTypeDescription), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
104 { "enabledPlugin", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMMimeTypeEnabledPlugin), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
105};
106
107const ClassInfo JSDOMMimeTypePrototype::s_info = { "MimeTypePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMMimeTypePrototype) };
108
109void JSDOMMimeTypePrototype::finishCreation(VM& vm)
110{
111 Base::finishCreation(vm);
112 reifyStaticProperties(vm, JSDOMMimeType::info(), JSDOMMimeTypePrototypeTableValues, *this);
113}
114
115const ClassInfo JSDOMMimeType::s_info = { "MimeType", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMMimeType) };
116
117JSDOMMimeType::JSDOMMimeType(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DOMMimeType>&& impl)
118 : JSDOMWrapper<DOMMimeType>(structure, globalObject, WTFMove(impl))
119{
120}
121
122void JSDOMMimeType::finishCreation(VM& vm)
123{
124 Base::finishCreation(vm);
125 ASSERT(inherits(vm, info()));
126
127}
128
129JSObject* JSDOMMimeType::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
130{
131 return JSDOMMimeTypePrototype::create(vm, &globalObject, JSDOMMimeTypePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
132}
133
134JSObject* JSDOMMimeType::prototype(VM& vm, JSDOMGlobalObject& globalObject)
135{
136 return getDOMPrototype<JSDOMMimeType>(vm, globalObject);
137}
138
139JSValue JSDOMMimeType::getConstructor(VM& vm, const JSGlobalObject* globalObject)
140{
141 return getDOMConstructor<JSDOMMimeTypeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
142}
143
144void JSDOMMimeType::destroy(JSC::JSCell* cell)
145{
146 JSDOMMimeType* thisObject = static_cast<JSDOMMimeType*>(cell);
147 thisObject->JSDOMMimeType::~JSDOMMimeType();
148}
149
150template<> inline JSDOMMimeType* IDLAttribute<JSDOMMimeType>::cast(ExecState& state, EncodedJSValue thisValue)
151{
152 return jsDynamicCast<JSDOMMimeType*>(state.vm(), JSValue::decode(thisValue));
153}
154
155EncodedJSValue jsDOMMimeTypeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
156{
157 VM& vm = state->vm();
158 auto throwScope = DECLARE_THROW_SCOPE(vm);
159 auto* prototype = jsDynamicCast<JSDOMMimeTypePrototype*>(vm, JSValue::decode(thisValue));
160 if (UNLIKELY(!prototype))
161 return throwVMTypeError(state, throwScope);
162 return JSValue::encode(JSDOMMimeType::getConstructor(state->vm(), prototype->globalObject()));
163}
164
165bool setJSDOMMimeTypeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
166{
167 VM& vm = state->vm();
168 auto throwScope = DECLARE_THROW_SCOPE(vm);
169 auto* prototype = jsDynamicCast<JSDOMMimeTypePrototype*>(vm, JSValue::decode(thisValue));
170 if (UNLIKELY(!prototype)) {
171 throwVMTypeError(state, throwScope);
172 return false;
173 }
174 // Shadowing a built-in constructor
175 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
176}
177
178static inline JSValue jsDOMMimeTypeTypeGetter(ExecState& state, JSDOMMimeType& thisObject, ThrowScope& throwScope)
179{
180 UNUSED_PARAM(throwScope);
181 UNUSED_PARAM(state);
182 auto& impl = thisObject.wrapped();
183 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.type());
184 return result;
185}
186
187EncodedJSValue jsDOMMimeTypeType(ExecState* state, EncodedJSValue thisValue, PropertyName)
188{
189 return IDLAttribute<JSDOMMimeType>::get<jsDOMMimeTypeTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "type");
190}
191
192static inline JSValue jsDOMMimeTypeSuffixesGetter(ExecState& state, JSDOMMimeType& thisObject, ThrowScope& throwScope)
193{
194 UNUSED_PARAM(throwScope);
195 UNUSED_PARAM(state);
196 auto& impl = thisObject.wrapped();
197 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.suffixes());
198 return result;
199}
200
201EncodedJSValue jsDOMMimeTypeSuffixes(ExecState* state, EncodedJSValue thisValue, PropertyName)
202{
203 return IDLAttribute<JSDOMMimeType>::get<jsDOMMimeTypeSuffixesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "suffixes");
204}
205
206static inline JSValue jsDOMMimeTypeDescriptionGetter(ExecState& state, JSDOMMimeType& thisObject, ThrowScope& throwScope)
207{
208 UNUSED_PARAM(throwScope);
209 UNUSED_PARAM(state);
210 auto& impl = thisObject.wrapped();
211 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.description());
212 return result;
213}
214
215EncodedJSValue jsDOMMimeTypeDescription(ExecState* state, EncodedJSValue thisValue, PropertyName)
216{
217 return IDLAttribute<JSDOMMimeType>::get<jsDOMMimeTypeDescriptionGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "description");
218}
219
220static inline JSValue jsDOMMimeTypeEnabledPluginGetter(ExecState& state, JSDOMMimeType& thisObject, ThrowScope& throwScope)
221{
222 UNUSED_PARAM(throwScope);
223 UNUSED_PARAM(state);
224 auto& impl = thisObject.wrapped();
225 JSValue result = toJS<IDLInterface<DOMPlugin>>(state, *thisObject.globalObject(), throwScope, impl.enabledPlugin());
226 return result;
227}
228
229EncodedJSValue jsDOMMimeTypeEnabledPlugin(ExecState* state, EncodedJSValue thisValue, PropertyName)
230{
231 return IDLAttribute<JSDOMMimeType>::get<jsDOMMimeTypeEnabledPluginGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "enabledPlugin");
232}
233
234void JSDOMMimeType::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
235{
236 auto* thisObject = jsCast<JSDOMMimeType*>(cell);
237 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
238 if (thisObject->scriptExecutionContext())
239 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
240 Base::heapSnapshot(cell, builder);
241}
242
243bool JSDOMMimeTypeOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
244{
245 UNUSED_PARAM(handle);
246 UNUSED_PARAM(visitor);
247 UNUSED_PARAM(reason);
248 return false;
249}
250
251void JSDOMMimeTypeOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
252{
253 auto* jsDOMMimeType = static_cast<JSDOMMimeType*>(handle.slot()->asCell());
254 auto& world = *static_cast<DOMWrapperWorld*>(context);
255 uncacheWrapper(world, &jsDOMMimeType->wrapped(), jsDOMMimeType);
256}
257
258#if ENABLE(BINDING_INTEGRITY)
259#if PLATFORM(WIN)
260#pragma warning(disable: 4483)
261extern "C" { extern void (*const __identifier("??_7DOMMimeType@WebCore@@6B@")[])(); }
262#else
263extern "C" { extern void* _ZTVN7WebCore11DOMMimeTypeE[]; }
264#endif
265#endif
266
267JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<DOMMimeType>&& impl)
268{
269
270#if ENABLE(BINDING_INTEGRITY)
271 void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
272#if PLATFORM(WIN)
273 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7DOMMimeType@WebCore@@6B@"));
274#else
275 void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore11DOMMimeTypeE[2]);
276#endif
277
278 // If this fails DOMMimeType does not have a vtable, so you need to add the
279 // ImplementationLacksVTable attribute to the interface definition
280 static_assert(std::is_polymorphic<DOMMimeType>::value, "DOMMimeType is not polymorphic");
281
282 // If you hit this assertion you either have a use after free bug, or
283 // DOMMimeType has subclasses. If DOMMimeType has subclasses that get passed
284 // to toJS() we currently require DOMMimeType you to opt out of binding hardening
285 // by adding the SkipVTableValidation attribute to the interface IDL definition
286 RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
287#endif
288 return createWrapper<DOMMimeType>(globalObject, WTFMove(impl));
289}
290
291JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DOMMimeType& impl)
292{
293 return wrap(state, globalObject, impl);
294}
295
296DOMMimeType* JSDOMMimeType::toWrapped(JSC::VM& vm, JSC::JSValue value)
297{
298 if (auto* wrapper = jsDynamicCast<JSDOMMimeType*>(vm, value))
299 return &wrapper->wrapped();
300 return nullptr;
301}
302
303}
304