| 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 "JSFileSystemDirectoryReader.h" |
| 23 | |
| 24 | #include "JSDOMBinding.h" |
| 25 | #include "JSDOMConstructorNotConstructable.h" |
| 26 | #include "JSDOMConvertCallbacks.h" |
| 27 | #include "JSDOMConvertNullable.h" |
| 28 | #include "JSDOMExceptionHandling.h" |
| 29 | #include "JSDOMGlobalObject.h" |
| 30 | #include "JSDOMOperation.h" |
| 31 | #include "JSDOMWrapperCache.h" |
| 32 | #include "JSErrorCallback.h" |
| 33 | #include "JSFileSystemEntriesCallback.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 jsFileSystemDirectoryReaderPrototypeFunctionReadEntries(JSC::ExecState*); |
| 49 | |
| 50 | // Attributes |
| 51 | |
| 52 | JSC::EncodedJSValue jsFileSystemDirectoryReaderConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 53 | bool setJSFileSystemDirectoryReaderConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 54 | |
| 55 | class JSFileSystemDirectoryReaderPrototype : public JSC::JSNonFinalObject { |
| 56 | public: |
| 57 | using Base = JSC::JSNonFinalObject; |
| 58 | static JSFileSystemDirectoryReaderPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 59 | { |
| 60 | JSFileSystemDirectoryReaderPrototype* ptr = new (NotNull, JSC::allocateCell<JSFileSystemDirectoryReaderPrototype>(vm.heap)) JSFileSystemDirectoryReaderPrototype(vm, globalObject, structure); |
| 61 | ptr->finishCreation(vm); |
| 62 | return ptr; |
| 63 | } |
| 64 | |
| 65 | DECLARE_INFO; |
| 66 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 67 | { |
| 68 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 69 | } |
| 70 | |
| 71 | private: |
| 72 | JSFileSystemDirectoryReaderPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 73 | : JSC::JSNonFinalObject(vm, structure) |
| 74 | { |
| 75 | } |
| 76 | |
| 77 | void finishCreation(JSC::VM&); |
| 78 | }; |
| 79 | |
| 80 | using JSFileSystemDirectoryReaderConstructor = JSDOMConstructorNotConstructable<JSFileSystemDirectoryReader>; |
| 81 | |
| 82 | template<> JSValue JSFileSystemDirectoryReaderConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 83 | { |
| 84 | UNUSED_PARAM(vm); |
| 85 | return globalObject.functionPrototype(); |
| 86 | } |
| 87 | |
| 88 | template<> void JSFileSystemDirectoryReaderConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 89 | { |
| 90 | putDirect(vm, vm.propertyNames->prototype, JSFileSystemDirectoryReader::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 91 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("FileSystemDirectoryReader"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 92 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 93 | } |
| 94 | |
| 95 | template<> const ClassInfo JSFileSystemDirectoryReaderConstructor::s_info = { "FileSystemDirectoryReader" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFileSystemDirectoryReaderConstructor) }; |
| 96 | |
| 97 | /* Hash table for prototype */ |
| 98 | |
| 99 | static const HashTableValue JSFileSystemDirectoryReaderPrototypeTableValues[] = |
| 100 | { |
| 101 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileSystemDirectoryReaderConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFileSystemDirectoryReaderConstructor) } }, |
| 102 | { "readEntries" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsFileSystemDirectoryReaderPrototypeFunctionReadEntries), (intptr_t) (1) } }, |
| 103 | }; |
| 104 | |
| 105 | const ClassInfo JSFileSystemDirectoryReaderPrototype::s_info = { "FileSystemDirectoryReaderPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFileSystemDirectoryReaderPrototype) }; |
| 106 | |
| 107 | void JSFileSystemDirectoryReaderPrototype::finishCreation(VM& vm) |
| 108 | { |
| 109 | Base::finishCreation(vm); |
| 110 | reifyStaticProperties(vm, JSFileSystemDirectoryReader::info(), JSFileSystemDirectoryReaderPrototypeTableValues, *this); |
| 111 | } |
| 112 | |
| 113 | const ClassInfo JSFileSystemDirectoryReader::s_info = { "FileSystemDirectoryReader" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFileSystemDirectoryReader) }; |
| 114 | |
| 115 | JSFileSystemDirectoryReader::JSFileSystemDirectoryReader(Structure* structure, JSDOMGlobalObject& globalObject, Ref<FileSystemDirectoryReader>&& impl) |
| 116 | : JSDOMWrapper<FileSystemDirectoryReader>(structure, globalObject, WTFMove(impl)) |
| 117 | { |
| 118 | } |
| 119 | |
| 120 | void JSFileSystemDirectoryReader::finishCreation(VM& vm) |
| 121 | { |
| 122 | Base::finishCreation(vm); |
| 123 | ASSERT(inherits(vm, info())); |
| 124 | |
| 125 | } |
| 126 | |
| 127 | JSObject* JSFileSystemDirectoryReader::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 128 | { |
| 129 | return JSFileSystemDirectoryReaderPrototype::create(vm, &globalObject, JSFileSystemDirectoryReaderPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 130 | } |
| 131 | |
| 132 | JSObject* JSFileSystemDirectoryReader::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 133 | { |
| 134 | return getDOMPrototype<JSFileSystemDirectoryReader>(vm, globalObject); |
| 135 | } |
| 136 | |
| 137 | JSValue JSFileSystemDirectoryReader::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 138 | { |
| 139 | return getDOMConstructor<JSFileSystemDirectoryReaderConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 140 | } |
| 141 | |
| 142 | void JSFileSystemDirectoryReader::destroy(JSC::JSCell* cell) |
| 143 | { |
| 144 | JSFileSystemDirectoryReader* thisObject = static_cast<JSFileSystemDirectoryReader*>(cell); |
| 145 | thisObject->JSFileSystemDirectoryReader::~JSFileSystemDirectoryReader(); |
| 146 | } |
| 147 | |
| 148 | template<> inline JSFileSystemDirectoryReader* IDLOperation<JSFileSystemDirectoryReader>::cast(ExecState& state) |
| 149 | { |
| 150 | return jsDynamicCast<JSFileSystemDirectoryReader*>(state.vm(), state.thisValue()); |
| 151 | } |
| 152 | |
| 153 | EncodedJSValue jsFileSystemDirectoryReaderConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 154 | { |
| 155 | VM& vm = state->vm(); |
| 156 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 157 | auto* prototype = jsDynamicCast<JSFileSystemDirectoryReaderPrototype*>(vm, JSValue::decode(thisValue)); |
| 158 | if (UNLIKELY(!prototype)) |
| 159 | return throwVMTypeError(state, throwScope); |
| 160 | return JSValue::encode(JSFileSystemDirectoryReader::getConstructor(state->vm(), prototype->globalObject())); |
| 161 | } |
| 162 | |
| 163 | bool setJSFileSystemDirectoryReaderConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 164 | { |
| 165 | VM& vm = state->vm(); |
| 166 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 167 | auto* prototype = jsDynamicCast<JSFileSystemDirectoryReaderPrototype*>(vm, JSValue::decode(thisValue)); |
| 168 | if (UNLIKELY(!prototype)) { |
| 169 | throwVMTypeError(state, throwScope); |
| 170 | return false; |
| 171 | } |
| 172 | // Shadowing a built-in constructor |
| 173 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 174 | } |
| 175 | |
| 176 | static inline JSC::EncodedJSValue jsFileSystemDirectoryReaderPrototypeFunctionReadEntriesBody(JSC::ExecState* state, typename IDLOperation<JSFileSystemDirectoryReader>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 177 | { |
| 178 | UNUSED_PARAM(state); |
| 179 | UNUSED_PARAM(throwScope); |
| 180 | auto& impl = castedThis->wrapped(); |
| 181 | if (UNLIKELY(state->argumentCount() < 1)) |
| 182 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 183 | auto* context = jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject())->scriptExecutionContext(); |
| 184 | if (UNLIKELY(!context)) |
| 185 | return JSValue::encode(jsUndefined()); |
| 186 | auto successCallback = convert<IDLCallbackFunction<JSFileSystemEntriesCallback>>(*state, state->uncheckedArgument(0), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 0, "successCallback" , "FileSystemDirectoryReader" , "readEntries" ); }); |
| 187 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 188 | auto errorCallback = convert<IDLNullable<IDLCallbackFunction<JSErrorCallback>>>(*state, state->argument(1), *castedThis->globalObject(), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentMustBeFunctionError(state, scope, 1, "errorCallback" , "FileSystemDirectoryReader" , "readEntries" ); }); |
| 189 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 190 | impl.readEntries(*context, successCallback.releaseNonNull(), WTFMove(errorCallback)); |
| 191 | return JSValue::encode(jsUndefined()); |
| 192 | } |
| 193 | |
| 194 | EncodedJSValue JSC_HOST_CALL jsFileSystemDirectoryReaderPrototypeFunctionReadEntries(ExecState* state) |
| 195 | { |
| 196 | return IDLOperation<JSFileSystemDirectoryReader>::call<jsFileSystemDirectoryReaderPrototypeFunctionReadEntriesBody>(*state, "readEntries" ); |
| 197 | } |
| 198 | |
| 199 | void JSFileSystemDirectoryReader::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 200 | { |
| 201 | auto* thisObject = jsCast<JSFileSystemDirectoryReader*>(cell); |
| 202 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 203 | if (thisObject->scriptExecutionContext()) |
| 204 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 205 | Base::heapSnapshot(cell, builder); |
| 206 | } |
| 207 | |
| 208 | bool JSFileSystemDirectoryReaderOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 209 | { |
| 210 | UNUSED_PARAM(handle); |
| 211 | UNUSED_PARAM(visitor); |
| 212 | UNUSED_PARAM(reason); |
| 213 | return false; |
| 214 | } |
| 215 | |
| 216 | void JSFileSystemDirectoryReaderOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 217 | { |
| 218 | auto* jsFileSystemDirectoryReader = static_cast<JSFileSystemDirectoryReader*>(handle.slot()->asCell()); |
| 219 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 220 | uncacheWrapper(world, &jsFileSystemDirectoryReader->wrapped(), jsFileSystemDirectoryReader); |
| 221 | } |
| 222 | |
| 223 | #if ENABLE(BINDING_INTEGRITY) |
| 224 | #if PLATFORM(WIN) |
| 225 | #pragma warning(disable: 4483) |
| 226 | extern "C" { extern void (*const __identifier("??_7FileSystemDirectoryReader@WebCore@@6B@" )[])(); } |
| 227 | #else |
| 228 | extern "C" { extern void* _ZTVN7WebCore25FileSystemDirectoryReaderE[]; } |
| 229 | #endif |
| 230 | #endif |
| 231 | |
| 232 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<FileSystemDirectoryReader>&& impl) |
| 233 | { |
| 234 | |
| 235 | #if ENABLE(BINDING_INTEGRITY) |
| 236 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
| 237 | #if PLATFORM(WIN) |
| 238 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7FileSystemDirectoryReader@WebCore@@6B@" )); |
| 239 | #else |
| 240 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore25FileSystemDirectoryReaderE[2]); |
| 241 | #endif |
| 242 | |
| 243 | // If this fails FileSystemDirectoryReader does not have a vtable, so you need to add the |
| 244 | // ImplementationLacksVTable attribute to the interface definition |
| 245 | static_assert(std::is_polymorphic<FileSystemDirectoryReader>::value, "FileSystemDirectoryReader is not polymorphic" ); |
| 246 | |
| 247 | // If you hit this assertion you either have a use after free bug, or |
| 248 | // FileSystemDirectoryReader has subclasses. If FileSystemDirectoryReader has subclasses that get passed |
| 249 | // to toJS() we currently require FileSystemDirectoryReader you to opt out of binding hardening |
| 250 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
| 251 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
| 252 | #endif |
| 253 | return createWrapper<FileSystemDirectoryReader>(globalObject, WTFMove(impl)); |
| 254 | } |
| 255 | |
| 256 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, FileSystemDirectoryReader& impl) |
| 257 | { |
| 258 | return wrap(state, globalObject, impl); |
| 259 | } |
| 260 | |
| 261 | FileSystemDirectoryReader* JSFileSystemDirectoryReader::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 262 | { |
| 263 | if (auto* wrapper = jsDynamicCast<JSFileSystemDirectoryReader*>(vm, value)) |
| 264 | return &wrapper->wrapped(); |
| 265 | return nullptr; |
| 266 | } |
| 267 | |
| 268 | } |
| 269 | |