| 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 "JSFileSystemEntry.h" |
| 23 | |
| 24 | #include "JSDOMAttribute.h" |
| 25 | #include "JSDOMBinding.h" |
| 26 | #include "JSDOMConstructorNotConstructable.h" |
| 27 | #include "JSDOMConvertBoolean.h" |
| 28 | #include "JSDOMConvertCallbacks.h" |
| 29 | #include "JSDOMConvertInterface.h" |
| 30 | #include "JSDOMConvertNullable.h" |
| 31 | #include "JSDOMConvertStrings.h" |
| 32 | #include "JSDOMExceptionHandling.h" |
| 33 | #include "JSDOMFileSystem.h" |
| 34 | #include "JSDOMGlobalObject.h" |
| 35 | #include "JSDOMOperation.h" |
| 36 | #include "JSDOMWrapperCache.h" |
| 37 | #include "JSErrorCallback.h" |
| 38 | #include "JSFileSystemEntryCallback.h" |
| 39 | #include "ScriptExecutionContext.h" |
| 40 | #include <JavaScriptCore/FunctionPrototype.h> |
| 41 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 42 | #include <JavaScriptCore/JSCInlines.h> |
| 43 | #include <wtf/GetPtr.h> |
| 44 | #include <wtf/PointerPreparations.h> |
| 45 | #include <wtf/URL.h> |
| 46 | |
| 47 | |
| 48 | namespace WebCore { |
| 49 | using namespace JSC; |
| 50 | |
| 51 | // Functions |
| 52 | |
| 53 | JSC::EncodedJSValue JSC_HOST_CALL jsFileSystemEntryPrototypeFunctionGetParent(JSC::ExecState*); |
| 54 | |
| 55 | // Attributes |
| 56 | |
| 57 | JSC::EncodedJSValue jsFileSystemEntryConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 58 | bool setJSFileSystemEntryConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 59 | JSC::EncodedJSValue jsFileSystemEntryIsFile(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 60 | JSC::EncodedJSValue jsFileSystemEntryIsDirectory(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 61 | JSC::EncodedJSValue jsFileSystemEntryName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 62 | JSC::EncodedJSValue jsFileSystemEntryFullPath(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 63 | JSC::EncodedJSValue jsFileSystemEntryFilesystem(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 64 | |
| 65 | class JSFileSystemEntryPrototype : public JSC::JSNonFinalObject { |
| 66 | public: |
| 67 | using Base = JSC::JSNonFinalObject; |
| 68 | static JSFileSystemEntryPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 69 | { |
| 70 | JSFileSystemEntryPrototype* ptr = new (NotNull, JSC::allocateCell<JSFileSystemEntryPrototype>(vm.heap)) JSFileSystemEntryPrototype(vm, globalObject, structure); |
| 71 | ptr->finishCreation(vm); |
| 72 | return ptr; |
| 73 | } |
| 74 | |
| 75 | DECLARE_INFO; |
| 76 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 77 | { |
| 78 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 79 | } |
| 80 | |
| 81 | private: |
| 82 | JSFileSystemEntryPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 83 | : JSC::JSNonFinalObject(vm, structure) |
| 84 | { |
| 85 | } |
| 86 | |
| 87 | void finishCreation(JSC::VM&); |
| 88 | }; |
| 89 | |
| 90 | using JSFileSystemEntryConstructor = JSDOMConstructorNotConstructable<JSFileSystemEntry>; |
| 91 | |
| 92 | template<> JSValue JSFileSystemEntryConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 93 | { |
| 94 | UNUSED_PARAM(vm); |
| 95 | return globalObject.functionPrototype(); |
| 96 | } |
| 97 | |
| 98 | template<> void JSFileSystemEntryConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 99 | { |
| 100 | putDirect(vm, vm.propertyNames->prototype, JSFileSystemEntry::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 101 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("FileSystemEntry"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 102 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 103 | } |
| 104 | |
| 105 | template<> const ClassInfo JSFileSystemEntryConstructor::s_info = { "FileSystemEntry" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFileSystemEntryConstructor) }; |
| 106 | |
| 107 | /* Hash table for prototype */ |
| 108 | |
| 109 | static const HashTableValue JSFileSystemEntryPrototypeTableValues[] = |
| 110 | { |
| 111 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileSystemEntryConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFileSystemEntryConstructor) } }, |
| 112 | { "isFile" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileSystemEntryIsFile), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 113 | { "isDirectory" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileSystemEntryIsDirectory), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 114 | { "name" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileSystemEntryName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 115 | { "fullPath" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileSystemEntryFullPath), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 116 | { "filesystem" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileSystemEntryFilesystem), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 117 | { "getParent" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFileSystemEntryPrototypeFunctionGetParent), (intptr_t) (0) } }, |
| 118 | }; |
| 119 | |
| 120 | const ClassInfo JSFileSystemEntryPrototype::s_info = { "FileSystemEntryPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFileSystemEntryPrototype) }; |
| 121 | |
| 122 | void JSFileSystemEntryPrototype::finishCreation(VM& vm) |
| 123 | { |
| 124 | Base::finishCreation(vm); |
| 125 | reifyStaticProperties(vm, JSFileSystemEntry::info(), JSFileSystemEntryPrototypeTableValues, *this); |
| 126 | } |
| 127 | |
| 128 | const ClassInfo JSFileSystemEntry::s_info = { "FileSystemEntry" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFileSystemEntry) }; |
| 129 | |
| 130 | JSFileSystemEntry::JSFileSystemEntry(Structure* structure, JSDOMGlobalObject& globalObject, Ref<FileSystemEntry>&& impl) |
| 131 | : JSDOMWrapper<FileSystemEntry>(structure, globalObject, WTFMove(impl)) |
| 132 | { |
| 133 | } |
| 134 | |
| 135 | void JSFileSystemEntry::finishCreation(VM& vm) |
| 136 | { |
| 137 | Base::finishCreation(vm); |
| 138 | ASSERT(inherits(vm, info())); |
| 139 | |
| 140 | } |
| 141 | |
| 142 | JSObject* JSFileSystemEntry::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 143 | { |
| 144 | return JSFileSystemEntryPrototype::create(vm, &globalObject, JSFileSystemEntryPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 145 | } |
| 146 | |
| 147 | JSObject* JSFileSystemEntry::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 148 | { |
| 149 | return getDOMPrototype<JSFileSystemEntry>(vm, globalObject); |
| 150 | } |
| 151 | |
| 152 | JSValue JSFileSystemEntry::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 153 | { |
| 154 | return getDOMConstructor<JSFileSystemEntryConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 155 | } |
| 156 | |
| 157 | void JSFileSystemEntry::destroy(JSC::JSCell* cell) |
| 158 | { |
| 159 | JSFileSystemEntry* thisObject = static_cast<JSFileSystemEntry*>(cell); |
| 160 | thisObject->JSFileSystemEntry::~JSFileSystemEntry(); |
| 161 | } |
| 162 | |
| 163 | template<> inline JSFileSystemEntry* IDLAttribute<JSFileSystemEntry>::cast(ExecState& state, EncodedJSValue thisValue) |
| 164 | { |
| 165 | return jsDynamicCast<JSFileSystemEntry*>(state.vm(), JSValue::decode(thisValue)); |
| 166 | } |
| 167 | |
| 168 | template<> inline JSFileSystemEntry* IDLOperation<JSFileSystemEntry>::cast(ExecState& state) |
| 169 | { |
| 170 | return jsDynamicCast<JSFileSystemEntry*>(state.vm(), state.thisValue()); |
| 171 | } |
| 172 | |
| 173 | EncodedJSValue jsFileSystemEntryConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 174 | { |
| 175 | VM& vm = state->vm(); |
| 176 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 177 | auto* prototype = jsDynamicCast<JSFileSystemEntryPrototype*>(vm, JSValue::decode(thisValue)); |
| 178 | if (UNLIKELY(!prototype)) |
| 179 | return throwVMTypeError(state, throwScope); |
| 180 | return JSValue::encode(JSFileSystemEntry::getConstructor(state->vm(), prototype->globalObject())); |
| 181 | } |
| 182 | |
| 183 | bool setJSFileSystemEntryConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 184 | { |
| 185 | VM& vm = state->vm(); |
| 186 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 187 | auto* prototype = jsDynamicCast<JSFileSystemEntryPrototype*>(vm, JSValue::decode(thisValue)); |
| 188 | if (UNLIKELY(!prototype)) { |
| 189 | throwVMTypeError(state, throwScope); |
| 190 | return false; |
| 191 | } |
| 192 | // Shadowing a built-in constructor |
| 193 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 194 | } |
| 195 | |
| 196 | static inline JSValue jsFileSystemEntryIsFileGetter(ExecState& state, JSFileSystemEntry& thisObject, ThrowScope& throwScope) |
| 197 | { |
| 198 | UNUSED_PARAM(throwScope); |
| 199 | UNUSED_PARAM(state); |
| 200 | auto& impl = thisObject.wrapped(); |
| 201 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.isFile()); |
| 202 | return result; |
| 203 | } |
| 204 | |
| 205 | EncodedJSValue jsFileSystemEntryIsFile(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 206 | { |
| 207 | return IDLAttribute<JSFileSystemEntry>::get<jsFileSystemEntryIsFileGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "isFile" ); |
| 208 | } |
| 209 | |
| 210 | static inline JSValue jsFileSystemEntryIsDirectoryGetter(ExecState& state, JSFileSystemEntry& thisObject, ThrowScope& throwScope) |
| 211 | { |
| 212 | UNUSED_PARAM(throwScope); |
| 213 | UNUSED_PARAM(state); |
| 214 | auto& impl = thisObject.wrapped(); |
| 215 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.isDirectory()); |
| 216 | return result; |
| 217 | } |
| 218 | |
| 219 | EncodedJSValue jsFileSystemEntryIsDirectory(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 220 | { |
| 221 | return IDLAttribute<JSFileSystemEntry>::get<jsFileSystemEntryIsDirectoryGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "isDirectory" ); |
| 222 | } |
| 223 | |
| 224 | static inline JSValue jsFileSystemEntryNameGetter(ExecState& state, JSFileSystemEntry& thisObject, ThrowScope& throwScope) |
| 225 | { |
| 226 | UNUSED_PARAM(throwScope); |
| 227 | UNUSED_PARAM(state); |
| 228 | auto& impl = thisObject.wrapped(); |
| 229 | JSValue result = toJS<IDLUSVString>(state, throwScope, impl.name()); |
| 230 | return result; |
| 231 | } |
| 232 | |
| 233 | EncodedJSValue jsFileSystemEntryName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 234 | { |
| 235 | return IDLAttribute<JSFileSystemEntry>::get<jsFileSystemEntryNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "name" ); |
| 236 | } |
| 237 | |
| 238 | static inline JSValue jsFileSystemEntryFullPathGetter(ExecState& state, JSFileSystemEntry& thisObject, ThrowScope& throwScope) |
| 239 | { |
| 240 | UNUSED_PARAM(throwScope); |
| 241 | UNUSED_PARAM(state); |
| 242 | auto& impl = thisObject.wrapped(); |
| 243 | JSValue result = toJS<IDLUSVString>(state, throwScope, impl.virtualPath()); |
| 244 | return result; |
| 245 | } |
| 246 | |
| 247 | EncodedJSValue jsFileSystemEntryFullPath(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 248 | { |
| 249 | return IDLAttribute<JSFileSystemEntry>::get<jsFileSystemEntryFullPathGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "fullPath" ); |
| 250 | } |
| 251 | |
| 252 | static inline JSValue jsFileSystemEntryFilesystemGetter(ExecState& state, JSFileSystemEntry& thisObject, ThrowScope& throwScope) |
| 253 | { |
| 254 | UNUSED_PARAM(throwScope); |
| 255 | UNUSED_PARAM(state); |
| 256 | auto& impl = thisObject.wrapped(); |
| 257 | JSValue result = toJS<IDLInterface<DOMFileSystem>>(state, *thisObject.globalObject(), throwScope, impl.filesystem()); |
| 258 | return result; |
| 259 | } |
| 260 | |
| 261 | EncodedJSValue jsFileSystemEntryFilesystem(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 262 | { |
| 263 | return IDLAttribute<JSFileSystemEntry>::get<jsFileSystemEntryFilesystemGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "filesystem" ); |
| 264 | } |
| 265 | |
| 266 | static inline JSC::EncodedJSValue jsFileSystemEntryPrototypeFunctionGetParentBody(JSC::ExecState* state, typename IDLOperation<JSFileSystemEntry>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 267 | { |
| 268 | UNUSED_PARAM(state); |
| 269 | UNUSED_PARAM(throwScope); |
| 270 | auto& impl = castedThis->wrapped(); |
| 271 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
| 272 | if (UNLIKELY(!context)) |
| 273 | return JSValue::encode(jsUndefined()); |
| 274 | auto successCallback = convert<IDLNullable<IDLCallbackFunction<JSFileSystemEntryCallback>>>(*state, state->argument(0), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 0, "successCallback" , "FileSystemEntry" , "getParent" ); }); |
| 275 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 276 | auto errorCallback = convert<IDLNullable<IDLCallbackFunction<JSErrorCallback>>>(*state, state->argument(1), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 1, "errorCallback" , "FileSystemEntry" , "getParent" ); }); |
| 277 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 278 | impl.getParent(*context, WTFMove(successCallback), WTFMove(errorCallback)); |
| 279 | return JSValue::encode(jsUndefined()); |
| 280 | } |
| 281 | |
| 282 | EncodedJSValue JSC_HOST_CALL jsFileSystemEntryPrototypeFunctionGetParent(ExecState* state) |
| 283 | { |
| 284 | return IDLOperation<JSFileSystemEntry>::call<jsFileSystemEntryPrototypeFunctionGetParentBody>(*state, "getParent" ); |
| 285 | } |
| 286 | |
| 287 | void JSFileSystemEntry::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 288 | { |
| 289 | auto* thisObject = jsCast<JSFileSystemEntry*>(cell); |
| 290 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 291 | if (thisObject->scriptExecutionContext()) |
| 292 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 293 | Base::heapSnapshot(cell, builder); |
| 294 | } |
| 295 | |
| 296 | bool JSFileSystemEntryOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 297 | { |
| 298 | UNUSED_PARAM(handle); |
| 299 | UNUSED_PARAM(visitor); |
| 300 | UNUSED_PARAM(reason); |
| 301 | return false; |
| 302 | } |
| 303 | |
| 304 | void JSFileSystemEntryOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 305 | { |
| 306 | auto* jsFileSystemEntry = static_cast<JSFileSystemEntry*>(handle.slot()->asCell()); |
| 307 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 308 | uncacheWrapper(world, &jsFileSystemEntry->wrapped(), jsFileSystemEntry); |
| 309 | } |
| 310 | |
| 311 | FileSystemEntry* JSFileSystemEntry::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 312 | { |
| 313 | if (auto* wrapper = jsDynamicCast<JSFileSystemEntry*>(vm, value)) |
| 314 | return &wrapper->wrapped(); |
| 315 | return nullptr; |
| 316 | } |
| 317 | |
| 318 | } |
| 319 | |