/* THIS FILE IS AUTOGENERATED FROM URLSearchParams.webidl BY Codegen.py - DO NOT EDIT */

#ifndef mozilla_dom_URLSearchParamsBinding_h
#define mozilla_dom_URLSearchParamsBinding_h

#include "js/RootingAPI.h"
#include "jspubtd.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/FakeString.h"
#include "mozilla/dom/IterableIterator.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/Record.h"
#include "mozilla/dom/UnionMember.h"

namespace mozilla {
namespace dom {

struct NativePropertyHooks;
class ProtoAndIfaceCache;
class URLSearchParams;
struct URLSearchParamsAtoms;

} // namespace dom
} // namespace mozilla

namespace mozilla {
namespace dom {

class USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString
{
  friend class USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVStringArgument;
  enum Type
  {
    eUninitialized,
    eUSVStringSequenceSequence,
    eUSVStringUSVStringRecord,
    eUSVString
  };

  union Value
  {
    UnionMember<binding_detail::AutoSequence<Sequence<nsString>> > mUSVStringSequenceSequence;
    UnionMember<Record<nsString, nsString> > mUSVStringUSVStringRecord;
    UnionMember<binding_detail::FakeString > mUSVString;

  };

  Type mType;
  Value mValue;

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

  inline ~USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString()
  {
    Uninit();
  }

  inline binding_detail::AutoSequence<Sequence<nsString>>&
  RawSetAsUSVStringSequenceSequence()
  {
    if (mType == eUSVStringSequenceSequence) {
      return mValue.mUSVStringSequenceSequence.Value();
    }
    MOZ_ASSERT(mType == eUninitialized);
    mType = eUSVStringSequenceSequence;
    return mValue.mUSVStringSequenceSequence.SetValue();
  }

  inline binding_detail::AutoSequence<Sequence<nsString>>&
  SetAsUSVStringSequenceSequence()
  {
    if (mType == eUSVStringSequenceSequence) {
      return mValue.mUSVStringSequenceSequence.Value();
    }
    Uninit();
    mType = eUSVStringSequenceSequence;
    return mValue.mUSVStringSequenceSequence.SetValue();
  }

  inline bool
  IsUSVStringSequenceSequence() const
  {
    return mType == eUSVStringSequenceSequence;
  }

  inline binding_detail::AutoSequence<Sequence<nsString>>&
  GetAsUSVStringSequenceSequence()
  {
    MOZ_ASSERT(IsUSVStringSequenceSequence(), "Wrong type!");
    return mValue.mUSVStringSequenceSequence.Value();
  }

  inline const Sequence<Sequence<nsString>>&
  GetAsUSVStringSequenceSequence() const
  {
    MOZ_ASSERT(IsUSVStringSequenceSequence(), "Wrong type!");
    return mValue.mUSVStringSequenceSequence.Value();
  }

  inline Record<nsString, nsString>&
  RawSetAsUSVStringUSVStringRecord()
  {
    if (mType == eUSVStringUSVStringRecord) {
      return mValue.mUSVStringUSVStringRecord.Value();
    }
    MOZ_ASSERT(mType == eUninitialized);
    mType = eUSVStringUSVStringRecord;
    return mValue.mUSVStringUSVStringRecord.SetValue();
  }

  inline Record<nsString, nsString>&
  SetAsUSVStringUSVStringRecord()
  {
    if (mType == eUSVStringUSVStringRecord) {
      return mValue.mUSVStringUSVStringRecord.Value();
    }
    Uninit();
    mType = eUSVStringUSVStringRecord;
    return mValue.mUSVStringUSVStringRecord.SetValue();
  }

  inline bool
  IsUSVStringUSVStringRecord() const
  {
    return mType == eUSVStringUSVStringRecord;
  }

  inline Record<nsString, nsString>&
  GetAsUSVStringUSVStringRecord()
  {
    MOZ_ASSERT(IsUSVStringUSVStringRecord(), "Wrong type!");
    return mValue.mUSVStringUSVStringRecord.Value();
  }

  inline const Record<nsString, nsString>&
  GetAsUSVStringUSVStringRecord() const
  {
    MOZ_ASSERT(IsUSVStringUSVStringRecord(), "Wrong type!");
    return mValue.mUSVStringUSVStringRecord.Value();
  }

  inline binding_detail::FakeString&
  RawSetAsUSVString()
  {
    if (mType == eUSVString) {
      return mValue.mUSVString.Value();
    }
    MOZ_ASSERT(mType == eUninitialized);
    mType = eUSVString;
    return mValue.mUSVString.SetValue();
  }

  inline binding_detail::FakeString&
  SetAsUSVString()
  {
    if (mType == eUSVString) {
      return mValue.mUSVString.Value();
    }
    Uninit();
    mType = eUSVString;
    return mValue.mUSVString.SetValue();
  }

  inline bool
  IsUSVString() const
  {
    return mType == eUSVString;
  }

  inline binding_detail::FakeString&
  GetAsUSVString()
  {
    MOZ_ASSERT(IsUSVString(), "Wrong type!");
    return mValue.mUSVString.Value();
  }

  inline const nsAString&
  GetAsUSVString() const
  {
    MOZ_ASSERT(IsUSVString(), "Wrong type!");
    return mValue.mUSVString.Value();
  }

