--- a/xpcom/glue/nsCOMPtr.cpp
+++ b/xpcom/glue/nsCOMPtr.cpp
@@ -44,85 +44,85 @@ nsCOMPtr_base::assign_with_AddRef(nsISup
assign_assuming_AddRef(aRawPtr);
}
void
nsCOMPtr_base::assign_from_qi(const nsQueryInterface aQI, const nsIID& aIID)
{
void* newRawPtr;
if (NS_FAILED(aQI(aIID, &newRawPtr))) {
- newRawPtr = 0;
+ newRawPtr = nullptr;
}
assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
}
void
nsCOMPtr_base::assign_from_qi_with_error(const nsQueryInterfaceWithError& aQI,
const nsIID& aIID)
{
void* newRawPtr;
if (NS_FAILED(aQI(aIID, &newRawPtr))) {
- newRawPtr = 0;
+ newRawPtr = nullptr;
}
assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
}
void
nsCOMPtr_base::assign_from_gs_cid(const nsGetServiceByCID aGS,
const nsIID& aIID)
{
void* newRawPtr;
if (NS_FAILED(aGS(aIID, &newRawPtr))) {
- newRawPtr = 0;
+ newRawPtr = nullptr;
}
assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
}
void
nsCOMPtr_base::assign_from_gs_cid_with_error(
const nsGetServiceByCIDWithError& aGS, const nsIID& aIID)
{
void* newRawPtr;
if (NS_FAILED(aGS(aIID, &newRawPtr))) {
- newRawPtr = 0;
+ newRawPtr = nullptr;
}
assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
}
void
nsCOMPtr_base::assign_from_gs_contractid(const nsGetServiceByContractID aGS,
const nsIID& aIID)
{
void* newRawPtr;
if (NS_FAILED(aGS(aIID, &newRawPtr))) {
- newRawPtr = 0;
+ newRawPtr = nullptr;
}
assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
}
void
nsCOMPtr_base::assign_from_gs_contractid_with_error(
const nsGetServiceByContractIDWithError& aGS, const nsIID& aIID)
{
void* newRawPtr;
if (NS_FAILED(aGS(aIID, &newRawPtr))) {
- newRawPtr = 0;
+ newRawPtr = nullptr;
}
assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
}
void
nsCOMPtr_base::assign_from_helper(const nsCOMPtr_helper& aHelper,
const nsIID& aIID)
{
void* newRawPtr;
if (NS_FAILED(aHelper(aIID, &newRawPtr))) {
- newRawPtr = 0;
+ newRawPtr = nullptr;
}
assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
}
void**
nsCOMPtr_base::begin_assignment()
{
- assign_assuming_AddRef(0);
+ assign_assuming_AddRef(nullptr);
return reinterpret_cast<void**>(&mRawPtr);
}
--- a/xpcom/glue/nsCOMPtr.h
+++ b/xpcom/glue/nsCOMPtr.h
@@ -280,17 +280,17 @@ private:
*
* template<class T> class Foo { ... };
* template<> class Foo<void*> { ... };
* template<class T> class Foo<T*> : private Foo<void*> { ... };
*/
class nsCOMPtr_base
{
public:
- explicit nsCOMPtr_base(nsISupports* aRawPtr = 0) : mRawPtr(aRawPtr) {}
+ explicit nsCOMPtr_base(nsISupports* aRawPtr = nullptr) : mRawPtr(aRawPtr) {}
NS_CONSTRUCTOR_FASTCALL ~nsCOMPtr_base()
{
NSCAP_LOG_RELEASE(this, mRawPtr);
if (mRawPtr) {
NSCAP_RELEASE(this, mRawPtr);
}
}
@@ -419,20 +419,20 @@ public:
#else
#define NSCAP_ASSERT_NO_QUERY_NEEDED()
#endif
// Constructors
nsCOMPtr()
- : NSCAP_CTOR_BASE(0)
+ : NSCAP_CTOR_BASE(nullptr)
{
assert_validity();
- NSCAP_LOG_ASSIGNMENT(this, 0);
+ NSCAP_LOG_ASSIGNMENT(this, nullptr);
}
nsCOMPtr(const nsCOMPtr<T>& aSmartPtr)
: NSCAP_CTOR_BASE(aSmartPtr.mRawPtr)
{
assert_validity();
if (mRawPtr) {
NSCAP_ADDREF(this, mRawPtr);
@@ -500,75 +500,75 @@ public:
static_assert(mozilla::IsBaseOf<T, U>::value,
"U is not a subclass of T");
NSCAP_LOG_ASSIGNMENT(this, static_cast<T*>(mRawPtr));
NSCAP_ASSERT_NO_QUERY_NEEDED();
}
// Construct from |do_QueryInterface(expr)|.
MOZ_IMPLICIT nsCOMPtr(const nsQueryInterface aQI)
- : NSCAP_CTOR_BASE(0)
+ : NSCAP_CTOR_BASE(nullptr)
{
assert_validity();
- NSCAP_LOG_ASSIGNMENT(this, 0);
+ NSCAP_LOG_ASSIGNMENT(this, nullptr);
assign_from_qi(aQI, NS_GET_TEMPLATE_IID(T));
}
// Construct from |do_QueryInterface(expr, &rv)|.
MOZ_IMPLICIT nsCOMPtr(const nsQueryInterfaceWithError& aQI)
- : NSCAP_CTOR_BASE(0)
+ : NSCAP_CTOR_BASE(nullptr)
{
assert_validity();
- NSCAP_LOG_ASSIGNMENT(this, 0);
+ NSCAP_LOG_ASSIGNMENT(this, nullptr);
assign_from_qi_with_error(aQI, NS_GET_TEMPLATE_IID(T));
}
// Construct from |do_GetService(cid_expr)|.
MOZ_IMPLICIT nsCOMPtr(const nsGetServiceByCID aGS)
- : NSCAP_CTOR_BASE(0)
+ : NSCAP_CTOR_BASE(nullptr)
{
assert_validity();
- NSCAP_LOG_ASSIGNMENT(this, 0);
+ NSCAP_LOG_ASSIGNMENT(this, nullptr);
assign_from_gs_cid(aGS, NS_GET_TEMPLATE_IID(T));
}
// Construct from |do_GetService(cid_expr, &rv)|.
MOZ_IMPLICIT nsCOMPtr(const nsGetServiceByCIDWithError& aGS)
- : NSCAP_CTOR_BASE(0)
+ : NSCAP_CTOR_BASE(nullptr)
{
assert_validity();
- NSCAP_LOG_ASSIGNMENT(this, 0);
+ NSCAP_LOG_ASSIGNMENT(this, nullptr);
assign_from_gs_cid_with_error(aGS, NS_GET_TEMPLATE_IID(T));
}
// Construct from |do_GetService(contractid_expr)|.
MOZ_IMPLICIT nsCOMPtr(const nsGetServiceByContractID aGS)
- : NSCAP_CTOR_BASE(0)
+ : NSCAP_CTOR_BASE(nullptr)
{
assert_validity();
- NSCAP_LOG_ASSIGNMENT(this, 0);
+ NSCAP_LOG_ASSIGNMENT(this, nullptr);
assign_from_gs_contractid(aGS, NS_GET_TEMPLATE_IID(T));
}
// Construct from |do_GetService(contractid_expr, &rv)|.
MOZ_IMPLICIT nsCOMPtr(const nsGetServiceByContractIDWithError& aGS)
- : NSCAP_CTOR_BASE(0)
+ : NSCAP_CTOR_BASE(nullptr)
{
assert_validity();
- NSCAP_LOG_ASSIGNMENT(this, 0);
+ NSCAP_LOG_ASSIGNMENT(this, nullptr);
assign_from_gs_contractid_with_error(aGS, NS_GET_TEMPLATE_IID(T));
}
// And finally, anything else we might need to construct from can exploit the
// nsCOMPtr_helper facility.
MOZ_IMPLICIT nsCOMPtr(const nsCOMPtr_helper& aHelper)
- : NSCAP_CTOR_BASE(0)
+ : NSCAP_CTOR_BASE(nullptr)
{
assert_validity();
- NSCAP_LOG_ASSIGNMENT(this, 0);
+ NSCAP_LOG_ASSIGNMENT(this, nullptr);
assign_from_helper(aHelper, NS_GET_TEMPLATE_IID(T));
NSCAP_ASSERT_NO_QUERY_NEEDED();
}
// Defined in OwningNonNull.h
template<class U>
MOZ_IMPLICIT nsCOMPtr(const mozilla::OwningNonNull<U>& aOther);
@@ -701,31 +701,31 @@ public:
// Other pointer operators
// Return the value of mRawPtr and null out mRawPtr. Useful for
// already_AddRefed return values.
already_AddRefed<T> forget()
{
- T* temp = 0;
+ T* temp = nullptr;
swap(temp);
return already_AddRefed<T>(temp);
}
// Set the target of aRhs to the value of mRawPtr and null out mRawPtr.
// Useful to avoid unnecessary AddRef/Release pairs with "out" parameters
// where aRhs bay be a T** or an I** where I is a base class of T.
template<typename I>
void forget(I** aRhs)
{
NS_ASSERTION(aRhs, "Null pointer passed to forget!");
NSCAP_LOG_RELEASE(this, mRawPtr);
*aRhs = get();
- mRawPtr = 0;
+ mRawPtr = nullptr;
}
// Prefer the implicit conversion provided automatically by
// |operator T*() const|. Use |get()| to resolve ambiguity or to get a
// castable pointer.
T* get() const { return reinterpret_cast<T*>(mRawPtr); }
// Makes an nsCOMPtr act like its underlying raw pointer type whenever it is
@@ -747,39 +747,39 @@ public:
operator T*() const && = delete;
// Needed to avoid the deleted operator above
explicit operator bool() const { return !!mRawPtr; }
#endif
T* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN
{
- MOZ_ASSERT(mRawPtr != 0,
+ MOZ_ASSERT(mRawPtr != nullptr,
"You can't dereference a NULL nsCOMPtr with operator->().");
return get();
}
// These are not intended to be used by clients. See |address_of| below.
nsCOMPtr<T>* get_address() { return this; }
const nsCOMPtr<T>* get_address() const { return this; }
public:
T& operator*() const
{
- MOZ_ASSERT(mRawPtr != 0,
+ MOZ_ASSERT(mRawPtr != nullptr,
"You can't dereference a NULL nsCOMPtr with operator*().");
return *get();
}
T** StartAssignment()
{
#ifndef NSCAP_FEATURE_INLINE_STARTASSIGNMENT
return reinterpret_cast<T**>(begin_assignment());
#else
- assign_assuming_AddRef(0);
+ assign_assuming_AddRef(nullptr);
return reinterpret_cast<T**>(&mRawPtr);
#endif
}
};
/*
* Specializing nsCOMPtr for nsISupports allows us to use nsCOMPtr<nsISupports>
@@ -795,19 +795,19 @@ class nsCOMPtr<nsISupports>
: private nsCOMPtr_base
{
public:
typedef nsISupports element_type;
// Constructors
nsCOMPtr()
- : nsCOMPtr_base(0)
+ : nsCOMPtr_base(nullptr)
{
- NSCAP_LOG_ASSIGNMENT(this, 0);
+ NSCAP_LOG_ASSIGNMENT(this, nullptr);
}
nsCOMPtr(const nsCOMPtr<nsISupports>& aSmartPtr)
: nsCOMPtr_base(aSmartPtr.mRawPtr)
{
if (mRawPtr) {
NSCAP_ADDREF(this, mRawPtr);
}
@@ -834,68 +834,68 @@ public:
MOZ_IMPLICIT nsCOMPtr(already_AddRefed<nsISupports>&& aSmartPtr)
: nsCOMPtr_base(aSmartPtr.take())
{
NSCAP_LOG_ASSIGNMENT(this, mRawPtr);
}
// Construct from |do_QueryInterface(expr)|.
MOZ_IMPLICIT nsCOMPtr(const nsQueryInterface aQI)
- : nsCOMPtr_base(0)
+ : nsCOMPtr_base(nullptr)
{
- NSCAP_LOG_ASSIGNMENT(this, 0);
+ NSCAP_LOG_ASSIGNMENT(this, nullptr);
assign_from_qi(aQI, NS_GET_IID(nsISupports));
}
// Construct from |do_QueryInterface(expr, &rv)|.
MOZ_IMPLICIT nsCOMPtr(const nsQueryInterfaceWithError& aQI)
- : nsCOMPtr_base(0)
+ : nsCOMPtr_base(nullptr)
{
- NSCAP_LOG_ASSIGNMENT(this, 0);
+ NSCAP_LOG_ASSIGNMENT(this, nullptr);
assign_from_qi_with_error(aQI, NS_GET_IID(nsISupports));
}
// Construct from |do_GetService(cid_expr)|.
MOZ_IMPLICIT nsCOMPtr(const nsGetServiceByCID aGS)
- : nsCOMPtr_base(0)
+ : nsCOMPtr_base(nullptr)
{
- NSCAP_LOG_ASSIGNMENT(this, 0);
+ NSCAP_LOG_ASSIGNMENT(this, nullptr);
assign_from_gs_cid(aGS, NS_GET_IID(nsISupports));
}
// Construct from |do_GetService(cid_expr, &rv)|.
MOZ_IMPLICIT nsCOMPtr(const nsGetServiceByCIDWithError& aGS)
- : nsCOMPtr_base(0)
+ : nsCOMPtr_base(nullptr)
{
- NSCAP_LOG_ASSIGNMENT(this, 0);
+ NSCAP_LOG_ASSIGNMENT(this, nullptr);
assign_from_gs_cid_with_error(aGS, NS_GET_IID(nsISupports));
}
// Construct from |do_GetService(contractid_expr)|.
MOZ_IMPLICIT nsCOMPtr(const nsGetServiceByContractID aGS)
- : nsCOMPtr_base(0)
+ : nsCOMPtr_base(nullptr)
{
- NSCAP_LOG_ASSIGNMENT(this, 0);
+ NSCAP_LOG_ASSIGNMENT(this, nullptr);
assign_from_gs_contractid(aGS, NS_GET_IID(nsISupports));
}
// Construct from |do_GetService(contractid_expr, &rv)|.
MOZ_IMPLICIT nsCOMPtr(const nsGetServiceByContractIDWithError& aGS)
- : nsCOMPtr_base(0)
+ : nsCOMPtr_base(nullptr)
{
- NSCAP_LOG_ASSIGNMENT(this, 0);
+ NSCAP_LOG_ASSIGNMENT(this, nullptr);
assign_from_gs_contractid_with_error(aGS, NS_GET_IID(nsISupports));
}
// And finally, anything else we might need to construct from can exploit
// the |nsCOMPtr_helper| facility
MOZ_IMPLICIT nsCOMPtr(const nsCOMPtr_helper& aHelper)
- : nsCOMPtr_base(0)
+ : nsCOMPtr_base(nullptr)
{
- NSCAP_LOG_ASSIGNMENT(this, 0);
+ NSCAP_LOG_ASSIGNMENT(this, nullptr);
assign_from_helper(aHelper, NS_GET_IID(nsISupports));
}
// Assignment operators
nsCOMPtr<nsISupports>& operator=(const nsCOMPtr<nsISupports>& aRhs)
{
@@ -994,28 +994,28 @@ public:
aRhs = mRawPtr;
mRawPtr = temp;
}
// Return the value of mRawPtr and null out mRawPtr. Useful for
// already_AddRefed return values.
already_AddRefed<nsISupports> forget()
{
- nsISupports* temp = 0;
+ nsISupports* temp = nullptr;
swap(temp);
return already_AddRefed<nsISupports>(temp);
}
// Set the target of aRhs to the value of mRawPtr and null out mRawPtr.
// Useful to avoid unnecessary AddRef/Release pairs with "out"
// parameters.
void forget(nsISupports** aRhs)
{
NS_ASSERTION(aRhs, "Null pointer passed to forget!");
- *aRhs = 0;
+ *aRhs = nullptr;
swap(*aRhs);
}
// Other pointer operators
// Prefer the implicit conversion provided automatically by
// |operator nsISupports*() const|. Use |get()| to resolve ambiguity or to
// get a castable pointer.
@@ -1026,40 +1026,40 @@ public:
// that makes an nsCOMPtr substitutable for a raw pointer.
//
// Prefer the implicit use of this operator to calling |get()|, except where
// necessary to resolve ambiguity/
operator nsISupports* () const { return get(); }
nsISupports* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN
{
- MOZ_ASSERT(mRawPtr != 0,
+ MOZ_ASSERT(mRawPtr != nullptr,
"You can't dereference a NULL nsCOMPtr with operator->().");
return get();
}
// These are not intended to be used by clients. See |address_of| below.
nsCOMPtr<nsISupports>* get_address() { return this; }
const nsCOMPtr<nsISupports>* get_address() const { return this; }
public:
nsISupports& operator*() const
{
- MOZ_ASSERT(mRawPtr != 0,
+ MOZ_ASSERT(mRawPtr != nullptr,
"You can't dereference a NULL nsCOMPtr with operator*().");
return *get();
}
nsISupports** StartAssignment()
{
#ifndef NSCAP_FEATURE_INLINE_STARTASSIGNMENT
return reinterpret_cast<nsISupports**>(begin_assignment());
#else
- assign_assuming_AddRef(0);
+ assign_assuming_AddRef(nullptr);
return reinterpret_cast<nsISupports**>(&mRawPtr);
#endif
}
};
template<typename T>
inline void
ImplCycleCollectionUnlink(nsCOMPtr<T>& aField)
@@ -1089,96 +1089,96 @@ nsCOMPtr<T>::assign_with_AddRef(nsISuppo
}
template<class T>
void
nsCOMPtr<T>::assign_from_qi(const nsQueryInterface aQI, const nsIID& aIID)
{
void* newRawPtr;
if (NS_FAILED(aQI(aIID, &newRawPtr))) {
- newRawPtr = 0;
+ newRawPtr = nullptr;
}
assign_assuming_AddRef(static_cast<T*>(newRawPtr));
}
template<class T>
void
nsCOMPtr<T>::assign_from_qi_with_error(const nsQueryInterfaceWithError& aQI,
const nsIID& aIID)
{
void* newRawPtr;
if (NS_FAILED(aQI(aIID, &newRawPtr))) {
- newRawPtr = 0;
+ newRawPtr = nullptr;
}
assign_assuming_AddRef(static_cast<T*>(newRawPtr));
}
template<class T>
void
nsCOMPtr<T>::assign_from_gs_cid(const nsGetServiceByCID aGS, const nsIID& aIID)
{
void* newRawPtr;
if (NS_FAILED(aGS(aIID, &newRawPtr))) {
- newRawPtr = 0;
+ newRawPtr = nullptr;
}
assign_assuming_AddRef(static_cast<T*>(newRawPtr));
}
template<class T>
void
nsCOMPtr<T>::assign_from_gs_cid_with_error(const nsGetServiceByCIDWithError& aGS,
const nsIID& aIID)
{
void* newRawPtr;
if (NS_FAILED(aGS(aIID, &newRawPtr))) {
- newRawPtr = 0;
+ newRawPtr = nullptr;
}
assign_assuming_AddRef(static_cast<T*>(newRawPtr));
}
template<class T>
void
nsCOMPtr<T>::assign_from_gs_contractid(const nsGetServiceByContractID aGS,
const nsIID& aIID)
{
void* newRawPtr;
if (NS_FAILED(aGS(aIID, &newRawPtr))) {
- newRawPtr = 0;
+ newRawPtr = nullptr;
}
assign_assuming_AddRef(static_cast<T*>(newRawPtr));
}
template<class T>
void
nsCOMPtr<T>::assign_from_gs_contractid_with_error(
const nsGetServiceByContractIDWithError& aGS, const nsIID& aIID)
{
void* newRawPtr;
if (NS_FAILED(aGS(aIID, &newRawPtr))) {
- newRawPtr = 0;
+ newRawPtr = nullptr;
}
assign_assuming_AddRef(static_cast<T*>(newRawPtr));
}
template<class T>
void
nsCOMPtr<T>::assign_from_helper(const nsCOMPtr_helper& helper, const nsIID& aIID)
{
void* newRawPtr;
if (NS_FAILED(helper(aIID, &newRawPtr))) {
- newRawPtr = 0;
+ newRawPtr = nullptr;
}
assign_assuming_AddRef(static_cast<T*>(newRawPtr));
}
template<class T>
void**
nsCOMPtr<T>::begin_assignment()
{
- assign_assuming_AddRef(0);
+ assign_assuming_AddRef(nullptr);
union
{
T** mT;
void** mVoid;
} result;
result.mT = &mRawPtr;
return result.mVoid;
}
@@ -1421,27 +1421,27 @@ CallQueryInterface(nsCOMPtr<SourceType>&
return CallQueryInterface(aSourcePtr.get(), aDestPtr);
}
template <class T>
RefPtr<T>::RefPtr(const nsCOMPtr_helper& aHelper)
{
void* newRawPtr;
if (NS_FAILED(aHelper(NS_GET_TEMPLATE_IID(T), &newRawPtr))) {
- newRawPtr = 0;
+ newRawPtr = nullptr;
}
mRawPtr = static_cast<T*>(newRawPtr);
}
template <class T>
RefPtr<T>&
RefPtr<T>::operator=(const nsCOMPtr_helper& aHelper)
{
void* newRawPtr;
if (NS_FAILED(aHelper(NS_GET_TEMPLATE_IID(T), &newRawPtr))) {
- newRawPtr = 0;
+ newRawPtr = nullptr;
}
assign_assuming_AddRef(static_cast<T*>(newRawPtr));
return *this;
}
#endif // !defined(nsCOMPtr_h___)