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


#include "mozilla/GfxMessageUtils.h"
#include "mozilla/GfxMessageUtils.h"
#include "mozilla/widget/PlatformWidgetTypes.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 GtkCompositorWidgetInitData|
//
namespace mozilla {
namespace widget {
} // namespace widget
} // namespace mozilla

namespace IPC {
auto ParamTraits<::mozilla::widget::GtkCompositorWidgetInitData>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    IPC::WriteParam(aWriter, (aVar).XWindow());
    // Sentinel = 'XWindow'
    (aWriter)->WriteSentinel(180290257);
    IPC::WriteParam(aWriter, (aVar).XDisplayString());
    // Sentinel = 'XDisplayString'
    (aWriter)->WriteSentinel(690881958);
    IPC::WriteParam(aWriter, (aVar).IsX11Display());
    // Sentinel = 'IsX11Display'
    (aWriter)->WriteSentinel(434766925);
    IPC::WriteParam(aWriter, (aVar).InitialClientSize());
    // Sentinel = 'InitialClientSize'
    (aWriter)->WriteSentinel(1006307013);
}

auto ParamTraits<::mozilla::widget::GtkCompositorWidgetInitData>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    auto maybe___XWindow = IPC::ReadParam<::uintptr_t>(aReader);
    if (!maybe___XWindow) {
        aReader->FatalError("Error deserializing 'XWindow' (uintptr_t) member of 'GtkCompositorWidgetInitData'");
        return {};

    }
    auto& _XWindow = *maybe___XWindow;
    // Sentinel = 'XWindow'
    if ((!((aReader)->ReadSentinel(180290257)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'XWindow' (uintptr_t) member of 'GtkCompositorWidgetInitData'");
        return {};
    }
    auto maybe___XDisplayString = IPC::ReadParam<::nsCString>(aReader);
    if (!maybe___XDisplayString) {
        aReader->FatalError("Error deserializing 'XDisplayString' (nsCString) member of 'GtkCompositorWidgetInitData'");
        return {};

    }
    auto& _XDisplayString = *maybe___XDisplayString;
    // Sentinel = 'XDisplayString'
    if ((!((aReader)->ReadSentinel(690881958)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'XDisplayString' (nsCString) member of 'GtkCompositorWidgetInitData'");
        return {};
    }
    auto maybe___IsX11Display = IPC::ReadParam<bool>(aReader);
    if (!maybe___IsX11Display) {
        aReader->FatalError("Error deserializing 'IsX11Display' (bool) member of 'GtkCompositorWidgetInitData'");
        return {};

    }
    auto& _IsX11Display = *maybe___IsX11Display;
    // Sentinel = 'IsX11Display'
    if ((!((aReader)->ReadSentinel(434766925)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'IsX11Display' (bool) member of 'GtkCompositorWidgetInitData'");
        return {};
    }
    auto maybe___InitialClientSize = IPC::ReadParam<::mozilla::LayoutDeviceIntSize>(aReader);
    if (!maybe___InitialClientSize) {
        aReader->FatalError("Error deserializing 'InitialClientSize' (LayoutDeviceIntSize) member of 'GtkCompositorWidgetInitData'");
        return {};

    }
    auto& _InitialClientSize = *maybe___InitialClientSize;
    // Sentinel = 'InitialClientSize'
    if ((!((aReader)->ReadSentinel(1006307013)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'InitialClientSize' (LayoutDeviceIntSize) member of 'GtkCompositorWidgetInitData'");
        return {};
    }
    IPC::ReadResult<paramType> result__{
            std::in_place,
            std::move(_XWindow),
            std::move(_XDisplayString),
            std::move(_IsX11Display),
            std::move(_InitialClientSize)};
    return result__;
}

} // namespace IPC

//-----------------------------------------------------------------------------
// Method definitions for the IPDL type |union CompositorWidgetInitData|
//
namespace mozilla {
namespace widget {
auto CompositorWidgetInitData::MaybeDestroy() -> void
{
    if ((mType) == (T__None)) {
        return;
    }
    switch (mType) {
    case TGtkCompositorWidgetInitData:
        {
            (ptr_GtkCompositorWidgetInitData())->~GtkCompositorWidgetInitData__tdef();
            break;
        }
    case THeadlessCompositorWidgetInitData:
        {
            (ptr_HeadlessCompositorWidgetInitData())->~HeadlessCompositorWidgetInitData__tdef();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("not reached");
            break;
        }
    }
}

MOZ_IMPLICIT CompositorWidgetInitData::CompositorWidgetInitData(const GtkCompositorWidgetInitData& aOther)
{
    new (mozilla::KnownNotNull, ptr_GtkCompositorWidgetInitData()) GtkCompositorWidgetInitData(aOther);
    mType = TGtkCompositorWidgetInitData;
}

MOZ_IMPLICIT CompositorWidgetInitData::CompositorWidgetInitData(GtkCompositorWidgetInitData&& aOther)
{
    new (mozilla::KnownNotNull, ptr_GtkCompositorWidgetInitData()) GtkCompositorWidgetInitData(std::move(aOther));
    mType = TGtkCompositorWidgetInitData;
}

MOZ_IMPLICIT CompositorWidgetInitData::CompositorWidgetInitData(const HeadlessCompositorWidgetInitData& aOther)
{
    new (mozilla::KnownNotNull, ptr_HeadlessCompositorWidgetInitData()) HeadlessCompositorWidgetInitData(aOther);
    mType = THeadlessCompositorWidgetInitData;
}

MOZ_IMPLICIT CompositorWidgetInitData::CompositorWidgetInitData(HeadlessCompositorWidgetInitData&& aOther)
{
    new (mozilla::KnownNotNull, ptr_HeadlessCompositorWidgetInitData()) HeadlessCompositorWidgetInitData(std::move(aOther));
    mType = THeadlessCompositorWidgetInitData;
}

MOZ_IMPLICIT CompositorWidgetInitData::CompositorWidgetInitData(const CompositorWidgetInitData& aOther)
{
    (aOther).AssertSanity();
    switch ((aOther).type()) {
    case TGtkCompositorWidgetInitData:
        {
            new (mozilla::KnownNotNull, ptr_GtkCompositorWidgetInitData()) GtkCompositorWidgetInitData((aOther).get_GtkCompositorWidgetInitData());
            break;
        }
    case THeadlessCompositorWidgetInitData:
        {
            new (mozilla::KnownNotNull, ptr_HeadlessCompositorWidgetInitData()) HeadlessCompositorWidgetInitData((aOther).get_HeadlessCompositorWidgetInitData());
            break;
        }
    case T__None:
        {
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            return;
        }
    }
    mType = (aOther).type();
}

MOZ_IMPLICIT CompositorWidgetInitData::CompositorWidgetInitData(CompositorWidgetInitData&& aOther)
{
    (aOther).AssertSanity();
    Type t = (aOther).type();
    switch (t) {
    case TGtkCompositorWidgetInitData:
        {
            new (mozilla::KnownNotNull, ptr_GtkCompositorWidgetInitData()) GtkCompositorWidgetInitData(std::move((aOther).get_GtkCompositorWidgetInitData()));
            (aOther).MaybeDestroy();
            break;
        }
    case THeadlessCompositorWidgetInitData:
        {
            new (mozilla::KnownNotNull, ptr_HeadlessCompositorWidgetInitData()) HeadlessCompositorWidgetInitData(std::move((aOther).get_HeadlessCompositorWidgetInitData()));
            (aOther).MaybeDestroy();
            break;
        }
    case T__None:
        {
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            return;
        }
    }
    (aOther).mType = T__None;
    mType = t;
}

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

auto CompositorWidgetInitData::operator=(const GtkCompositorWidgetInitData& aRhs) -> CompositorWidgetInitData&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_GtkCompositorWidgetInitData()) GtkCompositorWidgetInitData(aRhs);
    mType = TGtkCompositorWidgetInitData;
    return (*(this));
}

auto CompositorWidgetInitData::operator=(GtkCompositorWidgetInitData&& aRhs) -> CompositorWidgetInitData&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_GtkCompositorWidgetInitData()) GtkCompositorWidgetInitData(std::move(aRhs));
    mType = TGtkCompositorWidgetInitData;
    return (*(this));
}

auto CompositorWidgetInitData::operator=(const HeadlessCompositorWidgetInitData& aRhs) -> CompositorWidgetInitData&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_HeadlessCompositorWidgetInitData()) HeadlessCompositorWidgetInitData(aRhs);
    mType = THeadlessCompositorWidgetInitData;
    return (*(this));
}

auto CompositorWidgetInitData::operator=(HeadlessCompositorWidgetInitData&& aRhs) -> CompositorWidgetInitData&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_HeadlessCompositorWidgetInitData()) HeadlessCompositorWidgetInitData(std::move(aRhs));
    mType = THeadlessCompositorWidgetInitData;
    return (*(this));
}

