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


#include "mozilla/webgpu/PWebGPUTypes.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 BufferMapSuccess|
//
namespace mozilla {
namespace webgpu {
auto BufferMapSuccess::StaticAssertions() const -> void
{
    static_assert(
        (offsetof(BufferMapSuccess, size_) - offsetof(BufferMapSuccess, offset_)) == 8,
        "Bad assumptions about field layout!");
}

} // namespace webgpu
} // namespace mozilla

namespace IPC {
auto ParamTraits<::mozilla::webgpu::BufferMapSuccess>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    IPC::WriteParam(aWriter, (aVar).writable());
    // Sentinel = 'writable'
    (aWriter)->WriteSentinel(259982171);
    (aWriter)->WriteBytes((&((aVar).offset())), 16);
    // Sentinel = 'offset | size'
    (aWriter)->WriteSentinel(592250111);
}

auto ParamTraits<::mozilla::webgpu::BufferMapSuccess>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    auto maybe___writable = IPC::ReadParam<bool>(aReader);
    if (!maybe___writable) {
        aReader->FatalError("Error deserializing 'writable' (bool) member of 'BufferMapSuccess'");
        return {};

    }
    auto& _writable = *maybe___writable;
    // Sentinel = 'writable'
    if ((!((aReader)->ReadSentinel(259982171)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'writable' (bool) member of 'BufferMapSuccess'");
        return {};
    }
    IPC::ReadResult<paramType> result__{
            std::in_place,
            ::uint64_t{0},
            ::uint64_t{0},
            std::move(_writable)};
    if ((!((aReader)->ReadBytesInto((&((result__)->offset())), 16)))) {
        aReader->FatalError("Error bulk reading fields from uint64_t");
        return {};
    }
    // Sentinel = 'offset | size'
    if ((!((aReader)->ReadSentinel(592250111)))) {
        mozilla::ipc::SentinelReadError("Error bulk reading fields from uint64_t");
        return {};
    }
    return result__;
}

} // namespace IPC

//-----------------------------------------------------------------------------
// Method definitions for the IPDL type |struct BufferMapError|
//
namespace mozilla {
namespace webgpu {
} // namespace webgpu
} // namespace mozilla

namespace IPC {
auto ParamTraits<::mozilla::webgpu::BufferMapError>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    IPC::WriteParam(aWriter, (aVar).message());
    // Sentinel = 'message'
    (aWriter)->WriteSentinel(197198566);
}

auto ParamTraits<::mozilla::webgpu::BufferMapError>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    auto maybe___message = IPC::ReadParam<::nsCString>(aReader);
    if (!maybe___message) {
        aReader->FatalError("Error deserializing 'message' (nsCString) member of 'BufferMapError'");
        return {};

    }
    auto& _message = *maybe___message;
    // Sentinel = 'message'
    if ((!((aReader)->ReadSentinel(197198566)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'message' (nsCString) member of 'BufferMapError'");
        return {};
    }
    IPC::ReadResult<paramType> result__{
            std::in_place,
            std::move(_message)};
    return result__;
}

} // namespace IPC

//-----------------------------------------------------------------------------
// Method definitions for the IPDL type |union BufferMapResult|
//
namespace mozilla {
namespace webgpu {
auto BufferMapResult::MaybeDestroy() -> void
{
    if ((mType) == (T__None)) {
        return;
    }
    switch (mType) {
    case TBufferMapSuccess:
        {
            (ptr_BufferMapSuccess())->~BufferMapSuccess__tdef();
            break;
        }
    case TBufferMapError:
        {
            (ptr_BufferMapError())->~BufferMapError__tdef();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("not reached");
            break;
        }
    }
}

MOZ_IMPLICIT BufferMapResult::BufferMapResult(const BufferMapSuccess& aOther)
{
    new (mozilla::KnownNotNull, ptr_BufferMapSuccess()) BufferMapSuccess(aOther);
    mType = TBufferMapSuccess;
}

MOZ_IMPLICIT BufferMapResult::BufferMapResult(BufferMapSuccess&& aOther)
{
    new (mozilla::KnownNotNull, ptr_BufferMapSuccess()) BufferMapSuccess(std::move(aOther));
    mType = TBufferMapSuccess;
}

MOZ_IMPLICIT BufferMapResult::BufferMapResult(const BufferMapError& aOther)
{
    new (mozilla::KnownNotNull, ptr_BufferMapError()) BufferMapError(aOther);
    mType = TBufferMapError;
}

MOZ_IMPLICIT BufferMapResult::BufferMapResult(BufferMapError&& aOther)
{
    new (mozilla::KnownNotNull, ptr_BufferMapError()) BufferMapError(std::move(aOther));
    mType = TBufferMapError;
}

MOZ_IMPLICIT BufferMapResult::BufferMapResult(const BufferMapResult& aOther)
{
    (aOther).AssertSanity();
    switch ((aOther).type()) {
    case TBufferMapSuccess:
        {
            new (mozilla::KnownNotNull, ptr_BufferMapSuccess()) BufferMapSuccess((aOther).get_BufferMapSuccess());
            break;
        }
    case TBufferMapError:
        {
            new (mozilla::KnownNotNull, ptr_BufferMapError()) BufferMapError((aOther).get_BufferMapError());
            break;
        }
    case T__None:
        {
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            return;
        }
    }
    mType = (aOther).type();
}

MOZ_IMPLICIT BufferMapResult::BufferMapResult(BufferMapResult&& aOther)
{
    (aOther).AssertSanity();
    Type t = (aOther).type();
    switch (t) {
    case TBufferMapSuccess:
        {
            new (mozilla::KnownNotNull, ptr_BufferMapSuccess()) BufferMapSuccess(std::move((aOther).get_BufferMapSuccess()));
            (aOther).MaybeDestroy();
            break;
        }
    case TBufferMapError:
        {
            new (mozilla::KnownNotNull, ptr_BufferMapError()) BufferMapError(std::move((aOther).get_BufferMapError()));
            (aOther).MaybeDestroy();
            break;
        }
    case T__None:
        {
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            return;
        }
    }
    (aOther).mType = T__None;
    mType = t;
}

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

auto BufferMapResult::operator=(const BufferMapSuccess& aRhs) -> BufferMapResult&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_BufferMapSuccess()) BufferMapSuccess(aRhs);
    mType = TBufferMapSuccess;
    return (*(this));
}

