Skip to content

Commit

Permalink
Bug 1329857 - Remove NS_METHOD and NS_CALLBACK. r=froydnj.
Browse files Browse the repository at this point in the history
Bug 1295053 removed most uses of NS_METHOD and NS_CALLBACK, but one use was
unintentionally left behind (in the XPIDL parser) and another has since crept
in (in MediaDrmCDMProxy.h).

So this patch removes NS_METHOD and NS_CALLBACK. NS_METHOD_(nsresult) and
NS_CALLBACK_(nsresult, T) can still be used for the same purpose, but those
alternatives are less likely to be used unintentionally.

--HG--
extra : rebase_source : a50fc7b2a64a36d1ca9beda81bc0edb8f2ec1934
  • Loading branch information
nnethercote committed Jan 10, 2017
1 parent 2b6f1ff commit 949658e
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions dom/media/eme/mediadrm/MediaDrmCDMProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class MediaDrmCDMProxy : public CDMProxy {
, mReason(aReason)
{
}
NS_METHOD Run() {
NS_IMETHOD Run() override {
mProxy->RejectPromise(mId, mCode, mReason);
return NS_OK;
}
Expand Down Expand Up @@ -182,4 +182,4 @@ class MediaDrmCDMProxy : public CDMProxy {

} // namespace mozilla

#endif // MediaDrmCDMProxy_h_
#endif // MediaDrmCDMProxy_h_
25 changes: 12 additions & 13 deletions xpcom/base/nscore.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@
#define NS_CONSTRUCTOR_FASTCALL
#endif

/**
* Various API modifiers.
*
* - NS_IMETHOD/NS_IMETHOD_: use for in-class declarations and definitions.
* - NS_IMETHODIMP/NS_IMETHODIMP_: use for out-of-class definitions.
* - NS_METHOD_: usually used in conjunction with NS_CALLBACK_. Best avoided.
* - NS_CALLBACK_: used in some legacy situations. Best avoided.
*/

#ifdef XP_WIN

#define NS_IMPORT __declspec(dllimport)
Expand Down Expand Up @@ -121,6 +130,9 @@

#endif

#define NS_IMETHOD NS_IMETHOD_(nsresult)
#define NS_IMETHODIMP NS_IMETHODIMP_(nsresult)

/**
* Macro for creating typedefs for pointer-to-member types which are
* declared with stdcall. It is important to use this for any type which is
Expand Down Expand Up @@ -159,19 +171,6 @@
# define MOZ_DEPRECATED
#endif

/**
* Generic API modifiers which return the standard XPCOM nsresult type
*
* - NS_IMETHOD: use for in-class declarations and definitions.
* - NS_IMETHODIMP: use for out-of-class definitions.
* - NS_METHOD: usually used in conjunction with NS_CALLBACK.
* - NS_CALLBACK: used in some legacy situations. Best avoided.
*/
#define NS_IMETHOD NS_IMETHOD_(nsresult)
#define NS_IMETHODIMP NS_IMETHODIMP_(nsresult)
#define NS_METHOD NS_METHOD_(nsresult)
#define NS_CALLBACK(_name) NS_CALLBACK_(nsresult, _name)

/**
* Import/Export macros for XPCOM APIs
*/
Expand Down
2 changes: 1 addition & 1 deletion xpcom/build/nsXPCOMPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ typedef void (*CycleCollectorSuspect3Func)(void*,
nsCycleCollectingAutoRefCnt*,
bool*);
// PRIVATE AND DEPRECATED
typedef NS_CALLBACK(XPCOMExitRoutine)(void);
typedef NS_CALLBACK_(nsresult, XPCOMExitRoutine)(void);

typedef nsresult (*RegisterXPCOMExitRoutineFunc)(XPCOMExitRoutine aExitRoutine,
uint32_t aPriority);
Expand Down
7 changes: 4 additions & 3 deletions xpcom/glue/nsIClassInfoImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ class GenericClassInfo : public nsIClassInfo
public:
struct ClassInfoData
{
// This function pointer uses NS_CALLBACK because it's always set to an
// This function pointer uses NS_CALLBACK_ because it's always set to an
// NS_IMETHOD function, which uses __stdcall on Win32.
typedef NS_CALLBACK(GetInterfacesProc)(uint32_t* aCountP, nsIID*** aArray);
typedef NS_CALLBACK_(nsresult, GetInterfacesProc)(uint32_t* aCountP,
nsIID*** aArray);
GetInterfacesProc getinterfaces;

// This function pointer doesn't use NS_CALLBACK because it's always set to
// This function pointer doesn't use NS_CALLBACK_ because it's always set to
// a vanilla function.
typedef nsresult (*GetScriptableHelperProc)(nsIXPCScriptable** aHelper);
GetScriptableHelperProc getscriptablehelper;
Expand Down
2 changes: 1 addition & 1 deletion xpcom/idl-parser/xpidl/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def write_attr_decl(a):
fd.write(iface_epilog % names)

def writeDeclaration(fd, iface, virtual):
declType = "NS_IMETHOD" if virtual else "NS_METHOD"
declType = "NS_IMETHOD" if virtual else "nsresult"
suffix = " override" if virtual else ""
for member in iface.members:
if isinstance(member, xpidl.Attribute):
Expand Down
28 changes: 14 additions & 14 deletions xpcom/threads/nsTimerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ nsTimerImpl::InitWithFuncCallbackCommon(nsTimerCallbackFunc aFunc,
return InitCommon(aDelay, aType);
}

NS_IMETHODIMP
nsresult
nsTimerImpl::InitWithFuncCallback(nsTimerCallbackFunc aFunc,
void* aClosure,
uint32_t aDelay,
Expand All @@ -253,7 +253,7 @@ nsTimerImpl::InitWithFuncCallback(nsTimerCallbackFunc aFunc,
return InitWithFuncCallbackCommon(aFunc, aClosure, aDelay, aType, name);
}

NS_IMETHODIMP
nsresult
nsTimerImpl::InitWithNamedFuncCallback(nsTimerCallbackFunc aFunc,
void* aClosure,
uint32_t aDelay,
Expand All @@ -264,7 +264,7 @@ nsTimerImpl::InitWithNamedFuncCallback(nsTimerCallbackFunc aFunc,
return InitWithFuncCallbackCommon(aFunc, aClosure, aDelay, aType, name);
}

NS_IMETHODIMP
nsresult
nsTimerImpl::InitWithNameableFuncCallback(nsTimerCallbackFunc aFunc,
void* aClosure,
uint32_t aDelay,
Expand All @@ -275,7 +275,7 @@ nsTimerImpl::InitWithNameableFuncCallback(nsTimerCallbackFunc aFunc,
return InitWithFuncCallbackCommon(aFunc, aClosure, aDelay, aType, name);
}

NS_IMETHODIMP
nsresult
nsTimerImpl::InitWithCallback(nsITimerCallback* aCallback,
uint32_t aDelay,
uint32_t aType)
Expand All @@ -292,7 +292,7 @@ nsTimerImpl::InitWithCallback(nsITimerCallback* aCallback,
return InitCommon(aDelay, aType);
}

NS_IMETHODIMP
nsresult
nsTimerImpl::Init(nsIObserver* aObserver, uint32_t aDelay, uint32_t aType)
{
if (NS_WARN_IF(!aObserver)) {
Expand All @@ -307,7 +307,7 @@ nsTimerImpl::Init(nsIObserver* aObserver, uint32_t aDelay, uint32_t aType)
return InitCommon(aDelay, aType);
}

NS_IMETHODIMP
nsresult
nsTimerImpl::Cancel()
{

Expand All @@ -334,7 +334,7 @@ nsTimerImpl::Neuter()
++mGeneration;
}

NS_IMETHODIMP
nsresult
nsTimerImpl::SetDelay(uint32_t aDelay)
{
if (mCallbackType == CallbackType::Unknown && mType == nsITimer::TYPE_ONE_SHOT) {
Expand All @@ -359,14 +359,14 @@ nsTimerImpl::SetDelay(uint32_t aDelay)
return NS_OK;
}

NS_IMETHODIMP
nsresult
nsTimerImpl::GetDelay(uint32_t* aDelay)
{
*aDelay = mDelay;
return NS_OK;
}

NS_IMETHODIMP
nsresult
nsTimerImpl::SetType(uint32_t aType)
{
mType = (uint8_t)aType;
Expand All @@ -376,23 +376,23 @@ nsTimerImpl::SetType(uint32_t aType)
return NS_OK;
}

NS_IMETHODIMP
nsresult
nsTimerImpl::GetType(uint32_t* aType)
{
*aType = mType;
return NS_OK;
}


NS_IMETHODIMP
nsresult
nsTimerImpl::GetClosure(void** aClosure)
{
*aClosure = mClosure;
return NS_OK;
}


NS_IMETHODIMP
nsresult
nsTimerImpl::GetCallback(nsITimerCallback** aCallback)
{
if (mCallbackType == CallbackType::Interface) {
Expand All @@ -405,15 +405,15 @@ nsTimerImpl::GetCallback(nsITimerCallback** aCallback)
}


NS_IMETHODIMP
nsresult
nsTimerImpl::GetTarget(nsIEventTarget** aTarget)
{
NS_IF_ADDREF(*aTarget = mEventTarget);
return NS_OK;
}


NS_IMETHODIMP
nsresult
nsTimerImpl::SetTarget(nsIEventTarget* aTarget)
{
if (NS_WARN_IF(mCallbackType != CallbackType::Unknown)) {
Expand Down

0 comments on commit 949658e

Please sign in to comment.