Bug 1045436 - Fix more bad implicit constructors in XPCOM; r=froydnj

This commit is contained in:
Ehsan Akhgari 2014-07-29 20:43:56 -04:00
parent 03e77dbb2f
commit 38ec6af068
26 changed files with 76 additions and 47 deletions

View File

@ -1812,7 +1812,7 @@ nsNPAPIPluginInstance::CheckJavaC2PJSObjectQuirk(uint16_t paramCount,
return;
}
mozilla::Version version = javaVersion.get();
mozilla::Version version(javaVersion.get());
if (version >= "1.7.0.4") {
return;

View File

@ -1388,8 +1388,8 @@ PromiseWorkerProxy::StoreISupports(nsISupports* aSupports)
{
MOZ_ASSERT(NS_IsMainThread());
nsMainThreadPtrHandle<nsISupports> supports =
new nsMainThreadPtrHolder<nsISupports>(aSupports);
nsMainThreadPtrHandle<nsISupports> supports(
new nsMainThreadPtrHolder<nsISupports>(aSupports));
mSupportsArray.AppendElement(supports);
}

View File

@ -416,8 +416,8 @@ protected:
// Point WorkerDataStoreCursor to DataStoreCursor.
nsRefPtr<DataStoreCursor> cursor = mBackingStore->Sync(mRevisionId, mRv);
nsMainThreadPtrHandle<DataStoreCursor> backingCursor =
new nsMainThreadPtrHolder<DataStoreCursor>(cursor);
nsMainThreadPtrHandle<DataStoreCursor> backingCursor(
new nsMainThreadPtrHolder<DataStoreCursor>(cursor));
mWorkerCursor->SetBackingDataStoreCursor(backingCursor);
return true;

View File

@ -122,7 +122,7 @@ GetDataStoresStructuredCloneCallbacksRead(JSContext* aCx,
{
nsRefPtr<WorkerDataStore> workerStore =
new WorkerDataStore(workerPrivate->GlobalScope());
nsMainThreadPtrHandle<DataStore> backingStore = dataStoreholder;
nsMainThreadPtrHandle<DataStore> backingStore(dataStoreholder);
// When we're on the worker thread, prepare a DataStoreChangeEventProxy.
nsRefPtr<DataStoreChangeEventProxy> eventProxy =

View File

@ -261,8 +261,8 @@ public:
return;
}
nsMainThreadPtrHandle<ServiceWorkerUpdateInstance> handle =
new nsMainThreadPtrHolder<ServiceWorkerUpdateInstance>(this);
nsMainThreadPtrHandle<ServiceWorkerUpdateInstance> handle(
new nsMainThreadPtrHolder<ServiceWorkerUpdateInstance>(this));
// FIXME(nsm): Deal with error case (worker failed to download, redirect,
// parse) in error handler patch.
nsRefPtr<FinishSuccessfulFetchWorkerRunnable> r =
@ -1009,8 +1009,8 @@ ServiceWorkerManager::Install(ServiceWorkerRegistration* aRegistration,
InvalidateServiceWorkerContainerWorker(aRegistration,
WhichServiceWorker::INSTALLING_WORKER);
nsMainThreadPtrHandle<ServiceWorkerRegistration> handle =
new nsMainThreadPtrHolder<ServiceWorkerRegistration>(aRegistration);
nsMainThreadPtrHandle<ServiceWorkerRegistration> handle(
new nsMainThreadPtrHolder<ServiceWorkerRegistration>(aRegistration));
nsRefPtr<ServiceWorker> serviceWorker;
nsresult rv =
@ -1085,8 +1085,8 @@ public:
return rv;
}
nsMainThreadPtrHandle<ServiceWorkerRegistration> handle =
new nsMainThreadPtrHolder<ServiceWorkerRegistration>(mRegistration);
nsMainThreadPtrHandle<ServiceWorkerRegistration> handle(
new nsMainThreadPtrHolder<ServiceWorkerRegistration>(mRegistration));
nsRefPtr<ActivateEventRunnable> r =
new ActivateEventRunnable(serviceWorker->GetWorkerPrivate(), handle);

View File

@ -32,8 +32,8 @@ class NotifyObserverRunnable : public nsRunnable
public:
NotifyObserverRunnable(nsIObserver * observer,
const char * topicStringLiteral)
: mObserver(), mTopic(topicStringLiteral) {
mObserver = new nsMainThreadPtrHolder<nsIObserver>(observer);
: mObserver(new nsMainThreadPtrHolder<nsIObserver>(observer)),
mTopic(topicStringLiteral) {
}
NS_DECL_NSIRUNNABLE
private:

View File

@ -321,7 +321,7 @@ public:
// For returning a smart reference from a raw reference that must be
// released. Explicit construction is required so as not to risk
// unintentionally releasing the resource associated with a raw ref.
explicit nsReturnRef(RawRefOnly aRefToRelease)
MOZ_IMPLICIT nsReturnRef(RawRefOnly aRefToRelease)
: BaseClass(aRefToRelease)
{
}
@ -332,7 +332,7 @@ public:
{
}
nsReturnRef(const nsReturningRef<T>& aReturning)
MOZ_IMPLICIT nsReturnRef(const nsReturningRef<T>& aReturning)
: BaseClass(aReturning)
{
}
@ -513,7 +513,7 @@ protected:
}
// Construct with a handle to a resource.
// A specialization must provide this.
nsSimpleRef(RawRef aRawRef)
explicit nsSimpleRef(RawRef aRawRef)
: mRawRef(aRawRef)
{
}
@ -567,7 +567,7 @@ protected:
class RawRefOnly
{
public:
RawRefOnly(RawRef aRawRef)
MOZ_IMPLICIT RawRefOnly(RawRef aRawRef)
: mRawRef(aRawRef)
{
}

View File

@ -107,7 +107,7 @@ class GenericModule MOZ_FINAL : public nsIModule
~GenericModule() {}
public:
GenericModule(const mozilla::Module* aData)
explicit GenericModule(const mozilla::Module* aData)
: mData(aData)
{
}

View File

@ -25,7 +25,7 @@ public:
this->size = sizeof(*this);
}
ScopedAppData(const nsXREAppData* aAppData);
explicit ScopedAppData(const nsXREAppData* aAppData);
void Zero() { memset(this, 0, sizeof(*this)); }

View File

@ -271,7 +271,7 @@ static const uint32_t CPU_TYPE = CPU_TYPE_POWERPC64;
class ScopedMMap
{
public:
ScopedMMap(const char* aFilePath)
explicit ScopedMMap(const char* aFilePath)
: buf(nullptr)
{
fd = open(aFilePath, O_RDONLY);

View File

@ -28,7 +28,7 @@ public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIFACTORY
GenericFactory(ConstructorProcPtr aCtor)
explicit GenericFactory(ConstructorProcPtr aCtor)
: mCtor(aCtor)
{
NS_ASSERTION(mCtor, "GenericFactory with no constructor");

View File

@ -41,7 +41,7 @@ public:
* ReentrantMonitor
* @param aName A name which can reference this monitor
*/
ReentrantMonitor(const char* aName)
explicit ReentrantMonitor(const char* aName)
: BlockingResourceBase(aName, eReentrantMonitor)
#ifdef DEBUG
, mEntryCount(0)
@ -173,7 +173,7 @@ public:
*
* @param aReentrantMonitor A valid mozilla::ReentrantMonitor*.
**/
ReentrantMonitorAutoEnter(mozilla::ReentrantMonitor& aReentrantMonitor)
explicit ReentrantMonitorAutoEnter(mozilla::ReentrantMonitor& aReentrantMonitor)
: mReentrantMonitor(&aReentrantMonitor)
{
NS_ASSERTION(mReentrantMonitor, "null monitor");
@ -222,7 +222,7 @@ public:
* @param aReentrantMonitor A valid mozilla::ReentrantMonitor*. It
* must be already locked.
**/
ReentrantMonitorAutoExit(ReentrantMonitor& aReentrantMonitor)
explicit ReentrantMonitorAutoExit(ReentrantMonitor& aReentrantMonitor)
: mReentrantMonitor(&aReentrantMonitor)
{
NS_ASSERTION(mReentrantMonitor, "null monitor");

View File

@ -24,7 +24,7 @@ public:
NS_DECL_NSISIMPLEENUMERATOR
// nsSimpleArrayEnumerator methods
nsSimpleArrayEnumerator(nsIArray* aValueArray)
explicit nsSimpleArrayEnumerator(nsIArray* aValueArray)
: mValueArray(aValueArray)
, mIndex(0)
{

View File

@ -27,7 +27,7 @@ class NS_COM_GLUE nsCategoryObserver MOZ_FINAL : public nsIObserver
~nsCategoryObserver();
public:
nsCategoryObserver(const char* aCategory);
explicit nsCategoryObserver(const char* aCategory);
void ListenerDied();
nsInterfaceHashtable<nsCStringHashKey, nsISupports>& GetHash()

View File

@ -105,7 +105,7 @@ public:
NS_IMETHOD HasMoreElements(bool* aResult);
NS_IMETHOD GetNext(nsISupports** aResult);
nsSingletonEnumerator(nsISupports* aValue);
explicit nsSingletonEnumerator(nsISupports* aValue);
private:
~nsSingletonEnumerator();

View File

@ -46,7 +46,7 @@ TS_tfopen(const char* aPath, const char* aMode)
class AutoFILE
{
public:
AutoFILE(FILE* aFp = nullptr) : fp_(aFp) {}
explicit AutoFILE(FILE* aFp = nullptr) : fp_(aFp) {}
~AutoFILE()
{
if (fp_) {
@ -95,7 +95,7 @@ nsresult
nsINIParser::Init(const char* aPath)
{
/* open the file */
AutoFILE fd = TS_tfopen(aPath, READ_BINARYMODE);
AutoFILE fd(TS_tfopen(aPath, READ_BINARYMODE));
if (!fd) {
return NS_ERROR_FAILURE;
}

View File

@ -11,7 +11,7 @@
class nsProxyReleaseEvent : public nsRunnable
{
public:
nsProxyReleaseEvent(nsISupports* aDoomed) : mDoomed(aDoomed) {}
explicit nsProxyReleaseEvent(nsISupports* aDoomed) : mDoomed(aDoomed) {}
NS_IMETHOD Run()
{

View File

@ -177,7 +177,7 @@ class nsMainThreadPtrHandle
public:
nsMainThreadPtrHandle() : mPtr(nullptr) {}
nsMainThreadPtrHandle(nsMainThreadPtrHolder<T>* aHolder) : mPtr(aHolder) {}
explicit nsMainThreadPtrHandle(nsMainThreadPtrHolder<T>* aHolder) : mPtr(aHolder) {}
nsMainThreadPtrHandle(const nsMainThreadPtrHandle& aOther)
: mPtr(aOther.mPtr)
{
@ -187,6 +187,11 @@ public:
mPtr = aOther.mPtr;
return *this;
}
nsMainThreadPtrHandle& operator=(nsMainThreadPtrHolder<T>* aHolder)
{
mPtr = aHolder;
return *this;
}
// These all call through to nsMainThreadPtrHolder, and thus implicitly
// assert that we're on the main thread. Off-main-thread consumers must treat

View File

@ -1307,7 +1307,7 @@ class nsGetterCopies
public:
typedef char16_t char_type;
nsGetterCopies(nsString& aStr)
explicit nsGetterCopies(nsString& aStr)
: mString(aStr)
, mData(nullptr)
{
@ -1333,7 +1333,7 @@ class nsCGetterCopies
public:
typedef char char_type;
nsCGetterCopies(nsCString& aStr)
explicit nsCGetterCopies(nsCString& aStr)
: mString(aStr)
, mData(nullptr)
{

View File

@ -311,7 +311,7 @@ public:
typedef nsAutoTObserverArray<T, N> array_type;
typedef Iterator base_type;
ForwardIterator(const array_type& aArray)
explicit ForwardIterator(const array_type& aArray)
: Iterator(0, aArray)
{
}
@ -354,7 +354,7 @@ public:
typedef nsAutoTObserverArray<T, N> array_type;
typedef Iterator base_type;
EndLimitedIterator(const array_type& aArray)
explicit EndLimitedIterator(const array_type& aArray)
: ForwardIterator(aArray)
, mEnd(aArray, aArray.Length())
{
@ -391,7 +391,7 @@ public:
typedef nsAutoTObserverArray<T, N> array_type;
typedef Iterator base_type;
BackwardIterator(const array_type& aArray)
explicit BackwardIterator(const array_type& aArray)
: Iterator(aArray.Length(), aArray)
{
}

View File

@ -171,7 +171,7 @@ private:
int mCnt;
Type* mObj;
Inner(Type* aObj)
explicit Inner(Type* aObj)
: mCnt(1)
, mObj(aObj)
{

View File

@ -274,7 +274,7 @@ class nsNameThreadRunnable MOZ_FINAL : public nsIRunnable
~nsNameThreadRunnable() {}
public:
nsNameThreadRunnable(const nsACString& aName) : mName(aName) {}
explicit nsNameThreadRunnable(const nsACString& aName) : mName(aName) {}
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIRUNNABLE

View File

@ -51,7 +51,7 @@ int32_t NS_COM_GLUE CompareVersions(const char16_t* aStrA, const char16_t* aStrB
struct NS_COM_GLUE Version
{
Version(const char* aVersionString)
explicit Version(const char* aVersionString)
{
versionContent = strdup(aVersionString);
}
@ -90,6 +90,30 @@ struct NS_COM_GLUE Version
{
return CompareVersions(versionContent, aRhs.ReadContent()) != 0;
}
bool operator<(const char* aRhs) const
{
return CompareVersions(versionContent, aRhs) == -1;
}
bool operator<=(const char* aRhs) const
{
return CompareVersions(versionContent, aRhs) < 1;
}
bool operator>(const char* aRhs) const
{
return CompareVersions(versionContent, aRhs) == 1;
}
bool operator>=(const char* aRhs) const
{
return CompareVersions(versionContent, aRhs) > -1;
}
bool operator==(const char* aRhs) const
{
return CompareVersions(versionContent, aRhs) == 0;
}
bool operator!=(const char* aRhs) const
{
return CompareVersions(versionContent, aRhs) != 0;
}
private:
char* versionContent;

View File

@ -30,7 +30,7 @@ class NS_COM_GLUE nsVoidArray
{
public:
nsVoidArray();
nsVoidArray(int32_t aCount); // initial count of aCount elements set to nullptr
explicit nsVoidArray(int32_t aCount); // initial count of aCount elements set to nullptr
~nsVoidArray();
nsVoidArray& operator=(const nsVoidArray& aOther);

View File

@ -24,7 +24,7 @@ public:
private:
friend class nsSupportsWeakReference;
nsWeakReference(nsSupportsWeakReference* aReferent)
explicit nsWeakReference(nsSupportsWeakReference* aReferent)
: mReferent(aReferent)
// ...I can only be constructed by an |nsSupportsWeakReference|
{

View File

@ -23,10 +23,10 @@ class nsXPTType : public XPTTypeDescriptorPrefix
public:
nsXPTType()
{} // random contents
nsXPTType(const XPTTypeDescriptorPrefix& prefix)
MOZ_IMPLICIT nsXPTType(const XPTTypeDescriptorPrefix& prefix)
{*(XPTTypeDescriptorPrefix*)this = prefix;}
nsXPTType(const uint8_t& prefix)
MOZ_IMPLICIT nsXPTType(const uint8_t& prefix)
{*(uint8_t*)this = prefix;}
nsXPTType& operator=(uint8_t val)
@ -124,7 +124,7 @@ class nsXPTParamInfo : public XPTParamDescriptor
{
// NO DATA - this a flyweight wrapper
public:
nsXPTParamInfo(const XPTParamDescriptor& desc)
MOZ_IMPLICIT nsXPTParamInfo(const XPTParamDescriptor& desc)
{*(XPTParamDescriptor*)this = desc;}
@ -183,7 +183,7 @@ class nsXPTMethodInfo : public XPTMethodDescriptor
{
// NO DATA - this a flyweight wrapper
public:
nsXPTMethodInfo(const XPTMethodDescriptor& desc)
MOZ_IMPLICIT nsXPTMethodInfo(const XPTMethodDescriptor& desc)
{*(XPTMethodDescriptor*)this = desc;}
bool IsGetter() const {return 0 != (XPT_MD_IS_GETTER(flags) );}
@ -216,7 +216,7 @@ class nsXPTConstant : public XPTConstDescriptor
{
// NO DATA - this a flyweight wrapper
public:
nsXPTConstant(const XPTConstDescriptor& desc)
MOZ_IMPLICIT nsXPTConstant(const XPTConstDescriptor& desc)
{*(XPTConstDescriptor*)this = desc;}
const char* GetName() const