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


#include "mozilla/dom/IPCBlob.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 |union RemoteLazyStream|
//
namespace mozilla {
auto RemoteLazyStream::MaybeDestroy() -> void
{
    if ((mType) == (T__None)) {
        return;
    }
    switch (mType) {
    case TRemoteLazyInputStream:
        {
            (ptr_RemoteLazyInputStream())->~RemoteLazyInputStream__tdef();
            break;
        }
    case TIPCStream:
        {
            (ptr_IPCStream())->~IPCStream__tdef();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("not reached");
            break;
        }
    }
}

MOZ_IMPLICIT RemoteLazyStream::RemoteLazyStream(RemoteLazyInputStream* aOther)
{
    new (mozilla::KnownNotNull, ptr_RemoteLazyInputStream()) RefPtr<RemoteLazyInputStream>(aOther);
    mType = TRemoteLazyInputStream;
}

MOZ_IMPLICIT RemoteLazyStream::RemoteLazyStream(RefPtr<RemoteLazyInputStream>&& aOther)
{
    new (mozilla::KnownNotNull, ptr_RemoteLazyInputStream()) RefPtr<RemoteLazyInputStream>(std::move(aOther));
    mType = TRemoteLazyInputStream;
}

MOZ_IMPLICIT RemoteLazyStream::RemoteLazyStream(const IPCStream& aOther)
{
    new (mozilla::KnownNotNull, ptr_IPCStream()) IPCStream(aOther);
    mType = TIPCStream;
}

MOZ_IMPLICIT RemoteLazyStream::RemoteLazyStream(IPCStream&& aOther)
{
    new (mozilla::KnownNotNull, ptr_IPCStream()) IPCStream(std::move(aOther));
    mType = TIPCStream;
}

MOZ_IMPLICIT RemoteLazyStream::RemoteLazyStream(const RemoteLazyStream& aOther)
{
    (aOther).AssertSanity();
    switch ((aOther).type()) {
    case TRemoteLazyInputStream:
        {
            new (mozilla::KnownNotNull, ptr_RemoteLazyInputStream()) RefPtr<RemoteLazyInputStream>((aOther).get_RemoteLazyInputStream());
            break;
        }
    case TIPCStream:
        {
            new (mozilla::KnownNotNull, ptr_IPCStream()) IPCStream((aOther).get_IPCStream());
            break;
        }
    case T__None:
        {
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            return;
        }
    }
    mType = (aOther).type();
}

MOZ_IMPLICIT RemoteLazyStream::RemoteLazyStream(RemoteLazyStream&& aOther)
{
    (aOther).AssertSanity();
    Type t = (aOther).type();
    switch (t) {
    case TRemoteLazyInputStream:
        {
            new (mozilla::KnownNotNull, ptr_RemoteLazyInputStream()) RefPtr<RemoteLazyInputStream>(std::move((aOther).get_RemoteLazyInputStream()));
            (aOther).MaybeDestroy();
            break;
        }
    case TIPCStream:
        {
            new (mozilla::KnownNotNull, ptr_IPCStream()) IPCStream(std::move((aOther).get_IPCStream()));
            (aOther).MaybeDestroy();
            break;
        }
    case T__None:
        {
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            return;
        }
    }
    (aOther).mType = T__None;
    mType = t;
}

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

auto RemoteLazyStream::operator=(RemoteLazyInputStream* aRhs) -> RemoteLazyStream&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_RemoteLazyInputStream()) RefPtr<RemoteLazyInputStream>(aRhs);
    mType = TRemoteLazyInputStream;
    return (*(this));
}

auto RemoteLazyStream::operator=(RefPtr<RemoteLazyInputStream>&& aRhs) -> RemoteLazyStream&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_RemoteLazyInputStream()) RefPtr<RemoteLazyInputStream>(std::move(aRhs));
    mType = TRemoteLazyInputStream;
    return (*(this));
}

auto RemoteLazyStream::operator=(const IPCStream& aRhs) -> RemoteLazyStream&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_IPCStream()) IPCStream(aRhs);
    mType = TIPCStream;
    return (*(this));
}

auto RemoteLazyStream::operator=(IPCStream&& aRhs) -> RemoteLazyStream&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_IPCStream()) IPCStream(std::move(aRhs));
    mType = TIPCStream;
    return (*(this));
}

auto RemoteLazyStream::operator=(const RemoteLazyStream& aRhs) -> RemoteLazyStream&
{
    (aRhs).AssertSanity();
    Type t = (aRhs).type();
    switch (t) {
    case TRemoteLazyInputStream:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_RemoteLazyInputStream()) RefPtr<RemoteLazyInputStream>((aRhs).get_RemoteLazyInputStream());
            break;
        }
    case TIPCStream:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_IPCStream()) IPCStream((aRhs).get_IPCStream());
            break;
        }
    case T__None:
        {
            MaybeDestroy();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            break;
        }
    }
    mType = t;
    return (*(this));
}

