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


#include "mozilla/ipc/PBackgroundParent.h"
#include "mozilla/ipc/PBackgroundChild.h"
#include "mozilla/dom/PFileCreator.h"
#include "mozilla/dom/PFileCreatorParent.h"
#include "mozilla/dom/PFileCreatorChild.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"

namespace mozilla {
namespace dom {
namespace PFileCreator {

nsresult
CreateEndpoints(
        mozilla::ipc::EndpointProcInfo aParentDestInfo,
        mozilla::ipc::EndpointProcInfo aChildDestInfo,
        mozilla::ipc::Endpoint<::mozilla::dom::PFileCreatorParent>* aParent,
        mozilla::ipc::Endpoint<::mozilla::dom::PFileCreatorChild>* aChild)
{
    return mozilla::ipc::CreateEndpoints(
        mozilla::ipc::PrivateIPDLInterface(),
        aParentDestInfo, aChildDestInfo, aParent, aChild);
}
mozilla::UniquePtr<IPC::Message>
Msg___delete__(IPC::Message::routeid_t routingId)
{
    return IPC::Message::IPDLMessage(routingId, Msg___delete____ID, 0, IPC::Message::HeaderFlags(IPC::Message::NOT_NESTED, IPC::Message::NORMAL_PRIORITY, IPC::Message::COMPRESSION_NONE, IPC::Message::EAGER_SEND, IPC::Message::NOT_CONSTRUCTOR, IPC::Message::ASYNC, IPC::Message::NOT_REPLY));
}
mozilla::UniquePtr<IPC::Message>
Reply___delete__(IPC::Message::routeid_t routingId)
{
    return IPC::Message::IPDLMessage(routingId, Reply___delete____ID, 0, IPC::Message::HeaderFlags(IPC::Message::NOT_NESTED, IPC::Message::NORMAL_PRIORITY, IPC::Message::COMPRESSION_NONE, IPC::Message::EAGER_SEND, IPC::Message::NOT_CONSTRUCTOR, IPC::Message::ASYNC, IPC::Message::REPLY));
}

} // namespace PFileCreator
} // namespace dom
} // namespace mozilla

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

namespace IPC {
auto ParamTraits<::mozilla::dom::FileCreationSuccessResult>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    IPC::WriteParam(aWriter, (aVar).blob());
    // Sentinel = 'blob'
    (aWriter)->WriteSentinel(68157856);
}

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

    }
    auto& _blob = *maybe___blob;
    // Sentinel = 'blob'
    if ((!((aReader)->ReadSentinel(68157856)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'blob' (IPCBlob) member of 'FileCreationSuccessResult'");
        return {};
    }
    IPC::ReadResult<paramType> result__{
            std::in_place,
            std::move(_blob)};
    return result__;
}

} // namespace IPC

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

namespace IPC {
auto ParamTraits<::mozilla::dom::FileCreationErrorResult>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    IPC::WriteParam(aWriter, (aVar).errorCode());
    // Sentinel = 'errorCode'
    (aWriter)->WriteSentinel(312345510);
}

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

    }
    auto& _errorCode = *maybe___errorCode;
    // Sentinel = 'errorCode'
    if ((!((aReader)->ReadSentinel(312345510)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'errorCode' (nsresult) member of 'FileCreationErrorResult'");
        return {};
    }
    IPC::ReadResult<paramType> result__{
            std::in_place,
            std::move(_errorCode)};
    return result__;
}

} // namespace IPC