  inline void
  Uninit()
  {
    switch (mType) {
      case eUninitialized: {
        break;
      }
      case eUSVStringSequenceSequence: {
        DestroyUSVStringSequenceSequence();
        break;
      }
      case eUSVStringUSVStringRecord: {
        DestroyUSVStringUSVStringRecord();
        break;
      }
      case eUSVString: {
        DestroyUSVString();
        break;
      }
    }
  }

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

private:
  inline void
  DestroyUSVStringSequenceSequence()
  {
    MOZ_ASSERT(IsUSVStringSequenceSequence(), "Wrong type!");
    mValue.mUSVStringSequenceSequence.Destroy();
    mType = eUninitialized;
  }

  inline void
  DestroyUSVStringUSVStringRecord()
  {
    MOZ_ASSERT(IsUSVStringUSVStringRecord(), "Wrong type!");
    mValue.mUSVStringUSVStringRecord.Destroy();
    mType = eUninitialized;
  }

  inline void
  DestroyUSVString()
  {
    MOZ_ASSERT(IsUSVString(), "Wrong type!");
    mValue.mUSVString.Destroy();
    mType = eUninitialized;
  }
};


class OwningUSVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString : public AllOwningUnionBase
{
  friend void ImplCycleCollectionUnlink(OwningUSVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString& aUnion);
  enum Type
  {
    eUninitialized,
    eUSVStringSequenceSequence,
    eUSVStringUSVStringRecord,
    eUSVString
  };

  union Value
  {
    UnionMember<Sequence<Sequence<nsString>> > mUSVStringSequenceSequence;
    UnionMember<Record<nsString, nsString> > mUSVStringUSVStringRecord;
    UnionMember<nsString > mUSVString;

  };

  Type mType;
  Value mValue;

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

  inline ~OwningUSVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString()
  {
    Uninit();
  }

  Sequence<Sequence<nsString>>&
  RawSetAsUSVStringSequenceSequence();

  Sequence<Sequence<nsString>>&
  SetAsUSVStringSequenceSequence();

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

  inline bool
  IsUSVStringSequenceSequence() const
  {
    return mType == eUSVStringSequenceSequence;
  }

  inline Sequence<Sequence<nsString>>&
  GetAsUSVStringSequenceSequence()
  {
    MOZ_ASSERT(IsUSVStringSequenceSequence(), "Wrong type!");
    return mValue.mUSVStringSequenceSequence.Value();
  }

  inline Sequence<Sequence<nsString>> const &
  GetAsUSVStringSequenceSequence() const
  {
    MOZ_ASSERT(IsUSVStringSequenceSequence(), "Wrong type!");
    return mValue.mUSVStringSequenceSequence.Value();
  }

  Record<nsString, nsString>&
  RawSetAsUSVStringUSVStringRecord();

  Record<nsString, nsString>&
  SetAsUSVStringUSVStringRecord();

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

  inline bool
  IsUSVStringUSVStringRecord() const
  {
    return mType == eUSVStringUSVStringRecord;
  }

  inline Record<nsString, nsString>&
  GetAsUSVStringUSVStringRecord()
  {
    MOZ_ASSERT(IsUSVStringUSVStringRecord(), "Wrong type!");
    return mValue.mUSVStringUSVStringRecord.Value();
  }

  inline Record<nsString, nsString> const &
  GetAsUSVStringUSVStringRecord() const
  {
    MOZ_ASSERT(IsUSVStringUSVStringRecord(), "Wrong type!");
    return mValue.mUSVStringUSVStringRecord.Value();
  }

  nsString&
  RawSetAsUSVString();

  nsString&
  SetAsUSVString();

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

  inline void
  SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
  {
    RawSetAsUSVString().Assign(aData, aLength);
  }

  inline bool
  IsUSVString() const
  {
    return mType == eUSVString;
  }

  inline nsString&
  GetAsUSVString()
  {
    MOZ_ASSERT(IsUSVString(), "Wrong type!");
    return mValue.mUSVString.Value();
  }

  inline nsString const &
  GetAsUSVString() const
  {
    MOZ_ASSERT(IsUSVString(), "Wrong type!");
    return mValue.mUSVString.Value();
  }

  void
  Uninit();

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

  void
  TraceUnion(JSTracer* trc);

private:
  void
  DestroyUSVStringSequenceSequence();

  void
  DestroyUSVStringUSVStringRecord();

  void
  DestroyUSVString();
};


namespace URLSearchParamsBinding {

  typedef mozilla::dom::URLSearchParams NativeType;

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

  const JSClass*
  GetJSClass();

  bool
  Wrap(JSContext* aCx, mozilla::dom::URLSearchParams* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);

  template <class T>
  inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
  {
    JS::Rooted<JSObject*> reflector(aCx);
    return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
  }

  // 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[];

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

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

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

  JSObject*
  GetConstructorObject(JSContext* aCx);

} // namespace URLSearchParamsBinding



namespace URLSearchParamsIteratorBinding {

  typedef mozilla::dom::IterableIterator<mozilla::dom::URLSearchParams> NativeType;

  const JSClass*
  GetJSClass();

  bool
  Wrap(JSContext* aCx, mozilla::dom::IterableIterator<mozilla::dom::URLSearchParams>* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);

  // 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[];

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

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

} // namespace URLSearchParamsIteratorBinding



} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_URLSearchParamsBinding_h
