/* 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;

} // namespace dom
} // namespace mozilla

namespace mozilla {
namespace dom {

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

  inline LifecycleCallbacks()
  {
  }

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);
};
struct LifecycleCallbacksInitializer : public LifecycleCallbacks
{
  LifecycleCallbacksInitializer();
};


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

  inline ElementRegistrationOptions()
    : mPrototype(nullptr)
  {
  }

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);
};
struct ElementRegistrationOptionsInitializer : public ElementRegistrationOptions
{
  ElementRegistrationOptionsInitializer();
};


class LifecycleCreatedCallback : public CallbackFunction
{
public:
  explicit inline LifecycleCreatedCallback(JSObject* aCallback)
    : CallbackFunction(aCallback)
  {
  }

  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__
