| /* |
| 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 "JSHashChangeEvent.h" |
| |
| #include "ExceptionCode.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 { |
| |
| // Functions |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsHashChangeEventPrototypeFunctionInitHashChangeEvent(JSC::ExecState*); |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsHashChangeEventOldURL(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsHashChangeEventNewURL(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsHashChangeEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSHashChangeEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSHashChangeEventPrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSHashChangeEventPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSHashChangeEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSHashChangeEventPrototype>(vm.heap)) JSHashChangeEventPrototype(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: |
| JSHashChangeEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| typedef JSDOMConstructor<JSHashChangeEvent> JSHashChangeEventConstructor; |
| |
| template<> EncodedJSValue JSC_HOST_CALL JSHashChangeEventConstructor::construct(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| auto* jsConstructor = jsCast<JSHashChangeEventConstructor*>(state->callee()); |
| ASSERT(jsConstructor); |
| |
| if (!jsConstructor->scriptExecutionContext()) |
| return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "HashChangeEvent"); |
| |
| 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()); |
| |
| HashChangeEventInit 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 (!fillHashChangeEventInit(eventInit, dictionary)) |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| Ref<HashChangeEvent> event = HashChangeEvent::createForBindings(eventType, eventInit); |
| return JSValue::encode(createWrapper<HashChangeEvent>(jsConstructor->globalObject(), WTFMove(event))); |
| } |
| |
| bool fillHashChangeEventInit(HashChangeEventInit& eventInit, JSDictionary& dictionary) |
| { |
| if (!fillEventInit(eventInit, dictionary)) |
| return false; |
| |
| if (!dictionary.tryGetProperty("oldURL", eventInit.oldURL)) |
| return false; |
| if (!dictionary.tryGetProperty("newURL", eventInit.newURL)) |
| return false; |
| return true; |
| } |
| |
| template<> JSValue JSHashChangeEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| { |
| return JSEvent::getConstructor(vm, &globalObject); |
| } |
| |
| template<> void JSHashChangeEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| { |
| putDirect(vm, vm.propertyNames->prototype, JSHashChangeEvent::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("HashChangeEvent"))), ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum); |
| } |
| |
| template<> const ClassInfo JSHashChangeEventConstructor::s_info = { "HashChangeEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSHashChangeEventConstructor) }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSHashChangeEventPrototypeTableValues[] = |
| { |
| { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHashChangeEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHashChangeEventConstructor) } }, |
| { "oldURL", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHashChangeEventOldURL), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "newURL", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHashChangeEventNewURL), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "initHashChangeEvent", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsHashChangeEventPrototypeFunctionInitHashChangeEvent), (intptr_t) (0) } }, |
| }; |
| |
| const ClassInfo JSHashChangeEventPrototype::s_info = { "HashChangeEventPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSHashChangeEventPrototype) }; |
| |
| void JSHashChangeEventPrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSHashChangeEventPrototypeTableValues, *this); |
| } |
| |
| const ClassInfo JSHashChangeEvent::s_info = { "HashChangeEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSHashChangeEvent) }; |
| |
| JSHashChangeEvent::JSHashChangeEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<HashChangeEvent>&& impl) |
| : JSEvent(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSHashChangeEvent::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSHashChangeEventPrototype::create(vm, globalObject, JSHashChangeEventPrototype::createStructure(vm, globalObject, JSEvent::prototype(vm, globalObject))); |
| } |
| |
| JSObject* JSHashChangeEvent::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSHashChangeEvent>(vm, globalObject); |
| } |
| |
| EncodedJSValue jsHashChangeEventOldURL(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<JSHashChangeEvent*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "HashChangeEvent", "oldURL"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.oldURL()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsHashChangeEventNewURL(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<JSHashChangeEvent*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "HashChangeEvent", "newURL"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.newURL()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsHashChangeEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSHashChangeEventPrototype* domObject = jsDynamicCast<JSHashChangeEventPrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) |
| return throwVMTypeError(state, throwScope); |
| return JSValue::encode(JSHashChangeEvent::getConstructor(state->vm(), domObject->globalObject())); |
| } |
| |
| bool setJSHashChangeEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSHashChangeEventPrototype* domObject = jsDynamicCast<JSHashChangeEventPrototype*>(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 JSHashChangeEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| { |
| return getDOMConstructor<JSHashChangeEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsHashChangeEventPrototypeFunctionInitHashChangeEvent(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSHashChangeEvent*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "HashChangeEvent", "initHashChangeEvent"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSHashChangeEvent::info()); |
| auto& impl = castedThis->wrapped(); |
| auto type = state->argument(0).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto canBubble = state->argument(1).toBoolean(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto cancelable = state->argument(2).toBoolean(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto oldURL = valueToUSVString(state, state->argument(3)); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto newURL = valueToUSVString(state, state->argument(4)); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| impl.initHashChangeEvent(WTFMove(type), WTFMove(canBubble), WTFMove(cancelable), WTFMove(oldURL), WTFMove(newURL)); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| |
| } |