mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1622166 - Change variadic functions from the old recursive way using Fold expressions r=gerald,jld
Differential Revision: https://phabricator.services.mozilla.com/D70431
This commit is contained in:
parent
91e4aa862f
commit
72803335c4
@ -19,8 +19,4 @@ bool ByteLengthIsValid(uint32_t aNumElements, size_t aElementSize,
|
||||
return true;
|
||||
}
|
||||
|
||||
void WriteParams(Message* aMsg) {}
|
||||
|
||||
bool ReadParams(const Message* aMsg, PickleIterator* aIter) { return true; }
|
||||
|
||||
} // namespace IPC
|
||||
|
@ -1269,24 +1269,15 @@ struct BitfieldHelper {
|
||||
// WriteParams(aMsg, aParam.foo, aParam.bar, aParam.baz)
|
||||
// ReadParams(aMsg, aIter, aParam.foo, aParam.bar, aParam.baz)
|
||||
|
||||
// Base case
|
||||
void WriteParams(Message* aMsg);
|
||||
|
||||
template <typename T0, typename... Tn>
|
||||
static void WriteParams(Message* aMsg, const T0& aArg,
|
||||
const Tn&... aRemainingArgs) {
|
||||
WriteParam(aMsg, aArg); // Write first arg
|
||||
WriteParams(aMsg, aRemainingArgs...); // Recurse for the rest
|
||||
template <typename... Ts>
|
||||
static void WriteParams(Message* aMsg, const Ts&... aArgs) {
|
||||
(WriteParam(aMsg, aArgs), ...);
|
||||
}
|
||||
|
||||
// Base case
|
||||
bool ReadParams(const Message* aMsg, PickleIterator* aIter);
|
||||
|
||||
template <typename T0, typename... Tn>
|
||||
static bool ReadParams(const Message* aMsg, PickleIterator* aIter, T0& aArg,
|
||||
Tn&... aRemainingArgs) {
|
||||
return ReadParam(aMsg, aIter, &aArg) && // Read first arg
|
||||
ReadParams(aMsg, aIter, aRemainingArgs...); // Recurse for the rest
|
||||
template <typename... Ts>
|
||||
static bool ReadParams(const Message* aMsg, PickleIterator* aIter,
|
||||
Ts&... aArgs) {
|
||||
return (ReadParam(aMsg, aIter, &aArgs) && ...);
|
||||
}
|
||||
|
||||
// Macros that allow syntax like:
|
||||
|
Loading…
Reference in New Issue
Block a user