auto CompositorWidgetInitData::operator=(const CompositorWidgetInitData& aRhs) -> CompositorWidgetInitData&
{
    (aRhs).AssertSanity();
    Type t = (aRhs).type();
    switch (t) {
    case TGtkCompositorWidgetInitData:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_GtkCompositorWidgetInitData()) GtkCompositorWidgetInitData((aRhs).get_GtkCompositorWidgetInitData());
            break;
        }
    case THeadlessCompositorWidgetInitData:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_HeadlessCompositorWidgetInitData()) HeadlessCompositorWidgetInitData((aRhs).get_HeadlessCompositorWidgetInitData());
            break;
        }
    case T__None:
        {
            MaybeDestroy();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            break;
        }
    }
    mType = t;
    return (*(this));
}

auto CompositorWidgetInitData::operator=(CompositorWidgetInitData&& aRhs) -> CompositorWidgetInitData&
{
    (aRhs).AssertSanity();
    Type t = (aRhs).type();
    switch (t) {
    case TGtkCompositorWidgetInitData:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_GtkCompositorWidgetInitData()) GtkCompositorWidgetInitData(std::move((aRhs).get_GtkCompositorWidgetInitData()));
            (aRhs).MaybeDestroy();
            break;
        }
    case THeadlessCompositorWidgetInitData:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_HeadlessCompositorWidgetInitData()) HeadlessCompositorWidgetInitData(std::move((aRhs).get_HeadlessCompositorWidgetInitData()));
            (aRhs).MaybeDestroy();
            break;
        }
    case T__None:
        {
            MaybeDestroy();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            break;
        }
    }
    (aRhs).mType = T__None;
    mType = t;
    return (*(this));
}

} // namespace widget
} // namespace mozilla

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

    switch (type) {
    case union__::TGtkCompositorWidgetInitData:
        {
            IPC::WriteParam(aWriter, (aVar).get_GtkCompositorWidgetInitData());
            // Sentinel = 'TGtkCompositorWidgetInitData'
            (aWriter)->WriteSentinel(2692090652);
            return;
        }
    case union__::THeadlessCompositorWidgetInitData:
        {
            IPC::WriteParam(aWriter, (aVar).get_HeadlessCompositorWidgetInitData());
            // Sentinel = 'THeadlessCompositorWidgetInitData'
            (aWriter)->WriteSentinel(3719564575);
            return;
        }
    default:
        {
            aWriter->FatalError("unknown variant of union CompositorWidgetInitData");
            return;
        }
    }
}

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

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

    switch (type) {
    case union__::TGtkCompositorWidgetInitData:
        {
            auto maybe__tmp = IPC::ReadParam<::mozilla::widget::GtkCompositorWidgetInitData>(aReader);
            if (!maybe__tmp) {
                aReader->FatalError("Error deserializing variant TGtkCompositorWidgetInitData of union CompositorWidgetInitData");
                return {};

            }
            auto& tmp = *maybe__tmp;
            // Sentinel = 'TGtkCompositorWidgetInitData'
            if ((!((aReader)->ReadSentinel(2692090652)))) {
                mozilla::ipc::SentinelReadError("Error deserializing variant TGtkCompositorWidgetInitData of union CompositorWidgetInitData");
                return {};
            }
            return std::move(tmp);
        }
    case union__::THeadlessCompositorWidgetInitData:
        {
            auto maybe__tmp = IPC::ReadParam<::mozilla::widget::HeadlessCompositorWidgetInitData>(aReader);
            if (!maybe__tmp) {
                aReader->FatalError("Error deserializing variant THeadlessCompositorWidgetInitData of union CompositorWidgetInitData");
                return {};

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

} // namespace IPC
