Bug 1253678 - Rename mozilla::Function to mozilla::function. r=froydnj
authorBenoit Girard <b56girard@gmail.com>
Fri, 11 Mar 2016 16:49:13 -0500
changeset 288341 c3c4bc792bb542765f57869b00ccd8c28905e5ea
parent 288340 602a58ea423e0691f6cdc702dee98b318b91b485
child 288342 79af3a479ce9229d2fd494466996acd11ec58be8
push id73395
push userb56girard@gmail.com
push dateFri, 11 Mar 2016 23:19:55 +0000
treeherdermozilla-inbound@c3c4bc792bb5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1253678
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1253678 - Rename mozilla::Function to mozilla::function. r=froydnj MozReview-Commit-ID: 60RPmEsYDN2
dom/media/VideoUtils.cpp
gfx/2d/SFNTNameTable.h
gfx/layers/apz/util/APZCCallbackHelper.h
gfx/layers/apz/util/APZEventState.h
gfx/skia/skia/include/private/SkTLogic.h
mfbt/Function.h
mfbt/tests/TestFunction.cpp
xpcom/base/NSPRLogModulesParser.cpp
xpcom/base/NSPRLogModulesParser.h
--- a/dom/media/VideoUtils.cpp
+++ b/dom/media/VideoUtils.cpp
@@ -493,18 +493,18 @@ ParseCodecsString(const nsAString& aCode
     // Last codec name was empty
     return false;
   }
   return true;
 }
 
 static bool
 CheckContentType(const nsAString& aContentType,
-                 mozilla::Function<bool(const nsAString&)> aSubtypeFilter,
-                 mozilla::Function<bool(const nsAString&)> aCodecFilter)
+                 mozilla::function<bool(const nsAString&)> aSubtypeFilter,
+                 mozilla::function<bool(const nsAString&)> aCodecFilter)
 {
   nsContentTypeParser parser(aContentType);
   nsAutoString mimeType;
   nsresult rv = parser.GetType(mimeType);
   if (NS_FAILED(rv) || !aSubtypeFilter(mimeType)) {
     return false;
   }
 
--- a/gfx/2d/SFNTNameTable.h
+++ b/gfx/2d/SFNTNameTable.h
@@ -13,17 +13,17 @@
 #include "u16string.h"
 
 namespace mozilla {
 namespace gfx {
 
 struct NameHeader;
 struct NameRecord;
 
-typedef Vector<Function<bool(const NameRecord*)>> NameRecordMatchers;
+typedef Vector<function<bool(const NameRecord*)>> NameRecordMatchers;
 
 class SFNTNameTable final
 {
 public:
 
   /**
    * Creates a SFNTNameTable if the header data is valid. Note that the data is
    * NOT copied, so must exist for the lifetime of the table.
--- a/gfx/layers/apz/util/APZCCallbackHelper.h
+++ b/gfx/layers/apz/util/APZCCallbackHelper.h
@@ -17,17 +17,17 @@ class nsIDocument;
 class nsIPresShell;
 class nsIWidget;
 template<class T> struct already_AddRefed;
 template<class T> class nsCOMPtr;
 
 namespace mozilla {
 namespace layers {
 
-typedef Function<void(uint64_t, const nsTArray<TouchBehaviorFlags>&)>
+typedef function<void(uint64_t, const nsTArray<TouchBehaviorFlags>&)>
         SetAllowedTouchBehaviorCallback;
 
 /* This class contains some helper methods that facilitate implementing the
    GeckoContentController callback interface required by the AsyncPanZoomController.
    Since different platforms need to implement this interface in similar-but-
    not-quite-the-same ways, this utility class provides some helpful methods
    to hold code that can be shared across the different platform implementations.
  */
--- a/gfx/layers/apz/util/APZEventState.h
+++ b/gfx/layers/apz/util/APZEventState.h
@@ -23,17 +23,17 @@ class nsIDocument;
 class nsIPresShell;
 class nsIWidget;
 
 namespace mozilla {
 namespace layers {
 
 class ActiveElementManager;
 
-typedef Function<void(const ScrollableLayerGuid&,
+typedef function<void(const ScrollableLayerGuid&,
                       uint64_t /* input block id */,
                       bool /* prevent default */)>
         ContentReceivedInputBlockCallback;
 
 /**
  * A content-side component that keeps track of state for handling APZ
  * gestures and sending APZ notifications.
  */
--- a/gfx/skia/skia/include/private/SkTLogic.h
+++ b/gfx/skia/skia/include/private/SkTLogic.h
@@ -54,17 +54,21 @@ namespace std {
     using mozilla::IsEmpty;
     using mozilla::FalseType;
     using mozilla::TrueType;
     #define integral_constant IntegralConstant
     #define is_empty IsEmpty
     #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<typename Signature>
+    using Function = mozilla::function<Signature>;
     #define function Function
 #endif
 }
 
 namespace skstd {
 
 template <bool B> using bool_constant = mozilla::IntegralConstant<bool, B>;
 
--- a/mfbt/Function.h
+++ b/mfbt/Function.h
@@ -9,32 +9,32 @@
 #ifndef mozilla_Function_h
 #define mozilla_Function_h
 
 #include "mozilla/Attributes.h"  // for MOZ_IMPLICIT
 #include "mozilla/Move.h"
 #include "mozilla/RefCounted.h"
 #include "mozilla/RefPtr.h"
 
-// |Function<Signature>| is a wrapper that can hold any type of callable
+// |function<Signature>| 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.
 //
 // Supported callable types include non-member functions, static member
 // functions, and function objects (that is to say, objects with an overloaded
 // call operator; this includes C++11 lambdas). Member functions aren't
 // directly supported; they first need to be wrapped into a function object
 // using |std::mem_fn()| or an equivalent.
 //
 // |Signature| is a type of the form |ReturnType(Arguments...)|. Syntactically,
 // 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.
 //
 // This class is intended to provide functionality similar to the C++11
 // standard library class |std::function|.
 
 namespace mozilla {
 
@@ -124,55 +124,55 @@ public:
 } // namespace detail
 
 // The primary template is never defined. As |Signature| is required to be
 // of the form |ReturnType(Arguments...)|, we only define a partial
 // specialization that matches this form. This allows us to use |ReturnType|
 // and |Arguments| in the definition of the specialization without having to
 // introspect |Signature|.
 template<typename Signature>
-class Function;
+class function;
 
 template<typename ReturnType, typename... Arguments>
-class Function<ReturnType(Arguments...)>
+class function<ReturnType(Arguments...)>
 {
 public:
-  Function() {}
+  function() {}
 
   // This constructor is implicit to match the interface of |std::function|.
   template <typename Callable>
-  MOZ_IMPLICIT Function(const Callable& aCallable)
+  MOZ_IMPLICIT function(const Callable& aCallable)
     : mImpl(new detail::FunctionImpl<Callable, ReturnType, Arguments...>(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 <typename Callable>
-  Function& operator=(const Callable& aCallable)
+  function& operator=(const Callable& aCallable)
   {
     mImpl = new detail::FunctionImpl<Callable, ReturnType, Arguments...>(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;
   }
 
   template<typename... Args>
   ReturnType operator()(Args&&... aArguments) const
   {
--- a/mfbt/tests/TestFunction.cpp
+++ b/mfbt/tests/TestFunction.cpp
@@ -2,17 +2,17 @@
    /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Assertions.h"
 #include "mozilla/Function.h"
 
-using mozilla::Function;
+using mozilla::function;
 
 #define CHECK(c) \
   do { \
     bool cond = !!(c); \
     MOZ_RELEASE_ASSERT(cond, "Failed assertion: " #c); \
   } while (false)
 
 struct ConvertibleToInt
@@ -31,77 +31,77 @@ struct S {
 
 struct Incrementor {
   int operator()(int arg) { return arg + 1; }
 };
 
 static void
 TestNonmemberFunction()
 {
-  Function<int(int)> f = &increment;
+  function<int(int)> f = &increment;
   CHECK(f(42) == 43);
 }
 
 static void
 TestStaticMemberFunction()
 {
-  Function<int(int)> f = &S::increment;
+  function<int(int)> f = &S::increment;
   CHECK(f(42) == 43);
 }
 
 static void
 TestFunctionObject()
 {
-  Function<int(int)> f = Incrementor();
+  function<int(int)> f = Incrementor();
   CHECK(f(42) == 43);
 }
 
 static void
 TestLambda()
 {
   // Test non-capturing lambda
-  Function<int(int)> f = [](int arg){ return arg + 1; };
+  function<int(int)> f = [](int arg){ return arg + 1; };
   CHECK(f(42) == 43);
 
   // Test capturing lambda
   int one = 1;
-  Function<int(int)> g = [one](int arg){ return arg + one; };
+  function<int(int)> g = [one](int arg){ return arg + one; };
   CHECK(g(42) == 43);
 }
 
 static void
 TestDefaultConstructionAndAssignmentLater()
 {
-  Function<int(int)> f;  // allowed
+  function<int(int)> f;  // allowed
   // Would get an assertion if we tried calling f now.
   f = &increment;
   CHECK(f(42) == 43);
 }
 
 static void
 TestReassignment()
 {
-  Function<int(int)> f = &increment;
+  function<int(int)> f = &increment;
   CHECK(f(42) == 43);
   f = [](int arg){ return arg + 2; };
   CHECK(f(42) == 44);
 }
 
 static void
 TestMemberFunction()
 {
-  Function<int(S&, int)> f = &S::decrement;
+  function<int(S&, int)> f = &S::decrement;
   S s;
   CHECK((f(s, 1) == 0));
 }
 
 static void
 TestConstMemberFunction()
 {
-  Function<int(const S*, int, int)> f = &S::sum;
+  function<int(const S*, int, int)> f = &S::sum;
   const S s;
   CHECK((f(&s, 1, 1) == 2));
 }
 int
 main()
 {
   TestNonmemberFunction();
   TestStaticMemberFunction();
--- a/xpcom/base/NSPRLogModulesParser.cpp
+++ b/xpcom/base/NSPRLogModulesParser.cpp
@@ -10,17 +10,17 @@
 
 const char kDelimiters[] = ", ";
 const char kAdditionalWordChars[] = "_-";
 
 namespace mozilla {
 
 void
 NSPRLogModulesParser(const char* aLogModules,
-                     Function<void(const char*, LogLevel)> aCallback)
+                     function<void(const char*, LogLevel)> aCallback)
 {
   if (!aLogModules) {
     return;
   }
 
   Tokenizer parser(aLogModules, kDelimiters, kAdditionalWordChars);
   nsAutoCString moduleName;
 
--- a/xpcom/base/NSPRLogModulesParser.h
+++ b/xpcom/base/NSPRLogModulesParser.h
@@ -12,11 +12,11 @@ namespace mozilla {
 /**
  * Helper function that parses the legacy NSPR_LOG_MODULES env var format
  * for specifying log levels and logging options.
  *
  * @param aLogModules The log modules configuration string.
  * @param aCallback The callback to invoke for each log module config entry.
  */
 void NSPRLogModulesParser(const char* aLogModules,
-                          Function<void(const char*, LogLevel)> aCallback);
+                          function<void(const char*, LogLevel)> aCallback);
 
 } // namespace mozilla