/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */

#ifndef mozilla_dom_EventHandlerBinding_h__
#define mozilla_dom_EventHandlerBinding_h__

#include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/CallbackFunction.h"
#include "mozilla/dom/DOMJSClass.h"
#include "mozilla/dom/DOMJSProxyHandler.h"

class XPCWrappedNativeScope;
class nsIDOMEvent;

class nsIDOMEvent;

class JSObject;

class JSObject;

namespace mozilla {
namespace dom {

class EventOrString;

} // namespace dom
} // namespace mozilla


namespace mozilla {
namespace dom {

class EventHandlerNonNull : public CallbackFunction
{
public:
  inline EventHandlerNonNull(JSContext* cx, JSObject* aOwner, JSObject* aCallable, bool* aInited)
    : CallbackFunction(cx, aOwner, aCallable, aInited)
  {
  }

  explicit inline EventHandlerNonNull(CallbackFunction* aOther)
    : CallbackFunction(aOther)
  {
  }

  template <typename T>
  inline JS::Value
  Call(const T& thisObj, nsIDOMEvent* event, ErrorResult& aRv)
  {
    CallSetup s(mCallable);
    if (!s.GetContext()) {
      aRv.Throw(NS_ERROR_UNEXPECTED);
      return JS::UndefinedValue();
    }
    JSObject* thisObjJS = WrapCallThisObject(s.GetContext(), mCallable, thisObj);
    if (!thisObjJS) {
      aRv.Throw(NS_ERROR_FAILURE);
      return JS::UndefinedValue();
    }
    return Call(s.GetContext(), thisObjJS, event, aRv);
  }

  inline JS::Value
  Call(nsIDOMEvent* event, ErrorResult& aRv)
  {
    CallSetup s(mCallable);
    if (!s.GetContext()) {
      aRv.Throw(NS_ERROR_UNEXPECTED);
      return JS::UndefinedValue();
    }
    return Call(s.GetContext(), nullptr, event, aRv);
  }

private:
  JS::Value Call(JSContext* cx, JSObject* aThisObj, nsIDOMEvent* event, ErrorResult& aRv);
};


class BeforeUnloadEventHandlerNonNull : public CallbackFunction
{
public:
  inline BeforeUnloadEventHandlerNonNull(JSContext* cx, JSObject* aOwner, JSObject* aCallable, bool* aInited)
    : CallbackFunction(cx, aOwner, aCallable, aInited)
  {
  }

  explicit inline BeforeUnloadEventHandlerNonNull(CallbackFunction* aOther)
    : CallbackFunction(aOther)
  {
  }

  template <typename T>
  inline void
  Call(const T& thisObj, nsIDOMEvent* event, nsString& retval, ErrorResult& aRv)
  {
    CallSetup s(mCallable);
    if (!s.GetContext()) {
      aRv.Throw(NS_ERROR_UNEXPECTED);
      return;
    }
    JSObject* thisObjJS = WrapCallThisObject(s.GetContext(), mCallable, thisObj);
    if (!thisObjJS) {
      aRv.Throw(NS_ERROR_FAILURE);
      return;
    }
    return Call(s.GetContext(), thisObjJS, event, retval, aRv);
  }

  inline void
  Call(nsIDOMEvent* event, nsString& retval, ErrorResult& aRv)
  {
    CallSetup s(mCallable);
    if (!s.GetContext()) {
      aRv.Throw(NS_ERROR_UNEXPECTED);
      return;
    }
    return Call(s.GetContext(), nullptr, event, retval, aRv);
  }

private:
  void Call(JSContext* cx, JSObject* aThisObj, nsIDOMEvent* event, nsString& retval, ErrorResult& aRv);
};


class OnErrorEventHandlerNonNull : public CallbackFunction
{
public:
  inline OnErrorEventHandlerNonNull(JSContext* cx, JSObject* aOwner, JSObject* aCallable, bool* aInited)
    : CallbackFunction(cx, aOwner, aCallable, aInited)
  {
  }

  explicit inline OnErrorEventHandlerNonNull(CallbackFunction* aOther)
    : CallbackFunction(aOther)
  {
  }

  template <typename T>
  inline bool
  Call(const T& thisObj, const EventOrString& event, const Optional< nsAString >& source, const Optional< uint32_t >& lineno, const Optional< uint32_t >& column, ErrorResult& aRv)
  {
    CallSetup s(mCallable);
    if (!s.GetContext()) {
      aRv.Throw(NS_ERROR_UNEXPECTED);
      return bool(0);
    }
    JSObject* thisObjJS = WrapCallThisObject(s.GetContext(), mCallable, thisObj);
    if (!thisObjJS) {
      aRv.Throw(NS_ERROR_FAILURE);
      return bool(0);
    }
    return Call(s.GetContext(), thisObjJS, event, source, lineno, column, aRv);
  }

  inline bool
  Call(const EventOrString& event, const Optional< nsAString >& source, const Optional< uint32_t >& lineno, const Optional< uint32_t >& column, ErrorResult& aRv)
  {
    CallSetup s(mCallable);
    if (!s.GetContext()) {
      aRv.Throw(NS_ERROR_UNEXPECTED);
      return bool(0);
    }
    return Call(s.GetContext(), nullptr, event, source, lineno, column, aRv);
  }

private:
  bool Call(JSContext* cx, JSObject* aThisObj, const EventOrString& event, const Optional< nsAString >& source, const Optional< uint32_t >& lineno, const Optional< uint32_t >& column, ErrorResult& aRv);
};


} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_EventHandlerBinding_h__
