| /* |
| 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 "JSErrorEvent.h" |
| |
| #include "JSDOMBinding.h" |
| #include "JSDOMConstructor.h" |
| #include "JSDictionary.h" |
| #include "URL.h" |
| #include <runtime/Error.h> |
| #include <runtime/JSString.h> |
| #include <wtf/GetPtr.h> |
| |
| using namespace JSC; |
| |
| namespace WebCore { |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsErrorEventMessage(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsErrorEventFilename(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsErrorEventLineno(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsErrorEventColno(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsErrorEventError(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsErrorEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSErrorEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSErrorEventPrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSErrorEventPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSErrorEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSErrorEventPrototype>(vm.heap)) JSErrorEventPrototype(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: |
| JSErrorEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| typedef JSDOMConstructor<JSErrorEvent> JSErrorEventConstructor; |
| |
| template<> EncodedJSValue JSC_HOST_CALL JSErrorEventConstructor::construct(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| auto* jsConstructor = jsCast<JSErrorEventConstructor*>(state->callee()); |
| ASSERT(jsConstructor); |
| |
| if (!jsConstructor->scriptExecutionContext()) |
| return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "ErrorEvent"); |
| |
| if (UNLIKELY(state->argumentCount() < 1)) |
| return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| |
| AtomicString eventType = state->uncheckedArgument(0).toString(state)->toAtomicString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| |
| ErrorEventInit eventInit; |
| |
| JSValue initializerValue = state->argument(1); |
| if (!initializerValue.isUndefinedOrNull()) { |
| // Given the above test, this will always yield an object. |
| JSObject* initializerObject = initializerValue.toObject(state); |
| ASSERT(!throwScope.exception()); |
| |
| // Create the dictionary wrapper from the initializer object. |
| JSDictionary dictionary(state, initializerObject); |
| |
| // Attempt to fill in the EventInit. |
| if (!fillErrorEventInit(eventInit, dictionary)) |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| Ref<ErrorEvent> event = ErrorEvent::createForBindings(eventType, eventInit); |
| return JSValue::encode(createWrapper<ErrorEvent>(jsConstructor->globalObject(), WTFMove(event))); |
| } |
| |
| bool fillErrorEventInit(ErrorEventInit& eventInit, JSDictionary& dictionary) |
| { |
| if (!fillEventInit(eventInit, dictionary)) |
| return false; |
| |
| if (!dictionary.tryGetProperty("message", eventInit.message)) |
| return false; |
| if (!dictionary.tryGetProperty("filename", eventInit.filename)) |
| return false; |
| if (!dictionary.tryGetProperty("lineno", eventInit.lineno)) |
| return false; |
| if (!dictionary.tryGetProperty("colno", eventInit.colno)) |
| return false; |
| if (!dictionary.tryGetProperty("error", eventInit.error)) |
| return false; |
| return true; |
| } |
| |
| template<> JSValue JSErrorEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| { |
| return JSEvent::getConstructor(vm, &globalObject); |
| } |
| |
| template<> void JSErrorEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| { |
| putDirect(vm, vm.propertyNames->prototype, JSErrorEvent::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("ErrorEvent"))), ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum); |
| } |
| |
| template<> const ClassInfo JSErrorEventConstructor::s_info = { "ErrorEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSErrorEventConstructor) }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSErrorEventPrototypeTableValues[] = |
| { |
| { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsErrorEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSErrorEventConstructor) } }, |
| { "message", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsErrorEventMessage), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "filename", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsErrorEventFilename), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "lineno", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsErrorEventLineno), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "colno", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsErrorEventColno), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "error", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsErrorEventError), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| }; |
| |
| const ClassInfo JSErrorEventPrototype::s_info = { "ErrorEventPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSErrorEventPrototype) }; |
| |
| void JSErrorEventPrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSErrorEventPrototypeTableValues, *this); |
| } |
| |
| const ClassInfo JSErrorEvent::s_info = { "ErrorEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSErrorEvent) }; |
| |
| JSErrorEvent::JSErrorEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<ErrorEvent>&& impl) |
| : JSEvent(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSErrorEvent::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSErrorEventPrototype::create(vm, globalObject, JSErrorEventPrototype::createStructure(vm, globalObject, JSEvent::prototype(vm, globalObject))); |
| } |
| |
| JSObject* JSErrorEvent::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSErrorEvent>(vm, globalObject); |
| } |
| |
| EncodedJSValue jsErrorEventMessage(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<JSErrorEvent*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "ErrorEvent", "message"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.message()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsErrorEventFilename(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<JSErrorEvent*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "ErrorEvent", "filename"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.filename()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsErrorEventLineno(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<JSErrorEvent*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "ErrorEvent", "lineno"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsNumber(impl.lineno()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsErrorEventColno(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<JSErrorEvent*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "ErrorEvent", "colno"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsNumber(impl.colno()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsErrorEventError(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<JSErrorEvent*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "ErrorEvent", "error"); |
| } |
| return JSValue::encode(castedThis->error(*state)); |
| } |
| |
| |
| EncodedJSValue jsErrorEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSErrorEventPrototype* domObject = jsDynamicCast<JSErrorEventPrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) |
| return throwVMTypeError(state, throwScope); |
| return JSValue::encode(JSErrorEvent::getConstructor(state->vm(), domObject->globalObject())); |
| } |
| |
| bool setJSErrorEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSErrorEventPrototype* domObject = jsDynamicCast<JSErrorEventPrototype*>(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 JSErrorEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| { |
| return getDOMConstructor<JSErrorEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| } |
| |
| |
| } |