EncodedJSValue JSC_HOST_CALL jsTestEventTargetPrototypeFunctionRemoveEventListener(ExecState* state) { JSValue thisValue = state->thisValue(); JSTestEventTarget* castedThis = jsDynamicCast<JSTestEventTarget*>(thisValue); if (UNLIKELY(!castedThis)) return throwThisTypeError(*state, "TestEventTarget", "removeEventListener"); ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestEventTarget::info()); auto& impl = castedThis->wrapped(); JSValue listener = state->argument(1); if (UNLIKELY(!listener.isObject())) return JSValue::encode(jsUndefined()); impl.removeEventListener(state->argument(0).toString(state)->toAtomicString(state), createJSEventListenerForRemove(*state, *asObject(listener), *castedThis).ptr(), state->argument(2).toBoolean(state)); return JSValue::encode(jsUndefined()); }
EncodedJSValue JSC_HOST_CALL jsTestEventTargetPrototypeFunctionItem(ExecState* state) { JSValue thisValue = state->thisValue(); JSTestEventTarget* castedThis = jsDynamicCast<JSTestEventTarget*>(thisValue); if (UNLIKELY(!castedThis)) return throwThisTypeError(*state, "TestEventTarget", "item"); ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestEventTarget::info()); auto& impl = castedThis->wrapped(); if (UNLIKELY(state->argumentCount() < 1)) return throwVMError(state, createNotEnoughArgumentsError(state)); unsigned index = toUInt32(state, state->argument(0), NormalConversion); if (UNLIKELY(state->hadException())) return JSValue::encode(jsUndefined()); JSValue result = toJS(state, castedThis->globalObject(), WTF::getPtr(impl.item(index))); return JSValue::encode(result); }
EncodedJSValue JSC_HOST_CALL jsTestEventTargetPrototypeFunctionDispatchEvent(ExecState* state) { JSValue thisValue = state->thisValue(); JSTestEventTarget* castedThis = jsDynamicCast<JSTestEventTarget*>(thisValue); if (UNLIKELY(!castedThis)) return throwThisTypeError(*state, "TestEventTarget", "dispatchEvent"); ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestEventTarget::info()); auto& impl = castedThis->wrapped(); if (UNLIKELY(state->argumentCount() < 1)) return throwVMError(state, createNotEnoughArgumentsError(state)); ExceptionCode ec = 0; Event* evt = JSEvent::toWrapped(state->argument(0)); if (UNLIKELY(state->hadException())) return JSValue::encode(jsUndefined()); JSValue result = jsBoolean(impl.dispatchEvent(evt, ec)); setDOMException(state, ec); return JSValue::encode(result); }