mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1253678 - Rename mozilla::Function to mozilla::function. r=froydnj
MozReview-Commit-ID: 60RPmEsYDN2 --HG-- extra : rebase_source : 9d0bebc7362af2778d123425c56ac20553d9303b
This commit is contained in:
parent
98f171e09f
commit
52f227c58b
@ -498,8 +498,8 @@ ParseCodecsString(const nsAString& aCodecs, nsTArray<nsString>& aOutCodecs)
|
||||
|
||||
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;
|
||||
|
@ -18,7 +18,7 @@ namespace gfx {
|
||||
struct NameHeader;
|
||||
struct NameRecord;
|
||||
|
||||
typedef Vector<Function<bool(const NameRecord*)>> NameRecordMatchers;
|
||||
typedef Vector<function<bool(const NameRecord*)>> NameRecordMatchers;
|
||||
|
||||
class SFNTNameTable final
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ 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
|
||||
|
@ -28,7 +28,7 @@ namespace layers {
|
||||
|
||||
class ActiveElementManager;
|
||||
|
||||
typedef Function<void(const ScrollableLayerGuid&,
|
||||
typedef function<void(const ScrollableLayerGuid&,
|
||||
uint64_t /* input block id */,
|
||||
bool /* prevent default */)>
|
||||
ContentReceivedInputBlockCallback;
|
||||
|
@ -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<typename Signature>
|
||||
using Function = mozilla::function<Signature>;
|
||||
#define function Function
|
||||
#endif
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
#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.
|
||||
@ -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<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;
|
||||
|
@ -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<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);
|
||||
}
|
||||
|
||||
@ -58,19 +58,19 @@ 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);
|
||||
@ -79,7 +79,7 @@ TestDefaultConstructionAndAssignmentLater()
|
||||
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);
|
||||
@ -88,7 +88,7 @@ TestReassignment()
|
||||
static void
|
||||
TestMemberFunction()
|
||||
{
|
||||
Function<int(S&, int)> f = &S::decrement;
|
||||
function<int(S&, int)> f = &S::decrement;
|
||||
S s;
|
||||
CHECK((f(s, 1) == 0));
|
||||
}
|
||||
@ -96,7 +96,7 @@ TestMemberFunction()
|
||||
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));
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace mozilla {
|
||||
|
||||
void
|
||||
NSPRLogModulesParser(const char* aLogModules,
|
||||
Function<void(const char*, LogLevel)> aCallback)
|
||||
function<void(const char*, LogLevel)> aCallback)
|
||||
{
|
||||
if (!aLogModules) {
|
||||
return;
|
||||
|
@ -17,6 +17,6 @@ namespace mozilla {
|
||||
* @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
|
||||
|
Loading…
Reference in New Issue
Block a user