| /* |
| This file is part of the WebKit open source project. |
| This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| |
| This library is free software; you can redistribute it and/or |
| modify it under the terms of the GNU Library General Public |
| License as published by the Free Software Foundation; either |
| version 2 of the License, or (at your option) any later version. |
| |
| This library is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| Library General Public License for more details. |
| |
| You should have received a copy of the GNU Library General Public License |
| along with this library; see the file COPYING.LIB. If not, write to |
| the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| Boston, MA 02110-1301, USA. |
| */ |
| |
| #include "config.h" |
| #include "JSDOMCoreException.h" |
| |
| #include "ExceptionCode.h" |
| #include "JSDOMBinding.h" |
| #include "JSDOMConstructor.h" |
| #include "URL.h" |
| #include <runtime/Error.h> |
| #include <runtime/FunctionPrototype.h> |
| #include <runtime/JSString.h> |
| #include <wtf/GetPtr.h> |
| |
| using namespace JSC; |
| |
| namespace WebCore { |
| |
| // Functions |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsDOMCoreExceptionPrototypeFunctionToString(JSC::ExecState*); |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsDOMCoreExceptionCode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsDOMCoreExceptionName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsDOMCoreExceptionMessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsDOMCoreExceptionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSDOMCoreExceptionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSDOMCoreExceptionPrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSDOMCoreExceptionPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSDOMCoreExceptionPrototype* ptr = new (NotNull, JSC::allocateCell<JSDOMCoreExceptionPrototype>(vm.heap)) JSDOMCoreExceptionPrototype(vm, globalObject, structure); |
| ptr->finishCreation(vm); |
| return ptr; |
| } |
| |
| DECLARE_INFO; |
| static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| { |
| return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| } |
| |
| private: |
| JSDOMCoreExceptionPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| typedef JSDOMConstructor<JSDOMCoreException> JSDOMCoreExceptionConstructor; |
| |
| /* Hash table */ |
| |
| static const struct CompactHashIndex JSDOMCoreExceptionTableIndex[9] = { |
| { -1, -1 }, |
| { 0, 8 }, |
| { -1, -1 }, |
| { -1, -1 }, |
| { -1, -1 }, |
| { -1, -1 }, |
| { -1, -1 }, |
| { 2, -1 }, |
| { 1, -1 }, |
| }; |
| |
| |
| static const HashTableValue JSDOMCoreExceptionTableValues[] = |
| { |
| { "code", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMCoreExceptionCode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "name", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMCoreExceptionName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "message", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMCoreExceptionMessage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| }; |
| |
| static const HashTable JSDOMCoreExceptionTable = { 3, 7, true, JSDOMCoreExceptionTableValues, JSDOMCoreExceptionTableIndex }; |
| /* Hash table for constructor */ |
| |
| static const HashTableValue JSDOMCoreExceptionConstructorTableValues[] = |
| { |
| { "INDEX_SIZE_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
| { "DOMSTRING_SIZE_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
| { "HIERARCHY_REQUEST_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
| { "WRONG_DOCUMENT_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(4) } }, |
| { "INVALID_CHARACTER_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(5) } }, |
| { "NO_DATA_ALLOWED_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(6) } }, |
| { "NO_MODIFICATION_ALLOWED_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(7) } }, |
| { "NOT_FOUND_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(8) } }, |
| { "NOT_SUPPORTED_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(9) } }, |
| { "INUSE_ATTRIBUTE_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(10) } }, |
| { "INVALID_STATE_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(11) } }, |
| { "SYNTAX_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(12) } }, |
| { "INVALID_MODIFICATION_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(13) } }, |
| { "NAMESPACE_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(14) } }, |
| { "INVALID_ACCESS_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(15) } }, |
| { "VALIDATION_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(16) } }, |
| { "TYPE_MISMATCH_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(17) } }, |
| { "SECURITY_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(18) } }, |
| { "NETWORK_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(19) } }, |
| { "ABORT_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(20) } }, |
| { "URL_MISMATCH_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(21) } }, |
| { "QUOTA_EXCEEDED_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(22) } }, |
| { "TIMEOUT_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(23) } }, |
| { "INVALID_NODE_TYPE_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(24) } }, |
| { "DATA_CLONE_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(25) } }, |
| }; |
| |
| template<> EncodedJSValue JSC_HOST_CALL JSDOMCoreExceptionConstructor::construct(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| auto* castedThis = jsCast<JSDOMCoreExceptionConstructor*>(state->callee()); |
| ASSERT(castedThis); |
| auto message = state->argument(0).isUndefined() ? emptyString() : state->uncheckedArgument(0).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto name = state->argument(1).isUndefined() ? ASCIILiteral("Error") : state->uncheckedArgument(1).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto object = DOMCoreException::create(WTFMove(message), WTFMove(name)); |
| return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object))); |
| } |
| |
| template<> JSValue JSDOMCoreExceptionConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| { |
| UNUSED_PARAM(vm); |
| return globalObject.functionPrototype(); |
| } |
| |
| template<> void JSDOMCoreExceptionConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| { |
| putDirect(vm, vm.propertyNames->prototype, JSDOMCoreException::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("DOMException"))), ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum); |
| reifyStaticProperties(vm, JSDOMCoreExceptionConstructorTableValues, *this); |
| } |
| |
| template<> const ClassInfo JSDOMCoreExceptionConstructor::s_info = { "DOMException", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDOMCoreExceptionConstructor) }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSDOMCoreExceptionPrototypeTableValues[] = |
| { |
| { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMCoreExceptionConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMCoreExceptionConstructor) } }, |
| { "toString", DontEnum | JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDOMCoreExceptionPrototypeFunctionToString), (intptr_t) (0) } }, |
| { "INDEX_SIZE_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
| { "DOMSTRING_SIZE_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
| { "HIERARCHY_REQUEST_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
| { "WRONG_DOCUMENT_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(4) } }, |
| { "INVALID_CHARACTER_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(5) } }, |
| { "NO_DATA_ALLOWED_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(6) } }, |
| { "NO_MODIFICATION_ALLOWED_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(7) } }, |
| { "NOT_FOUND_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(8) } }, |
| { "NOT_SUPPORTED_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(9) } }, |
| { "INUSE_ATTRIBUTE_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(10) } }, |
| { "INVALID_STATE_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(11) } }, |
| { "SYNTAX_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(12) } }, |
| { "INVALID_MODIFICATION_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(13) } }, |
| { "NAMESPACE_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(14) } }, |
| { "INVALID_ACCESS_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(15) } }, |
| { "VALIDATION_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(16) } }, |
| { "TYPE_MISMATCH_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(17) } }, |
| { "SECURITY_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(18) } }, |
| { "NETWORK_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(19) } }, |
| { "ABORT_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(20) } }, |
| { "URL_MISMATCH_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(21) } }, |
| { "QUOTA_EXCEEDED_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(22) } }, |
| { "TIMEOUT_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(23) } }, |
| { "INVALID_NODE_TYPE_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(24) } }, |
| { "DATA_CLONE_ERR", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(25) } }, |
| }; |
| |
| const ClassInfo JSDOMCoreExceptionPrototype::s_info = { "DOMExceptionPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDOMCoreExceptionPrototype) }; |
| |
| void JSDOMCoreExceptionPrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSDOMCoreExceptionPrototypeTableValues, *this); |
| } |
| |
| const ClassInfo JSDOMCoreException::s_info = { "DOMException", &Base::s_info, &JSDOMCoreExceptionTable, CREATE_METHOD_TABLE(JSDOMCoreException) }; |
| |
| JSDOMCoreException::JSDOMCoreException(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DOMCoreException>&& impl) |
| : JSDOMWrapper<DOMCoreException>(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSDOMCoreException::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSDOMCoreExceptionPrototype::create(vm, globalObject, JSDOMCoreExceptionPrototype::createStructure(vm, globalObject, globalObject->errorPrototype())); |
| } |
| |
| JSObject* JSDOMCoreException::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSDOMCoreException>(vm, globalObject); |
| } |
| |
| void JSDOMCoreException::destroy(JSC::JSCell* cell) |
| { |
| JSDOMCoreException* thisObject = static_cast<JSDOMCoreException*>(cell); |
| thisObject->JSDOMCoreException::~JSDOMCoreException(); |
| } |
| |
| EncodedJSValue jsDOMCoreExceptionCode(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSDOMCoreException*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "DOMException", "code"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsNumber(impl.code()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsDOMCoreExceptionName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSDOMCoreException*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "DOMException", "name"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.name()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsDOMCoreExceptionMessage(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSDOMCoreException*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "DOMException", "message"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.message()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsDOMCoreExceptionConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSDOMCoreExceptionPrototype* domObject = jsDynamicCast<JSDOMCoreExceptionPrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) |
| return throwVMTypeError(state, throwScope); |
| return JSValue::encode(JSDOMCoreException::getConstructor(state->vm(), domObject->globalObject())); |
| } |
| |
| bool setJSDOMCoreExceptionConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSDOMCoreExceptionPrototype* domObject = jsDynamicCast<JSDOMCoreExceptionPrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) { |
| throwVMTypeError(state, throwScope); |
| return false; |
| } |
| // Shadowing a built-in constructor |
| return domObject->putDirect(state->vm(), state->propertyNames().constructor, value); |
| } |
| |
| JSValue JSDOMCoreException::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| { |
| return getDOMConstructor<JSDOMCoreExceptionConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsDOMCoreExceptionPrototypeFunctionToString(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSDOMCoreException*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "DOMException", "toString"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMCoreException::info()); |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.toString()); |
| return JSValue::encode(result); |
| } |
| |
| bool JSDOMCoreExceptionOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor) |
| { |
| UNUSED_PARAM(handle); |
| UNUSED_PARAM(visitor); |
| return false; |
| } |
| |
| void JSDOMCoreExceptionOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| { |
| auto* jsDOMCoreException = jsCast<JSDOMCoreException*>(handle.slot()->asCell()); |
| auto& world = *static_cast<DOMWrapperWorld*>(context); |
| uncacheWrapper(world, &jsDOMCoreException->wrapped(), jsDOMCoreException); |
| } |
| |
| JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<DOMCoreException>&& impl) |
| { |
| #if COMPILER(CLANG) |
| // If you hit this failure the interface definition has the ImplementationLacksVTable |
| // attribute. You should remove that attribute. If the class has subclasses |
| // that may be passed through this toJS() function you should use the SkipVTableValidation |
| // attribute to DOMCoreException. |
| static_assert(!__is_polymorphic(DOMCoreException), "DOMCoreException is polymorphic but the IDL claims it is not"); |
| #endif |
| return createWrapper<DOMCoreException>(globalObject, WTFMove(impl)); |
| } |
| |
| JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DOMCoreException& impl) |
| { |
| return wrap(state, globalObject, impl); |
| } |
| |
| DOMCoreException* JSDOMCoreException::toWrapped(JSC::JSValue value) |
| { |
| if (auto* wrapper = jsDynamicCast<JSDOMCoreException*>(value)) |
| return &wrapper->wrapped(); |
| return nullptr; |
| } |
| |
| } |