//
// Automatically generated by ipdlc.
// Edit at your own risk
//


#include "mozilla/dom/TabMessageUtils.h"
#include "mozilla/dom/PBrowserParent.h"
#include "mozilla/dom/PBrowserChild.h"
#include "mozilla/dom/PTabContext.h"

#include "ipc/IPCMessageUtils.h"
#include "ipc/IPCMessageUtilsSpecializations.h"
#include "nsIFile.h"
#include "mozilla/ipc/Endpoint.h"
#include "mozilla/ipc/ProtocolMessageUtils.h"
#include "mozilla/ipc/ProtocolUtils.h"
#include "mozilla/ipc/ShmemMessageUtils.h"
#include "mozilla/ipc/TaintingIPCUtils.h"


//-----------------------------------------------------------------------------
// Method definitions for the IPDL type |struct PopupIPCTabContext|
//
namespace mozilla {
namespace dom {
} // namespace dom
} // namespace mozilla

namespace IPC {
auto ParamTraits<::mozilla::dom::PopupIPCTabContext>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    IPC::WriteParam(aWriter, (aVar).opener());
    // Sentinel = 'opener'
    (aWriter)->WriteSentinel(149553802);
    (aWriter)->WriteBytes((&((aVar).chromeOuterWindowID())), 8);
    // Sentinel = 'chromeOuterWindowID'
    (aWriter)->WriteSentinel(1303119763);
}

auto ParamTraits<::mozilla::dom::PopupIPCTabContext>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    auto maybe___opener = IPC::ReadParam<mozilla::NotNull<::mozilla::ipc::SideVariant<::mozilla::dom::PBrowserParent*, ::mozilla::dom::PBrowserChild*>>>(aReader);
    if (!maybe___opener) {
        aReader->FatalError("Error deserializing 'opener' (NotNull<PBrowser>) member of 'PopupIPCTabContext'");
        return {};

    }
    auto& _opener = *maybe___opener;
    // Sentinel = 'opener'
    if ((!((aReader)->ReadSentinel(149553802)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'opener' (NotNull<PBrowser>) member of 'PopupIPCTabContext'");
        return {};
    }
    IPC::ReadResult<paramType> result__{
            std::in_place,
            std::move(_opener),
            ::uint64_t{0}};
    if ((!((aReader)->ReadBytesInto((&((result__)->chromeOuterWindowID())), 8)))) {
        aReader->FatalError("Error bulk reading fields from uint64_t");
        return {};
    }
    // Sentinel = 'chromeOuterWindowID'
    if ((!((aReader)->ReadSentinel(1303119763)))) {
        mozilla::ipc::SentinelReadError("Error bulk reading fields from uint64_t");
        return {};
    }
    return result__;
}

} // namespace IPC

//-----------------------------------------------------------------------------
// Method definitions for the IPDL type |struct FrameIPCTabContext|
//
namespace mozilla {
namespace dom {
} // namespace dom
} // namespace mozilla

namespace IPC {
auto ParamTraits<::mozilla::dom::FrameIPCTabContext>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    (aWriter)->WriteBytes((&((aVar).chromeOuterWindowID())), 8);
    // Sentinel = 'chromeOuterWindowID'
    (aWriter)->WriteSentinel(1303119763);
    (aWriter)->WriteBytes((&((aVar).maxTouchPoints())), 4);
    // Sentinel = 'maxTouchPoints'
    (aWriter)->WriteSentinel(719586759);
}

auto ParamTraits<::mozilla::dom::FrameIPCTabContext>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    IPC::ReadResult<paramType> result__{
            std::in_place,
            ::uint64_t{0},
            ::uint32_t{0}};
    if ((!((aReader)->ReadBytesInto((&((result__)->chromeOuterWindowID())), 8)))) {
        aReader->FatalError("Error bulk reading fields from uint64_t");
        return {};
    }
    // Sentinel = 'chromeOuterWindowID'
    if ((!((aReader)->ReadSentinel(1303119763)))) {
        mozilla::ipc::SentinelReadError("Error bulk reading fields from uint64_t");
        return {};
    }
    if ((!((aReader)->ReadBytesInto((&((result__)->maxTouchPoints())), 4)))) {
        aReader->FatalError("Error bulk reading fields from uint32_t");
        return {};
    }
    // Sentinel = 'maxTouchPoints'
    if ((!((aReader)->ReadSentinel(719586759)))) {
        mozilla::ipc::SentinelReadError("Error bulk reading fields from uint32_t");
        return {};
    }
    return result__;
}

} // namespace IPC

