diff --git a/devtools/shared/heapsnapshot/HeapSnapshot.cpp b/devtools/shared/heapsnapshot/HeapSnapshot.cpp index 85251f7ad65b..f5db6b730b6b 100644 --- a/devtools/shared/heapsnapshot/HeapSnapshot.cpp +++ b/devtools/shared/heapsnapshot/HeapSnapshot.cpp @@ -136,7 +136,7 @@ struct GetOrInternStringMatcher { explicit GetOrInternStringMatcher(InternedStringSet& strings) : internedStrings(strings) {} - const CharT* match(const std::string* str) { + const CharT* operator()(const std::string* str) { MOZ_ASSERT(str); size_t length = str->length() / sizeof(CharT); auto tempString = reinterpret_cast(str->data()); @@ -147,7 +147,7 @@ struct GetOrInternStringMatcher { return internedStrings.back().get(); } - const CharT* match(uint64_t ref) { + const CharT* operator()(uint64_t ref) { if (MOZ_LIKELY(ref < internedStrings.length())) { auto& string = internedStrings[ref]; MOZ_ASSERT(string); @@ -788,31 +788,33 @@ class TwoByteString using Base = Variant; struct AsTwoByteStringMatcher { - TwoByteString match(JSAtom* atom) { return TwoByteString(atom); } + TwoByteString operator()(JSAtom* atom) { return TwoByteString(atom); } - TwoByteString match(const char16_t* chars) { return TwoByteString(chars); } + TwoByteString operator()(const char16_t* chars) { + return TwoByteString(chars); + } }; struct IsNonNullMatcher { template - bool match(const T& t) { + bool operator()(const T& t) { return t != nullptr; } }; struct LengthMatcher { - size_t match(JSAtom* atom) { + size_t operator()(JSAtom* atom) { MOZ_ASSERT(atom); JS::ubi::AtomOrTwoByteChars s(atom); return s.length(); } - size_t match(const char16_t* chars) { + size_t operator()(const char16_t* chars) { MOZ_ASSERT(chars); return NS_strlen(chars); } - size_t match(const JS::ubi::EdgeName& ptr) { + size_t operator()(const JS::ubi::EdgeName& ptr) { MOZ_ASSERT(ptr); return NS_strlen(ptr.get()); } @@ -825,15 +827,17 @@ class TwoByteString CopyToBufferMatcher(RangedPtr destination, size_t maxLength) : destination(destination), maxLength(maxLength) {} - size_t match(JS::ubi::EdgeName& ptr) { return ptr ? match(ptr.get()) : 0; } + size_t operator()(JS::ubi::EdgeName& ptr) { + return ptr ? operator()(ptr.get()) : 0; + } - size_t match(JSAtom* atom) { + size_t operator()(JSAtom* atom) { MOZ_ASSERT(atom); JS::ubi::AtomOrTwoByteChars s(atom); return s.copyToBuffer(destination, maxLength); } - size_t match(const char16_t* chars) { + size_t operator()(const char16_t* chars) { MOZ_ASSERT(chars); JS::ubi::AtomOrTwoByteChars s(chars); return s.copyToBuffer(destination, maxLength); @@ -896,19 +900,19 @@ struct TwoByteString::HashPolicy { using Lookup = TwoByteString; struct HashingMatcher { - js::HashNumber match(const JSAtom* atom) { + js::HashNumber operator()(const JSAtom* atom) { return js::DefaultHasher::hash(atom); } - js::HashNumber match(const char16_t* chars) { + js::HashNumber operator()(const char16_t* chars) { MOZ_ASSERT(chars); auto length = NS_strlen(chars); return HashString(chars, length); } - js::HashNumber match(const JS::ubi::EdgeName& ptr) { + js::HashNumber operator()(const JS::ubi::EdgeName& ptr) { MOZ_ASSERT(ptr); - return match(ptr.get()); + return operator()(ptr.get()); } }; @@ -921,11 +925,11 @@ struct TwoByteString::HashPolicy { const TwoByteString& rhs; explicit EqualityMatcher(const TwoByteString& rhs) : rhs(rhs) {} - bool match(const JSAtom* atom) { + bool operator()(const JSAtom* atom) { return rhs.is() && rhs.as() == atom; } - bool match(const char16_t* chars) { + bool operator()(const char16_t* chars) { MOZ_ASSERT(chars); const char16_t* rhsChars = nullptr; @@ -943,9 +947,9 @@ struct TwoByteString::HashPolicy { return memcmp(chars, rhsChars, length * sizeof(char16_t)) == 0; } - bool match(const JS::ubi::EdgeName& ptr) { + bool operator()(const JS::ubi::EdgeName& ptr) { MOZ_ASSERT(ptr); - return match(ptr.get()); + return operator()(ptr.get()); } }; diff --git a/dom/localstorage/ActorsParent.cpp b/dom/localstorage/ActorsParent.cpp index b1202735e342..c1afc10c32f9 100644 --- a/dom/localstorage/ActorsParent.cpp +++ b/dom/localstorage/ActorsParent.cpp @@ -7233,22 +7233,22 @@ void ArchivedOriginScope::GetBindingClause(nsACString& aBindingClause) const { explicit Matcher(nsACString* aBindingClause) : mBindingClause(aBindingClause) {} - void match(const Origin& aOrigin) { + void operator()(const Origin& aOrigin) { *mBindingClause = NS_LITERAL_CSTRING( " WHERE originKey = :originKey " "AND originAttributes = :originAttributes"); } - void match(const Prefix& aPrefix) { + void operator()(const Prefix& aPrefix) { *mBindingClause = NS_LITERAL_CSTRING(" WHERE originKey = :originKey"); } - void match(const Pattern& aPattern) { + void operator()(const Pattern& aPattern) { *mBindingClause = NS_LITERAL_CSTRING( " WHERE originAttributes MATCH :originAttributesPattern"); } - void match(const Null& aNull) { *mBindingClause = EmptyCString(); } + void operator()(const Null& aNull) { *mBindingClause = EmptyCString(); } }; mData.match(Matcher(&aBindingClause)); @@ -7264,7 +7264,7 @@ nsresult ArchivedOriginScope::BindToStatement( explicit Matcher(mozIStorageStatement* aStmt) : mStmt(aStmt) {} - nsresult match(const Origin& aOrigin) { + nsresult operator()(const Origin& aOrigin) { nsresult rv = mStmt->BindUTF8StringByName(NS_LITERAL_CSTRING("originKey"), aOrigin.OriginNoSuffix()); if (NS_WARN_IF(NS_FAILED(rv))) { @@ -7280,7 +7280,7 @@ nsresult ArchivedOriginScope::BindToStatement( return NS_OK; } - nsresult match(const Prefix& aPrefix) { + nsresult operator()(const Prefix& aPrefix) { nsresult rv = mStmt->BindUTF8StringByName(NS_LITERAL_CSTRING("originKey"), aPrefix.OriginNoSuffix()); if (NS_WARN_IF(NS_FAILED(rv))) { @@ -7290,7 +7290,7 @@ nsresult ArchivedOriginScope::BindToStatement( return NS_OK; } - nsresult match(const Pattern& aPattern) { + nsresult operator()(const Pattern& aPattern) { nsresult rv = mStmt->BindUTF8StringByName( NS_LITERAL_CSTRING("originAttributesPattern"), NS_LITERAL_CSTRING("pattern1")); @@ -7301,7 +7301,7 @@ nsresult ArchivedOriginScope::BindToStatement( return NS_OK; } - nsresult match(const Null& aNull) { return NS_OK; } + nsresult operator()(const Null& aNull) { return NS_OK; } }; nsresult rv = mData.match(Matcher(aStmt)); @@ -7323,7 +7323,7 @@ bool ArchivedOriginScope::HasMatches( explicit Matcher(ArchivedOriginHashtable* aHashtable) : mHashtable(aHashtable) {} - bool match(const Origin& aOrigin) { + bool operator()(const Origin& aOrigin) { nsCString hashKey = GetArchivedOriginHashKey(aOrigin.OriginSuffix(), aOrigin.OriginNoSuffix()); @@ -7331,7 +7331,7 @@ bool ArchivedOriginScope::HasMatches( return mHashtable->Get(hashKey, &archivedOriginInfo); } - bool match(const Prefix& aPrefix) { + bool operator()(const Prefix& aPrefix) { for (auto iter = mHashtable->ConstIter(); !iter.Done(); iter.Next()) { ArchivedOriginInfo* archivedOriginInfo = iter.Data(); @@ -7343,7 +7343,7 @@ bool ArchivedOriginScope::HasMatches( return false; } - bool match(const Pattern& aPattern) { + bool operator()(const Pattern& aPattern) { for (auto iter = mHashtable->ConstIter(); !iter.Done(); iter.Next()) { ArchivedOriginInfo* archivedOriginInfo = iter.Data(); @@ -7356,7 +7356,7 @@ bool ArchivedOriginScope::HasMatches( return false; } - bool match(const Null& aNull) { return mHashtable->Count(); } + bool operator()(const Null& aNull) { return mHashtable->Count(); } }; return mData.match(Matcher(aHashtable)); @@ -7373,14 +7373,14 @@ void ArchivedOriginScope::RemoveMatches( explicit Matcher(ArchivedOriginHashtable* aHashtable) : mHashtable(aHashtable) {} - void match(const Origin& aOrigin) { + void operator()(const Origin& aOrigin) { nsCString hashKey = GetArchivedOriginHashKey(aOrigin.OriginSuffix(), aOrigin.OriginNoSuffix()); mHashtable->Remove(hashKey); } - void match(const Prefix& aPrefix) { + void operator()(const Prefix& aPrefix) { for (auto iter = mHashtable->Iter(); !iter.Done(); iter.Next()) { ArchivedOriginInfo* archivedOriginInfo = iter.Data(); @@ -7390,7 +7390,7 @@ void ArchivedOriginScope::RemoveMatches( } } - void match(const Pattern& aPattern) { + void operator()(const Pattern& aPattern) { for (auto iter = mHashtable->Iter(); !iter.Done(); iter.Next()) { ArchivedOriginInfo* archivedOriginInfo = iter.Data(); @@ -7401,7 +7401,7 @@ void ArchivedOriginScope::RemoveMatches( } } - void match(const Null& aNull) { mHashtable->Clear(); } + void operator()(const Null& aNull) { mHashtable->Clear(); } }; mData.match(Matcher(aHashtable)); diff --git a/dom/media/doctor/DDLogValue.cpp b/dom/media/doctor/DDLogValue.cpp index 43fab1ced388..b2da4e536e7a 100644 --- a/dom/media/doctor/DDLogValue.cpp +++ b/dom/media/doctor/DDLogValue.cpp @@ -13,47 +13,49 @@ namespace mozilla { struct LogValueMatcher { nsCString& mString; - void match(const DDNoValue&) const {} - void match(const DDLogObject& a) const { a.AppendPrintf(mString); } - void match(const char* a) const { mString.AppendPrintf(R"("%s")", a); } - void match(const nsCString& a) const { + void operator()(const DDNoValue&) const {} + void operator()(const DDLogObject& a) const { a.AppendPrintf(mString); } + void operator()(const char* a) const { mString.AppendPrintf(R"("%s")", a); } + void operator()(const nsCString& a) const { mString.AppendPrintf(R"(nsCString("%s"))", a.Data()); } - void match(bool a) const { mString.AppendPrintf(a ? "true" : "false"); } - void match(int8_t a) const { mString.AppendPrintf("int8_t(%" PRIi8 ")", a); } - void match(uint8_t a) const { + void operator()(bool a) const { mString.AppendPrintf(a ? "true" : "false"); } + void operator()(int8_t a) const { + mString.AppendPrintf("int8_t(%" PRIi8 ")", a); + } + void operator()(uint8_t a) const { mString.AppendPrintf("uint8_t(%" PRIu8 ")", a); } - void match(int16_t a) const { + void operator()(int16_t a) const { mString.AppendPrintf("int16_t(%" PRIi16 ")", a); } - void match(uint16_t a) const { + void operator()(uint16_t a) const { mString.AppendPrintf("uint16_t(%" PRIu16 ")", a); } - void match(int32_t a) const { + void operator()(int32_t a) const { mString.AppendPrintf("int32_t(%" PRIi32 ")", a); } - void match(uint32_t a) const { + void operator()(uint32_t a) const { mString.AppendPrintf("uint32_t(%" PRIu32 ")", a); } - void match(int64_t a) const { + void operator()(int64_t a) const { mString.AppendPrintf("int64_t(%" PRIi64 ")", a); } - void match(uint64_t a) const { + void operator()(uint64_t a) const { mString.AppendPrintf("uint64_t(%" PRIu64 ")", a); } - void match(double a) const { mString.AppendPrintf("double(%f)", a); } - void match(const DDRange& a) const { + void operator()(double a) const { mString.AppendPrintf("double(%f)", a); } + void operator()(const DDRange& a) const { mString.AppendPrintf("%" PRIi64 "<=(%" PRIi64 "B)<%" PRIi64 "", a.mOffset, a.mBytes, a.mOffset + a.mBytes); } - void match(const nsresult& a) const { + void operator()(const nsresult& a) const { nsCString name; GetErrorName(a, name); mString.AppendPrintf("nsresult(%s =0x%08" PRIx32 ")", name.get(), static_cast(a)); } - void match(const MediaResult& a) const { + void operator()(const MediaResult& a) const { nsCString name; GetErrorName(a.Code(), name); mString.AppendPrintf("MediaResult(%s =0x%08" PRIx32 ", \"%s\")", name.get(), @@ -69,38 +71,38 @@ struct LogValueMatcherJson { JSONWriter& mJW; const char* mPropertyName; - void match(const DDNoValue&) const { mJW.NullProperty(mPropertyName); } - void match(const DDLogObject& a) const { + void operator()(const DDNoValue&) const { mJW.NullProperty(mPropertyName); } + void operator()(const DDLogObject& a) const { mJW.StringProperty( mPropertyName, nsPrintfCString(R"("%s[%p]")", a.TypeName(), a.Pointer()).get()); } - void match(const char* a) const { mJW.StringProperty(mPropertyName, a); } - void match(const nsCString& a) const { + void operator()(const char* a) const { mJW.StringProperty(mPropertyName, a); } + void operator()(const nsCString& a) const { mJW.StringProperty(mPropertyName, a.Data()); } - void match(bool a) const { mJW.BoolProperty(mPropertyName, a); } - void match(int8_t a) const { mJW.IntProperty(mPropertyName, a); } - void match(uint8_t a) const { mJW.IntProperty(mPropertyName, a); } - void match(int16_t a) const { mJW.IntProperty(mPropertyName, a); } - void match(uint16_t a) const { mJW.IntProperty(mPropertyName, a); } - void match(int32_t a) const { mJW.IntProperty(mPropertyName, a); } - void match(uint32_t a) const { mJW.IntProperty(mPropertyName, a); } - void match(int64_t a) const { mJW.IntProperty(mPropertyName, a); } - void match(uint64_t a) const { mJW.DoubleProperty(mPropertyName, a); } - void match(double a) const { mJW.DoubleProperty(mPropertyName, a); } - void match(const DDRange& a) const { + void operator()(bool a) const { mJW.BoolProperty(mPropertyName, a); } + void operator()(int8_t a) const { mJW.IntProperty(mPropertyName, a); } + void operator()(uint8_t a) const { mJW.IntProperty(mPropertyName, a); } + void operator()(int16_t a) const { mJW.IntProperty(mPropertyName, a); } + void operator()(uint16_t a) const { mJW.IntProperty(mPropertyName, a); } + void operator()(int32_t a) const { mJW.IntProperty(mPropertyName, a); } + void operator()(uint32_t a) const { mJW.IntProperty(mPropertyName, a); } + void operator()(int64_t a) const { mJW.IntProperty(mPropertyName, a); } + void operator()(uint64_t a) const { mJW.DoubleProperty(mPropertyName, a); } + void operator()(double a) const { mJW.DoubleProperty(mPropertyName, a); } + void operator()(const DDRange& a) const { mJW.StartArrayProperty(mPropertyName); mJW.IntElement(a.mOffset); mJW.IntElement(a.mOffset + a.mBytes); mJW.EndArray(); } - void match(const nsresult& a) const { + void operator()(const nsresult& a) const { nsCString name; GetErrorName(a, name); mJW.StringProperty(mPropertyName, name.get()); } - void match(const MediaResult& a) const { + void operator()(const MediaResult& a) const { nsCString name; GetErrorName(a.Code(), name); mJW.StringProperty(mPropertyName, diff --git a/dom/plugins/ipc/IpdlTuple.h b/dom/plugins/ipc/IpdlTuple.h index d718bfc0bca6..3818bf166567 100644 --- a/dom/plugins/ipc/IpdlTuple.h +++ b/dom/plugins/ipc/IpdlTuple.h @@ -152,7 +152,7 @@ struct ParamTraits { explicit LogMatcher(std::wstring* aLog) : mLog(aLog) {} template - void match(const EntryType& aParam) { + void operator()(const EntryType& aParam) { LogParam(aParam, mLog); } diff --git a/dom/quota/OriginScope.h b/dom/quota/OriginScope.h index 909eea63780a..90e3c9e96a07 100644 --- a/dom/quota/OriginScope.h +++ b/dom/quota/OriginScope.h @@ -212,13 +212,19 @@ class OriginScope { explicit Matcher(const OriginScope& aThis) : mThis(aThis) {} - bool match(const Origin& aOther) { return mThis.MatchesOrigin(aOther); } + bool operator()(const Origin& aOther) { + return mThis.MatchesOrigin(aOther); + } - bool match(const Prefix& aOther) { return mThis.MatchesPrefix(aOther); } + bool operator()(const Prefix& aOther) { + return mThis.MatchesPrefix(aOther); + } - bool match(const Pattern& aOther) { return mThis.MatchesPattern(aOther); } + bool operator()(const Pattern& aOther) { + return mThis.MatchesPattern(aOther); + } - bool match(const Null& aOther) { return true; } + bool operator()(const Null& aOther) { return true; } }; return aOther.mData.match(Matcher(*this)); @@ -245,19 +251,19 @@ class OriginScope { explicit OriginMatcher(const Origin& aOther) : mOther(aOther) {} - bool match(const Origin& aThis) { + bool operator()(const Origin& aThis) { return aThis.GetOrigin().Equals(mOther.GetOrigin()); } - bool match(const Prefix& aThis) { + bool operator()(const Prefix& aThis) { return aThis.GetOriginNoSuffix().Equals(mOther.GetOriginNoSuffix()); } - bool match(const Pattern& aThis) { + bool operator()(const Pattern& aThis) { return aThis.GetPattern().Matches(mOther.GetAttributes()); } - bool match(const Null& aThis) { + bool operator()(const Null& aThis) { // Null covers everything. return true; } @@ -272,22 +278,22 @@ class OriginScope { explicit PrefixMatcher(const Prefix& aOther) : mOther(aOther) {} - bool match(const Origin& aThis) { + bool operator()(const Origin& aThis) { return aThis.GetOriginNoSuffix().Equals(mOther.GetOriginNoSuffix()); } - bool match(const Prefix& aThis) { + bool operator()(const Prefix& aThis) { return aThis.GetOriginNoSuffix().Equals(mOther.GetOriginNoSuffix()); } - bool match(const Pattern& aThis) { + bool operator()(const Pattern& aThis) { // The match will be always true here because any origin attributes // pattern overlaps any origin prefix (an origin prefix targets all // origin attributes). return true; } - bool match(const Null& aThis) { + bool operator()(const Null& aThis) { // Null covers everything. return true; } @@ -302,22 +308,22 @@ class OriginScope { explicit PatternMatcher(const Pattern& aOther) : mOther(aOther) {} - bool match(const Origin& aThis) { + bool operator()(const Origin& aThis) { return mOther.GetPattern().Matches(aThis.GetAttributes()); } - bool match(const Prefix& aThis) { + bool operator()(const Prefix& aThis) { // The match will be always true here because any origin attributes // pattern overlaps any origin prefix (an origin prefix targets all // origin attributes). return true; } - bool match(const Pattern& aThis) { + bool operator()(const Pattern& aThis) { return aThis.GetPattern().Overlaps(mOther.GetPattern()); } - bool match(const Null& aThis) { + bool operator()(const Null& aThis) { // Null covers everything. return true; } diff --git a/gfx/2d/FilterNodeCapture.cpp b/gfx/2d/FilterNodeCapture.cpp index 28706c9e8b6f..07d644546b0b 100644 --- a/gfx/2d/FilterNodeCapture.cpp +++ b/gfx/2d/FilterNodeCapture.cpp @@ -13,7 +13,7 @@ struct Setter { Setter(FilterNode* aNode, DrawTarget* aDT, bool aInputsChanged) : mNode{aNode}, mIndex{0}, mDT{aDT}, mInputsChanged{aInputsChanged} {} template - void match(T& aValue) { + void operator()(T& aValue) { mNode->SetAttribute(mIndex, aValue); } @@ -24,12 +24,13 @@ struct Setter { }; template <> -void Setter::match>(std::vector& aValue) { +void Setter::operator()>(std::vector& aValue) { mNode->SetAttribute(mIndex, aValue.data(), aValue.size()); } template <> -void Setter::match>(RefPtr& aSurface) { +void Setter::operator()>( + RefPtr& aSurface) { if (!mInputsChanged) { return; } @@ -37,7 +38,7 @@ void Setter::match>(RefPtr& aSurface) { } template <> -void Setter::match>(RefPtr& aNode) { +void Setter::operator()>(RefPtr& aNode) { RefPtr node = aNode; if (node->GetBackendType() == FilterBackend::FILTER_BACKEND_CAPTURE) { FilterNodeCapture* captureNode = diff --git a/gfx/layers/apz/src/FocusState.cpp b/gfx/layers/apz/src/FocusState.cpp index 92f353de85c3..e1ee3b9c52ad 100644 --- a/gfx/layers/apz/src/FocusState.cpp +++ b/gfx/layers/apz/src/FocusState.cpp @@ -102,7 +102,7 @@ void FocusState::Update(LayersId aRootLayerTreeId, FocusState& mFocusState; const uint64_t mSequenceNumber; - bool match(const FocusTarget::NoFocusTarget& aNoFocusTarget) { + bool operator()(const FocusTarget::NoFocusTarget& aNoFocusTarget) { FS_LOG("Setting target to nil (reached a nil target) with seq=%" PRIu64 "\n", mSequenceNumber); @@ -123,7 +123,7 @@ void FocusState::Update(LayersId aRootLayerTreeId, return true; } - bool match(const LayersId& aRefLayerId) { + bool operator()(const LayersId& aRefLayerId) { // Guard against infinite loops MOZ_ASSERT(mFocusState.mFocusLayersId != aRefLayerId); if (mFocusState.mFocusLayersId == aRefLayerId) { @@ -141,7 +141,7 @@ void FocusState::Update(LayersId aRootLayerTreeId, return false; } - bool match(const FocusTarget::ScrollTargets& aScrollTargets) { + bool operator()(const FocusTarget::ScrollTargets& aScrollTargets) { FS_LOG("Setting target to h=%" PRIu64 ", v=%" PRIu64 ", and seq=%" PRIu64 "\n", aScrollTargets.mHorizontal, aScrollTargets.mVertical, diff --git a/gfx/src/FilterSupport.cpp b/gfx/src/FilterSupport.cpp index 78edfbe6bc52..e7f51379c089 100644 --- a/gfx/src/FilterSupport.cpp +++ b/gfx/src/FilterSupport.cpp @@ -668,12 +668,12 @@ static already_AddRefed FilterNodeFromPrimitiveDescription( nsTArray& mSourceRegions; nsTArray>& mInputImages; - already_AddRefed match( + already_AddRefed operator()( const EmptyAttributes& aEmptyAttributes) { return nullptr; } - already_AddRefed match(const BlendAttributes& aBlend) { + already_AddRefed operator()(const BlendAttributes& aBlend) { uint32_t mode = aBlend.mBlendMode; RefPtr filter; if (mode == SVG_FEBLEND_MODE_UNKNOWN) { @@ -718,7 +718,7 @@ static already_AddRefed FilterNodeFromPrimitiveDescription( return filter.forget(); } - already_AddRefed match( + already_AddRefed operator()( const ColorMatrixAttributes& aMatrixAttributes) { float colorMatrix[20]; if (!ComputeColorMatrix(aMatrixAttributes, colorMatrix)) { @@ -744,7 +744,7 @@ static already_AddRefed FilterNodeFromPrimitiveDescription( return filter.forget(); } - already_AddRefed match( + already_AddRefed operator()( const MorphologyAttributes& aMorphology) { Size radii = aMorphology.mRadii; int32_t rx = radii.width; @@ -775,7 +775,7 @@ static already_AddRefed FilterNodeFromPrimitiveDescription( return filter.forget(); } - already_AddRefed match(const FloodAttributes& aFlood) { + already_AddRefed operator()(const FloodAttributes& aFlood) { Color color = aFlood.mColor; RefPtr filter = mDT->CreateFilter(FilterType::FLOOD); if (!filter) { @@ -785,7 +785,7 @@ static already_AddRefed FilterNodeFromPrimitiveDescription( return filter.forget(); } - already_AddRefed match(const TileAttributes& aTile) { + already_AddRefed operator()(const TileAttributes& aTile) { RefPtr filter = mDT->CreateFilter(FilterType::TILE); if (!filter) { return nullptr; @@ -795,7 +795,7 @@ static already_AddRefed FilterNodeFromPrimitiveDescription( return filter.forget(); } - already_AddRefed match( + already_AddRefed operator()( const ComponentTransferAttributes& aComponentTransfer) { RefPtr filters[4]; // one for each FILTER_*_TRANSFER type bool useRgb = aComponentTransfer.mTypes[kChannelG] == @@ -822,7 +822,7 @@ static already_AddRefed FilterNodeFromPrimitiveDescription( return lastFilter.forget(); } - already_AddRefed match(const OpacityAttributes& aOpacity) { + already_AddRefed operator()(const OpacityAttributes& aOpacity) { RefPtr filter = mDT->CreateFilter(FilterType::OPACITY); if (!filter) { return nullptr; @@ -832,7 +832,7 @@ static already_AddRefed FilterNodeFromPrimitiveDescription( return filter.forget(); } - already_AddRefed match( + already_AddRefed operator()( const ConvolveMatrixAttributes& aConvolveMatrix) { RefPtr filter = mDT->CreateFilter(FilterType::CONVOLVE_MATRIX); @@ -866,11 +866,11 @@ static already_AddRefed FilterNodeFromPrimitiveDescription( return filter.forget(); } - already_AddRefed match(const OffsetAttributes& aOffset) { + already_AddRefed operator()(const OffsetAttributes& aOffset) { return FilterWrappers::Offset(mDT, mSources[0], aOffset.mValue); } - already_AddRefed match( + already_AddRefed operator()( const DisplacementMapAttributes& aDisplacementMap) { RefPtr filter = mDT->CreateFilter(FilterType::DISPLACEMENT_MAP); @@ -894,7 +894,7 @@ static already_AddRefed FilterNodeFromPrimitiveDescription( return filter.forget(); } - already_AddRefed match( + already_AddRefed operator()( const TurbulenceAttributes& aTurbulence) { RefPtr filter = mDT->CreateFilter(FilterType::TURBULENCE); if (!filter) { @@ -918,7 +918,8 @@ static already_AddRefed FilterNodeFromPrimitiveDescription( return FilterWrappers::Offset(mDT, filter, aTurbulence.mOffset); } - already_AddRefed match(const CompositeAttributes& aComposite) { + already_AddRefed operator()( + const CompositeAttributes& aComposite) { RefPtr filter; uint32_t op = aComposite.mOperator; if (op == SVG_FECOMPOSITE_OPERATOR_ARITHMETIC) { @@ -955,7 +956,7 @@ static already_AddRefed FilterNodeFromPrimitiveDescription( return filter.forget(); } - already_AddRefed match(const MergeAttributes& aMerge) { + already_AddRefed operator()(const MergeAttributes& aMerge) { if (mSources.Length() == 0) { return nullptr; } @@ -975,13 +976,13 @@ static already_AddRefed FilterNodeFromPrimitiveDescription( return filter.forget(); } - already_AddRefed match( + already_AddRefed operator()( const GaussianBlurAttributes& aGaussianBlur) { return FilterWrappers::GaussianBlur(mDT, mSources[0], aGaussianBlur.mStdDeviation); } - already_AddRefed match( + already_AddRefed operator()( const DropShadowAttributes& aDropShadow) { RefPtr alpha = FilterWrappers::ToAlpha(mDT, mSources[0]); RefPtr blur = @@ -1020,13 +1021,13 @@ static already_AddRefed FilterNodeFromPrimitiveDescription( return filter.forget(); } - already_AddRefed match( + already_AddRefed operator()( const SpecularLightingAttributes& aLighting) { - return match( + return operator()( *(static_cast(&aLighting))); } - already_AddRefed match( + already_AddRefed operator()( const DiffuseLightingAttributes& aLighting) { bool isSpecular = mDescription.Attributes().is(); @@ -1117,7 +1118,7 @@ static already_AddRefed FilterNodeFromPrimitiveDescription( return filter.forget(); } - already_AddRefed match(const ImageAttributes& aImage) { + already_AddRefed operator()(const ImageAttributes& aImage) { const Matrix& TM = aImage.mTransform; if (!TM.Determinant()) { return nullptr; @@ -1137,7 +1138,7 @@ static already_AddRefed FilterNodeFromPrimitiveDescription( return transform.forget(); } - already_AddRefed match(const ToAlphaAttributes& aToAlpha) { + already_AddRefed operator()(const ToAlphaAttributes& aToAlpha) { return FilterWrappers::ToAlpha(mDT, mSources[0]); } }; @@ -1367,19 +1368,19 @@ static nsIntRegion ResultChangeRegionForPrimitive( const FilterPrimitiveDescription& mDescription; const nsTArray& mInputChangeRegions; - nsIntRegion match(const EmptyAttributes& aEmptyAttributes) { + nsIntRegion operator()(const EmptyAttributes& aEmptyAttributes) { return nsIntRegion(); } - nsIntRegion match(const BlendAttributes& aBlend) { + nsIntRegion operator()(const BlendAttributes& aBlend) { return UnionOfRegions(mInputChangeRegions); } - nsIntRegion match(const ColorMatrixAttributes& aColorMatrix) { + nsIntRegion operator()(const ColorMatrixAttributes& aColorMatrix) { return mInputChangeRegions[0]; } - nsIntRegion match(const MorphologyAttributes& aMorphology) { + nsIntRegion operator()(const MorphologyAttributes& aMorphology) { Size radii = aMorphology.mRadii; int32_t rx = clamped(int32_t(ceil(radii.width)), 0, kMorphologyMaxRadius); int32_t ry = @@ -1387,21 +1388,24 @@ static nsIntRegion ResultChangeRegionForPrimitive( return mInputChangeRegions[0].Inflated(nsIntMargin(ry, rx, ry, rx)); } - nsIntRegion match(const FloodAttributes& aFlood) { return nsIntRegion(); } + nsIntRegion operator()(const FloodAttributes& aFlood) { + return nsIntRegion(); + } - nsIntRegion match(const TileAttributes& aTile) { + nsIntRegion operator()(const TileAttributes& aTile) { return mDescription.PrimitiveSubregion(); } - nsIntRegion match(const ComponentTransferAttributes& aComponentTransfer) { + nsIntRegion operator()( + const ComponentTransferAttributes& aComponentTransfer) { return mInputChangeRegions[0]; } - nsIntRegion match(const OpacityAttributes& aOpacity) { + nsIntRegion operator()(const OpacityAttributes& aOpacity) { return UnionOfRegions(mInputChangeRegions); } - nsIntRegion match(const ConvolveMatrixAttributes& aConvolveMatrix) { + nsIntRegion operator()(const ConvolveMatrixAttributes& aConvolveMatrix) { if (aConvolveMatrix.mEdgeMode != EDGE_MODE_NONE) { return mDescription.PrimitiveSubregion(); } @@ -1416,37 +1420,37 @@ static nsIntRegion ResultChangeRegionForPrimitive( return mInputChangeRegions[0].Inflated(m); } - nsIntRegion match(const OffsetAttributes& aOffset) { + nsIntRegion operator()(const OffsetAttributes& aOffset) { IntPoint offset = aOffset.mValue; return mInputChangeRegions[0].MovedBy(offset.x, offset.y); } - nsIntRegion match(const DisplacementMapAttributes& aDisplacementMap) { + nsIntRegion operator()(const DisplacementMapAttributes& aDisplacementMap) { int32_t scale = ceil(std::abs(aDisplacementMap.mScale)); return mInputChangeRegions[0].Inflated( nsIntMargin(scale, scale, scale, scale)); } - nsIntRegion match(const TurbulenceAttributes& aTurbulence) { + nsIntRegion operator()(const TurbulenceAttributes& aTurbulence) { return nsIntRegion(); } - nsIntRegion match(const CompositeAttributes& aComposite) { + nsIntRegion operator()(const CompositeAttributes& aComposite) { return UnionOfRegions(mInputChangeRegions); } - nsIntRegion match(const MergeAttributes& aMerge) { + nsIntRegion operator()(const MergeAttributes& aMerge) { return UnionOfRegions(mInputChangeRegions); } - nsIntRegion match(const GaussianBlurAttributes& aGaussianBlur) { + nsIntRegion operator()(const GaussianBlurAttributes& aGaussianBlur) { const Size& stdDeviation = aGaussianBlur.mStdDeviation; int32_t dx = InflateSizeForBlurStdDev(stdDeviation.width); int32_t dy = InflateSizeForBlurStdDev(stdDeviation.height); return mInputChangeRegions[0].Inflated(nsIntMargin(dy, dx, dy, dx)); } - nsIntRegion match(const DropShadowAttributes& aDropShadow) { + nsIntRegion operator()(const DropShadowAttributes& aDropShadow) { IntPoint offset = aDropShadow.mOffset; nsIntRegion offsetRegion = mInputChangeRegions[0].MovedBy(offset.x, offset.y); @@ -1459,21 +1463,23 @@ static nsIntRegion ResultChangeRegionForPrimitive( return blurRegion; } - nsIntRegion match(const SpecularLightingAttributes& aLighting) { - return match( + nsIntRegion operator()(const SpecularLightingAttributes& aLighting) { + return operator()( *(static_cast(&aLighting))); } - nsIntRegion match(const DiffuseLightingAttributes& aLighting) { + nsIntRegion operator()(const DiffuseLightingAttributes& aLighting) { Size kernelUnitLength = aLighting.mKernelUnitLength; int32_t dx = ceil(kernelUnitLength.width); int32_t dy = ceil(kernelUnitLength.height); return mInputChangeRegions[0].Inflated(nsIntMargin(dy, dx, dy, dx)); } - nsIntRegion match(const ImageAttributes& aImage) { return nsIntRegion(); } + nsIntRegion operator()(const ImageAttributes& aImage) { + return nsIntRegion(); + } - nsIntRegion match(const ToAlphaAttributes& aToAlpha) { + nsIntRegion operator()(const ToAlphaAttributes& aToAlpha) { return mInputChangeRegions[0]; } }; @@ -1560,15 +1566,15 @@ nsIntRegion FilterSupport::PostFilterExtentsForPrimitive( const FilterPrimitiveDescription& mDescription; const nsTArray& mInputExtents; - nsIntRegion match(const EmptyAttributes& aEmptyAttributes) { + nsIntRegion operator()(const EmptyAttributes& aEmptyAttributes) { return IntRect(); } - nsIntRegion match(const BlendAttributes& aBlend) { + nsIntRegion operator()(const BlendAttributes& aBlend) { return ResultChangeRegionForPrimitive(mDescription, mInputExtents); } - nsIntRegion match(const ColorMatrixAttributes& aColorMatrix) { + nsIntRegion operator()(const ColorMatrixAttributes& aColorMatrix) { if (aColorMatrix.mType == (uint32_t)SVG_FECOLORMATRIX_TYPE_MATRIX) { const nsTArray& values = aColorMatrix.mValues; if (values.Length() == 20 && values[19] > 0.0f) { @@ -1578,7 +1584,7 @@ nsIntRegion FilterSupport::PostFilterExtentsForPrimitive( return mInputExtents[0]; } - nsIntRegion match(const MorphologyAttributes& aMorphology) { + nsIntRegion operator()(const MorphologyAttributes& aMorphology) { uint32_t op = aMorphology.mOperator; if (op == SVG_OPERATOR_ERODE) { return mInputExtents[0]; @@ -1590,18 +1596,19 @@ nsIntRegion FilterSupport::PostFilterExtentsForPrimitive( return mInputExtents[0].Inflated(nsIntMargin(ry, rx, ry, rx)); } - nsIntRegion match(const FloodAttributes& aFlood) { + nsIntRegion operator()(const FloodAttributes& aFlood) { if (aFlood.mColor.a == 0.0f) { return IntRect(); } return mDescription.PrimitiveSubregion(); } - nsIntRegion match(const TileAttributes& aTile) { + nsIntRegion operator()(const TileAttributes& aTile) { return ResultChangeRegionForPrimitive(mDescription, mInputExtents); } - nsIntRegion match(const ComponentTransferAttributes& aComponentTransfer) { + nsIntRegion operator()( + const ComponentTransferAttributes& aComponentTransfer) { if (ResultOfZeroUnderTransferFunction(aComponentTransfer, kChannelA) > 0.0f) { return mDescription.PrimitiveSubregion(); @@ -1609,27 +1616,27 @@ nsIntRegion FilterSupport::PostFilterExtentsForPrimitive( return mInputExtents[0]; } - nsIntRegion match(const OpacityAttributes& aOpacity) { + nsIntRegion operator()(const OpacityAttributes& aOpacity) { return ResultChangeRegionForPrimitive(mDescription, mInputExtents); } - nsIntRegion match(const ConvolveMatrixAttributes& aConvolveMatrix) { + nsIntRegion operator()(const ConvolveMatrixAttributes& aConvolveMatrix) { return ResultChangeRegionForPrimitive(mDescription, mInputExtents); } - nsIntRegion match(const OffsetAttributes& aOffset) { + nsIntRegion operator()(const OffsetAttributes& aOffset) { return ResultChangeRegionForPrimitive(mDescription, mInputExtents); } - nsIntRegion match(const DisplacementMapAttributes& aDisplacementMap) { + nsIntRegion operator()(const DisplacementMapAttributes& aDisplacementMap) { return ResultChangeRegionForPrimitive(mDescription, mInputExtents); } - nsIntRegion match(const TurbulenceAttributes& aTurbulence) { + nsIntRegion operator()(const TurbulenceAttributes& aTurbulence) { return mDescription.PrimitiveSubregion(); } - nsIntRegion match(const CompositeAttributes& aComposite) { + nsIntRegion operator()(const CompositeAttributes& aComposite) { uint32_t op = aComposite.mOperator; if (op == SVG_FECOMPOSITE_OPERATOR_ARITHMETIC) { // The arithmetic composite primitive can draw outside the bounding @@ -1660,31 +1667,32 @@ nsIntRegion FilterSupport::PostFilterExtentsForPrimitive( return ResultChangeRegionForPrimitive(mDescription, mInputExtents); } - nsIntRegion match(const MergeAttributes& aMerge) { + nsIntRegion operator()(const MergeAttributes& aMerge) { return ResultChangeRegionForPrimitive(mDescription, mInputExtents); } - nsIntRegion match(const GaussianBlurAttributes& aGaussianBlur) { + nsIntRegion operator()(const GaussianBlurAttributes& aGaussianBlur) { return ResultChangeRegionForPrimitive(mDescription, mInputExtents); } - nsIntRegion match(const DropShadowAttributes& aDropShadow) { + nsIntRegion operator()(const DropShadowAttributes& aDropShadow) { return ResultChangeRegionForPrimitive(mDescription, mInputExtents); } - nsIntRegion match(const DiffuseLightingAttributes& aDiffuseLighting) { + nsIntRegion operator()(const DiffuseLightingAttributes& aDiffuseLighting) { return mDescription.PrimitiveSubregion(); } - nsIntRegion match(const SpecularLightingAttributes& aSpecularLighting) { + nsIntRegion operator()( + const SpecularLightingAttributes& aSpecularLighting) { return mDescription.PrimitiveSubregion(); } - nsIntRegion match(const ImageAttributes& aImage) { + nsIntRegion operator()(const ImageAttributes& aImage) { return mDescription.PrimitiveSubregion(); } - nsIntRegion match(const ToAlphaAttributes& aToAlpha) { + nsIntRegion operator()(const ToAlphaAttributes& aToAlpha) { return ResultChangeRegionForPrimitive(mDescription, mInputExtents); } }; @@ -1738,19 +1746,19 @@ static nsIntRegion SourceNeededRegionForPrimitive( const nsIntRegion& mResultNeededRegion; const int32_t mInputIndex; - nsIntRegion match(const EmptyAttributes& aEmptyAttributes) { + nsIntRegion operator()(const EmptyAttributes& aEmptyAttributes) { return nsIntRegion(); } - nsIntRegion match(const BlendAttributes& aBlend) { + nsIntRegion operator()(const BlendAttributes& aBlend) { return mResultNeededRegion; } - nsIntRegion match(const ColorMatrixAttributes& aColorMatrix) { + nsIntRegion operator()(const ColorMatrixAttributes& aColorMatrix) { return mResultNeededRegion; } - nsIntRegion match(const MorphologyAttributes& aMorphology) { + nsIntRegion operator()(const MorphologyAttributes& aMorphology) { Size radii = aMorphology.mRadii; int32_t rx = clamped(int32_t(ceil(radii.width)), 0, kMorphologyMaxRadius); int32_t ry = @@ -1758,24 +1766,25 @@ static nsIntRegion SourceNeededRegionForPrimitive( return mResultNeededRegion.Inflated(nsIntMargin(ry, rx, ry, rx)); } - nsIntRegion match(const FloodAttributes& aFlood) { + nsIntRegion operator()(const FloodAttributes& aFlood) { MOZ_CRASH("GFX: this shouldn't be called for filters without inputs"); return nsIntRegion(); } - nsIntRegion match(const TileAttributes& aTile) { + nsIntRegion operator()(const TileAttributes& aTile) { return IntRect(INT32_MIN / 2, INT32_MIN / 2, INT32_MAX, INT32_MAX); } - nsIntRegion match(const ComponentTransferAttributes& aComponentTransfer) { + nsIntRegion operator()( + const ComponentTransferAttributes& aComponentTransfer) { return mResultNeededRegion; } - nsIntRegion match(const OpacityAttributes& aOpacity) { + nsIntRegion operator()(const OpacityAttributes& aOpacity) { return mResultNeededRegion; } - nsIntRegion match(const ConvolveMatrixAttributes& aConvolveMatrix) { + nsIntRegion operator()(const ConvolveMatrixAttributes& aConvolveMatrix) { Size kernelUnitLength = aConvolveMatrix.mKernelUnitLength; IntSize kernelSize = aConvolveMatrix.mKernelSize; IntPoint target = aConvolveMatrix.mTarget; @@ -1787,12 +1796,12 @@ static nsIntRegion SourceNeededRegionForPrimitive( return mResultNeededRegion.Inflated(m); } - nsIntRegion match(const OffsetAttributes& aOffset) { + nsIntRegion operator()(const OffsetAttributes& aOffset) { IntPoint offset = aOffset.mValue; return mResultNeededRegion.MovedBy(-nsIntPoint(offset.x, offset.y)); } - nsIntRegion match(const DisplacementMapAttributes& aDisplacementMap) { + nsIntRegion operator()(const DisplacementMapAttributes& aDisplacementMap) { if (mInputIndex == 1) { return mResultNeededRegion; } @@ -1801,27 +1810,27 @@ static nsIntRegion SourceNeededRegionForPrimitive( nsIntMargin(scale, scale, scale, scale)); } - nsIntRegion match(const TurbulenceAttributes& aTurbulence) { + nsIntRegion operator()(const TurbulenceAttributes& aTurbulence) { MOZ_CRASH("GFX: this shouldn't be called for filters without inputs"); return nsIntRegion(); } - nsIntRegion match(const CompositeAttributes& aComposite) { + nsIntRegion operator()(const CompositeAttributes& aComposite) { return mResultNeededRegion; } - nsIntRegion match(const MergeAttributes& aMerge) { + nsIntRegion operator()(const MergeAttributes& aMerge) { return mResultNeededRegion; } - nsIntRegion match(const GaussianBlurAttributes& aGaussianBlur) { + nsIntRegion operator()(const GaussianBlurAttributes& aGaussianBlur) { const Size& stdDeviation = aGaussianBlur.mStdDeviation; int32_t dx = InflateSizeForBlurStdDev(stdDeviation.width); int32_t dy = InflateSizeForBlurStdDev(stdDeviation.height); return mResultNeededRegion.Inflated(nsIntMargin(dy, dx, dy, dx)); } - nsIntRegion match(const DropShadowAttributes& aDropShadow) { + nsIntRegion operator()(const DropShadowAttributes& aDropShadow) { IntPoint offset = aDropShadow.mOffset; nsIntRegion offsetRegion = mResultNeededRegion.MovedBy(-nsIntPoint(offset.x, offset.y)); @@ -1834,24 +1843,24 @@ static nsIntRegion SourceNeededRegionForPrimitive( return blurRegion; } - nsIntRegion match(const SpecularLightingAttributes& aLighting) { - return match( + nsIntRegion operator()(const SpecularLightingAttributes& aLighting) { + return operator()( *(static_cast(&aLighting))); } - nsIntRegion match(const DiffuseLightingAttributes& aLighting) { + nsIntRegion operator()(const DiffuseLightingAttributes& aLighting) { Size kernelUnitLength = aLighting.mKernelUnitLength; int32_t dx = ceil(kernelUnitLength.width); int32_t dy = ceil(kernelUnitLength.height); return mResultNeededRegion.Inflated(nsIntMargin(dy, dx, dy, dx)); } - nsIntRegion match(const ImageAttributes& aImage) { + nsIntRegion operator()(const ImageAttributes& aImage) { MOZ_CRASH("GFX: this shouldn't be called for filters without inputs"); return nsIntRegion(); } - nsIntRegion match(const ToAlphaAttributes& aToAlpha) { + nsIntRegion operator()(const ToAlphaAttributes& aToAlpha) { return mResultNeededRegion; } }; diff --git a/ipc/glue/IPCMessageUtils.h b/ipc/glue/IPCMessageUtils.h index aeff61c75844..8fac423153c2 100644 --- a/ipc/glue/IPCMessageUtils.h +++ b/ipc/glue/IPCMessageUtils.h @@ -980,7 +980,7 @@ struct ParamTraits> { Message* msg; template - void match(const T& t) { + void operator()(const T& t) { WriteParam(msg, t); } }; diff --git a/js/public/GCVariant.h b/js/public/GCVariant.h index 6be77ac628c5..e5575b895fd1 100644 --- a/js/public/GCVariant.h +++ b/js/public/GCVariant.h @@ -119,7 +119,7 @@ struct GCPolicy> { private: struct IsValidMatcher { template - bool match(T& v) { + bool operator()(T& v) { return GCPolicy::isValid(v); }; }; diff --git a/js/src/frontend/EitherParser.h b/js/src/frontend/EitherParser.h index e2bda54f5be1..eab3e014a96b 100644 --- a/js/src/frontend/EitherParser.h +++ b/js/src/frontend/EitherParser.h @@ -47,7 +47,7 @@ struct InvokeMemberFunction { : args{std::forward(actualArgs)...} {} template - auto match(Parser* parser) + auto operator()(Parser* parser) -> decltype(this->matchInternal(GetThis::get(parser), std::index_sequence_for{})) { return this->matchInternal(GetThis::get(parser), @@ -88,21 +88,21 @@ struct TokenStreamComputeLineAndColumn { struct ParseHandlerMatcher { template - frontend::FullParseHandler& match(Parser* parser) { + frontend::FullParseHandler& operator()(Parser* parser) { return parser->handler_; } }; struct ParserSharedBaseMatcher { template - frontend::ParserSharedBase& match(Parser* parser) { + frontend::ParserSharedBase& operator()(Parser* parser) { return *static_cast(parser); } }; struct ErrorReporterMatcher { template - frontend::ErrorReporter& match(Parser* parser) { + frontend::ErrorReporter& operator()(Parser* parser) { return parser->tokenStream; } }; diff --git a/js/src/vm/Compartment.h b/js/src/vm/Compartment.h index bcbbaffc0ef0..62072f8a8c69 100644 --- a/js/src/vm/Compartment.h +++ b/js/src/vm/Compartment.h @@ -87,13 +87,17 @@ class CrossCompartmentKey { struct WrappedMatcher { F f_; explicit WrappedMatcher(F f) : f_(f) {} - auto match(JSObject*& obj) { return f_(&obj); } - auto match(JSString*& str) { return f_(&str); } - auto match(DebuggerAndScript& tpl) { return f_(&mozilla::Get<1>(tpl)); } - auto match(DebuggerAndLazyScript& tpl) { + auto operator()(JSObject*& obj) { return f_(&obj); } + auto operator()(JSString*& str) { return f_(&str); } + auto operator()(DebuggerAndScript& tpl) { + return f_(&mozilla::Get<1>(tpl)); + } + auto operator()(DebuggerAndLazyScript& tpl) { + return f_(&mozilla::Get<1>(tpl)); + } + auto operator()(DebuggerAndObject& tpl) { return f_(&mozilla::Get<1>(tpl)); } - auto match(DebuggerAndObject& tpl) { return f_(&mozilla::Get<1>(tpl)); } } matcher(f); return wrapped.match(matcher); } @@ -104,15 +108,15 @@ class CrossCompartmentKey { struct DebuggerMatcher { F f_; explicit DebuggerMatcher(F f) : f_(f) {} - ReturnType match(JSObject*& obj) { return ReturnType(); } - ReturnType match(JSString*& str) { return ReturnType(); } - ReturnType match(DebuggerAndScript& tpl) { + ReturnType operator()(JSObject*& obj) { return ReturnType(); } + ReturnType operator()(JSString*& str) { return ReturnType(); } + ReturnType operator()(DebuggerAndScript& tpl) { return f_(&mozilla::Get<0>(tpl)); } - ReturnType match(DebuggerAndLazyScript& tpl) { + ReturnType operator()(DebuggerAndLazyScript& tpl) { return f_(&mozilla::Get<0>(tpl)); } - ReturnType match(DebuggerAndObject& tpl) { + ReturnType operator()(DebuggerAndObject& tpl) { return f_(&mozilla::Get<0>(tpl)); } } matcher(f); @@ -125,21 +129,21 @@ class CrossCompartmentKey { struct Hasher : public DefaultHasher { struct HashFunctor { - HashNumber match(JSObject* obj) { + HashNumber operator()(JSObject* obj) { return DefaultHasher::hash(obj); } - HashNumber match(JSString* str) { + HashNumber operator()(JSString* str) { return DefaultHasher::hash(str); } - HashNumber match(const DebuggerAndScript& tpl) { + HashNumber operator()(const DebuggerAndScript& tpl) { return DefaultHasher::hash(mozilla::Get<0>(tpl)) ^ DefaultHasher::hash(mozilla::Get<1>(tpl)); } - HashNumber match(const DebuggerAndLazyScript& tpl) { + HashNumber operator()(const DebuggerAndLazyScript& tpl) { return DefaultHasher::hash(mozilla::Get<0>(tpl)) ^ DefaultHasher::hash(mozilla::Get<1>(tpl)); } - HashNumber match(const DebuggerAndObject& tpl) { + HashNumber operator()(const DebuggerAndObject& tpl) { return DefaultHasher::hash(mozilla::Get<0>(tpl)) ^ DefaultHasher::hash(mozilla::Get<1>(tpl)) ^ (mozilla::Get<2>(tpl) << 5); diff --git a/js/src/vm/HelperThreads.cpp b/js/src/vm/HelperThreads.cpp index 32fe7ee75e5c..aa7768fcc995 100644 --- a/js/src/vm/HelperThreads.cpp +++ b/js/src/vm/HelperThreads.cpp @@ -234,15 +234,17 @@ static void FinishOffThreadIonCompile(jit::IonBuilder* builder, static JSRuntime* GetSelectorRuntime(const CompilationSelector& selector) { struct Matcher { - JSRuntime* match(JSScript* script) { + JSRuntime* operator()(JSScript* script) { return script->runtimeFromMainThread(); } - JSRuntime* match(Realm* realm) { return realm->runtimeFromMainThread(); } - JSRuntime* match(Zone* zone) { return zone->runtimeFromMainThread(); } - JSRuntime* match(ZonesInState zbs) { return zbs.runtime; } - JSRuntime* match(JSRuntime* runtime) { return runtime; } - JSRuntime* match(AllCompilations all) { return nullptr; } - JSRuntime* match(CompilationsUsingNursery cun) { return cun.runtime; } + JSRuntime* operator()(Realm* realm) { + return realm->runtimeFromMainThread(); + } + JSRuntime* operator()(Zone* zone) { return zone->runtimeFromMainThread(); } + JSRuntime* operator()(ZonesInState zbs) { return zbs.runtime; } + JSRuntime* operator()(JSRuntime* runtime) { return runtime; } + JSRuntime* operator()(AllCompilations all) { return nullptr; } + JSRuntime* operator()(CompilationsUsingNursery cun) { return cun.runtime; } }; return selector.match(Matcher()); @@ -250,13 +252,13 @@ static JSRuntime* GetSelectorRuntime(const CompilationSelector& selector) { static bool JitDataStructuresExist(const CompilationSelector& selector) { struct Matcher { - bool match(JSScript* script) { return !!script->realm()->jitRealm(); } - bool match(Realm* realm) { return !!realm->jitRealm(); } - bool match(Zone* zone) { return !!zone->jitZone(); } - bool match(ZonesInState zbs) { return zbs.runtime->hasJitRuntime(); } - bool match(JSRuntime* runtime) { return runtime->hasJitRuntime(); } - bool match(AllCompilations all) { return true; } - bool match(CompilationsUsingNursery cun) { + bool operator()(JSScript* script) { return !!script->realm()->jitRealm(); } + bool operator()(Realm* realm) { return !!realm->jitRealm(); } + bool operator()(Zone* zone) { return !!zone->jitZone(); } + bool operator()(ZonesInState zbs) { return zbs.runtime->hasJitRuntime(); } + bool operator()(JSRuntime* runtime) { return runtime->hasJitRuntime(); } + bool operator()(AllCompilations all) { return true; } + bool operator()(CompilationsUsingNursery cun) { return cun.runtime->hasJitRuntime(); } }; @@ -269,20 +271,22 @@ static bool IonBuilderMatches(const CompilationSelector& selector, struct BuilderMatches { jit::IonBuilder* builder_; - bool match(JSScript* script) { return script == builder_->script(); } - bool match(Realm* realm) { return realm == builder_->script()->realm(); } - bool match(Zone* zone) { + bool operator()(JSScript* script) { return script == builder_->script(); } + bool operator()(Realm* realm) { + return realm == builder_->script()->realm(); + } + bool operator()(Zone* zone) { return zone == builder_->script()->zoneFromAnyThread(); } - bool match(JSRuntime* runtime) { + bool operator()(JSRuntime* runtime) { return runtime == builder_->script()->runtimeFromAnyThread(); } - bool match(AllCompilations all) { return true; } - bool match(ZonesInState zbs) { + bool operator()(AllCompilations all) { return true; } + bool operator()(ZonesInState zbs) { return zbs.runtime == builder_->script()->runtimeFromAnyThread() && zbs.state == builder_->script()->zoneFromAnyThread()->gcState(); } - bool match(CompilationsUsingNursery cun) { + bool operator()(CompilationsUsingNursery cun) { return cun.runtime == builder_->script()->runtimeFromAnyThread() && !builder_->safeForMinorGC(); } diff --git a/js/src/vm/JSScript.cpp b/js/src/vm/JSScript.cpp index 19f680ae0872..dd8a67ede17e 100644 --- a/js/src/vm/JSScript.cpp +++ b/js/src/vm/JSScript.cpp @@ -2320,12 +2320,12 @@ struct SourceCompressionTask::PerformTaskWork { explicit PerformTaskWork(SourceCompressionTask* task) : task_(task) {} template - void match(const ScriptSource::Uncompressed&) { + void operator()(const ScriptSource::Uncompressed&) { task_->workEncodingSpecific(); } template - void match(const T&) { + void operator()(const T&) { MOZ_CRASH( "why are we compressing missing, already-compressed, or " "BinAST source?"); diff --git a/js/src/vm/JSScript.h b/js/src/vm/JSScript.h index 50f79f9f25f8..d7e54450e648 100644 --- a/js/src/vm/JSScript.h +++ b/js/src/vm/JSScript.h @@ -714,12 +714,12 @@ class ScriptSource { private: struct UncompressedDataMatcher { template - const void* match(const Uncompressed& u) { + const void* operator()(const Uncompressed& u) { return u.units(); } template - const void* match(const T&) { + const void* operator()(const T&) { MOZ_CRASH( "attempting to access uncompressed data in a " "ScriptSource not containing it"); @@ -736,12 +736,12 @@ class ScriptSource { private: struct CompressedDataMatcher { template - char* match(const Compressed& c) { + char* operator()(const Compressed& c) { return const_cast(c.raw.chars()); } template - char* match(const T&) { + char* operator()(const T&) { MOZ_CRASH( "attempting to access compressed data in a ScriptSource " "not containing it"); @@ -757,12 +757,14 @@ class ScriptSource { private: struct BinASTDataMatcher { - void* match(const BinAST& b) { return const_cast(b.string.chars()); } + void* operator()(const BinAST& b) { + return const_cast(b.string.chars()); + } void notBinAST() { MOZ_CRASH("ScriptSource isn't backed by BinAST data"); } template - void* match(const T&) { + void* operator()(const T&) { notBinAST(); return nullptr; } @@ -774,18 +776,18 @@ class ScriptSource { private: struct HasUncompressedSource { template - bool match(const Uncompressed&) { + bool operator()(const Uncompressed&) { return true; } template - bool match(const Compressed&) { + bool operator()(const Compressed&) { return false; } - bool match(const BinAST&) { return false; } + bool operator()(const BinAST&) { return false; } - bool match(const Missing&) { return false; } + bool operator()(const Missing&) { return false; } }; public: @@ -802,18 +804,18 @@ class ScriptSource { private: struct HasCompressedSource { template - bool match(const Compressed&) { + bool operator()(const Compressed&) { return true; } template - bool match(const Uncompressed&) { + bool operator()(const Uncompressed&) { return false; } - bool match(const BinAST&) { return false; } + bool operator()(const BinAST&) { return false; } - bool match(const Missing&) { return false; } + bool operator()(const Missing&) { return false; } }; public: @@ -829,21 +831,21 @@ class ScriptSource { template struct SourceTypeMatcher { template