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

#ifndef mozilla_dom_DOMMobileMessageErrorBinding_h
#define mozilla_dom_DOMMobileMessageErrorBinding_h

#include "js/RootingAPI.h"
#include "jspubtd.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/UnionMember.h"

class nsIDOMMozMmsMessage;
class nsIDOMMozSmsMessage;

namespace mozilla {
namespace dom {

class DOMMobileMessageError;
struct DOMMobileMessageErrorAtoms;
struct NativePropertyHooks;
class OwningMozSmsMessageOrMozMmsMessage;
class ProtoAndIfaceCache;

} // namespace dom
} // namespace mozilla

namespace mozilla {
namespace dom {

void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningMozSmsMessageOrMozMmsMessage& aUnion, const char* aName, uint32_t aFlags = 0);


void
ImplCycleCollectionUnlink(OwningMozSmsMessageOrMozMmsMessage& aUnion);


class MozSmsMessageOrMozMmsMessage
{
  friend class MozSmsMessageOrMozMmsMessageArgument;
  enum Type
  {
    eUninitialized,
    eMozSmsMessage,
    eMozMmsMessage
  };

  union Value
  {
    UnionMember<nsIDOMMozSmsMessage* > mMozSmsMessage;
    UnionMember<nsIDOMMozMmsMessage* > mMozMmsMessage;

  };

  Type mType;
  Value mValue;

  MozSmsMessageOrMozMmsMessage(const MozSmsMessageOrMozMmsMessage&) = delete;
  void operator=(const MozSmsMessageOrMozMmsMessage) = delete;
public:
  explicit inline MozSmsMessageOrMozMmsMessage()
    : mType(eUninitialized)
  {
  }

  inline ~MozSmsMessageOrMozMmsMessage()
  {
    Uninit();
  }

  inline nsIDOMMozSmsMessage*&
  RawSetAsMozSmsMessage()
  {
    if (mType == eMozSmsMessage) {
      return mValue.mMozSmsMessage.Value();
    }
    MOZ_ASSERT(mType == eUninitialized);
    mType = eMozSmsMessage;
    return mValue.mMozSmsMessage.SetValue();
  }

  inline nsIDOMMozSmsMessage*&
  SetAsMozSmsMessage()
  {
    if (mType == eMozSmsMessage) {
      return mValue.mMozSmsMessage.Value();
    }
    Uninit();
    mType = eMozSmsMessage;
    return mValue.mMozSmsMessage.SetValue();
  }

  inline bool
  IsMozSmsMessage() const
  {
    return mType == eMozSmsMessage;
  }

  inline nsIDOMMozSmsMessage*&
  GetAsMozSmsMessage()
  {
    MOZ_ASSERT(IsMozSmsMessage(), "Wrong type!");
    return mValue.mMozSmsMessage.Value();
  }

  inline nsIDOMMozSmsMessage*
  GetAsMozSmsMessage() const
  {
    MOZ_ASSERT(IsMozSmsMessage(), "Wrong type!");
    return mValue.mMozSmsMessage.Value();
  }

  inline nsIDOMMozMmsMessage*&
  RawSetAsMozMmsMessage()
  {
    if (mType == eMozMmsMessage) {
      return mValue.mMozMmsMessage.Value();
    }
    MOZ_ASSERT(mType == eUninitialized);
    mType = eMozMmsMessage;
    return mValue.mMozMmsMessage.SetValue();
  }

  inline nsIDOMMozMmsMessage*&
  SetAsMozMmsMessage()
  {
    if (mType == eMozMmsMessage) {
      return mValue.mMozMmsMessage.Value();
    }
    Uninit();
    mType = eMozMmsMessage;
    return mValue.mMozMmsMessage.SetValue();
  }

  inline bool
  IsMozMmsMessage() const
  {
    return mType == eMozMmsMessage;
  }

  inline nsIDOMMozMmsMessage*&
  GetAsMozMmsMessage()
  {
    MOZ_ASSERT(IsMozMmsMessage(), "Wrong type!");
    return mValue.mMozMmsMessage.Value();
  }

  inline nsIDOMMozMmsMessage*
  GetAsMozMmsMessage() const
  {
    MOZ_ASSERT(IsMozMmsMessage(), "Wrong type!");
    return mValue.mMozMmsMessage.Value();
  }

  bool
  ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;

private:
  inline void
  DestroyMozSmsMessage()
  {
    MOZ_ASSERT(IsMozSmsMessage(), "Wrong type!");
    mValue.mMozSmsMessage.Destroy();
    mType = eUninitialized;
  }

  inline void
  DestroyMozMmsMessage()
  {
    MOZ_ASSERT(IsMozMmsMessage(), "Wrong type!");
    mValue.mMozMmsMessage.Destroy();
    mType = eUninitialized;
  }

