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