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

#ifndef mozilla_dom_DOMMatrixBinding_h
#define mozilla_dom_DOMMatrixBinding_h

#include "DOMMatrixBinding.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/Nullable.h"
#include "mozilla/dom/UnionMember.h"

namespace mozilla {
namespace dom {

class DOMMatrix;
struct DOMMatrix2DInitAtoms;
struct DOMMatrixAtoms;
struct DOMMatrixInitAtoms;
class DOMMatrixReadOnly;
struct DOMMatrixReadOnlyAtoms;
struct NativePropertyHooks;
class ProtoAndIfaceCache;

} // namespace dom
} // namespace mozilla

namespace mozilla {
namespace dom {

struct DOMMatrix2DInit : public DictionaryBase
{
  MOZ_INIT_OUTSIDE_CTOR Optional<double> mA;
  MOZ_INIT_OUTSIDE_CTOR Optional<double> mB;
  MOZ_INIT_OUTSIDE_CTOR Optional<double> mC;
  MOZ_INIT_OUTSIDE_CTOR Optional<double> mD;
  MOZ_INIT_OUTSIDE_CTOR Optional<double> mE;
  MOZ_INIT_OUTSIDE_CTOR Optional<double> mF;
  MOZ_INIT_OUTSIDE_CTOR Optional<double> mM11;
  MOZ_INIT_OUTSIDE_CTOR Optional<double> mM12;
  MOZ_INIT_OUTSIDE_CTOR Optional<double> mM21;
  MOZ_INIT_OUTSIDE_CTOR Optional<double> mM22;
  MOZ_INIT_OUTSIDE_CTOR Optional<double> mM41;
  MOZ_INIT_OUTSIDE_CTOR Optional<double> mM42;

  DOMMatrix2DInit();

  explicit inline DOMMatrix2DInit(const FastDictionaryInitializer& )
  {
    // Do nothing here; this is used by our "Fast" subclass
  }

  explicit inline DOMMatrix2DInit(const DOMMatrix2DInit& aOther)
  {
    *this = aOther;
  }

  bool
  Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);

  bool
  ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;

  void
  TraceDictionary(JSTracer* trc);

  void
  operator=(const DOMMatrix2DInit& aOther);

private:
  static bool
  InitIds(JSContext* cx, DOMMatrix2DInitAtoms* atomsCache);
};

namespace binding_detail {
struct FastDOMMatrix2DInit : public DOMMatrix2DInit
{
  inline FastDOMMatrix2DInit()
    : DOMMatrix2DInit(FastDictionaryInitializer())
  {
    // Doesn't matter what int we pass to the parent constructor
  }
};
} // namespace binding_detail


class StringOrUnrestrictedDoubleSequence
{
  friend class StringOrUnrestrictedDoubleSequenceArgument;
  enum Type
  {
    eUninitialized,
    eString,
    eUnrestrictedDoubleSequence
  };

  union Value
  {
    UnionMember<binding_detail::FakeString > mString;
    UnionMember<binding_detail::AutoSequence<double> > mUnrestrictedDoubleSequence;

  };

  Type mType;
  Value mValue;

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

  inline ~StringOrUnrestrictedDoubleSequence()
  {
    Uninit();
  }

  inline binding_detail::FakeString&
  RawSetAsString()
  {
    if (mType == eString) {
      return mValue.mString.Value();
    }
    MOZ_ASSERT(mType == eUninitialized);
    mType = eString;
    return mValue.mString.SetValue();
  }

  inline binding_detail::FakeString&
  SetAsString()
  {
    if (mType == eString) {
      return mValue.mString.Value();
    }
    Uninit();
    mType = eString;
    return mValue.mString.SetValue();
  }

  inline bool
  IsString() const
  {
    return mType == eString;
  }

  inline binding_detail::FakeString&
  GetAsString()
  {
    MOZ_ASSERT(IsString(), "Wrong type!");
    return mValue.mString.Value();
  }

  inline const nsAString&
  GetAsString() const
  {
    MOZ_ASSERT(IsString(), "Wrong type!");
    return mValue.mString.Value();
  }

  inline binding_detail::AutoSequence<double>&
  RawSetAsUnrestrictedDoubleSequence()
  {
    if (mType == eUnrestrictedDoubleSequence) {
      return mValue.mUnrestrictedDoubleSequence.Value();
    }
    MOZ_ASSERT(mType == eUninitialized);
    mType = eUnrestrictedDoubleSequence;
    return mValue.mUnrestrictedDoubleSequence.SetValue();
  }

  inline binding_detail::AutoSequence<double>&
  SetAsUnrestrictedDoubleSequence()
  {
    if (mType == eUnrestrictedDoubleSequence) {
      return mValue.mUnrestrictedDoubleSequence.Value();
    }
    Uninit();
    mType = eUnrestrictedDoubleSequence;
    return mValue.mUnrestrictedDoubleSequence.SetValue();
  }

  inline bool
  IsUnrestrictedDoubleSequence() const
  {
    return mType == eUnrestrictedDoubleSequence;
  }

  inline binding_detail::AutoSequence<double>&
  GetAsUnrestrictedDoubleSequence()
  {
    MOZ_ASSERT(IsUnrestrictedDoubleSequence(), "Wrong type!");
    return mValue.mUnrestrictedDoubleSequence.Value();
  }

  inline const Sequence<double>&
  GetAsUnrestrictedDoubleSequence() const
  {
    MOZ_ASSERT(IsUnrestrictedDoubleSequence(), "Wrong type!");
    return mValue.mUnrestrictedDoubleSequence.Value();
  }

