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

#ifndef mozilla_dom_WebComponentsBinding_h__
#define mozilla_dom_WebComponentsBinding_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/CallbackFunction.h"
#include "mozilla/dom/Nullable.h"

namespace mozilla {
namespace dom {

struct ElementRegistrationOptionsAtoms;
struct LifecycleCallbacks;
struct LifecycleCallbacksAtoms;
class LifecycleCreatedCallback;
class NativePropertyHooks;
class ProtoAndIfaceArray;

} // namespace dom
} // namespace mozilla

namespace mozilla {
namespace dom {

struct LifecycleCallbacks : public MainThreadDictionaryBase
{
  nsRefPtr<LifecycleCreatedCallback> mCreated;

  LifecycleCallbacks();

protected:
  explicit inline LifecycleCallbacks(int )
  {
    // Do nothing here; this is used by our "Fast" subclass
  }

private:
  LifecycleCallbacks(const LifecycleCallbacks&) MOZ_DELETE;
  void operator=(const LifecycleCallbacks) MOZ_DELETE;

  static bool
  InitIds(JSContext* cx, LifecycleCallbacksAtoms* atomsCache);

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

  bool
  Init(const nsAString& aJSON);

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

  void
  TraceDictionary(JSTracer* trc);
};

namespace dictionary_detail {
struct FastLifecycleCallbacks : public LifecycleCallbacks
{
  inline FastLifecycleCallbacks()
    : LifecycleCallbacks(42)
  {
    // Doesn't matter what int we pass to the parent constructor
  }
};
} // namespace dictionary_detail


struct ElementRegistrationOptions : public MainThreadDictionaryBase
{
  LifecycleCallbacks mLifecycle;
  JSObject* mPrototype;

  ElementRegistrationOptions();

protected:
  explicit inline ElementRegistrationOptions(int )
    : mPrototype(nullptr)
  {
    // Do nothing here; this is used by our "Fast" subclass
  }

private:
  ElementRegistrationOptions(const ElementRegistrationOptions&) MOZ_DELETE;
  void operator=(const ElementRegistrationOptions) MOZ_DELETE;

  static bool
  InitIds(JSContext* cx, ElementRegistrationOptionsAtoms* atomsCache);

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

  bool
  Init(const nsAString& aJSON);

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

  void
  TraceDictionary(JSTracer* trc);
};

namespace dictionary_detail {
struct FastElementRegistrationOptions : public ElementRegistrationOptions
{
  inline FastElementRegistrationOptions()
    : ElementRegistrationOptions(42)
  {
    // Doesn't matter what int we pass to the parent constructor
  }
};
} // namespace dictionary_detail


class LifecycleCreatedCallback : public CallbackFunction
{
public:
  explicit inline LifecycleCreatedCallback(JSObject* aCallback)
    : CallbackFunction(aCallback)
  {
    MOZ_ASSERT(JS_ObjectIsCallable(nullptr, mCallback));
  }

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

  template <typename T>
  inline void
  Call(const T& thisObj, ErrorResult& aRv, ExceptionHandling aExceptionHandling = eReportExceptions)
  {
    CallSetup s(CallbackPreserveColor(), aRv, aExceptionHandling);
    if (!s.GetContext()) {
      aRv.Throw(NS_ERROR_UNEXPECTED);
      return;
    }
    JS::Rooted<JSObject*> thisObjJS(s.GetContext(),
      WrapCallThisObject(s.GetContext(), CallbackPreserveColor(), thisObj));
    if (!thisObjJS) {
      aRv.Throw(NS_ERROR_FAILURE);
      return;
    }
    return Call(s.GetContext(), thisObjJS, aRv);
  }

  inline void
  Call(ErrorResult& aRv, ExceptionHandling aExceptionHandling = eReportExceptions)
  {
    CallSetup s(CallbackPreserveColor(), aRv, aExceptionHandling);
    if (!s.GetContext()) {
      aRv.Throw(NS_ERROR_UNEXPECTED);
      return;
    }
    return Call(s.GetContext(), JS::NullPtr(), aRv);
  }

private:
  void Call(JSContext* cx, JS::Handle<JSObject*> aThisObj, ErrorResult& aRv);
};


} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_WebComponentsBinding_h__
