diff --git a/dom/media/VideoUtils.cpp b/dom/media/VideoUtils.cpp index 08ee071691b8..088015bc064d 100644 --- a/dom/media/VideoUtils.cpp +++ b/dom/media/VideoUtils.cpp @@ -498,8 +498,8 @@ ParseCodecsString(const nsAString& aCodecs, nsTArray& aOutCodecs) static bool CheckContentType(const nsAString& aContentType, - mozilla::Function aSubtypeFilter, - mozilla::Function aCodecFilter) + mozilla::function aSubtypeFilter, + mozilla::function aCodecFilter) { nsContentTypeParser parser(aContentType); nsAutoString mimeType; diff --git a/gfx/2d/SFNTNameTable.h b/gfx/2d/SFNTNameTable.h index f5e2ac31b9d1..3879e328d552 100644 --- a/gfx/2d/SFNTNameTable.h +++ b/gfx/2d/SFNTNameTable.h @@ -18,7 +18,7 @@ namespace gfx { struct NameHeader; struct NameRecord; -typedef Vector> NameRecordMatchers; +typedef Vector> NameRecordMatchers; class SFNTNameTable final { diff --git a/gfx/layers/apz/util/APZCCallbackHelper.h b/gfx/layers/apz/util/APZCCallbackHelper.h index 93ff4f7309ae..ae6dd244bc7a 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.h +++ b/gfx/layers/apz/util/APZCCallbackHelper.h @@ -22,7 +22,7 @@ template class nsCOMPtr; namespace mozilla { namespace layers { -typedef Function&)> +typedef function&)> SetAllowedTouchBehaviorCallback; /* This class contains some helper methods that facilitate implementing the diff --git a/gfx/layers/apz/util/APZEventState.h b/gfx/layers/apz/util/APZEventState.h index 5572d5b1bee7..74936f040d00 100644 --- a/gfx/layers/apz/util/APZEventState.h +++ b/gfx/layers/apz/util/APZEventState.h @@ -28,7 +28,7 @@ namespace layers { class ActiveElementManager; -typedef Function ContentReceivedInputBlockCallback; diff --git a/gfx/skia/skia/include/private/SkTLogic.h b/gfx/skia/skia/include/private/SkTLogic.h index f94d13ecf8eb..5754d5d536fe 100644 --- a/gfx/skia/skia/include/private/SkTLogic.h +++ b/gfx/skia/skia/include/private/SkTLogic.h @@ -59,7 +59,11 @@ namespace std { #define false_type FalseType #define true_type TrueType - using mozilla::Function; + // If we have 'using mozilla::function', we're going to collide with + // 'std::function' on platforms that have it. Therefore we use a macro + // work around. + template + using Function = mozilla::function; #define function Function #endif } diff --git a/mfbt/Function.h b/mfbt/Function.h index 6a617e38314c..54278a4d0822 100644 --- a/mfbt/Function.h +++ b/mfbt/Function.h @@ -14,7 +14,7 @@ #include "mozilla/RefCounted.h" #include "mozilla/RefPtr.h" -// |Function| is a wrapper that can hold any type of callable +// |function| is a wrapper that can hold any type of callable // object that can be invoked in a way that's compatible with |Signature|. // The standard "type erasure" technique is used to avoid the type of the // wrapper depending on the concrete type of the wrapped callable. @@ -29,7 +29,7 @@ // this is a function type; it's not used in any way other than serving as a // vehicle to encode the return and argument types into a single type. // -// |Function| is default-constructible. A default-constructed instance is +// |function| is default-constructible. A default-constructed instance is // considered "empty". Invoking an empty instance is undefined behaviour. // An empty instance can be populated with a callable by assigning to it. // @@ -129,45 +129,45 @@ public: // and |Arguments| in the definition of the specialization without having to // introspect |Signature|. template -class Function; +class function; template -class Function +class function { public: - Function() {} + function() {} // This constructor is implicit to match the interface of |std::function|. template - MOZ_IMPLICIT Function(const Callable& aCallable) + MOZ_IMPLICIT function(const Callable& aCallable) : mImpl(new detail::FunctionImpl(aCallable)) {} - MOZ_IMPLICIT Function(const Function& aFunction) + MOZ_IMPLICIT function(const function& aFunction) : mImpl(aFunction.mImpl) {} - MOZ_IMPLICIT Function(decltype(nullptr)) + MOZ_IMPLICIT function(decltype(nullptr)) {} // Move constructor and move assingment operator. // These should be generated automatically, but MSVC doesn't do that yet. - Function(Function&& aOther) : mImpl(Move(aOther.mImpl)) {} - Function& operator=(Function&& aOther) { + function(function&& aOther) : mImpl(Move(aOther.mImpl)) {} + function& operator=(function&& aOther) { mImpl = Move(aOther.mImpl); return *this; } template - Function& operator=(const Callable& aCallable) + function& operator=(const Callable& aCallable) { mImpl = new detail::FunctionImpl(aCallable); return *this; } - Function& operator=(const Function& aFunction) + function& operator=(const function& aFunction) { mImpl = aFunction.mImpl; return *this; } - Function& operator=(decltype(nullptr)) + function& operator=(decltype(nullptr)) { mImpl = nullptr; return *this; diff --git a/mfbt/tests/TestFunction.cpp b/mfbt/tests/TestFunction.cpp index 6074fab950a6..f9f36ce2788e 100644 --- a/mfbt/tests/TestFunction.cpp +++ b/mfbt/tests/TestFunction.cpp @@ -7,7 +7,7 @@ #include "mozilla/Assertions.h" #include "mozilla/Function.h" -using mozilla::Function; +using mozilla::function; #define CHECK(c) \ do { \ @@ -36,21 +36,21 @@ struct Incrementor { static void TestNonmemberFunction() { - Function f = &increment; + function f = &increment; CHECK(f(42) == 43); } static void TestStaticMemberFunction() { - Function f = &S::increment; + function f = &S::increment; CHECK(f(42) == 43); } static void TestFunctionObject() { - Function f = Incrementor(); + function f = Incrementor(); CHECK(f(42) == 43); } @@ -58,19 +58,19 @@ static void TestLambda() { // Test non-capturing lambda - Function f = [](int arg){ return arg + 1; }; + function f = [](int arg){ return arg + 1; }; CHECK(f(42) == 43); // Test capturing lambda int one = 1; - Function g = [one](int arg){ return arg + one; }; + function g = [one](int arg){ return arg + one; }; CHECK(g(42) == 43); } static void TestDefaultConstructionAndAssignmentLater() { - Function f; // allowed + function f; // allowed // Would get an assertion if we tried calling f now. f = &increment; CHECK(f(42) == 43); @@ -79,7 +79,7 @@ TestDefaultConstructionAndAssignmentLater() static void TestReassignment() { - Function f = &increment; + function f = &increment; CHECK(f(42) == 43); f = [](int arg){ return arg + 2; }; CHECK(f(42) == 44); @@ -88,7 +88,7 @@ TestReassignment() static void TestMemberFunction() { - Function f = &S::decrement; + function f = &S::decrement; S s; CHECK((f(s, 1) == 0)); } @@ -96,7 +96,7 @@ TestMemberFunction() static void TestConstMemberFunction() { - Function f = &S::sum; + function f = &S::sum; const S s; CHECK((f(&s, 1, 1) == 2)); } diff --git a/xpcom/base/NSPRLogModulesParser.cpp b/xpcom/base/NSPRLogModulesParser.cpp index 43c80e915f46..31fe2587927e 100644 --- a/xpcom/base/NSPRLogModulesParser.cpp +++ b/xpcom/base/NSPRLogModulesParser.cpp @@ -15,7 +15,7 @@ namespace mozilla { void NSPRLogModulesParser(const char* aLogModules, - Function aCallback) + function aCallback) { if (!aLogModules) { return; diff --git a/xpcom/base/NSPRLogModulesParser.h b/xpcom/base/NSPRLogModulesParser.h index 664bd73e68a9..5ecafe13ed91 100644 --- a/xpcom/base/NSPRLogModulesParser.h +++ b/xpcom/base/NSPRLogModulesParser.h @@ -17,6 +17,6 @@ namespace mozilla { * @param aCallback The callback to invoke for each log module config entry. */ void NSPRLogModulesParser(const char* aLogModules, - Function aCallback); + function aCallback); } // namespace mozilla