  inline void
  Uninit()
  {
    switch (mType) {
      case eUninitialized: {
        break;
      }
      case eString: {
        DestroyString();
        break;
      }
      case eUnrestrictedDoubleSequence: {
        DestroyUnrestrictedDoubleSequence();
        break;
      }
    }
  }

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

private:
  inline void
  DestroyString()
  {
    MOZ_ASSERT(IsString(), "Wrong type!");
    mValue.mString.Destroy();
    mType = eUninitialized;
  }

  inline void
  DestroyUnrestrictedDoubleSequence()
  {
    MOZ_ASSERT(IsUnrestrictedDoubleSequence(), "Wrong type!");
    mValue.mUnrestrictedDoubleSequence.Destroy();
    mType = eUninitialized;
  }
};


class OwningStringOrUnrestrictedDoubleSequence : public AllOwningUnionBase
{
  friend void ImplCycleCollectionUnlink(OwningStringOrUnrestrictedDoubleSequence& aUnion);
  enum Type
  {
    eUninitialized,
    eString,
    eUnrestrictedDoubleSequence
  };

  union Value
  {
    UnionMember<nsString > mString;
    UnionMember<Sequence<double> > mUnrestrictedDoubleSequence;

  };

  Type mType;
  Value mValue;

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

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

  inline ~OwningStringOrUnrestrictedDoubleSequence()
  {
    Uninit();
  }

  nsString&
  RawSetAsString();

  nsString&
  SetAsString();

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

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

  inline bool
  IsString() const
  {
    return mType == eString;
  }

  inline nsString&
  GetAsString()
  {
    MOZ_ASSERT(IsString(), "Wrong type!");
    return mValue.mString.Value();
  }

  inline nsString const &
  GetAsString() const
  {
    MOZ_ASSERT(IsString(), "Wrong type!");
    return mValue.mString.Value();
  }

  Sequence<double>&
  RawSetAsUnrestrictedDoubleSequence();

  Sequence<double>&
  SetAsUnrestrictedDoubleSequence();

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

  inline bool
  IsUnrestrictedDoubleSequence() const
  {
    return mType == eUnrestrictedDoubleSequence;
  }

  inline Sequence<double>&
  GetAsUnrestrictedDoubleSequence()
  {
    MOZ_ASSERT(IsUnrestrictedDoubleSequence(), "Wrong type!");
    return mValue.mUnrestrictedDoubleSequence.Value();
  }

  inline Sequence<double> const &
  GetAsUnrestrictedDoubleSequence() const
  {
    MOZ_ASSERT(IsUnrestrictedDoubleSequence(), "Wrong type!");
    return mValue.mUnrestrictedDoubleSequence.Value();
  }

  void
  Uninit();

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

  void
  TraceUnion(JSTracer* trc);

  void
  operator=(const OwningStringOrUnrestrictedDoubleSequence& aOther);

private:
  void
  DestroyString();

  void
  DestroyUnrestrictedDoubleSequence();
};


struct DOMMatrixInit : public DOMMatrix2DInit
{
  MOZ_INIT_OUTSIDE_CTOR Optional<bool> mIs2D;
  MOZ_INIT_OUTSIDE_CTOR double mM13;
  MOZ_INIT_OUTSIDE_CTOR double mM14;
  MOZ_INIT_OUTSIDE_CTOR double mM23;
  MOZ_INIT_OUTSIDE_CTOR double mM24;
  MOZ_INIT_OUTSIDE_CTOR double mM31;
  MOZ_INIT_OUTSIDE_CTOR double mM32;
  MOZ_INIT_OUTSIDE_CTOR double mM33;
  MOZ_INIT_OUTSIDE_CTOR double mM34;
  MOZ_INIT_OUTSIDE_CTOR double mM43;
  MOZ_INIT_OUTSIDE_CTOR double mM44;

  DOMMatrixInit();

  explicit inline DOMMatrixInit(const FastDictionaryInitializer& )
    : DOMMatrix2DInit(FastDictionaryInitializer())
  {
    // Do nothing here; this is used by our "Fast" subclass
  }

  explicit inline DOMMatrixInit(const DOMMatrixInit& aOther)
  {
    *this = aOther;
  }

  bool
  Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);

  bool
  ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;

  void
  TraceDictionary(JSTracer* trc);

  void
  operator=(const DOMMatrixInit& aOther);

private:
  static bool
  InitIds(JSContext* cx, DOMMatrixInitAtoms* atomsCache);
};

namespace binding_detail {
struct FastDOMMatrixInit : public DOMMatrixInit
{
  inline FastDOMMatrixInit()
    : DOMMatrixInit(FastDictionaryInitializer())
  {
    // Doesn't matter what int we pass to the parent constructor
  }
};
} // namespace binding_detail


namespace DOMMatrixBinding {

  typedef mozilla::dom::DOMMatrix NativeType;

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

  const JSClass*
  GetJSClass();

  bool
  Wrap(JSContext* aCx, mozilla::dom::DOMMatrix* 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);

  JSObject*
  GetProtoObject(JSContext* aCx);

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

  JSObject*
  GetConstructorObject(JSContext* aCx);

} // namespace DOMMatrixBinding



namespace DOMMatrixReadOnlyBinding {

  typedef mozilla::dom::DOMMatrixReadOnly NativeType;

  bool
  JsonifyAttributes(JSContext* aCx, JS::Handle<JSObject*> obj, mozilla::dom::DOMMatrixReadOnly* self, JS::Rooted<JSObject*>& aResult);

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

  const JSClass*
  GetJSClass();

  bool
  Wrap(JSContext* aCx, mozilla::dom::DOMMatrixReadOnly* 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);

  JSObject*
  GetProtoObject(JSContext* aCx);

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

  JSObject*
  GetConstructorObject(JSContext* aCx);

} // namespace DOMMatrixReadOnlyBinding



} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_DOMMatrixBinding_h
