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

#include <type_traits>
#include "AtomList.h"
#include "MainThreadUtils.h"
#include "NetErrorInfoBinding.h"
#include "js/CallAndConstruct.h"
#include "js/Exception.h"
#include "js/MapAndSet.h"
#include "js/Object.h"
#include "js/PropertyAndElement.h"
#include "js/PropertyDescriptor.h"
#include "js/experimental/JitInfo.h"
#include "mozilla/OwningNonNull.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/NonRefcountedDOMObject.h"
#include "mozilla/dom/PrimitiveConversions.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/SimpleGlobalObject.h"

namespace mozilla::dom {

namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;



NetErrorInfo::NetErrorInfo()
{
  // Safe to pass a null context if we pass a null value
  Init();
}




bool
NetErrorInfo::InitIds(JSContext* cx, NetErrorInfoAtoms* atomsCache)
{
  MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());

  // Initialize these in reverse order so that any failure leaves the first one
  // uninitialized.
  if (!atomsCache->responseStatusText_id.init(cx, "responseStatusText") ||
      !atomsCache->responseStatus_id.init(cx, "responseStatus") ||
      !atomsCache->errorCodeString_id.init(cx, "errorCodeString") ||
      !atomsCache->channelStatus_id.init(cx, "channelStatus")) {
    return false;
  }
  return true;
}

bool
NetErrorInfo::Init(const char* sourceDescription, bool passedToJSImpl)
{
  {
    // scope for any temporaries our default value setting needs.
    mChannelStatus = 0U;
  }

  {
    // scope for any temporaries our default value setting needs.
    mErrorCodeString.AssignLiteral(u"");
  }

  {
    // scope for any temporaries our default value setting needs.
    mResponseStatus = 0U;
  }

  {
    // scope for any temporaries our default value setting needs.
    mResponseStatusText.AssignLiteral(u"");
  }
  return true;
}

bool
NetErrorInfo::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
  NetErrorInfoAtoms* atomsCache = GetAtomCache<NetErrorInfoAtoms>(cx);
  if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
      !InitIds(cx, atomsCache)) {
    return false;
  }

  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
  if (!obj) {
    return false;
  }
  rval.setObject(*obj);

  do {
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
    JS::Rooted<JS::Value> temp(cx);
    uint32_t const & currentValue = mChannelStatus;
    temp.setNumber(currentValue);
    if (!JS_DefinePropertyById(cx, obj, atomsCache->channelStatus_id, temp, JSPROP_ENUMERATE)) {
      return false;
    }
    break;
  } while(false);

  do {
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
    JS::Rooted<JS::Value> temp(cx);
    nsString const & currentValue = mErrorCodeString;
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
      return false;
    }
    if (!JS_DefinePropertyById(cx, obj, atomsCache->errorCodeString_id, temp, JSPROP_ENUMERATE)) {
      return false;
    }
    break;
  } while(false);

  do {
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
    JS::Rooted<JS::Value> temp(cx);
    uint32_t const & currentValue = mResponseStatus;
    temp.setNumber(currentValue);
    if (!JS_DefinePropertyById(cx, obj, atomsCache->responseStatus_id, temp, JSPROP_ENUMERATE)) {
      return false;
    }
    break;
  } while(false);

  do {
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
    JS::Rooted<JS::Value> temp(cx);
    nsString const & currentValue = mResponseStatusText;
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
      return false;
    }
    if (!JS_DefinePropertyById(cx, obj, atomsCache->responseStatusText_id, temp, JSPROP_ENUMERATE)) {
      return false;
    }
    break;
  } while(false);

  return true;
}

void
NetErrorInfo::TraceDictionary(JSTracer* trc)
{
}

NetErrorInfo&
NetErrorInfo::operator=(const NetErrorInfo& aOther)
{
  DictionaryBase::operator=(aOther);
  mChannelStatus = aOther.mChannelStatus;
  mErrorCodeString = aOther.mErrorCodeString;
  mResponseStatus = aOther.mResponseStatus;
  mResponseStatusText = aOther.mResponseStatusText;
  return *this;
}


} // namespace mozilla::dom