//-----------------------------------------------------------------------------
// Method definitions for the IPDL type |union IPCTabContext|
//
namespace mozilla {
namespace dom {
auto IPCTabContext::MaybeDestroy() -> void
{
    if ((mType) == (T__None)) {
        return;
    }
    switch (mType) {
    case TPopupIPCTabContext:
        {
            (ptr_PopupIPCTabContext())->~PopupIPCTabContext__tdef();
            break;
        }
    case TFrameIPCTabContext:
        {
            (ptr_FrameIPCTabContext())->~FrameIPCTabContext__tdef();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("not reached");
            break;
        }
    }
}

MOZ_IMPLICIT IPCTabContext::IPCTabContext(const PopupIPCTabContext& aOther)
{
    new (mozilla::KnownNotNull, ptr_PopupIPCTabContext()) PopupIPCTabContext(aOther);
    mType = TPopupIPCTabContext;
}

MOZ_IMPLICIT IPCTabContext::IPCTabContext(PopupIPCTabContext&& aOther)
{
    new (mozilla::KnownNotNull, ptr_PopupIPCTabContext()) PopupIPCTabContext(std::move(aOther));
    mType = TPopupIPCTabContext;
}

MOZ_IMPLICIT IPCTabContext::IPCTabContext(const FrameIPCTabContext& aOther)
{
    new (mozilla::KnownNotNull, ptr_FrameIPCTabContext()) FrameIPCTabContext(aOther);
    mType = TFrameIPCTabContext;
}

MOZ_IMPLICIT IPCTabContext::IPCTabContext(FrameIPCTabContext&& aOther)
{
    new (mozilla::KnownNotNull, ptr_FrameIPCTabContext()) FrameIPCTabContext(std::move(aOther));
    mType = TFrameIPCTabContext;
}

MOZ_IMPLICIT IPCTabContext::IPCTabContext(const IPCTabContext& aOther)
{
    (aOther).AssertSanity();
    switch ((aOther).type()) {
    case TPopupIPCTabContext:
        {
            new (mozilla::KnownNotNull, ptr_PopupIPCTabContext()) PopupIPCTabContext((aOther).get_PopupIPCTabContext());
            break;
        }
    case TFrameIPCTabContext:
        {
            new (mozilla::KnownNotNull, ptr_FrameIPCTabContext()) FrameIPCTabContext((aOther).get_FrameIPCTabContext());
            break;
        }
    case T__None:
        {
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            return;
        }
    }
    mType = (aOther).type();
}

MOZ_IMPLICIT IPCTabContext::IPCTabContext(IPCTabContext&& aOther)
{
    (aOther).AssertSanity();
    Type t = (aOther).type();
    switch (t) {
    case TPopupIPCTabContext:
        {
            new (mozilla::KnownNotNull, ptr_PopupIPCTabContext()) PopupIPCTabContext(std::move((aOther).get_PopupIPCTabContext()));
            (aOther).MaybeDestroy();
            break;
        }
    case TFrameIPCTabContext:
        {
            new (mozilla::KnownNotNull, ptr_FrameIPCTabContext()) FrameIPCTabContext(std::move((aOther).get_FrameIPCTabContext()));
            (aOther).MaybeDestroy();
            break;
        }
    case T__None:
        {
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            return;
        }
    }
    (aOther).mType = T__None;
    mType = t;
}

IPCTabContext::~IPCTabContext()
{
    MaybeDestroy();
}

auto IPCTabContext::operator=(const PopupIPCTabContext& aRhs) -> IPCTabContext&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_PopupIPCTabContext()) PopupIPCTabContext(aRhs);
    mType = TPopupIPCTabContext;
    return (*(this));
}

auto IPCTabContext::operator=(PopupIPCTabContext&& aRhs) -> IPCTabContext&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_PopupIPCTabContext()) PopupIPCTabContext(std::move(aRhs));
    mType = TPopupIPCTabContext;
    return (*(this));
}

auto IPCTabContext::operator=(const FrameIPCTabContext& aRhs) -> IPCTabContext&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_FrameIPCTabContext()) FrameIPCTabContext(aRhs);
    mType = TFrameIPCTabContext;
    return (*(this));
}

auto IPCTabContext::operator=(FrameIPCTabContext&& aRhs) -> IPCTabContext&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_FrameIPCTabContext()) FrameIPCTabContext(std::move(aRhs));
    mType = TFrameIPCTabContext;
    return (*(this));
}

