| 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 "JSFileError.h" |
| 23 | |
| 24 | #include "JSDOMAttribute.h" |
| 25 | #include "JSDOMBinding.h" |
| 26 | #include "JSDOMConstructorNotConstructable.h" |
| 27 | #include "JSDOMConvertNumbers.h" |
| 28 | #include "JSDOMExceptionHandling.h" |
| 29 | #include "JSDOMWrapperCache.h" |
| 30 | #include "ScriptExecutionContext.h" |
| 31 | #include <JavaScriptCore/FunctionPrototype.h> |
| 32 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 33 | #include <JavaScriptCore/JSCInlines.h> |
| 34 | #include <wtf/GetPtr.h> |
| 35 | #include <wtf/PointerPreparations.h> |
| 36 | #include <wtf/URL.h> |
| 37 | |
| 38 | |
| 39 | namespace WebCore { |
| 40 | using namespace JSC; |
| 41 | |
| 42 | // Attributes |
| 43 | |
| 44 | JSC::EncodedJSValue jsFileErrorConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 45 | bool setJSFileErrorConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 46 | JSC::EncodedJSValue jsFileErrorCode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 47 | |
| 48 | class JSFileErrorPrototype : public JSC::JSNonFinalObject { |
| 49 | public: |
| 50 | using Base = JSC::JSNonFinalObject; |
| 51 | static JSFileErrorPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 52 | { |
| 53 | JSFileErrorPrototype* ptr = new (NotNull, JSC::allocateCell<JSFileErrorPrototype>(vm.heap)) JSFileErrorPrototype(vm, globalObject, structure); |
| 54 | ptr->finishCreation(vm); |
| 55 | return ptr; |
| 56 | } |
| 57 | |
| 58 | DECLARE_INFO; |
| 59 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 60 | { |
| 61 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 62 | } |
| 63 | |
| 64 | private: |
| 65 | JSFileErrorPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 66 | : JSC::JSNonFinalObject(vm, structure) |
| 67 | { |
| 68 | } |
| 69 | |
| 70 | void finishCreation(JSC::VM&); |
| 71 | }; |
| 72 | |
| 73 | using JSFileErrorConstructor = JSDOMConstructorNotConstructable<JSFileError>; |
| 74 | |
| 75 | /* Hash table for constructor */ |
| 76 | |
| 77 | static const HashTableValue JSFileErrorConstructorTableValues[] = |
| 78 | { |
| 79 | { "NOT_FOUND_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
| 80 | { "SECURITY_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
| 81 | { "ABORT_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
| 82 | { "NOT_READABLE_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } }, |
| 83 | { "ENCODING_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } }, |
| 84 | { "NO_MODIFICATION_ALLOWED_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(6) } }, |
| 85 | { "INVALID_STATE_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(7) } }, |
| 86 | { "SYNTAX_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } }, |
| 87 | { "INVALID_MODIFICATION_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(9) } }, |
| 88 | { "QUOTA_EXCEEDED_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(10) } }, |
| 89 | { "TYPE_MISMATCH_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(11) } }, |
| 90 | { "PATH_EXISTS_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(12) } }, |
| 91 | }; |
| 92 | |
| 93 | static_assert(FileError::NOT_FOUND_ERR == 1, "NOT_FOUND_ERR in FileError does not match value from IDL" ); |
| 94 | static_assert(FileError::SECURITY_ERR == 2, "SECURITY_ERR in FileError does not match value from IDL" ); |
| 95 | static_assert(FileError::ABORT_ERR == 3, "ABORT_ERR in FileError does not match value from IDL" ); |
| 96 | static_assert(FileError::NOT_READABLE_ERR == 4, "NOT_READABLE_ERR in FileError does not match value from IDL" ); |
| 97 | static_assert(FileError::ENCODING_ERR == 5, "ENCODING_ERR in FileError does not match value from IDL" ); |
| 98 | static_assert(FileError::NO_MODIFICATION_ALLOWED_ERR == 6, "NO_MODIFICATION_ALLOWED_ERR in FileError does not match value from IDL" ); |
| 99 | static_assert(FileError::INVALID_STATE_ERR == 7, "INVALID_STATE_ERR in FileError does not match value from IDL" ); |
| 100 | static_assert(FileError::SYNTAX_ERR == 8, "SYNTAX_ERR in FileError does not match value from IDL" ); |
| 101 | static_assert(FileError::INVALID_MODIFICATION_ERR == 9, "INVALID_MODIFICATION_ERR in FileError does not match value from IDL" ); |
| 102 | static_assert(FileError::QUOTA_EXCEEDED_ERR == 10, "QUOTA_EXCEEDED_ERR in FileError does not match value from IDL" ); |
| 103 | static_assert(FileError::TYPE_MISMATCH_ERR == 11, "TYPE_MISMATCH_ERR in FileError does not match value from IDL" ); |
| 104 | static_assert(FileError::PATH_EXISTS_ERR == 12, "PATH_EXISTS_ERR in FileError does not match value from IDL" ); |
| 105 | |
| 106 | template<> JSValue JSFileErrorConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 107 | { |
| 108 | UNUSED_PARAM(vm); |
| 109 | return globalObject.functionPrototype(); |
| 110 | } |
| 111 | |
| 112 | template<> void JSFileErrorConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 113 | { |
| 114 | putDirect(vm, vm.propertyNames->prototype, JSFileError::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 115 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("FileError"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 116 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 117 | reifyStaticProperties(vm, JSFileError::info(), JSFileErrorConstructorTableValues, *this); |
| 118 | } |
| 119 | |
| 120 | template<> const ClassInfo JSFileErrorConstructor::s_info = { "FileError" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFileErrorConstructor) }; |
| 121 | |
| 122 | /* Hash table for prototype */ |
| 123 | |
| 124 | static const HashTableValue JSFileErrorPrototypeTableValues[] = |
| 125 | { |
| 126 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileErrorConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSFileErrorConstructor) } }, |
| 127 | { "code" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsFileErrorCode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 128 | { "NOT_FOUND_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
| 129 | { "SECURITY_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
| 130 | { "ABORT_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
| 131 | { "NOT_READABLE_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } }, |
| 132 | { "ENCODING_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } }, |
| 133 | { "NO_MODIFICATION_ALLOWED_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(6) } }, |
| 134 | { "INVALID_STATE_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(7) } }, |
| 135 | { "SYNTAX_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } }, |
| 136 | { "INVALID_MODIFICATION_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(9) } }, |
| 137 | { "QUOTA_EXCEEDED_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(10) } }, |
| 138 | { "TYPE_MISMATCH_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(11) } }, |
| 139 | { "PATH_EXISTS_ERR" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(12) } }, |
| 140 | }; |
| 141 | |
| 142 | const ClassInfo JSFileErrorPrototype::s_info = { "FileErrorPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFileErrorPrototype) }; |
| 143 | |
| 144 | void JSFileErrorPrototype::finishCreation(VM& vm) |
| 145 | { |
| 146 | Base::finishCreation(vm); |
| 147 | reifyStaticProperties(vm, JSFileError::info(), JSFileErrorPrototypeTableValues, *this); |
| 148 | } |
| 149 | |
| 150 | const ClassInfo JSFileError::s_info = { "FileError" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFileError) }; |
| 151 | |
| 152 | JSFileError::JSFileError(Structure* structure, JSDOMGlobalObject& globalObject, Ref<FileError>&& impl) |
| 153 | : JSDOMWrapper<FileError>(structure, globalObject, WTFMove(impl)) |
| 154 | { |
| 155 | } |
| 156 | |
| 157 | void JSFileError::finishCreation(VM& vm) |
| 158 | { |
| 159 | Base::finishCreation(vm); |
| 160 | ASSERT(inherits(vm, info())); |
| 161 | |
| 162 | } |
| 163 | |
| 164 | JSObject* JSFileError::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 165 | { |
| 166 | return JSFileErrorPrototype::create(vm, &globalObject, JSFileErrorPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 167 | } |
| 168 | |
| 169 | JSObject* JSFileError::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 170 | { |
| 171 | return getDOMPrototype<JSFileError>(vm, globalObject); |
| 172 | } |
| 173 | |
| 174 | JSValue JSFileError::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 175 | { |
| 176 | return getDOMConstructor<JSFileErrorConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 177 | } |
| 178 | |
| 179 | void JSFileError::destroy(JSC::JSCell* cell) |
| 180 | { |
| 181 | JSFileError* thisObject = static_cast<JSFileError*>(cell); |
| 182 | thisObject->JSFileError::~JSFileError(); |
| 183 | } |
| 184 | |
| 185 | template<> inline JSFileError* IDLAttribute<JSFileError>::cast(ExecState& state, EncodedJSValue thisValue) |
| 186 | { |
| 187 | return jsDynamicCast<JSFileError*>(state.vm(), JSValue::decode(thisValue)); |
| 188 | } |
| 189 | |
| 190 | EncodedJSValue jsFileErrorConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 191 | { |
| 192 | VM& vm = state->vm(); |
| 193 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 194 | auto* prototype = jsDynamicCast<JSFileErrorPrototype*>(vm, JSValue::decode(thisValue)); |
| 195 | if (UNLIKELY(!prototype)) |
| 196 | return throwVMTypeError(state, throwScope); |
| 197 | return JSValue::encode(JSFileError::getConstructor(state->vm(), prototype->globalObject())); |
| 198 | } |
| 199 | |
| 200 | bool setJSFileErrorConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 201 | { |
| 202 | VM& vm = state->vm(); |
| 203 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 204 | auto* prototype = jsDynamicCast<JSFileErrorPrototype*>(vm, JSValue::decode(thisValue)); |
| 205 | if (UNLIKELY(!prototype)) { |
| 206 | throwVMTypeError(state, throwScope); |
| 207 | return false; |
| 208 | } |
| 209 | // Shadowing a built-in constructor |
| 210 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 211 | } |
| 212 | |
| 213 | static inline JSValue jsFileErrorCodeGetter(ExecState& state, JSFileError& thisObject, ThrowScope& throwScope) |
| 214 | { |
| 215 | UNUSED_PARAM(throwScope); |
| 216 | UNUSED_PARAM(state); |
| 217 | auto& impl = thisObject.wrapped(); |
| 218 | JSValue result = toJS<IDLUnsignedShort>(state, throwScope, impl.code()); |
| 219 | return result; |
| 220 | } |
| 221 | |
| 222 | EncodedJSValue jsFileErrorCode(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 223 | { |
| 224 | return IDLAttribute<JSFileError>::get<jsFileErrorCodeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "code" ); |
| 225 | } |
| 226 | |
| 227 | void JSFileError::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 228 | { |
| 229 | auto* thisObject = jsCast<JSFileError*>(cell); |
| 230 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 231 | if (thisObject->scriptExecutionContext()) |
| 232 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 233 | Base::heapSnapshot(cell, builder); |
| 234 | } |
| 235 | |
| 236 | bool JSFileErrorOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 237 | { |
| 238 | UNUSED_PARAM(handle); |
| 239 | UNUSED_PARAM(visitor); |
| 240 | UNUSED_PARAM(reason); |
| 241 | return false; |
| 242 | } |
| 243 | |
| 244 | void JSFileErrorOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 245 | { |
| 246 | auto* jsFileError = static_cast<JSFileError*>(handle.slot()->asCell()); |
| 247 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 248 | uncacheWrapper(world, &jsFileError->wrapped(), jsFileError); |
| 249 | } |
| 250 | |
| 251 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<FileError>&& impl) |
| 252 | { |
| 253 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
| 254 | // attribute. You should remove that attribute. If the class has subclasses |
| 255 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
| 256 | // attribute to FileError. |
| 257 | static_assert(!std::is_polymorphic<FileError>::value, "FileError is polymorphic but the IDL claims it is not" ); |
| 258 | return createWrapper<FileError>(globalObject, WTFMove(impl)); |
| 259 | } |
| 260 | |
| 261 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, FileError& impl) |
| 262 | { |
| 263 | return wrap(state, globalObject, impl); |
| 264 | } |
| 265 | |
| 266 | FileError* JSFileError::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 267 | { |
| 268 | if (auto* wrapper = jsDynamicCast<JSFileError*>(vm, value)) |
| 269 | return &wrapper->wrapped(); |
| 270 | return nullptr; |
| 271 | } |
| 272 | |
| 273 | } |
| 274 | |