//-----------------------------------------------------------------------------
// Method definitions for the IPDL type |union FileCreationResult|
//
namespace mozilla {
namespace dom {
auto FileCreationResult::MaybeDestroy() -> void
{
    if ((mType) == (T__None)) {
        return;
    }
    switch (mType) {
    case TFileCreationSuccessResult:
        {
            (ptr_FileCreationSuccessResult())->~FileCreationSuccessResult__tdef();
            break;
        }
    case TFileCreationErrorResult:
        {
            (ptr_FileCreationErrorResult())->~FileCreationErrorResult__tdef();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("not reached");
            break;
        }
    }
}

MOZ_IMPLICIT FileCreationResult::FileCreationResult(const FileCreationSuccessResult& aOther)
{
    new (mozilla::KnownNotNull, ptr_FileCreationSuccessResult()) FileCreationSuccessResult(aOther);
    mType = TFileCreationSuccessResult;
}

MOZ_IMPLICIT FileCreationResult::FileCreationResult(FileCreationSuccessResult&& aOther)
{
    new (mozilla::KnownNotNull, ptr_FileCreationSuccessResult()) FileCreationSuccessResult(std::move(aOther));
    mType = TFileCreationSuccessResult;
}

MOZ_IMPLICIT FileCreationResult::FileCreationResult(const FileCreationErrorResult& aOther)
{
    new (mozilla::KnownNotNull, ptr_FileCreationErrorResult()) FileCreationErrorResult(aOther);
    mType = TFileCreationErrorResult;
}

MOZ_IMPLICIT FileCreationResult::FileCreationResult(FileCreationErrorResult&& aOther)
{
    new (mozilla::KnownNotNull, ptr_FileCreationErrorResult()) FileCreationErrorResult(std::move(aOther));
    mType = TFileCreationErrorResult;
}

MOZ_IMPLICIT FileCreationResult::FileCreationResult(const FileCreationResult& aOther)
{
    (aOther).AssertSanity();
    switch ((aOther).type()) {
    case TFileCreationSuccessResult:
        {
            new (mozilla::KnownNotNull, ptr_FileCreationSuccessResult()) FileCreationSuccessResult((aOther).get_FileCreationSuccessResult());
            break;
        }
    case TFileCreationErrorResult:
        {
            new (mozilla::KnownNotNull, ptr_FileCreationErrorResult()) FileCreationErrorResult((aOther).get_FileCreationErrorResult());
            break;
        }
    case T__None:
        {
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            return;
        }
    }
    mType = (aOther).type();
}

MOZ_IMPLICIT FileCreationResult::FileCreationResult(FileCreationResult&& aOther)
{
    (aOther).AssertSanity();
    Type t = (aOther).type();
    switch (t) {
    case TFileCreationSuccessResult:
        {
            new (mozilla::KnownNotNull, ptr_FileCreationSuccessResult()) FileCreationSuccessResult(std::move((aOther).get_FileCreationSuccessResult()));
            (aOther).MaybeDestroy();
            break;
        }
    case TFileCreationErrorResult:
        {
            new (mozilla::KnownNotNull, ptr_FileCreationErrorResult()) FileCreationErrorResult(std::move((aOther).get_FileCreationErrorResult()));
            (aOther).MaybeDestroy();
            break;
        }
    case T__None:
        {
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            return;
        }
    }
    (aOther).mType = T__None;
    mType = t;
}

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

auto FileCreationResult::operator=(const FileCreationSuccessResult& aRhs) -> FileCreationResult&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_FileCreationSuccessResult()) FileCreationSuccessResult(aRhs);
    mType = TFileCreationSuccessResult;
    return (*(this));
}

auto FileCreationResult::operator=(FileCreationSuccessResult&& aRhs) -> FileCreationResult&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_FileCreationSuccessResult()) FileCreationSuccessResult(std::move(aRhs));
    mType = TFileCreationSuccessResult;
    return (*(this));
}

auto FileCreationResult::operator=(const FileCreationErrorResult& aRhs) -> FileCreationResult&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_FileCreationErrorResult()) FileCreationErrorResult(aRhs);
    mType = TFileCreationErrorResult;
    return (*(this));
}

auto FileCreationResult::operator=(FileCreationErrorResult&& aRhs) -> FileCreationResult&
{
    MaybeDestroy();
    new (mozilla::KnownNotNull, ptr_FileCreationErrorResult()) FileCreationErrorResult(std::move(aRhs));
    mType = TFileCreationErrorResult;
    return (*(this));
}

auto FileCreationResult::operator=(const FileCreationResult& aRhs) -> FileCreationResult&
{
    (aRhs).AssertSanity();
    Type t = (aRhs).type();
    switch (t) {
    case TFileCreationSuccessResult:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_FileCreationSuccessResult()) FileCreationSuccessResult((aRhs).get_FileCreationSuccessResult());
            break;
        }
    case TFileCreationErrorResult:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_FileCreationErrorResult()) FileCreationErrorResult((aRhs).get_FileCreationErrorResult());
            break;
        }
    case T__None:
        {
            MaybeDestroy();
            break;
        }
    default:
        {
            mozilla::ipc::LogicError("unreached");
            break;
        }
    }
    mType = t;
    return (*(this));
}

auto FileCreationResult::operator=(FileCreationResult&& aRhs) -> FileCreationResult&
{
    (aRhs).AssertSanity();
    Type t = (aRhs).type();
    switch (t) {
    case TFileCreationSuccessResult:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_FileCreationSuccessResult()) FileCreationSuccessResult(std::move((aRhs).get_FileCreationSuccessResult()));
            (aRhs).MaybeDestroy();
            break;
        }
    case TFileCreationErrorResult:
        {
            MaybeDestroy();
            new (mozilla::KnownNotNull, ptr_FileCreationErrorResult()) FileCreationErrorResult(std::move((aRhs).get_FileCreationErrorResult()));
            (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::FileCreationResult>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    typedef ::mozilla::dom::FileCreationResult union__;
    int type = (aVar).type();
    IPC::WriteParam(aWriter, type);
    // Sentinel = 'FileCreationResult'
    (aWriter)->WriteSentinel(1108084533);

    switch (type) {
    case union__::TFileCreationSuccessResult:
        {
            IPC::WriteParam(aWriter, (aVar).get_FileCreationSuccessResult());
            // Sentinel = 'TFileCreationSuccessResult'
            (aWriter)->WriteSentinel(2276133474);
            return;
        }
    case union__::TFileCreationErrorResult:
        {
            IPC::WriteParam(aWriter, (aVar).get_FileCreationErrorResult());
            // Sentinel = 'TFileCreationErrorResult'
            (aWriter)->WriteSentinel(1937639827);
            return;
        }
    default:
        {
            aWriter->FatalError("unknown variant of union FileCreationResult");
            return;
        }
    }
}

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

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

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

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

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

} // namespace IPC
