From b586a191ec085d2c6c5c4fdfb1b12102fb5de4c4 Mon Sep 17 00:00:00 2001 From: JustOff Date: Wed, 13 Mar 2019 20:04:13 +0200 Subject: Rename the MozMap C++ type to "record" and give it a template parameter for the key type --- dom/bindings/BindingUtils.h | 61 +++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 30 deletions(-) (limited to 'dom/bindings/BindingUtils.h') diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h index 23bbbea5a..e017b986a 100644 --- a/dom/bindings/BindingUtils.h +++ b/dom/bindings/BindingUtils.h @@ -49,7 +49,7 @@ namespace mozilla { enum UseCounter : int16_t; namespace dom { -template class MozMap; +template class Record; nsresult UnwrapArgImpl(JS::Handle src, const nsIID& iid, void** ppArg); @@ -2293,25 +2293,26 @@ public: } }; -template -void TraceMozMap(JSTracer* trc, MozMap& map) +template +void TraceRecord(JSTracer* trc, Record& record) { - for (auto& entry : map.Entries()) { + for (auto& entry : record.Entries()) { // Act like it's a one-element sequence to leverage all that infrastructure. - SequenceTracer::TraceSequence(trc, &entry.mValue, &entry.mValue + 1); + SequenceTracer::TraceSequence(trc, &entry.mValue, &entry.mValue + 1); } } -// sequence -template -class SequenceTracer, false, false, false> +// sequence +template +class SequenceTracer, false, false, false> { explicit SequenceTracer() = delete; // Should never be instantiated public: - static void TraceSequence(JSTracer* trc, MozMap* seqp, MozMap* end) { + static void TraceSequence(JSTracer* trc, Record* seqp, + Record* end) { for (; seqp != end; ++seqp) { - TraceMozMap(trc, *seqp); + TraceRecord(trc, *seqp); } } }; @@ -2389,51 +2390,51 @@ public: SequenceType mSequenceType; }; -// Rooter class for MozMap; this is what we mostly use in the codegen. -template -class MOZ_RAII MozMapRooter final : private JS::CustomAutoRooter +// Rooter class for Record; this is what we mostly use in the codegen. +template +class MOZ_RAII RecordRooter final : private JS::CustomAutoRooter { public: - MozMapRooter(JSContext *aCx, MozMap* aMozMap + RecordRooter(JSContext *aCx, Record* aRecord MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : JS::CustomAutoRooter(aCx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT), - mMozMap(aMozMap), - mMozMapType(eMozMap) + mRecord(aRecord), + mRecordType(eRecord) { } - MozMapRooter(JSContext *aCx, Nullable>* aMozMap + RecordRooter(JSContext *aCx, Nullable>* aRecord MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : JS::CustomAutoRooter(aCx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT), - mNullableMozMap(aMozMap), - mMozMapType(eNullableMozMap) + mNullableRecord(aRecord), + mRecordType(eNullableRecord) { } private: - enum MozMapType { - eMozMap, - eNullableMozMap + enum RecordType { + eRecord, + eNullableRecord }; virtual void trace(JSTracer *trc) override { - if (mMozMapType == eMozMap) { - TraceMozMap(trc, *mMozMap); + if (mRecordType == eRecord) { + TraceRecord(trc, *mRecord); } else { - MOZ_ASSERT(mMozMapType == eNullableMozMap); - if (!mNullableMozMap->IsNull()) { - TraceMozMap(trc, mNullableMozMap->Value()); + MOZ_ASSERT(mRecordType == eNullableRecord); + if (!mNullableRecord->IsNull()) { + TraceRecord(trc, mNullableRecord->Value()); } } } union { - MozMap* mMozMap; - Nullable>* mNullableMozMap; + Record* mRecord; + Nullable>* mNullableRecord; }; - MozMapType mMozMapType; + RecordType mRecordType; }; template -- cgit v1.2.3