auto BufferMapResult::operator=(BufferMapSuccess&& aRhs) -> BufferMapResult&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_BufferMapSuccess()) BufferMapSuccess(std::move(aRhs));
    mType = TBufferMapSuccess;
    return (*(this));
}

auto BufferMapResult::operator=(const BufferMapError& aRhs) -> BufferMapResult&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_BufferMapError()) BufferMapError(aRhs);
    mType = TBufferMapError;
    return (*(this));
}

auto BufferMapResult::operator=(BufferMapError&& aRhs) -> BufferMapResult&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_BufferMapError()) BufferMapError(std::move(aRhs));
    mType = TBufferMapError;
    return (*(this));
}

auto BufferMapResult::operator=(const BufferMapResult& aRhs) -> BufferMapResult&
{
    (aRhs).AssertSanity();
    Type t = (aRhs).type();
    switch (t) {
    case TBufferMapSuccess:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_BufferMapSuccess()) BufferMapSuccess((aRhs).get_BufferMapSuccess());
            break;
        }
    case TBufferMapError:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_BufferMapError()) BufferMapError((aRhs).get_BufferMapError());
            break;
        }
    case T__None:
        {
            MaybeDestroy();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            break;
        }
    }
    mType = t;
    return (*(this));
}

auto BufferMapResult::operator=(BufferMapResult&& aRhs) -> BufferMapResult&
{
    (aRhs).AssertSanity();
    Type t = (aRhs).type();
    switch (t) {
    case TBufferMapSuccess:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_BufferMapSuccess()) BufferMapSuccess(std::move((aRhs).get_BufferMapSuccess()));
            (aRhs).MaybeDestroy();
            break;
        }
    case TBufferMapError:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_BufferMapError()) BufferMapError(std::move((aRhs).get_BufferMapError()));
            (aRhs).MaybeDestroy();
            break;
        }
    case T__None:
        {
            MaybeDestroy();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            break;
        }
    }
    (aRhs).mType = T__None;
    mType = t;
    return (*(this));
}

} // namespace webgpu
} // namespace mozilla

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

    switch (type) {
    case union__::TBufferMapSuccess:
        {
            IPC::WriteParam(aWriter, (aVar).get_BufferMapSuccess());
            // Sentinel = 'TBufferMapSuccess'
            (aWriter)->WriteSentinel(972359334);
            return;
        }
    case union__::TBufferMapError:
        {
            IPC::WriteParam(aWriter, (aVar).get_BufferMapError());
            // Sentinel = 'TBufferMapError'
            (aWriter)->WriteSentinel(756811223);
            return;
        }
    default:
        {
            aWriter->FatalError("unknown variant of union BufferMapResult");
            return;
        }
    }
}

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

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

    switch (type) {
    case union__::TBufferMapSuccess:
        {
            auto maybe__tmp = IPC::ReadParam<::mozilla::webgpu::BufferMapSuccess>(aReader);
            if (!maybe__tmp) {
                aReader->FatalError("Error deserializing variant TBufferMapSuccess of union BufferMapResult");
                return {};

            }
            auto& tmp = *maybe__tmp;
            // Sentinel = 'TBufferMapSuccess'
            if ((!((aReader)->ReadSentinel(972359334)))) {
                mozilla::ipc::SentinelReadError("Error deserializing variant TBufferMapSuccess of union BufferMapResult");
                return {};
            }
            return std::move(tmp);
        }
    case union__::TBufferMapError:
        {
            auto maybe__tmp = IPC::ReadParam<::mozilla::webgpu::BufferMapError>(aReader);
            if (!maybe__tmp) {
                aReader->FatalError("Error deserializing variant TBufferMapError of union BufferMapResult");
                return {};

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

} // namespace IPC
