From 19f195a70c03cc2499d7f6958c6890ca9cad4e04 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Tue, 22 Mar 2022 16:44:58 +0000 Subject: [PATCH] Bug 1760812 - Part 1: Use std::tuple in NativeThenHandler r=smaug,mccr8 Differential Revision: https://phabricator.services.mozilla.com/D141754 --- dom/promise/Promise-inl.h | 4 ++-- xpcom/base/nsCycleCollectionParticipant.h | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/dom/promise/Promise-inl.h b/dom/promise/Promise-inl.h index 46a7bbafa61e..ae1e804516cf 100644 --- a/dom/promise/Promise-inl.h +++ b/dom/promise/Promise-inl.h @@ -153,7 +153,7 @@ class NativeThenHandler final : public PromiseNativeThenHandlerBase { JS::Handle aValue, ErrorResult& aRv, std::index_sequence) { - return aHandler(aCx, aValue, aRv, ArgType(Get(mArgs))...); + return aHandler(aCx, aValue, aRv, ArgType(std::get(mArgs))...); } template @@ -166,7 +166,7 @@ class NativeThenHandler final : public PromiseNativeThenHandlerBase { ResolveCallback mOnResolve; RejectCallback mOnReject; - Tuple...> mArgs; + std::tuple...> mArgs; }; } // anonymous namespace diff --git a/xpcom/base/nsCycleCollectionParticipant.h b/xpcom/base/nsCycleCollectionParticipant.h index e7950649db01..319caa0ff42f 100644 --- a/xpcom/base/nsCycleCollectionParticipant.h +++ b/xpcom/base/nsCycleCollectionParticipant.h @@ -1085,4 +1085,21 @@ inline void ImplCycleCollectionUnlink(JS::Heap& aField) { MOZ_FOR_EACH_EXPAND_HELPER js_members_) \ NS_IMPL_CYCLE_COLLECTION_TRACE_END +template +inline void ImplCycleCollectionUnlink(std::tuple& aField) { + std::apply([](auto&&... aArgs) { (ImplCycleCollectionUnlink(aArgs), ...); }, + aField); +} +template +inline void ImplCycleCollectionTraverse( + nsCycleCollectionTraversalCallback& aCallback, + std::tuple& aField, const char* aName, uint32_t aFlags) { + aFlags |= CycleCollectionEdgeNameArrayFlag; + std::apply( + [&](auto&&... aArgs) { + (ImplCycleCollectionTraverse(aCallback, aArgs, aName, aFlags), ...); + }, + aField); +} + #endif // nsCycleCollectionParticipant_h__