1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef MOZILLA_PARAMTRAITS_TIEDFIELDS_H
7 #define MOZILLA_PARAMTRAITS_TIEDFIELDS_H
9 #include "ipc/IPCMessageUtils.h"
10 #include "mozilla/ipc/IPDLParamTraits.h"
11 #include "TiedFields.h"
16 struct ParamTraits_TiedFields
{
17 static_assert(mozilla::AssertTiedFieldsAreExhaustive
<T
>());
19 static void Write(MessageWriter
* const writer
, const T
& in
) {
20 const auto& fields
= mozilla::TiedFields(in
);
21 mozilla::MapTuple(fields
, [&](const auto& field
) {
22 WriteParam(writer
, field
);
23 return true; // ignored
27 static bool Read(MessageReader
* const reader
, T
* const out
) {
28 const auto& fields
= mozilla::TiedFields(*out
);
30 mozilla::MapTuple(fields
, [&](auto& field
) {
32 ok
&= ReadParam(reader
, &field
);
34 return true; // ignored
42 template <class U
, size_t N
>
43 struct ParamTraits
<mozilla::PaddingField
<U
, N
>> final
44 : public ParamTraits_TiedFields
<mozilla::PaddingField
<U
, N
>> {};