auto RemoteLazyStream::operator=(RemoteLazyStream&& aRhs) -> RemoteLazyStream&
{
    (aRhs).AssertSanity();
    Type t = (aRhs).type();
    switch (t) {
    case TRemoteLazyInputStream:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_RemoteLazyInputStream()) RefPtr<RemoteLazyInputStream>(std::move((aRhs).get_RemoteLazyInputStream()));
            (aRhs).MaybeDestroy();
            break;
        }
    case TIPCStream:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_IPCStream()) IPCStream(std::move((aRhs).get_IPCStream()));
            (aRhs).MaybeDestroy();
            break;
        }
    case T__None:
        {
            MaybeDestroy();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            break;
        }
    }
    (aRhs).mType = T__None;
    mType = t;
    return (*(this));
}

} // namespace mozilla

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

    switch (type) {
    case union__::TRemoteLazyInputStream:
        {
            IPC::WriteParam(aWriter, (aVar).get_RemoteLazyInputStream());
            // Sentinel = 'TRemoteLazyInputStream'
            (aWriter)->WriteSentinel(1677986013);
            return;
        }
    case union__::TIPCStream:
        {
            IPC::WriteParam(aWriter, (aVar).get_IPCStream());
            // Sentinel = 'TIPCStream'
            (aWriter)->WriteSentinel(311690141);
            return;
        }
    default:
        {
            aWriter->FatalError("unknown variant of union RemoteLazyStream");
            return;
        }
    }
}

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

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

    switch (type) {
    case union__::TRemoteLazyInputStream:
        {
            auto maybe__tmp = IPC::ReadParam<RefPtr<::mozilla::RemoteLazyInputStream>>(aReader);
            if (!maybe__tmp) {
                aReader->FatalError("Error deserializing variant TRemoteLazyInputStream of union RemoteLazyStream");
                return {};

            }
            auto& tmp = *maybe__tmp;
            // Sentinel = 'TRemoteLazyInputStream'
            if ((!((aReader)->ReadSentinel(1677986013)))) {
                mozilla::ipc::SentinelReadError("Error deserializing variant TRemoteLazyInputStream of union RemoteLazyStream");
                return {};
            }
            return std::move(tmp);
        }
    case union__::TIPCStream:
        {
            auto maybe__tmp = IPC::ReadParam<::mozilla::ipc::IPCStream>(aReader);
            if (!maybe__tmp) {
                aReader->FatalError("Error deserializing variant TIPCStream of union RemoteLazyStream");
                return {};

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

} // namespace IPC

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

namespace IPC {
auto ParamTraits<::mozilla::dom::IPCFile>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    IPC::WriteParam(aWriter, (aVar).name());
    // Sentinel = 'name'
    (aWriter)->WriteSentinel(69075362);
    IPC::WriteParam(aWriter, (aVar).DOMPath());
    // Sentinel = 'DOMPath'
    (aWriter)->WriteSentinel(150012526);
    IPC::WriteParam(aWriter, (aVar).fullPath());
    // Sentinel = 'fullPath'
    (aWriter)->WriteSentinel(247595841);
    IPC::WriteParam(aWriter, (aVar).isDirectory());
    // Sentinel = 'isDirectory'
    (aWriter)->WriteSentinel(446497938);
    (aWriter)->WriteBytes((&((aVar).lastModified())), 8);
    // Sentinel = 'lastModified'
    (aWriter)->WriteSentinel(531629270);
}

auto ParamTraits<::mozilla::dom::IPCFile>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    auto maybe___name = IPC::ReadParam<::nsString>(aReader);
    if (!maybe___name) {
        aReader->FatalError("Error deserializing 'name' (nsString) member of 'IPCFile'");
        return {};

    }
    auto& _name = *maybe___name;
    // Sentinel = 'name'
    if ((!((aReader)->ReadSentinel(69075362)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'name' (nsString) member of 'IPCFile'");
        return {};
    }
    auto maybe___DOMPath = IPC::ReadParam<::nsString>(aReader);
    if (!maybe___DOMPath) {
        aReader->FatalError("Error deserializing 'DOMPath' (nsString) member of 'IPCFile'");
        return {};

    }
    auto& _DOMPath = *maybe___DOMPath;
    // Sentinel = 'DOMPath'
    if ((!((aReader)->ReadSentinel(150012526)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'DOMPath' (nsString) member of 'IPCFile'");
        return {};
    }
    auto maybe___fullPath = IPC::ReadParam<::nsString>(aReader);
    if (!maybe___fullPath) {
        aReader->FatalError("Error deserializing 'fullPath' (nsString) member of 'IPCFile'");
        return {};

    }
    auto& _fullPath = *maybe___fullPath;
    // Sentinel = 'fullPath'
    if ((!((aReader)->ReadSentinel(247595841)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'fullPath' (nsString) member of 'IPCFile'");
        return {};
    }
    auto maybe___isDirectory = IPC::ReadParam<bool>(aReader);
    if (!maybe___isDirectory) {
        aReader->FatalError("Error deserializing 'isDirectory' (bool) member of 'IPCFile'");
        return {};

    }
    auto& _isDirectory = *maybe___isDirectory;
    // Sentinel = 'isDirectory'
    if ((!((aReader)->ReadSentinel(446497938)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'isDirectory' (bool) member of 'IPCFile'");
        return {};
    }
    IPC::ReadResult<paramType> result__{
            std::in_place,
            std::move(_name),
            ::int64_t{0},
            std::move(_DOMPath),
            std::move(_fullPath),
            std::move(_isDirectory)};
    if ((!((aReader)->ReadBytesInto((&((result__)->lastModified())), 8)))) {
        aReader->FatalError("Error bulk reading fields from int64_t");
        return {};
    }
    // Sentinel = 'lastModified'
    if ((!((aReader)->ReadSentinel(531629270)))) {
        mozilla::ipc::SentinelReadError("Error bulk reading fields from int64_t");
        return {};
    }
    return result__;
}

} // namespace IPC

//-----------------------------------------------------------------------------
// Method definitions for the IPDL type |struct IPCBlob|
//
namespace mozilla {
namespace dom {
auto IPCBlob::StaticAssertions() const -> void
{
    static_assert(
        (offsetof(IPCBlob, fileId_) - offsetof(IPCBlob, size_)) == 8,
        "Bad assumptions about field layout!");
}

} // namespace dom
} // namespace mozilla

namespace IPC {
auto ParamTraits<::mozilla::dom::IPCBlob>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    IPC::WriteParam(aWriter, (aVar).type());
    // Sentinel = 'type'
    (aWriter)->WriteSentinel(75760067);
    IPC::WriteParam(aWriter, (aVar).blobImplType());
    // Sentinel = 'blobImplType'
    (aWriter)->WriteSentinel(521077972);
    IPC::WriteParam(aWriter, (aVar).inputStream());
    // Sentinel = 'inputStream'
    (aWriter)->WriteSentinel(469370013);
    IPC::WriteParam(aWriter, (aVar).file());
    // Sentinel = 'file'
    (aWriter)->WriteSentinel(68420001);
    (aWriter)->WriteBytes((&((aVar).size())), 16);
    // Sentinel = 'size | fileId'
    (aWriter)->WriteSentinel(572916933);
}

auto ParamTraits<::mozilla::dom::IPCBlob>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    auto maybe___type = IPC::ReadParam<::nsString>(aReader);
    if (!maybe___type) {
        aReader->FatalError("Error deserializing 'type' (nsString) member of 'IPCBlob'");
        return {};

    }
    auto& _type = *maybe___type;
    // Sentinel = 'type'
    if ((!((aReader)->ReadSentinel(75760067)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'type' (nsString) member of 'IPCBlob'");
        return {};
    }
    auto maybe___blobImplType = IPC::ReadParam<::nsString>(aReader);
    if (!maybe___blobImplType) {
        aReader->FatalError("Error deserializing 'blobImplType' (nsString) member of 'IPCBlob'");
        return {};

    }
    auto& _blobImplType = *maybe___blobImplType;
    // Sentinel = 'blobImplType'
    if ((!((aReader)->ReadSentinel(521077972)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'blobImplType' (nsString) member of 'IPCBlob'");
        return {};
    }
    auto maybe___inputStream = IPC::ReadParam<::mozilla::RemoteLazyStream>(aReader);
    if (!maybe___inputStream) {
        aReader->FatalError("Error deserializing 'inputStream' (RemoteLazyStream) member of 'IPCBlob'");
        return {};

    }
    auto& _inputStream = *maybe___inputStream;
    // Sentinel = 'inputStream'
    if ((!((aReader)->ReadSentinel(469370013)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'inputStream' (RemoteLazyStream) member of 'IPCBlob'");
        return {};
    }
    auto maybe___file = IPC::ReadParam<mozilla::Maybe<::mozilla::dom::IPCFile>>(aReader);
    if (!maybe___file) {
        aReader->FatalError("Error deserializing 'file' (IPCFile?) member of 'IPCBlob'");
        return {};

    }
    auto& _file = *maybe___file;
    // Sentinel = 'file'
    if ((!((aReader)->ReadSentinel(68420001)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'file' (IPCFile?) member of 'IPCBlob'");
        return {};
    }
    IPC::ReadResult<paramType> result__{
            std::in_place,
            std::move(_type),
            ::uint64_t{0},
            std::move(_blobImplType),
            std::move(_inputStream),
            std::move(_file),
            ::int64_t{0}};
    if ((!((aReader)->ReadBytesInto((&((result__)->size())), 16)))) {
        aReader->FatalError("Error bulk reading fields from uint64_t");
        return {};
    }
    // Sentinel = 'size | fileId'
    if ((!((aReader)->ReadSentinel(572916933)))) {
        mozilla::ipc::SentinelReadError("Error bulk reading fields from uint64_t");
        return {};
    }
    return result__;
}

} // namespace IPC