auto IPCTabContext::operator=(const IPCTabContext& aRhs) -> IPCTabContext&
{
    (aRhs).AssertSanity();
    Type t = (aRhs).type();
    switch (t) {
    case TPopupIPCTabContext:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_PopupIPCTabContext()) PopupIPCTabContext((aRhs).get_PopupIPCTabContext());
            break;
        }
    case TFrameIPCTabContext:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_FrameIPCTabContext()) FrameIPCTabContext((aRhs).get_FrameIPCTabContext());
            break;
        }
    case T__None:
        {
            MaybeDestroy();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            break;
        }
    }
    mType = t;
    return (*(this));
}

auto IPCTabContext::operator=(IPCTabContext&& aRhs) -> IPCTabContext&
{
    (aRhs).AssertSanity();
    Type t = (aRhs).type();
    switch (t) {
    case TPopupIPCTabContext:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_PopupIPCTabContext()) PopupIPCTabContext(std::move((aRhs).get_PopupIPCTabContext()));
            (aRhs).MaybeDestroy();
            break;
        }
    case TFrameIPCTabContext:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_FrameIPCTabContext()) FrameIPCTabContext(std::move((aRhs).get_FrameIPCTabContext()));
            (aRhs).MaybeDestroy();
            break;
        }
    case T__None:
        {
            MaybeDestroy();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            break;
        }
    }
    (aRhs).mType = T__None;
    mType = t;
    return (*(this));
}

} // namespace dom
} // namespace mozilla

namespace IPC {
auto ParamTraits<::mozilla::dom::IPCTabContext>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    typedef ::mozilla::dom::IPCTabContext union__;
    int type = (aVar).type();
    IPC::WriteParam(aWriter, type);
    // Sentinel = 'IPCTabContext'
    (aWriter)->WriteSentinel(521929945);

    switch (type) {
    case union__::TPopupIPCTabContext:
        {
            IPC::WriteParam(aWriter, (aVar).get_PopupIPCTabContext());
            // Sentinel = 'TPopupIPCTabContext'
            (aWriter)->WriteSentinel(1180174145);
            return;
        }
    case union__::TFrameIPCTabContext:
        {
            IPC::WriteParam(aWriter, (aVar).get_FrameIPCTabContext());
            // Sentinel = 'TFrameIPCTabContext'
            (aWriter)->WriteSentinel(1138034456);
            return;
        }
    default:
        {
            aWriter->FatalError("unknown variant of union IPCTabContext");
            return;
        }
    }
}

auto ParamTraits<::mozilla::dom::IPCTabContext>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    typedef ::mozilla::dom::IPCTabContext union__;
    auto maybe__type = IPC::ReadParam<int>(aReader);
    if (!maybe__type) {
        aReader->FatalError("Error deserializing type of union IPCTabContext");
        return {};

    }
    auto& type = *maybe__type;
    // Sentinel = 'IPCTabContext'
    if ((!((aReader)->ReadSentinel(521929945)))) {
        mozilla::ipc::SentinelReadError("Error deserializing type of union IPCTabContext");
        return {};
    }

    switch (type) {
    case union__::TPopupIPCTabContext:
        {
            auto maybe__tmp = IPC::ReadParam<::mozilla::dom::PopupIPCTabContext>(aReader);
            if (!maybe__tmp) {
                aReader->FatalError("Error deserializing variant TPopupIPCTabContext of union IPCTabContext");
                return {};

            }
            auto& tmp = *maybe__tmp;
            // Sentinel = 'TPopupIPCTabContext'
            if ((!((aReader)->ReadSentinel(1180174145)))) {
                mozilla::ipc::SentinelReadError("Error deserializing variant TPopupIPCTabContext of union IPCTabContext");
                return {};
            }
            return std::move(tmp);
        }
    case union__::TFrameIPCTabContext:
        {
            auto maybe__tmp = IPC::ReadParam<::mozilla::dom::FrameIPCTabContext>(aReader);
            if (!maybe__tmp) {
                aReader->FatalError("Error deserializing variant TFrameIPCTabContext of union IPCTabContext");
                return {};

            }
            auto& tmp = *maybe__tmp;
            // Sentinel = 'TFrameIPCTabContext'
            if ((!((aReader)->ReadSentinel(1138034456)))) {
                mozilla::ipc::SentinelReadError("Error deserializing variant TFrameIPCTabContext of union IPCTabContext");
                return {};
            }
            return std::move(tmp);
        }
    default:
        {
            aReader->FatalError("unknown variant of union IPCTabContext");
            return {};
        }
    }
}

} // namespace IPC