  inline void
  Uninit()
  {
    switch (mType) {
      case eUninitialized: {
        break;
      }
      case eMozSmsMessage: {
        DestroyMozSmsMessage();
        break;
      }
      case eMozMmsMessage: {
        DestroyMozMmsMessage();
        break;
      }
    }
  }
};


class OwningMozSmsMessageOrMozMmsMessage : public AllOwningUnionBase
{
  friend void ImplCycleCollectionUnlink(OwningMozSmsMessageOrMozMmsMessage& aUnion);
  enum Type
  {
    eUninitialized,
    eMozSmsMessage,
    eMozMmsMessage
  };

  union Value
  {
    UnionMember<nsRefPtr<nsIDOMMozSmsMessage> > mMozSmsMessage;
    UnionMember<nsRefPtr<nsIDOMMozMmsMessage> > mMozMmsMessage;

  };

  Type mType;
  Value mValue;

public:
  explicit inline OwningMozSmsMessageOrMozMmsMessage()
    : mType(eUninitialized)
  {
  }

  explicit inline OwningMozSmsMessageOrMozMmsMessage(const OwningMozSmsMessageOrMozMmsMessage& aOther)
    : mType(eUninitialized)
  {
    *this = aOther;
  }

  inline ~OwningMozSmsMessageOrMozMmsMessage()
  {
    Uninit();
  }

  nsRefPtr<nsIDOMMozSmsMessage>&
  RawSetAsMozSmsMessage();

  nsRefPtr<nsIDOMMozSmsMessage>&
  SetAsMozSmsMessage();

  bool
  TrySetToMozSmsMessage(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);

  inline bool
  IsMozSmsMessage() const
  {
    return mType == eMozSmsMessage;
  }

  inline nsRefPtr<nsIDOMMozSmsMessage>&
  GetAsMozSmsMessage()
  {
    MOZ_ASSERT(IsMozSmsMessage(), "Wrong type!");
    return mValue.mMozSmsMessage.Value();
  }

  inline nsRefPtr<nsIDOMMozSmsMessage> const &
  GetAsMozSmsMessage() const
  {
    MOZ_ASSERT(IsMozSmsMessage(), "Wrong type!");
    return mValue.mMozSmsMessage.Value();
  }

  nsRefPtr<nsIDOMMozMmsMessage>&
  RawSetAsMozMmsMessage();

  nsRefPtr<nsIDOMMozMmsMessage>&
  SetAsMozMmsMessage();

  bool
  TrySetToMozMmsMessage(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);

  inline bool
  IsMozMmsMessage() const
  {
    return mType == eMozMmsMessage;
  }

  inline nsRefPtr<nsIDOMMozMmsMessage>&
  GetAsMozMmsMessage()
  {
    MOZ_ASSERT(IsMozMmsMessage(), "Wrong type!");
    return mValue.mMozMmsMessage.Value();
  }

  inline nsRefPtr<nsIDOMMozMmsMessage> const &
  GetAsMozMmsMessage() const
  {
    MOZ_ASSERT(IsMozMmsMessage(), "Wrong type!");
    return mValue.mMozMmsMessage.Value();
  }

  bool
  ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;

  void
  TraceUnion(JSTracer* trc);

  void
  operator=(const OwningMozSmsMessageOrMozMmsMessage& aOther);

private:
  void
  DestroyMozSmsMessage();

  void
  DestroyMozMmsMessage();

  void
  Uninit();
};


namespace DOMMobileMessageErrorBinding {

  typedef mozilla::dom::DOMMobileMessageError NativeType;

  // We declare this as an array so that retrieving a pointer to this
  // binding's property hooks only requires compile/link-time resolvable
  // address arithmetic.  Declaring it as a pointer instead would require
  // doing a run-time load to fetch a pointer to this binding's property
  // hooks.  And then structures which embedded a pointer to this structure
  // would require a run-time load for proper initialization, which would
  // then induce static constructors.  Lots of static constructors.
  extern const NativePropertyHooks sNativePropertyHooks[];

  JSObject*
  DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);

  bool
  ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);

  const JSClass*
  GetJSClass();

  JSObject*
  Wrap(JSContext* aCx, mozilla::dom::DOMMobileMessageError* aObject, nsWrapperCache* aCache);

  template <class T>
  inline JSObject* Wrap(JSContext* aCx, T* aObject)
  {
    return Wrap(aCx, aObject, aObject);
  }

  void
  CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);

  JS::Handle<JSObject*>
  GetProtoObjectHandle(JSContext* aCx, JS::Handle<JSObject*> aGlobal);

  JS::Handle<JSObject*>
  GetConstructorObjectHandle(JSContext* aCx, JS::Handle<JSObject*> aGlobal, bool aDefineOnGlobal = true);

  JSObject*
  GetConstructorObject(JSContext* aCx, JS::Handle<JSObject*> aGlobal);

} // namespace DOMMobileMessageErrorBinding



} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_DOMMobileMessageErrorBinding_h
